summaryrefslogtreecommitdiff
path: root/include/provider.h
blob: 5046ceced694fae4ce1d5d3a10680d311d62c6a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
/*
 * Copyright 2012  Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.tizenopensource.org/license
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __PROVIDER_H
#define __PROVIDER_H

#ifdef __cplusplus
extern "C" {
#endif

/*!
 * Text signal & Content event uses this data structure.
 */
struct event_info {
        struct {
                double x; /*!< X value of current mouse(touch) position */
                double y; /*!< Y value of current mouse(touch) position */
                int down; /*!< Is it pressed(1) or not(0) */
        } pointer;

        struct {
                double sx; /*!< Pressed object's left top X */
                double sy; /*!< Pressed object's left top Y */
                double ex; /*!< Pressed object's right bottom X */
                double ey; /*!< Pressed object's right bottom Y */
        } part;
};

enum access_event {
	ACCESS_READ,
	ACCESS_READ_NEXT,
	ACCESS_READ_PREV,
	ACCESS_ACTIVATE,
	ACCESS_UP,
	ACCESS_DOWN,
};

struct event_arg {
	enum {
		EVENT_NEW, /*!< Master will send this to create a new livebox instance */
		EVENT_RENEW, /*!< If the master detects any problems of your slave, it will terminate slave provider.
		                  and after reactivating the provider slave, this request will be delievered to create
				  a livebox instance again */

		EVENT_DELETE, /*!< Master will send this to delete a livebox instance */

		EVENT_CONTENT_EVENT, /*!< Any events are generated from your livebox or PD, this event will be sent to you */
		EVENT_CLICKED, /*!< If a livebox is clicked, the master will send this event */
		EVENT_TEXT_SIGNAL, /*!< Text type livebox or PD will generate this event */

		EVENT_RESIZE, /*!< If a livebox is resized, the master will send this event */
		EVENT_SET_PERIOD, /*!< To change the update period of a livebox */
		EVENT_CHANGE_GROUP, /*!< To change the group(cluster/sub-cluster) of a livebox */
		EVENT_PINUP, /*!< To make pin up of a livebox */

		EVENT_UPDATE_CONTENT, /*!< It's time to update the content of a livebox */

		EVENT_PAUSE, /*!< Freeze all timer and go to sleep mode */
		EVENT_RESUME, /*!< Thaw all timer and wake up */

		EVENT_PD_CREATE, /*!< Only for the buffer type */
		EVENT_PD_DESTROY, /*!< Only for the buffer type */
		EVENT_PD_MOVE, /*!< Only for the buffer type */

		EVENT_LB_PAUSE, /*!< Freeze the update timer of a specified livebox */
		EVENT_LB_RESUME, /*!< Thaw the update timer of a specified livebox */

		EVENT_PD_ACCESS, /* PD: Accessibility event */
		EVENT_LB_ACCESS, /* LB: Accessibility event */
	} type;
	const char *pkgname; /*!< Package name of a livebox */
	const char *id; /*!< Instance Id of a livebox */

	union {
		struct {
			int w; /*!< PD buffer is created with width "w" */
			int h; /*!< PD buffer is created with height "h" */

			double x; /*!< Relative X position of a livebox from this PD */
			double y; /*!< Relative Y position of a livebox from this PD */
		} pd_create;

		struct {
		} pd_destroy;

		struct {
			int w; /*!< PD buffer width */
			int h; /*!< PD buffer height */

			double x; /*!< Relative X position of a livebox from this PD */
			double y; /*!< Relative Y position of a livebox from this PD */
		} pd_move;

		struct {
			const char *content; /*!< Content info */
			int timeout; /*!< Timeout */
			int has_script; /*!< Livebox has script (buffer is created from the master) */
			double period; /*!< Update period */
			const char *cluster; /*!< Cluster ID of this livebox instance */
			const char *category; /*!< Sub-cluster ID of this livebox instance */
			int skip_need_to_create; /*!< Is this livebox need to check the "need_to_create"? */
			int width; /*!< Width of a livebox content */
			int height; /*!< Height of a livebox content */
			const char *abi; /*!< ABI tag of this livebox */
			char *out_content; /*!< Output content */
			char *out_title; /*!< Output title */
			int out_is_pinned_up; /*!< Is this pinned up? */
		} lb_create; /*!< "new" */

		struct {
			const char *content;
			int timeout;
			int has_script;
			double period;
			const char *cluster;
			const char *category;
			int width; /*!< Width of a livebox content */
			int height; /*!< Height of a livebox content */
			const char *abi;
			char *out_content; /*!< Output content */
			char *out_title; /*!< Output title */
			int out_is_pinned_up; /*!< Is this pinned up? */
		} lb_recreate; /*!< renew */

		struct {
		} lb_destroy; /*!< delete */

		struct {
			const char *emission; /*!< Event string */
			const char *source; /*!< Object ID which makes event */
			struct event_info info;
		} content_event; /*!< script */

		struct {
			const char *event; /*!< Event type, currently only "click" supported */
			double timestamp; /*!< Timestamp of event occurred */
			double x; /*!< X position of the click event */
			double y; /*!< Y position of the click event */
		} clicked; /*!< clicked */

		struct {
			const char *emission; /*!< Event string */
			const char *source; /*!< Object ID which makes event */
			struct event_info info;
		} text_signal; /*!< text_signal */

		struct {
			int w; /*!< New width of a livebox */
			int h; /*!< New height of a livebox */
		} resize; /*!< resize */

		struct {
			double period; /*!< New period */
		} set_period; /*!< set_period */

