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>
40 #include "ail_private.h"
48 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
49 #define argsdelimiter " \t"
51 #define SQL_INSERT_LOCALNAME_STR "insert into localname (package, locale, name) values "
52 #define SQL_INSERT_LOCALNAME_STR_LEN (sizeof(SQL_INSERT_LOCALNAME_STR)-1)
54 #define SQL_INSERT_LOCALNAME_INIT_STR SQL_INSERT_LOCALNAME_STR"( ?, ?, ?) "
56 #define SQL_LOCALNAME_TRIPLET_STR ", ( ?, ?, ?)"
57 #define SQL_LOCALNAME_TRIPLET_STR_LEN (sizeof(SQL_LOCALNAME_TRIPLET_STR)-1)
68 ail_error_e (*value_cb)(void *data, char *tag, char *value);
71 inline static char *_ltrim(char *str)
73 if (!str) return NULL;
75 while (*str == ' ' || *str == '\t' || *str == '\n') str ++;
82 inline static int _rtrim(char *str)
87 while (--len >= 0 && (str[len] == ' ' || str[len] == '\n' || str[len] == '\t')) str[len] = '\0';
107 char* x_slp_packagetype;
108 char* x_slp_packagecategories;
109 char* x_slp_packageid;
112 char* x_slp_exe_path;
116 char* x_slp_submodemainid;
117 char* x_slp_installedstorage;
118 int x_slp_baselayoutwidth;
119 int x_slp_installedtime;
121 int x_slp_taskmanage;
124 int x_slp_ishorizontalscale;
133 static ail_error_e _read_exec(void *data, char *tag, char *value)
135 desktop_info_s *info = data;
136 char *token_exe_path;
140 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
141 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
143 SAFE_FREE_AND_STRDUP(value, info->exec);
144 retv_if(!info->exec, AIL_ERROR_OUT_OF_MEMORY);
146 temp_exec = strdup(value);
149 return AIL_ERROR_OUT_OF_MEMORY;
152 token_exe_path = strtok_r(temp_exec, argsdelimiter, &save_ptr);
154 info->x_slp_exe_path = strdup(token_exe_path);
155 if(!info->x_slp_exe_path) {
159 return AIL_ERROR_OUT_OF_MEMORY;
169 static ail_error_e _read_name(void *data, char *tag, char *value)
171 desktop_info_s *info = data;
173 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
174 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
175 retv_if(0 == strlen(value), AIL_ERROR_FAIL);
177 if (tag && strlen(tag) > 0) {
178 struct name_item *item;
179 item = (struct name_item *)calloc(1, sizeof(struct name_item));
180 retv_if (NULL == item, AIL_ERROR_OUT_OF_MEMORY);
182 SAFE_FREE_AND_STRDUP(tag, item->locale);
183 if(NULL == item->locale) {
184 _E("(NULL == item->locale) return\n");
186 return AIL_ERROR_OUT_OF_MEMORY;
189 SAFE_FREE_AND_STRDUP(value, item->name);
190 if(NULL == item->name) {
191 _E("(NULL == item->name) return\n");
194 return AIL_ERROR_OUT_OF_MEMORY;
197 info->localname = g_slist_append(info->localname, item);
201 SAFE_FREE_AND_STRDUP(value, info->name);
202 retv_if (!info->name, AIL_ERROR_OUT_OF_MEMORY);
210 static ail_error_e _read_type(void *data, char *tag, char *value)
212 desktop_info_s *info = data;
214 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
215 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
217 SAFE_FREE_AND_STRDUP(value, info->type);
218 retv_if (!info->type, AIL_ERROR_OUT_OF_MEMORY);
225 _get_package_from_icon(char* icon)
230 retv_if(!icon, NULL);
232 package = strdup(icon);
233 retv_if(!package, NULL);
234 extension = rindex(package, '.');
238 _E("cannot extract from icon [%s] to package.", icon);
246 _get_icon_with_path(char* icon, uid_t uid)
248 retv_if(!icon, NULL);
250 if (index(icon, '/') == NULL) {
253 char* icon_with_path = NULL;
255 char *app_path = NULL;
257 package = _get_package_from_icon(icon);
258 retv_if(!package, NULL);
260 /* "db/setting/theme" is not exist */
262 theme = vconf_get_str("db/setting/theme");
264 theme = strdup("default");
271 theme = strdup("default");
274 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
275 icon_with_path = malloc(len);
276 if(icon_with_path == NULL) {
277 _E("icon_with_path == NULL\n");
283 memset(icon_with_path, 0, len);
284 if (uid != GLOBAL_USER)
285 sqlite3_snprintf( len, icon_with_path, "%s%q", ail_get_icon_path(uid), icon);
287 sqlite3_snprintf( len, icon_with_path, "%s/%q/small/%q", ail_get_icon_path(GLOBAL_USER), theme, icon);
289 if (access (icon_with_path, F_OK)) {
290 app_path = tzplatform_getenv(TZ_SYS_RW_APP);
292 sqlite3_snprintf( len, icon_with_path, "%s/%q/res/icons/%q/small/%q",app_path, package, theme, icon);
293 if (access (icon_with_path, F_OK))
294 _E("Cannot find icon path");
298 _D("Icon path : %s", icon_with_path);
299 return icon_with_path;
301 char* confirmed_icon = NULL;
303 confirmed_icon = strdup(icon);
304 retv_if(!confirmed_icon, NULL);
305 return confirmed_icon;
310 static ail_error_e _read_icon(void *data, char *tag, char *value, uid_t uid)
312 desktop_info_s *info = data;
314 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
315 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
317 info->icon = _get_icon_with_path(value, uid);
319 retv_if (!info->icon, AIL_ERROR_OUT_OF_MEMORY);
326 static ail_error_e _read_categories(void *data, char *tag, char *value)
328 desktop_info_s *info = data;
330 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
331 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
333 SAFE_FREE_AND_STRDUP(value, info->categories);
334 retv_if (!info->categories, AIL_ERROR_OUT_OF_MEMORY);
341 static ail_error_e _read_version(void *data, char *tag, char *value)
343 desktop_info_s *info = data;
345 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
346 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
348 SAFE_FREE_AND_STRDUP(value, info->version);
349 retv_if (!info->version, AIL_ERROR_OUT_OF_MEMORY);
356 static ail_error_e _read_mimetype(void *data, char *tag, char *value)
358 desktop_info_s *info = data;
359 int size, total_len = 0;
360 char *mimes_origin, *mimes_changed, *token_unalias, *save_ptr;
362 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
363 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
364 retv_if(!strlen(value), AIL_ERROR_FAIL);
366 mimes_origin = strdup(value);
367 retv_if(!mimes_origin, AIL_ERROR_OUT_OF_MEMORY);
369 size = getpagesize();
370 mimes_changed = calloc(1, size);
371 if(mimes_changed == NULL) {
372 _E("(mimes_changed == NULL) return\n");
374 return AIL_ERROR_OUT_OF_MEMORY;
377 token_unalias = strtok_r(mimes_origin, ";", &save_ptr);
379 while (token_unalias) {
381 const char *token_alias;
383 _rtrim(token_unalias);
384 token_unalias = _ltrim(token_unalias);
386 token_alias = xdg_mime_unalias_mime_type(token_unalias);
387 if (!token_alias) continue;
389 token_len = strlen(token_alias);
390 if (total_len + token_len + (1<<1) >= size) {
393 tmp = realloc(mimes_changed, size);
396 return AIL_ERROR_OUT_OF_MEMORY;
401 strncat(mimes_changed, token_alias, size-1);
402 total_len += token_len;
404 token_unalias = strtok_r(NULL, ";", &save_ptr);
406 strncat(mimes_changed, ";", size-strlen(mimes_changed)-1);
410 SAFE_FREE(info->mimetype);
411 info->mimetype = mimes_changed;
418 static ail_error_e _read_nodisplay(void *data, char *tag, char *value)
420 desktop_info_s* info = data;
422 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
423 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
425 info->nodisplay = !strcasecmp(value, "true");
432 static ail_error_e _read_x_slp_service(void *data, char *tag, char *value)
434 desktop_info_s *info = data;
436 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
437 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
439 SAFE_FREE_AND_STRDUP(value, info->x_slp_service);
440 retv_if(!info->x_slp_service, AIL_ERROR_OUT_OF_MEMORY);
447 static ail_error_e _read_x_slp_packagetype(void *data, char *tag, char *value)
449 desktop_info_s *info = data;
451 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
452 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
454 SAFE_FREE_AND_STRDUP(value, info->x_slp_packagetype);
455 retv_if(!info->x_slp_packagetype, AIL_ERROR_OUT_OF_MEMORY);
462 static ail_error_e _read_x_slp_packagecategories(void *data, char *tag, char *value)
464 desktop_info_s *info = data;
466 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
467 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
469 SAFE_FREE_AND_STRDUP(value, info->x_slp_packagecategories);
470 retv_if(!info->x_slp_packagecategories, AIL_ERROR_OUT_OF_MEMORY);
477 static ail_error_e _read_x_slp_packageid(void *data, char *tag, char *value)
479 desktop_info_s *info = data;
481 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
482 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
484 SAFE_FREE_AND_STRDUP(value, info->x_slp_packageid);
485 retv_if(!info->x_slp_packageid, AIL_ERROR_OUT_OF_MEMORY);
490 static ail_error_e _read_x_slp_submodemainid(void *data, char *tag, char *value)
492 desktop_info_s *info = data;
494 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
495 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
497 SAFE_FREE_AND_STRDUP(value, info->x_slp_submodemainid);
498 retv_if(!info->x_slp_submodemainid, AIL_ERROR_OUT_OF_MEMORY);
503 static ail_error_e _read_x_slp_installedstorage(void *data, char *tag, char *value)
505 desktop_info_s *info = data;
507 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
508 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
510 SAFE_FREE_AND_STRDUP(value, info->x_slp_installedstorage);
511 retv_if(!info->x_slp_installedstorage, AIL_ERROR_OUT_OF_MEMORY);
516 static ail_error_e _read_x_slp_uri(void *data, char *tag, char *value)
518 desktop_info_s *info = data;
520 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
521 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
523 SAFE_FREE_AND_STRDUP(value, info->x_slp_uri);
524 retv_if(!info->x_slp_uri, AIL_ERROR_OUT_OF_MEMORY);
531 static ail_error_e _read_x_slp_svc(void *data, char *tag, char *value)
533 desktop_info_s *info = data;
535 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
536 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
538 SAFE_FREE_AND_STRDUP(value, info->x_slp_svc);
539 retv_if(!info->x_slp_svc, AIL_ERROR_OUT_OF_MEMORY);
546 static ail_error_e _read_x_slp_taskmanage(void *data, char *tag, char *value)
548 desktop_info_s *info = data;
550 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
551 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
553 info->x_slp_taskmanage = !strcasecmp(value, "true");
560 static ail_error_e _read_x_slp_multiple(void *data, char *tag, char *value)
562 desktop_info_s *info = data;
564 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
565 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
567 info->x_slp_multiple = !strcasecmp(value, "true");
574 static ail_error_e _read_x_slp_removable(void *data, char *tag, char *value)
576 desktop_info_s *info = data;
578 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
579 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
581 info->x_slp_removable = !strcasecmp(value, "true");
587 static ail_error_e _read_x_slp_submode(void *data, char *tag, char *value)
589 desktop_info_s *info = data;
591 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
592 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
594 info->x_slp_submode = !strcasecmp(value, "true");
599 static ail_error_e _read_x_slp_appid(void *data, char *tag, char *value)
601 desktop_info_s *info = data;
603 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
604 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
606 SAFE_FREE_AND_STRDUP(value, info->x_slp_appid);
607 retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
613 static ail_error_e _read_x_slp_pkgid(void *data, char *tag, char *value)
615 desktop_info_s *info = data;
617 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
618 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
620 SAFE_FREE_AND_STRDUP(value, info->x_slp_pkgid);
621 retv_if(!info->x_slp_pkgid, AIL_ERROR_OUT_OF_MEMORY);
627 static ail_error_e _read_x_slp_domain(void *data, char *tag, char *value)
629 desktop_info_s *info = data;
631 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
632 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
634 SAFE_FREE_AND_STRDUP(value, info->x_slp_domain);
635 retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
641 static ail_error_e _read_x_slp_enabled(void *data, char *tag, char *value)
643 desktop_info_s *info = data;
645 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
646 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
648 info->x_slp_enabled = !strcasecmp(value, "true");
654 static struct entry_parser entry_parsers[] = {
657 .value_cb = _read_exec,
661 .value_cb = _read_name,
665 .value_cb = _read_type,
669 .value_cb = _read_icon,
672 .field = "categories",
673 .value_cb = _read_categories,
677 .value_cb = _read_version,
681 .value_cb = _read_mimetype,
684 .field = "x-tizen-service",
685 .value_cb = _read_x_slp_service,
688 .field = "x-tizen-packagetype",
689 .value_cb = _read_x_slp_packagetype,
692 .field = "x-tizen-packagecategories",
693 .value_cb = _read_x_slp_packagecategories,
696 .field = "x-tizen-packageid",
697 .value_cb = _read_x_slp_packageid,
700 .field = "x-tizen-submodemainid",
701 .value_cb = _read_x_slp_submodemainid,
704 .field = "x-tizen-installedstorage",
705 .value_cb = _read_x_slp_installedstorage,
708 .field = "x-tizen-uri",
709 .value_cb = _read_x_slp_uri,
712 .field = "x-tizen-svc",
713 .value_cb = _read_x_slp_svc,
716 .field = "nodisplay",
717 .value_cb = _read_nodisplay,
720 .field = "x-tizen-taskmanage",
721 .value_cb = _read_x_slp_taskmanage,
724 .field = "x-tizen-enabled",
725 .value_cb = _read_x_slp_enabled,
728 .field = "x-tizen-submode",
729 .value_cb = _read_x_slp_submode,
732 .field = "x-tizen-multiple",
733 .value_cb = _read_x_slp_multiple,
736 .field = "x-tizen-removable",
737 .value_cb = _read_x_slp_removable,
740 .field = "x-tizen-appid",
741 .value_cb = _read_x_slp_appid,
744 .field = "x-tizen-pkgid",
745 .value_cb = _read_x_slp_pkgid,
748 .field = "x-tizen-domain",
749 .value_cb = _read_x_slp_domain,
752 .field = "x-tizen-enabled",
753 .value_cb = _read_x_slp_domain,
763 /* Utility functions */
764 static int _count_all(uid_t uid)
769 if (uid != GLOBAL_USER)
770 ret = ail_filter_count_usr_appinfo(NULL, &count, uid);
772 ret = ail_filter_count_appinfo(NULL, &count);
773 if(ret != AIL_ERROR_OK) {
774 _E("cannot count appinfo");
778 retv_if(ret != AIL_ERROR_OK, -1);
783 char *_pkgname_to_desktop(const char *package, uid_t uid)
789 retv_if(!package, NULL);
791 desktop_path = al_get_desktop_path(uid);
793 size = strlen(desktop_path) + strlen(package) + 10;
794 desktop = malloc(size);
795 retv_if(!desktop, NULL);
797 snprintf(desktop, size, "%s/%s.desktop", desktop_path, package);
799 _D("uid: %d / desktop: [%s]\n", uid, desktop);
804 static inline int _bind_local_info(desktop_info_s* info, sqlite3_stmt * stmt)
808 struct name_item *item;
810 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
811 retv_if(!info->localname, AIL_ERROR_INVALID_PARAMETER);
812 retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
813 localname = info->localname;
815 item = (struct name_item *) localname->data;
816 if (item && item->locale && item->name) {
817 // Bind values for a triplet : package, locale, name
818 retv_if(db_bind_text(stmt, i+1, info->package) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
819 retv_if(db_bind_text(stmt, i+2, item->locale) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
820 retv_if(db_bind_text(stmt, i+3, item->name) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
823 localname = g_slist_next(localname);
829 static inline int _len_local_info(desktop_info_s* info)
832 struct name_item *item;
834 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
835 if(info->localname) {
836 localname = info->localname;
838 item = (struct name_item *) localname->data;
839 if (item && item->locale && item->name)
841 localname = g_slist_next(localname);
848 static inline int _insert_local_info(desktop_info_s* info, uid_t uid)
850 int len_query = SQL_INSERT_LOCALNAME_STR_LEN;
853 int ret = AIL_ERROR_OK;
854 sqlite3_stmt *stmt = NULL;
856 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
857 retv_if(!info->localname, AIL_ERROR_INVALID_PARAMETER);
859 nb_locale_args = _len_local_info(info);
861 retv_if(!nb_locale_args, AIL_ERROR_INVALID_PARAMETER);
863 len_query += SQL_LOCALNAME_TRIPLET_STR_LEN*nb_locale_args +1;
865 query = (char *) malloc(len_query);
866 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
867 stpncpy(query, SQL_INSERT_LOCALNAME_INIT_STR, len_query);
868 for (i = 0; i < nb_locale_args - 1; i++)
869 strcat(query, SQL_LOCALNAME_TRIPLET_STR);
872 if(uid != GLOBAL_USER)
873 ret = db_prepare_rw(query, &stmt);
875 ret = db_prepare_globalrw(query, &stmt);
878 ret = _bind_local_info(info, stmt);
880 _E("Can't bind locale information to this query - %s. ",query);
885 if (ret != AIL_ERROR_NO_DATA) {
886 /* Insert Request doesn't return any data.
887 * db_step should returns AIL_ERROR_NO_DATA in this case. */
888 _E("Can't execute this query - %s. ",query);
892 ret = db_finalize(stmt);
899 static inline int _strlen_desktop_info(desktop_info_s* info)
903 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
905 if (info->package) len += strlen(info->package);
906 if (info->exec) len += strlen(info->exec);
907 if (info->name) len += strlen(info->name);
908 if (info->type) len += strlen(info->type);
909 if (info->icon) len += strlen(info->icon);
910 if (info->categories) len += strlen(info->categories);
911 if (info->version) len += strlen(info->version);
912 if (info->mimetype) len += strlen(info->mimetype);
913 if (info->x_slp_service) len += strlen(info->x_slp_service);
914 if (info->x_slp_packagetype) len += strlen(info->x_slp_packagetype);
915 if (info->x_slp_packagecategories) len += strlen(info->x_slp_packagecategories);
916 if (info->x_slp_packageid) len += strlen(info->x_slp_packageid);
917 if (info->x_slp_uri) len += strlen(info->x_slp_uri);
918 if (info->x_slp_svc) len += strlen(info->x_slp_svc);
919 if (info->x_slp_exe_path) len += strlen(info->x_slp_exe_path);
920 if (info->x_slp_appid) len += strlen(info->x_slp_appid);
921 if (info->desktop) len += strlen(info->desktop);
922 if (info->x_slp_submodemainid) len += strlen(info->x_slp_submodemainid);
923 if (info->x_slp_installedstorage) len += strlen(info->x_slp_installedstorage);
929 int __is_ail_initdb(void)
931 if( getenv("AIL_INITDB") || getenv("INITDB") )
937 /* Manipulating desktop_info functions */
938 static ail_error_e _init_desktop_info(desktop_info_s *info, const char *package, uid_t uid)
940 static int is_initdb = -1;
942 _D("package - [%s].", package);
945 is_initdb = __is_ail_initdb();
947 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
948 retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
951 info->package = package;
953 info->x_slp_taskmanage = 1;
954 info->x_slp_removable = 1;
955 info->x_slp_submode = 0;
958 info->x_slp_installedtime = 0;
960 info->x_slp_installedtime = time(NULL);
963 info->x_slp_packagetype = strdup(PKGTYPE);
965 info->x_slp_packagetype = strdup("rpm");
967 retv_if(!info->x_slp_packagetype, AIL_ERROR_OUT_OF_MEMORY);
969 info->x_slp_packageid = strdup(package);
970 retv_if(!info->x_slp_packageid, AIL_ERROR_OUT_OF_MEMORY);
971 info->x_slp_appid = strdup(package);
972 retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
974 info->x_slp_enabled = 1;
976 info->desktop = _pkgname_to_desktop(package, uid);
977 retv_if(!info->desktop, AIL_ERROR_FAIL);
979 _D("desktop - [%s].", info->desktop);
986 static ail_error_e _read_desktop_info(desktop_info_s* info)
993 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
995 fp = fopen(info->desktop, "r");
996 retv_if(!fp, AIL_ERROR_FAIL);
998 while ((read = getline(&line, &size, fp)) != -1) {
1000 char *tmp, *field, *field_name, *tag, *value;
1003 if(tmp == NULL) continue;
1004 if (*tmp == '#') continue;
1005 if (_rtrim(tmp) <= 0) continue;
1007 len = strlen(line) + 1;
1008 field = calloc(1, len);
1009 field_name = calloc(1, len);
1010 tag = calloc(1, len);
1011 value = calloc(1, len);
1013 if (!field || !field_name || !tag || !value) {
1017 sscanf(tmp, "%[^=]=%[^\n]", field, value);
1019 tmp = _ltrim(value);
1021 sscanf(field, "%[^[][%[^]]]", field_name, tag);
1023 if (!field_name || !strlen(field_name)){
1027 for (idx = 0; entry_parsers[idx].field; idx ++) {
1028 if (!g_ascii_strcasecmp(entry_parsers[idx].field, field_name) && entry_parsers[idx].value_cb) {
1029 if (entry_parsers[idx].value_cb(info, tag, tmp) != AIL_ERROR_OK) {
1030 _E("field - [%s] is wrong.", field_name);
1037 SAFE_FREE(field_name);
1042 _D("Read (%s).", info->package);
1045 return AIL_ERROR_OK;
1049 static ail_error_e _retrieve_all_column_to_desktop_info(desktop_info_s* info, sqlite3_stmt *stmt)
1056 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1058 values = calloc(NUM_OF_PROP, sizeof(char *));
1059 retv_if(!values, AIL_ERROR_OUT_OF_MEMORY);
1061 for (i = 0; i < NUM_OF_PROP; i++) {
1062 err = db_column_str(stmt, i, &col);
1063 if (AIL_ERROR_OK != err)
1069 values[i] = strdup(col);
1071 err = AIL_ERROR_OUT_OF_MEMORY;
1077 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_EXEC_STR], info->exec);
1078 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_NAME_STR], info->name);
1079 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_TYPE_STR], info->type);
1080 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_ICON_STR], info->icon);
1081 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_CATEGORIES_STR], info->categories);
1082 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_VERSION_STR], info->version);
1083 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_MIMETYPE_STR], info->mimetype);
1084 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_SERVICE_STR], info->x_slp_service);
1085 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PACKAGETYPE_STR], info->x_slp_packagetype);
1086 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR], info->x_slp_packagecategories);
1087 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PACKAGEID_STR], info->x_slp_packageid);
1088 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_URI_STR], info->x_slp_uri);
1089 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_SVC_STR], info->x_slp_svc);
1090 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_EXE_PATH], info->x_slp_exe_path);
1091 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_APPID_STR], info->x_slp_appid);
1092 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PKGID_STR], info->x_slp_pkgid);
1093 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_DOMAIN_STR], info->x_slp_domain);
1094 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_SUBMODEMAINID_STR], info->x_slp_submodemainid);
1095 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR], info->x_slp_installedstorage);
1097 info->x_slp_installedtime = atoi(values[E_AIL_PROP_X_SLP_INSTALLEDTIME_INT]);
1099 info->nodisplay = atoi(values[E_AIL_PROP_NODISPLAY_BOOL]);
1100 info->x_slp_taskmanage = atoi(values[E_AIL_PROP_X_SLP_TASKMANAGE_BOOL]);
1101 info->x_slp_multiple = atoi(values[E_AIL_PROP_X_SLP_MULTIPLE_BOOL]);
1102 info->x_slp_removable = atoi(values[E_AIL_PROP_X_SLP_REMOVABLE_BOOL]);
1103 info->x_slp_ishorizontalscale = atoi(values[E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL]);
1104 info->x_slp_enabled = atoi(values[E_AIL_PROP_X_SLP_ENABLED_BOOL]);
1105 info->x_slp_submode = atoi(values[E_AIL_PROP_X_SLP_SUBMODE_BOOL]);
1110 for (j = 0; j < i; ++j) {
1120 static ail_error_e _load_desktop_info(desktop_info_s* info, uid_t uid)
1123 char query[AIL_SQL_QUERY_MAX_LEN];
1124 sqlite3_stmt *stmt = NULL;
1125 char w[AIL_SQL_QUERY_MAX_LEN];
1127 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1129 snprintf(w, sizeof(w), sql_get_filter(E_AIL_PROP_X_SLP_APPID_STR), info->package);
1131 snprintf(query, sizeof(query), "SELECT %s FROM %s WHERE %s",SQL_FLD_APP_INFO, SQL_TBL_APP_INFO, w);
1134 ret = db_open(DB_OPEN_RO, uid);
1137 ret = db_prepare(query, &stmt);
1138 //ret = db_prepare_globalro(query, &stmt);
1141 ret = db_step(stmt);
1147 ret = _retrieve_all_column_to_desktop_info(info, stmt);
1153 ret = db_finalize(stmt);
1156 return AIL_ERROR_OK;
1162 static ail_error_e _modify_desktop_info_bool(desktop_info_s* info,
1163 const char *property,
1166 ail_prop_bool_e prop;
1169 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1170 retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
1172 prop = _ail_convert_to_prop_bool(property);
1174 if (prop < E_AIL_PROP_BOOL_MIN || prop > E_AIL_PROP_BOOL_MAX)
1175 return AIL_ERROR_INVALID_PARAMETER;
1178 case E_AIL_PROP_X_SLP_ENABLED_BOOL:
1179 info->x_slp_enabled = (int)value;
1182 return AIL_ERROR_FAIL;
1185 return AIL_ERROR_OK;
1189 static ail_error_e _modify_desktop_info_str(desktop_info_s* info,
1190 const char *property,
1193 ail_prop_bool_e prop;
1196 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1197 retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
1199 prop = _ail_convert_to_prop_str(property);
1201 if (prop < E_AIL_PROP_STR_MIN || prop > E_AIL_PROP_STR_MAX)
1202 return AIL_ERROR_INVALID_PARAMETER;
1205 case E_AIL_PROP_NAME_STR:
1206 SAFE_FREE_AND_STRDUP(value, info->name);
1207 retv_if (!info->name, AIL_ERROR_OUT_OF_MEMORY);
1209 case E_AIL_PROP_X_SLP_SVC_STR:
1210 SAFE_FREE_AND_STRDUP(value, info->x_slp_svc);
1211 retv_if (!info->x_slp_svc, AIL_ERROR_OUT_OF_MEMORY);
1213 case E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR:
1214 SAFE_FREE_AND_STRDUP(value, info->x_slp_installedstorage);
1215 retv_if (!info->x_slp_installedstorage, AIL_ERROR_OUT_OF_MEMORY);
1218 _E("prop[%d] is not defined\n", prop);
1219 return AIL_ERROR_FAIL;
1222 return AIL_ERROR_OK;
1226 static inline void _insert_localname(gpointer data, gpointer user_data, uid_t uid)
1230 struct name_item *item = (struct name_item *)data;
1231 desktop_info_s *info = (desktop_info_s *)user_data;
1233 sqlite3_snprintf(sizeof(query), query, "insert into localname (package, locale, name, x_slp_pkgid) "
1234 "values ('%q', '%q', '%q', '%q');",
1235 info->package, item->locale, item->name, info->x_slp_pkgid);
1236 if(uid != GLOBAL_USER) {
1237 if (db_exec_usr_rw(query) < 0)
1238 _E("Failed to insert local name of package[%s]",info->package);
1240 if (db_exec_glo_rw(query) < 0)
1241 _E("Failed to insert local name of package[%s]",info->package);
1245 static ail_error_e _insert_desktop_info(desktop_info_s *info, uid_t uid)
1251 len = _strlen_desktop_info(info) + (0x01 << 10);
1252 query = calloc(1, len);
1253 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1255 sqlite3_snprintf(len, query, "insert into app_info ("
1264 "x_slp_packagetype, "
1265 "x_slp_packagecategories, "
1273 "x_slp_submodemainid, "
1274 "x_slp_installedstorage, "
1275 "x_slp_baselayoutwidth, "
1276 "x_slp_installedtime, "
1278 "x_slp_taskmanage, "
1281 "x_slp_ishorizontalscale, "
1286 "('%q', '%q', '%q', '%q', '%q', "
1287 "'%q', '%q', '%q', '%q', '%q', "
1288 "'%q', '%q', '%q', '%q', '%q', "
1289 "'%q', '%q', '%q', '%q', '%q', "
1290 "%d, %d, %d, %d, %d, %d, %d,"
1301 info->x_slp_service,
1302 info->x_slp_packagetype,
1303 info->x_slp_packagecategories,
1304 info->x_slp_packageid,
1307 info->x_slp_exe_path,
1311 info->x_slp_submodemainid,
1312 info->x_slp_installedstorage,
1313 info->x_slp_baselayoutwidth,
1314 info->x_slp_installedtime,
1316 info->x_slp_taskmanage,
1317 info->x_slp_multiple,
1318 info->x_slp_removable,
1319 info->x_slp_ishorizontalscale,
1320 info->x_slp_enabled,
1321 info->x_slp_submode,
1325 ret = db_open(DB_OPEN_RW, uid);
1326 if(ret != AIL_ERROR_OK) {
1327 _E("(tmp == NULL) return\n");
1329 return AIL_ERROR_DB_FAILED;
1331 if (uid != GLOBAL_USER)
1332 ret = db_exec_usr_rw(query);
1334 ret = db_exec_glo_rw(query);
1337 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
1339 if (info->localname)
1340 _insert_local_info(info, uid);
1342 _D("Add (%s).", query);
1344 return AIL_ERROR_OK;
1349 static ail_error_e _update_desktop_info(desktop_info_s *info, uid_t uid)
1354 retv_if (NULL == info, AIL_ERROR_INVALID_PARAMETER);
1356 if (db_open(DB_OPEN_RW, uid) < 0) {
1357 return AIL_ERROR_DB_FAILED;
1360 len = _strlen_desktop_info(info) + (0x01 << 10);
1361 query = calloc(1, len);
1362 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1364 sqlite3_snprintf ( len, query, "update app_info set "
1372 "x_slp_service='%q', "
1373 "x_slp_packagetype='%q', "
1374 "x_slp_packagecategories='%q', "
1375 "x_slp_packageid='%q', "
1378 "x_slp_exe_path='%q', "
1379 "x_slp_appid='%q', "
1380 "x_slp_pkgid='%q', "
1381 "x_slp_domain='%q', "
1382 "x_slp_submodemainid='%q', "
1383 "x_slp_installedstorage='%q', "
1384 "x_slp_baselayoutwidth=%d, "
1385 "x_slp_installedtime=%d, "
1387 "x_slp_taskmanage=%d, "
1388 "x_slp_multiple=%d, "
1389 "x_slp_removable=%d, "
1390 "x_slp_ishorizontalscale=%d, "
1391 "x_slp_enabled=%d, "
1392 "x_slp_submode=%d, "
1394 "where package='%q'",
1402 info->x_slp_service,
1403 info->x_slp_packagetype,
1404 info->x_slp_packagecategories,
1405 info->x_slp_packageid,
1408 info->x_slp_exe_path,
1412 info->x_slp_submodemainid,
1413 info->x_slp_installedstorage,
1414 info->x_slp_baselayoutwidth,
1415 info->x_slp_installedtime,
1417 info->x_slp_taskmanage,
1418 info->x_slp_multiple,
1419 info->x_slp_removable,
1420 info->x_slp_ishorizontalscale,
1421 info->x_slp_enabled,
1422 info->x_slp_submode,
1426 if(uid != GLOBAL_USER) {
1427 if (db_exec_usr_rw(query) < 0) {
1429 return AIL_ERROR_DB_FAILED;
1432 if (db_exec_glo_rw(query) < 0) {
1434 return AIL_ERROR_DB_FAILED;
1437 snprintf(query, len, "delete from localname where package = '%s'", info->package);
1438 if (uid != GLOBAL_USER) {
1439 if (db_exec_usr_rw(query) < 0) {
1441 return AIL_ERROR_DB_FAILED;
1444 if (db_exec_glo_rw(query) < 0) {
1446 return AIL_ERROR_DB_FAILED;
1449 if (info->localname)
1450 _insert_local_info(info, uid);
1452 _D("Update (%s).", info->package);
1456 return AIL_ERROR_OK;
1461 static ail_error_e _remove_package(const char* package, uid_t uid)
1466 retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
1468 if (db_open(DB_OPEN_RW, uid) < 0) {
1469 return AIL_ERROR_DB_FAILED;
1472 size = strlen(package) + (0x01 << 10);
1473 query = calloc(1, size);
1474 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1476 snprintf(query, size, "delete from app_info where package = '%s'", package);
1478 if(uid != GLOBAL_USER) {
1479 if (db_exec_usr_rw(query) < 0) {
1481 return AIL_ERROR_DB_FAILED;
1484 if (db_exec_glo_rw(query) < 0) {
1486 return AIL_ERROR_DB_FAILED;
1489 snprintf(query, size, "delete from localname where package = '%s'", package);
1490 _D("query=%s",query);
1492 if(uid != GLOBAL_USER) {
1493 if (db_exec_usr_rw(query) < 0) {
1495 return AIL_ERROR_DB_FAILED;
1498 if (db_exec_glo_rw(query) < 0) {
1500 return AIL_ERROR_DB_FAILED;
1503 _D("Remove (%s).", package);
1506 return AIL_ERROR_OK;
1509 static ail_error_e _clean_pkgid_data(const char* pkgid, uid_t uid)
1514 retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
1516 if (db_open(DB_OPEN_RW, uid) ){
1517 return AIL_ERROR_DB_FAILED;
1520 size = strlen(pkgid) + (0x01 << 10);
1521 query = calloc(1, size);
1522 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1524 snprintf(query, size, "delete from app_info where x_slp_pkgid = '%s'", pkgid);
1526 if(uid != GLOBAL_USER) {
1527 if (db_exec_usr_rw(query) < 0) {
1529 return AIL_ERROR_DB_FAILED;
1532 if (db_exec_glo_rw(query) < 0) {
1534 return AIL_ERROR_DB_FAILED;
1537 snprintf(query, size, "delete from localname where x_slp_pkgid = '%s'", pkgid);
1538 _D("query=%s",query);
1540 if(uid != GLOBAL_USER) {
1541 if (db_exec_usr_rw(query) < 0) {
1543 return AIL_ERROR_DB_FAILED;
1546 if (db_exec_glo_rw(query) < 0) {
1548 return AIL_ERROR_DB_FAILED;
1551 _D("Clean pkgid data (%s).", pkgid);
1554 return AIL_ERROR_OK;
1557 static ail_error_e _send_db_done_noti(noti_type type, const char *package)
1559 char *type_string, *noti_string;
1562 retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
1566 type_string = "create";
1569 type_string = "update";
1572 type_string = "delete";
1575 return AIL_ERROR_FAIL;
1578 size = snprintf(NULL, 0, "%s:%s:%u", type_string, package, getuid());
1579 noti_string = (char*) calloc(size + 1, sizeof(char));
1580 retv_if(!noti_string, AIL_ERROR_OUT_OF_MEMORY);
1582 snprintf(noti_string, size + 1, "%s:%s:%u", type_string, package, getuid());
1583 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
1584 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
1585 _D("Noti : %s", noti_string);
1589 return AIL_ERROR_OK;
1593 static void inline _name_item_free_func(gpointer data)
1595 struct name_item *item = (struct name_item *)data;
1597 SAFE_FREE(item->locale);
1598 item->locale = NULL;
1599 SAFE_FREE(item->name);
1605 static void _fini_desktop_info(desktop_info_s *info)
1607 SAFE_FREE(info->exec);
1608 SAFE_FREE(info->name);
1609 SAFE_FREE(info->type);
1610 SAFE_FREE(info->icon);
1611 SAFE_FREE(info->categories);
1612 SAFE_FREE(info->version);
1613 SAFE_FREE(info->mimetype);
1614 SAFE_FREE(info->x_slp_service);
1615 SAFE_FREE(info->x_slp_packagetype);
1616 SAFE_FREE(info->x_slp_packagecategories);
1617 SAFE_FREE(info->x_slp_packageid);
1618 SAFE_FREE(info->x_slp_uri);
1619 SAFE_FREE(info->x_slp_svc);
1620 SAFE_FREE(info->x_slp_exe_path);
1621 SAFE_FREE(info->x_slp_appid);
1622 SAFE_FREE(info->x_slp_pkgid);
1623 SAFE_FREE(info->x_slp_domain);
1624 SAFE_FREE(info->x_slp_submodemainid);
1625 SAFE_FREE(info->x_slp_installedstorage);
1626 SAFE_FREE(info->desktop);
1627 if (info->localname) {
1628 g_slist_free_full(info->localname, _name_item_free_func);
1629 info->localname = NULL;
1635 static int __is_authorized()
1637 uid_t uid = getuid();
1638 if ((uid_t) 0 == uid )
1645 /* Public functions */
1646 EXPORT_API ail_error_e ail_usr_desktop_add(const char *appid, uid_t uid)
1648 desktop_info_s info = {0,};
1651 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1653 ret = _init_desktop_info(&info, appid, uid);
1654 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1656 ret = _read_desktop_info(&info);
1657 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1659 ret = _insert_desktop_info(&info, uid);
1660 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1662 ret = _send_db_done_noti(NOTI_ADD, appid);
1663 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1665 _fini_desktop_info(&info);
1667 return AIL_ERROR_OK;
1670 EXPORT_API ail_error_e ail_desktop_add(const char *appid)
1672 return ail_usr_desktop_add(appid,GLOBAL_USER);
1675 EXPORT_API ail_error_e ail_usr_desktop_update(const char *appid, uid_t uid)
1677 desktop_info_s info = {0,};
1680 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1682 ret = _init_desktop_info(&info, appid, uid);
1683 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1685 ret = _read_desktop_info(&info);
1686 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1688 ret = _update_desktop_info(&info, uid);
1689 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1691 ret = _send_db_done_noti(NOTI_UPDATE, appid);
1692 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1694 _fini_desktop_info(&info);
1696 return AIL_ERROR_OK;
1699 EXPORT_API ail_error_e ail_desktop_update(const char *appid)
1701 return ail_usr_desktop_update(appid,GLOBAL_USER);
1705 EXPORT_API ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid)
1709 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1711 ret = _remove_package(appid, uid);
1712 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1714 ret = _send_db_done_noti(NOTI_REMOVE, appid);
1715 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1717 return AIL_ERROR_OK;
1720 EXPORT_API ail_error_e ail_desktop_remove(const char *appid)
1722 return ail_usr_desktop_remove(appid, GLOBAL_USER);
1726 EXPORT_API ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid)
1730 retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
1732 _D("ail_desktop_clean=%s",pkgid);
1734 ret = _clean_pkgid_data(pkgid, uid);
1735 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1737 return AIL_ERROR_OK;
1740 EXPORT_API ail_error_e ail_desktop_clean(const char *pkgid)
1742 return ail_usr_desktop_clean(pkgid, GLOBAL_USER);
1745 EXPORT_API ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid)
1747 desktop_info_s info = {0,};
1750 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1752 ret = _init_desktop_info(&info, appid, uid);
1753 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1755 ret = _read_desktop_info(&info);
1756 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1758 ret = _insert_desktop_info(&info, uid);
1759 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1761 _fini_desktop_info(&info);
1763 return AIL_ERROR_OK;
1766 EXPORT_API ail_error_e ail_desktop_fota(const char *appid)
1768 return ail_usr_desktop_fota(appid, GLOBAL_USER);
1772 EXPORT_API ail_error_e ail_desktop_appinfo_modify_usr_bool(const char *appid,
1773 const char *property,
1775 bool broadcast, uid_t uid)
1777 desktop_info_s info = {0,};
1780 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1782 retv_if(strcmp(property, AIL_PROP_X_SLP_ENABLED_BOOL),
1783 AIL_ERROR_INVALID_PARAMETER);
1785 ret = _init_desktop_info(&info, appid, uid);
1786 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1788 ret = _load_desktop_info(&info, uid);
1789 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1791 ret = _modify_desktop_info_bool(&info, property, value);
1792 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1794 ret = _update_desktop_info(&info, uid);
1795 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1798 ret = _send_db_done_noti(NOTI_UPDATE, appid);
1799 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1802 _fini_desktop_info(&info);
1804 return AIL_ERROR_OK;
1807 EXPORT_API ail_error_e ail_desktop_appinfo_modify_bool(const char *appid,
1808 const char *property,
1812 return ail_desktop_appinfo_modify_usr_bool(appid, property, value, broadcast,
1817 EXPORT_API ail_error_e ail_desktop_appinfo_modify_usr_str(const char *appid, uid_t uid,
1818 const char *property,
1822 desktop_info_s info = {0,};
1825 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1827 ret = _init_desktop_info(&info, appid, uid);
1828 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1830 ret = _load_desktop_info(&info, uid);
1831 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1833 _D("info.name [%s], value [%s]", info.name, value);
1834 ret = _modify_desktop_info_str(&info, property, value);
1835 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1836 _D("info.name [%s], value [%s]", info.name, value);
1838 ret = _update_desktop_info(&info, uid);
1839 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1842 ret = _send_db_done_noti(NOTI_UPDATE, appid);
1843 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1846 _fini_desktop_info(&info);
1848 return AIL_ERROR_OK;
1851 EXPORT_API ail_error_e ail_desktop_appinfo_modify_str(const char *appid,
1852 const char *property,
1856 return ail_desktop_appinfo_modify_usr_str(appid, GLOBAL_USER, property, value,