4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
30 #include <sys/types.h>
32 #include <tzplatform_config.h>
35 #define GROUP_MENU 6010
36 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
38 #define USR_DESKTOP_DIRECTORY tzplatform_getenv(TZ_SYS_RO_DESKTOP_APP)
39 #define APP_INFO_DB_FILE tzplatform_mkpath(TZ_SYS_DB,".app_info.db")
40 #define APP_INFO_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB,".app_info.db-journal")
41 #define APP_INFO_DB_LABEL "*"
45 #endif /* __cplusplus */
51 * @ingroup APPLICATION_FRAMEWORK
52 * @defgroup ail Application Information Library
57 * @brief Application Information Library header
58 * @author Sunghyuk Lee (sunghyuk.lee@samsung.com), Jin Yoon (jinny.yoon@samsung.com)
69 * @brief string type properties
71 #define AIL_PROP_PACKAGE_STR "AIL_PROP_PACKAGE_STR"
72 #define AIL_PROP_EXEC_STR "AIL_PROP_EXEC_STR"
73 #define AIL_PROP_NAME_STR "AIL_PROP_NAME_STR"
74 #define AIL_PROP_TYPE_STR "AIL_PROP_TYPE_STR"
75 #define AIL_PROP_ICON_STR "AIL_PROP_ICON_STR"
76 #define AIL_PROP_CATEGORIES_STR "AIL_PROP_CATEGORIES_STR"
77 #define AIL_PROP_VERSION_STR "AIL_PROP_VERSION_STR"
78 #define AIL_PROP_MIMETYPE_STR "AIL_PROP_MIMETYPE_STR"
79 #define AIL_PROP_X_SLP_SERVICE_STR "AIL_PROP_X_SLP_SERVICE_STR"
80 #define AIL_PROP_X_SLP_PACKAGETYPE_STR "AIL_PROP_X_SLP_PACKAGETYPE_STR"
81 #define AIL_PROP_X_SLP_PACKAGECATEGORIES_STR "AIL_PROP_X_SLP_PACKAGECATEGORIES_STR"
82 #define AIL_PROP_X_SLP_PACKAGEID_STR "AIL_PROP_X_SLP_PACKAGEID_STR"
83 #define AIL_PROP_X_SLP_SVC_STR "AIL_PROP_X_SLP_SVC_STR"
84 #define AIL_PROP_X_SLP_EXE_PATH "AIL_PROP_X_SLP_EXE_PATH"
85 #define AIL_PROP_X_SLP_APPID_STR "AIL_PROP_X_SLP_APPID_STR"
86 #define AIL_PROP_X_SLP_PKGID_STR "AIL_PROP_X_SLP_PKGID_STR"
87 #define AIL_PROP_X_SLP_DOMAIN_STR "AIL_PROP_X_SLP_DOMAIN_STR"
88 #define AIL_PROP_X_SLP_SUBMODEMAINID_STR "AIL_PROP_X_SLP_SUBMODEMAINID_STR"
89 #define AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR "AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR"
92 * @brief integer type properties
94 #define AIL_PROP_X_SLP_TEMP_INT "AIL_PROP_X_SLP_TEMP_INT"
95 #define AIL_PROP_X_SLP_INSTALLEDTIME_INT "AIL_PROP_X_SLP_INSTALLEDTIME_INT"
98 * @brief boolean type properties
100 #define AIL_PROP_NODISPLAY_BOOL "AIL_PROP_NODISPLAY_BOOL"
101 #define AIL_PROP_X_SLP_TASKMANAGE_BOOL "AIL_PROP_X_SLP_TASKMANAGE_BOOL"
102 #define AIL_PROP_X_SLP_MULTIPLE_BOOL "AIL_PROP_X_SLP_MULTIPLE_BOOL"
103 #define AIL_PROP_X_SLP_REMOVABLE_BOOL "AIL_PROP_X_SLP_REMOVABLE_BOOL"
104 #define AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL "AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL"
105 #define AIL_PROP_X_SLP_ENABLED_BOOL "AIL_PROP_X_SLP_ENABLED_BOOL"
106 #define AIL_PROP_X_SLP_SUBMODE_BOOL "AIL_PROP_X_SLP_SUBMODE_BOOL"
109 * @brief A handle for filters
111 typedef struct ail_filter *ail_filter_h;
114 * @brief A handle for appinfos
116 typedef struct ail_appinfo *ail_appinfo_h;
119 * @brief return values
122 AIL_ERROR_OK = 0, /**< General success */
123 AIL_ERROR_FAIL = -1, /**< General error */
124 AIL_ERROR_DB_FAILED = -2, /**< Database error */
125 AIL_ERROR_OUT_OF_MEMORY = -3, /**< Out of memory */
126 AIL_ERROR_INVALID_PARAMETER = -4, /**< Invalid parameter */
127 AIL_ERROR_NO_DATA = -5, /**< Success, but no data */
131 * @fn ail_error_e ail_filter_new(ail_filter_h *filter)
133 * @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.
135 * @par Sync (or) Async : Synchronous API.
137 * @param[out] filter a pointer to a filter which is newly created
139 * @return 0 if success, negative value(<0) if fail\n
140 * @retval AIL_ERROR_OK success
141 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
142 * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
145 * @post If the filter is no longer used, it should be freed with ail_filter_destroy()
147 * @see ail_filter_destroy()
149 * @par Prospective Clients:
159 ret = ail_filter_new(&filter);
160 if (ret != AIL_ERROR_OK) {
164 ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
165 if (ret != AIL_ERROR_OK) {
169 ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, "audio/wav");
170 if (ret != AIL_ERROR_OK) {
174 ret = ail_filter_count_appinfo(filter, &n);
175 if (ret != AIL_ERROR_OK) {
178 ret = ail_filter_destroy(filter);
180 printf("N of apps not to be displayed and supporting 'audo/wav' mime type = %d\n", n);
186 ail_error_e ail_filter_new(ail_filter_h *filter);
191 * @fn ail_error_e ail_error_e ail_filter_add_int(ail_filter_h filter, const char *property, const int value)
193 * @brief Add integer condition to filter
195 * @par Sync (or) Async : Synchronous API
197 * @param[in] filter a filter handle which can be create with ail_filter_new()
198 * @param[in] property a property type of integer
199 * @param[in] value the value to filter by
201 * @return 0 if success, negative value(<0) if fail\n
202 * @retval AIL_ERROR_OK success
203 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
204 * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
206 * @pre The filter should be valid handle which was created by ail_filter_new()
208 * @see ail_filter_new()
210 * @par Prospective Clients:
220 ret = ail_filter_new(&filter);
221 if (ret != AIL_ERROR_OK) {
225 ret = ail_filter_add_int(filter, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, 480);
226 if (ret != AIL_ERROR_OK) {
230 ret = ail_filter_count_appinfo(filter, &n);
231 if (ret != AIL_ERROR_OK) {
235 printf("N of apps = %d\n", n);
241 ail_error_e ail_filter_add_int(ail_filter_h filter, const char *property, const int value);
245 * @fn ail_error_e ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *property, const bool value)
247 * @brief Add boolean condition to filter by. The value can be true/false only
249 * @par Sync (or) Async : Synchronous API
251 * @param[in] filter a filter handle which can be create with ail_filter_new()
252 * @param[in] property a property type of boolean
253 * @param[in] value the value to filter by
255 * @return 0 if success, negative value(<0) if fail\n
256 * @retval AIL_ERROR_OK success
257 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
258 * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
260 * @pre The filter should be valid handle which was created by ail_filter_new()
262 * @see ail_filter_new()
264 * @par Prospective Clients:
274 ret = ail_filter_new(&filter);
275 if (ret != AIL_ERROR_OK) {
279 ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
280 if (ret != AIL_ERROR_OK) {
284 ret = ail_filter_count_appinfo(filter, &n);
285 if (ret != AIL_ERROR_OK) {
289 fprintf(stderr, "N of apps = %d\n", n);
295 ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *property, bool value);
300 * @fn ail_error_e ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const char *value)
302 * @brief Add string condition to filter by. The string is case-sensitive.
304 * @par Sync (or) Async : Synchronous API
306 * @param[in] filter a filter handle which can be create with ail_filter_new()
307 * @param[in] property a property type of string
308 * @param[in] value the value to filter by
310 * @return 0 if success, negative value(<0) if fail\n
311 * @retval AIL_ERROR_OK success
312 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
313 * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
315 * @pre The filter should be valid handle which was created by ail_filter_new()
317 * @see ail_filter_new()
319 * @par Prospective Clients:
329 ret = ail_filter_new(&filter);
330 if (ret != AIL_ERROR_OK) {
334 ret = ail_filter_add_str(filter, AIL_PROP_PACKAGE_STR, "com.samsung.memo");
335 if (ret != AIL_ERROR_OK) {
339 ret = ail_filter_count_appinfo(filter, &n);
340 if (ret != AIL_ERROR_OK) {
344 fprintf(stderr, "N of apps = %d\n", n);
350 ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const char *value);
355 * @fn ail_error_e ail_filter_destroy(ail_filter_h filter)
357 * @brief Destroy a filter which is not used any longer.
359 * @par Sync (or) Async : Synchronous API
361 * @param[in] filter filter handle
363 * @return 0 if success, negative value(<0) if fail\n
364 * @retval AIL_ERROR_OK success
365 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
367 * @post If the filter is no longer used, it should be freed with ail_filter_destroy()
369 * @see ail_filter_new()
371 * @par Prospective Clients:
381 ret = ail_filter_new(&filter);
382 if (ret != AIL_ERROR_OK) {
386 ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
387 if (ret != AIL_ERROR_OK) {
391 ret = ail_filter_count_appinfo(filter, &n);
392 if (ret != AIL_ERROR_OK) {
396 printf("N of removable apps = %d\n", n);
398 ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, "audio/wav");
399 if (ret != AIL_ERROR_OK) {
403 ret = ail_filter_count_appinfo(filter, &n);
404 if (ret != AIL_ERROR_OK) {
408 printf("N of apps removable and supporting 'audo/wav' mime type = %d\n", n);
410 ret = ail_filter_destroy(filter);
416 ail_error_e ail_filter_destroy(ail_filter_h filter);
421 * @brief return value type of ail_list_appinfo_cb
424 AIL_CB_RET_CONTINUE = 1, /**< continue */
425 AIL_CB_RET_CANCEL = 0, /**< cancel */
429 * @fn ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void *user_data)
431 * @breif Specifies the type of functions passed to ail_filter_list_appinfo_foreach().
433 * @param[in] appinfo_h the appinfo's handle
434 * @param[in] user_data user data passed to ail_filtet_list_appinfo_foreach()
436 * @return 0 if success, negative value(<0) if fail\n
437 * @retval AIL_CB_RET_CONTINUE return if you continue iteration
438 * @retval AIL_CB_RET_CANCEL return if you cancel iteration
440 * @see ail_filter_list_appinfo_foreach()
442 typedef ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void *user_data,uid_t uid);
445 * @fn ail_error_e ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb func, void *user_data)
446 * @fn ail_error_e ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb func, void *user_data, uid_t uid)
447 * @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.
449 * @par Sync (or) Async : Synchronous API
451 * @param[in] filter a filter handle
452 * @param[in] func the function to call with each app's appinfo
453 * @param[in] user_data user_data to pass to the function
454 * @param[in] uid ID of the owner of the application
456 * @return 0 if success, negative value(<0) if fail\n
457 * @retval AIL_ERROR_OK success
458 * @retval AIL_ERROR_DB_FAILED database error
459 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
461 * @see ail_list_appinfo_cb
462 * @see ail_filter_add_bool()
463 * @see ail_filter_add_int()
464 * @see ail_filter_add_str()
466 * @par Prospective Clients:
471 ail_cb_ret_e appinfo_func(const ail_appinfo_h appinfo, void *user_data)
473 int *i = (int *)user_data;
476 ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &appid);
477 printf("i=%d %s\n", (*i)++, appid);
480 return AIL_CB_RET_CANCEL;
482 return AIL_CB_RET_CONTINUE;
491 ret = ail_filter_new(&filter);
492 if (ret != AIL_ERROR_OK) {
496 ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
497 if (ret != AIL_ERROR_OK) {
501 ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
502 if (ret != AIL_ERROR_OK) {
506 printf("List apps which are removable and 'Application' typed\n");
507 ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
509 ail_filter_destroy(filter);
515 ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter,
516 ail_list_appinfo_cb appinfo_func,
518 ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter,
519 ail_list_appinfo_cb appinfo_func,
520 void *user_data, uid_t uid);
522 * @fn ail_error_e ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count, uid_t uid)
523 * @fn ail_error_e ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *count)
524 * @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.
526 * @par Sync (or) Async : Synchronous API
528 * @param[in] filter a filter handle
529 * @param[in] count the number of appinfo which is filtered
530 * @param[in] uid ID of the owner of the application
532 * @return 0 if success, negative value(<0) if fail\n
533 * @retval AIL_ERROR_OK success
534 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
535 * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
540 * @see ail_filter_new()
541 * @see ail_filter_add_bool()
542 * @see ail_filter_add_int()
543 * @see ail_filter_add_str()
545 * @par Prospective Clients:
555 ret = ail_filter_new(&filter);
556 if (ret != AIL_ERROR_OK) {
560 ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, true);
561 if (ret != AIL_ERROR_OK) {
565 ret = ail_filter_count_appinfo(filter, &n);
566 if (ret != AIL_ERROR_OK) {
570 printf("N of app not to be displayed = %d", n);
572 ret = ail_filter_count_appinfo(NULL, &n);
573 if (ret != AIL_ERROR_OK) {
577 printf("N of all app = %d\n", n);
583 ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count);
584 ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *count, uid_t uid);
587 * @fn ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_h *handle)
588 * @fn ail_error_e ail_package_get_appinfo(const char *package, uid_t uid, ail_appinfo_h *handle)
589 * @brief get an application information related to a package.
590 This API just retrieves all the information of the package from Application Information Database.
591 All data related to the package are loaded in the memory after calling this function.
592 If you want to read a value from the retrieving data, you have to use the functions of ail_appinfo_get_xxx.
594 * @par Sync (or) Async : Synchronous API.
596 * @param[in] package package name what you want to know about.
597 * @param[in] uid ID of the owner of the application
598 * @param[out] handle handle will be used with the functions of ail_appinfo_get_xxx. If no data, it will be NULL.
600 * @return 0 if success, negative value(<0) if fail\n
601 * @retval AIL_ERROR_OK success
602 * @retval AIL_ERROR_FAIL internal error
603 * @retval AIL_ERROR_DB_FAILED database error
604 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
605 * @retval AIL_ERROR_NO_DATA no data. cannot find the package.
607 * @pre declare a handle before calling this function. The handle is used as a second argument of this API.
608 * @post destroy the handle with the function of ail_package_destroy_appinfo after using it all.
610 * @see ail_package_destroy_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
612 * @par Prospective Clients:
616 static ail_error_e _get_name(const char *package)
618 ail_appinfo_h handle;
622 ret = ail_package_get_appinfo(package, &handle);
623 if (ret != AIL_ERROR_OK) {
624 return AIL_ERROR_FAIL;
627 ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
628 if (ret != AIL_ERROR_OK) {
629 return AIL_ERROR_FAIL;
631 fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str);
633 ret = ail_package_destroy_appinfo(handle);
634 if (ret != AIL_ERROR_OK) {
635 return AIL_ERROR_FAIL;
642 ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_h *handle) __attribute__((deprecated));
643 ail_error_e ail_package_get_usr_appinfo(const char *package, uid_t uid, ail_appinfo_h *handle) __attribute__((deprecated));
645 * @fn ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *handle)
646 * @fn ail_error_e ail_get_usr_appinfo(const char *appid, uid_t uid, ail_appinfo_h *handle)
647 * @brief get an application information related to a appid.
648 This API just retrieves all the information of the application from Application Information Database.
649 All data related to the appid are loaded in the memory after calling this function.
650 If you want to read a value from the retrieving data, you have to use the functions of ail_appinfo_get_xxx.
652 * @par Sync (or) Async : Synchronous API.
654 * @param[in] appid appid what you want to know about.
655 * @param[out] handle handle will be used with the functions of ail_appinfo_get_xxx. If no data, it will be NULL.
657 * @return 0 if success, negative value(<0) if fail\n
658 * @retval AIL_ERROR_OK success
659 * @retval AIL_ERROR_FAIL internal error
660 * @retval AIL_ERROR_DB_FAILED database error
661 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
662 * @retval AIL_ERROR_NO_DATA no data. cannot find the app.
664 * @pre declare a handle before calling this function. The handle is used as a second argument of this API.
665 * @post destroy the handle with the function of ail_get_appinfo after using it all.
667 * @see ail_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
669 * @par Prospective Clients:
673 static ail_error_e _get_name(const char *appid)
675 ail_appinfo_h handle;
679 ret = ail_get_appinfo(appid, &handle);
680 if (ret != AIL_ERROR_OK) {
681 return AIL_ERROR_FAIL;
684 ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
685 if (ret != AIL_ERROR_OK) {
686 return AIL_ERROR_FAIL;
688 fprintf(stderr, "Package[%s], Property[%s] : %s\n", appid, property, str);
690 ret = ail_destroy_appinfo(handle);
691 if (ret != AIL_ERROR_OK) {
692 return AIL_ERROR_FAIL;
699 ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *handle);
700 ail_error_e ail_get_usr_appinfo(const char *appid, uid_t uid, ail_appinfo_h *handle);
703 * @fn ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *property, bool *value)
705 * @brief get a boolean value related to the property.
706 Before using this API, the handle is defined by calling ail_get_appinfo.
707 This function needs a out-parameter for the value.
709 * @par Sync (or) Async : Synchronous API.
711 * @param[in] handle the handle is defined by calling ail_get_appinfo.
712 * @param[in] property a property type of boolean
713 * @param[out] value a out-parameter value that is mapped with the property.
715 * @return 0 if success, negative value(<0) if fail\n
716 * @retval AIL_ERROR_OK success
717 * @retval AIL_ERROR_DB_FAILED database error
718 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
720 * @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
721 * @post destroy the handle with the function of ail_destroy_appinfo after using it all.
723 * @see ail_get_appinfo(), ail_destroy_appinfo(), ail_appinfo_get_int(), ail_appinfo_get_str()
725 * @par Prospective Clients:
729 static ail_error_e _get_nodisplay(const char *appid)
731 ail_appinfo_h handle;
735 ret = ail_get_appinfo(appid, &handle);
736 if (ret != AIL_ERROR_OK) {
737 return AIL_ERROR_FAIL;
740 ret = ail_appinfo_get_bool(handle, AIL_PROP_NODISPLAY_BOOL, &value);
741 if (ret != AIL_ERROR_OK) {
742 return AIL_ERROR_FAIL;
744 fprintf(stderr, "appid[%s] : %d\n", appid, value);
746 ret = ail_destroy_appinfo(handle);
747 if (ret != AIL_ERROR_OK) {
748 return AIL_ERROR_FAIL;
755 ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *property, bool *value);
760 * @fn ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property, int *value)
762 * @brief get a integer value related to the property.
763 Before using this API, the handle is defined by calling ail_get_appinfo.
764 This function needs a out-parameter for the value.
766 * @par Sync (or) Async : Synchronous API.
768 * @param[in] handle the handle is defined by calling ail_get_appinfo.
769 * @param[in] property a property type of integer.
770 * @param[out] value a out-parameter value that is mapped with the property.
772 * @return 0 if success, negative value(<0) if fail\n
773 * @retval AIL_ERROR_OK success
774 * @retval AIL_ERROR_DB_FAILED database error
775 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
777 * @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
778 * @post destroy the handle with the function of ail_destroy_appinfo after using it all.
780 * @see ail_get_appinfo(), ail_destroy_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_str()
782 * @par Prospective Clients:
786 static ail_error_e _get_x_slp_baselayoutwidth(const char *appid)
788 ail_appinfo_h handle;
792 ret = ail_get_appinfo(appid, &handle);
793 if (ret != AIL_ERROR_OK) {
794 return AIL_ERROR_FAIL;
797 ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, &value);
798 if (ret != AIL_ERROR_OK) {
799 return AIL_ERROR_FAIL;
801 fprintf(stderr, "Package[%s] : %d\n", appid, value);
803 ret = ail_destroy_appinfo(handle);
804 if (ret != AIL_ERROR_OK) {
805 return AIL_ERROR_FAIL;
812 ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property, int *value);
815 * @fn ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, uid_t uid, char **str)
816 * @fn ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h handle, const char *property, char **str)
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.
821 * @par Sync (or) Async : Synchronous API.
823 * @param[in] handle the handle is defined by calling ail_get_appinfo.
824 * @param[in] property a property type of string.
825 * @param[in] uid the addressee user id of the instruction
826 * @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.
828 * @return 0 if success, negative value(<0) if fail\n
829 * @retval AIL_ERROR_OK success
830 * @retval AIL_ERROR_DB_FAILED database error
831 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
833 * @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
834 * @post str doesn't need to be freed. It will be freed by calling ail_destroy_appinfo.
836 * @see ail_get_appinfo(), ail_destroy_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int()
838 * @par Prospective Clients:
842 static ail_error_e _get_nodisplay(const char *appid)
844 ail_appinfo_h handle;
848 ret = ail_get_appinfo(appid, &handle);
849 if (ret != AIL_ERROR_OK) {
850 return AIL_ERROR_FAIL;
853 ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &value);
854 if (ret != AIL_ERROR_OK) {
855 return AIL_ERROR_FAIL;
857 fprintf(stderr, "Package[%s] : %d\n", appid, value);
859 ret = ail_destroy_appinfo(handle);
860 if (ret != AIL_ERROR_OK) {
861 return AIL_ERROR_FAIL;
868 ail_error_e ail_appinfo_get_str(const ail_appinfo_h handle, const char *property, char **str);
869 ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h handle, const char *property, uid_t uid, char **str);
873 * @fn ail_error_e ail_package_destroy_appinfo(const ail_appinfo_h handle)
875 * @brief destroy a handle what you get with the function of ail_package_get_appinfo.
877 * @par Sync (or) Async : Synchronous API.
879 * @param[in] handle destroy all resources related to the handle.
881 * @return 0 if success, negative value(<0) if fail\n
882 * @retval AIL_ERROR_OK success
883 * @retval AIL_ERROR_DB_FAILED database error
884 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
886 * @pre need a handle that you don't need anymore.
887 * @post cannot use the handle after destroying.
889 * @see ail_package_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
891 * @par Prospective Clients:
895 static ail_error_e _get_name(const char *package)
897 ail_appinfo_h handle;
901 ret = ail_package_get_appinfo(package, &handle);
902 if (ret != AIL_ERROR_OK) {
903 return AIL_ERROR_FAIL;
906 ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
907 if (ret != AIL_ERROR_OK) {
908 return AIL_ERROR_FAIL;
910 fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str);
912 ret = ail_package_destroy_appinfo(handle);
913 if (ret != AIL_ERROR_OK) {
914 return AIL_ERROR_FAIL;
921 ail_error_e ail_package_destroy_appinfo(const ail_appinfo_h handle) __attribute__((deprecated));
925 * @fn ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle)
927 * @brief destroy a handle what you get with the function of ail_get_appinfo.
929 * @par Sync (or) Async : Synchronous API.
931 * @param[in] handle destroy all resources related to the handle.
933 * @return 0 if success, negative value(<0) if fail\n
934 * @retval AIL_ERROR_OK success
935 * @retval AIL_ERROR_DB_FAILED database error
936 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
938 * @pre need a handle that you don't need anymore.
939 * @post cannot use the handle after destroying.
941 * @see ail_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
943 * @par Prospective Clients:
947 static ail_error_e _get_name(const char *appid)
949 ail_appinfo_h handle;
953 ret = ail_get_appinfo(appid, &handle);
954 if (ret != AIL_ERROR_OK) {
955 return AIL_ERROR_FAIL;
958 ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
959 if (ret != AIL_ERROR_OK) {
960 return AIL_ERROR_FAIL;
962 fprintf(stderr, "Package[%s], Property[%s] : %s\n", appid, property, str);
964 ret = ail_destroy_appinfo(handle);
965 if (ret != AIL_ERROR_OK) {
966 return AIL_ERROR_FAIL;
973 ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle);
976 * @fn ail_error_e ail_close_appinfo_db(void)
978 * @brief close appinfo db.
980 * @par Sync (or) Async : Synchronous API.
982 * @return 0 if success, negative value(<0) if fail\n
983 * @retval AIL_ERROR_OK success
984 * @retval AIL_ERROR_DB_FAILED database error
985 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
987 * @pre need a handle that you don't need anymore.
988 * @post cannot use the handle after destroying.
990 * @see ail_get_appinfo(), ail_appinfo_get_bool(), ail_appinfo_get_int(), ail_appinfo_get_str()
992 * @par Prospective Clients:
996 static ail_error_e _get_name(const char *appid)
998 ail_appinfo_h handle;
1002 ret = ail_get_appinfo(appid, &handle);
1003 if (ret != AIL_ERROR_OK) {
1004 return AIL_ERROR_FAIL;
1007 ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &str);
1008 if (ret != AIL_ERROR_OK) {
1009 return AIL_ERROR_FAIL;
1011 fprintf(stderr, "Package[%s], Property[%s] : %s\n", appid, property, str);
1013 ret = ail_destroy_appinfo(handle);
1014 if (ret != AIL_ERROR_OK) {
1015 return AIL_ERROR_FAIL;
1018 ret = ail_close_appinfo_db();
1019 if (ret != AIL_ERROR_OK) {
1020 return AIL_ERROR_FAIL;
1023 return AIL_ERROR_OK;
1027 ail_error_e ail_close_appinfo_db(void);
1031 * @fn ail_error_e ail_desktop_add(const char *appid, )
1032 * @fn ail_error_e ail_usr_desktop_add(const char *appid, uid_t uid)
1033 * @brief add a app information into Application Information Database.
1034 A desktop file for this app has to be installed in the desktop directory before using this API.
1035 If there is no database for Application Information Database, this API will create the DB.
1036 If there is a DB, this function adds information for the app into the DB.
1037 And a notification is published to the applications who want to know about changing DB.
1039 * @par Sync (or) Async : Synchronous API.
1042 * @param[in] uid the addressee user id of the instruction
1044 * @return 0 if success, negative value(<0) if fail\n
1045 * @retval AIL_ERROR_OK success
1046 * @retval AIL_ERROR_FAIL internal error
1047 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
1049 * @pre a desktop file for the app has to be installed in the desktop directory before using this API.
1050 * @post app information is added into the Application Information Database.
1052 * @see ail_desktop_update(), ail_desktop_remove()
1054 * @par Prospective Clients:
1058 static ail_error_e _add_desktop(const char *appid)
1063 return AIL_ERROR_FAIL;
1066 ret = ail_desktop_add(appid);
1067 if (ret != AIL_ERROR_OK) {
1068 return AIL_ERROR_FAIL;
1071 return AIL_ERROR_OK;
1075 ail_error_e ail_desktop_add(const char *appid);
1076 ail_error_e ail_usr_desktop_add(const char *appid, uid_t uid);
1080 * @fn ail_error_e ail_desktop_update(const char *appid)
1081 * @fn ail_error_e ail_usr_desktop_update(const char *appid, uid_t uid)
1082 * @brief update a app information in the Application Information Database.
1083 A desktop file for this app has to be installed in the desktop directory before using this API.
1084 And a notification is published to the applications who want to know about changing DB.
1086 * @par Sync (or) Async : Synchronous API.
1089 * @param[in] uid ID of the owner of the application
1091 * @return 0 if success, negative value(<0) if fail\n
1092 * @retval AIL_ERROR_OK success
1093 * @retval AIL_ERROR_FAIL internal error
1094 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
1096 * @pre a desktop file for the app has to be installed in the desktop directory before using this API.
1097 * @post update a app information in the Application Information Database.
1099 * @see ail_desktop_add(), ail_desktop_remove()
1101 * @par Prospective Clients:
1105 static ail_error_e _update_desktop(const char *appid)
1110 return AIL_ERROR_FAIL;
1113 ret = ail_desktop_update(appid);
1114 if (ret != AIL_ERROR_OK) {
1115 return AIL_ERROR_FAIL;
1118 return AIL_ERROR_OK;
1122 ail_error_e ail_desktop_update(const char *appid);
1123 ail_error_e ail_usr_desktop_update(const char *appid, uid_t uid);
1127 * @fn ail_error_e ail_desktop_remove(const char *appid)
1128 * @fn ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid)
1129 * @brief remove a app information in the Application Information Database.
1130 And a notification is published to the applications who want to know about changing DB.
1132 * @par Sync (or) Async : Synchronous API.
1135 * @param[in] uid the addressee user id of the instruction
1137 * @return 0 if success, negative value(<0) if fail\n
1138 * @retval AIL_ERROR_OK success
1139 * @retval AIL_ERROR_FAIL internal error
1140 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
1142 * @pre no pre-condition.
1143 * @post app information is removed in the Application Information Database.
1145 * @see ail_desktop_add(), ail_desktop_update()
1147 * @par Prospective Clients:
1151 static ail_error_e _remove_desktop(const char *appid)
1156 return AIL_ERROR_FAIL;
1159 ret = ail_desktop_remove(appid);
1160 if (ret != AIL_ERROR_OK) {
1161 return AIL_ERROR_FAIL;
1164 return AIL_ERROR_OK;
1168 ail_error_e ail_desktop_remove(const char *appid);
1169 ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid);
1172 * @fn ail_error_e ail_desktop_clean(const char *pkgid)
1173 * @fn ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid))
1174 * @brief clean a pkg information in the Application Information Database.
1176 * @par Sync (or) Async : Synchronous API.
1179 * @param[in] uid ID of the owner of the application
1181 * @return 0 if success, negative value(<0) if fail\n
1182 * @retval AIL_ERROR_OK success
1183 * @retval AIL_ERROR_FAIL internal error
1184 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
1186 * @pre no pre-condition.
1187 * @post app information is removed in the Application Information Database.
1189 * @see ail_desktop_add(), ail_desktop_update()
1191 * @par Prospective Clients:
1195 static ail_error_e _clean_desktop(const char *pkgid)
1200 return AIL_ERROR_FAIL;
1203 ret = ail_desktop_clean(pkgid);
1204 if (ret != AIL_ERROR_OK) {
1205 return AIL_ERROR_FAIL;
1208 return AIL_ERROR_OK;
1212 ail_error_e ail_desktop_clean(const char *pkgid);
1213 ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid);
1216 * @fn ail_error_e ail_desktop_fota(const char *appid)
1217 * @fn ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid)
1218 * @brief add a app information into Application Information Database.
1219 A desktop file for this app has to be installed in the desktop directory before using this API.
1220 If there is no database for Application Information Database, this API will create the DB.
1221 If there is a DB, this function adds information for the app into the DB.
1222 And a notification is not published to the applications who want to know about changing DB.
1224 * @par Sync (or) Async : Synchronous API.
1227 * @param[in] uid the addressee user id of the instruction
1229 * @return 0 if success, negative value(<0) if fail\n
1230 * @retval AIL_ERROR_OK success
1231 * @retval AIL_ERROR_FAIL internal error
1232 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
1234 * @pre a desktop file for the app has to be installed in the desktop directory before using this API.
1235 * @post app information is added into the Application Information Database.
1237 * @see ail_desktop_update(), ail_desktop_remove()
1239 * @par Prospective Clients:
1243 static ail_error_e _add_desktop_fota(const char *appid)
1248 return AIL_ERROR_FAIL;
1251 ret = ail_desktop_fota(appid);
1252 if (ret != AIL_ERROR_OK) {
1253 return AIL_ERROR_FAIL;
1256 return AIL_ERROR_OK;
1260 ail_error_e ail_desktop_fota(const char *appid);
1261 ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid);
1263 *@fn ail_error_e ail_desktop_appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast)
1264 * @fn ail_error_e ail_desktop_appinfo_modify_usr_str(const char *appid, uid_t uid, const char *property, const char *value, bool broadcast)
1265 * @brief update a app information db.
1266 And a notification is published to the applications who want to know about changing DB.
1268 * @par Sync (or) Async : Synchronous API.
1271 * @param[in] uid ID of the owner of the application
1273 * @return 0 if success, negative value(<0) if fail\n
1274 * @retval AIL_ERROR_OK success
1275 * @retval AIL_ERROR_FAIL internal error
1276 * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
1278 * @pre no pre-condition.
1279 * @post app information is removed in the Application Information Database.
1282 * @par Prospective Clients:
1286 static ail_error_e _appinfo_modify_str(const char *appid, uid_t uid, const char *property, const char *value, bool broadcast)
1291 return AIL_ERROR_FAIL;
1294 return AIL_ERROR_FAIL;
1297 return AIL_ERROR_FAIL;
1300 ret = ail_desktop_appinfo_modify_str(appid, property, value, broadcast);
1301 if (ret != AIL_ERROR_OK) {
1302 return AIL_ERROR_FAIL;
1305 return AIL_ERROR_OK;
1310 ail_error_e ail_desktop_appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast);
1311 ail_error_e ail_desktop_appinfo_modify_usr_str(const char *appid, uid_t uid, const char *property, const char *value, bool broadcast);
1317 #endif /* __cplusplus */
1319 #endif /* __AIL_H__ */