From 89b22e0b1d1b389e1170e8d986d8018d6a534c03 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 6 Apr 2007 22:54:06 +0000 Subject: [PATCH] Active patch from pompase --- mvpclient.c | 31 ++++++++++++++++++++++++++++++- mvpclient.h | 6 ++++++ mvpserver.c | 4 ++++ vompserver.c | 8 ++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/mvpclient.c b/mvpclient.c index b10282d..fb7e34b 100644 --- a/mvpclient.c +++ b/mvpclient.c @@ -21,7 +21,11 @@ #include "mvpclient.h" // This is here else it causes compile errors with something in libdvbmpeg -#include +//#include + +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 diff --git a/mvpclient.h b/mvpclient.h index 296f795..885a328 100644 --- a/mvpclient.h +++ b/mvpclient.h @@ -33,6 +33,7 @@ #include #include #include +#include #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(); diff --git a/mvpserver.c b/mvpserver.c index 15c0f2c..f1ce562 100644 --- a/mvpserver.c +++ b/mvpserver.c @@ -20,8 +20,12 @@ #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() diff --git a/vompserver.c b/vompserver.c index 4e209eb..2374730 100644 --- a/vompserver.c +++ b/vompserver.c @@ -22,6 +22,7 @@ #include #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! -- 2.39.2