HelperLauncher.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // Created by Tobias Hieta on 28/08/15.
  3. //
  4. #ifndef KONVERGO_HELPERLAUNCHER_H
  5. #define KONVERGO_HELPERLAUNCHER_H
  6. #include <QLocalSocket>
  7. #include <QObject>
  8. #include <QProcess>
  9. #include <QJsonObject>
  10. #include "LocalJsonClient.h"
  11. #include "tools/helper/HelperSocket.h"
  12. #include "Version.h"
  13. #include "utils/Utils.h"
  14. #ifdef Q_OS_MAC
  15. #include "HelperLaunchd.h"
  16. #endif
  17. class HelperLauncher : public QObject
  18. {
  19. Q_OBJECT
  20. DEFINE_SINGLETON(HelperLauncher)
  21. public:
  22. bool connectToHelper();
  23. static QString HelperPath();
  24. void stop();
  25. void start();
  26. private Q_SLOTS:
  27. void gotMessage(const QVariantMap& message);
  28. void socketError(QLocalSocket::LocalSocketError error);
  29. void didConnect();
  30. void launch();
  31. void socketDisconnect();
  32. bool killHelper();
  33. private:
  34. explicit HelperLauncher(QObject* parent = nullptr);
  35. QProcess* m_helperProcess;
  36. LocalJsonClient* m_jsonClient;
  37. void updateClientId();
  38. bool helperEnabled();
  39. #ifdef Q_OS_MAC
  40. HelperLaunchd* m_launchd;
  41. #endif
  42. };
  43. #endif //KONVERGO_HELPERLAUNCHER_H