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