DSDebug: Added LCOV_EXCL to whole code
[platform/core/uifw/libds.git] / src / DSWaylandServer / dswayland-server-tizen_policy_ext.h
1 /* Protocol XML file : wayland-extension/tizen_policy_ext.xml */
2
3 #ifndef __DS_TIZEN_POLICY_EXT_PROTOCOL_H__
4 #define __DS_TIZEN_POLICY_EXT_PROTOCOL_H__
5
6 #include "wayland-server-core.h"
7 #include <wayland-server.h>
8 #include "tizen_policy_ext-server-protocol.h"
9 #include <cstdio>
10 #include <cassert>
11 #include <string>
12 #include <map>
13 #include <algorithm>
14
15 #ifndef WAYLAND_VERSION_CHECK
16 #define WAYLAND_VERSION_CHECK(major, minor, micro) \
17     ((WAYLAND_VERSION_MAJOR > (major)) || \
18     (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \
19     (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro)))
20 #endif
21
22
23 namespace DSWaylandServer {
24     class  tizen_policy_ext
25     {
26     public:
27         tizen_policy_ext(struct ::wl_client *client, uint32_t id, int version);
28         tizen_policy_ext(struct ::wl_display *display, int version);
29         tizen_policy_ext(struct ::wl_resource *resource);
30         tizen_policy_ext();
31
32         virtual ~tizen_policy_ext();
33
34         class Resource
35         {
36         public:
37             Resource() : tizen_policy_ext_object(NULL), handle(NULL) {}
38             virtual ~Resource() {}
39
40             tizen_policy_ext *tizen_policy_ext_object;
41             tizen_policy_ext *object() { return tizen_policy_ext_object; } 
42             struct ::wl_resource *handle;
43
44             struct ::wl_client *client() const { return wl_resource_get_client(handle); }
45             int version() const { return wl_resource_get_version(handle); }
46
47             static Resource *fromResource(struct ::wl_resource *resource);
48         };
49
50         void init(struct ::wl_client *client, uint32_t id, int version);
51         void init(struct ::wl_display *display, int version);
52         void init(struct ::wl_resource *resource);
53
54         Resource *add(struct ::wl_client *client, int version);
55         Resource *add(struct ::wl_client *client, uint32_t id, int version);
56         Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version);
57
58         Resource *resource() { return m_resource; }
59         const Resource *resource() const { return m_resource; }
60
61         std::multimap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; }
62         const std::multimap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; }
63
64         bool isGlobal() const { return m_global != NULL; }
65         bool isResource() const { return m_resource != NULL; }
66
67         static const struct ::wl_interface *interface();
68         static std::string interfaceName() { return interface()->name; }
69         static int interfaceVersion() { return interface()->version; }
70
71
72         void send_active_angle(uint32_t angle);
73         void send_active_angle(struct ::wl_resource *resource, uint32_t angle);
74
75     protected:
76         virtual Resource *tizen_policy_ext_allocate();
77
78         virtual void tizen_policy_ext_bind_resource(Resource *resource);
79         virtual void tizen_policy_ext_destroy_resource(Resource *resource);
80
81         virtual void tizen_policy_ext_get_rotation(Resource *resource, uint32_t id, struct ::wl_resource *surface);
82         virtual void tizen_policy_ext_get_active_angle(Resource *resource, struct ::wl_resource *surface);
83
84     private:
85         static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id);
86         static void destroy_func(struct ::wl_resource *client_resource);
87         static void display_destroy_func(struct ::wl_listener *listener, void *data);
88
89         Resource *bind(struct ::wl_client *client, uint32_t id, int version);
90         Resource *bind(struct ::wl_resource *handle);
91
92         static const struct ::tizen_policy_ext_interface m_tizen_policy_ext_interface;
93
94         static void handle_get_rotation(
95             ::wl_client *client,
96             struct wl_resource *resource,
97             uint32_t id,
98             struct ::wl_resource *surface);
99         static void handle_get_active_angle(
100             ::wl_client *client,
101             struct wl_resource *resource,
102             struct ::wl_resource *surface);
103
104         std::multimap<struct ::wl_client*, Resource*> m_resource_map;
105         Resource *m_resource;
106         struct ::wl_global *m_global;
107         uint32_t m_globalVersion;
108         struct DisplayDestroyedListener : ::wl_listener {
109             tizen_policy_ext *parent;
110             DisplayDestroyedListener(): parent(NULL) {}
111         };
112         DisplayDestroyedListener m_displayDestroyedListener;
113     };
114
115     class  tizen_rotation
116     {
117     public:
118         tizen_rotation(struct ::wl_client *client, uint32_t id, int version);
119         tizen_rotation(struct ::wl_display *display, int version);
120         tizen_rotation(struct ::wl_resource *resource);
121         tizen_rotation();
122
123         virtual ~tizen_rotation();
124
125         class Resource
126         {
127         public:
128             Resource() : tizen_rotation_object(NULL), handle(NULL) {}
129             virtual ~Resource() {}
130
131             tizen_rotation *tizen_rotation_object;
132             tizen_rotation *object() { return tizen_rotation_object; } 
133             struct ::wl_resource *handle;
134
135             struct ::wl_client *client() const { return wl_resource_get_client(handle); }
136             int version() const { return wl_resource_get_version(handle); }
137
138             static Resource *fromResource(struct ::wl_resource *resource);
139         };
140
141         void init(struct ::wl_client *client, uint32_t id, int version);
142         void init(struct ::wl_display *display, int version);
143         void init(struct ::wl_resource *resource);
144
145         Resource *add(struct ::wl_client *client, int version);
146         Resource *add(struct ::wl_client *client, uint32_t id, int version);
147         Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version);
148
149         Resource *resource() { return m_resource; }
150         const Resource *resource() const { return m_resource; }
151
152         std::multimap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; }
153         const std::multimap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; }
154
155         bool isGlobal() const { return m_global != NULL; }
156         bool isResource() const { return m_resource != NULL; }
157
158         static const struct ::wl_interface *interface();
159         static std::string interfaceName() { return interface()->name; }
160         static int interfaceVersion() { return interface()->version; }
161
162
163         enum angle {
164             angle_none = 0,
165             angle_0 = 1,
166             angle_90 = 2,
167             angle_180 = 4,
168             angle_270 = 8,
169         };
170
171         void send_available_angles_done(uint32_t angles);
172         void send_available_angles_done(struct ::wl_resource *resource, uint32_t angles);
173         void send_preferred_angle_done(uint32_t angle);
174         void send_preferred_angle_done(struct ::wl_resource *resource, uint32_t angle);
175         void send_angle_change(uint32_t angle, uint32_t serial);
176         void send_angle_change(struct ::wl_resource *resource, uint32_t angle, uint32_t serial);
177         void send_angle_change_with_resize(uint32_t angle, uint32_t serial, uint32_t width, uint32_t height);
178         void send_angle_change_with_resize(struct ::wl_resource *resource, uint32_t angle, uint32_t serial, uint32_t width, uint32_t height);
179
180     protected:
181         virtual Resource *tizen_rotation_allocate();
182
183         virtual void tizen_rotation_bind_resource(Resource *resource);
184         virtual void tizen_rotation_destroy_resource(Resource *resource);
185
186         virtual void tizen_rotation_destroy(Resource *resource);
187         virtual void tizen_rotation_set_available_angles(Resource *resource, uint32_t angles);
188         virtual void tizen_rotation_set_preferred_angle(Resource *resource, uint32_t angle);
189         virtual void tizen_rotation_ack_angle_change(Resource *resource, uint32_t serial);
190         virtual void tizen_rotation_set_geometry_hint(Resource *resource, uint32_t angle, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
191
192     private:
193         static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id);
194         static void destroy_func(struct ::wl_resource *client_resource);
195         static void display_destroy_func(struct ::wl_listener *listener, void *data);
196
197         Resource *bind(struct ::wl_client *client, uint32_t id, int version);
198         Resource *bind(struct ::wl_resource *handle);
199
200         static const struct ::tizen_rotation_interface m_tizen_rotation_interface;
201
202         static void handle_destroy(
203             ::wl_client *client,
204             struct wl_resource *resource);
205         static void handle_set_available_angles(
206             ::wl_client *client,
207             struct wl_resource *resource,
208             uint32_t angles);
209         static void handle_set_preferred_angle(
210             ::wl_client *client,
211             struct wl_resource *resource,
212             uint32_t angle);
213         static void handle_ack_angle_change(
214             ::wl_client *client,
215             struct wl_resource *resource,
216             uint32_t serial);
217         static void handle_set_geometry_hint(
218             ::wl_client *client,
219             struct wl_resource *resource,
220             uint32_t angle,
221             uint32_t x,
222             uint32_t y,
223             uint32_t w,
224             uint32_t h);
225
226         std::multimap<struct ::wl_client*, Resource*> m_resource_map;
227         Resource *m_resource;
228         struct ::wl_global *m_global;
229         uint32_t m_globalVersion;
230         struct DisplayDestroyedListener : ::wl_listener {
231             tizen_rotation *parent;
232             DisplayDestroyedListener(): parent(NULL) {}
233         };
234         DisplayDestroyedListener m_displayDestroyedListener;
235     };
236 }
237
238 #endif