SystemComponent.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef __SYSTEM_COMPONENT_H__
  2. #define __SYSTEM_COMPONENT_H__
  3. #include "ComponentManager.h"
  4. #include <QTimer>
  5. #include "utils/Utils.h"
  6. #include "Paths.h"
  7. #include "Names.h"
  8. // System modifiers
  9. #define SYSTEM_MODIFIER_OPENELEC "OpenELEC"
  10. class SystemComponent : public ComponentBase
  11. {
  12. Q_OBJECT
  13. DEFINE_SINGLETON(SystemComponent);
  14. public:
  15. virtual bool componentExport() { return true; }
  16. virtual const char* componentName() { return "system"; }
  17. virtual bool componentInitialize();
  18. virtual void componentPostInitialize();
  19. Q_INVOKABLE QVariantMap systemInformation() const;
  20. Q_INVOKABLE void exit();
  21. Q_INVOKABLE static void restart();
  22. Q_INVOKABLE void info(QString text);
  23. Q_INVOKABLE void setCursorVisibility(bool visible);
  24. Q_INVOKABLE QString getUserAgent();
  25. Q_INVOKABLE QString debugInformation();
  26. Q_INVOKABLE QStringList networkAddresses() const;
  27. Q_INVOKABLE int networkPort() const;
  28. Q_INVOKABLE void userInformation(const QVariantMap& userModel);
  29. Q_INVOKABLE void openExternalUrl(const QString& url);
  30. Q_INVOKABLE void runUserScript(QString script);
  31. // possible os types type enum
  32. enum PlatformType
  33. {
  34. platformTypeUnknown,
  35. platformTypeOsx,
  36. platformTypeWindows,
  37. platformTypeLinux,
  38. platformTypeOpenELEC
  39. };
  40. // possible values for target types
  41. enum PlatformArch
  42. {
  43. platformArchUnknown,
  44. platformArchX86_32,
  45. platformArchX86_64,
  46. platformArchRpi2
  47. };
  48. inline PlatformType getPlatformType() { return m_platformType; }
  49. inline PlatformArch getPlatformArch() { return m_platformArch; }
  50. QString getPlatformTypeString() const;
  51. QString getPlatformArchString() const;
  52. inline bool isOpenELEC() { return m_platformType == platformTypeOpenELEC; }
  53. Q_INVOKABLE void crashApp();
  54. signals:
  55. void hostMessage(const QString& message);
  56. void scaleChanged(qreal scale);
  57. private:
  58. SystemComponent(QObject* parent = 0);
  59. static QMap<QString, QString> networkInterfaces();
  60. QTimer* m_mouseOutTimer;
  61. PlatformType m_platformType;
  62. PlatformArch m_platformArch;
  63. QString m_overridePlatform;
  64. bool m_doLogMessages;
  65. };
  66. #endif