ownclouddolphinpluginhelper.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /******************************************************************************
  2. * Copyright (C) 2014 by Olivier Goffart <ogoffart@woboq.com *
  3. * *
  4. * This program is free software; you can redistribute it and/or modify *
  5. * it under the terms of the GNU General Public License as published by *
  6. * the Free Software Foundation; either version 2 of the License, or *
  7. * (at your option) any later version. *
  8. * *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * *
  14. * You should have received a copy of the GNU General Public License *
  15. * along with this program; if not, write to the *
  16. * Free Software Foundation, Inc., *
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
  18. ******************************************************************************/
  19. #pragma once
  20. #include <QObject>
  21. #include <QBasicTimer>
  22. #include <QLocalSocket>
  23. #include <QRegularExpression>
  24. #include "ownclouddolphinpluginhelper_export.h"
  25. #include "config.h"
  26. class OWNCLOUDDOLPHINPLUGINHELPER_EXPORT OwncloudDolphinPluginHelper : public QObject {
  27. Q_OBJECT
  28. public:
  29. static OwncloudDolphinPluginHelper *instance();
  30. [[nodiscard]] bool isConnected() const;
  31. void sendCommand(const char *data);
  32. [[nodiscard]] QVector<QString> paths() const { return _paths; }
  33. [[nodiscard]] QString contextMenuTitle() const
  34. {
  35. return _strings.value("CONTEXT_MENU_TITLE", APPLICATION_NAME);
  36. }
  37. [[nodiscard]] QString shareActionTitle() const
  38. {
  39. return _strings.value("SHARE_MENU_TITLE", "Share …");
  40. }
  41. [[nodiscard]] QString contextMenuIconName() const
  42. {
  43. return _strings.value("CONTEXT_MENU_ICON", APPLICATION_ICON_NAME);
  44. }
  45. [[nodiscard]] QString copyPrivateLinkTitle() const { return _strings["COPY_PRIVATE_LINK_MENU_TITLE"]; }
  46. [[nodiscard]] QString emailPrivateLinkTitle() const { return _strings["EMAIL_PRIVATE_LINK_MENU_TITLE"]; }
  47. QByteArray version() { return _version; }
  48. signals:
  49. void commandRecieved(const QByteArray &cmd);
  50. protected:
  51. void timerEvent(QTimerEvent*) override;
  52. private:
  53. OwncloudDolphinPluginHelper();
  54. void slotConnected();
  55. void slotReadyRead();
  56. void tryConnect();
  57. QLocalSocket _socket;
  58. QByteArray _line;
  59. QVector<QString> _paths;
  60. QBasicTimer _connectTimer;
  61. QMap<QString, QString> _strings;
  62. QByteArray _version;
  63. };