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>
37 #include "ail_private.h"
42 #define OPT_DESKTOP_DIRECTORY "/opt/share/applications"
43 #define USR_DESKTOP_DIRECTORY "/usr/share/applications"
46 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
47 #define argsdelimiter " \t"
49 #define SQL_INSERT_LOCALNAME_STR "insert into localname (package, locale, name) values "
50 #define SQL_INSERT_LOCALNAME_STR_LEN (sizeof(SQL_INSERT_LOCALNAME_STR)-1)
52 #define SQL_INSERT_LOCALNAME_INIT_STR SQL_INSERT_LOCALNAME_STR"( ?, ?, ?) "
54 #define SQL_LOCALNAME_TRIPLET_STR ", ( ?, ?, ?)"
55 #define SQL_LOCALNAME_TRIPLET_STR_LEN (sizeof(SQL_LOCALNAME_TRIPLET_STR)-1)
66 ail_error_e (*value_cb)(void *data, char *tag, char *value);
69 inline static char *_ltrim(char *str)
71 if (!str) return NULL;
73 while (*str == ' ' || *str == '\t' || *str == '\n') str ++;
80 inline static int _rtrim(char *str)
85 while (--len >= 0 && (str[len] == ' ' || str[len] == '\n' || str[len] == '\t')) str[len] = '\0';
105 char* x_slp_packagetype;
106 char* x_slp_packagecategories;
107 char* x_slp_packageid;
110 char* x_slp_exe_path;
114 char* x_slp_submodemainid;
115 int x_slp_baselayoutwidth;
116 int x_slp_installedtime;
118 int x_slp_taskmanage;
121 int x_slp_ishorizontalscale;
130 static ail_error_e _read_exec(void *data, char *tag, char *value)
132 desktop_info_s *info = data;
133 char *token_exe_path;
137 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
138 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
140 SAFE_FREE_AND_STRDUP(value, info->exec);
141 retv_if(!info->exec, AIL_ERROR_OUT_OF_MEMORY);
143 temp_exec = strdup(value);
146 return AIL_ERROR_OUT_OF_MEMORY;
149 token_exe_path = strtok_r(temp_exec, argsdelimiter, &save_ptr);
151 info->x_slp_exe_path = strdup(token_exe_path);
152 if(!info->x_slp_exe_path) {
156 return AIL_ERROR_OUT_OF_MEMORY;
166 static ail_error_e _read_name(void *data, char *tag, char *value)
168 desktop_info_s *info = data;
170 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
171 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
172 retv_if(0 == strlen(value), AIL_ERROR_FAIL);
174 if (tag && strlen(tag) > 0) {
175 struct name_item *item;
176 item = (struct name_item *)calloc(1, sizeof(struct name_item));
177 retv_if (NULL == item, AIL_ERROR_OUT_OF_MEMORY);
179 SAFE_FREE_AND_STRDUP(tag, item->locale);
180 if(NULL == item->locale) {
181 _E("(NULL == item->locale) return\n");
183 return AIL_ERROR_OUT_OF_MEMORY;
186 SAFE_FREE_AND_STRDUP(value, item->name);
187 if(NULL == item->name) {
188 _E("(NULL == item->name) return\n");
191 return AIL_ERROR_OUT_OF_MEMORY;
194 info->localname = g_slist_append(info->localname, item);
198 SAFE_FREE_AND_STRDUP(value, info->name);
199 retv_if (!info->name, AIL_ERROR_OUT_OF_MEMORY);
207 static ail_error_e _read_type(void *data, char *tag, char *value)
209 desktop_info_s *info = data;
211 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
212 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
214 SAFE_FREE_AND_STRDUP(value, info->type);
215 retv_if (!info->type, AIL_ERROR_OUT_OF_MEMORY);
222 _get_package_from_icon(char* icon)
227 retv_if(!icon, NULL);
229 package = strdup(icon);
230 retv_if(!package, NULL);
231 extension = rindex(package, '.');
235 _E("cannot extract from icon [%s] to package.", icon);
243 _get_icon_with_path(char* icon)
245 retv_if(!icon, NULL);
247 if (index(icon, '/') == NULL) {
250 char* icon_with_path = NULL;
253 package = _get_package_from_icon(icon);
254 retv_if(!package, NULL);
256 theme = vconf_get_str("db/setting/theme");
258 theme = strdup("default");
265 len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
266 icon_with_path = malloc(len);
267 if(icon_with_path == NULL) {
268 _E("(icon_with_path == NULL) return\n");
274 memset(icon_with_path, 0, len);
276 sqlite3_snprintf( len, icon_with_path,"/opt/share/icons/%q/small/%q", theme, icon);
278 if (access(icon_with_path, R_OK) == 0) break;
279 sqlite3_snprintf( len, icon_with_path,"/usr/share/icons/%q/small/%q", theme, icon);
280 if (access(icon_with_path, R_OK) == 0) break;
281 _D("cannot find icon %s", icon_with_path);
282 sqlite3_snprintf( len, icon_with_path, "/opt/share/icons/default/small/%q", icon);
283 if (access(icon_with_path, R_OK) == 0) break;
284 sqlite3_snprintf( len, icon_with_path, "/usr/share/icons/default/small/%q", icon);
285 if (access(icon_with_path, R_OK) == 0) break;
287 #if 1 /* this will be remove when finish the work for moving icon path */
288 _E("icon file must be moved to %s", icon_with_path);
289 sqlite3_snprintf( len, icon_with_path, "/opt/apps/%q/res/icons/%q/small/%q", package, theme, icon);
290 if (access(icon_with_path, R_OK) == 0) break;
291 sqlite3_snprintf( len, icon_with_path, "/usr/apps/%q/res/icons/%q/small/%q", package, theme, icon);
292 if (access(icon_with_path, R_OK) == 0) break;
293 _D("cannot find icon %s", icon_with_path);
294 sqlite3_snprintf( len, icon_with_path, "/opt/apps/%q/res/icons/default/small/%q", package, icon);
295 if (access(icon_with_path, R_OK) == 0) break;
296 sqlite3_snprintf( len, icon_with_path, "/usr/apps/%q/res/icons/default/small/%q", package, icon);
297 if (access(icon_with_path, R_OK) == 0) break;
304 _D("Icon path : %s ---> %s", icon, icon_with_path);
306 return icon_with_path;
308 char* confirmed_icon = NULL;
310 confirmed_icon = strdup(icon);
311 retv_if(!confirmed_icon, NULL);
312 return confirmed_icon;
317 static ail_error_e _read_icon(void *data, char *tag, char *value)
319 desktop_info_s *info = data;
321 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
322 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
324 info->icon = _get_icon_with_path(value);
326 retv_if (!info->icon, AIL_ERROR_OUT_OF_MEMORY);
333 static ail_error_e _read_categories(void *data, char *tag, char *value)
335 desktop_info_s *info = data;
337 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
338 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
340 SAFE_FREE_AND_STRDUP(value, info->categories);
341 retv_if (!info->categories, AIL_ERROR_OUT_OF_MEMORY);
348 static ail_error_e _read_version(void *data, char *tag, char *value)
350 desktop_info_s *info = data;
352 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
353 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
355 SAFE_FREE_AND_STRDUP(value, info->version);
356 retv_if (!info->version, AIL_ERROR_OUT_OF_MEMORY);
363 static ail_error_e _read_mimetype(void *data, char *tag, char *value)
365 desktop_info_s *info = data;
366 int size, total_len = 0;
367 char *mimes_origin, *mimes_changed, *token_unalias, *save_ptr;
369 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
370 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
371 retv_if(!strlen(value), AIL_ERROR_FAIL);
373 mimes_origin = strdup(value);
374 retv_if(!mimes_origin, AIL_ERROR_OUT_OF_MEMORY);
376 size = getpagesize();
377 mimes_changed = calloc(1, size);
378 if(mimes_changed == NULL) {
379 _E("(mimes_changed == NULL) return\n");
381 return AIL_ERROR_OUT_OF_MEMORY;
384 token_unalias = strtok_r(mimes_origin, ";", &save_ptr);
386 while (token_unalias) {
388 const char *token_alias;
390 _rtrim(token_unalias);
391 token_unalias = _ltrim(token_unalias);
393 token_alias = xdg_mime_unalias_mime_type(token_unalias);
394 if (!token_alias) continue;
396 token_len = strlen(token_alias);
397 if (total_len + token_len + (1<<1) >= size) {
400 tmp = realloc(mimes_changed, size);
403 return AIL_ERROR_OUT_OF_MEMORY;
408 strncat(mimes_changed, token_alias, size-1);
409 total_len += token_len;
411 token_unalias = strtok_r(NULL, ";", &save_ptr);
413 strncat(mimes_changed, ";", size-strlen(mimes_changed)-1);
417 SAFE_FREE(info->mimetype);
418 info->mimetype = mimes_changed;
425 static ail_error_e _read_nodisplay(void *data, char *tag, char *value)
427 desktop_info_s* info = data;
429 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
430 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
432 info->nodisplay = !strcasecmp(value, "true");
439 static ail_error_e _read_x_slp_service(void *data, char *tag, char *value)
441 desktop_info_s *info = data;
443 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
444 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
446 SAFE_FREE_AND_STRDUP(value, info->x_slp_service);
447 retv_if(!info->x_slp_service, AIL_ERROR_OUT_OF_MEMORY);
454 static ail_error_e _read_x_slp_packagetype(void *data, char *tag, char *value)
456 desktop_info_s *info = data;
458 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
459 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
461 SAFE_FREE_AND_STRDUP(value, info->x_slp_packagetype);
462 retv_if(!info->x_slp_packagetype, AIL_ERROR_OUT_OF_MEMORY);
469 static ail_error_e _read_x_slp_packagecategories(void *data, char *tag, char *value)
471 desktop_info_s *info = data;
473 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
474 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
476 SAFE_FREE_AND_STRDUP(value, info->x_slp_packagecategories);
477 retv_if(!info->x_slp_packagecategories, AIL_ERROR_OUT_OF_MEMORY);
484 static ail_error_e _read_x_slp_packageid(void *data, char *tag, char *value)
486 desktop_info_s *info = data;
488 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
489 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
491 SAFE_FREE_AND_STRDUP(value, info->x_slp_packageid);
492 retv_if(!info->x_slp_packageid, AIL_ERROR_OUT_OF_MEMORY);
497 static ail_error_e _read_x_slp_submodemainid(void *data, char *tag, char *value)
499 desktop_info_s *info = data;
501 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
502 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
504 SAFE_FREE_AND_STRDUP(value, info->x_slp_submodemainid);
505 retv_if(!info->x_slp_submodemainid, AIL_ERROR_OUT_OF_MEMORY);
511 static ail_error_e _read_x_slp_uri(void *data, char *tag, char *value)
513 desktop_info_s *info = data;
515 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
516 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
518 SAFE_FREE_AND_STRDUP(value, info->x_slp_uri);
519 retv_if(!info->x_slp_uri, AIL_ERROR_OUT_OF_MEMORY);
526 static ail_error_e _read_x_slp_svc(void *data, char *tag, char *value)
528 desktop_info_s *info = data;
530 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
531 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
533 SAFE_FREE_AND_STRDUP(value, info->x_slp_svc);
534 retv_if(!info->x_slp_svc, AIL_ERROR_OUT_OF_MEMORY);
541 static ail_error_e _read_x_slp_taskmanage(void *data, char *tag, char *value)
543 desktop_info_s *info = data;
545 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
546 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
548 info->x_slp_taskmanage = !strcasecmp(value, "true");
555 static ail_error_e _read_x_slp_multiple(void *data, char *tag, char *value)
557 desktop_info_s *info = data;
559 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
560 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
562 info->x_slp_multiple = !strcasecmp(value, "true");
569 static ail_error_e _read_x_slp_removable(void *data, char *tag, char *value)
571 desktop_info_s *info = data;
573 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
574 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
576 info->x_slp_removable = !strcasecmp(value, "true");
582 static ail_error_e _read_x_slp_submode(void *data, char *tag, char *value)
584 desktop_info_s *info = data;
586 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
587 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
589 info->x_slp_submode = !strcasecmp(value, "true");
594 static ail_error_e _read_x_slp_appid(void *data, char *tag, char *value)
596 desktop_info_s *info = data;
598 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
599 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
601 SAFE_FREE_AND_STRDUP(value, info->x_slp_appid);
602 retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
608 static ail_error_e _read_x_slp_pkgid(void *data, char *tag, char *value)
610 desktop_info_s *info = data;
612 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
613 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
615 SAFE_FREE_AND_STRDUP(value, info->x_slp_pkgid);
616 retv_if(!info->x_slp_pkgid, AIL_ERROR_OUT_OF_MEMORY);
622 static ail_error_e _read_x_slp_domain(void *data, char *tag, char *value)
624 desktop_info_s *info = data;
626 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
627 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
629 SAFE_FREE_AND_STRDUP(value, info->x_slp_domain);
630 retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
636 static ail_error_e _read_x_slp_enabled(void *data, char *tag, char *value)
638 desktop_info_s *info = data;
640 retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
641 retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
643 info->x_slp_enabled = !strcasecmp(value, "true");
649 static struct entry_parser entry_parsers[] = {
652 .value_cb = _read_exec,
656 .value_cb = _read_name,
660 .value_cb = _read_type,
664 .value_cb = _read_icon,
667 .field = "categories",
668 .value_cb = _read_categories,
672 .value_cb = _read_version,
676 .value_cb = _read_mimetype,
679 .field = "x-tizen-service",
680 .value_cb = _read_x_slp_service,
683 .field = "x-tizen-packagetype",
684 .value_cb = _read_x_slp_packagetype,
687 .field = "x-tizen-packagecategories",
688 .value_cb = _read_x_slp_packagecategories,
691 .field = "x-tizen-packageid",
692 .value_cb = _read_x_slp_packageid,
695 .field = "x-tizen-submodemainid",
696 .value_cb = _read_x_slp_submodemainid,
699 .field = "x-tizen-uri",
700 .value_cb = _read_x_slp_uri,
703 .field = "x-tizen-svc",
704 .value_cb = _read_x_slp_svc,
707 .field = "nodisplay",
708 .value_cb = _read_nodisplay,
711 .field = "x-tizen-taskmanage",
712 .value_cb = _read_x_slp_taskmanage,
715 .field = "x-tizen-enabled",
716 .value_cb = _read_x_slp_enabled,
719 .field = "x-tizen-submode",
720 .value_cb = _read_x_slp_submode,
723 .field = "x-tizen-multiple",
724 .value_cb = _read_x_slp_multiple,
727 .field = "x-tizen-removable",
728 .value_cb = _read_x_slp_removable,
731 .field = "x-tizen-appid",
732 .value_cb = _read_x_slp_appid,
735 .field = "x-tizen-pkgid",
736 .value_cb = _read_x_slp_pkgid,
739 .field = "x-tizen-domain",
740 .value_cb = _read_x_slp_domain,
743 .field = "x-tizen-enabled",
744 .value_cb = _read_x_slp_domain,
754 /* Utility functions */
755 static int _count_all(void)
760 ret = ail_filter_count_appinfo(NULL, &count);
761 if(ret != AIL_ERROR_OK) {
762 _E("cannot count appinfo");
766 retv_if(ret != AIL_ERROR_OK, -1);
773 char *_pkgname_to_desktop(const char *package)
778 retv_if(!package, NULL);
780 size = strlen(OPT_DESKTOP_DIRECTORY) + strlen(package) + 10;
781 desktop = malloc(size);
782 retv_if(!desktop, NULL);
784 snprintf(desktop, size, OPT_DESKTOP_DIRECTORY"/%s.desktop", package);
786 if (access(desktop, R_OK) == 0)
789 snprintf(desktop, size, USR_DESKTOP_DIRECTORY"/%s.desktop", package);
794 static inline int _bind_local_info(desktop_info_s* info, sqlite3_stmt * stmt)
798 struct name_item *item;
800 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
801 retv_if(!info->localname, AIL_ERROR_INVALID_PARAMETER);
802 retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
803 localname = info->localname;
805 item = (struct name_item *) localname->data;
806 if (item && item->locale && item->name) {
807 // Bind values for a triplet : package, locale, name
808 retv_if(db_bind_text(stmt, i+1, info->package) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
809 retv_if(db_bind_text(stmt, i+2, item->locale) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
810 retv_if(db_bind_text(stmt, i+3, item->name) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
813 localname = g_slist_next(localname);
819 static inline int _len_local_info(desktop_info_s* info)
822 struct name_item *item;
824 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
825 if(info->localname) {
826 localname = info->localname;
828 item = (struct name_item *) localname->data;
829 if (item && item->locale && item->name)
831 localname = g_slist_next(localname);
838 static inline int _insert_local_info(desktop_info_s* info)
840 int len_query = SQL_INSERT_LOCALNAME_STR_LEN;
843 int ret = AIL_ERROR_OK;
844 sqlite3_stmt *stmt = NULL;
846 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
847 retv_if(!info->localname, AIL_ERROR_INVALID_PARAMETER);
849 nb_locale_args = _len_local_info(info);
851 retv_if(!nb_locale_args, AIL_ERROR_INVALID_PARAMETER);
853 len_query += SQL_LOCALNAME_TRIPLET_STR_LEN*nb_locale_args +1;
855 query = (char *) malloc(len_query);
856 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
857 stpncpy(query, SQL_INSERT_LOCALNAME_INIT_STR, len_query);
858 for (i = 0; i < nb_locale_args - 1; i++)
859 strcat(query, SQL_LOCALNAME_TRIPLET_STR);
862 ret = db_prepare_rw(query, &stmt);
865 ret = _bind_local_info(info, stmt);
867 _E("Can't bind locale information to this query - %s. ",query);
872 if (ret != AIL_ERROR_NO_DATA) {
873 /* Insert Request doesn't return any data.
874 * db_step should returns AIL_ERROR_NO_DATA in this case. */
875 _E("Can't execute this query - %s. ",query);
879 ret = db_finalize(stmt);
886 static inline int _strlen_desktop_info(desktop_info_s* info)
890 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
892 if (info->package) len += strlen(info->package);
893 if (info->exec) len += strlen(info->exec);
894 if (info->name) len += strlen(info->name);
895 if (info->type) len += strlen(info->type);
896 if (info->icon) len += strlen(info->icon);
897 if (info->categories) len += strlen(info->categories);
898 if (info->version) len += strlen(info->version);
899 if (info->mimetype) len += strlen(info->mimetype);
900 if (info->x_slp_service) len += strlen(info->x_slp_service);
901 if (info->x_slp_packagetype) len += strlen(info->x_slp_packagetype);
902 if (info->x_slp_packagecategories) len += strlen(info->x_slp_packagecategories);
903 if (info->x_slp_packageid) len += strlen(info->x_slp_packageid);
904 if (info->x_slp_uri) len += strlen(info->x_slp_uri);
905 if (info->x_slp_svc) len += strlen(info->x_slp_svc);
906 if (info->x_slp_exe_path) len += strlen(info->x_slp_exe_path);
907 if (info->x_slp_appid) len += strlen(info->x_slp_appid);
908 if (info->desktop) len += strlen(info->desktop);
909 if (info->x_slp_submodemainid) len += strlen(info->x_slp_submodemainid);
915 int __is_ail_initdb(void)
917 if( getenv("AIL_INITDB") || getenv("INITDB") )
925 /* Manipulating desktop_info functions */
926 static ail_error_e _init_desktop_info(desktop_info_s *info, const char *package)
928 static int is_initdb = -1;
931 is_initdb = __is_ail_initdb();
933 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
934 retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
937 info->package = package;
939 info->x_slp_taskmanage = 1;
940 info->x_slp_removable = 1;
941 info->x_slp_submode = 0;
944 info->x_slp_installedtime = 0;
946 info->x_slp_installedtime = time(NULL);
949 info->x_slp_packagetype = strdup(PKGTYPE);
951 info->x_slp_packagetype = strdup("rpm");
953 retv_if(!info->x_slp_packagetype, AIL_ERROR_OUT_OF_MEMORY);
955 info->x_slp_packageid = strdup(package);
956 retv_if(!info->x_slp_packageid, AIL_ERROR_OUT_OF_MEMORY);
957 info->x_slp_appid = strdup(package);
958 retv_if(!info->x_slp_appid, AIL_ERROR_OUT_OF_MEMORY);
960 info->x_slp_enabled = 1;
962 info->desktop = _pkgname_to_desktop(package);
963 retv_if(!info->desktop, AIL_ERROR_FAIL);
970 static ail_error_e _read_desktop_info(desktop_info_s* info)
977 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
979 fp = fopen(info->desktop, "r");
980 retv_if(!fp, AIL_ERROR_FAIL);
982 while ((read = getline(&line, &size, fp)) != -1) {
984 char *tmp, *field, *field_name, *tag, *value;
987 if(tmp == NULL) continue;
988 if (*tmp == '#') continue;
989 if (_rtrim(tmp) <= 0) continue;
991 len = strlen(line) + 1;
992 field = calloc(1, len);
993 field_name = calloc(1, len);
994 tag = calloc(1, len);
995 value = calloc(1, len);
997 if (!field || !field_name || !tag || !value) {
1001 sscanf(tmp, "%[^=]=%[^\n]", field, value);
1003 tmp = _ltrim(value);
1005 sscanf(field, "%[^[][%[^]]]", field_name, tag);
1007 if (!field_name || !strlen(field_name)){
1011 for (idx = 0; entry_parsers[idx].field; idx ++) {
1012 if (!g_ascii_strcasecmp(entry_parsers[idx].field, field_name) && entry_parsers[idx].value_cb) {
1013 if (entry_parsers[idx].value_cb(info, tag, tmp) != AIL_ERROR_OK) {
1014 _E("field - [%s] is wrong.", field_name);
1021 SAFE_FREE(field_name);
1026 _D("Read (%s).", info->package);
1029 return AIL_ERROR_OK;
1033 static ail_error_e _retrieve_all_column_to_desktop_info(desktop_info_s* info, sqlite3_stmt *stmt)
1040 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1042 values = calloc(NUM_OF_PROP, sizeof(char *));
1043 retv_if(!values, AIL_ERROR_OUT_OF_MEMORY);
1045 for (i = 0; i < NUM_OF_PROP; i++) {
1046 err = db_column_str(stmt, i, &col);
1047 if (AIL_ERROR_OK != err)
1053 values[i] = strdup(col);
1055 err = AIL_ERROR_OUT_OF_MEMORY;
1061 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_EXEC_STR], info->exec);
1062 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_NAME_STR], info->name);
1063 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_TYPE_STR], info->type);
1064 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_ICON_STR], info->icon);
1065 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_CATEGORIES_STR], info->categories);
1066 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_VERSION_STR], info->version);
1067 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_MIMETYPE_STR], info->mimetype);
1068 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_SERVICE_STR], info->x_slp_service);
1069 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PACKAGETYPE_STR], info->x_slp_packagetype);
1070 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR], info->x_slp_packagecategories);
1071 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PACKAGEID_STR], info->x_slp_packageid);
1072 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_URI_STR], info->x_slp_uri);
1073 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_SVC_STR], info->x_slp_svc);
1074 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_EXE_PATH], info->x_slp_exe_path);
1075 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_APPID_STR], info->x_slp_appid);
1076 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PKGID_STR], info->x_slp_pkgid);
1077 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_DOMAIN_STR], info->x_slp_domain);
1078 SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_SUBMODEMAINID_STR], info->x_slp_submodemainid);
1080 info->x_slp_installedtime = atoi(values[E_AIL_PROP_X_SLP_INSTALLEDTIME_INT]);
1082 info->nodisplay = atoi(values[E_AIL_PROP_NODISPLAY_BOOL]);
1083 info->x_slp_taskmanage = atoi(values[E_AIL_PROP_X_SLP_TASKMANAGE_BOOL]);
1084 info->x_slp_multiple = atoi(values[E_AIL_PROP_X_SLP_MULTIPLE_BOOL]);
1085 info->x_slp_removable = atoi(values[E_AIL_PROP_X_SLP_REMOVABLE_BOOL]);
1086 info->x_slp_ishorizontalscale = atoi(values[E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL]);
1087 info->x_slp_enabled = atoi(values[E_AIL_PROP_X_SLP_ENABLED_BOOL]);
1088 info->x_slp_submode = atoi(values[E_AIL_PROP_X_SLP_SUBMODE_BOOL]);
1093 for (j = 0; j < i; ++j) {
1103 static ail_error_e _load_desktop_info(desktop_info_s* info)
1106 char query[AIL_SQL_QUERY_MAX_LEN];
1107 sqlite3_stmt *stmt = NULL;
1108 char w[AIL_SQL_QUERY_MAX_LEN];
1110 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1112 snprintf(w, sizeof(w), sql_get_filter(E_AIL_PROP_X_SLP_APPID_STR), info->package);
1114 snprintf(query, sizeof(query), "SELECT %s FROM %s WHERE %s",SQL_FLD_APP_INFO, SQL_TBL_APP_INFO, w);
1117 ret = db_open(DB_OPEN_RO);
1120 ret = db_prepare(query, &stmt);
1123 ret = db_step(stmt);
1129 ret = _retrieve_all_column_to_desktop_info(info, stmt);
1135 ret = db_finalize(stmt);
1138 return AIL_ERROR_OK;
1144 static ail_error_e _modify_desktop_info_bool(desktop_info_s* info,
1145 const char *property,
1148 ail_prop_bool_e prop;
1151 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1152 retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
1154 prop = _ail_convert_to_prop_bool(property);
1156 if (prop < E_AIL_PROP_BOOL_MIN || prop > E_AIL_PROP_BOOL_MAX)
1157 return AIL_ERROR_INVALID_PARAMETER;
1160 case E_AIL_PROP_X_SLP_ENABLED_BOOL:
1161 info->x_slp_enabled = (int)value;
1164 return AIL_ERROR_FAIL;
1167 return AIL_ERROR_OK;
1171 static ail_error_e _modify_desktop_info_str(desktop_info_s* info,
1172 const char *property,
1175 ail_prop_bool_e prop;
1178 retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
1179 retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
1181 prop = _ail_convert_to_prop_str(property);
1183 if (prop < E_AIL_PROP_STR_MIN || prop > E_AIL_PROP_STR_MAX)
1184 return AIL_ERROR_INVALID_PARAMETER;
1187 case E_AIL_PROP_NAME_STR:
1188 SAFE_FREE_AND_STRDUP(value, info->name);
1189 retv_if (!info->name, AIL_ERROR_OUT_OF_MEMORY);
1191 case E_AIL_PROP_X_SLP_SVC_STR:
1192 SAFE_FREE_AND_STRDUP(value, info->x_slp_svc);
1193 retv_if (!info->x_slp_svc, AIL_ERROR_OUT_OF_MEMORY);
1196 return AIL_ERROR_FAIL;
1199 return AIL_ERROR_OK;
1205 static ail_error_e _create_table(void)
1209 const char *tbls[3] = {
1210 "CREATE TABLE app_info "
1211 "(package TEXT PRIMARY KEY, "
1212 "exec TEXT DEFAULT 'No Exec', "
1213 "name TEXT DEFAULT 'No Name', "
1214 "type TEXT DEFAULT 'Application', "
1215 "icon TEXT DEFAULT 'No Icon', "
1219 "x_slp_service TEXT, "
1220 "x_slp_packagetype TEXT, "
1221 "x_slp_packagecategories TEXT, "
1222 "x_slp_packageid TEXT, "
1225 "x_slp_exe_path TEXT, "
1226 "x_slp_appid TEXT, "
1227 "x_slp_pkgid TEXT, "
1228 "x_slp_domain TEXT, "
1229 "x_slp_submodemainid TEXT, "
1230 "x_slp_baselayoutwidth INTEGER DEFAULT 0, "
1231 "x_slp_installedtime INTEGER DEFAULT 0, "
1232 "nodisplay INTEGER DEFAULT 0, "
1233 "x_slp_taskmanage INTEGER DEFAULT 1, "
1234 "x_slp_multiple INTEGER DEFAULT 0, "
1235 "x_slp_removable INTEGER DEFAULT 1, "
1236 "x_slp_ishorizontalscale INTEGER DEFAULT 0, "
1237 "x_slp_enabled INTEGER DEFAULT 1, "
1238 "x_slp_submode INTEGER DEFAULT 0, "
1239 "desktop TEXT UNIQUE NOT NULL);",
1240 "CREATE TABLE localname (package TEXT NOT NULL, "
1241 "locale TEXT NOT NULL, "
1242 "name TEXT NOT NULL, "
1243 "x_slp_pkgid TEXT NOT NULL, PRIMARY KEY (package, locale));",
1248 ret = db_open(DB_OPEN_RW);
1249 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
1251 for (i = 0; tbls[i] != NULL; i++) {
1252 ret = db_exec(tbls[i]);
1253 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
1256 return AIL_ERROR_OK;
1260 static inline void _insert_localname(gpointer data, gpointer user_data)
1264 struct name_item *item = (struct name_item *)data;
1265 desktop_info_s *info = (desktop_info_s *)user_data;
1267 sqlite3_snprintf(sizeof(query), query, "insert into localname (package, locale, name, x_slp_pkgid) "
1268 "values ('%q', '%q', '%q', '%q');",
1269 info->package, item->locale, item->name, info->x_slp_pkgid);
1270 if (db_exec(query) < 0)
1271 _E("Failed to insert local name of package[%s]",info->package);
1274 static ail_error_e _insert_desktop_info(desktop_info_s *info)
1280 len = _strlen_desktop_info(info) + (0x01 << 10);
1281 query = calloc(1, len);
1282 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1284 sqlite3_snprintf(len, query, "insert into app_info ("
1293 "x_slp_packagetype, "
1294 "x_slp_packagecategories, "
1302 "x_slp_submodemainid, "
1303 "x_slp_baselayoutwidth, "
1304 "x_slp_installedtime, "
1306 "x_slp_taskmanage, "
1309 "x_slp_ishorizontalscale, "
1314 "('%q', '%q', '%q', '%q', '%q', "
1315 "'%q', '%q', '%q', '%q', '%q', "
1316 "'%q', '%q', '%q', '%q', '%q', "
1317 "'%q', '%q', '%q', '%q',"
1318 "%d, %d, %d, %d, %d, %d, %d,"
1329 info->x_slp_service,
1330 info->x_slp_packagetype,
1331 info->x_slp_packagecategories,
1332 info->x_slp_packageid,
1335 info->x_slp_exe_path,
1339 info->x_slp_submodemainid,
1340 info->x_slp_baselayoutwidth,
1341 info->x_slp_installedtime,
1343 info->x_slp_taskmanage,
1344 info->x_slp_multiple,
1345 info->x_slp_removable,
1346 info->x_slp_ishorizontalscale,
1347 info->x_slp_enabled,
1348 info->x_slp_submode,
1352 ret = db_open(DB_OPEN_RW);
1353 if(ret != AIL_ERROR_OK) {
1354 _E("(tmp == NULL) return\n");
1356 return AIL_ERROR_DB_FAILED;
1359 ret = db_exec(query);
1361 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
1363 if (info->localname)
1364 _insert_local_info(info);
1366 _D("Add (%s).", info->package);
1368 return AIL_ERROR_OK;
1373 static ail_error_e _update_desktop_info(desktop_info_s *info)
1378 retv_if (NULL == info, AIL_ERROR_INVALID_PARAMETER);
1380 if (db_open(DB_OPEN_RW) < 0) {
1381 return AIL_ERROR_DB_FAILED;
1384 len = _strlen_desktop_info(info) + (0x01 << 10);
1385 query = calloc(1, len);
1386 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1388 sqlite3_snprintf ( len, query, "update app_info set "
1396 "x_slp_service='%q', "
1397 "x_slp_packagetype='%q', "
1398 "x_slp_packagecategories='%q', "
1399 "x_slp_packageid='%q', "
1402 "x_slp_exe_path='%q', "
1403 "x_slp_appid='%q', "
1404 "x_slp_pkgid='%q', "
1405 "x_slp_domain='%q', "
1406 "x_slp_submodemainid='%q', "
1407 "x_slp_baselayoutwidth=%d, "
1408 "x_slp_installedtime=%d, "
1410 "x_slp_taskmanage=%d, "
1411 "x_slp_multiple=%d, "
1412 "x_slp_removable=%d, "
1413 "x_slp_ishorizontalscale=%d, "
1414 "x_slp_enabled=%d, "
1415 "x_slp_submode=%d, "
1417 "where package='%q'",
1425 info->x_slp_service,
1426 info->x_slp_packagetype,
1427 info->x_slp_packagecategories,
1428 info->x_slp_packageid,
1431 info->x_slp_exe_path,
1435 info->x_slp_submodemainid,
1436 info->x_slp_baselayoutwidth,
1437 info->x_slp_installedtime,
1439 info->x_slp_taskmanage,
1440 info->x_slp_multiple,
1441 info->x_slp_removable,
1442 info->x_slp_ishorizontalscale,
1443 info->x_slp_enabled,
1444 info->x_slp_submode,
1448 if (db_exec(query) < 0) {
1450 return AIL_ERROR_DB_FAILED;
1453 snprintf(query, len, "delete from localname where package = '%s'", info->package);
1455 if (db_exec(query) < 0) {
1457 return AIL_ERROR_DB_FAILED;
1460 if (info->localname)
1461 _insert_local_info(info);
1463 _D("Update (%s).", info->package);
1467 return AIL_ERROR_OK;
1472 static ail_error_e _remove_package(const char* package)
1477 retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
1479 if (db_open(DB_OPEN_RW) < 0) {
1480 return AIL_ERROR_DB_FAILED;
1483 size = strlen(package) + (0x01 << 10);
1484 query = calloc(1, size);
1485 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1487 snprintf(query, size, "delete from app_info where package = '%s'", package);
1489 if (db_exec(query) < 0) {
1491 return AIL_ERROR_DB_FAILED;
1494 snprintf(query, size, "delete from localname where package = '%s'", package);
1495 _D("query=%s",query);
1497 if (db_exec(query) < 0) {
1499 return AIL_ERROR_DB_FAILED;
1502 _D("Remove (%s).", package);
1505 return AIL_ERROR_OK;
1508 static ail_error_e _clean_pkgid_data(const char* pkgid)
1513 retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
1515 if (db_open(DB_OPEN_RW) < 0) {
1516 return AIL_ERROR_DB_FAILED;
1519 size = strlen(pkgid) + (0x01 << 10);
1520 query = calloc(1, size);
1521 retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
1523 snprintf(query, size, "delete from app_info where x_slp_pkgid = '%s'", pkgid);
1525 if (db_exec(query) < 0) {
1527 return AIL_ERROR_DB_FAILED;
1530 snprintf(query, size, "delete from localname where x_slp_pkgid = '%s'", pkgid);
1531 _D("query=%s",query);
1533 if (db_exec(query) < 0) {
1535 return AIL_ERROR_DB_FAILED;
1538 _D("Clean pkgid data (%s).", pkgid);
1541 return AIL_ERROR_OK;
1545 static ail_error_e _send_db_done_noti(noti_type type, const char *package)
1547 char *type_string, *noti_string;
1550 retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
1554 type_string = "create";
1557 type_string = "update";
1560 type_string = "delete";
1563 return AIL_ERROR_FAIL;
1566 size = strlen(package) + 8;
1567 noti_string = calloc(1, size);
1568 retv_if(!noti_string, AIL_ERROR_OUT_OF_MEMORY);
1570 snprintf(noti_string, size, "%s:%s", type_string, package);
1571 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
1572 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
1573 _D("Noti : %s", noti_string);
1577 return AIL_ERROR_OK;
1581 static void inline _name_item_free_func(gpointer data)
1583 struct name_item *item = (struct name_item *)data;
1585 SAFE_FREE(item->locale);
1586 item->locale = NULL;
1587 SAFE_FREE(item->name);
1593 static void _fini_desktop_info(desktop_info_s *info)
1595 SAFE_FREE(info->exec);
1596 SAFE_FREE(info->name);
1597 SAFE_FREE(info->type);
1598 SAFE_FREE(info->icon);
1599 SAFE_FREE(info->categories);
1600 SAFE_FREE(info->version);
1601 SAFE_FREE(info->mimetype);
1602 SAFE_FREE(info->x_slp_service);
1603 SAFE_FREE(info->x_slp_packagetype);
1604 SAFE_FREE(info->x_slp_packagecategories);
1605 SAFE_FREE(info->x_slp_packageid);
1606 SAFE_FREE(info->x_slp_uri);
1607 SAFE_FREE(info->x_slp_svc);
1608 SAFE_FREE(info->x_slp_exe_path);
1609 SAFE_FREE(info->x_slp_appid);
1610 SAFE_FREE(info->x_slp_pkgid);
1611 SAFE_FREE(info->x_slp_domain);
1612 SAFE_FREE(info->x_slp_submodemainid);
1613 SAFE_FREE(info->desktop);
1614 if (info->localname) {
1615 g_slist_free_full(info->localname, _name_item_free_func);
1616 info->localname = NULL;
1622 static int __is_authorized()
1624 uid_t uid = getuid();
1625 if ((uid_t) 0 == uid )
1632 /* Public functions */
1633 EXPORT_API ail_error_e ail_desktop_add(const char *appid)
1635 desktop_info_s info = {0,};
1639 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1640 if (!__is_authorized()) {
1641 _E("You are not an authorized user on adding!\n");
1645 count = _count_all();
1647 ret = _create_table();
1648 if (ret != AIL_ERROR_OK) {
1649 _D("Cannot create a table. Maybe there is already a table.");
1653 ret = _init_desktop_info(&info, appid);
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);
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;
1672 EXPORT_API ail_error_e ail_desktop_update(const char *appid)
1674 desktop_info_s info = {0,};
1677 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1678 if (!__is_authorized()) {
1679 _E("You are not an authorized user on updating!\n");
1683 ret = _init_desktop_info(&info, appid);
1684 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1686 ret = _read_desktop_info(&info);
1687 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1689 ret = _update_desktop_info(&info);
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;
1702 EXPORT_API ail_error_e ail_desktop_remove(const char *appid)
1706 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1707 if (!__is_authorized()) {
1708 _E("You are not an authorized user on removing!\n");
1712 ret = _remove_package(appid);
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_clean(const char *pkgid)
1725 retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
1726 if (!__is_authorized()) {
1727 _E("You are not an authorized user on removing!\n");
1731 _D("ail_desktop_clean=%s",pkgid);
1733 ret = _clean_pkgid_data(pkgid);
1734 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1736 return AIL_ERROR_OK;
1740 EXPORT_API ail_error_e ail_desktop_fota(const char *appid)
1742 desktop_info_s info = {0,};
1746 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1747 if (!__is_authorized()) {
1748 _E("You are not an authorized user on adding!\n");
1752 count = _count_all();
1754 ret = _create_table();
1755 if (ret != AIL_ERROR_OK) {
1756 _D("Cannot create a table. Maybe there is already a table.");
1760 ret = _init_desktop_info(&info, appid);
1761 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1763 ret = _read_desktop_info(&info);
1764 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1766 ret = _insert_desktop_info(&info);
1767 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1769 _fini_desktop_info(&info);
1771 return AIL_ERROR_OK;
1774 EXPORT_API ail_error_e ail_desktop_appinfo_modify_bool(const char *appid,
1775 const char *property,
1779 desktop_info_s info = {0,};
1782 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1784 retv_if(strcmp(property, AIL_PROP_X_SLP_ENABLED_BOOL),
1785 AIL_ERROR_INVALID_PARAMETER);
1787 ret = _init_desktop_info(&info, appid);
1788 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1790 ret = _load_desktop_info(&info);
1791 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1793 ret = _modify_desktop_info_bool(&info, property, value);
1794 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1796 ret = _update_desktop_info(&info);
1797 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1800 ret = _send_db_done_noti(NOTI_UPDATE, appid);
1801 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1804 _fini_desktop_info(&info);
1806 return AIL_ERROR_OK;
1810 EXPORT_API ail_error_e ail_desktop_appinfo_modify_str(const char *appid,
1811 const char *property,
1815 desktop_info_s info = {0,};
1818 retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
1820 ret = _init_desktop_info(&info, appid);
1821 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1823 ret = _load_desktop_info(&info);
1824 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1826 _D("info.name [%s], value [%s]", info.name, value);
1827 ret = _modify_desktop_info_str(&info, property, value);
1828 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1829 _D("info.name [%s], value [%s]", info.name, value);
1831 ret = _update_desktop_info(&info);
1832 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1835 ret = _send_db_done_noti(NOTI_UPDATE, appid);
1836 retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
1839 _fini_desktop_info(&info);
1841 return AIL_ERROR_OK;