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.
31 #include <sys/types.h>
33 #include <tzplatform_config.h>
41 #include "ail_private.h"
47 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
49 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
50 #define argsdelimiter " \t"
52 #define SQL_INSERT_LOCALNAME_STR "insert into localname (package, locale, name) values "
53 #define SQL_INSERT_LOCALNAME_STR_LEN (sizeof(SQL_INSERT_LOCALNAME_STR)-1)
55 #define SQL_INSERT_LOCALNAME_INIT_STR SQL_INSERT_LOCALNAME_STR"( ?, ?, ?) "
57 #define SQL_LOCALNAME_TRIPLET_STR ", ( ?, ?, ?)"
58 #define SQL_LOCALNAME_TRIPLET_STR_LEN (sizeof(SQL_LOCALNAME_TRIPLET_STR)-1)
69 ail_error_e (*value_cb)(void *data, char *tag, char *value, uid_t uid);
72 inline static char *_ltrim(char *str)
74 if (!str) return NULL;
76 while (*str == ' ' || *str == '\t' || *str == '\n') str ++;
83 inline static int _rtrim(char *str)
88 while (--len >= 0 && (str[len] == ' ' || str[len] == '\n' || str[len] == '\t')) str[len] = '\0';
108 char* x_slp_packagetype;
109 char* x_slp_packagecategories;
110 char* x_slp_packageid;
113 char* x_slp_exe_path;
117 char* x_slp_submodemainid;
118 char* x_slp_installedstorage;
119 int x_slp_baselayoutwidth;
120 int x_slp_installedtime;
122 int x_slp_taskmanage;
125 int x_slp_ishorizontalscale;
134 static ail_error_e _read_exec(void *data, char *tag, char *value, uid_t uid)
136 desktop_info_s *info = data;
137 char *token_exe_path;
141 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
142 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
144 SAFE_FREE_AND_STRDUP(value, info->exec);
145 retv_if(!info->exec, AIL_ERROR_OUT_OF_MEMORY);
147 temp_exec = strdup(value);
150 return AIL_ERROR_OUT_OF_MEMORY;
153 token_exe_path = strtok_r(temp_exec, argsdelimiter, &save_ptr);
155 info->x_slp_exe_path = strdup(token_exe_path);
156 if(!info->x_slp_exe_path) {
160 return AIL_ERROR_OUT_OF_MEMORY;
170 static ail_error_e _read_name(void *data, char *tag, char *value, uid_t uid)
172 desktop_info_s *info = data;
174 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
175 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
176 retv_if(0 == strlen(value), AIL_ERROR_FAIL);
178 if (tag && strlen(tag) > 0) {
179 struct name_item *item;
180 item = (struct name_item *)calloc(1, sizeof(struct name_item));
181 retv_if (NULL == item, AIL_ERROR_OUT_OF_MEMORY);
183 SAFE_FREE_AND_STRDUP(tag, item->locale);
184 if(NULL == item->locale) {
185 _E("(NULL == item->locale) return\n");
187 return AIL_ERROR_OUT_OF_MEMORY;
190 SAFE_FREE_AND_STRDUP(value, item->name);
191 if(NULL == item->name) {
192 _E("(NULL == item->name) return\n");
195 return AIL_ERROR_OUT_OF_MEMORY;
198 info->localname = g_slist_append(info->localname, item);
202 SAFE_FREE_AND_STRDUP(value, info->name);
203 retv_if (!info->name, AIL_ERROR_OUT_OF_MEMORY);
211 static ail_error_e _read_type(void *data, char *tag, char *value, uid_t uid)
213 desktop_info_s *info = data;
215 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
216 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
218 SAFE_FREE_AND_STRDUP(value, info->type);
219 retv_if (!info->type, AIL_ERROR_OUT_OF_MEMORY);
226 _get_package_from_icon(char* icon)
231 retv_if(!icon, NULL);
233 package = strdup(icon);
234 retv_if(!package, NULL);
235 extension = rindex(package, '.');
239 _E("cannot extract from icon [%s] to package.", icon);
247 _get_icon_with_path(char* icon, uid_t uid)
249 retv_if(!icon, NULL);
251 if (index(icon, '/') == NULL) {
254 char* icon_with_path = NULL;
256 char *app_path = NULL;
258 package = _get_package_from_icon(icon);
259 retv_if(!package, NULL);
261 /* "db/setting/theme" is not exist */
263 theme = vconf_get_str("db/setting/theme");
265 theme = strdup("default");
272 theme = strdup("default");
275 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
276 icon_with_path = malloc(len);
277 if(icon_with_path == NULL) {
278 _E("icon_with_path == NULL\n");
284 memset(icon_with_path, 0, len);
285 if (uid != GLOBAL_USER)
286 sqlite3_snprintf( len, icon_with_path, "%s%q", ail_get_icon_path(uid), icon);
288 sqlite3_snprintf( len, icon_with_path, "%s/%q/small/%q", ail_get_icon_path(GLOBAL_USER), theme, icon);
290 if (access (icon_with_path, F_OK)) {
291 app_path = tzplatform_getenv(TZ_SYS_RW_APP);
293 sqlite3_snprintf( len, icon_with_path, "%s/%q/res/icons/%q/small/%q",app_path, package, theme, icon);
294 if (access (icon_with_path, F_OK))
295 _E("Cannot find icon path");
299 _D("Icon path : %s", icon_with_path);
300 return icon_with_path;
302 char* confirmed_icon = NULL;
304 confirmed_icon = strdup(icon);
305 retv_if(!confirmed_icon, NULL);
306 return confirmed_icon;
311 static ail_error_e _read_icon(void *data, char *tag, char *value, uid_t uid)
313 desktop_info_s *info = data;
315 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
316 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
318 info->icon = _get_icon_with_path(value, uid);
320 retv_if (!info->icon, AIL_ERROR_OUT_OF_MEMORY);
327 static ail_error_e _read_categories(void *data, char *tag, char *value, uid_t uid)
329 desktop_info_s *info = data;
331 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
332 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
334 SAFE_FREE_AND_STRDUP(value, info->categories);
335 retv_if (!info->categories, AIL_ERROR_OUT_OF_MEMORY);
342 static ail_error_e _read_version(void *data, char *tag, char *value, uid_t uid)
344 desktop_info_s *info = data;
346 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
347 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
349 SAFE_FREE_AND_STRDUP(value, info->version);
350 retv_if (!info->version, AIL_ERROR_OUT_OF_MEMORY);
357 static ail_error_e _read_mimetype(void *data, char *tag, char *value, uid_t uid)
359 desktop_info_s *info = data;
360 int size, total_len = 0;
361 char *mimes_origin, *mimes_changed, *token_unalias, *save_ptr;
363 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
364 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
365 retv_if(!strlen(value), AIL_ERROR_FAIL);
367 mimes_origin = strdup(value);
368 retv_if(!mimes_origin, AIL_ERROR_OUT_OF_MEMORY);
370 size = getpagesize();
371 mimes_changed = calloc(1, size);
372 if(mimes_changed == NULL) {
373 _E("(mimes_changed == NULL) return\n");
375 return AIL_ERROR_OUT_OF_MEMORY;
378 token_unalias = strtok_r(mimes_origin, ";", &save_ptr);
380 while (token_unalias) {
382 const char *token_alias;
384 _rtrim(token_unalias);
385 token_unalias = _ltrim(token_unalias);
387 token_alias = xdg_mime_unalias_mime_type(token_unalias);
388 if (!token_alias) continue;
390 token_len = strlen(token_alias);
391 if (total_len + token_len + (1<<1) >= size) {
394 tmp = realloc(mimes_changed, size);
397 return AIL_ERROR_OUT_OF_MEMORY;
402 strncat(mimes_changed, token_alias, size-1);
403 total_len += token_len;
405 token_unalias = strtok_r(NULL, ";", &save_ptr);
407 strncat(mimes_changed, ";", size-strlen(mimes_changed)-1);
411 SAFE_FREE(info->mimetype);
412 info->mimetype = mimes_changed;
419 static ail_error_e _read_nodisplay(void *data, char *tag, char *value, uid_t uid)
421 desktop_info_s* info = data;
423 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
424 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
426 info->nodisplay = !strcasecmp(value, "true");
433 static ail_error_e _read_x_slp_service(void *data, char *tag, char *value, uid_t uid)
435 desktop_info_s *info = data;
437 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
438 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
440 SAFE_FREE_AND_STRDUP(value, info->x_slp_service);
441 retv_if(!info->x_slp_service, AIL_ERROR_OUT_OF_MEMORY);
448 static ail_error_e _read_x_slp_packagetype(void *data, char *tag, char *value, uid_t uid)
450 desktop_info_s *info = data;
452 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
453 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
455 SAFE_FREE_AND_STRDUP(value, info->x_slp_packagetype);
456 retv_if(!info->x_slp_packagetype, AIL_ERROR_OUT_OF_MEMORY);
463 static ail_error_e _read_x_slp_packagecategories(void *data, char *tag, char *value, uid_t uid)
465 desktop_info_s *info = data;
467 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
468 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
470 SAFE_FREE_AND_STRDUP(value, info->x_slp_packagecategories);
471 retv_if(!info->x_slp_packagecategories, AIL_ERROR_OUT_OF_MEMORY);
478 static ail_error_e _read_x_slp_packageid(void *data, char *tag, char *value, uid_t uid)
480 desktop_info_s *info = data;
482 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
483 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
485 SAFE_FREE_AND_STRDUP(value, info->x_slp_packageid);
486 retv_if(!info->x_slp_packageid, AIL_ERROR_OUT_OF_MEMORY);
491 static ail_error_e _read_x_slp_submodemainid(void *data, char *tag, char *value, uid_t uid)
493 desktop_info_s *info = data;
495 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
496 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
498 SAFE_FREE_AND_STRDUP(value, info->x_slp_submodemainid);
499 retv_if(!info->x_slp_submodemainid, AIL_ERROR_OUT_OF_MEMORY);
504 static ail_error_e _read_x_slp_installedstorage(void *data, char *tag, char *value, uid_t uid)
506 desktop_info_s *info = data;
508 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
509 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
511 SAFE_FREE_AND_STRDUP(value, info->x_slp_installedstorage);
512 retv_if(!info->x_slp_installedstorage, AIL_ERROR_OUT_OF_MEMORY);
517 static ail_error_e _read_x_slp_uri(void *data, char *tag, char *value, uid_t uid)
519 desktop_info_s *info = data;
521 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
522 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
524 SAFE_FREE_AND_STRDUP(value, info->x_slp_uri);
525 retv_if(!info->x_slp_uri, AIL_ERROR_OUT_OF_MEMORY);
532 static ail_error_e _read_x_slp_svc(void *data, char *tag, char *value, uid_t uid)
534 desktop_info_s *info = data;
536 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
537 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
539 SAFE_FREE_AND_STRDUP(value, info->x_slp_svc);
540 retv_if(!info->x_slp_svc, AIL_ERROR_OUT_OF_MEMORY);
547 static ail_error_e _read_x_slp_taskmanage(void *data, char *tag, char *value, uid_t uid)
549 desktop_info_s *info = data;
551 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
552 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
554 info->x_slp_taskmanage = !strcasecmp(value, "true");
561 static ail_error_e _read_x_slp_multiple(void *data, char *tag, char *value, uid_t uid)
563 desktop_info_s *info = data;
565 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
566 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
568 info->x_slp_multiple = !strcasecmp(value, "true");
575 static ail_error_e _read_x_slp_removable(void *data, char *tag, char *value, uid_t uid)
577 desktop_info_s *info = data;
579 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
580 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
582 info->x_slp_removable = !strcasecmp(value, "true");
588 static ail_error_e _read_x_slp_submode(void *data, char *tag, char *value, uid_t uid)
590 desktop_info_s *info = data;
592 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
593 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
595 info->x_slp_submode = !strcasecmp(value, "true");
600 static ail_error_e _read_x_slp_appid(void *data, char *tag, char *value, uid_t uid)
602 desktop_info_s *info = data;
604 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
605 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
607 SAFE_FREE_AND_STRDUP(value, info->x_slp_appid);
608 retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
614 static ail_error_e _read_x_slp_pkgid(void *data, char *tag, char *value, uid_t uid)
616 desktop_info_s *info = data;
618 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
619 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
621 SAFE_FREE_AND_STRDUP(value, info->x_slp_pkgid);
622 retv_if(!info->x_slp_pkgid, AIL_ERROR_OUT_OF_MEMORY);
628 static ail_error_e _read_x_slp_domain(void *data, char *tag, char *value, uid_t uid)
630 desktop_info_s *info = data;
632 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
633 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
635 SAFE_FREE_AND_STRDUP(value, info->x_slp_domain);
636 retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
642 static ail_error_e _read_x_slp_enabled(void *data, char *tag, char *value, uid_t uid)
644 desktop_info_s *info = data;
646 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
647 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
649 info->x_slp_enabled = !strcasecmp(value, "true");
655 static struct entry_parser entry_parsers[] = {
658 .value_cb = _read_exec,
662 .value_cb = _read_name,
666 .value_cb = _read_type,
670 .value_cb = _read_icon,
673 .field = "categories",
674 .value_cb = _read_categories,
678 .value_cb = _read_version,
682 .value_cb = _read_mimetype,
685 .field = "x-tizen-service",
686 .value_cb = _read_x_slp_service,
689 .field = "x-tizen-packagetype",
690 .value_cb = _read_x_slp_packagetype,
693 .field = "x-tizen-packagecategories",
694 .value_cb = _read_x_slp_packagecategories,
697 .field = "x-tizen-packageid",
698 .value_cb = _read_x_slp_packageid,
701 .field = "x-tizen-submodemainid",
702 .value_cb = _read_x_slp_submodemainid,
705 .field = "x-tizen-installedstorage",
706 .value_cb = _read_x_slp_installedstorage,
709 .field = "x-tizen-uri",
710 .value_cb = _read_x_slp_uri,
713 .field = "x-tizen-svc",
714 .value_cb = _read_x_slp_svc,
717 .field = "nodisplay",
718 .value_cb = _read_nodisplay,
721 .field = "x-tizen-taskmanage",
722 .value_cb = _read_x_slp_taskmanage,
725 .field = "x-tizen-enabled",
726 .value_cb = _read_x_slp_enabled,
729 .field = "x-tizen-submode",
730 .value_cb = _read_x_slp_submode,
733 .field = "x-tizen-multiple",
734 .value_cb = _read_x_slp_multiple,
737 .field = "x-tizen-removable",
738 .value_cb = _read_x_slp_removable,
741 .field = "x-tizen-appid",
742 .value_cb = _read_x_slp_appid,
745 .field = "x-tizen-pkgid",
746 .value_cb = _read_x_slp_pkgid,
749 .field = "x-tizen-domain",
750 .value_cb = _read_x_slp_domain,
753 .field = "x-tizen-enabled",
754 .value_cb = _read_x_slp_domain,
764 /* Utility functions */
765 static int _count_all(uid_t uid)
770 if (uid != GLOBAL_USER)
771 ret = ail_filter_count_usr_appinfo(NULL, &count, uid);
773 ret = ail_filter_count_appinfo(NULL, &count);
774 if(ret != AIL_ERROR_OK) {
775 _E("cannot count appinfo");
779 retv_if(ret != AIL_ERROR_OK, -1);
784 char *_pkgname_to_desktop(const char *package, uid_t uid)
790 retv_if(!package, NULL);
792 desktop_path = ail_get_desktop_path(uid);
794 size = strlen(desktop_path) + strlen(package) + 10;
795 desktop = malloc(size);
796 retv_if(!desktop, NULL);
798 snprintf(desktop, size, "%s/%s.desktop", desktop_path, package);
800 _D("uid: %d / desktop: [%s]\n", uid, desktop);
805 static inline int _bind_local_info(desktop_info_s* info, sqlite3_stmt * stmt)
809 struct name_item *item;
811 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
812 retv_if(!info->localname, AIL_ERROR_INVALID_PARAMETER);
813 retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
814 localname = info->localname;
816 item = (struct name_item *) localname->data;
817 if (item && item->locale && item->name) {
818 // Bind values for a triplet : package, locale, name
819 retv_if(db_bind_text(stmt, i+1, info->package) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
820 retv_if(db_bind_text(stmt, i+2, item->locale) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
821 retv_if(db_bind_text(stmt, i+3, item->name) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
824 localname = g_slist_next(localname);
830 static inline int _len_local_info(desktop_info_s* info)
833 struct name_item *item;
835 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
836 if(info->localname) {
837 localname = info->localname;
839 item = (struct name_item *) localname->data;
840 if (item && item->locale && item->name)
842 localname = g_slist_next(localname);
849 static inline int _insert_local_info(desktop_info_s* info, uid_t uid)
851 int len_query = SQL_INSERT_LOCALNAME_STR_LEN;
854 int ret = AIL_ERROR_OK;
855 sqlite3_stmt *stmt = NULL;
857 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
858 retv_if(!info->localname, AIL_ERROR_INVALID_PARAMETER);
860 nb_locale_args = _len_local_info(info);
862 retv_if(!nb_locale_args, AIL_ERROR_INVALID_PARAMETER);
864 len_query += SQL_LOCALNAME_TRIPLET_STR_LEN*nb_locale_args +1;
866 query = (char *) malloc(len_query);
867 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
868 stpncpy(query, SQL_INSERT_LOCALNAME_INIT_STR, len_query);
869 for (i = 0; i < nb_locale_args - 1; i++)
870 strcat(query, SQL_LOCALNAME_TRIPLET_STR);
873 if(uid != GLOBAL_USER)
874 ret = db_prepare_rw(query, &stmt);
876 ret = db_prepare_globalrw(query, &stmt);
879 ret = _bind_local_info(info, stmt);
881 _E("Can't bind locale information to this query - %s. ",query);
886 if (ret != AIL_ERROR_NO_DATA) {
887 /* Insert Request doesn't return any data.
888 * db_step should returns AIL_ERROR_NO_DATA in this case. */
889 _E("Can't execute this query - %s. ",query);
893 ret = db_finalize(stmt);
900 static inline int _strlen_desktop_info(desktop_info_s* info)
904 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
906 if (info->package) len += strlen(info->package);
907 if (info->exec) len += strlen(info->exec);
908 if (info->name) len += strlen(info->name);
909 if (info->type) len += strlen(info->type);
910 if (info->icon) len += strlen(info->icon);
911 if (info->categories) len += strlen(info->categories);
912 if (info->version) len += strlen(info->version);
913 if (info->mimetype) len += strlen(info->mimetype);
914 if (info->x_slp_service) len += strlen(info->x_slp_service);
915 if (info->x_slp_packagetype) len += strlen(info->x_slp_packagetype);
916 if (info->x_slp_packagecategories) len += strlen(info->x_slp_packagecategories);
917 if (info->x_slp_packageid) len += strlen(info->x_slp_packageid);
918 if (info->x_slp_uri) len += strlen(info->x_slp_uri);
919 if (info->x_slp_svc) len += strlen(info->x_slp_svc);
920 if (info->x_slp_exe_path) len += strlen(info->x_slp_exe_path);
921 if (info->x_slp_appid) len += strlen(info->x_slp_appid);
922 if (info->desktop) len += strlen(info->desktop);
923 if (info->x_slp_submodemainid) len += strlen(info->x_slp_submodemainid);
924 if (info->x_slp_installedstorage) len += strlen(info->x_slp_installedstorage);
930 int __is_ail_initdb(void)
932 if( getenv("AIL_INITDB") || getenv("INITDB") )
938 /* Manipulating desktop_info functions */
939 static ail_error_e _init_desktop_info(desktop_info_s *info, const char *package, uid_t uid)
941 static int is_initdb = -1;
943 _D("package - [%s].", package);
946 is_initdb = __is_ail_initdb();
948 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
949 retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
952 info->package = package;
954 info->x_slp_taskmanage = 1;
955 info->x_slp_removable = 1;
956 info->x_slp_submode = 0;
959 info->x_slp_installedtime = 0;
961 info->x_slp_installedtime = time(NULL);
964 info->x_slp_packagetype = strdup(PKGTYPE);
966 info->x_slp_packagetype = strdup("rpm");
968 retv_if(!info->x_slp_packagetype, AIL_ERROR_OUT_OF_MEMORY);
970 info->x_slp_packageid = strdup(package);
971 retv_if(!info->x_slp_packageid, AIL_ERROR_OUT_OF_MEMORY);
972 info->x_slp_appid = strdup(package);
973 retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
975 info->x_slp_enabled = 1;
977 info->desktop = _pkgname_to_desktop(package, uid);
978 retv_if(!info->desktop, AIL_ERROR_FAIL);
980 _D("desktop - [%s].", info->desktop);
987 static ail_error_e _read_desktop_info(desktop_info_s* info,uid_t uid)
994 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
996 fp = fopen(info->desktop, "r");
997 retv_if(!fp, AIL_ERROR_FAIL);
999 while ((read = getline(&line, &size, fp)) != -1) {
1001 char *tmp, *field, *field_name, *tag, *value;
1004 if(tmp == NULL) continue;
1005 if (*tmp == '#') continue;
1006 if (_rtrim(tmp) <= 0) continue;
1008 len = strlen(line) + 1;
1009 field = calloc(1, len);
1010 field_name = calloc(1, len);
1011 tag = calloc(1, len);
1012 value = calloc(1, len);
1014 if (!field || !field_name || !tag || !value) {
1018 sscanf(tmp, "%[^=]=%[^\n]", field, value);
1020 tmp = _ltrim(value);
1022 sscanf(field, "%[^[][%[^]]]", field_name, tag);
1024 if (!field_name || !strlen(field_name)){
1028 for (idx = 0; entry_parsers[idx].field; idx ++) {
1029 if (!g_ascii_strcasecmp(entry_parsers[idx].field, field_name) && entry_parsers[idx].value_cb) {
1030 if (entry_parsers[idx].value_cb(info, tag, tmp,uid) != AIL_ERROR_OK) {
1031 _E("field - [%s] is wrong.", field_name);
1038 SAFE_FREE(field_name);
1043 _D("Read (%s).", info->package);
1046 return AIL_ERROR_OK;
1050 static ail_error_e _retrieve_all_column_to_desktop_info(desktop_info_s* info, sqlite3_stmt *stmt)
1057 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1059 values = calloc(NUM_OF_PROP, sizeof(char *));
1060 retv_if(!values, AIL_ERROR_OUT_OF_MEMORY);
1062 for (i = 0; i < NUM_OF_PROP; i++) {
1063 err = db_column_str(stmt, i, &col);
1064 if (AIL_ERROR_OK != err)
1070 values[i] = strdup(col);
1072 err = AIL_ERROR_OUT_OF_MEMORY;
1078 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_EXEC_STR], info->exec);
1079 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_NAME_STR], info->name);
1080 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_TYPE_STR], info->type);
1081 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_ICON_STR], info->icon);
1082 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_CATEGORIES_STR], info->categories);
1083 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_VERSION_STR], info->version);
1084 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_MIMETYPE_STR], info->mimetype);
1085 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_SERVICE_STR], info->x_slp_service);
1086 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PACKAGETYPE_STR], info->x_slp_packagetype);
1087 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR], info->x_slp_packagecategories);
1088 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PACKAGEID_STR], info->x_slp_packageid);
1089 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_URI_STR], info->x_slp_uri);
1090 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_SVC_STR], info->x_slp_svc);
1091 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_EXE_PATH], info->x_slp_exe_path);
1092 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_APPID_STR], info->x_slp_appid);
1093 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PKGID_STR], info->x_slp_pkgid);
1094 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_DOMAIN_STR], info->x_slp_domain);
1095 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_SUBMODEMAINID_STR], info->x_slp_submodemainid);
1096 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR], info->x_slp_installedstorage);
1098 info->x_slp_installedtime = atoi(values[E_AIL_PROP_X_SLP_INSTALLEDTIME_INT]);
1100 info->nodisplay = atoi(values[E_AIL_PROP_NODISPLAY_BOOL]);
1101 info->x_slp_taskmanage = atoi(values[E_AIL_PROP_X_SLP_TASKMANAGE_BOOL]);
1102 info->x_slp_multiple = atoi(values[E_AIL_PROP_X_SLP_MULTIPLE_BOOL]);
1103 info->x_slp_removable = atoi(values[E_AIL_PROP_X_SLP_REMOVABLE_BOOL]);
1104 info->x_slp_ishorizontalscale = atoi(values[E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL]);
1105 info->x_slp_enabled = atoi(values[E_AIL_PROP_X_SLP_ENABLED_BOOL]);
1106 info->x_slp_submode = atoi(values[E_AIL_PROP_X_SLP_SUBMODE_BOOL]);
1111 for (j = 0; j < i; ++j) {
1121 static ail_error_e _load_desktop_info(desktop_info_s* info, uid_t uid)
1124 char query[AIL_SQL_QUERY_MAX_LEN];
1125 sqlite3_stmt *stmt = NULL;
1126 char w[AIL_SQL_QUERY_MAX_LEN];
1128 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1130 snprintf(w, sizeof(w), sql_get_filter(E_AIL_PROP_X_SLP_APPID_STR), info->package);
1132 snprintf(query, sizeof(query), "SELECT %s FROM %s WHERE %s",SQL_FLD_APP_INFO, SQL_TBL_APP_INFO, w);
1135 ret = db_open(DB_OPEN_RO, uid);
1138 ret = db_prepare(query, &stmt);
1139 //ret = db_prepare_globalro(query, &stmt);
1142 ret = db_step(stmt);
1148 ret = _retrieve_all_column_to_desktop_info(info, stmt);
1154 ret = db_finalize(stmt);
1157 return AIL_ERROR_OK;
1163 static ail_error_e _modify_desktop_info_bool(desktop_info_s* info,
1164 const char *property,
1167 ail_prop_bool_e prop;
1170 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1171 retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
1173 prop = _ail_convert_to_prop_bool(property);
1175 if (prop < E_AIL_PROP_BOOL_MIN || prop > E_AIL_PROP_BOOL_MAX)
1176 return AIL_ERROR_INVALID_PARAMETER;
1179 case E_AIL_PROP_X_SLP_ENABLED_BOOL:
1180 info->x_slp_enabled = (int)value;
1183 return AIL_ERROR_FAIL;
1186 return AIL_ERROR_OK;
1190 static ail_error_e _modify_desktop_info_str(desktop_info_s* info,
1191 const char *property,
1194 ail_prop_bool_e prop;
1197 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1198 retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
1200 prop = _ail_convert_to_prop_str(property);
1202 if (prop < E_AIL_PROP_STR_MIN || prop > E_AIL_PROP_STR_MAX)
1203 return AIL_ERROR_INVALID_PARAMETER;
1206 case E_AIL_PROP_NAME_STR:
1207 SAFE_FREE_AND_STRDUP(value, info->name);
1208 retv_if (!info->name, AIL_ERROR_OUT_OF_MEMORY);
1210 case E_AIL_PROP_X_SLP_SVC_STR:
1211 SAFE_FREE_AND_STRDUP(value, info->x_slp_svc);
1212 retv_if (!info->x_slp_svc, AIL_ERROR_OUT_OF_MEMORY);
1214 case E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR:
1215 SAFE_FREE_AND_STRDUP(value, info->x_slp_installedstorage);
1216 retv_if (!info->x_slp_installedstorage, AIL_ERROR_OUT_OF_MEMORY);
1219 _E("prop[%d] is not defined\n", prop);
1220 return AIL_ERROR_FAIL;
1223 return AIL_ERROR_OK;
1227 static inline void _insert_localname(gpointer data, gpointer user_data, uid_t uid)
1231 struct name_item *item = (struct name_item *)data;
1232 desktop_info_s *info = (desktop_info_s *)user_data;
1234 sqlite3_snprintf(sizeof(query), query, "insert into localname (package, locale, name, x_slp_pkgid) "
1235 "values ('%q', '%q', '%q', '%q');",
1236 info->package, item->locale, item->name, info->x_slp_pkgid);
1237 if(uid != GLOBAL_USER) {
1238 if (db_exec_usr_rw(query) < 0)
1239 _E("Failed to insert local name of package[%s]",info->package);
1241 if (db_exec_glo_rw(query) < 0)
1242 _E("Failed to insert local name of package[%s]",info->package);
1246 static ail_error_e _insert_desktop_info(desktop_info_s *info, uid_t uid)
1252 len = _strlen_desktop_info(info) + (0x01 << 10);
1253 query = calloc(1, len);
1254 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1256 sqlite3_snprintf(len, query, "insert into app_info ("
1265 "x_slp_packagetype, "
1266 "x_slp_packagecategories, "
1274 "x_slp_submodemainid, "
1275 "x_slp_installedstorage, "
1276 "x_slp_baselayoutwidth, "
1277 "x_slp_installedtime, "
1279 "x_slp_taskmanage, "
1282 "x_slp_ishorizontalscale, "
1287 "('%q', '%q', '%q', '%q', '%q', "
1288 "'%q', '%q', '%q', '%q', '%q', "
1289 "'%q', '%q', '%q', '%q', '%q', "
1290 "'%q', '%q', '%q', '%q', '%q', "
1291 "%d, %d, %d, %d, %d, %d, %d,"
1302 info->x_slp_service,
1303 info->x_slp_packagetype,
1304 info->x_slp_packagecategories,
1305 info->x_slp_packageid,
1308 info->x_slp_exe_path,
1312 info->x_slp_submodemainid,
1313 info->x_slp_installedstorage,
1314 info->x_slp_baselayoutwidth,
1315 info->x_slp_installedtime,
1317 info->x_slp_taskmanage,
1318 info->x_slp_multiple,
1319 info->x_slp_removable,
1320 info->x_slp_ishorizontalscale,
1321 info->x_slp_enabled,
1322 info->x_slp_submode,
1326 ret = db_open(DB_OPEN_RW, uid);
1327 if(ret != AIL_ERROR_OK) {
1328 _E("(tmp == NULL) return\n");
1330 return AIL_ERROR_DB_FAILED;
1332 if (uid != GLOBAL_USER)
1333 ret = db_exec_usr_rw(query);
1335 ret = db_exec_glo_rw(query);
1338 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
1340 if (info->localname)
1341 _insert_local_info(info, uid);
1343 _D("Add (%s).", query);
1345 return AIL_ERROR_OK;
1350 static ail_error_e _update_desktop_info(desktop_info_s *info, uid_t uid)
1355 retv_if (NULL == info, AIL_ERROR_INVALID_PARAMETER);
1357 if (db_open(DB_OPEN_RW, uid) < 0) {
1358 return AIL_ERROR_DB_FAILED;
1361 len = _strlen_desktop_info(info) + (0x01 << 10);
1362 query = calloc(1, len);
1363 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1365 sqlite3_snprintf ( len, query, "update app_info set "
1373 "x_slp_service='%q', "
1374 "x_slp_packagetype='%q', "
1375 "x_slp_packagecategories='%q', "
1376 "x_slp_packageid='%q', "
1379 "x_slp_exe_path='%q', "
1380 "x_slp_appid='%q', "
1381 "x_slp_pkgid='%q', "
1382 "x_slp_domain='%q', "
1383 "x_slp_submodemainid='%q', "
1384 "x_slp_installedstorage='%q', "
1385 "x_slp_baselayoutwidth=%d, "
1386 "x_slp_installedtime=%d, "
1388 "x_slp_taskmanage=%d, "
1389 "x_slp_multiple=%d, "
1390 "x_slp_removable=%d, "
1391 "x_slp_ishorizontalscale=%d, "
1392 "x_slp_enabled=%d, "
1393 "x_slp_submode=%d, "
1395 "where package='%q'",
1403 info->x_slp_service,
1404 info->x_slp_packagetype,
1405 info->x_slp_packagecategories,
1406 info->x_slp_packageid,
1409 info->x_slp_exe_path,
1413 info->x_slp_submodemainid,
1414 info->x_slp_installedstorage,
1415 info->x_slp_baselayoutwidth,
1416 info->x_slp_installedtime,
1418 info->x_slp_taskmanage,
1419 info->x_slp_multiple,
1420 info->x_slp_removable,
1421 info->x_slp_ishorizontalscale,
1422 info->x_slp_enabled,
1423 info->x_slp_submode,
1427 if(uid != GLOBAL_USER) {
1428 if (db_exec_usr_rw(query) < 0) {
1430 return AIL_ERROR_DB_FAILED;
1433 if (db_exec_glo_rw(query) < 0) {
1435 return AIL_ERROR_DB_FAILED;
1438 snprintf(query, len, "delete from localname where package = '%s'", info->package);
1439 if (uid != GLOBAL_USER) {
1440 if (db_exec_usr_rw(query) < 0) {
1442 return AIL_ERROR_DB_FAILED;
1445 if (db_exec_glo_rw(query) < 0) {
1447 return AIL_ERROR_DB_FAILED;
1450 if (info->localname)
1451 _insert_local_info(info, uid);
1453 _D("Update (%s).", info->package);
1457 return AIL_ERROR_OK;
1462 static ail_error_e _remove_package(const char* package, uid_t uid)
1467 retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
1469 if (db_open(DB_OPEN_RW, uid) < 0) {
1470 return AIL_ERROR_DB_FAILED;
1473 size = strlen(package) + (0x01 << 10);
1474 query = calloc(1, size);
1475 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1477 snprintf(query, size, "delete from app_info where package = '%s'", package);
1479 if(uid != GLOBAL_USER) {
1480 if (db_exec_usr_rw(query) < 0) {
1482 return AIL_ERROR_DB_FAILED;
1485 if (db_exec_glo_rw(query) < 0) {
1487 return AIL_ERROR_DB_FAILED;
1490 snprintf(query, size, "delete from localname where package = '%s'", package);
1491 _D("query=%s",query);
1493 if(uid != GLOBAL_USER) {
1494 if (db_exec_usr_rw(query) < 0) {
1496 return AIL_ERROR_DB_FAILED;
1499 if (db_exec_glo_rw(query) < 0) {
1501 return AIL_ERROR_DB_FAILED;
1504 _D("Remove (%s).", package);
1507 return AIL_ERROR_OK;
1510 static ail_error_e _clean_pkgid_data(const char* pkgid, uid_t uid)
1515 retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
1517 if (db_open(DB_OPEN_RW, uid) ){
1518 return AIL_ERROR_DB_FAILED;
1521 size = strlen(pkgid) + (0x01 << 10);
1522 query = calloc(1, size);
1523 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1525 snprintf(query, size, "delete from app_info where x_slp_pkgid = '%s'", pkgid);
1527 if(uid != GLOBAL_USER) {
1528 if (db_exec_usr_rw(query) < 0) {
1530 return AIL_ERROR_DB_FAILED;
1533 if (db_exec_glo_rw(query) < 0) {
1535 return AIL_ERROR_DB_FAILED;
1538 snprintf(query, size, "delete from localname where x_slp_pkgid = '%s'", pkgid);
1539 _D("query=%s",query);
1541 if(uid != GLOBAL_USER) {
1542 if (db_exec_usr_rw(query) < 0) {
1544 return AIL_ERROR_DB_FAILED;
1547 if (db_exec_glo_rw(query) < 0) {
1549 return AIL_ERROR_DB_FAILED;
1552 _D("Clean pkgid data (%s).", pkgid);
1555 return AIL_ERROR_OK;
1558 static ail_error_e _send_db_done_noti(noti_type type, const char *package)
1560 char *type_string, *noti_string;
1563 retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
1567 type_string = "create";
1570 type_string = "update";
1573 type_string = "delete";
1576 return AIL_ERROR_FAIL;
1579 size = snprintf(NULL, 0, "%s:%s:%u", type_string, package, getuid());
1580 noti_string = (char*) calloc(size + 1, sizeof(char));
1581 retv_if(!noti_string, AIL_ERROR_OUT_OF_MEMORY);
1583 snprintf(noti_string, size + 1, "%s:%s:%u", type_string, package, getuid());
1584 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
1585 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
1586 _D("Noti : %s", noti_string);
1590 return AIL_ERROR_OK;
1594 static void inline _name_item_free_func(gpointer data)
1596 struct name_item *item = (struct name_item *)data;
1598 SAFE_FREE(item->locale);
1599 item->locale = NULL;
1600 SAFE_FREE(item->name);
1606 static void _fini_desktop_info(desktop_info_s *info)
1608 SAFE_FREE(info->exec);
1609 SAFE_FREE(info->name);
1610 SAFE_FREE(info->type);
1611 SAFE_FREE(info->icon);
1612 SAFE_FREE(info->categories);
1613 SAFE_FREE(info->version);
1614 SAFE_FREE(info->mimetype);
1615 SAFE_FREE(info->x_slp_service);
1616 SAFE_FREE(info->x_slp_packagetype);
1617 SAFE_FREE(info->x_slp_packagecategories);
1618 SAFE_FREE(info->x_slp_packageid);
1619 SAFE_FREE(info->x_slp_uri);
1620 SAFE_FREE(info->x_slp_svc);
1621 SAFE_FREE(info->x_slp_exe_path);
1622 SAFE_FREE(info->x_slp_appid);
1623 SAFE_FREE(info->x_slp_pkgid);
1624 SAFE_FREE(info->x_slp_domain);
1625 SAFE_FREE(info->x_slp_submodemainid);
1626 SAFE_FREE(info->x_slp_installedstorage);
1627 SAFE_FREE(info->desktop);
1628 if (info->localname) {
1629 g_slist_free_full(info->localname, _name_item_free_func);
1630 info->localname = NULL;
1636 static int __is_authorized()
1638 uid_t uid = getuid();
1639 if ((uid_t) GLOBAL_USER == uid )
1646 /* Public functions */
1647 EXPORT_API ail_error_e ail_usr_desktop_add(const char *appid, uid_t uid)
1649 desktop_info_s info = {0,};
1652 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1654 ret = _init_desktop_info(&info, appid, uid);
1655 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1657 ret = _read_desktop_info(&info,uid);
1658 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1660 ret = _insert_desktop_info(&info, uid);
1661 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1663 ret = _send_db_done_noti(NOTI_ADD, appid);
1664 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1666 _fini_desktop_info(&info);
1668 return AIL_ERROR_OK;
1671 EXPORT_API ail_error_e ail_desktop_add(const char *appid)
1673 return ail_usr_desktop_add(appid,GLOBAL_USER);
1676 EXPORT_API ail_error_e ail_usr_desktop_update(const char *appid, uid_t uid)
1678 desktop_info_s info = {0,};
1681 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1683 ret = _init_desktop_info(&info, appid, uid);
1684 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1686 ret = _read_desktop_info(&info,uid);
1687 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1689 ret = _update_desktop_info(&info, uid);
1690 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1692 ret = _send_db_done_noti(NOTI_UPDATE, appid);
1693 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1695 _fini_desktop_info(&info);
1697 return AIL_ERROR_OK;
1700 EXPORT_API ail_error_e ail_desktop_update(const char *appid)
1702 return ail_usr_desktop_update(appid,GLOBAL_USER);
1706 EXPORT_API ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid)
1710 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1712 ret = _remove_package(appid, uid);
1713 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1715 ret = _send_db_done_noti(NOTI_REMOVE, appid);
1716 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1718 return AIL_ERROR_OK;
1721 EXPORT_API ail_error_e ail_desktop_remove(const char *appid)
1723 return ail_usr_desktop_remove(appid, GLOBAL_USER);
1727 EXPORT_API ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid)
1731 retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
1733 _D("ail_desktop_clean=%s",pkgid);
1735 ret = _clean_pkgid_data(pkgid, uid);
1736 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1738 return AIL_ERROR_OK;
1741 EXPORT_API ail_error_e ail_desktop_clean(const char *pkgid)
1743 return ail_usr_desktop_clean(pkgid, GLOBAL_USER);
1746 EXPORT_API ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid)
1748 desktop_info_s info = {0,};
1751 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1753 ret = _init_desktop_info(&info, appid, uid);
1754 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1756 ret = _read_desktop_info(&info,uid);
1757 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1759 ret = _insert_desktop_info(&info, uid);
1760 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1762 _fini_desktop_info(&info);
1764 return AIL_ERROR_OK;
1767 EXPORT_API ail_error_e ail_desktop_fota(const char *appid)
1769 return ail_usr_desktop_fota(appid, GLOBAL_USER);
1773 EXPORT_API ail_error_e ail_desktop_appinfo_modify_usr_bool(const char *appid,
1774 const char *property,
1776 bool broadcast, uid_t uid)
1778 desktop_info_s info = {0,};
1781 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1783 retv_if(strcmp(property, AIL_PROP_X_SLP_ENABLED_BOOL),
1784 AIL_ERROR_INVALID_PARAMETER);
1786 ret = _init_desktop_info(&info, appid, uid);
1787 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1789 ret = _load_desktop_info(&info, uid);
1790 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1792 ret = _modify_desktop_info_bool(&info, property, value);
1793 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1795 ret = _update_desktop_info(&info, uid);
1796 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1799 ret = _send_db_done_noti(NOTI_UPDATE, appid);
1800 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1803 _fini_desktop_info(&info);
1805 return AIL_ERROR_OK;
1808 EXPORT_API ail_error_e ail_desktop_appinfo_modify_bool(const char *appid,
1809 const char *property,
1813 return ail_desktop_appinfo_modify_usr_bool(appid, property, value, broadcast,
1818 EXPORT_API ail_error_e ail_desktop_appinfo_modify_usr_str(const char *appid, uid_t uid,
1819 const char *property,
1823 desktop_info_s info = {0,};
1826 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1828 ret = _init_desktop_info(&info, appid, uid);
1829 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1831 ret = _load_desktop_info(&info, uid);
1832 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1834 _D("info.name [%s], value [%s]", info.name, value);
1835 ret = _modify_desktop_info_str(&info, property, value);
1836 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1837 _D("info.name [%s], value [%s]", info.name, value);
1839 ret = _update_desktop_info(&info, uid);
1840 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1843 ret = _send_db_done_noti(NOTI_UPDATE, appid);
1844 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1847 _fini_desktop_info(&info);
1849 return AIL_ERROR_OK;
1852 EXPORT_API ail_error_e ail_desktop_appinfo_modify_str(const char *appid,
1853 const char *property,
1857 return ail_desktop_appinfo_modify_usr_str(appid, GLOBAL_USER, property, value,