Browse Source

Add a system.hello() call that takes version as argument

This should be called by the web-client when everything is inited on the web-side. It allows the host to start sending input events over to it.
Tobias Hieta 9 years ago
parent
commit
6421198a9f

+ 10 - 2
src/input/InputComponent.cpp

@@ -211,8 +211,16 @@ void InputComponent::remapInput(const QString &source, const QString &keycode, I
 
   if (!queuedActions.isEmpty())
   {
-    QLOG_DEBUG() << "Emit input action:" << queuedActions;
-    emit hostInput(queuedActions);
+    if (SystemComponent::Get().isWebClientConnected())
+    {
+      QLOG_DEBUG() << "Emit input action:" << queuedActions;
+      emit hostInput(queuedActions);
+    }
+    else
+    {
+      QLOG_DEBUG() << "Web Client has not connected, handling input in host instead.";
+      executeActions(queuedActions);
+    }
   }
 }
 

+ 1 - 1
src/settings/SettingsComponent.cpp

@@ -601,7 +601,7 @@ bool SettingsComponent::componentInitialize()
 /////////////////////////////////////////////////////////////////////////////////////////
 void SettingsComponent::setupVersion()
 {
-  QSettings settings("Plex", "Plex Media Player");
+  QSettings settings;
   m_oldestPreviousVersion = settings.value(OLDEST_PREVIOUS_VERSION_KEY).toString();
   if (m_oldestPreviousVersion.isEmpty())
   {

+ 9 - 0
src/system/SystemComponent.cpp

@@ -314,3 +314,12 @@ void SystemComponent::runUserScript(QString script)
   }
 }
 
+/////////////////////////////////////////////////////////////////////////////////////////
+void SystemComponent::hello(const QString& version)
+{
+  QLOG_DEBUG() << QString("Web-client (%1) fully inited.").arg(version);
+  m_webClientVersion = version;
+}
+
+
+

+ 6 - 3
src/system/SystemComponent.h

@@ -42,6 +42,9 @@ public:
 
   Q_INVOKABLE void runUserScript(QString script);
 
+  // called by the web-client when everything is properly inited
+  Q_INVOKABLE void hello(const QString& version);
+
   // possible os types type enum
   enum PlatformType
   {
@@ -67,7 +70,8 @@ public:
   QString getPlatformTypeString() const;
   QString getPlatformArchString() const;
 
-  inline bool isOpenELEC() { return m_platformType == platformTypeOpenELEC; }
+  inline bool isOpenELEC() const { return m_platformType == platformTypeOpenELEC; }
+  bool isWebClientConnected() const { return !m_webClientVersion.isEmpty(); }
 
   inline QString authenticationToken() { return m_authenticationToken; }
 
@@ -85,10 +89,9 @@ private:
   QTimer* m_mouseOutTimer;
   PlatformType m_platformType;
   PlatformArch m_platformArch;
-  QString m_overridePlatform;
   bool m_doLogMessages;
   QString m_authenticationToken;
-
+  QString m_webClientVersion;
 };
 
 #endif