]> git.vomp.tv Git - vompserver.git/commitdiff
Active patch from pompase
authorChris Tallon <chris@vomp.tv>
Fri, 6 Apr 2007 22:54:06 +0000 (22:54 +0000)
committerChris Tallon <chris@vomp.tv>
Fri, 6 Apr 2007 22:54:06 +0000 (22:54 +0000)
mvpclient.c
mvpclient.h
mvpserver.c
vompserver.c

index b10282d24aa8059f8e64de7a961e0914d10b756f..fb7e34b7a0547bd03125ec81cb605e31b2366694 100644 (file)
 #include "mvpclient.h"
 
 // This is here else it causes compile errors with something in libdvbmpeg
-#include <vdr/menu.h>
+//#include <vdr/menu.h>
+
+pthread_mutex_t threadClientMutex;
+int MVPClient::nr_clients = 0;
+
 
 MVPClient::MVPClient(char* tconfigDirExtra, int tsocket)
  : tcp(tsocket)
@@ -32,6 +36,7 @@ MVPClient::MVPClient(char* tconfigDirExtra, int tsocket)
   log = Log::getInstance();
   loggedIn = false;
   configDirExtra = tconfigDirExtra;
+  incClients();
 }
 
 MVPClient::~MVPClient()
@@ -53,6 +58,7 @@ MVPClient::~MVPClient()
   }
 
   if (loggedIn) cleanConfig();
+  decClients();
 }
 
 ULLONG MVPClient::ntohll(ULLONG a)
@@ -1631,6 +1637,29 @@ int MVPClient::processSetTimer(UCHAR* buffer, int length)
   return 1;
 }
 
+void MVPClient::incClients()
+{
+  pthread_mutex_lock(&threadClientMutex);
+  MVPClient::nr_clients++;
+  pthread_mutex_unlock(&threadClientMutex);
+}
+
+void MVPClient::decClients()
+{
+  pthread_mutex_lock(&threadClientMutex);
+  MVPClient::nr_clients--;
+  pthread_mutex_unlock(&threadClientMutex);
+}
+
+int MVPClient::getNrClients()
+{
+  int nrClients;
+  pthread_mutex_lock(&threadClientMutex);
+  nrClients = MVPClient::nr_clients;
+  pthread_mutex_unlock(&threadClientMutex);
+  return nrClients;
+}
+
 int MVPClient::processGetRecInfo(UCHAR* data, int length)
 {
   // data is a pointer to the fileName string
index 296f79573aa501ffe06324193a2f8eccb542aa1e..885a3282c4e3fa4ef936b52ef650b604aa3da375 100644 (file)
@@ -33,6 +33,7 @@
 #include <vdr/videodir.h>
 #include <vdr/plugin.h>
 #include <vdr/timers.h>
+#include <vdr/menu.h>
 
 #include "defines.h"
 #include "tcp.h"
@@ -49,8 +50,10 @@ class MVPClient
     int run();
     // not for external use
     void run2();
+    static int getNrClients();
 
   private:
+    static int nr_clients;
     pthread_t runThread;
     int initted;
     TCP tcp;
@@ -87,6 +90,9 @@ class MVPClient
 
     int processReScanRecording(UCHAR* data, int length);           // FIXME obselete
 
+    void incClients();
+    void decClients();
+
     cChannel* channelFromNumber(ULONG channelNumber);
     void writeResumeData();
     void cleanConfig();
index 15c0f2cda43714889b4344019ab5244a8cd17b47..f1ce5622adb31db6f48f8fe298a48419a62b29c9 100644 (file)
 
 #include "mvpserver.h"
 
+extern pthread_mutex_t threadClientMutex;
+
 MVPServer::MVPServer()
 {
+  // MH in case anbody has a better position :-)
+  pthread_mutex_init(&threadClientMutex, NULL);
 }
 
 MVPServer::~MVPServer()
index 4e209eb922ea2031ac831abb2e794d6eb10468d5..23747306519b25b17c6305ebedf6b085b385c99c 100644 (file)
@@ -22,6 +22,7 @@
 #include <getopt.h>
 
 #include "mvpserver.h"
+#include "mvpclient.h"
 
 static const char *VERSION        = "0.2.6";
 static const char *DESCRIPTION    = "VDR on MVP plugin by Chris Tallon";
@@ -38,6 +39,7 @@ public:
   virtual bool Initialize(void);
   virtual bool Start(void);
   virtual bool SetupParse(const char *Name, const char *Value);
+  virtual cString Active(void);
 
 private:
 
@@ -107,5 +109,11 @@ bool cPluginVompserver::SetupParse(const char *Name, const char *Value)
   return false;
 }
 
+cString cPluginVompserver::Active(void)
+{
+  if(MVPClient::getNrClients() != 0) return tr("VOMP client(s) connected");
+  return NULL;
+}
+
 VDRPLUGINCREATOR(cPluginVompserver); // Don't touch this!