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