bug fix: TC-1152
[profile/ivi/ico-uxf-homescreen.git] / include / ico_syc_private.h
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9 /**
10  * @brief   header file of System Controller internal definition
11  *
12  * @date    Sep-4-2013
13  */
14
15 #ifndef _ICO_SYC_PRIVATE_H_
16 #define _ICO_SYC_PRIVATE_H_
17
18 #include <stdio.h>
19 #include <stdlib.h>
20
21 #include <ico_uws.h>
22
23 #include "ico_syc_type.h"
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /*============================================================================*/
30 /* definition                                                                 */
31 /*============================================================================*/
32 /*
33  * uri and protocol
34  */
35 #define ICO_SYC_URI             (char *)"ws://127.0.0.1:18081"
36 #define ICO_SYC_PROTOCOL        (char *)"ico_syc_protocol"
37
38 #define ICO_SYC_MAX_LEN         128
39
40 /*
41  * package name
42  */
43 #define ICO_SYC_PACKAGE_SYSTEMCONTROLLER    "org.tizen.ico.system-controller"
44 #define ICO_SYC_PACKAGE_HOMESCREEN          "org.tizen.ico.homescreen"
45 #define ICO_SYC_PACKAGE_STATUSBAR           "org.tizen.ico.statusbar"
46 #define ICO_SYC_PACKAGE_ONSCREEN            "org.tizen.ico.onscreen"
47 #define ICO_SYC_PACKAGE_LOGIN               "org.tizen.ico.login"
48 #define ICO_SYC_PACKAGE_DIALER              "org.tizen.dialer"
49
50 /*
51  * configuration file path
52  */
53 #define ICO_SYC_CONFIGPATH_HOME             "ico"
54 #define ICO_SYC_CONFIGPATH_HOME_CONFIG      ICO_SYC_CONFIGPATH_HOME "/config"
55 #define ICO_SYC_CONFIGPATH_HOME_IMAGE       ICO_SYC_CONFIGPATH_HOME "/images"
56 #define ICO_SYC_CONFIGPATH_HOME_SOUND       ICO_SYC_CONFIGPATH_HOME "/sound"
57 #define ICO_SYC_CONFIGPATH_PACKAGE          "res"
58 #define ICO_SYC_CONFIGPATH_PACKAGE_CONFIG   ICO_SYC_CONFIGPATH_PACKAGE "/config"
59 #define ICO_SYC_CONFIGPATH_PACKAGE_IMAGE    ICO_SYC_CONFIGPATH_PACKAGE "/images"
60 #define ICO_SYC_CONFIGPATH_PACKAGE_SOUND    ICO_SYC_CONFIGPATH_PACKAGE "/sound"
61
62 /*============================================================================*/
63 /* variable & table                                                           */
64 /*============================================================================*/
65 struct ico_syc_res_context {
66     char                    appid[ICO_SYC_MAX_LEN];
67     /* window resource */
68     ico_syc_res_window_t    *window;
69     /* sound resource */
70     ico_syc_res_sound_t     *sound;
71     /* input resource */
72     ico_syc_res_input_t     *input;
73
74     /* window and sound resource type (basic or interruption) */
75     int                     type;
76 };
77
78 /*============================================================================*/
79 /* internal function (common)                                                 */
80 /*============================================================================*/
81 /*--------------------------------------------------------------------------*/
82 /**
83  * @internal
84  * @brief   ico_syc_get_context
85  *          Get the ico_uws context connected to System Controller.
86  *
87  * @return      uws_context
88  * @retval      context                 success
89  * @retval      NULL                    error
90  */
91 /*--------------------------------------------------------------------------*/
92 struct ico_uws_context *ico_syc_get_context(void);
93
94 /*--------------------------------------------------------------------------*/
95 /**
96  * @internal
97  * @brief   ico_syc_get_id
98  *          Get the ico_uws id to send message to System Controller.
99  *
100  * @return      uws_id
101  * @retval      id                      success
102  * @retval      NULL                    error
103  */
104 /*--------------------------------------------------------------------------*/
105 void *ico_syc_get_id(void);
106
107 /*--------------------------------------------------------------------------*/
108 /**
109  * @internal
110  * @brief   ico_syc_get_appid
111  *          Get the application id.
112  *
113  * @return      appid
114  * @retval      appid                   success
115  * @retval      NULL                    error
116  */
117 /*--------------------------------------------------------------------------*/
118 char *ico_syc_get_appid(void);
119
120 /*============================================================================*/
121 /* internal function (winctl)                                                 */
122 /*============================================================================*/
123 /*--------------------------------------------------------------------------*/
124 /**
125  * @internal
126  * @brief   ico_syc_cb_win
127  *          Execute callback function. (ICO_SYC_EV_WIN_ACTIVE
128  *                                      ICO_SYC_EV_WIN_CREATE
129  *                                      ICO_SYC_EV_WIN_DESTROY)
130  *
131  * @param[in]   callback                callback function
132  * @param[in]   user_data               passed data on called callback function
133  * @param[in]   event                   event code
134  * @param[in]   data                    message data
135  * @param[in]   len                     length of data
136  * @return      none
137  */
138 /*--------------------------------------------------------------------------*/
139 void ico_syc_cb_win(ico_syc_callback_t callback, void *user_data,
140                     int event, const void *data, size_t len);
141
142 /*--------------------------------------------------------------------------*/
143 /**
144  * @internal
145  * @brief   ico_syc_cb_win_attr
146  *          Execute callback function. (ICO_SYC_EV_WIN_ATTR_CHANGE)
147  *
148  * @param[in]   callback                callback function
149  * @param[in]   user_data               passed data on called callback function
150  * @param[in]   event                   event code
151  * @param[in]   data                    message data
152  * @param[in]   len                     length of data
153  * @return      none
154  */
155 /*--------------------------------------------------------------------------*/
156 void ico_syc_cb_win_attr(ico_syc_callback_t callback, void *user_data,
157                          int event, const void *data, size_t len);
158
159 /*--------------------------------------------------------------------------*/
160 /**
161  * @internal
162  * @brief   ico_syc_cb_thumb
163  *          Execute callback function. (ICO_SYC_EV_THUMB_ERROR
164  *                                      ICO_SYC_EV_THUMB_CHANGE
165  *                                      ICO_SYC_EV_THUMB_UNMAP)
166  *
167  * @param[in]   callback                callback function
168  * @param[in]   user_data               passed data on called callback function
169  * @param[in]   event                   event code
170  * @param[in]   data                    message data
171  * @param[in]   len                     length of data
172  * @return      none
173  */
174 /*--------------------------------------------------------------------------*/
175 void ico_syc_cb_thumb(ico_syc_callback_t callback, void *user_data,
176                       int event, const void *data, size_t len);
177
178 /*--------------------------------------------------------------------------*/
179 /**
180  * @internal
181  * @brief   ico_syc_cb_layer
182  *          Execute callback function. (ICO_SYC_EV_LAYER_ATTR_CHANGE)
183  *
184  * @param[in]   callback                callback function
185  * @param[in]   user_data               passed data on called callback function
186  * @param[in]   event                   event code
187  * @param[in]   data                    message data
188  * @param[in]   len                     length of data
189  * @return      none
190  */
191 /*--------------------------------------------------------------------------*/
192 void ico_syc_cb_layer(ico_syc_callback_t callback, void *user_data,
193                       int event, const void *data, size_t len);
194
195 /*============================================================================*/
196 /* internal function (userctl)                                                */
197 /*============================================================================*/
198 /*--------------------------------------------------------------------------*/
199 /**
200  * @internal
201  * @brief   ico_syc_cb_auth
202  *          Execute callback function. (ICO_SYC_EV_AUTH_FAIL)
203  *
204  * @param[in]   callback                callback function
205  * @param[in]   user_data               passed data on called callback function
206  * @param[in]   event                   event code
207  * @return      none
208  */
209 /*--------------------------------------------------------------------------*/
210 void ico_syc_cb_auth(ico_syc_callback_t callback, void *user_data, int event);
211
212 /*--------------------------------------------------------------------------*/
213 /**
214  * @internal
215  * @brief   ico_syc_cb_userlist
216  *          Execute callback function. (ICO_SYC_EV_USERLIST)
217  *
218  * @param[in]   callback                callback function
219  * @param[in]   user_data               passed data on called callback function
220  * @param[in]   event                   event code
221  * @param[in]   data                    message data
222  * @param[in]   len                     length of data
223  * @return      none
224  */
225 /*--------------------------------------------------------------------------*/
226 void ico_syc_cb_userlist(ico_syc_callback_t callback, void *user_data,
227                          int event, const void *data, size_t len);
228
229 /*--------------------------------------------------------------------------*/
230 /**
231  * @internal
232  * @brief   ico_syc_cb_lastinfo
233  *          Execute callback function. (ICO_SYC_EV_LASTINFO)
234  *
235  * @param[in]   callback                callback function
236  * @param[in]   user_data               passed data on called callback function
237  * @param[in]   event                   event code
238  * @param[in]   data                    message data
239  * @param[in]   len                     length of data
240  * @return      none
241  */
242 /*--------------------------------------------------------------------------*/
243 void ico_syc_cb_lastinfo(ico_syc_callback_t callback, void *user_data,
244                          int event, const void *data, size_t len);
245
246 /*============================================================================*/
247 /* internal function (appresctl)                                              */
248 /*============================================================================*/
249 /*--------------------------------------------------------------------------*/
250 /**
251  * @internal
252  * @brief   ico_syc_cb_res
253  *          Execute callback function. (ICO_SYC_EV_RES_ACQUIRE
254  *                                      ICO_SYC_EV_RES_DEPRIVE
255  *                                      ICO_SYC_EV_RES_WAITING
256  *                                      ICO_SYC_EV_RES_REVERT
257  *                                      ICO_SYC_EV_RES_RELEASE)
258  *
259  * @param[in]   callback                callback function
260  * @param[in]   user_data               passed data on called callback function
261  * @param[in]   event                   event code
262  * @param[in]   data                    message data
263  * @param[in]   len                     length of data
264  * @return      none
265  */
266 /*--------------------------------------------------------------------------*/
267 void ico_syc_cb_res(ico_syc_callback_t callback, void *user_data,
268                     int event, const void *data, size_t len);
269
270 /*--------------------------------------------------------------------------*/
271 /**
272  * @internal
273  * @brief   ico_syc_cb_region
274  *          Execute callback function. (ICO_SYC_EV_INPUT_SET
275  *                                      ICO_SYC_EV_INPUT_UNSET)
276  *
277  * @param[in]   callback                callback function
278  * @param[in]   user_data               passed data on called callback function
279  * @param[in]   event                   event code
280  * @param[in]   data                    message data
281  * @param[in]   len                     length of data
282  * @return      none
283  */
284 /*--------------------------------------------------------------------------*/
285 void ico_syc_cb_region(ico_syc_callback_t callback, void *user_data,
286                        int event, const void *data, size_t len);
287
288
289 /*============================================================================*/
290 /* NodeId <-> DisplayId macro                                                 */
291 /*============================================================================*/
292 #define ICO_SYC_ECUBASE 100
293 #define ICO_SYC_DISPLAYID(nodeid)           (nodeid % ICO_SYC_ECUBASE)
294 #define ICO_SYC_ECUID(nodeid)               (nodeid / ICO_SYC_ECUBASE)
295 #define ICO_SYC_NODEID(ecuid, displayid)    (ecuid * ICO_SYC_ECUBASE + \
296                                              (displayid % ICO_SYC_ECUBASE))
297
298 /*============================================================================*/
299 /* log macro                                                                  */
300 /*============================================================================*/
301 #ifndef  _NO_USE_DLOG
302
303 #ifdef LOG_TAG
304 #undef LOG_TAG
305 #endif
306
307 #define LOG_TAG "ICO_SYC"
308 #include <dlog/dlog.h>
309
310 #define _ERR(fmt, arg...)                                       \
311     do {                                                        \
312         fprintf(stderr,                                         \
313                 "ico_syc E: %s:%d [ "fmt" ]\n",                 \
314                 __FUNCTION__,                                   \
315                 __LINE__,                                       \
316                 ##arg);                                         \
317         LOGE("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg);      \
318     } while (0)
319
320 #define _WARN(fmt, arg...)                                      \
321     do {                                                        \
322         fprintf(stderr,                                         \
323                 "ico_syc W: %s:%d [ "fmt" ]\n",                 \
324                 __FUNCTION__,                                   \
325                 __LINE__,                                       \
326                 ##arg);                                         \
327         LOGW("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg);      \
328     } while (0)
329
330 #define _INFO(fmt, arg...)                                      \
331     do {                                                        \
332         fprintf(stderr,                                         \
333                 "ico_syc I: %s:%d [ "fmt" ]\n",                 \
334                 __FUNCTION__,                                   \
335                 __LINE__,                                       \
336                 ##arg);                                         \
337         LOGI("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg);      \
338     } while (0)
339
340 #define _DBG(fmt, arg...)                                       \
341     do {                                                        \
342         LOGD("%s:%d " fmt, __FUNCTION__, __LINE__, ##arg);      \
343     } while (0)
344
345 #else
346
347 #define _ERR(fmt, arg...)                                       \
348     do {                                                        \
349         fprintf(stderr,                                         \
350                 "ico_syc E: %s:%d [ "fmt" ]\n",                 \
351                 __FUNCTION__,                                   \
352                 __LINE__,                                       \
353                 ##arg);                                         \
354     } while (0)
355
356 #define _WARN(fmt, arg...)                                      \
357     do {                                                        \
358         fprintf(stderr,                                         \
359                 "ico_syc W: %s:%d [ "fmt" ]\n",                 \
360                 __FUNCTION__,                                   \
361                 __LINE__,                                       \
362                 ##arg);                                         \
363     } while (0)
364
365
366 #define _INFO(fmt, arg...)                                      \
367     do {                                                        \
368         fprintf(stderr,                                         \
369                 "ico_syc I: %s:%d [ "fmt" ]\n",                 \
370                 __FUNCTION__,                                   \
371                 __LINE__,                                       \
372                 ##arg);                                         \
373     } while (0)
374
375 #define _DBG(fmt, arg...)                                       \
376     do {                                                        \
377         if (getenv("ICO_SYC_DEBUG")) {                          \
378             fprintf(stderr,                                     \
379                     "ico_syc D: %s:%d [ "fmt" ]\n",             \
380                     __FUNCTION__,                               \
381                     __LINE__,                                   \
382                     ##arg);                                     \
383         }                                                       \
384     } while (0)
385
386 #endif
387
388
389 #ifdef __cplusplus
390 }
391 #endif
392 #endif /*_ICO_SYC_PRIVATE_H_*/
393 /* vim:set expandtab ts=4 sw=4: */