00001 #ifndef ZMCLIENT_H_
00002 #define ZMCLIENT_H_
00003
00004 using namespace std;
00005
00006 #include <iostream>
00007
00008
00009 #include <qobject.h>
00010 #include <qstringlist.h>
00011 #include <qvaluevector.h>
00012 #include <qsocket.h>
00013 #include <qtimer.h>
00014 #include <qdatetime.h>
00015 #include <qmutex.h>
00016
00017
00018 #include "mythtv/mythsocket.h"
00019 #include "mythtv/mythexp.h"
00020
00021
00022 #include "zmdefines.h"
00023
00024 class MPUBLIC ZMClient : public QObject
00025 {
00026 Q_OBJECT
00027
00028 protected:
00029 ZMClient();
00030
00031 static bool m_server_unavailable;
00032 static class ZMClient *m_zmclient;
00033
00034 public:
00035 ~ZMClient();
00036
00037 static class ZMClient *get(void);
00038 static bool setupZMClient (void);
00039
00040
00041 bool connectToHost(const QString &hostname, unsigned int port);
00042 bool connected(void) { return m_bConnected; }
00043
00044 bool checkProtoVersion(void);
00045
00046
00047
00048 void shutdown();
00049
00050 void getServerStatus(QString &status, QString &cpuStat, QString &diskStat);
00051 void getMonitorStatus(vector<Monitor*> *monitorList);
00052 void getEventList(const QString &monitorName, bool oldestFirst,
00053 QString date, vector<Event*> *eventList);
00054 void getEventFrame(int monitorID, int eventID, int frameNo, QImage &image);
00055 void getAnalyseFrame(int monitorID, int eventID, int frameNo, QImage &image);
00056 int getLiveFrame(int monitorID, QString &status, unsigned char* buffer, int bufferSize);
00057 void getFrameList(int eventID, vector<Frame*> *frameList);
00058 void deleteEvent(int eventID);
00059 void deleteEventList(vector<Event*> *eventList);
00060
00061 void getCameraList(QStringList &cameraList);
00062 void getMonitorList(vector<Monitor*> *monitorList);
00063 void getEventDates(const QString &monitorName, bool oldestFirst,
00064 QStringList &dateList);
00065 void setMonitorFunction(const int monitorID, const QString &function, const int enabled);
00066
00067 private slots:
00068 void restartConnection(void);
00069
00070 private:
00071 bool readData(unsigned char *data, int dataSize);
00072 bool sendReceiveStringList(QStringList &strList);
00073
00074 MythSocket *m_socket;
00075 QMutex m_socketLock;
00076 QString m_hostname;
00077 uint m_port;
00078 bool m_bConnected;
00079 QTimer *m_retryTimer;
00080 bool m_zmclientReady;
00081 };
00082
00083 #endif