Initialize Tizen 2.3
[apps/livebox/livebox-viewer.git] / include / livebox_internal.h
1 /*
2  * Copyright 2013  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 extern void lb_invoke_event_handler(struct livebox *handler, enum livebox_event_type event);
18 extern void lb_invoke_fault_handler(enum livebox_fault_type type, const char *pkgname, const char *filename, const char *function);
19
20 extern struct livebox_common *lb_find_common_handle(const char *pkgname, const char *filename);
21 extern struct livebox *lb_new_livebox(const char *pkgname, const char *id, double timestamp, const char *cluster, const char *category);
22 extern struct livebox_common *lb_find_common_handle_by_timestamp(double timestamp);
23
24 extern int lb_set_group(struct livebox_common *common, const char *cluster, const char *category);
25 extern void lb_set_size(struct livebox_common *common, int w, int h);
26 extern void lb_set_pdsize(struct livebox_common *common, int w, int h);
27 extern void lb_set_default_pdsize(struct livebox_common *common, int w, int h);
28 extern int lb_set_content(struct livebox_common *common, const char *content);
29 extern int lb_set_title(struct livebox_common *handler, const char *title);
30 extern void lb_set_auto_launch(struct livebox_common *handler, const char *auto_launch);
31 extern void lb_set_id(struct livebox_common *handler, const char *id);
32 extern void lb_set_size_list(struct livebox_common *handler, int size_list);
33 extern void lb_set_priority(struct livebox_common *handler, double priority);
34 extern int lb_set_lb_fb(struct livebox_common *handler, const char *filename);
35 extern int lb_set_pd_fb(struct livebox_common *handler, const char *filename);
36 extern struct fb_info *lb_get_pd_fb(struct livebox_common *handler);
37 extern struct fb_info *lb_get_lb_fb(struct livebox_common *handler);
38 extern void lb_set_user(struct livebox_common *handler, int user);
39 extern void lb_set_pinup(struct livebox_common *handler, int pinup);
40 extern void lb_set_text_lb(struct livebox_common *handler);
41 extern void lb_set_text_pd(struct livebox_common *handler);
42 extern int lb_text_lb(struct livebox_common *handler);
43 extern int lb_text_pd(struct livebox_common *handler);
44 extern void lb_set_period(struct livebox_common *handler, double period);
45 extern void lb_set_update_mode(struct livebox_common *handler, int active_mode);
46 extern void lb_set_filename(struct livebox_common *handler, const char *filename);
47 extern void lb_set_alt_info(struct livebox_common *handler, const char *icon, const char *name);
48 extern int lb_destroy_lock_file(struct livebox_common *common, int is_pd);
49 extern int lb_create_lock_file(struct livebox_common *common, int is_pd);
50 extern int lb_destroy_common_handle(struct livebox_common *common);
51 extern struct livebox_common *lb_create_common_handle(struct livebox *handle, const char *pkgname, const char *cluster, const char *category);
52 extern int lb_sync_pd_fb(struct livebox_common *common);
53 extern int lb_sync_lb_fb(struct livebox_common *common);
54 extern int lb_common_unref(struct livebox_common *common, struct livebox *handle);
55 extern int lb_common_ref(struct livebox_common *common, struct livebox *handle);
56
57 extern struct livebox *lb_ref(struct livebox *handler);
58 extern struct livebox *lb_unref(struct livebox *handler, int destroy_common);
59 extern int lb_send_delete(struct livebox *handler, int type, ret_cb_t cb, void *data);
60 extern int lb_delete_all(void);
61
62 enum lb_type { /*!< Must have to be sync with data-provider-master */
63         _LB_TYPE_NONE = 0x0,
64         _LB_TYPE_SCRIPT,
65         _LB_TYPE_FILE,
66         _LB_TYPE_TEXT,
67         _LB_TYPE_BUFFER
68 };
69
70 enum pd_type { /*!< Must have to be sync with data-provider-master */
71         _PD_TYPE_NONE = 0x0,
72         _PD_TYPE_SCRIPT,
73         _PD_TYPE_TEXT,
74         _PD_TYPE_BUFFER
75 };
76
77 enum livebox_state {
78         CREATE = 0xBEEFbeef,
79         DELETE = 0xDEADdead, /* Delete only for this client */
80         DESTROYED = 0x00DEAD00
81 };
82
83 struct livebox_common {
84         enum livebox_state state;
85
86         struct dlist *livebox_list;
87         int refcnt;
88
89         char *cluster;
90         char *category;
91
92         char *pkgname;
93         char *id;
94
95         char *content;
96         char *title;
97         char *filename;
98
99         double timestamp;
100
101         struct alt_info {
102                 char *icon;
103                 char *name;
104         } alt;
105
106         enum livebox_delete_type delete_type;
107
108         int is_user;
109         int is_pd_created;
110         int is_pinned_up;
111         int is_active_update;
112         enum livebox_visible_state visible;
113
114         struct {
115                 enum lb_type type;
116                 struct fb_info *fb;
117
118                 int size_list;
119
120                 int width;
121                 int height;
122                 double priority;
123
124                 char *auto_launch;
125                 double period;
126                 int pinup_supported;
127                 int mouse_event;
128
129                 /* For the filtering event */
130                 double x;
131                 double y;
132                 char *lock;
133                 int lock_fd;
134         } lb;
135
136         struct {
137                 enum pd_type type;
138                 struct fb_info *fb;
139
140                 int width;
141                 int height;
142
143                 int default_width;
144                 int default_height;
145
146                 /* For the filtering event */
147                 double x;
148                 double y;
149                 char *lock;
150                 int lock_fd;
151         } pd;
152
153         int nr_of_sizes;
154
155         struct requested_flag {
156                 unsigned int created:1;
157                 unsigned int deleted:1;
158                 unsigned int pinup:1;
159                 unsigned int group_changed:1;
160                 unsigned int period_changed:1;
161                 unsigned int size_changed:1;
162                 unsigned int pd_created:1;
163                 unsigned int pd_destroyed:1;
164                 unsigned int update_mode:1;
165                 unsigned int access_event:1;
166                 unsigned int key_event:1;
167
168                 /*!
169                  * \note
170                  * Reserved
171                  */
172                 unsigned int reserved:21;
173         } request;
174 };
175
176 struct job_item {
177         struct livebox *handle;
178         ret_cb_t cb;
179         int ret;
180         void *data;
181 };
182
183 struct livebox {
184         enum livebox_state state;
185
186         int refcnt;
187         int paused_updating;
188
189         enum livebox_visible_state visible;
190         struct livebox_common *common;
191
192         void *data;
193
194         struct callback_table {
195                 struct livebox_script_operators lb_ops;
196                 struct livebox_script_operators pd_ops;
197
198                 struct created {
199                         ret_cb_t cb;
200                         void *data;
201                 } created;
202
203                 struct deleted {
204                         ret_cb_t cb;
205                         void *data;
206                 } deleted;
207
208                 struct pinup {
209                         ret_cb_t cb;
210                         void *data;
211                 } pinup;
212
213                 struct group_changed {
214                         ret_cb_t cb;
215                         void *data;
216                 } group_changed;
217
218                 struct period_changed {
219                         ret_cb_t cb;
220                         void *data;
221                 } period_changed;
222
223                 struct size_changed {
224                         ret_cb_t cb;
225                         void *data;
226                 } size_changed;
227
228                 struct pd_created {
229                         ret_cb_t cb;
230                         void *data;
231                 } pd_created;
232
233                 struct pd_destroyed {
234                         ret_cb_t cb;
235                         void *data;
236                 } pd_destroyed;
237
238                 struct update_mode {
239                         ret_cb_t cb;
240                         void *data;
241                 } update_mode;
242
243                 struct access_event {
244                         ret_cb_t cb;
245                         void *data;
246                 } access_event;
247
248                 struct key_event {
249                         ret_cb_t cb;
250                         void *data;
251                 } key_event;
252         } cbs;
253 };
254
255 /* End of a file */