Moved the AFBClient to singleton
[staging/windowmanager.git] / AFBClient.h
1 #ifndef AFBCLIENT_H
2 #define AFBCLIENT_H
3
4 #include <systemd/sd-event.h>
5
6 #ifdef AFB
7 extern "C"
8 {
9 #include <json-c/json.h>
10
11 #include "afb-wsj1.h"
12 #include "afb-ws-client.h"
13 }
14 #endif
15
16 class AFBClient
17 {
18     explicit AFBClient();
19     AFBClient(const AFBClient& that) = delete;
20     AFBClient& operator=(AFBClient const&);
21     virtual~AFBClient();
22
23 public:
24     static AFBClient &instance()
25     {
26         static AFBClient obj;
27         return obj;
28     }
29
30     bool init();
31     void requestSurface(const char *label);
32     void activateSurface(const char *label);
33     void deactivateSurface(const char *label);
34     void endDraw(const char *label);
35
36     static void onCall(void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg);
37     static void onEvent(void *closure, const char *event, struct afb_wsj1_msg *msg);
38     static void onHangup(void *closure, struct afb_wsj1 *wsj1);
39     static void onReply(void *closure, struct afb_wsj1_msg *msg);
40
41 private:
42     void call(const char *api, const char *verb, const char *object);
43     void emitSignalOrCall(const char *api, const char *verb, const char *object);
44     void event(const char *event, const char *object);
45
46     struct afb_wsj1 *wsj1;
47     struct afb_wsj1_itf itf;
48
49     sd_event *loop;
50     static const char *wmURI;
51     static const char *wmAPI;
52 };
53
54 #endif // AFBCLIENT_H