MythTV  master
zmclient.h
Go to the documentation of this file.
1 #ifndef ZMCLIENT_H_
2 #define ZMCLIENT_H_
3 
4 #include <iostream>
5 #include <vector>
6 using namespace std;
7 
8 // myth
9 #include <mythsocket.h>
10 #include <mythexp.h>
11 #include <mythimage.h>
12 
13 // zm
14 #include "zmdefines.h"
15 
16 class MPUBLIC ZMClient : public QObject
17 {
18  Q_OBJECT
19 
20  protected:
21  ZMClient();
22 
24 
25  public:
26  ~ZMClient();
27 
28  static ZMClient *get(void);
29  static bool setupZMClient (void);
30 
31  void customEvent(QEvent *event) override; // QObject
32 
33  // Used to actually connect to an ZM server
34  bool connectToHost(const QString &hostname, unsigned int port);
35  bool connected(void) { return m_bConnected; }
36 
37  bool checkProtoVersion(void);
38 
39  // If you want to be pleasant, call shutdown() before deleting your ZMClient
40  // device
41  void shutdown();
42 
43  void getServerStatus(QString &status, QString &cpuStat, QString &diskStat);
44  void updateMonitorStatus(void);
45  void getEventList(const QString &monitorName, bool oldestFirst,
46  const QString &date, bool includeContinuous, vector<Event*> *eventList);
47  void getEventFrame(Event *event, int frameNo, MythImage **image);
48  void getAnalyseFrame(Event *event, int frameNo, QImage &image);
49  int getLiveFrame(int monitorID, QString &status, unsigned char* buffer, int bufferSize);
50  void getFrameList(int eventID, vector<Frame*> *frameList);
51  void deleteEvent(int eventID);
52  void deleteEventList(vector<Event*> *eventList);
53 
54  int getMonitorCount(void);
55  Monitor* getMonitorAt(int pos);
56  Monitor* getMonitorByID(int monID);
57 
58  void getCameraList(QStringList &cameraList);
59  void getEventDates(const QString &monitorName, bool oldestFirst,
60  QStringList &dateList);
61  void setMonitorFunction(const int monitorID, const QString &function, const bool enabled);
62  bool updateAlarmStates(void);
63 
64  bool isMiniPlayerEnabled(void) { return m_isMiniPlayerEnabled; }
65  void setIsMiniPlayerEnabled(bool enabled) { m_isMiniPlayerEnabled = enabled; }
66 
67  void saveNotificationMonitors(void);
68  void showMiniPlayer(int monitorID);
69 
70  private slots:
71  void restartConnection(void); // Try to re-establish the connection to
72  // ZMServer every 10 seconds
73  private:
74  void doGetMonitorList(void);
75  bool readData(unsigned char *data, int dataSize);
76  bool sendReceiveStringList(QStringList &strList);
77 
78  QMutex m_listLock {QMutex::Recursive};
79  QMutex m_commandLock {QMutex::Recursive};
80  QList<Monitor*> m_monitorList;
81  QMap<int, Monitor*> m_monitorMap;
82 
83  MythSocket *m_socket {nullptr};
84  QMutex m_socketLock {QMutex::Recursive};
85  QString m_hostname {"localhost"};
86  uint m_port {6548};
87  bool m_bConnected {false};
88  QTimer *m_retryTimer {nullptr};
89  bool m_zmclientReady {false};
90  bool m_isMiniPlayerEnabled {true};
91 };
92 
93 #endif
static QKeyEvent deleteEvent(QKeyEvent(QEvent::KeyPress, 0, Qt::NoModifier,"DELETE"))
QList< Monitor * > m_monitorList
Definition: zmclient.h:80
unsigned int slots[4]
Definition: element.c:38
QMap< int, Monitor * > m_monitorMap
Definition: zmclient.h:81
#define MPUBLIC
Definition: mythexp.h:10
static ZMClient * m_zmclient
Definition: zmclient.h:23
unsigned int uint
Definition: compat.h:140
static int shutdown()
static void showMiniPlayer(void)
bool isMiniPlayerEnabled(void)
Definition: zmclient.h:64
void setIsMiniPlayerEnabled(bool enabled)
Definition: zmclient.h:65
string hostname
Definition: caa.py:17
Event details.
Definition: zmdefines.h:25
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:26
bool connected(void)
Definition: zmclient.h:35