		struct {
			const char *cluster;
			const char *category;
		} change_group; /*!< change_group */

		struct {
			int state;
			char *content_info; /* out value */
		} pinup; /*!< pinup */

		struct {
			const char *cluster;
			const char *category;
		} update_content; /*! update_content */

		struct {
			double timestamp;
		} pause; /*!< pause */

		struct {
			double timestamp;
		} resume; /*!< resume */

		struct {
			/*!< */
		} lb_pause;

		struct {
			/*!< */
		} lb_resume;

		struct {
			/*!< Accessibility */
			enum access_event event;
			double x;
			double y;
			int w;
			int h;
		} lb_access;

		struct {
			/*!< Accessibility */
			enum access_event event;
			double x;
			double y;
			int w;
			int h;
		} pd_access;
	} info;
};

struct event_handler {
	int (*lb_create)(struct event_arg *arg, int *width, int *height, double *priority, void *data); /* new */
	int (*lb_destroy)(struct event_arg *arg, void *data); /* delete */

	/* Recover from the fault of slave */
	int (*lb_recreate)(struct event_arg *arg, void *data);

	int (*lb_pause)(struct event_arg *arg, void *data);
	int (*lb_resume)(struct event_arg *arg, void *data);

	int (*content_event)(struct event_arg *arg, void *data);
	int (*clicked)(struct event_arg *arg, void *data);
	int (*text_signal)(struct event_arg *arg, void *data);
	int (*resize)(struct event_arg *arg, void *data);
	int (*set_period)(struct event_arg *arg, void *data);
	int (*change_group)(struct event_arg *arg, void *data);
	int (*pinup)(struct event_arg *arg, void *data);
	int (*update_content)(struct event_arg *arg, void *data);

	int (*pause)(struct event_arg *arg, void *data);
	int (*resume)(struct event_arg *arg, void *data);

	int (*disconnected)(struct event_arg *arg, void *data);
	int (*connected)(struct event_arg *arg, void *data);

	/*!
	 * \note
	 * Only for the buffer type
	 */
	int (*pd_create)(struct event_arg *arg, void *data);
	int (*pd_destroy)(struct event_arg *arg, void *data);
	int (*pd_move)(struct event_arg *arg, void *data);

	/*!
	 * \note
	 * Accessibility functions
	 */
	int (*lb_access)(struct event_arg *arg, void *data);
	int (*pd_access)(struct event_arg *arg, void *data);
};

/*!
 * \brief Initialize the provider service
 * \param[in] disp XDisplay object, if you don't know what this is, set NULL
 * \param[in] name Slave name which is given by the master provider.
 * \param[in] table Event handler table
 * \return int Success 0 otherwise errno < 0
 */
extern int provider_init(void *disp, const char *name, struct event_handler *table, void *data);

/*!
 * \brief Finalize the provider service
 */
extern void *provider_fini(void);

/*!
 * \brief Send the hello signal to the master
 *        Master will activate connection of this only if you send this hello event.
 *        or the master will reject all requests from your provider.
 * \return int Success 0 otherwise errno < 0
 */
extern int provider_send_hello(void);

/*!
 * \brief Send the ping message to the master to notify that your provider is working properly.
 * \return int Success 0 otherwise errno < 0
 */
extern int provider_send_ping(void);

/*!
 * \brief Send the updated event to the master
 * \param[in] pkgname Package name which of an updated livebox.
 * \param[in] id Instance ID of an updated livebox.
 * \param[in] w Width of an updated content
 * \param[in] h Height of an updated content
 * \param[in] priority Priority of an updated content
 * \return int Success 0 otherwise errno < 0
 */
extern int provider_send_updated(const char *pkgname, const char *id, int w, int h, double priority, const char *content, const char *title);

/*!
 * \brief Send the description data updated event to the master
 * \param[in] pkgname Package name of an updated livebox.
 * \param[in] id Instance ID of an updated livebox.
 * \param[in] descfile The filename of a description file.
 * \return int Success 0 otherwise errno < 0
 */
extern int provider_send_desc_updated(const char *pkgname, const char *id, const char *descfile);

/*!
 * \brief Send the deleted event of specified livebox instance
 * \param[in] pkgname Package name of the livebox
 * \param[in] id Livebox instance ID
 * \return int Success 0 otherwise errno < 0
 */
extern int provider_send_deleted(const char *pkgname, const char *id);

/*!
 * \breif If you want to use the fault management service of the master provider,
 *        Before call any functions of a livebox, call this.
 * \param[in] pkgname Package name of the livebox
 * \param[in] id Instance ID of the livebox
 * \param[in] funcname Function name which will be called
 * \return int Success 0 otherwise errno < 0
 */
extern int provider_send_ret(const char *pkgname, const char *id, const char *funcname);

/*!
 * \brief If you want to use the fault management service of the master provider,
 *        After call any functions of a livebox, call this.
 * \param[in] pkgname Package name of the livebox
 * \param[in] id Instance ID of the livebox
 * \param[in] funcname Function name which is called by the slave
 * \return int Success 0 otherwise errno < 0
 */
extern int provider_send_call(const char *pkgname, const char *id, const char *funcname);

/*!
 * \brief If you want to send the fault event to the master provider,
 *        Use this API
 * \param[in] pkgname Package name of the livebox
 * \param[in] id ID of the livebox instance
 * \param[in] funcname Reason of the fault error
 * \return int Success 0 otherwise errno < 0
 */
extern int provider_send_faulted(const char *pkgname, const char *id, const char *funcname);

#ifdef __cplusplus
}
#endif

#endif
/* End of a file */