Add multi User features
[platform/core/appfw/ail.git] / include / ail.h
1 /*
2  * ail
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22
23
24
25 #ifndef __AIL_H__
26 #define __AIL_H__
27
28 #include <stdbool.h>
29 #include <unistd.h>
30 #include <sys/types.h>
31 #include <pwd.h>
32 #include <tzplatform_config.h>
33 #define OWNER_ROOT 0
34 #define GROUP_MENU 6010
35 #define BUFSZE 1024
36 #define OPT_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RW_DESKTOP_APP)
37 #define USR_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RO_DESKTOP_APP)
38 #define APP_INFO_DB_FILE tzplatform_mkpath(TZ_SYS_DB,".app_info.db")
39 #define APP_INFO_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB,".app_info.db-journal")
40 #define APP_INFO_DB_LABEL "ail::db"
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif /* __cplusplus */
45
46
47
48 /**
49  * @open
50  * @ingroup APPLICATION_FRAMEWORK
51  * @defgroup ail Application Information Library
52  */
53
54 /**
55  * @file       ail.h
56  * @brief      Application Information Library header
57  * @author     Sunghyuk Lee (sunghyuk.lee@samsung.com), Jin Yoon (jinny.yoon@samsung.com)
58  * @date       2011-07-30
59  * @version    0.1
60  */
61
62 /**
63  * @addtogroup ail
64  * @{
65  */
66
67 /**
68  * @brief string type properties
69  */
70 #define AIL_PROP_PACKAGE_STR                    "AIL_PROP_PACKAGE_STR"
71 #define AIL_PROP_EXEC_STR                       "AIL_PROP_EXEC_STR"
72 #define AIL_PROP_NAME_STR                       "AIL_PROP_NAME_STR"
73 #define AIL_PROP_TYPE_STR                       "AIL_PROP_TYPE_STR"
74 #define AIL_PROP_ICON_STR                       "AIL_PROP_ICON_STR"
75 #define AIL_PROP_CATEGORIES_STR                 "AIL_PROP_CATEGORIES_STR"
76 #define AIL_PROP_VERSION_STR                    "AIL_PROP_VERSION_STR"
77 #define AIL_PROP_MIMETYPE_STR                   "AIL_PROP_MIMETYPE_STR"
78 #define AIL_PROP_X_SLP_SERVICE_STR              "AIL_PROP_X_SLP_SERVICE_STR"
79 #define AIL_PROP_X_SLP_PACKAGETYPE_STR          "AIL_PROP_X_SLP_PACKAGETYPE_STR"
80 #define AIL_PROP_X_SLP_PACKAGECATEGORIES_STR    "AIL_PROP_X_SLP_PACKAGECATEGORIES_STR"
81 #define AIL_PROP_X_SLP_PACKAGEID_STR            "AIL_PROP_X_SLP_PACKAGEID_STR"
82 #define AIL_PROP_X_SLP_SVC_STR                  "AIL_PROP_X_SLP_SVC_STR"
83 #define AIL_PROP_X_SLP_EXE_PATH                 "AIL_PROP_X_SLP_EXE_PATH"
84 #define AIL_PROP_X_SLP_APPID_STR                "AIL_PROP_X_SLP_APPID_STR"
85 #define AIL_PROP_X_SLP_PKGID_STR                "AIL_PROP_X_SLP_PKGID_STR"
86 #define AIL_PROP_X_SLP_DOMAIN_STR               "AIL_PROP_X_SLP_DOMAIN_STR"
87 #define AIL_PROP_X_SLP_SUBMODEMAINID_STR                "AIL_PROP_X_SLP_SUBMODEMAINID_STR"
88 #define AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR             "AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR"
89
90 /**
91  * @brief integer type properties
92  */
93 #define AIL_PROP_X_SLP_TEMP_INT                 "AIL_PROP_X_SLP_TEMP_INT"
94 #define AIL_PROP_X_SLP_INSTALLEDTIME_INT        "AIL_PROP_X_SLP_INSTALLEDTIME_INT"
95
96 /**
97  * @brief boolean type properties
98  */
99 #define AIL_PROP_NODISPLAY_BOOL                 "AIL_PROP_NODISPLAY_BOOL"
100 #define AIL_PROP_X_SLP_TASKMANAGE_BOOL          "AIL_PROP_X_SLP_TASKMANAGE_BOOL"
101 #define AIL_PROP_X_SLP_MULTIPLE_BOOL            "AIL_PROP_X_SLP_MULTIPLE_BOOL"
102 #define AIL_PROP_X_SLP_REMOVABLE_BOOL           "AIL_PROP_X_SLP_REMOVABLE_BOOL"
103 #define AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL   "AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL"
104 #define AIL_PROP_X_SLP_ENABLED_BOOL             "AIL_PROP_X_SLP_ENABLED_BOOL"
105 #define AIL_PROP_X_SLP_SUBMODE_BOOL             "AIL_PROP_X_SLP_SUBMODE_BOOL"
106
107 /**
108  * @brief A handle for filters
109  */
110 typedef struct ail_filter *ail_filter_h;
111
112 /**
113  * @brief A handle for appinfos
114  */
115 typedef struct ail_appinfo *ail_appinfo_h;
116
117 /**
118  * @brief return values 
119  */
120 typedef enum {
121         AIL_ERROR_OK = 0,                                               /**< General success */
122         AIL_ERROR_FAIL = -1,                                    /**< General error */
123         AIL_ERROR_DB_FAILED = -2,                               /**< Database error */
124         AIL_ERROR_OUT_OF_MEMORY = -3,                   /**< Out of memory */
125         AIL_ERROR_INVALID_PARAMETER = -4,               /**< Invalid parameter */
126         AIL_ERROR_NO_DATA = -5,                                 /**< Success, but no data */
127 } ail_error_e;
128
129 /**
130  * @fn ail_error_e ail_filter_new(ail_filter_h *filter)
131  *
132  * @brief  Create a new filter handle which is used to filter records from Application Information Database. You can add filtering conditions to filter with ail_filter_add_xxx functions. All conditions are ANDed.
133  *
134  * @par Sync (or) Async : Synchronous API.
135  *
136  * @param[out] filter a pointer to a filter which is newly created
137  *
138  * @return 0 if success, negative value(<0) if fail\n
139  * @retval      AIL_ERROR_OK                                    success
140  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
141  * @retval      AIL_ERROR_OUT_OF_MEMORY                 out of memory
142  *
143  * @pre None
144  * @post If the filter is no longer used, it should be freed with ail_filter_destroy()
145  *
146  * @see  ail_filter_destroy()
147  *
148  * @par Prospective Clients:
149  * External Apps.
150  *
151  * @code
152 int count_apps()
153 {
154         ail_filter_h filter;
155         ail_error_e ret;
156         int n;
157
158         ret = ail_filter_new(&filter);
159         if (ret != AIL_ERROR_OK) {
160                 return -1;
161         }
162
163         ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
164         if (ret != AIL_ERROR_OK) {
165                 return -1;
166         }
167
168         ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, "audio/wav");
169         if (ret != AIL_ERROR_OK) {
170                 return -1;
171         }
172
173         ret = ail_filter_count_appinfo(filter, &n);
174         if (ret != AIL_ERROR_OK) {
175                 return -1;
176         }
177         ret = ail_filter_destroy(filter);
178
179         printf("N of apps not to be displayed and supporting 'audo/wav' mime type = %d\n", n);
180
181         return n;
182 }
183  * @endcode
184  */
185 ail_error_e ail_filter_new(ail_filter_h *filter);
186
187
188
189 /**
190  * @fn ail_error_e ail_error_e ail_filter_add_int(ail_filter_h filter, const char *property, const int value)
191  *
192  * @brief Add integer condition to filter
193  *
194  * @par Sync (or) Async : Synchronous API
195  *
196  * @param[in] filter    a filter handle which can be create with ail_filter_new()
197  * @param[in] property          a property type of integer
198  * @param[in] value             the value to filter by
199  *
200  * @return 0 if success, negative value(<0) if fail\n
201  * @retval      AIL_ERROR_OK                                    success
202  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
203  * @retval      AIL_ERROR_OUT_OF_MEMORY                 out of memory
204  *
205  * @pre The filter should be valid handle which was created by ail_filter_new()
206  *
207  * @see  ail_filter_new()
208  *
209  * @par Prospective Clients:
210  * External Apps.
211  *
212  * @code
213 int count_apps()
214 {
215         ail_filter_h filter;
216         ail_error_e ret;
217         int n;
218
219         ret = ail_filter_new(&filter);
220         if (ret != AIL_ERROR_OK) {
221                 return -1;
222         }
223
224         ret = ail_filter_add_int(filter, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, 480);
225         if (ret != AIL_ERROR_OK) {
226                 return -1;
227         }
228
229         ret = ail_filter_count_appinfo(filter, &n);
230         if (ret != AIL_ERROR_OK) {
231                 return -1;
232         }
233
234         printf("N of apps = %d\n", n);
235
236         return n;
237 }
238  * @endcode
239  */
240 ail_error_e ail_filter_add_int(ail_filter_h filter, const char *property, const int value);
241
242
243 /**
244  * @fn ail_error_e ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *property, const bool value)
245  *
246  * @brief Add boolean condition to filter by. The value can be true/false only
247  *
248  * @par Sync (or) Async : Synchronous API
249  *
250  * @param[in] filter     a filter handle which can be create with ail_filter_new()
251  * @param[in] property   a property type of boolean
252  * @param[in] value      the value to filter by
253  *
254  * @return 0 if success, negative value(<0) if fail\n
255  * @retval      AIL_ERROR_OK                                    success
256  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
257  * @retval      AIL_ERROR_OUT_OF_MEMORY                 out of memory
258  *
259  * @pre The filter should be valid handle which was created by ail_filter_new()
260  *
261  * @see  ail_filter_new()
262  *
263  * @par Prospective Clients:
264  * External Apps.
265  *
266  * @code
267 int count_apps()
268 {
269         ail_filter_h filter;
270         ail_error_e ret;
271         int n;
272
273         ret = ail_filter_new(&filter);
274         if (ret != AIL_ERROR_OK) {
275                 return -1;
276         }
277
278         ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
279         if (ret != AIL_ERROR_OK) {
280                 return -1;
281         }
282
283         ret = ail_filter_count_appinfo(filter, &n);
284         if (ret != AIL_ERROR_OK) {
285                 return -1;
286         }
287
288         fprintf(stderr, "N of apps = %d\n", n);
289
290         return n;
291 }
292  * @endcode
293  */
294 ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *property, bool value);
295
296
297
298 /**
299  * @fn ail_error_e ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const char *value)
300  *
301  * @brief Add string condition to filter by. The string is case-sensitive.
302  *
303  * @par Sync (or) Async : Synchronous API
304  *
305  * @param[in] filter     a filter handle which can be create with ail_filter_new()
306  * @param[in] property   a property type of string
307  * @param[in] value      the value to filter by
308  *
309  * @return 0 if success, negative value(<0) if fail\n
310  * @retval      AIL_ERROR_OK                                    success
311  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
312  * @retval      AIL_ERROR_OUT_OF_MEMORY                 out of memory
313  *
314  * @pre The filter should be valid handle which was created by ail_filter_new()
315  *
316  * @see  ail_filter_new()
317  *
318  * @par Prospective Clients:
319  * External Apps.
320  *
321  * @code
322 int count_apps()
323 {
324         ail_filter_h filter;
325         ail_error_e ret;
326         int n;
327
328         ret = ail_filter_new(&filter);
329         if (ret != AIL_ERROR_OK) {
330                 return -1;
331         }
332
333         ret = ail_filter_add_str(filter, AIL_PROP_PACKAGE_STR, "com.samsung.memo");
334         if (ret != AIL_ERROR_OK) {
335                 return -1;
336         }
337
338         ret = ail_filter_count_appinfo(filter, &n);
339         if (ret != AIL_ERROR_OK) {
340                 return -1;
341         }
342
343         fprintf(stderr, "N of apps = %d\n", n);
344
345         return n;
346 }
347  * @endcode
348  */
349 ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const char *value);
350
351
352
353 /**
354  * @fn ail_error_e ail_filter_destroy(ail_filter_h filter)
355  *
356  * @brief Destroy a filter which is not used any longer.
357  *
358  * @par Sync (or) Async : Synchronous API
359  *
360  * @param[in] filter    filter handle
361  *
362  * @return 0 if success, negative value(<0) if fail\n
363  * @retval      AIL_ERROR_OK    success
364  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
365  *
366  * @post If the filter is no longer used, it should be freed with ail_filter_destroy()
367  *
368  * @see  ail_filter_new()
369  *
370  * @par Prospective Clients:
371  * External Apps.
372  *
373  * @code
374 int count_apps()
375 {
376         ail_filter_h filter;
377         ail_error_e ret;
378         int n;
379
380         ret = ail_filter_new(&filter);
381         if (ret != AIL_ERROR_OK) {
382                 return -1;
383         }
384
385         ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
386         if (ret != AIL_ERROR_OK) {
387                 return -1;
388         }
389
390         ret = ail_filter_count_appinfo(filter, &n);
391         if (ret != AIL_ERROR_OK) {
392                 return -1;
393         }
394
395         printf("N of removable apps = %d\n", n);
396
397         ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, "audio/wav");
398         if (ret != AIL_ERROR_OK) {
399                 return -1;
400         }
401
402         ret = ail_filter_count_appinfo(filter, &n);
403         if (ret != AIL_ERROR_OK) {
404                 return -1;
405         }
406
407         printf("N of apps removable and supporting 'audo/wav' mime type = %d\n", n);
408
409         ret = ail_filter_destroy(filter);
410
411         return n;
412 }
413  * @endcode
414  */
415 ail_error_e ail_filter_destroy(ail_filter_h filter);
416
417
418
419 /**
420  * @brief return value type of ail_list_appinfo_cb
421  */
422 typedef enum {
423         AIL_CB_RET_CONTINUE = 1,                /**< continue */
424         AIL_CB_RET_CANCEL = 0,                  /**< cancel */
425 } ail_cb_ret_e;
426
427 /**
428  * @fn ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void *user_data)
429  *
430  * @breif Specifies the type of functions passed to ail_filter_list_appinfo_foreach().
431  *
432  * @param[in] appinfo_h the appinfo's handle
433  * @param[in] user_data user data passed to ail_filtet_list_appinfo_foreach()
434  *
435  * @return 0 if success, negative value(<0) if fail\n
436  * @retval      AIL_CB_RET_CONTINUE                             return if you continue iteration
437  * @retval      AIL_CB_RET_CANCEL                               return if you cancel iteration
438  *
439  * @see  ail_filter_list_appinfo_foreach()
440  */
441 typedef ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void *user_data);
442
443 /**
444  * @fn ail_error_e ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb func, void *user_data)
445  *
446  * @brief Calls the callback function for each app filtered by given filter. If the filter is not given (i.e filter handle is NULL), it is invoked for all apps.
447  *
448  * @par Sync (or) Async : Synchronous API
449  *
450  * @param[in] filter            a filter handle
451  * @param[in] func                      the function to call with each app's appinfo
452  * @param[in] user_data         user_data to pass to the function
453  *
454  * @return  0 if success, negative value(<0) if fail\n
455  * @retval AIL_ERROR_OK                                 success
456  * @retval AIL_ERROR_DB_FAILED                          database error
457  * @retval AIL_ERROR_INVALID_PARAMETER          invalid parameter
458  *
459  * @see  ail_list_appinfo_cb
460  * @see ail_filter_add_bool()
461  * @see ail_filter_add_int()
462  * @see ail_filter_add_str()
463  *
464  * @par Prospective Clients:
465  * External Apps.
466  *
467  * @code
468
469 ail_cb_ret_e appinfo_func(const ail_appinfo_h appinfo, void *user_data)
470 {
471         int *i = (int *)user_data;
472         char *appid;
473
474         ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &appid);
475         printf("i=%d %s\n", (*i)++, appid);
476
477         if (*i > 30)
478                 return AIL_CB_RET_CANCEL;
479
480         return AIL_CB_RET_CONTINUE;
481 }
482
483 int list_apps()
484 {
485         ail_filter_h filter;
486         ail_error_e ret;
487         int i=0;
488
489         ret = ail_filter_new(&filter);
490         if (ret != AIL_ERROR_OK) {
491                 return -1;
492         }
493
494         ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
495         if (ret != AIL_ERROR_OK) {
496                 return -1;
497         }
498
499         ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
500         if (ret != AIL_ERROR_OK) {
501                 return -1;
502         }
503
504         printf("List apps which are removable and 'Application' typed\n");
505         ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
506
507         ail_filter_destroy(filter);
508         
509         return 0;
510 }
511  * @endcode
512  */
513 ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter,
514                                             ail_list_appinfo_cb appinfo_func,
515                                             void *user_data);
516
517
518
519 /**
520  * @fn ail_error_e ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count)
521  *
522  * @brief Gets the number of app which is filtered by the given filter. If the filter is not given (i.e filter handle is NULL), all app are counted.
523  *
524  * @par Sync (or) Async : Synchronous API
525  *
526  * @param[in] filter    a filter handle
527  * @param[in] count             the number of appinfo which is filtered
528  *
529  * @return 0 if success, negative value(<0) if fail\n
530  * @retval      AIL_ERROR_OK                                    success
531  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
532  * @retval      AIL_ERROR_OUT_OF_MEMORY                 out of memory
533  *
534  * @pre None
535  * @post None
536  *
537  * @see ail_filter_new()
538  * @see ail_filter_add_bool()
539  * @see ail_filter_add_int()
540  * @see ail_filter_add_str()
541  *
542  * @par Prospective Clients:
543  * External Apps.
544  *
545  * @code
546 int count_apps()
547 {
548         ail_filter_h filter;
549         ail_error_e ret;
550         int n;
551
552         ret = ail_filter_new(&filter);
553         if (ret != AIL_ERROR_OK) {
554                 return -1;
555         }
556
557         ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, true);
558         if (ret != AIL_ERROR_OK) {
559                 return -1;
560         }
561
562         ret = ail_filter_count_appinfo(filter, &n);
563         if (ret != AIL_ERROR_OK) {
564                 return -1;
565         }
566
567         printf("N of app not to be displayed = %d", n);
568
569         ret = ail_filter_count_appinfo(NULL, &n);
570         if (ret != AIL_ERROR_OK) {
571                 return -1;
572         }
573
574         printf("N of all app = %d\n", n);
575
576         return n;
577 }
578  * @endcode
579  */
580 ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count);
581
582
583
584 /**
585  * @fn ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_h *handle)
586  *
587  * @brief get an application information related to a package. 
588         This API just retrieves all the information of the package from Application Information Database.
589         All data related to the package are loaded in the memory after calling this function. 
590         If you want to read a value from the retrieving data, you have to use the functions of ail_appinfo_get_xxx.
591
592  * @par Sync (or) Async : Synchronous API.
593  *
594  * @param[in] package package name what you want to know about.
595  * @param[out] handle handle will be used with the functions of ail_appinfo_get_xxx. If no data, it will be NULL.
596  *
597  * @return 0 if success, negative value(<0) if fail\n
598  * @retval      AIL_ERROR_OK                                    success
599  * @retval      AIL_ERROR_FAIL                                  internal error
600  * @retval      AIL_ERROR_DB_FAILED                             database error
601  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
602  * @retval      AIL_ERROR_NO_DATA                               no data. cannot find the package.
603  *
604  * @pre declare a handle before calling this function. The handle is used as a second argument of this API.
605  * @post destroy the handle with the function of ail_package_destroy_appinfo after using it all.
606  *
607  * @see  ail_package_destroy_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
608  *
609  * @par Prospective Clients:
610  * External Apps.
611  *
612  * @code
613 static ail_error_e _get_name(const char *package)
614 {
615         ail_appinfo_h handle;
616         ail_error_e ret;
617         char *str;
618
619         ret = ail_package_get_appinfo(package, &handle);
620         if (ret != AIL_ERROR_OK) {
621                 return AIL_ERROR_FAIL;
622         }
623
624         ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
625         if (ret != AIL_ERROR_OK) {
626                 return AIL_ERROR_FAIL;
627         }
628         fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str);
629
630         ret = ail_package_destroy_appinfo(handle);
631         if (ret != AIL_ERROR_OK) {
632                 return AIL_ERROR_FAIL;
633         }
634
635         return AIL_ERROR_OK;
636 }
637  * @endcode
638  */
639 ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_h *handle) __attribute__((deprecated));
640
641
642 /**
643  * @fn ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *handle)
644  *
645  * @brief get an application information related to a appid.
646         This API just retrieves all the information of the application from Application Information Database.
647         All data related to the appid are loaded in the memory after calling this function.
648         If you want to read a value from the retrieving data, you have to use the functions of ail_appinfo_get_xxx.
649
650  * @par Sync (or) Async : Synchronous API.
651  *
652  * @param[in] appid appid what you want to know about.
653  * @param[out] handle handle will be used with the functions of ail_appinfo_get_xxx. If no data, it will be NULL.
654  *
655  * @return 0 if success, negative value(<0) if fail\n
656  * @retval      AIL_ERROR_OK                                    success
657  * @retval      AIL_ERROR_FAIL                                  internal error
658  * @retval      AIL_ERROR_DB_FAILED                             database error
659  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
660  * @retval      AIL_ERROR_NO_DATA                               no data. cannot find the app.
661  *
662  * @pre declare a handle before calling this function. The handle is used as a second argument of this API.
663  * @post destroy the handle with the function of ail_get_appinfo after using it all.
664  *
665  * @see  ail_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
666  *
667  * @par Prospective Clients:
668  * External Apps.
669  *
670  * @code
671 static ail_error_e _get_name(const char *appid)
672 {
673         ail_appinfo_h handle;
674         ail_error_e ret;
675         char *str;
676
677         ret = ail_get_appinfo(appid, &handle);
678         if (ret != AIL_ERROR_OK) {
679                 return AIL_ERROR_FAIL;
680         }
681
682         ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
683         if (ret != AIL_ERROR_OK) {
684                 return AIL_ERROR_FAIL;
685         }
686         fprintf(stderr, "Package[%s], Property[%s] : %s\n", appid, property, str);
687
688         ret = ail_destroy_appinfo(handle);
689         if (ret != AIL_ERROR_OK) {
690                 return AIL_ERROR_FAIL;
691         }
692
693         return AIL_ERROR_OK;
694 }
695  * @endcode
696  */
697 ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *handle);
698
699
700 /**
701  * @fn ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *property, bool *value)
702  *
703  * @brief get a boolean value related to the property. 
704         Before using this API, the handle is defined by calling ail_get_appinfo.
705         This function needs a out-parameter for the value.
706  *
707  * @par Sync (or) Async : Synchronous API.
708  *
709  * @param[in] handle    the handle is defined by calling ail_get_appinfo.
710  * @param[in] property   a property type of boolean
711  * @param[out] value    a out-parameter value that is mapped with the property.
712  *
713  * @return 0 if success, negative value(<0) if fail\n
714  * @retval      AIL_ERROR_OK                                    success
715  * @retval      AIL_ERROR_DB_FAILED                             database error
716  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
717  *
718  * @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
719  * @post destroy the handle with the function of ail_destroy_appinfo after using it all.
720  *
721  * @see  ail_get_appinfo(), ail_destroy_appinfo(), ail_appinfo_get_int(), ail_appinfo_get_str()
722  *
723  * @par Prospective Clients:
724  * External Apps.
725  *
726  * @code
727 static ail_error_e _get_nodisplay(const char *appid)
728 {
729         ail_appinfo_h handle;
730         ail_error_e ret;
731         bool value;
732
733         ret = ail_get_appinfo(appid, &handle);
734         if (ret != AIL_ERROR_OK) {
735                 return AIL_ERROR_FAIL;
736         }
737
738         ret = ail_appinfo_get_bool(handle, AIL_PROP_NODISPLAY_BOOL, &value);
739         if (ret != AIL_ERROR_OK) {
740                 return AIL_ERROR_FAIL;
741         }
742         fprintf(stderr, "appid[%s] : %d\n", appid, value);
743
744         ret = ail_destroy_appinfo(handle);
745         if (ret != AIL_ERROR_OK) {
746                 return AIL_ERROR_FAIL;
747         }
748
749         return AIL_ERROR_OK;
750 }
751  * @endcode
752  */
753 ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *property, bool *value);
754
755
756
757 /**
758  * @fn ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property, int *value)
759  *
760  * @brief get a integer value related to the property. 
761         Before using this API, the handle is defined by calling ail_get_appinfo.
762         This function needs a out-parameter for the value.
763  *
764  * @par Sync (or) Async : Synchronous API.
765  *
766  * @param[in] handle    the handle is defined by calling ail_get_appinfo.
767  * @param[in] property  a property type of integer.
768  * @param[out] value    a out-parameter value that is mapped with the property.
769  *
770  * @return 0 if success, negative value(<0) if fail\n
771  * @retval      AIL_ERROR_OK                                    success
772  * @retval      AIL_ERROR_DB_FAILED                             database error
773  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
774  *
775  * @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
776  * @post destroy the handle with the function of ail_destroy_appinfo after using it all.
777  *
778  * @see  ail_get_appinfo(), ail_destroy_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_str()
779  *
780  * @par Prospective Clients:
781  * External Apps.
782  *
783  * @code
784 static ail_error_e _get_x_slp_baselayoutwidth(const char *appid)
785 {
786         ail_appinfo_h handle;
787         ail_error_e ret;
788         int value;
789
790         ret = ail_get_appinfo(appid, &handle);
791         if (ret != AIL_ERROR_OK) {
792                 return AIL_ERROR_FAIL;
793         }
794
795         ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, &value);
796         if (ret != AIL_ERROR_OK) {
797                 return AIL_ERROR_FAIL;
798         }
799         fprintf(stderr, "Package[%s] : %d\n", appid, value);
800
801         ret = ail_destroy_appinfo(handle);
802         if (ret != AIL_ERROR_OK) {
803                 return AIL_ERROR_FAIL;
804         }
805
806         return AIL_ERROR_OK;
807 }
808  * @endcode
809  */
810 ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property, int *value);
811
812
813
814 /**
815  * @fn ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, char **str)
816  *
817  * @brief get a string related to the property. 
818         Before using this API, the handle is defined by calling ail_get_appinfo.
819         This function needs a out-parameter for the value.
820  *
821  * @par Sync (or) Async : Synchronous API.
822  *
823  * @param[in] handle    the handle is defined by calling ail_get_appinfo.
824  * @param[in] property  a property type of string.
825  * @param[out] str              a out-parameter string that is mapped with the property. The icon property contains the absolute file path. If there is no data, the value of str is NULL.
826  *
827  * @return 0 if success, negative value(<0) if fail\n
828  * @retval      AIL_ERROR_OK                                    success
829  * @retval      AIL_ERROR_DB_FAILED                             database error
830  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
831  *
832  * @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
833  * @post str doesn't need to be freed. It will be freed by calling ail_destroy_appinfo.
834  *
835  * @see  ail_get_appinfo(), ail_destroy_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int()
836  *
837  * @par Prospective Clients:
838  * External Apps.
839  *
840  * @code
841 static ail_error_e _get_nodisplay(const char *appid)
842 {
843         ail_appinfo_h handle;
844         ail_error_e ret;
845         char* value;
846
847         ret = ail_get_appinfo(appid, &handle);
848         if (ret != AIL_ERROR_OK) {
849                 return AIL_ERROR_FAIL;
850         }
851
852         ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &value);
853         if (ret != AIL_ERROR_OK) {
854                 return AIL_ERROR_FAIL;
855         }
856         fprintf(stderr, "Package[%s] : %d\n", appid, value);
857
858         ret = ail_destroy_appinfo(handle);
859         if (ret != AIL_ERROR_OK) {
860                 return AIL_ERROR_FAIL;
861         }
862
863         return AIL_ERROR_OK;
864 }
865  * @endcode
866  */
867 ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, char **str);
868
869
870
871 /**
872  * @fn ail_error_e ail_package_destroy_appinfo(const ail_appinfo_h handle)
873  *
874  * @brief destroy a handle what you get with the function of ail_package_get_appinfo.
875  *
876  * @par Sync (or) Async : Synchronous API.
877  *
878  * @param[in] handle destroy all resources related to the handle.
879  *
880  * @return 0 if success, negative value(<0) if fail\n
881  * @retval      AIL_ERROR_OK                                    success
882  * @retval      AIL_ERROR_DB_FAILED                             database error
883  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
884  *
885  * @pre need a handle that you don't need anymore.
886  * @post cannot use the handle after destroying.
887  *
888  * @see  ail_package_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
889  *
890  * @par Prospective Clients:
891  * External Apps.
892  *
893  * @code
894 static ail_error_e _get_name(const char *package)
895 {
896         ail_appinfo_h handle;
897         ail_error_e ret;
898         char *str;
899
900         ret = ail_package_get_appinfo(package, &handle);
901         if (ret != AIL_ERROR_OK) {
902                 return AIL_ERROR_FAIL;
903         }
904
905         ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
906         if (ret != AIL_ERROR_OK) {
907                 return AIL_ERROR_FAIL;
908         }
909         fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str);
910
911         ret = ail_package_destroy_appinfo(handle);
912         if (ret != AIL_ERROR_OK) {
913                 return AIL_ERROR_FAIL;
914         }
915
916         return AIL_ERROR_OK;
917 }
918  * @endcode
919  */
920 ail_error_e ail_package_destroy_appinfo(const ail_appinfo_h handle) __attribute__((deprecated));
921
922
923 /**
924  * @fn ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle)
925  *
926  * @brief destroy a handle what you get with the function of ail_get_appinfo.
927  *
928  * @par Sync (or) Async : Synchronous API.
929  *
930  * @param[in] handle destroy all resources related to the handle.
931  *
932  * @return 0 if success, negative value(<0) if fail\n
933  * @retval      AIL_ERROR_OK                                    success
934  * @retval      AIL_ERROR_DB_FAILED                             database error
935  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
936  *
937  * @pre need a handle that you don't need anymore.
938  * @post cannot use the handle after destroying.
939  *
940  * @see  ail_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
941  *
942  * @par Prospective Clients:
943  * External Apps.
944  *
945  * @code
946 static ail_error_e _get_name(const char *appid)
947 {
948         ail_appinfo_h handle;
949         ail_error_e ret;
950         char *str;
951
952         ret = ail_get_appinfo(appid, &handle);
953         if (ret != AIL_ERROR_OK) {
954                 return AIL_ERROR_FAIL;
955         }
956
957         ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
958         if (ret != AIL_ERROR_OK) {
959                 return AIL_ERROR_FAIL;
960         }
961         fprintf(stderr, "Package[%s], Property[%s] : %s\n", appid, property, str);
962
963         ret = ail_destroy_appinfo(handle);
964         if (ret != AIL_ERROR_OK) {
965                 return AIL_ERROR_FAIL;
966         }
967
968         return AIL_ERROR_OK;
969 }
970  * @endcode
971  */
972 ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle);
973
974 /**
975  * @fn ail_error_e ail_close_appinfo_db(void)
976  *
977  * @brief close appinfo db.
978  *
979  * @par Sync (or) Async : Synchronous API.
980  *
981  * @return 0 if success, negative value(<0) if fail\n
982  * @retval      AIL_ERROR_OK                                    success
983  * @retval      AIL_ERROR_DB_FAILED                             database error
984  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
985  *
986  * @pre need a handle that you don't need anymore.
987  * @post cannot use the handle after destroying.
988  *
989  * @see  ail_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
990  *
991  * @par Prospective Clients:
992  * External Apps.
993  *
994  * @code
995 static ail_error_e _get_name(const char *appid)
996 {
997         ail_appinfo_h handle;
998         ail_error_e ret;
999         char *str;
1000
1001         ret = ail_get_appinfo(appid, &handle);
1002         if (ret != AIL_ERROR_OK) {
1003                 return AIL_ERROR_FAIL;
1004         }
1005
1006         ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
1007         if (ret != AIL_ERROR_OK) {
1008                 return AIL_ERROR_FAIL;
1009         }
1010         fprintf(stderr, "Package[%s], Property[%s] : %s\n", appid, property, str);
1011
1012         ret = ail_destroy_appinfo(handle);
1013         if (ret != AIL_ERROR_OK) {
1014                 return AIL_ERROR_FAIL;
1015         }
1016
1017         ret = ail_close_appinfo_db();
1018         if (ret != AIL_ERROR_OK) {
1019                 return AIL_ERROR_FAIL;
1020         }
1021
1022         return AIL_ERROR_OK;
1023 }
1024  * @endcode
1025  */
1026 ail_error_e ail_close_appinfo_db(void);
1027
1028
1029 /**
1030  * @fn ail_error_e ail_desktop_add(const char *appid)
1031  *
1032  * @brief add a app information into Application Information Database.
1033         A desktop file for this app has to be installed in the desktop directory before using this API.
1034         If there is no database for Application Information Database, this API will create the DB.
1035         If there is a DB, this function adds information for the app into the DB.
1036         And a notification is published to the applications who want to know about changing DB. 
1037  *
1038  * @par Sync (or) Async : Synchronous API.
1039  *
1040  * @param[in] appid
1041  *
1042  * @return 0 if success, negative value(<0) if fail\n
1043  * @retval      AIL_ERROR_OK                                    success
1044  * @retval      AIL_ERROR_FAIL                                  internal error
1045  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
1046  *
1047  * @pre a desktop file for the app has to be installed in the desktop directory before using this API.
1048  * @post app information is added into the Application Information Database.
1049  *
1050  * @see  ail_desktop_update(), ail_desktop_remove()
1051  *
1052  * @par Prospective Clients:
1053  * External Apps.
1054  *
1055  * @code
1056 static ail_error_e _add_desktop(const char *appid)
1057 {
1058         ail_error_e ret;
1059
1060         if (!appid) {
1061                 return AIL_ERROR_FAIL;
1062         }
1063
1064         ret = ail_desktop_add(appid);
1065         if (ret != AIL_ERROR_OK) {
1066                 return AIL_ERROR_FAIL;
1067         }
1068
1069         return AIL_ERROR_OK;
1070 }
1071  * @endcode
1072  */
1073 ail_error_e ail_desktop_add(const char *appid);
1074
1075
1076
1077 /**
1078  * @fn ail_error_e ail_desktop_update(const char *appid)
1079  *
1080  * @brief update a app information in the Application Information Database.
1081         A desktop file for this app has to be installed in the desktop directory before using this API.
1082         And a notification is published to the applications who want to know about changing DB. 
1083  *
1084  * @par Sync (or) Async : Synchronous API.
1085  *
1086  * @param[in] appid
1087  *
1088  * @return 0 if success, negative value(<0) if fail\n
1089  * @retval      AIL_ERROR_OK                                    success
1090  * @retval      AIL_ERROR_FAIL                                  internal error
1091  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
1092  *
1093  * @pre a desktop file for the app has to be installed in the desktop directory before using this API.
1094  * @post update a app information in the Application Information Database.
1095  *
1096  * @see  ail_desktop_add(), ail_desktop_remove()
1097  *
1098  * @par Prospective Clients:
1099  * External Apps.
1100  *
1101  * @code
1102 static ail_error_e _update_desktop(const char *appid)
1103 {
1104         ail_error_e ret;
1105
1106         if (!appid) {
1107                 return AIL_ERROR_FAIL;
1108         }
1109
1110         ret = ail_desktop_update(appid);
1111         if (ret != AIL_ERROR_OK) {
1112                 return AIL_ERROR_FAIL;
1113         }
1114
1115         return AIL_ERROR_OK;
1116 }
1117  * @endcode
1118  */
1119 ail_error_e ail_desktop_update(const char *appid);
1120
1121
1122
1123 /**
1124  * @fn ail_error_e ail_desktop_remove(const char *appid)
1125  *
1126  * @brief remove a app information in the Application Information Database.
1127         And a notification is published to the applications who want to know about changing DB. 
1128  *
1129  * @par Sync (or) Async : Synchronous API.
1130  *
1131  * @param[in] appid
1132  *
1133  * @return 0 if success, negative value(<0) if fail\n
1134  * @retval      AIL_ERROR_OK                                    success
1135  * @retval      AIL_ERROR_FAIL                                  internal error
1136  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
1137  *
1138  * @pre no pre-condition.
1139  * @post app information is removed in the Application Information Database.
1140  *
1141  * @see  ail_desktop_add(), ail_desktop_update()
1142  *
1143  * @par Prospective Clients:
1144  * External Apps.
1145  *
1146  * @code
1147 static ail_error_e _remove_desktop(const char *appid)
1148 {
1149         ail_error_e ret;
1150
1151         if (!appid) {
1152                 return AIL_ERROR_FAIL;
1153         }
1154
1155         ret = ail_desktop_remove(appid);
1156         if (ret != AIL_ERROR_OK) {
1157                 return AIL_ERROR_FAIL;
1158         }
1159
1160         return AIL_ERROR_OK;
1161 }
1162  * @endcode
1163  */
1164 ail_error_e ail_desktop_remove(const char *appid);
1165
1166 /**
1167  * @fn ail_error_e ail_desktop_clean(const char *pkgid)
1168  *
1169  * @brief clean a pkg information in the Application Information Database.
1170  *
1171  * @par Sync (or) Async : Synchronous API.
1172  *
1173  * @param[in] pkgid
1174  *
1175  * @return 0 if success, negative value(<0) if fail\n
1176  * @retval      AIL_ERROR_OK                                    success
1177  * @retval      AIL_ERROR_FAIL                                  internal error
1178  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
1179  *
1180  * @pre no pre-condition.
1181  * @post app information is removed in the Application Information Database.
1182  *
1183  * @see  ail_desktop_add(), ail_desktop_update()
1184  *
1185  * @par Prospective Clients:
1186  * External Apps.
1187  *
1188  * @code
1189 static ail_error_e _clean_desktop(const char *pkgid)
1190 {
1191         ail_error_e ret;
1192
1193         if (!appid) {
1194                 return AIL_ERROR_FAIL;
1195         }
1196
1197         ret = ail_desktop_clean(pkgid);
1198         if (ret != AIL_ERROR_OK) {
1199                 return AIL_ERROR_FAIL;
1200         }
1201
1202         return AIL_ERROR_OK;
1203 }
1204  * @endcode
1205  */
1206 ail_error_e ail_desktop_clean(const char *pkgid);
1207
1208
1209 /**
1210  * @fn ail_error_e ail_desktop_fota(const char *appid)
1211  *
1212  * @brief add a app information into Application Information Database.
1213         A desktop file for this app has to be installed in the desktop directory before using this API.
1214         If there is no database for Application Information Database, this API will create the DB.
1215         If there is a DB, this function adds information for the app into the DB.
1216         And a notification is not published to the applications who want to know about changing DB.
1217  *
1218  * @par Sync (or) Async : Synchronous API.
1219  *
1220  * @param[in] appid
1221  *
1222  * @return 0 if success, negative value(<0) if fail\n
1223  * @retval      AIL_ERROR_OK                                    success
1224  * @retval      AIL_ERROR_FAIL                                  internal error
1225  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
1226  *
1227  * @pre a desktop file for the app has to be installed in the desktop directory before using this API.
1228  * @post app information is added into the Application Information Database.
1229  *
1230  * @see  ail_desktop_update(), ail_desktop_remove()
1231  *
1232  * @par Prospective Clients:
1233  * External Apps.
1234  *
1235  * @code
1236 static ail_error_e _add_desktop_fota(const char *appid)
1237 {
1238         ail_error_e ret;
1239
1240         if (!appid) {
1241                 return AIL_ERROR_FAIL;
1242         }
1243
1244         ret = ail_desktop_fota(appid);
1245         if (ret != AIL_ERROR_OK) {
1246                 return AIL_ERROR_FAIL;
1247         }
1248
1249         return AIL_ERROR_OK;
1250 }
1251  * @endcode
1252  */
1253 ail_error_e ail_desktop_fota(const char *appid);
1254
1255 /**
1256  * @fn ail_error_e ail_desktop_appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast)
1257  *
1258  * @brief update a app information db.
1259         And a notification is published to the applications who want to know about changing DB.
1260  *
1261  * @par Sync (or) Async : Synchronous API.
1262  *
1263  * @param[in] appid
1264  *
1265  * @return 0 if success, negative value(<0) if fail\n
1266  * @retval      AIL_ERROR_OK                                    success
1267  * @retval      AIL_ERROR_FAIL                                  internal error
1268  * @retval      AIL_ERROR_INVALID_PARAMETER             invalid parameter
1269  *
1270  * @pre no pre-condition.
1271  * @post app information is removed in the Application Information Database.
1272  *
1273  *
1274  * @par Prospective Clients:
1275  * External Apps.
1276  *
1277  * @code
1278 static ail_error_e _appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast)
1279 {
1280         ail_error_e ret;
1281
1282         if (!appid) {
1283                 return AIL_ERROR_FAIL;
1284         }
1285         if (!property) {
1286                 return AIL_ERROR_FAIL;
1287         }
1288         if (!value) {
1289                 return AIL_ERROR_FAIL;
1290         }
1291
1292         ret = ail_desktop_appinfo_modify_str(appid, property, value, broadcast);
1293         if (ret != AIL_ERROR_OK) {
1294                 return AIL_ERROR_FAIL;
1295         }
1296
1297         return AIL_ERROR_OK;
1298 }
1299  * @endcode
1300  */
1301
1302 ail_error_e ail_desktop_appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast);
1303
1304 /** @} */
1305
1306
1307 #ifdef __cplusplus
1308 }
1309 #endif /* __cplusplus */
1310
1311 #endif /* __AIL_H__ */
1312 // End of a file