00001 #ifndef NETWORKCONTROL_H_ 00002 #define NETWORKCONTROL_H_ 00003 00004 #include <pthread.h> 00005 00006 #include <qserversocket.h> 00007 #include <qsocket.h> 00008 #include <qdom.h> 00009 #include <qdatetime.h> 00010 #include <qstring.h> 00011 #include <qmap.h> 00012 #include <qmutex.h> 00013 #include <qvaluelist.h> 00014 #include <qwaitcondition.h> 00015 00016 class MainServer; 00017 00018 class NetworkControl : public QServerSocket 00019 { 00020 Q_OBJECT 00021 public: 00022 NetworkControl(int port); 00023 ~NetworkControl(); 00024 00025 void newConnection(int socket); 00026 00027 private slots: 00028 void readClient(); 00029 void discardClient(); 00030 00031 protected: 00032 static void *SocketThread(void *param); 00033 void RunSocketThread(void); 00034 static void *CommandThread(void *param); 00035 void RunCommandThread(void); 00036 00037 private: 00038 QString processJump(QStringList tokens); 00039 QString processKey(QStringList tokens); 00040 QString processLiveTV(QStringList tokens); 00041 QString processPlay(QStringList tokens); 00042 QString processQuery(QStringList tokens); 00043 QString processHelp(QStringList tokens); 00044 00045 void notifyDataAvailable(void); 00046 void customEvent(QCustomEvent *e); 00047 00048 QString listRecordings(QString chanid = "", QString starttime = ""); 00049 QString listSchedule(const QString& chanID = "") const; 00050 QString saveScreenshot(QStringList tokens); 00051 00052 void processNetworkControlCommand(QString command); 00053 00054 00055 QString prompt; 00056 bool gotAnswer; 00057 QString answer; 00058 QMap <QString, QString> jumpMap; 00059 QMap <QString, int> keyMap; 00060 00061 QMutex clientLock; 00062 QSocket *client; 00063 QTextStream *cs; 00064 00065 QValueList<QString> networkControlCommands; 00066 QMutex ncLock; 00067 QWaitCondition ncCond; 00068 00069 QValueList<QString> networkControlReplies; 00070 QMutex nrLock; 00071 00072 pthread_t command_thread; 00073 bool stopCommandThread; 00074 }; 00075 00076 #endif 00077 00078 /* vim: set expandtab tabstop=4 shiftwidth=4: */ 00079
1.5.5