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>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
35 #include <libxml/parser.h>
36 #include <libxml/xmlreader.h>
37 #include <libxml/xmlschemas.h>
39 #include <dbus/dbus.h>
40 #include <dbus/dbus-glib-lowlevel.h>
42 #include "pkgmgr_parser.h"
43 #include "pkgmgr-info-internal.h"
44 #include "pkgmgr-info-debug.h"
45 #include "pkgmgr-info.h"
46 #include "pkgmgr_parser_db.h"
53 #define LOG_TAG "PKGMGR_INFO"
55 #define ASC_CHAR(s) (const char *)s
56 #define XML_CHAR(s) (const xmlChar *)s
58 #define MANIFEST_DB "/opt/dbspace/.pkgmgr_parser.db"
59 #define MAX_QUERY_LEN 4096
60 #define MAX_CERT_TYPE 9
61 #define CERT_DB "/opt/dbspace/.pkgmgr_cert.db"
62 #define DATACONTROL_DB "/opt/usr/dbspace/.app-package.db"
63 #define PKG_TYPE_STRING_LEN_MAX 128
64 #define PKG_VERSION_STRING_LEN_MAX 128
65 #define PKG_VALUE_STRING_LEN_MAX 512
66 #define PKG_LOCALE_STRING_LEN_MAX 8
67 #define PKG_RW_PATH "/opt/usr/apps/"
68 #define PKG_RO_PATH "/usr/apps/"
69 #define BLOCK_SIZE 4096 /*in bytes*/
71 #define MMC_PATH "/opt/storage/sdcard"
72 #define PKG_SD_PATH MMC_PATH"/app2sd/"
73 #define PKG_INSTALLATION_PATH "/opt/usr/apps/"
75 #define FILTER_QUERY_COUNT_PACKAGE "select count(DISTINCT package_info.package) " \
76 "from package_info LEFT OUTER JOIN package_localized_info " \
77 "ON package_info.package=package_localized_info.package " \
78 "and package_localized_info.package_locale='%s' where "
80 #define FILTER_QUERY_LIST_PACKAGE "select DISTINCT package_info.package " \
81 "from package_info LEFT OUTER JOIN package_localized_info " \
82 "ON package_info.package=package_localized_info.package " \
83 "and package_localized_info.package_locale='%s' where "
85 #define FILTER_QUERY_COUNT_APP "select count(DISTINCT package_app_info.app_id) " \
86 "from package_app_info LEFT OUTER JOIN package_app_localized_info " \
87 "ON package_app_info.app_id=package_app_localized_info.app_id " \
88 "and package_app_localized_info.app_locale='%s' " \
89 "LEFT OUTER JOIN package_app_app_svc " \
90 "ON package_app_info.app_id=package_app_app_svc.app_id " \
91 "LEFT OUTER JOIN package_app_app_category " \
92 "ON package_app_info.app_id=package_app_app_category.app_id where "
94 #define FILTER_QUERY_LIST_APP "select DISTINCT package_app_info.app_id, package_app_info.app_component " \
95 "from package_app_info LEFT OUTER JOIN package_app_localized_info " \
96 "ON package_app_info.app_id=package_app_localized_info.app_id " \
97 "and package_app_localized_info.app_locale='%s' " \
98 "LEFT OUTER JOIN package_app_app_svc " \
99 "ON package_app_info.app_id=package_app_app_svc.app_id " \
100 "LEFT OUTER JOIN package_app_app_category " \
101 "ON package_app_info.app_id=package_app_app_category.app_id where "
103 #define METADATA_FILTER_QUERY_SELECT_CLAUSE "select DISTINCT package_app_info.app_id, package_app_info.app_component " \
104 "from package_app_info LEFT OUTER JOIN package_app_app_metadata " \
105 "ON package_app_info.app_id=package_app_app_metadata.app_id where "
107 #define METADATA_FILTER_QUERY_UNION_CLAUSE " UNION "METADATA_FILTER_QUERY_SELECT_CLAUSE
109 #define LANGUAGE_LENGTH 2
110 #define LIBAIL_PATH "/usr/lib/libail.so.0"
112 #define SERVICE_NAME "org.tizen.system.deviced"
113 #define PATH_NAME "/Org/Tizen/System/DeviceD/Mmc"
114 #define INTERFACE_NAME "org.tizen.system.deviced.Mmc"
115 #define METHOD_NAME "RequestMountApp2ext"
117 typedef struct _pkgmgr_instcertinfo_x {
119 char *cert_info[MAX_CERT_TYPE]; /*certificate data*/
120 int is_new[MAX_CERT_TYPE]; /*whether already exist in table or not*/
121 int ref_count[MAX_CERT_TYPE]; /*reference count of certificate data*/
122 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
123 } pkgmgr_instcertinfo_x;
125 typedef struct _pkgmgr_certindexinfo_x {
128 } pkgmgr_certindexinfo_x;
130 typedef struct _pkgmgr_pkginfo_x {
131 manifest_x *manifest_info;
134 struct _pkgmgr_pkginfo_x *prev;
135 struct _pkgmgr_pkginfo_x *next;
138 typedef struct _pkgmgr_cert_x {
143 typedef struct _pkgmgr_datacontrol_x {
146 } pkgmgr_datacontrol_x;
148 typedef struct _pkgmgr_iconpath_x {
153 typedef struct _pkgmgr_image_x {
157 typedef struct _pkgmgr_locale_x {
161 typedef struct _pkgmgr_appinfo_x {
164 pkgmgrinfo_app_component app_component;
166 uiapplication_x *uiapp_info;
167 serviceapplication_x *svcapp_info;
171 typedef struct _pkgmgr_certinfo_x {
174 char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
175 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
179 typedef struct _pkgmgrinfo_filter_x {
181 } pkgmgrinfo_filter_x;
183 typedef struct _pkgmgrinfo_node_x {
189 typedef struct _pkgmgrinfo_appcontrol_x {
198 } pkgmgrinfo_appcontrol_x;
200 typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
202 typedef int (*pkgmgr_handler)(int req_id, const char *pkg_type,
203 const char *pkgid, const char *key,
204 const char *val, const void *pmsg, void *data);
206 typedef void pkgmgr_client;
207 typedef void pkgmgr_info;
212 PM_REQUEST_GET_SIZE = 2,
213 PM_REQUEST_KILL_APP = 3,
214 PM_REQUEST_CHECK_APP = 4,
216 }pkgmgr_request_service_type;
219 PM_GET_TOTAL_SIZE= 0,
220 PM_GET_DATA_SIZE = 1,
222 PM_GET_SIZE_INFO = 3,
223 PM_GET_TOTAL_AND_DATA = 4,
225 }pkgmgr_getsize_type;
233 #define PKG_SIZE_INFO_FILE "/tmp/pkgmgr_size_info.txt"
234 #define MAX_PKG_BUF_LEN 1024
235 #define MAX_PKG_INFO_LEN 10
237 char *pkgtype = "rpm";
239 __thread sqlite3 *cert_db = NULL;
241 static int __exec_certinfo_query(char *query, void *data);
242 static int __exec_certindexinfo_query(char *query, void *data);
243 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname);
244 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname);
245 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname);
246 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname);
247 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname);
248 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname);
249 static int __count_cb(void *data, int ncols, char **coltxt, char **colname);
250 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
251 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
252 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname);
253 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname);
254 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data);
255 static void __cleanup_appinfo(pkgmgr_appinfo_x *data);
256 static char* __convert_system_locale_to_manifest_locale(char *syslocale);
257 static void __destroy_each_node(gpointer data, gpointer user_data);
258 static void __get_filter_condition(gpointer data, char **condition);
259 static void __get_metadata_filter_condition(gpointer data, char **condition);
260 static gint __compare_func(gconstpointer data1, gconstpointer data2);
261 static int __delete_certinfo(const char *pkgid);
263 static gint __compare_func(gconstpointer data1, gconstpointer data2)
265 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
266 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
267 if (node1->prop == node2->prop)
269 else if (node1->prop > node2->prop)
275 static int __count_cb(void *data, int ncols, char **coltxt, char **colname)
278 *p = atoi(coltxt[0]);
279 _LOGE("count value is %d\n", *p);
283 static void __destroy_each_node(gpointer data, gpointer user_data)
285 ret_if(data == NULL);
286 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
299 static void __get_metadata_filter_condition(gpointer data, char **condition)
301 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
302 char key[MAX_QUERY_LEN] = {'\0'};
303 char value[MAX_QUERY_LEN] = {'\0'};
305 snprintf(key, MAX_QUERY_LEN, "(package_app_app_metadata.md_key='%s'", node->key);
308 snprintf(value, MAX_QUERY_LEN, " AND package_app_app_metadata.md_value='%s')", node->value);
313 *condition = strdup(key);
317 static void __get_filter_condition(gpointer data, char **condition)
319 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
320 char buf[MAX_QUERY_LEN + 1] = {'\0'};
321 char temp[PKG_STRING_LEN_MAX] = {'\0'};
322 switch (node->prop) {
323 case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
324 snprintf(buf, MAX_QUERY_LEN, "package_info.package='%s'", node->value);
326 case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
327 snprintf(buf, MAX_QUERY_LEN, "package_info.package_type='%s'", node->value);
329 case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
330 snprintf(buf, MAX_QUERY_LEN, "package_info.package_version='%s'", node->value);
332 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
333 snprintf(buf, MAX_QUERY_LEN, "package_info.install_location='%s'", node->value);
335 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
336 snprintf(buf, MAX_QUERY_LEN, "package_info.installed_storage='%s'", node->value);
338 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
339 snprintf(buf, MAX_QUERY_LEN, "package_info.author_name='%s'", node->value);
341 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
342 snprintf(buf, MAX_QUERY_LEN, "package_info.author_href='%s'", node->value);
344 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
345 snprintf(buf, MAX_QUERY_LEN, "package_info.author_email='%s'", node->value);
347 case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
348 snprintf(buf, MAX_QUERY_LEN, "package_info.package_size='%s'", node->value);
350 case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
351 snprintf(buf, MAX_QUERY_LEN, "package_info.package_removable IN %s", node->value);
353 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
354 snprintf(buf, MAX_QUERY_LEN, "package_info.package_preload IN %s", node->value);
356 case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
357 snprintf(buf, MAX_QUERY_LEN, "package_info.package_readonly IN %s", node->value);
359 case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
360 snprintf(buf, MAX_QUERY_LEN, "package_info.package_update IN %s", node->value);
362 case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
363 snprintf(buf, MAX_QUERY_LEN, "package_info.package_appsetting IN %s", node->value);
365 case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
366 snprintf(buf, MAX_QUERY_LEN, "package_info.package_nodisplay IN %s", node->value);
369 case E_PMINFO_APPINFO_PROP_APP_ID:
370 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_id='%s'", node->value);
372 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
373 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_component='%s'", node->value);
375 case E_PMINFO_APPINFO_PROP_APP_EXEC:
376 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_exec='%s'", node->value);
378 case E_PMINFO_APPINFO_PROP_APP_ICON:
379 snprintf(buf, MAX_QUERY_LEN, "package_app_localized_info.app_icon='%s'", node->value);
381 case E_PMINFO_APPINFO_PROP_APP_TYPE:
382 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_type='%s'", node->value);
384 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
385 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
386 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.operation IN %s", temp);
388 case E_PMINFO_APPINFO_PROP_APP_URI:
389 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
390 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.uri_scheme IN %s", temp);
392 case E_PMINFO_APPINFO_PROP_APP_MIME:
393 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
394 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.mime_type IN %s", temp);
396 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
397 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
398 snprintf(buf, MAX_QUERY_LEN, "package_app_app_category.category IN %s", temp);
400 case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
401 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_nodisplay IN %s", node->value);
403 case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
404 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_multiple IN %s", node->value);
406 case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
407 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_onboot IN %s", node->value);
409 case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
410 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_autorestart IN %s", node->value);
412 case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
413 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_taskmanage IN %s", node->value);
415 case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
416 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_hwacceleration='%s'", node->value);
418 case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
419 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_screenreader='%s'", node->value);
421 case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
422 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
425 _LOGE("Invalid Property Type\n");
429 *condition = strdup(buf);
433 static char* __convert_system_locale_to_manifest_locale(char *syslocale)
435 if (syslocale == NULL)
436 return strdup(DEFAULT_LOCALE);
438 locale = (char *)calloc(1, 6);
439 retvm_if(!locale, NULL, "Malloc Failed\n");
441 strncpy(locale, syslocale, 2);
442 strncat(locale, "-", 1);
443 locale[3] = syslocale[3] + 32;
444 locale[4] = syslocale[4] + 32;
448 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
450 ret_if(data == NULL);
452 free((void *)data->locale);
456 pkgmgr_parser_free_manifest_xml(data->manifest_info);
462 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
464 ret_if(data == NULL);
466 free((void *)data->package);
467 data->package = NULL;
470 free((void *)data->locale);
474 manifest_x *mfx = calloc(1, sizeof(manifest_x));
475 if (data->app_component == PMINFO_UI_APP)
476 mfx->uiapplication = data->uiapp_info;
477 else if (data->app_component == PMINFO_SVC_APP)
478 mfx->serviceapplication = data->svcapp_info;
479 pkgmgr_parser_free_manifest_xml(mfx);
485 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
487 pkgmgr_pkginfo_x *udata = (pkgmgr_pkginfo_x *)data;
489 pkgmgr_pkginfo_x *info = NULL;
490 info = calloc(1, sizeof(pkgmgr_pkginfo_x));
491 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
493 LISTADD(udata, info);
494 for(i = 0; i < ncols; i++)
496 if (strcmp(colname[i], "package") == 0) {
498 info->manifest_info->package = strdup(coltxt[i]);
500 info->manifest_info->package = NULL;
508 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname)
510 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
513 uiapplication_x *uiapp = NULL;
514 serviceapplication_x *svcapp = NULL;
515 for(i = 0; i < ncols; i++)
517 if ((strcmp(colname[i], "app_component") == 0) ||
518 (strcmp(colname[i], "package_app_info.app_component") == 0)) {
520 if (strcmp(coltxt[i], "uiapp") == 0) {
521 uiapp = calloc(1, sizeof(uiapplication_x));
523 _LOGE("Out of Memory!!!\n");
526 LISTADD(info->manifest_info->uiapplication, uiapp);
527 for(j = 0; j < ncols; j++)
529 if ((strcmp(colname[j], "app_id") == 0) ||
530 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
532 info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
533 } else if (strcmp(colname[j], "package") == 0) {
535 info->manifest_info->uiapplication->package = strdup(coltxt[j]);
540 svcapp = calloc(1, sizeof(serviceapplication_x));
541 if (svcapp == NULL) {
542 _LOGE("Out of Memory!!!\n");
545 LISTADD(info->manifest_info->serviceapplication, svcapp);
546 for(j = 0; j < ncols; j++)
548 if ((strcmp(colname[j], "app_id") == 0) ||
549 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
551 info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
552 } else if (strcmp(colname[j], "package") == 0) {
554 info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
568 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
570 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
572 uiapplication_x *uiapp = NULL;
574 label_x *label = NULL;
576 uiapp = calloc(1, sizeof(uiapplication_x));
577 LISTADD(info->manifest_info->uiapplication, uiapp);
578 icon = calloc(1, sizeof(icon_x));
579 LISTADD(info->manifest_info->uiapplication->icon, icon);
580 label = calloc(1, sizeof(label_x));
581 LISTADD(info->manifest_info->uiapplication->label, label);
583 for(i = 0; i < ncols; i++)
585 if (strcmp(colname[i], "app_id") == 0) {
587 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
589 info->manifest_info->uiapplication->appid = NULL;
590 } else if (strcmp(colname[i], "app_exec") == 0) {
592 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
594 info->manifest_info->uiapplication->exec = NULL;
595 } else if (strcmp(colname[i], "app_type") == 0 ){
597 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
599 info->manifest_info->uiapplication->type = NULL;
600 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
602 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
604 info->manifest_info->uiapplication->nodisplay = NULL;
605 } else if (strcmp(colname[i], "app_multiple") == 0 ){
607 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
609 info->manifest_info->uiapplication->multiple = NULL;
610 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
612 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
614 info->manifest_info->uiapplication->taskmanage = NULL;
615 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
617 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
619 info->manifest_info->uiapplication->hwacceleration = NULL;
620 } else if (strcmp(colname[i], "app_screenreader") == 0 ){
622 info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
624 info->manifest_info->uiapplication->screenreader = NULL;
625 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
627 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
629 info->manifest_info->uiapplication->indicatordisplay = NULL;
630 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
632 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
634 info->manifest_info->uiapplication->portraitimg = NULL;
635 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
637 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
639 info->manifest_info->uiapplication->landscapeimg = NULL;
640 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
642 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
644 info->manifest_info->uiapplication->guestmode_visibility = NULL;
645 } else if (strcmp(colname[i], "package") == 0 ){
647 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
649 info->manifest_info->uiapplication->package = NULL;
650 } else if (strcmp(colname[i], "app_icon") == 0) {
652 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
654 info->manifest_info->uiapplication->icon->text = NULL;
655 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
657 info->manifest_info->uiapplication->enabled= strdup(coltxt[i]);
659 info->manifest_info->uiapplication->enabled = NULL;
660 } else if (strcmp(colname[i], "app_label") == 0 ) {
662 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
664 info->manifest_info->uiapplication->label->text = NULL;
665 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
667 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
669 info->manifest_info->uiapplication->recentimage = NULL;
670 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
672 info->manifest_info->uiapplication->mainapp = strdup(coltxt[i]);
674 info->manifest_info->uiapplication->mainapp = NULL;
675 } else if (strcmp(colname[i], "app_locale") == 0 ) {
677 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
678 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
681 info->manifest_info->uiapplication->icon->lang = NULL;
682 info->manifest_info->uiapplication->label->lang = NULL;
684 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
686 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
688 info->manifest_info->uiapplication->permission_type = NULL;
689 } else if (strcmp(colname[i], "component_type") == 0 ) {
691 info->manifest_info->uiapplication->component_type = strdup(coltxt[i]);
693 info->manifest_info->uiapplication->component_type = NULL;
694 } else if (strcmp(colname[i], "app_preload") == 0 ) {
696 info->manifest_info->uiapplication->preload = strdup(coltxt[i]);
698 info->manifest_info->uiapplication->preload = NULL;
699 } else if (strcmp(colname[i], "app_submode") == 0 ) {
701 info->manifest_info->uiapplication->submode = strdup(coltxt[i]);
703 info->manifest_info->uiapplication->submode = NULL;
704 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
706 info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[i]);
708 info->manifest_info->uiapplication->submode_mainid = NULL;
709 } else if (strcmp(colname[i], "app_installed_storage") == 0 ) {
711 info->manifest_info->uiapplication->installed_storage = strdup(coltxt[i]);
713 info->manifest_info->uiapplication->installed_storage = NULL;
720 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
722 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
724 serviceapplication_x *svcapp = NULL;
726 label_x *label = NULL;
728 svcapp = calloc(1, sizeof(serviceapplication_x));
729 LISTADD(info->manifest_info->serviceapplication, svcapp);
730 icon = calloc(1, sizeof(icon_x));
731 LISTADD(info->manifest_info->serviceapplication->icon, icon);
732 label = calloc(1, sizeof(label_x));
733 LISTADD(info->manifest_info->serviceapplication->label, label);
734 for(i = 0; i < ncols; i++)
736 if (strcmp(colname[i], "app_id") == 0) {
738 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
740 info->manifest_info->serviceapplication->appid = NULL;
741 } else if (strcmp(colname[i], "app_exec") == 0) {
743 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
745 info->manifest_info->serviceapplication->exec = NULL;
746 } else if (strcmp(colname[i], "app_type") == 0 ){
748 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
750 info->manifest_info->serviceapplication->type = NULL;
751 } else if (strcmp(colname[i], "app_onboot") == 0 ){
753 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
755 info->manifest_info->serviceapplication->onboot = NULL;
756 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
758 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
760 info->manifest_info->serviceapplication->autorestart = NULL;
761 } else if (strcmp(colname[i], "package") == 0 ){
763 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
765 info->manifest_info->serviceapplication->package = NULL;
766 } else if (strcmp(colname[i], "app_icon") == 0) {
768 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
770 info->manifest_info->serviceapplication->icon->text = NULL;
771 } else if (strcmp(colname[i], "app_label") == 0 ) {
773 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
775 info->manifest_info->serviceapplication->label->text = NULL;
776 } else if (strcmp(colname[i], "app_locale") == 0 ) {
778 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
779 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
782 info->manifest_info->serviceapplication->icon->lang = NULL;
783 info->manifest_info->serviceapplication->label->lang = NULL;
785 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
787 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
789 info->manifest_info->serviceapplication->permission_type = NULL;
796 static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
798 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
801 uiapplication_x *uiapp = NULL;
802 serviceapplication_x *svcapp = NULL;
803 for(j = 0; j < ncols; j++)
805 if (strcmp(colname[j], "app_component") == 0) {
807 if (strcmp(coltxt[j], "uiapp") == 0) {
808 uiapp = calloc(1, sizeof(uiapplication_x));
810 _LOGE("Out of Memory!!!\n");
813 LISTADD(info->manifest_info->uiapplication, uiapp);
814 for(i = 0; i < ncols; i++)
816 if (strcmp(colname[i], "app_id") == 0) {
818 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
820 info->manifest_info->uiapplication->appid = NULL;
821 } else if (strcmp(colname[i], "app_exec") == 0) {
823 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
825 info->manifest_info->uiapplication->exec = NULL;
826 } else if (strcmp(colname[i], "app_type") == 0 ){
828 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
830 info->manifest_info->uiapplication->type = NULL;
831 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
833 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
835 info->manifest_info->uiapplication->nodisplay = NULL;
836 } else if (strcmp(colname[i], "app_multiple") == 0 ){
838 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
840 info->manifest_info->uiapplication->multiple = NULL;
841 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
843 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
845 info->manifest_info->uiapplication->taskmanage = NULL;
846 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
848 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
850 info->manifest_info->uiapplication->hwacceleration = NULL;
851 } else if (strcmp(colname[i], "app_screenreader") == 0 ){
853 info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
855 info->manifest_info->uiapplication->screenreader = NULL;
856 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
858 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
860 info->manifest_info->uiapplication->indicatordisplay = NULL;
861 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
863 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
865 info->manifest_info->uiapplication->portraitimg = NULL;
866 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
868 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
870 info->manifest_info->uiapplication->landscapeimg = NULL;
871 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
873 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
875 info->manifest_info->uiapplication->guestmode_visibility = NULL;
876 } else if (strcmp(colname[i], "package") == 0 ){
878 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
880 info->manifest_info->uiapplication->package = NULL;
881 } else if (strcmp(colname[i], "app_icon") == 0) {
883 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
885 info->manifest_info->uiapplication->icon->text = NULL;
886 } else if (strcmp(colname[i], "app_label") == 0 ) {
888 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
890 info->manifest_info->uiapplication->label->text = NULL;
891 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
893 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
895 info->manifest_info->uiapplication->recentimage = NULL;
896 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
898 info->manifest_info->uiapplication->mainapp= strdup(coltxt[i]);
900 info->manifest_info->uiapplication->mainapp = NULL;
901 } else if (strcmp(colname[i], "app_locale") == 0 ) {
903 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
904 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
907 info->manifest_info->uiapplication->icon->lang = NULL;
908 info->manifest_info->uiapplication->label->lang = NULL;
910 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
912 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
914 info->manifest_info->uiapplication->permission_type = NULL;
919 svcapp = calloc(1, sizeof(serviceapplication_x));
920 if (svcapp == NULL) {
921 _LOGE("Out of Memory!!!\n");
924 LISTADD(info->manifest_info->serviceapplication, svcapp);
925 for(i = 0; i < ncols; i++)
927 if (strcmp(colname[i], "app_id") == 0) {
929 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
931 info->manifest_info->serviceapplication->appid = NULL;
932 } else if (strcmp(colname[i], "app_exec") == 0) {
934 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
936 info->manifest_info->serviceapplication->exec = NULL;
937 } else if (strcmp(colname[i], "app_type") == 0 ){
939 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
941 info->manifest_info->serviceapplication->type = NULL;
942 } else if (strcmp(colname[i], "app_onboot") == 0 ){
944 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
946 info->manifest_info->serviceapplication->onboot = NULL;
947 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
949 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
951 info->manifest_info->serviceapplication->autorestart = NULL;
952 } else if (strcmp(colname[i], "package") == 0 ){
954 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
956 info->manifest_info->serviceapplication->package = NULL;
957 } else if (strcmp(colname[i], "app_icon") == 0) {
959 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
961 info->manifest_info->serviceapplication->icon->text = NULL;
962 } else if (strcmp(colname[i], "app_label") == 0 ) {
964 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
966 info->manifest_info->serviceapplication->label->text = NULL;
967 } else if (strcmp(colname[i], "app_locale") == 0 ) {
969 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
970 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
973 info->manifest_info->serviceapplication->icon->lang = NULL;
974 info->manifest_info->serviceapplication->label->lang = NULL;
976 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
978 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
980 info->manifest_info->serviceapplication->permission_type = NULL;
995 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname)
998 *p = atoi(coltxt[0]);
1002 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname)
1004 int *p = (int*)data;
1006 *p = atoi(coltxt[0]);
1010 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
1012 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
1014 author_x *author = NULL;
1015 icon_x *icon = NULL;
1016 label_x *label = NULL;
1017 description_x *description = NULL;
1018 privilege_x *privilege = NULL;
1020 author = calloc(1, sizeof(author_x));
1021 LISTADD(info->manifest_info->author, author);
1022 icon = calloc(1, sizeof(icon_x));
1023 LISTADD(info->manifest_info->icon, icon);
1024 label = calloc(1, sizeof(label_x));
1025 LISTADD(info->manifest_info->label, label);
1026 description = calloc(1, sizeof(description_x));
1027 LISTADD(info->manifest_info->description, description);
1028 privilege = calloc(1, sizeof(privilege_x));
1029 LISTADD(info->manifest_info->privileges->privilege, privilege);
1030 for(i = 0; i < ncols; i++)
1032 if (strcmp(colname[i], "package_version") == 0) {
1034 info->manifest_info->version = strdup(coltxt[i]);
1036 info->manifest_info->version = NULL;
1037 } else if (strcmp(colname[i], "package_type") == 0) {
1039 info->manifest_info->type = strdup(coltxt[i]);
1041 info->manifest_info->type = NULL;
1042 } else if (strcmp(colname[i], "install_location") == 0) {
1044 info->manifest_info->installlocation = strdup(coltxt[i]);
1046 info->manifest_info->installlocation = NULL;
1047 } else if (strcmp(colname[i], "package_size") == 0) {
1049 info->manifest_info->package_size = strdup(coltxt[i]);
1051 info->manifest_info->package_size = NULL;
1052 } else if (strcmp(colname[i], "author_email") == 0 ){
1054 info->manifest_info->author->email = strdup(coltxt[i]);
1056 info->manifest_info->author->email = NULL;
1057 } else if (strcmp(colname[i], "author_href") == 0 ){
1059 info->manifest_info->author->href = strdup(coltxt[i]);
1061 info->manifest_info->author->href = NULL;
1062 } else if (strcmp(colname[i], "package_label") == 0 ){
1064 info->manifest_info->label->text = strdup(coltxt[i]);
1066 info->manifest_info->label->text = NULL;
1067 } else if (strcmp(colname[i], "package_icon") == 0 ){
1069 info->manifest_info->icon->text = strdup(coltxt[i]);
1071 info->manifest_info->icon->text = NULL;
1072 } else if (strcmp(colname[i], "package_description") == 0 ){
1074 info->manifest_info->description->text = strdup(coltxt[i]);
1076 info->manifest_info->description->text = NULL;
1077 } else if (strcmp(colname[i], "package_author") == 0 ){
1079 info->manifest_info->author->text = strdup(coltxt[i]);
1081 info->manifest_info->author->text = NULL;
1082 } else if (strcmp(colname[i], "package_removable") == 0 ){
1084 info->manifest_info->removable = strdup(coltxt[i]);
1086 info->manifest_info->removable = NULL;
1087 } else if (strcmp(colname[i], "package_preload") == 0 ){
1089 info->manifest_info->preload = strdup(coltxt[i]);
1091 info->manifest_info->preload = NULL;
1092 } else if (strcmp(colname[i], "package_readonly") == 0 ){
1094 info->manifest_info->readonly = strdup(coltxt[i]);
1096 info->manifest_info->readonly = NULL;
1097 } else if (strcmp(colname[i], "package_update") == 0 ){
1099 info->manifest_info->update= strdup(coltxt[i]);
1101 info->manifest_info->update = NULL;
1102 } else if (strcmp(colname[i], "package_system") == 0 ){
1104 info->manifest_info->system= strdup(coltxt[i]);
1106 info->manifest_info->system = NULL;
1107 } else if (strcmp(colname[i], "package_appsetting") == 0 ){
1109 info->manifest_info->appsetting = strdup(coltxt[i]);
1111 info->manifest_info->appsetting = NULL;
1112 } else if (strcmp(colname[i], "installed_time") == 0 ){
1114 info->manifest_info->installed_time = strdup(coltxt[i]);
1116 info->manifest_info->installed_time = NULL;
1117 } else if (strcmp(colname[i], "installed_storage") == 0 ){
1119 info->manifest_info->installed_storage = strdup(coltxt[i]);
1121 info->manifest_info->installed_storage = NULL;
1122 } else if (strcmp(colname[i], "mainapp_id") == 0 ){
1124 info->manifest_info->mainapp_id = strdup(coltxt[i]);
1126 info->manifest_info->mainapp_id = NULL;
1127 } else if (strcmp(colname[i], "storeclient_id") == 0 ){
1129 info->manifest_info->storeclient_id = strdup(coltxt[i]);
1131 info->manifest_info->storeclient_id = NULL;
1132 } else if (strcmp(colname[i], "root_path") == 0 ){
1134 info->manifest_info->root_path = strdup(coltxt[i]);
1136 info->manifest_info->root_path = NULL;
1137 } else if (strcmp(colname[i], "csc_path") == 0 ){
1139 info->manifest_info->csc_path = strdup(coltxt[i]);
1141 info->manifest_info->csc_path = NULL;
1142 } else if (strcmp(colname[i], "privilege") == 0 ){
1144 info->manifest_info->privileges->privilege->text = strdup(coltxt[i]);
1146 info->manifest_info->privileges->privilege->text = NULL;
1147 } else if (strcmp(colname[i], "package_locale") == 0 ){
1149 info->manifest_info->author->lang = strdup(coltxt[i]);
1150 info->manifest_info->icon->lang = strdup(coltxt[i]);
1151 info->manifest_info->label->lang = strdup(coltxt[i]);
1152 info->manifest_info->description->lang = strdup(coltxt[i]);
1155 info->manifest_info->author->lang = NULL;
1156 info->manifest_info->icon->lang = NULL;
1157 info->manifest_info->label->lang = NULL;
1158 info->manifest_info->description->lang = NULL;
1160 } else if (strcmp(colname[i], "package_url") == 0 ){
1162 info->manifest_info->package_url = strdup(coltxt[i]);
1164 info->manifest_info->package_url = NULL;
1172 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1174 if ( strcasecmp(comp, "uiapp") == 0)
1175 return PMINFO_UI_APP;
1176 else if ( strcasecmp(comp, "svcapp") == 0)
1177 return PMINFO_SVC_APP;
1182 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1184 pkgmgr_certindexinfo_x *info = (pkgmgr_certindexinfo_x *)data;
1186 for(i = 0; i < ncols; i++) {
1187 if (strcmp(colname[i], "cert_id") == 0) {
1189 info->cert_id = atoi(coltxt[i]);
1192 } else if (strcmp(colname[i], "cert_ref_count") == 0) {
1194 info->cert_ref_count = atoi(coltxt[i]);
1196 info->cert_ref_count = 0;
1202 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1204 pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)data;
1206 for(i = 0; i < ncols; i++)
1208 if (strcmp(colname[i], "package") == 0) {
1210 info->pkgid = strdup(coltxt[i]);
1213 } else if (strcmp(colname[i], "author_signer_cert") == 0) {
1215 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = atoi(coltxt[i]);
1217 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = 0;
1218 } else if (strcmp(colname[i], "author_im_cert") == 0) {
1220 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1222 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 0;
1223 } else if (strcmp(colname[i], "author_root_cert") == 0) {
1225 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = atoi(coltxt[i]);
1227 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = 0;
1228 } else if (strcmp(colname[i], "dist_signer_cert") == 0 ){
1230 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = atoi(coltxt[i]);
1232 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 0;
1233 } else if (strcmp(colname[i], "dist_im_cert") == 0 ){
1235 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1237 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 0;
1238 } else if (strcmp(colname[i], "dist_root_cert") == 0 ){
1240 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = atoi(coltxt[i]);
1242 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = 0;
1243 } else if (strcmp(colname[i], "dist2_signer_cert") == 0 ){
1245 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = atoi(coltxt[i]);
1247 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 0;
1248 } else if (strcmp(colname[i], "dist2_im_cert") == 0 ){
1250 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1252 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 0;
1253 } else if (strcmp(colname[i], "dist2_root_cert") == 0 ){
1255 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = atoi(coltxt[i]);
1257 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 0;
1258 } else if (strcmp(colname[i], "cert_info") == 0 ){
1260 info->cert_value = strdup(coltxt[i]);
1262 info->cert_value = NULL;
1269 static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1271 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
1274 uiapplication_x *uiapp = NULL;
1275 serviceapplication_x *svcapp = NULL;
1276 for(i = 0; i < ncols; i++)
1278 if (strcmp(colname[i], "app_component") == 0) {
1280 if (strcmp(coltxt[i], "uiapp") == 0) {
1281 uiapp = calloc(1, sizeof(uiapplication_x));
1282 if (uiapp == NULL) {
1283 _LOGE("Out of Memory!!!\n");
1286 LISTADD(info->manifest_info->uiapplication, uiapp);
1287 for(j = 0; j < ncols; j++)
1289 if (strcmp(colname[j], "app_id") == 0) {
1291 info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
1292 } else if (strcmp(colname[j], "app_exec") == 0) {
1294 info->manifest_info->uiapplication->exec = strdup(coltxt[j]);
1296 info->manifest_info->uiapplication->exec = NULL;
1297 } else if (strcmp(colname[j], "app_nodisplay") == 0) {
1299 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[j]);
1301 info->manifest_info->uiapplication->nodisplay = NULL;
1302 } else if (strcmp(colname[j], "app_type") == 0 ) {
1304 info->manifest_info->uiapplication->type = strdup(coltxt[j]);
1306 info->manifest_info->uiapplication->type = NULL;
1307 } else if (strcmp(colname[j], "app_multiple") == 0 ) {
1309 info->manifest_info->uiapplication->multiple = strdup(coltxt[j]);
1311 info->manifest_info->uiapplication->multiple = NULL;
1312 } else if (strcmp(colname[j], "app_taskmanage") == 0 ) {
1314 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[j]);
1316 info->manifest_info->uiapplication->taskmanage = NULL;
1317 } else if (strcmp(colname[j], "app_hwacceleration") == 0 ) {
1319 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[j]);
1321 info->manifest_info->uiapplication->hwacceleration = NULL;
1322 } else if (strcmp(colname[j], "app_screenreader") == 0 ) {
1324 info->manifest_info->uiapplication->screenreader = strdup(coltxt[j]);
1326 info->manifest_info->uiapplication->screenreader = NULL;
1327 } else if (strcmp(colname[j], "app_enabled") == 0 ) {
1329 info->manifest_info->uiapplication->enabled= strdup(coltxt[j]);
1331 info->manifest_info->uiapplication->enabled = NULL;
1332 } else if (strcmp(colname[j], "app_indicatordisplay") == 0){
1334 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[j]);
1336 info->manifest_info->uiapplication->indicatordisplay = NULL;
1337 } else if (strcmp(colname[j], "app_portraitimg") == 0){
1339 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[j]);
1341 info->manifest_info->uiapplication->portraitimg = NULL;
1342 } else if (strcmp(colname[j], "app_landscapeimg") == 0){
1344 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[j]);
1346 info->manifest_info->uiapplication->landscapeimg = NULL;
1347 } else if (strcmp(colname[j], "app_guestmodevisibility") == 0){
1349 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[j]);
1351 info->manifest_info->uiapplication->guestmode_visibility = NULL;
1352 } else if (strcmp(colname[j], "app_recentimage") == 0 ) {
1354 info->manifest_info->uiapplication->recentimage = strdup(coltxt[j]);
1356 info->manifest_info->uiapplication->recentimage = NULL;
1357 } else if (strcmp(colname[j], "app_mainapp") == 0 ) {
1359 info->manifest_info->uiapplication->mainapp = strdup(coltxt[j]);
1361 info->manifest_info->uiapplication->mainapp = NULL;
1362 } else if (strcmp(colname[j], "package") == 0 ) {
1364 info->manifest_info->uiapplication->package = strdup(coltxt[j]);
1366 info->manifest_info->uiapplication->package = NULL;
1367 } else if (strcmp(colname[j], "app_component") == 0) {
1369 info->manifest_info->uiapplication->app_component = strdup(coltxt[j]);
1371 info->manifest_info->uiapplication->app_component = NULL;
1372 } else if (strcmp(colname[j], "app_permissiontype") == 0 ) {
1374 info->manifest_info->uiapplication->permission_type = strdup(coltxt[j]);
1376 info->manifest_info->uiapplication->permission_type = NULL;
1377 } else if (strcmp(colname[j], "component_type") == 0 ) {
1379 info->manifest_info->uiapplication->component_type = strdup(coltxt[j]);
1381 info->manifest_info->uiapplication->component_type = NULL;
1382 } else if (strcmp(colname[j], "app_preload") == 0 ) {
1384 info->manifest_info->uiapplication->preload = strdup(coltxt[j]);
1386 info->manifest_info->uiapplication->preload = NULL;
1387 } else if (strcmp(colname[j], "app_submode") == 0 ) {
1389 info->manifest_info->uiapplication->submode = strdup(coltxt[j]);
1391 info->manifest_info->uiapplication->submode = NULL;
1392 } else if (strcmp(colname[j], "app_submode_mainid") == 0 ) {
1394 info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[j]);
1396 info->manifest_info->uiapplication->submode_mainid = NULL;
1397 } else if (strcmp(colname[j], "app_installed_storage") == 0 ) {
1399 info->manifest_info->uiapplication->installed_storage = strdup(coltxt[j]);
1401 info->manifest_info->uiapplication->installed_storage = NULL;
1406 svcapp = calloc(1, sizeof(serviceapplication_x));
1407 if (svcapp == NULL) {
1408 _LOGE("Out of Memory!!!\n");
1411 LISTADD(info->manifest_info->serviceapplication, svcapp);
1412 for(j = 0; j < ncols; j++)
1414 if (strcmp(colname[j], "app_id") == 0) {
1416 info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
1417 } else if (strcmp(colname[j], "app_exec") == 0) {
1419 info->manifest_info->serviceapplication->exec = strdup(coltxt[j]);
1421 info->manifest_info->serviceapplication->exec = NULL;
1422 } else if (strcmp(colname[j], "app_type") == 0 ){
1424 info->manifest_info->serviceapplication->type = strdup(coltxt[j]);
1426 info->manifest_info->serviceapplication->type = NULL;
1427 } else if (strcmp(colname[j], "app_onboot") == 0 ){
1429 info->manifest_info->serviceapplication->onboot = strdup(coltxt[j]);
1431 info->manifest_info->serviceapplication->onboot = NULL;
1432 } else if (strcmp(colname[j], "app_autorestart") == 0 ){
1434 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[j]);
1436 info->manifest_info->serviceapplication->autorestart = NULL;
1437 } else if (strcmp(colname[j], "package") == 0 ){
1439 info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
1441 info->manifest_info->serviceapplication->package = NULL;
1442 } else if (strcmp(colname[j], "app_permissiontype") == 0 ) {
1444 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[j]);
1446 info->manifest_info->serviceapplication->permission_type = NULL;
1459 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1461 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1463 icon_x *icon = NULL;
1464 label_x *label = NULL;
1465 category_x *category = NULL;
1466 metadata_x *metadata = NULL;
1467 permission_x *permission = NULL;
1468 image_x *image = NULL;
1470 switch (info->app_component) {
1472 icon = calloc(1, sizeof(icon_x));
1473 LISTADD(info->uiapp_info->icon, icon);
1474 label = calloc(1, sizeof(label_x));
1475 LISTADD(info->uiapp_info->label, label);
1476 category = calloc(1, sizeof(category_x));
1477 LISTADD(info->uiapp_info->category, category);
1478 metadata = calloc(1, sizeof(metadata_x));
1479 LISTADD(info->uiapp_info->metadata, metadata);
1480 permission = calloc(1, sizeof(permission_x));
1481 LISTADD(info->uiapp_info->permission, permission);
1482 image = calloc(1, sizeof(image_x));
1483 LISTADD(info->uiapp_info->image, image);
1485 for(i = 0; i < ncols; i++)
1487 if (strcmp(colname[i], "app_id") == 0) {
1488 /*appid being foreign key, is column in every table
1489 Hence appid gets strduped every time leading to memory leak.
1490 If appid is already set, just continue.*/
1491 if (info->uiapp_info->appid)
1494 info->uiapp_info->appid = strdup(coltxt[i]);
1496 info->uiapp_info->appid = NULL;
1497 } else if (strcmp(colname[i], "app_exec") == 0) {
1499 info->uiapp_info->exec = strdup(coltxt[i]);
1501 info->uiapp_info->exec = NULL;
1502 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1504 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1506 info->uiapp_info->nodisplay = NULL;
1507 } else if (strcmp(colname[i], "app_type") == 0 ) {
1509 info->uiapp_info->type = strdup(coltxt[i]);
1511 info->uiapp_info->type = NULL;
1512 } else if (strcmp(colname[i], "app_icon_section") == 0 ) {
1514 info->uiapp_info->icon->section= strdup(coltxt[i]);
1516 info->uiapp_info->icon->section = NULL;
1517 } else if (strcmp(colname[i], "app_icon") == 0) {
1519 info->uiapp_info->icon->text = strdup(coltxt[i]);
1521 info->uiapp_info->icon->text = NULL;
1522 } else if (strcmp(colname[i], "app_label") == 0 ) {
1524 info->uiapp_info->label->text = strdup(coltxt[i]);
1526 info->uiapp_info->label->text = NULL;
1527 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1529 info->uiapp_info->multiple = strdup(coltxt[i]);
1531 info->uiapp_info->multiple = NULL;
1532 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1534 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1536 info->uiapp_info->taskmanage = NULL;
1537 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1539 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1541 info->uiapp_info->hwacceleration = NULL;
1542 } else if (strcmp(colname[i], "app_screenreader") == 0 ) {
1544 info->uiapp_info->screenreader = strdup(coltxt[i]);
1546 info->uiapp_info->screenreader = NULL;
1547 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1549 info->uiapp_info->enabled= strdup(coltxt[i]);
1551 info->uiapp_info->enabled = NULL;
1552 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1554 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1556 info->uiapp_info->indicatordisplay = NULL;
1557 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1559 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1561 info->uiapp_info->portraitimg = NULL;
1562 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1564 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1566 info->uiapp_info->landscapeimg = NULL;
1567 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1569 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1571 info->uiapp_info->guestmode_visibility = NULL;
1572 } else if (strcmp(colname[i], "category") == 0 ) {
1574 info->uiapp_info->category->name = strdup(coltxt[i]);
1576 info->uiapp_info->category->name = NULL;
1577 } else if (strcmp(colname[i], "md_key") == 0 ) {
1579 info->uiapp_info->metadata->key = strdup(coltxt[i]);
1581 info->uiapp_info->metadata->key = NULL;
1582 } else if (strcmp(colname[i], "md_value") == 0 ) {
1584 info->uiapp_info->metadata->value = strdup(coltxt[i]);
1586 info->uiapp_info->metadata->value = NULL;
1587 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1589 info->uiapp_info->permission->type= strdup(coltxt[i]);
1591 info->uiapp_info->permission->type = NULL;
1592 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1594 info->uiapp_info->permission->value = strdup(coltxt[i]);
1596 info->uiapp_info->permission->value = NULL;
1597 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1599 info->uiapp_info->recentimage = strdup(coltxt[i]);
1601 info->uiapp_info->recentimage = NULL;
1602 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1604 info->uiapp_info->mainapp = strdup(coltxt[i]);
1606 info->uiapp_info->mainapp = NULL;
1607 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1609 info->uiapp_info->icon->lang = strdup(coltxt[i]);
1610 info->uiapp_info->label->lang = strdup(coltxt[i]);
1613 info->uiapp_info->icon->lang = NULL;
1614 info->uiapp_info->label->lang = NULL;
1616 } else if (strcmp(colname[i], "app_image") == 0) {
1618 info->uiapp_info->image->text= strdup(coltxt[i]);
1620 info->uiapp_info->image->text = NULL;
1621 } else if (strcmp(colname[i], "app_image_section") == 0) {
1623 info->uiapp_info->image->section= strdup(coltxt[i]);
1625 info->uiapp_info->image->section = NULL;
1626 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1628 info->uiapp_info->permission_type = strdup(coltxt[i]);
1630 info->uiapp_info->permission_type = NULL;
1631 } else if (strcmp(colname[i], "component_type") == 0 ) {
1633 info->uiapp_info->component_type = strdup(coltxt[i]);
1635 info->uiapp_info->component_type = NULL;
1636 } else if (strcmp(colname[i], "app_preload") == 0 ) {
1638 info->uiapp_info->preload = strdup(coltxt[i]);
1640 info->uiapp_info->preload = NULL;
1641 } else if (strcmp(colname[i], "app_submode") == 0 ) {
1643 info->uiapp_info->submode = strdup(coltxt[i]);
1645 info->uiapp_info->submode = NULL;
1646 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
1648 info->uiapp_info->submode_mainid = strdup(coltxt[i]);
1650 info->uiapp_info->submode_mainid = NULL;
1651 } else if (strcmp(colname[i], "app_installed_storage") == 0 ) {
1653 info->uiapp_info->installed_storage = strdup(coltxt[i]);
1655 info->uiapp_info->installed_storage = NULL;
1660 case PMINFO_SVC_APP:
1661 icon = calloc(1, sizeof(icon_x));
1662 LISTADD(info->svcapp_info->icon, icon);
1663 label = calloc(1, sizeof(label_x));
1664 LISTADD(info->svcapp_info->label, label);
1665 category = calloc(1, sizeof(category_x));
1666 LISTADD(info->svcapp_info->category, category);
1667 metadata = calloc(1, sizeof(metadata_x));
1668 LISTADD(info->svcapp_info->metadata, metadata);
1669 permission = calloc(1, sizeof(permission_x));
1670 LISTADD(info->svcapp_info->permission, permission);
1671 for(i = 0; i < ncols; i++)
1673 if (strcmp(colname[i], "app_id") == 0) {
1674 /*appid being foreign key, is column in every table
1675 Hence appid gets strduped every time leading to memory leak.
1676 If appid is already set, just continue.*/
1677 if (info->svcapp_info->appid)
1680 info->svcapp_info->appid = strdup(coltxt[i]);
1682 info->svcapp_info->appid = NULL;
1683 } else if (strcmp(colname[i], "app_exec") == 0) {
1685 info->svcapp_info->exec = strdup(coltxt[i]);
1687 info->svcapp_info->exec = NULL;
1688 } else if (strcmp(colname[i], "app_icon") == 0) {
1690 info->svcapp_info->icon->text = strdup(coltxt[i]);
1692 info->svcapp_info->icon->text = NULL;
1693 } else if (strcmp(colname[i], "app_label") == 0 ) {
1695 info->svcapp_info->label->text = strdup(coltxt[i]);
1697 info->svcapp_info->label->text = NULL;
1698 } else if (strcmp(colname[i], "app_type") == 0 ) {
1700 info->svcapp_info->type = strdup(coltxt[i]);
1702 info->svcapp_info->type = NULL;
1703 } else if (strcmp(colname[i], "app_onboot") == 0 ) {
1705 info->svcapp_info->onboot = strdup(coltxt[i]);
1707 info->svcapp_info->onboot = NULL;
1708 } else if (strcmp(colname[i], "app_autorestart") == 0 ) {
1710 info->svcapp_info->autorestart = strdup(coltxt[i]);
1712 info->svcapp_info->autorestart = NULL;
1713 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1715 info->svcapp_info->enabled= strdup(coltxt[i]);
1717 info->svcapp_info->enabled = NULL;
1718 } else if (strcmp(colname[i], "category") == 0 ) {
1720 info->svcapp_info->category->name = strdup(coltxt[i]);
1722 info->svcapp_info->category->name = NULL;
1723 } else if (strcmp(colname[i], "md_key") == 0 ) {
1725 info->svcapp_info->metadata->key = strdup(coltxt[i]);
1727 info->svcapp_info->metadata->key = NULL;
1728 } else if (strcmp(colname[i], "md_value") == 0 ) {
1730 info->svcapp_info->metadata->value = strdup(coltxt[i]);
1732 info->svcapp_info->metadata->value = NULL;
1733 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1735 info->svcapp_info->permission->type= strdup(coltxt[i]);
1737 info->svcapp_info->permission->type = NULL;
1738 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1740 info->svcapp_info->permission->value = strdup(coltxt[i]);
1742 info->svcapp_info->permission->value = NULL;
1743 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1745 info->svcapp_info->icon->lang = strdup(coltxt[i]);
1746 info->svcapp_info->label->lang = strdup(coltxt[i]);
1749 info->svcapp_info->icon->lang = NULL;
1750 info->svcapp_info->label->lang = NULL;
1752 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1754 info->svcapp_info->permission_type = strdup(coltxt[i]);
1756 info->svcapp_info->permission_type = NULL;
1769 static int __appcomponent_cb(void *data, int ncols, char **coltxt, char **colname)
1771 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1773 for(i = 0; i < ncols; i++)
1775 if (strcmp(colname[i], "app_component") == 0) {
1776 info->app_component = __appcomponent_convert(coltxt[i]);
1777 } else if (strcmp(colname[i], "package") == 0) {
1778 info->package = strdup(coltxt[i]);
1785 static int __datacontrol_cb(void *data, int ncols, char **coltxt, char **colname)
1787 pkgmgr_datacontrol_x *info = (pkgmgr_datacontrol_x *)data;
1789 for(i = 0; i < ncols; i++)
1791 if (strcmp(colname[i], "PACKAGE_NAME") == 0) {
1793 info->appid = strdup(coltxt[i]);
1796 } else if (strcmp(colname[i], "ACCESS") == 0 ){
1798 info->access = strdup(coltxt[i]);
1800 info->access = NULL;
1807 static int __cert_cb(void *data, int ncols, char **coltxt, char **colname)
1809 pkgmgr_cert_x *info = (pkgmgr_cert_x *)data;
1812 for(i = 0; i < ncols; i++)
1814 if (strcmp(colname[i], "author_signer_cert") == 0) {
1816 info->cert_id = atoi(coltxt[i]);
1819 } else if (strcmp(colname[i], "package") == 0) {
1821 info->pkgid= strdup(coltxt[i]);
1830 /* get the first locale value*/
1831 static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
1833 pkgmgr_locale_x *info = (pkgmgr_locale_x *)data;
1836 info->locale = strdup(coltxt[0]);
1838 info->locale = NULL;
1843 static int __exec_certinfo_query(char *query, void *data)
1845 char *error_message = NULL;
1847 sqlite3_exec(cert_db, query, __certinfo_cb, data, &error_message)) {
1848 _LOGE("Don't execute query = %s error message = %s\n", query,
1850 sqlite3_free(error_message);
1853 sqlite3_free(error_message);
1857 static int __exec_certindexinfo_query(char *query, void *data)
1859 char *error_message = NULL;
1861 sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
1862 _LOGE("Don't execute query = %s error message = %s\n", query,
1864 sqlite3_free(error_message);
1867 sqlite3_free(error_message);
1871 static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data)
1873 char *error_message = NULL;
1875 sqlite3_exec(db, query, callback, data, &error_message)) {
1876 _LOGE("Don't execute query = %s error message = %s\n", query,
1878 sqlite3_free(error_message);
1881 sqlite3_free(error_message);
1886 static int __child_element(xmlTextReaderPtr reader, int depth)
1888 int ret = xmlTextReaderRead(reader);
1889 int cur = xmlTextReaderDepth(reader);
1892 switch (xmlTextReaderNodeType(reader)) {
1893 case XML_READER_TYPE_ELEMENT:
1894 if (cur == depth + 1)
1897 case XML_READER_TYPE_TEXT:
1898 /*text is handled by each function separately*/
1899 if (cur == depth + 1)
1902 case XML_READER_TYPE_END_ELEMENT:
1911 ret = xmlTextReaderRead(reader);
1912 cur = xmlTextReaderDepth(reader);
1917 static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, char **colname)
1919 int *p = (int*)data;
1920 *p = atoi(coltxt[0]);
1924 static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale)
1926 int result_query = -1;
1928 char query[MAX_QUERY_LEN];
1930 snprintf(query, MAX_QUERY_LEN, "select exists(select app_locale from package_app_localized_info where app_id='%s' and app_locale='%s')", appid, locale);
1931 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1932 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1933 return result_query;
1936 static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1938 int result_query = -1;
1940 char wildcard[2] = {'%','\0'};
1941 char query[MAX_QUERY_LEN];
1942 char lang[3] = {'\0'};
1943 strncpy(lang, locale, LANGUAGE_LENGTH);
1945 snprintf(query, MAX_QUERY_LEN, "select exists(select app_locale from package_app_localized_info where app_id='%s' and app_locale like '%s%s')", appid, lang, wildcard);
1946 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1947 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1948 return result_query;
1951 static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1954 char wildcard[2] = {'%','\0'};
1955 char lang[3] = {'\0'};
1956 char query[MAX_QUERY_LEN];
1957 char *locale_new = NULL;
1958 pkgmgr_locale_x *info = NULL;
1960 info = (pkgmgr_locale_x *)malloc(sizeof(pkgmgr_locale_x));
1962 _LOGE("Out of Memory!!!\n");
1965 memset(info, '\0', sizeof(*info));
1967 strncpy(lang, locale, 2);
1968 snprintf(query, MAX_QUERY_LEN, "select app_locale from package_app_localized_info where app_id='%s' and app_locale like '%s%s'", appid, lang, wildcard);
1969 ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
1970 tryvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1971 locale_new = info->locale;
1982 static char* __convert_syslocale_to_manifest_locale(char *syslocale)
1984 char *locale = malloc(6);
1986 _LOGE("Malloc Failed\n");
1990 sprintf(locale, "%c%c-%c%c", syslocale[0], syslocale[1], tolower(syslocale[3]), tolower(syslocale[4]));
1994 static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const char *syslocale)
1999 char *locale = NULL;
2000 char *locale_new = NULL;
2001 int check_result = 0;
2003 locale = __convert_syslocale_to_manifest_locale((char *)syslocale);
2005 /*check exact matching */
2006 check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale);
2009 if (check_result == 1) {
2010 // _LOGD("%s find exact locale(%s)\n", appid, locale);
2014 /* fallback matching */
2015 check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
2016 if(check_result == 1) {
2017 locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
2019 if (locale_new == NULL)
2020 locale_new = strdup(DEFAULT_LOCALE);
2024 /* default locale */
2026 return strdup(DEFAULT_LOCALE);
2029 static int __delete_certinfo(const char *pkgid)
2035 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
2036 char *error_message = NULL;
2037 char query[MAX_QUERY_LEN] = {'\0'};
2038 pkgmgr_certinfo_x *certinfo = NULL;
2039 pkgmgr_certindexinfo_x *indexinfo = NULL;
2040 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
2041 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
2042 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
2043 if (indexinfo == NULL) {
2044 _LOGE("Out of Memory!!!");
2045 ret = PMINFO_R_ERROR;
2048 /*populate certinfo from DB*/
2049 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
2050 ret = __exec_certinfo_query(query, (void *)certinfo);
2052 _LOGE("Package Cert Info DB Information retrieval failed\n");
2053 ret = PMINFO_R_ERROR;
2056 /*Update cert index table*/
2057 for (i = 0; i < MAX_CERT_TYPE; i++) {
2058 if ((certinfo->cert_id)[i]) {
2059 for (j = 0; j < MAX_CERT_TYPE; j++) {
2060 if ((certinfo->cert_id)[i] == unique_id[j]) {
2061 /*Ref count has already been updated. Just continue*/
2065 if (j == MAX_CERT_TYPE)
2066 unique_id[c++] = (certinfo->cert_id)[i];
2069 memset(query, '\0', MAX_QUERY_LEN);
2070 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
2071 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
2073 _LOGE("Cert Info DB Information retrieval failed\n");
2074 ret = PMINFO_R_ERROR;
2077 memset(query, '\0', MAX_QUERY_LEN);
2078 if (indexinfo->cert_ref_count > 1) {
2079 /*decrease ref count*/
2080 snprintf(query, MAX_QUERY_LEN, "update package_cert_index_info set cert_ref_count=%d where cert_id=%d ",
2081 indexinfo->cert_ref_count - 1, (certinfo->cert_id)[i]);
2083 /*delete this certificate as ref count is 1 and it will become 0*/
2084 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
2087 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
2088 _LOGE("Don't execute query = %s error message = %s\n", query,
2090 sqlite3_free(error_message);
2091 ret = PMINFO_R_ERROR;
2096 /*Now delete the entry from db*/
2097 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
2099 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
2100 _LOGE("Don't execute query = %s error message = %s\n", query,
2102 sqlite3_free(error_message);
2103 ret = PMINFO_R_ERROR;
2112 if (certinfo->pkgid) {
2113 free(certinfo->pkgid);
2114 certinfo->pkgid = NULL;
2116 for (i = 0; i < MAX_CERT_TYPE; i++) {
2117 if ((certinfo->cert_info)[i]) {
2118 free((certinfo->cert_info)[i]);
2119 (certinfo->cert_info)[i] = NULL;
2128 int __reqeust_get_size(const char *pkgid, int type)
2132 char *errmsg = NULL;
2134 void *handle = NULL;
2136 pkgmgr_client *(*__pkgmgr_client_new)(client_type ctype) = NULL;
2137 int (*__pkgmgr_client_get_size)(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data) = NULL;
2138 int (*__pkgmgr_client_request_service)(pkgmgr_request_service_type service_type, int service_mode,
2139 pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
2140 const char *custom_info, pkgmgr_handler event_cb, void *data) = NULL;
2142 retvm_if(pkgid == NULL, PMINFO_R_ERROR, "pkgid is NULL");
2144 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
2145 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
2147 __pkgmgr_client_new = dlsym(handle, "pkgmgr_client_new");
2149 tryvm_if((errmsg != NULL) || (__pkgmgr_client_new == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
2151 __pkgmgr_client_request_service = dlsym(handle, "pkgmgr_client_request_service");
2153 tryvm_if((errmsg != NULL) || (__pkgmgr_client_request_service == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
2155 pc = __pkgmgr_client_new(PC_REQUEST);
2156 tryvm_if(pc == NULL, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
2158 size = __pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, type, pc, NULL, pkgid, NULL, NULL, NULL);
2159 tryvm_if(size < 0, ret = PMINFO_R_ERROR, "get size failed.");
2168 void __get_package_size(const char *size_info, const char *pkgid, int *total_size, int *data_size)
2171 p = strstr(size_info, pkgid);
2177 *total_size = atoi(p+1);
2182 *data_size = atoi(p+1);
2195 int __get_package_size_info(char **size_info)
2200 pInfo = (char *)malloc(MAX_PKG_BUF_LEN * MAX_PKG_INFO_LEN);
2201 memset(pInfo, 0, MAX_PKG_BUF_LEN * MAX_PKG_INFO_LEN);
2203 fp = fopen(PKG_SIZE_INFO_FILE, "r");
2205 fread(pInfo, 1, MAX_PKG_BUF_LEN * MAX_PKG_INFO_LEN, fp);
2213 int __set_package_size_info(manifest_x *manifest, const char* size_info)
2218 char total_buf[PKG_TYPE_STRING_LEN_MAX] = {'\0'};
2219 char data_buf[PKG_TYPE_STRING_LEN_MAX] = {'\0'};
2221 __get_package_size(size_info, manifest->package, &total_size, &data_size);
2223 manifest->package_size = strdup("true");
2225 snprintf(total_buf, PKG_TYPE_STRING_LEN_MAX - 1, "%d", total_size);
2226 manifest->package_total_size = strndup(total_buf, PKG_TYPE_STRING_LEN_MAX - 1);
2228 snprintf(data_buf, PKG_TYPE_STRING_LEN_MAX - 1, "%d", data_size);
2229 manifest->package_data_size = strndup(data_buf, PKG_TYPE_STRING_LEN_MAX - 1);
2234 static int __pkginfo_check_installed_storage(pkgmgr_pkginfo_x *pkginfo)
2236 char buf[MAX_QUERY_LEN] = {'\0'};
2237 retvm_if(pkginfo->manifest_info->package == NULL, PMINFO_R_OK, "pkgid is NULL\n");
2239 if (strcmp(pkginfo->manifest_info->installed_storage,"installed_external") == 0) {
2240 snprintf(buf, MAX_QUERY_LEN - 1, "%s%s", PKG_SD_PATH, pkginfo->manifest_info->package);
2241 if (access(buf, R_OK) != 0) {
2242 _LOGE("can not access [%s]", buf);
2243 return PMINFO_R_OK;//tmep, it will be fixed to :: return PMINFO_R_ERROR;
2250 static int __appinfo_check_installed_storage(pkgmgr_appinfo_x *appinfo)
2252 char buf[MAX_QUERY_LEN] = {'\0'};
2255 pkgid = appinfo->package;
2257 pkgid = appinfo->uiapp_info->package;
2258 retvm_if(pkgid == NULL, PMINFO_R_OK, "pkgid is NULL\n");
2260 if (strcmp(appinfo->uiapp_info->installed_storage,"installed_external") == 0) {
2261 snprintf(buf, MAX_QUERY_LEN - 1, "%s%s", PKG_SD_PATH, pkgid);
2262 if (access(buf, R_OK) != 0) {
2263 _LOGE("can not access [%s]", buf);
2264 return PMINFO_R_OK;//tmep, it will be fixed to :: return PMINFO_R_ERROR;
2271 static int __update_ail_appinfo(manifest_x * mfx)
2274 uiapplication_x *uiapplication = mfx->uiapplication;
2275 void *lib_handle = NULL;
2276 int (*ail_desktop_operation) (const char *appid, const char *property, const char *value, bool broadcast);
2279 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
2280 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
2284 aop = "ail_desktop_appinfo_modify_str";
2286 if ((ail_desktop_operation =
2287 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
2288 _LOGE("can not find symbol \n");
2292 for(; uiapplication; uiapplication=uiapplication->next) {
2293 ret = ail_desktop_operation(uiapplication->appid, "AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR", mfx->installed_storage, FALSE);
2295 _LOGE("Failed to store info in DB\n");
2300 dlclose(lib_handle);
2305 static int __get_pkg_location(const char *pkgid)
2307 retvm_if(pkgid == NULL, PMINFO_R_OK, "pkginfo handle is NULL");
2310 char pkg_mmc_path[FILENAME_MAX] = { 0, };
2311 snprintf(pkg_mmc_path, FILENAME_MAX, "%s%s", PKG_SD_PATH, pkgid);
2313 /*check whether application is in external memory or not */
2314 fp = fopen(pkg_mmc_path, "r");
2318 return PMINFO_EXTERNAL_STORAGE;
2321 return PMINFO_INTERNAL_STORAGE;
2324 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
2326 retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
2327 int ret = PMINFO_R_OK;
2328 char query[MAX_QUERY_LEN] = {'\0'};
2329 char *syslocale = NULL;
2330 char *locale = NULL;
2331 pkgmgr_pkginfo_x *pkginfo = NULL;
2332 label_x *tmp1 = NULL;
2333 icon_x *tmp2 = NULL;
2334 description_x *tmp3 = NULL;
2335 author_x *tmp4 = NULL;
2336 privilege_x *tmp5 = NULL;
2337 sqlite3 *pkginfo_db = NULL;
2340 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
2341 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2343 /*get system locale*/
2344 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2345 locale = __convert_system_locale_to_manifest_locale(syslocale);
2346 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
2348 pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2349 pkgmgr_pkginfo_x *node = NULL;
2350 pkgmgr_pkginfo_x *temp_node = NULL;
2352 snprintf(query, MAX_QUERY_LEN, "select * from package_info");
2353 ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead);
2354 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2356 LISTHEAD(tmphead, node);
2358 for(node = node->next; node ; node = node->next) {
2360 pkginfo->locale = strdup(locale);
2361 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2362 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info\n");
2364 /*populate manifest_info from DB*/
2365 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
2366 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2367 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2369 memset(query, '\0', MAX_QUERY_LEN);
2370 /*populate privilege_info from DB*/
2371 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package);
2372 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2373 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package privilege Info DB Information retrieval failed");
2375 memset(query, '\0', MAX_QUERY_LEN);
2376 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2377 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
2378 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2379 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2381 /*Also store the values corresponding to default locales*/
2382 memset(query, '\0', MAX_QUERY_LEN);
2383 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2384 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
2385 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2386 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2388 if (pkginfo->manifest_info->label) {
2389 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2390 pkginfo->manifest_info->label = tmp1;
2392 if (pkginfo->manifest_info->icon) {
2393 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2394 pkginfo->manifest_info->icon = tmp2;
2396 if (pkginfo->manifest_info->description) {
2397 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2398 pkginfo->manifest_info->description = tmp3;
2400 if (pkginfo->manifest_info->author) {
2401 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2402 pkginfo->manifest_info->author = tmp4;
2404 if (pkginfo->manifest_info->privileges->privilege) {
2405 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2406 pkginfo->manifest_info->privileges->privilege = tmp5;
2410 LISTHEAD(tmphead, node);
2412 for(node = node->next; node ; node = node->next) {
2415 ret = __pkginfo_check_installed_storage(pkginfo);
2419 ret = pkg_list_cb( (void *)pkginfo, user_data);
2427 sqlite3_close(pkginfo_db);
2436 LISTHEAD(tmphead, node);
2437 temp_node = node->next;
2440 temp_node = node->next;
2441 __cleanup_pkginfo(node);
2444 __cleanup_pkginfo(tmphead);
2449 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
2451 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
2452 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2453 pkgmgr_pkginfo_x *pkginfo = NULL;
2454 int ret = PMINFO_R_OK;
2455 char query[MAX_QUERY_LEN] = {'\0'};
2456 char *syslocale = NULL;
2457 char *locale = NULL;
2459 label_x *tmp1 = NULL;
2460 icon_x *tmp2 = NULL;
2461 description_x *tmp3 = NULL;
2462 author_x *tmp4 = NULL;
2463 privilege_x *tmp5 = NULL;
2464 sqlite3 *pkginfo_db = NULL;
2467 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
2468 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2470 /*check pkgid exist on db*/
2471 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
2472 ret = __exec_db_query(pkginfo_db, query, __validate_cb, (void *)&exist);
2473 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
2474 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] not found in DB", pkgid);
2476 /*get system locale*/
2477 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2478 locale = __convert_system_locale_to_manifest_locale(syslocale);
2479 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
2481 pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2482 tryvm_if(pkginfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for pkginfo");
2484 pkginfo->locale = strdup(locale);
2486 pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
2487 tryvm_if(pkginfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for manifest info");
2489 pkginfo->manifest_info->package = strdup(pkgid);
2490 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2491 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info");
2493 /*populate manifest_info from DB*/
2494 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
2495 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2496 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2498 memset(query, '\0', MAX_QUERY_LEN);
2499 /*populate privilege_info from DB*/
2500 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
2501 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2502 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
2504 memset(query, '\0', MAX_QUERY_LEN);
2505 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2506 " package='%s' and package_locale='%s'", pkgid, locale);
2507 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2508 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2510 /*Also store the values corresponding to default locales*/
2511 memset(query, '\0', MAX_QUERY_LEN);
2512 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2513 " package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
2514 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2515 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2517 if (pkginfo->manifest_info->label) {
2518 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2519 pkginfo->manifest_info->label = tmp1;
2521 if (pkginfo->manifest_info->icon) {
2522 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2523 pkginfo->manifest_info->icon = tmp2;
2525 if (pkginfo->manifest_info->description) {
2526 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2527 pkginfo->manifest_info->description = tmp3;
2529 if (pkginfo->manifest_info->author) {
2530 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2531 pkginfo->manifest_info->author = tmp4;
2533 if (pkginfo->manifest_info->privileges->privilege) {
2534 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2535 pkginfo->manifest_info->privileges->privilege = tmp5;
2538 ret = __pkginfo_check_installed_storage(pkginfo);
2539 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "[%s] is installed external, but is not in mmc", pkgid);
2542 if (ret == PMINFO_R_OK)
2543 *handle = (void*)pkginfo;
2546 __cleanup_pkginfo(pkginfo);
2548 sqlite3_close(pkginfo_db);
2562 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
2564 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2565 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2566 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2567 if (info->manifest_info->package)
2568 *pkg_name = (char *)info->manifest_info->package;
2570 return PMINFO_R_ERROR;
2575 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
2577 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2578 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2579 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2580 if (info->manifest_info->package)
2581 *pkgid = (char *)info->manifest_info->package;
2583 return PMINFO_R_ERROR;
2588 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
2590 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2591 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2592 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2593 if (info->manifest_info->type)
2594 *type = (char *)info->manifest_info->type;
2600 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
2602 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2603 retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2604 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2605 *version = (char *)info->manifest_info->version;
2609 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
2611 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2612 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2614 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2615 val = (char *)info->manifest_info->installlocation;
2617 if (strcmp(val, "internal-only") == 0)
2618 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2619 else if (strcmp(val, "prefer-external") == 0)
2620 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2622 *location = PMINFO_INSTALL_LOCATION_AUTO;
2627 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
2629 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2630 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2632 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2633 val = (char *)info->manifest_info->package_size;
2638 _LOGE("package size is not specified\n");
2639 return PMINFO_R_ERROR;
2644 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
2646 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2647 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2653 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2654 val = (char *)info->manifest_info->package_size;
2655 if (strcmp(val, "true") == 0) {
2656 *size = atoi(info->manifest_info->package_total_size);
2664 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
2666 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2667 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2673 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2674 val = (char *)info->manifest_info->package_size;
2675 if (strcmp(val, "true") == 0) {
2676 *size = atoi(info->manifest_info->package_data_size);
2684 API int pkgmgrinfo_pkginfo_get_size_info(pkgmgrinfo_pkginfo_h handle, int *total_size, int *data_size)
2686 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2687 retvm_if(total_size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2688 retvm_if(data_size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2695 char* package_size_info = NULL;
2697 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2699 val = (char *)info->manifest_info->package_size;
2700 if (strcmp(val, "true") == 0) {
2701 *total_size = atoi(info->manifest_info->package_total_size);
2702 *data_size = atoi(info->manifest_info->package_data_size);
2713 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
2715 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2716 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2717 int ret = PMINFO_R_OK;
2718 char *locale = NULL;
2722 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2724 locale = info->locale;
2725 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2727 for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next)
2730 if (strcmp(ptr->lang, locale) == 0) {
2731 *icon = (char *)ptr->text;
2732 if (strcasecmp(*icon, "(null)") == 0) {
2733 locale = DEFAULT_LOCALE;
2737 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2738 *icon = (char *)ptr->text;
2747 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
2749 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2750 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2751 int ret = PMINFO_R_OK;
2752 char *locale = NULL;
2753 label_x *ptr = NULL;
2756 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2757 locale = info->locale;
2758 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2760 for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next)
2763 if (strcmp(ptr->lang, locale) == 0) {
2764 *label = (char *)ptr->text;
2765 if (strcasecmp(*label, "(null)") == 0) {
2766 locale = DEFAULT_LOCALE;
2770 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2771 *label = (char *)ptr->text;
2780 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
2782 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2783 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2784 char *locale = NULL;
2785 description_x *ptr = NULL;
2786 *description = NULL;
2788 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2789 locale = info->locale;
2790 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2792 for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next)
2795 if (strcmp(ptr->lang, locale) == 0) {
2796 *description = (char *)ptr->text;
2797 if (strcasecmp(*description, PKGMGR_PARSER_EMPTY_STR) == 0) {
2798 locale = DEFAULT_LOCALE;
2802 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2803 *description = (char *)ptr->text;
2811 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
2813 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2814 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2815 char *locale = NULL;
2816 author_x *ptr = NULL;
2817 *author_name = NULL;
2819 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2820 locale = info->locale;
2821 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2823 for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next)
2826 if (strcmp(ptr->lang, locale) == 0) {
2827 *author_name = (char *)ptr->text;
2828 if (strcasecmp(*author_name, PKGMGR_PARSER_EMPTY_STR) == 0) {
2829 locale = DEFAULT_LOCALE;
2833 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2834 *author_name = (char *)ptr->text;
2842 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
2844 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2845 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2846 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2847 *author_email = (char *)info->manifest_info->author->email;
2851 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
2853 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2854 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2855 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2856 *author_href = (char *)info->manifest_info->author->href;
2860 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
2862 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2863 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2865 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2867 if (strcmp(info->manifest_info->installed_storage,"installed_internal") == 0)
2868 *storage = PMINFO_INTERNAL_STORAGE;
2869 else if (strcmp(info->manifest_info->installed_storage,"installed_external") == 0)
2870 *storage = PMINFO_EXTERNAL_STORAGE;
2872 return PMINFO_R_ERROR;
2877 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
2879 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2880 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2881 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2882 if (info->manifest_info->installed_time)
2883 *installed_time = atoi(info->manifest_info->installed_time);
2885 return PMINFO_R_ERROR;
2890 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
2892 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2893 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2894 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2895 *storeclientid = (char *)info->manifest_info->storeclient_id;
2899 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
2901 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2902 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2903 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2904 *mainappid = (char *)info->manifest_info->mainapp_id;
2908 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
2910 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2911 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2912 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2913 *url = (char *)info->manifest_info->package_url;
2917 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
2919 const char *val = NULL;
2920 const xmlChar *node;
2921 xmlTextReaderPtr reader;
2922 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2923 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2926 reader = xmlReaderForFile(manifest, NULL, 0);
2929 if (__child_element(reader, -1)) {
2930 node = xmlTextReaderConstName(reader);
2932 _LOGE("xmlTextReaderConstName value is NULL\n");
2933 xmlFreeTextReader(reader);
2935 return PMINFO_R_ERROR;
2938 if (!strcmp(ASC_CHAR(node), "manifest")) {
2939 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
2940 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
2946 _LOGE("package size is not specified\n");
2947 xmlFreeTextReader(reader);
2949 return PMINFO_R_ERROR;
2952 _LOGE("Unable to create xml reader\n");
2953 xmlFreeTextReader(reader);
2955 return PMINFO_R_ERROR;
2959 _LOGE("xmlReaderForFile value is NULL\n");
2961 return PMINFO_R_ERROR;
2964 xmlFreeTextReader(reader);
2970 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
2972 const char *val = NULL;
2973 const xmlChar *node;
2974 xmlTextReaderPtr reader;
2975 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2976 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2979 reader = xmlReaderForFile(manifest, NULL, 0);
2982 if ( __child_element(reader, -1)) {
2983 node = xmlTextReaderConstName(reader);
2985 _LOGE("xmlTextReaderConstName value is NULL\n");
2986 xmlFreeTextReader(reader);
2988 return PMINFO_R_ERROR;
2991 if (!strcmp(ASC_CHAR(node), "manifest")) {
2992 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
2993 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
2996 if (strcmp(val, "internal-only") == 0)
2997 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2998 else if (strcmp(val, "prefer-external") == 0)
2999 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
3001 *location = PMINFO_INSTALL_LOCATION_AUTO;
3004 _LOGE("Unable to create xml reader\n");
3005 xmlFreeTextReader(reader);
3007 return PMINFO_R_ERROR;
3011 _LOGE("xmlReaderForFile value is NULL\n");
3013 return PMINFO_R_ERROR;
3016 xmlFreeTextReader(reader);
3023 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
3025 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3026 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3028 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3029 if (info->manifest_info->root_path)
3030 *path = (char *)info->manifest_info->root_path;
3032 return PMINFO_R_ERROR;
3037 API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
3039 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3040 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3042 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3043 if (info->manifest_info->csc_path)
3044 *path = (char *)info->manifest_info->csc_path;
3046 *path = (char *)info->manifest_info->csc_path;
3051 API int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, const char *rhs_package_id, pkgmgrinfo_cert_compare_result_type_e *compare_result)
3053 retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
3054 retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
3055 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3057 int ret = PMINFO_R_OK;
3058 char query[MAX_QUERY_LEN] = {'\0'};
3059 char *error_message = NULL;
3060 pkgmgr_cert_x *info= NULL;
3064 *compare_result = PMINFO_CERT_COMPARE_ERROR;
3065 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3066 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3068 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READONLY, NULL);
3069 if (ret != SQLITE_OK) {
3070 _LOGE("connect db [%s] failed!\n", CERT_DB);
3071 ret = PMINFO_R_ERROR;
3075 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
3077 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
3078 _LOGE("Don't execute query = %s error message = %s\n", query,
3080 ret = PMINFO_R_ERROR;
3087 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
3089 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
3090 _LOGE("Don't execute query = %s error message = %s\n", query,
3092 ret = PMINFO_R_ERROR;
3095 lcert = info->cert_id;
3098 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
3100 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
3101 _LOGE("Don't execute query = %s error message = %s\n", query,
3103 ret = PMINFO_R_ERROR;
3110 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
3112 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
3113 _LOGE("Don't execute query = %s error message = %s\n", query,
3115 ret = PMINFO_R_ERROR;
3118 rcert = info->cert_id;
3121 if ((lcert == 0) || (rcert == 0))
3123 if ((lcert == 0) && (rcert == 0))
3124 *compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
3125 else if (lcert == 0)
3126 *compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
3127 else if (rcert == 0)
3128 *compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
3131 *compare_result = PMINFO_CERT_COMPARE_MATCH;
3133 *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
3137 sqlite3_free(error_message);
3138 sqlite3_close(cert_db);
3151 API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const char *rhs_app_id, pkgmgrinfo_cert_compare_result_type_e *compare_result)
3153 retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
3154 retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
3155 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3157 int ret = PMINFO_R_OK;
3158 char query[MAX_QUERY_LEN] = {'\0'};
3159 char *error_message = NULL;
3160 pkgmgr_cert_x *info= NULL;
3162 char *lpkgid = NULL;
3163 char *rpkgid = NULL;
3164 sqlite3 *pkginfo_db = NULL;
3166 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3167 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3169 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3170 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3172 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
3174 sqlite3_exec(pkginfo_db, query, __validate_cb, (void *)&exist, &error_message)) {
3175 _LOGE("Don't execute query = %s error message = %s\n", query,
3177 ret = PMINFO_R_ERROR;
3184 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
3186 sqlite3_exec(pkginfo_db, query, __cert_cb, (void *)info, &error_message)) {
3187 _LOGE("Don't execute query = %s error message = %s\n", query,
3189 ret = PMINFO_R_ERROR;
3192 lpkgid = strdup(info->pkgid);
3193 if (lpkgid == NULL) {
3194 _LOGE("Out of Memory\n");
3195 ret = PMINFO_R_ERROR;
3202 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
3204 sqlite3_exec(pkginfo_db, query, __validate_cb, (void *)&exist, &error_message)) {
3205 _LOGE("Don't execute query = %s error message = %s\n", query,
3207 ret = PMINFO_R_ERROR;
3214 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
3216 sqlite3_exec(pkginfo_db, query, __cert_cb, (void *)info, &error_message)) {
3217 _LOGE("Don't execute query = %s error message = %s\n", query,
3219 ret = PMINFO_R_ERROR;
3222 rpkgid = strdup(info->pkgid);
3223 if (rpkgid == NULL) {
3224 _LOGE("Out of Memory\n");
3225 ret = PMINFO_R_ERROR;
3231 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
3234 sqlite3_free(error_message);
3235 sqlite3_close(pkginfo_db);
3255 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
3257 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3258 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3260 #if 0 //smack issue occured, check later
3262 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
3264 _LOGD("invalid func parameters\n");
3265 return PMINFO_R_ERROR;
3267 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
3270 char app_mmc_path[FILENAME_MAX] = { 0, };
3271 char app_dir_path[FILENAME_MAX] = { 0, };
3272 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
3273 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
3274 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
3275 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
3277 /*check whether application is in external memory or not */
3278 fp = fopen(app_mmc_path, "r");
3280 _LOGD(" app path in external memory not accesible\n");
3285 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
3289 /*check whether application is in internal or not */
3290 fp = fopen(app_dir_path, "r");
3292 _LOGD(" app path in internal memory not accesible\n");
3294 return PMINFO_R_ERROR;
3297 /*check whether the application is installed in SD card
3298 but SD card is not present*/
3299 fp = fopen(app_mmc_internal_path, "r");
3302 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
3307 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
3312 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
3319 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
3321 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3322 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3324 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3325 val = (char *)info->manifest_info->removable;
3327 if (strcasecmp(val, "true") == 0)
3329 else if (strcasecmp(val, "false") == 0)
3337 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
3339 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3340 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3343 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3345 val = (char *)info->manifest_info->installlocation;
3347 if (strcmp(val, "internal-only") == 0)
3349 else if (strcmp(val, "prefer-external") == 0)
3358 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
3360 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3361 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3363 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3364 val = (char *)info->manifest_info->preload;
3366 if (strcasecmp(val, "true") == 0)
3368 else if (strcasecmp(val, "false") == 0)
3376 API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
3378 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3379 retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3382 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3383 val = (char *)info->manifest_info->system;
3385 if (strcasecmp(val, "true") == 0)
3387 else if (strcasecmp(val, "false") == 0)
3396 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
3398 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3399 retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3401 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3402 val = (char *)info->manifest_info->readonly;
3404 if (strcasecmp(val, "true") == 0)
3406 else if (strcasecmp(val, "false") == 0)
3414 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
3416 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3417 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3420 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3421 val = (char *)info->manifest_info->update;
3423 if (strcasecmp(val, "true") == 0)
3425 else if (strcasecmp(val, "false") == 0)
3433 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
3435 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3436 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3437 __cleanup_pkginfo(info);
3441 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
3443 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
3445 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
3446 if (filter == NULL) {
3447 _LOGE("Out of Memory!!!");
3448 return PMINFO_R_ERROR;
3454 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
3456 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3457 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3459 g_slist_foreach(filter->list, __destroy_each_node, NULL);
3460 g_slist_free(filter->list);
3465 if (access(PKG_SIZE_INFO_FILE, F_OK) == 0) {
3466 char info_file[PKG_VALUE_STRING_LEN_MAX] = { 0, };
3467 snprintf(info_file, PKG_VALUE_STRING_LEN_MAX, "%s", PKG_SIZE_INFO_FILE);
3474 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
3475 const char *property, const int value)
3477 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3478 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3479 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3481 GSList *link = NULL;
3483 prop = _pminfo_pkginfo_convert_to_prop_int(property);
3484 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
3485 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
3486 _LOGE("Invalid Integer Property\n");
3487 return PMINFO_R_EINVAL;
3489 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3490 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3492 _LOGE("Out of Memory!!!\n");
3493 return PMINFO_R_ERROR;
3495 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3496 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3498 _LOGE("Out of Memory\n");
3501 return PMINFO_R_ERROR;
3505 /*If API is called multiple times for same property, we should override the previous values.
3506 Last value set will be used for filtering.*/
3507 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3509 filter->list = g_slist_delete_link(filter->list, link);
3510 filter->list = g_slist_append(filter->list, (gpointer)node);
3515 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
3516 const char *property, const bool value)
3518 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3519 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3521 GSList *link = NULL;
3523 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
3524 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
3525 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
3526 _LOGE("Invalid Boolean Property\n");
3527 return PMINFO_R_EINVAL;
3529 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3530 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3532 _LOGE("Out of Memory!!!\n");
3533 return PMINFO_R_ERROR;
3536 val = strndup("('true','True')", 15);
3538 val = strndup("('false','False')", 17);
3540 _LOGE("Out of Memory\n");
3543 return PMINFO_R_ERROR;
3547 /*If API is called multiple times for same property, we should override the previous values.
3548 Last value set will be used for filtering.*/
3549 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3551 filter->list = g_slist_delete_link(filter->list, link);
3552 filter->list = g_slist_append(filter->list, (gpointer)node);
3557 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
3558 const char *property, const char *value)
3560 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3561 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3562 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3564 GSList *link = NULL;
3566 prop = _pminfo_pkginfo_convert_to_prop_str(property);
3567 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
3568 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
3569 _LOGE("Invalid String Property\n");
3570 return PMINFO_R_EINVAL;
3572 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3573 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3575 _LOGE("Out of Memory!!!\n");
3576 return PMINFO_R_ERROR;
3578 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
3579 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
3580 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
3581 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
3582 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
3583 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
3584 else if (strcmp(value, "installed_internal") == 0)
3585 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
3586 else if (strcmp(value, "installed_external") == 0)
3587 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
3589 val = strndup(value, PKG_STRING_LEN_MAX - 1);
3591 _LOGE("Out of Memory\n");
3594 return PMINFO_R_ERROR;
3598 /*If API is called multiple times for same property, we should override the previous values.
3599 Last value set will be used for filtering.*/
3600 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3602 filter->list = g_slist_delete_link(filter->list, link);
3603 filter->list = g_slist_append(filter->list, (gpointer)node);
3608 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
3610 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3611 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3612 char *syslocale = NULL;
3613 char *locale = NULL;
3614 char *condition = NULL;
3615 char query[MAX_QUERY_LEN] = {'\0'};
3616 char where[MAX_QUERY_LEN] = {'\0'};
3619 pkgmgr_pkginfo_x *node = NULL;
3620 pkgmgr_pkginfo_x *tmphead = NULL;
3621 pkgmgr_pkginfo_x *pkginfo = NULL;
3622 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3623 sqlite3 *pkginfo_db = NULL;
3624 int filter_count = 0;
3627 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3628 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3630 /*get system locale*/
3631 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3632 locale = __convert_system_locale_to_manifest_locale(syslocale);
3633 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
3635 /*Start constructing query*/
3636 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
3638 /*Get where clause*/
3639 for (list = filter->list; list; list = g_slist_next(list)) {
3640 __get_filter_condition(list->data, &condition);
3642 strncat(where, condition, sizeof(where) - strlen(where) -1);
3643 where[sizeof(where) - 1] = '\0';
3647 if (g_slist_next(list)) {
3648 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3649 where[sizeof(where) - 1] = '\0';
3652 _LOGE("where = %s\n", where);
3653 if (strlen(where) > 0) {
3654 strncat(query, where, sizeof(query) - strlen(query) - 1);
3655 query[sizeof(query) - 1] = '\0';
3657 _LOGE("query = %s\n", query);
3659 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
3660 tryvm_if(tmphead == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3662 ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead);
3663 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3665 LISTHEAD(tmphead, node);
3666 for(node = node->next ; node ; node = node->next) {
3668 pkginfo->locale = strdup(locale);
3669 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
3670 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info\n");
3672 /*populate manifest_info from DB*/
3673 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
3674 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3675 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3677 memset(query, '\0', MAX_QUERY_LEN);
3678 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3679 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
3680 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3681 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3683 /*Also store the values corresponding to default locales*/
3684 memset(query, '\0', MAX_QUERY_LEN);
3685 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3686 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
3687 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3688 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3691 LISTHEAD(tmphead, node);
3693 for(node = node->next ; node ; node = node->next) {
3695 ret = __pkginfo_check_installed_storage(pkginfo);
3701 *count = filter_count;
3713 sqlite3_close(pkginfo_db);
3714 __cleanup_pkginfo(tmphead);
3718 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
3719 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
3721 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3722 retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3723 char *syslocale = NULL;
3724 char *locale = NULL;
3725 char *condition = NULL;
3726 char query[MAX_QUERY_LEN] = {'\0'};
3727 char where[MAX_QUERY_LEN] = {'\0'};
3730 label_x *tmp1 = NULL;
3731 icon_x *tmp2 = NULL;
3732 description_x *tmp3 = NULL;
3733 author_x *tmp4 = NULL;
3734 privilege_x *tmp5 = NULL;
3735 pkgmgr_pkginfo_x *node = NULL;
3736 pkgmgr_pkginfo_x *tmphead = NULL;
3737 pkgmgr_pkginfo_x *pkginfo = NULL;
3738 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3739 sqlite3 *pkginfo_db = NULL;
3740 const char* package_size_info = NULL;
3741 bool is_setting = false;
3744 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3745 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3747 /*get system locale*/
3748 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3749 locale = __convert_system_locale_to_manifest_locale(syslocale);
3750 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
3752 /*Start constructing query*/
3753 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
3755 /*Get where clause*/
3756 for (list = filter->list; list; list = g_slist_next(list)) {
3757 __get_filter_condition(list->data, &condition);
3759 strncat(where, condition, sizeof(where) - strlen(where) -1);
3760 where[sizeof(where) - 1] = '\0';
3762 if (strstr(condition, "package_info.package_nodisplay"))
3768 if (g_slist_next(list)) {
3769 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3770 where[sizeof(where) - 1] = '\0';
3773 _LOGE("where = %s\n", where);
3774 if (strlen(where) > 0) {
3775 strncat(query, where, sizeof(query) - strlen(query) - 1);
3776 query[sizeof(query) - 1] = '\0';
3778 _LOGE("query = %s\n", query);
3780 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
3781 tryvm_if(tmphead == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3783 ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead);
3784 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3787 ret = __reqeust_get_size("size_info", PM_GET_SIZE_INFO);
3788 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "fail reqeust size info");
3790 ret = __get_package_size_info(&package_size_info);
3791 tryvm_if(ret != 0 || package_size_info == NULL, ret = PMINFO_R_ERROR, "__get_package_size_info() failed");
3792 _LOGD("is_setting is true, get package size info success!! ");
3795 LISTHEAD(tmphead, node);
3796 for(node = node->next ; node ; node = node->next) {
3798 pkginfo->locale = strdup(locale);
3799 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
3800 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info\n");
3802 /*populate manifest_info from DB*/
3803 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
3804 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3805 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3807 memset(query, '\0', MAX_QUERY_LEN);
3808 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3809 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
3810 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3811 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3813 /*Also store the values corresponding to default locales*/
3814 memset(query, '\0', MAX_QUERY_LEN);
3815 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3816 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
3817 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3818 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3820 if (pkginfo->manifest_info->label) {
3821 LISTHEAD(pkginfo->manifest_info->label, tmp1);
3822 pkginfo->manifest_info->label = tmp1;
3824 if (pkginfo->manifest_info->icon) {
3825 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
3826 pkginfo->manifest_info->icon = tmp2;
3828 if (pkginfo->manifest_info->description) {
3829 LISTHEAD(pkginfo->manifest_info->description, tmp3);
3830 pkginfo->manifest_info->description = tmp3;
3832 if (pkginfo->manifest_info->author) {
3833 LISTHEAD(pkginfo->manifest_info->author, tmp4);
3834 pkginfo->manifest_info->author = tmp4;
3836 if (pkginfo->manifest_info->privileges->privilege) {
3837 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
3838 pkginfo->manifest_info->privileges->privilege = tmp5;
3841 __set_package_size_info(pkginfo->manifest_info, package_size_info);
3845 LISTHEAD(tmphead, node);
3847 for(node = node->next ; node ; node = node->next) {
3850 ret = __pkginfo_check_installed_storage(pkginfo);
3854 ret = pkg_cb( (void *)pkginfo, user_data);
3869 if (package_size_info) {
3870 free(package_size_info);
3873 sqlite3_close(pkginfo_db);
3874 __cleanup_pkginfo(tmphead);
3878 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
3879 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
3881 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3882 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3884 privilege_x *ptr = NULL;
3885 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3886 ptr = info->manifest_info->privileges->privilege;
3887 for (; ptr; ptr = ptr->next) {
3889 ret = privilege_func(ptr->text, user_data);
3897 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
3898 pkgmgrinfo_app_list_cb app_func, void *user_data)
3900 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3901 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
3902 retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
3904 char *syslocale = NULL;
3905 char *locale = NULL;
3907 char query[MAX_QUERY_LEN] = {'\0'};
3908 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3909 pkgmgr_pkginfo_x *allinfo = NULL;
3910 pkgmgr_appinfo_x *appinfo = NULL;
3911 icon_x *ptr1 = NULL;
3912 label_x *ptr2 = NULL;
3913 category_x *ptr3 = NULL;
3914 metadata_x *ptr4 = NULL;
3915 permission_x *ptr5 = NULL;
3916 image_x *ptr6 = NULL;
3917 sqlite3 *appinfo_db = NULL;
3919 /*check installed storage*/
3920 ret = __pkginfo_check_installed_storage(info);
3921 retvm_if(ret < 0, PMINFO_R_EINVAL, "[%s] is installed external, but is not in mmc", info->manifest_info->package);
3923 /*get system locale*/
3924 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3925 locale = __convert_system_locale_to_manifest_locale(syslocale);
3926 tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
3929 allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
3930 tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3932 /*calloc manifest_info*/
3933 allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
3934 tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
3937 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
3938 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3940 /*set component type*/
3941 if (component == PMINFO_UI_APP)
3942 appinfo->app_component = PMINFO_UI_APP;
3943 if (component == PMINFO_SVC_APP)
3944 appinfo->app_component = PMINFO_SVC_APP;
3945 if (component == PMINFO_ALL_APP)
3946 appinfo->app_component = PMINFO_ALL_APP;
3949 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
3950 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3952 appinfo->package = strdup(info->manifest_info->package);
3953 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
3954 "from package_app_info where " \
3955 "package='%s' and app_component='%s'",
3956 info->manifest_info->package,
3957 (appinfo->app_component==PMINFO_UI_APP ? "uiapp" : "svcapp"));
3961 /*Populate ui app info */
3962 ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
3963 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3965 uiapplication_x *tmp = NULL;
3966 if (info->manifest_info->uiapplication) {
3967 LISTHEAD(info->manifest_info->uiapplication, tmp);
3968 info->manifest_info->uiapplication = tmp;
3970 /*Populate localized info for default locales and call callback*/
3971 /*If the callback func return < 0 we break and no more call back is called*/
3974 appinfo->locale = strdup(locale);
3975 appinfo->uiapp_info = tmp;
3976 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
3980 locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
3983 memset(query, '\0', MAX_QUERY_LEN);
3984 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3985 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3986 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3988 memset(query, '\0', MAX_QUERY_LEN);
3989 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
3990 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3991 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3993 /*store setting notification icon section*/
3994 memset(query, '\0', MAX_QUERY_LEN);
3995 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3996 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3997 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
3999 /*store app preview image info*/
4000 memset(query, '\0', MAX_QUERY_LEN);
4001 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
4002 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4003 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4005 if (appinfo->uiapp_info->label) {
4006 LISTHEAD(appinfo->uiapp_info->label, ptr2);
4007 appinfo->uiapp_info->label = ptr2;
4009 if (appinfo->uiapp_info->icon) {
4010 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
4011 appinfo->uiapp_info->icon = ptr1;
4013 if (appinfo->uiapp_info->category) {
4014 LISTHEAD(appinfo->uiapp_info->category, ptr3);
4015 appinfo->uiapp_info->category = ptr3;
4017 if (appinfo->uiapp_info->metadata) {
4018 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
4019 appinfo->uiapp_info->metadata = ptr4;
4021 if (appinfo->uiapp_info->permission) {
4022 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
4023 appinfo->uiapp_info->permission = ptr5;
4025 if (appinfo->uiapp_info->image) {
4026 LISTHEAD(appinfo->uiapp_info->image, ptr6);
4027 appinfo->uiapp_info->image = ptr6;
4029 ret = app_func((void *)appinfo, user_data);
4035 case PMINFO_SVC_APP:
4036 /*Populate svc app info */
4037 ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
4038 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
4040 serviceapplication_x *tmp1 = NULL;
4041 if (info->manifest_info->serviceapplication) {
4042 LISTHEAD(info->manifest_info->serviceapplication, tmp1);
4043 info->manifest_info->serviceapplication = tmp1;
4045 /*Populate localized info for default locales and call callback*/
4046 /*If the callback func return < 0 we break and no more call back is called*/
4049 appinfo->locale = strdup(locale);
4050 appinfo->svcapp_info = tmp1;
4051 memset(query, '\0', MAX_QUERY_LEN);
4052 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
4053 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4054 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4056 memset(query, '\0', MAX_QUERY_LEN);
4057 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
4058 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4059 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4061 if (appinfo->svcapp_info->label) {
4062 LISTHEAD(appinfo->svcapp_info->label, ptr2);
4063 appinfo->svcapp_info->label = ptr2;
4065 if (appinfo->svcapp_info->icon) {
4066 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
4067 appinfo->svcapp_info->icon = ptr1;
4069 if (appinfo->svcapp_info->category) {
4070 LISTHEAD(appinfo->svcapp_info->category, ptr3);
4071 appinfo->svcapp_info->category = ptr3;
4073 if (appinfo->svcapp_info->metadata) {
4074 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
4075 appinfo->svcapp_info->metadata = ptr4;
4077 if (appinfo->svcapp_info->permission) {
4078 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
4079 appinfo->svcapp_info->permission = ptr5;
4081 ret = app_func((void *)appinfo, user_data);
4087 case PMINFO_ALL_APP:
4088 memset(query, '\0', MAX_QUERY_LEN);
4089 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
4091 /*Populate all app info */
4092 ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo);
4093 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
4096 appinfo->app_component = PMINFO_UI_APP;
4097 uiapplication_x *tmp2 = NULL;
4098 if (allinfo->manifest_info->uiapplication) {
4099 LISTHEAD(allinfo->manifest_info->uiapplication, tmp2);
4100 allinfo->manifest_info->uiapplication = tmp2;
4102 /*Populate localized info for default locales and call callback*/
4103 /*If the callback func return < 0 we break and no more call back is called*/
4106 appinfo->locale = strdup(locale);
4107 appinfo->uiapp_info = tmp2;
4108 memset(query, '\0', MAX_QUERY_LEN);
4109 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
4110 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4111 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4113 memset(query, '\0', MAX_QUERY_LEN);
4114 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
4115 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4116 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4118 /*store setting notification icon section*/
4119 memset(query, '\0', MAX_QUERY_LEN);
4120 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
4121 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4122 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4124 /*store app preview image info*/
4125 memset(query, '\0', MAX_QUERY_LEN);
4126 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
4127 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4128 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4130 if (appinfo->uiapp_info->label) {
4131 LISTHEAD(appinfo->uiapp_info->label, ptr2);
4132 appinfo->uiapp_info->label = ptr2;
4134 if (appinfo->uiapp_info->icon) {
4135 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
4136 appinfo->uiapp_info->icon = ptr1;
4138 if (appinfo->uiapp_info->category) {
4139 LISTHEAD(appinfo->uiapp_info->category, ptr3);
4140 appinfo->uiapp_info->category = ptr3;
4142 if (appinfo->uiapp_info->metadata) {
4143 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
4144 appinfo->uiapp_info->metadata = ptr4;
4146 if (appinfo->uiapp_info->permission) {
4147 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
4148 appinfo->uiapp_info->permission = ptr5;
4150 if (appinfo->uiapp_info->image) {
4151 LISTHEAD(appinfo->uiapp_info->image, ptr6);
4152 appinfo->uiapp_info->image = ptr6;
4154 ret = app_func((void *)appinfo, user_data);
4161 appinfo->app_component = PMINFO_SVC_APP;
4162 serviceapplication_x *tmp3 = NULL;
4163 if (allinfo->manifest_info->serviceapplication) {
4164 LISTHEAD(allinfo->manifest_info->serviceapplication, tmp3);
4165 allinfo->manifest_info->serviceapplication = tmp3;
4167 /*Populate localized info for default locales and call callback*/
4168 /*If the callback func return < 0 we break and no more call back is called*/
4171 appinfo->locale = strdup(locale);
4172 appinfo->svcapp_info = tmp3;
4173 memset(query, '\0', MAX_QUERY_LEN);
4174 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
4175 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4176 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4178 memset(query, '\0', MAX_QUERY_LEN);
4179 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
4180 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4181 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4183 if (appinfo->svcapp_info->label) {
4184 LISTHEAD(appinfo->svcapp_info->label, ptr2);
4185 appinfo->svcapp_info->label = ptr2;
4187 if (appinfo->svcapp_info->icon) {
4188 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
4189 appinfo->svcapp_info->icon = ptr1;
4191 if (appinfo->svcapp_info->category) {
4192 LISTHEAD(appinfo->svcapp_info->category, ptr3);
4193 appinfo->svcapp_info->category = ptr3;
4195 if (appinfo->svcapp_info->metadata) {
4196 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
4197 appinfo->svcapp_info->metadata = ptr4;
4199 if (appinfo->svcapp_info->permission) {
4200 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
4201 appinfo->svcapp_info->permission = ptr5;
4203 ret = app_func((void *)appinfo, user_data);
4208 appinfo->app_component = PMINFO_ALL_APP;
4224 if (appinfo->package) {
4225 free((void *)appinfo->package);
4226 appinfo->package = NULL;
4231 __cleanup_pkginfo(allinfo);
4233 sqlite3_close(appinfo_db);
4237 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4239 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4241 int ret = PMINFO_R_OK;
4242 char query[MAX_QUERY_LEN] = {'\0'};
4243 pkgmgr_appinfo_x *appinfo = NULL;
4244 uiapplication_x *ptr1 = NULL;
4245 serviceapplication_x *ptr2 = NULL;
4246 sqlite3 *appinfo_db = NULL;
4249 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
4250 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4253 pkgmgr_pkginfo_x *info = NULL;
4254 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4255 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4257 /*calloc manifest_info*/
4258 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4259 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4262 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4263 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4265 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4266 ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
4267 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4269 if (info->manifest_info->uiapplication) {
4270 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4271 info->manifest_info->uiapplication = ptr1;
4273 if (info->manifest_info->serviceapplication) {
4274 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4275 info->manifest_info->serviceapplication = ptr2;
4279 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4281 appinfo->app_component = PMINFO_UI_APP;
4282 appinfo->package = strdup(ptr1->package);
4283 appinfo->uiapp_info = ptr1;
4285 ret = __appinfo_check_installed_storage(appinfo);
4289 ret = app_func((void *)appinfo, user_data);
4292 free((void *)appinfo->package);
4293 appinfo->package = NULL;
4296 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4298 appinfo->app_component = PMINFO_SVC_APP;
4299 appinfo->package = strdup(ptr2->package);
4300 appinfo->svcapp_info = ptr2;
4302 ret = app_func((void *)appinfo, user_data);
4305 free((void *)appinfo->package);
4306 appinfo->package = NULL;
4311 sqlite3_close(appinfo_db);
4317 __cleanup_pkginfo(info);
4321 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4323 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4325 int ret = PMINFO_R_OK;
4326 char query[MAX_QUERY_LEN] = {'\0'};
4327 char *syslocale = NULL;
4328 char *locale = NULL;
4329 pkgmgr_appinfo_x *appinfo = NULL;
4330 uiapplication_x *ptr1 = NULL;
4331 serviceapplication_x *ptr2 = NULL;
4332 label_x *tmp1 = NULL;
4333 icon_x *tmp2 = NULL;
4334 category_x *tmp3 = NULL;
4335 metadata_x *tmp4 = NULL;
4336 permission_x *tmp5 = NULL;
4337 image_x *tmp6 = NULL;
4338 sqlite3 *appinfo_db = NULL;
4340 /*get system locale*/
4341 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4342 locale = __convert_system_locale_to_manifest_locale(syslocale);
4343 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4346 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
4347 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4350 pkgmgr_pkginfo_x *info = NULL;
4351 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4352 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4354 /*calloc manifest_info*/
4355 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4356 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4359 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4360 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4362 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4363 ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
4364 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4366 if (info->manifest_info->uiapplication) {
4367 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4368 info->manifest_info->uiapplication = ptr1;
4370 if (info->manifest_info->serviceapplication) {
4371 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4372 info->manifest_info->serviceapplication = ptr2;
4376 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4378 appinfo->locale = strdup(locale);
4379 appinfo->app_component = PMINFO_UI_APP;
4380 appinfo->package = strdup(ptr1->package);
4381 appinfo->uiapp_info = ptr1;
4382 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4383 "from package_app_info where " \
4384 "app_id='%s'", ptr1->appid);
4385 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4386 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4388 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
4392 locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
4395 memset(query, '\0', MAX_QUERY_LEN);
4396 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4397 "from package_app_localized_info where " \
4398 "app_id='%s' and app_locale='%s'",
4399 ptr1->appid, locale);
4400 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4401 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4403 memset(query, '\0', MAX_QUERY_LEN);
4404 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4405 "from package_app_localized_info where " \
4406 "app_id='%s' and app_locale='%s'",
4407 ptr1->appid, DEFAULT_LOCALE);
4409 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4410 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4412 /*store setting notification icon section*/
4413 memset(query, '\0', MAX_QUERY_LEN);
4414 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
4415 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4416 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4418 /*store app preview image info*/
4419 memset(query, '\0', MAX_QUERY_LEN);
4420 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
4421 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4422 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4424 if (appinfo->uiapp_info->label) {
4425 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4426 appinfo->uiapp_info->label = tmp1;
4428 if (appinfo->uiapp_info->icon) {
4429 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4430 appinfo->uiapp_info->icon= tmp2;
4432 if (appinfo->uiapp_info->category) {
4433 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4434 appinfo->uiapp_info->category = tmp3;
4436 if (appinfo->uiapp_info->metadata) {
4437 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4438 appinfo->uiapp_info->metadata = tmp4;
4440 if (appinfo->uiapp_info->permission) {
4441 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4442 appinfo->uiapp_info->permission = tmp5;
4444 if (appinfo->uiapp_info->image) {
4445 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4446 appinfo->uiapp_info->image = tmp6;
4449 ret = __appinfo_check_installed_storage(appinfo);
4453 ret = app_func((void *)appinfo, user_data);
4456 free((void *)appinfo->package);
4457 appinfo->package = NULL;
4460 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4462 appinfo->locale = strdup(locale);
4463 appinfo->app_component = PMINFO_SVC_APP;
4464 appinfo->package = strdup(ptr2->package);
4465 appinfo->svcapp_info = ptr2;
4466 memset(query, '\0', MAX_QUERY_LEN);
4467 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4468 "from package_app_info where " \
4469 "app_id='%s'", ptr2->appid);
4470 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4471 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4473 memset(query, '\0', MAX_QUERY_LEN);
4474 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4475 "from package_app_localized_info where " \
4476 "app_id='%s' and app_locale='%s'",
4477 ptr2->appid, locale);
4478 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4479 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4481 memset(query, '\0', MAX_QUERY_LEN);
4482 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4483 "from package_app_localized_info where " \
4484 "app_id='%s' and app_locale='%s'",
4485 ptr2->appid, DEFAULT_LOCALE);
4486 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4487 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4489 if (appinfo->svcapp_info->label) {
4490 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4491 appinfo->svcapp_info->label = tmp1;
4493 if (appinfo->svcapp_info->icon) {
4494 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4495 appinfo->svcapp_info->icon= tmp2;
4497 if (appinfo->svcapp_info->category) {
4498 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4499 appinfo->svcapp_info->category = tmp3;
4501 if (appinfo->svcapp_info->metadata) {
4502 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4503 appinfo->svcapp_info->metadata = tmp4;
4505 if (appinfo->svcapp_info->permission) {
4506 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4507 appinfo->svcapp_info->permission = tmp5;
4509 ret = app_func((void *)appinfo, user_data);
4512 free((void *)appinfo->package);
4513 appinfo->package = NULL;
4526 sqlite3_close(appinfo_db);
4531 __cleanup_pkginfo(info);
4535 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
4537 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
4538 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4540 pkgmgr_appinfo_x *appinfo = NULL;
4541 char *syslocale = NULL;
4542 char *locale = NULL;
4545 label_x *tmp1 = NULL;
4546 icon_x *tmp2 = NULL;
4547 category_x *tmp3 = NULL;
4548 metadata_x *tmp4 = NULL;
4549 permission_x *tmp5 = NULL;
4550 image_x *tmp6 = NULL;
4551 char query[MAX_QUERY_LEN] = {'\0'};
4552 sqlite3 *appinfo_db = NULL;
4555 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
4556 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4558 /*check appid exist on db*/
4559 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
4560 ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
4561 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
4562 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
4564 /*get system locale*/
4565 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4566 locale = __convert_system_locale_to_manifest_locale(syslocale);
4567 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4570 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4571 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
4573 /*check app_component from DB*/
4574 memset(query, '\0', MAX_QUERY_LEN);
4575 snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
4576 ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
4577 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4579 /*calloc app_component*/
4580 if (appinfo->app_component == PMINFO_UI_APP) {
4581 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4582 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
4584 appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
4585 tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
4587 appinfo->locale = strdup(locale);
4589 /*populate app_info from DB*/
4590 memset(query, '\0', MAX_QUERY_LEN);
4591 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
4592 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4593 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4595 memset(query, '\0', MAX_QUERY_LEN);
4596 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
4597 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4598 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4600 /*Also store the values corresponding to default locales*/
4601 memset(query, '\0', MAX_QUERY_LEN);
4602 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
4603 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4604 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4606 /*Populate app category*/
4607 memset(query, '\0', MAX_QUERY_LEN);
4608 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
4609 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4610 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
4612 /*Populate app metadata*/
4613 memset(query, '\0', MAX_QUERY_LEN);
4614 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
4615 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4616 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
4618 /*Populate app permission*/
4619 memset(query, '\0', MAX_QUERY_LEN);
4620 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
4621 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4622 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
4624 /*store setting notification icon section*/
4625 memset(query, '\0', MAX_QUERY_LEN);
4626 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
4627 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4628 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4630 /*store app preview image info*/
4631 memset(query, '\0', MAX_QUERY_LEN);
4632 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
4633 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4634 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4636 ret = __appinfo_check_installed_storage(appinfo);
4637 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "[%s] is installed external, but is not in mmc", appinfo->package);
4639 switch (appinfo->app_component) {
4641 if (appinfo->uiapp_info->label) {
4642 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4643 appinfo->uiapp_info->label = tmp1;
4645 if (appinfo->uiapp_info->icon) {
4646 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4647 appinfo->uiapp_info->icon = tmp2;
4649 if (appinfo->uiapp_info->category) {
4650 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4651 appinfo->uiapp_info->category = tmp3;
4653 if (appinfo->uiapp_info->metadata) {
4654 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4655 appinfo->uiapp_info->metadata = tmp4;
4657 if (appinfo->uiapp_info->permission) {
4658 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4659 appinfo->uiapp_info->permission = tmp5;
4661 if (appinfo->uiapp_info->image) {
4662 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4663 appinfo->uiapp_info->image = tmp6;
4666 case PMINFO_SVC_APP:
4667 if (appinfo->svcapp_info->label) {
4668 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4669 appinfo->svcapp_info->label = tmp1;
4671 if (appinfo->svcapp_info->icon) {
4672 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4673 appinfo->svcapp_info->icon = tmp2;
4675 if (appinfo->svcapp_info->category) {
4676 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4677 appinfo->svcapp_info->category = tmp3;
4679 if (appinfo->svcapp_info->metadata) {
4680 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4681 appinfo->svcapp_info->metadata = tmp4;
4683 if (appinfo->svcapp_info->permission) {
4684 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4685 appinfo->svcapp_info->permission = tmp5;
4695 if (ret == PMINFO_R_OK)
4696 *handle = (void*)appinfo;
4699 __cleanup_appinfo(appinfo);
4702 sqlite3_close(appinfo_db);
4715 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
4717 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4718 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4719 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4721 if (info->app_component == PMINFO_UI_APP)
4722 *appid = (char *)info->uiapp_info->appid;
4723 else if (info->app_component == PMINFO_SVC_APP)
4724 *appid = (char *)info->svcapp_info->appid;
4729 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
4731 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4732 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4733 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4735 *pkg_name = (char *)info->package;
4740 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
4742 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4743 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4744 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4746 *pkgid = (char *)info->package;
4751 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
4753 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4754 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4755 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4757 if (info->app_component == PMINFO_UI_APP)
4758 *exec = (char *)info->uiapp_info->exec;
4759 if (info->app_component == PMINFO_SVC_APP)
4760 *exec = (char *)info->svcapp_info->exec;
4766 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4768 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4769 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4770 char *locale = NULL;
4772 icon_x *start = NULL;
4775 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4776 locale = info->locale;
4777 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4779 if (info->app_component == PMINFO_UI_APP)
4780 start = info->uiapp_info->icon;
4781 if (info->app_component == PMINFO_SVC_APP)
4782 start = info->svcapp_info->icon;
4783 for(ptr = start; ptr != NULL; ptr = ptr->next)
4786 if (strcmp(ptr->lang, locale) == 0) {
4787 *icon = (char *)ptr->text;
4788 if (strcasecmp(*icon, "(null)") == 0) {
4789 locale = DEFAULT_LOCALE;
4793 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4794 *icon = (char *)ptr->text;
4803 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
4805 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4806 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4807 char *locale = NULL;
4808 label_x *ptr = NULL;
4809 label_x *start = NULL;
4812 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4813 locale = info->locale;
4814 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4816 if (info->app_component == PMINFO_UI_APP)
4817 start = info->uiapp_info->label;
4818 if (info->app_component == PMINFO_SVC_APP)
4819 start = info->svcapp_info->label;
4820 for(ptr = start; ptr != NULL; ptr = ptr->next)
4823 if (strcmp(ptr->lang, locale) == 0) {
4824 *label = (char *)ptr->text;
4825 if (strcasecmp(*label, "(null)") == 0) {
4826 locale = DEFAULT_LOCALE;
4830 } else if (strncasecmp(ptr->lang, locale, 2) == 0) {
4831 *label = (char *)ptr->text;
4832 if (strcasecmp(*label, "(null)") == 0) {
4833 locale = DEFAULT_LOCALE;
4837 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4838 *label = (char *)ptr->text;
4847 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
4849 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4850 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4851 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4853 if (info->app_component == PMINFO_UI_APP)
4854 *component = PMINFO_UI_APP;
4855 else if (info->app_component == PMINFO_SVC_APP)
4856 *component = PMINFO_SVC_APP;
4858 return PMINFO_R_ERROR;
4863 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
4865 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4866 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4867 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4869 if (info->app_component == PMINFO_UI_APP)
4870 *app_type = (char *)info->uiapp_info->type;
4871 if (info->app_component == PMINFO_SVC_APP)
4872 *app_type = (char *)info->svcapp_info->type;
4877 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
4878 int *operation_count, char ***operation)
4880 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4881 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4882 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4883 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4884 *operation_count = data->operation_count;
4885 *operation = data->operation;
4889 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
4890 int *uri_count, char ***uri)
4892 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4893 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4894 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4895 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4896 *uri_count = data->uri_count;
4901 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
4902 int *mime_count, char ***mime)
4904 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4905 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4906 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4907 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4908 *mime_count = data->mime_count;
4913 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
4914 int *subapp_count, char ***subapp)
4916 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4917 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4918 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4919 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4920 *subapp_count = data->subapp_count;
4921 *subapp = data->subapp;
4925 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4927 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4928 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4932 icon_x *start = NULL;
4933 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4935 start = info->uiapp_info->icon;
4937 for(ptr = start; ptr != NULL; ptr = ptr->next)
4940 val = (char *)ptr->section;
4941 if (strcmp(val, "setting") == 0){
4942 *icon = (char *)ptr->text;
4951 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4953 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4954 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4958 icon_x *start = NULL;
4959 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4961 start = info->uiapp_info->icon;
4963 for(ptr = start; ptr != NULL; ptr = ptr->next)
4966 val = (char *)ptr->section;
4968 if (strcmp(val, "notification") == 0){
4969 *icon = (char *)ptr->text;
4978 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
4980 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4981 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4983 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4984 val = (char *)info->uiapp_info->recentimage;
4986 if (strcasecmp(val, "capture") == 0)
4987 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
4988 else if (strcasecmp(val, "icon") == 0)
4989 *type = PMINFO_RECENTIMAGE_USE_ICON;
4991 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
4997 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
4999 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5000 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5003 image_x *ptr = NULL;
5004 image_x *start = NULL;
5005 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5007 start = info->uiapp_info->image;
5009 for(ptr = start; ptr != NULL; ptr = ptr->next)
5012 val = (char *)ptr->section;
5014 if (strcmp(val, "preview") == 0)
5015 *preview_img = (char *)ptr->text;
5023 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
5025 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5026 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5029 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5031 if (info->app_component == PMINFO_UI_APP)
5032 val = info->uiapp_info->permission_type;
5033 else if (info->app_component == PMINFO_SVC_APP)
5034 val = info->svcapp_info->permission_type;
5036 return PMINFO_R_ERROR;
5038 if (strcmp(val, "signature") == 0)
5039 *permission = PMINFO_PERMISSION_SIGNATURE;
5040 else if (strcmp(val, "privilege") == 0)
5041 *permission = PMINFO_PERMISSION_PRIVILEGE;
5043 *permission = PMINFO_PERMISSION_NORMAL;
5048 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
5050 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5051 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5052 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5054 *component_type = (char *)info->uiapp_info->component_type;
5059 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
5061 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5062 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5064 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5065 val = (char *)info->uiapp_info->hwacceleration;
5067 if (strcasecmp(val, "not-use-GL") == 0)
5068 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
5069 else if (strcasecmp(val, "use-GL") == 0)
5070 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
5072 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
5077 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
5079 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5080 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5082 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5083 val = (char *)info->uiapp_info->screenreader;
5085 if (strcasecmp(val, "screenreader-off") == 0)
5086 *screenreader = PMINFO_SCREENREADER_OFF;
5087 else if (strcasecmp(val, "screenreader-on") == 0)
5088 *screenreader = PMINFO_SCREENREADER_ON;
5090 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
5095 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
5097 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5098 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5099 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5100 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5102 if (info->app_component == PMINFO_UI_APP){
5103 *portrait_img = (char *)info->uiapp_info->portraitimg;
5104 *landscape_img = (char *)info->uiapp_info->landscapeimg;
5110 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
5112 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5113 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5114 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5116 *submode_mainid = (char *)info->uiapp_info->submode_mainid;
5121 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
5122 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
5124 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5125 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5127 permission_x *ptr = NULL;
5128 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5129 if (info->app_component == PMINFO_UI_APP)
5130 ptr = info->uiapp_info->permission;
5131 else if (info->app_component == PMINFO_SVC_APP)
5132 ptr = info->svcapp_info->permission;
5134 return PMINFO_R_EINVAL;
5135 for (; ptr; ptr = ptr->next) {
5137 ret = permission_func(ptr->value, user_data);
5145 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
5146 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
5148 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5149 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5151 category_x *ptr = NULL;
5152 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5153 if (info->app_component == PMINFO_UI_APP)
5154 ptr = info->uiapp_info->category;
5155 else if (info->app_component == PMINFO_SVC_APP)
5156 ptr = info->svcapp_info->category;
5158 return PMINFO_R_EINVAL;
5159 for (; ptr; ptr = ptr->next) {
5161 ret = category_func(ptr->name, user_data);
5169 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
5170 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
5172 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5173 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5175 metadata_x *ptr = NULL;
5176 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5177 if (info->app_component == PMINFO_UI_APP)
5178 ptr = info->uiapp_info->metadata;
5179 else if (info->app_component == PMINFO_SVC_APP)
5180 ptr = info->svcapp_info->metadata;
5182 return PMINFO_R_EINVAL;
5183 for (; ptr; ptr = ptr->next) {
5185 ret = metadata_func(ptr->key, ptr->value, user_data);
5193 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
5194 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
5196 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5197 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5205 char *manifest = NULL;
5206 char **operation = NULL;
5209 char **subapp = NULL;
5210 appcontrol_x *appcontrol = NULL;
5211 manifest_x *mfx = NULL;
5212 operation_x *op = NULL;
5215 subapp_x *sa = NULL;
5216 pkgmgrinfo_app_component component;
5217 pkgmgrinfo_appcontrol_x *ptr = NULL;
5218 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
5220 _LOGE("Failed to get package name\n");
5221 return PMINFO_R_ERROR;
5223 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
5225 _LOGE("Failed to get app component name\n");
5226 return PMINFO_R_ERROR;
5228 manifest = pkgmgr_parser_get_manifest_file(pkgid);
5229 if (manifest == NULL) {
5230 _LOGE("Failed to fetch package manifest file\n");
5231 return PMINFO_R_ERROR;
5233 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5235 _LOGE("Failed to parse package manifest file\n");
5238 return PMINFO_R_ERROR;
5241 ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
5243 _LOGE("Out of Memory!!!\n");
5244 pkgmgr_parser_free_manifest_xml(mfx);
5245 return PMINFO_R_ERROR;
5247 /*Get Operation, Uri, Mime*/
5248 switch (component) {
5250 if (mfx->uiapplication) {
5251 if (mfx->uiapplication->appsvc) {
5252 appcontrol = mfx->uiapplication->appsvc;
5256 case PMINFO_SVC_APP:
5257 if (mfx->serviceapplication) {
5258 if (mfx->serviceapplication->appsvc) {
5259 appcontrol = mfx->serviceapplication->appsvc;
5266 for (; appcontrol; appcontrol = appcontrol->next) {
5267 op = appcontrol->operation;
5268 for (; op; op = op->next)
5270 op = appcontrol->operation;
5272 ui = appcontrol->uri;
5273 for (; ui; ui = ui->next)
5275 ui = appcontrol->uri;
5277 mi = appcontrol->mime;
5278 for (; mi; mi = mi->next)
5280 mi = appcontrol->mime;
5282 sa = appcontrol->subapp;
5283 for (; sa; sa = sa->next)
5285 sa = appcontrol->subapp;
5287 operation = (char **)calloc(oc, sizeof(char *));
5288 for (i = 0; i < oc; i++) {
5289 operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
5293 uri = (char **)calloc(uc, sizeof(char *));
5294 for (i = 0; i < uc; i++) {
5295 uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
5299 mime = (char **)calloc(mc, sizeof(char *));
5300 for (i = 0; i < mc; i++) {
5301 mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
5305 subapp = (char **)calloc(sc, sizeof(char *));
5306 for (i = 0; i < sc; i++) {
5307 subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
5311 /*populate appcontrol handle*/
5312 ptr->operation_count = oc;
5313 ptr->uri_count = uc;
5314 ptr->mime_count = mc;
5315 ptr->subapp_count = sc;
5316 ptr->operation = operation;
5319 ptr->subapp = subapp;
5321 ret = appcontrol_func((void *)ptr, user_data);
5322 for (i = 0; i < oc; i++) {
5325 operation[i] = NULL;
5332 for (i = 0; i < uc; i++) {
5342 for (i = 0; i < mc; i++) {
5352 for (i = 0; i < sc; i++) {
5369 pkgmgr_parser_free_manifest_xml(mfx);
5377 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
5379 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5380 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5382 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5383 val = (char *)info->uiapp_info->nodisplay;
5385 if (strcasecmp(val, "true") == 0)
5387 else if (strcasecmp(val, "false") == 0)
5395 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
5397 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5398 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5400 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5401 val = (char *)info->uiapp_info->multiple;
5403 if (strcasecmp(val, "true") == 0)
5405 else if (strcasecmp(val, "false") == 0)
5413 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
5415 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5416 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5418 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5419 val = (char *)info->uiapp_info->indicatordisplay;
5421 if (strcasecmp(val, "true") == 0){
5422 *indicator_disp = 1;
5423 }else if (strcasecmp(val, "false") == 0){
5424 *indicator_disp = 0;
5426 *indicator_disp = 0;
5432 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
5434 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5435 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5437 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5438 val = (char *)info->uiapp_info->taskmanage;
5440 if (strcasecmp(val, "true") == 0)
5442 else if (strcasecmp(val, "false") == 0)
5450 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
5452 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5453 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5455 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5456 if (info->app_component == PMINFO_UI_APP)
5457 val = (char *)info->uiapp_info->enabled;
5458 else if (info->app_component == PMINFO_SVC_APP)
5459 val = (char *)info->uiapp_info->enabled;
5461 _LOGE("invalid component type\n");
5462 return PMINFO_R_EINVAL;
5466 if (strcasecmp(val, "true") == 0)
5468 else if (strcasecmp(val, "false") == 0)
5477 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
5479 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5480 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5482 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5483 val = (char *)info->svcapp_info->onboot;
5485 if (strcasecmp(val, "true") == 0)
5487 else if (strcasecmp(val, "false") == 0)
5495 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
5497 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5498 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5500 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5501 val = (char *)info->svcapp_info->autorestart;
5503 if (strcasecmp(val, "true") == 0)
5505 else if (strcasecmp(val, "false") == 0)
5513 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
5515 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5516 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5518 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5519 val = (char *)info->uiapp_info->mainapp;
5521 if (strcasecmp(val, "true") == 0)
5523 else if (strcasecmp(val, "false") == 0)
5531 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
5533 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5534 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5536 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5537 val = (char *)info->uiapp_info->preload;
5539 if (strcasecmp(val, "true") == 0)
5541 else if (strcasecmp(val, "false") == 0)
5549 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
5551 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5552 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5554 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5555 val = (char *)info->uiapp_info->submode;
5557 if (strcasecmp(val, "true") == 0)
5559 else if (strcasecmp(val, "false") == 0)
5567 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
5569 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5570 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5571 __cleanup_appinfo(info);
5575 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
5577 return (pkgmgrinfo_pkginfo_filter_create(handle));
5580 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
5582 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5585 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
5586 const char *property, const int value)
5588 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5589 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5590 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
5592 GSList *link = NULL;
5594 prop = _pminfo_appinfo_convert_to_prop_int(property);
5595 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
5596 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
5597 _LOGE("Invalid Integer Property\n");
5598 return PMINFO_R_EINVAL;
5600 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5601 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5603 _LOGE("Out of Memory!!!\n");
5604 return PMINFO_R_ERROR;
5606 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
5607 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
5609 _LOGE("Out of Memory\n");
5612 return PMINFO_R_ERROR;
5616 /*If API is called multiple times for same property, we should override the previous values.
5617 Last value set will be used for filtering.*/
5618 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5620 filter->list = g_slist_delete_link(filter->list, link);
5621 filter->list = g_slist_append(filter->list, (gpointer)node);
5626 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
5627 const char *property, const bool value)
5629 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5630 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5632 GSList *link = NULL;
5634 prop = _pminfo_appinfo_convert_to_prop_bool(property);
5635 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
5636 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
5637 _LOGE("Invalid Boolean Property\n");
5638 return PMINFO_R_EINVAL;
5640 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5641 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5643 _LOGE("Out of Memory!!!\n");
5644 return PMINFO_R_ERROR;
5647 val = strndup("('true','True')", 15);
5649 val = strndup("('false','False')", 17);
5651 _LOGE("Out of Memory\n");
5654 return PMINFO_R_ERROR;
5658 /*If API is called multiple times for same property, we should override the previous values.
5659 Last value set will be used for filtering.*/
5660 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5662 filter->list = g_slist_delete_link(filter->list, link);
5663 filter->list = g_slist_append(filter->list, (gpointer)node);
5668 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
5669 const char *property, const char *value)
5671 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5672 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5673 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5675 pkgmgrinfo_node_x *ptr = NULL;
5676 char prev[PKG_STRING_LEN_MAX] = {'\0'};
5677 char temp[PKG_STRING_LEN_MAX] = {'\0'};
5678 GSList *link = NULL;
5680 prop = _pminfo_appinfo_convert_to_prop_str(property);
5681 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
5682 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
5683 _LOGE("Invalid String Property\n");
5684 return PMINFO_R_EINVAL;
5686 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5687 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5689 _LOGE("Out of Memory!!!\n");
5690 return PMINFO_R_ERROR;
5694 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
5695 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
5696 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
5698 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
5700 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5702 filter->list = g_slist_delete_link(filter->list, link);
5703 filter->list = g_slist_append(filter->list, (gpointer)node);
5705 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
5706 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
5707 case E_PMINFO_APPINFO_PROP_APP_URI:
5708 case E_PMINFO_APPINFO_PROP_APP_MIME:
5709 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
5711 _LOGE("Out of Memory\n");
5714 return PMINFO_R_ERROR;
5716 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5718 ptr = (pkgmgrinfo_node_x *)link->data;
5719 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
5720 _LOGE("Previous value is %s\n", prev);
5721 filter->list = g_slist_delete_link(filter->list, link);
5722 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
5723 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5724 _LOGE("New value is %s\n", val);
5726 filter->list = g_slist_append(filter->list, (gpointer)node);
5727 memset(temp, '\0', PKG_STRING_LEN_MAX);
5729 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
5730 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5731 _LOGE("First value is %s\n", val);
5733 filter->list = g_slist_append(filter->list, (gpointer)node);
5734 memset(temp, '\0', PKG_STRING_LEN_MAX);
5738 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
5739 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5741 filter->list = g_slist_delete_link(filter->list, link);
5742 filter->list = g_slist_append(filter->list, (gpointer)node);
5748 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
5750 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5751 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5752 char *syslocale = NULL;
5753 char *locale = NULL;
5754 char *condition = NULL;
5755 char query[MAX_QUERY_LEN] = {'\0'};
5756 char where[MAX_QUERY_LEN] = {'\0'};
5759 uiapplication_x *ptr1 = NULL;
5760 serviceapplication_x *ptr2 = NULL;
5761 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5762 sqlite3 *pkginfo_db = NULL;
5763 int filter_count = 0;
5766 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
5767 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
5769 /*get system locale*/
5770 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5771 locale = __convert_system_locale_to_manifest_locale(syslocale);
5772 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
5774 /*Start constructing query*/
5775 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
5776 /*Get where clause*/
5777 for (list = filter->list; list; list = g_slist_next(list)) {
5778 __get_filter_condition(list->data, &condition);
5780 strncat(where, condition, sizeof(where) - strlen(where) -1);
5781 where[sizeof(where) - 1] = '\0';
5785 if (g_slist_next(list)) {
5786 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5787 where[sizeof(where) - 1] = '\0';
5790 _LOGE("where = %s\n", where);
5791 if (strlen(where) > 0) {
5792 strncat(query, where, sizeof(query) - strlen(query) - 1);
5793 query[sizeof(query) - 1] = '\0';
5795 // SECURE_LOGD("query = %s\n", query);
5796 /*To get filtered list*/
5797 pkgmgr_pkginfo_x *info = NULL;
5798 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5799 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5801 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5802 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5804 /*To get detail app info for each member of filtered list*/
5805 pkgmgr_pkginfo_x *filtinfo = NULL;
5806 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5807 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5809 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5810 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5812 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5813 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5815 ret = __exec_db_query(pkginfo_db, query, __app_list_cb, (void *)info);
5816 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5818 memset(query, '\0', MAX_QUERY_LEN);
5819 if (info->manifest_info->uiapplication) {
5820 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5821 info->manifest_info->uiapplication = ptr1;
5823 if (info->manifest_info->serviceapplication) {
5824 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5825 info->manifest_info->serviceapplication = ptr2;
5827 /*Filtered UI Apps*/
5828 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5830 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5831 ptr1->appid, "uiapp");
5832 ret = __exec_db_query(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo);
5833 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5835 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5837 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5838 ptr2->appid, "svcapp");
5839 ret = __exec_db_query(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo);
5840 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5842 if (filtinfo->manifest_info->uiapplication) {
5843 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5844 filtinfo->manifest_info->uiapplication = ptr1;
5846 /*If the callback func return < 0 we break and no more call back is called*/
5849 appinfo->locale = strdup(locale);
5850 appinfo->uiapp_info = ptr1;
5851 appinfo->app_component = PMINFO_UI_APP;
5853 ret = __appinfo_check_installed_storage(appinfo);
5863 /*Filtered Service Apps*/
5864 if (filtinfo->manifest_info->serviceapplication) {
5865 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5866 filtinfo->manifest_info->serviceapplication = ptr2;
5868 /*If the callback func return < 0 we break and no more call back is called*/
5871 appinfo->locale = strdup(locale);
5872 appinfo->svcapp_info = ptr2;
5873 appinfo->app_component = PMINFO_SVC_APP;
5877 *count = filter_count;
5889 sqlite3_close(pkginfo_db);
5894 __cleanup_pkginfo(info);
5895 __cleanup_pkginfo(filtinfo);
5899 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
5900 pkgmgrinfo_app_list_cb app_cb, void * user_data)
5902 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5903 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5904 char *syslocale = NULL;
5905 char *locale = NULL;
5906 char *condition = NULL;
5907 char query[MAX_QUERY_LEN] = {'\0'};
5908 char where[MAX_QUERY_LEN] = {'\0'};
5911 uiapplication_x *ptr1 = NULL;
5912 serviceapplication_x *ptr2 = NULL;
5913 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5914 sqlite3 *pkginfo_db = NULL;
5917 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
5918 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
5920 /*get system locale*/
5921 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5922 locale = __convert_system_locale_to_manifest_locale(syslocale);
5923 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
5925 /*Start constructing query*/
5926 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
5927 /*Get where clause*/
5928 for (list = filter->list; list; list = g_slist_next(list)) {
5929 __get_filter_condition(list->data, &condition);
5931 strncat(where, condition, sizeof(where) - strlen(where) -1);
5932 where[sizeof(where) - 1] = '\0';
5936 if (g_slist_next(list)) {
5937 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5938 where[sizeof(where) - 1] = '\0';
5941 _LOGE("where = %s\n", where);
5942 if (strlen(where) > 0) {
5943 strncat(query, where, sizeof(query) - strlen(query) - 1);
5944 query[sizeof(query) - 1] = '\0';
5946 _LOGE("query = %s\n", query);
5947 /*To get filtered list*/
5948 pkgmgr_pkginfo_x *info = NULL;
5949 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5950 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5952 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5953 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5955 /*To get detail app info for each member of filtered list*/
5956 pkgmgr_pkginfo_x *filtinfo = NULL;
5957 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5958 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5960 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5961 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5963 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5964 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5966 ret = __exec_db_query(pkginfo_db, query, __app_list_cb, (void *)info);
5967 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5969 memset(query, '\0', MAX_QUERY_LEN);
5970 if (info->manifest_info->uiapplication) {
5971 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5972 info->manifest_info->uiapplication = ptr1;
5974 if (info->manifest_info->serviceapplication) {
5975 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5976 info->manifest_info->serviceapplication = ptr2;
5978 /*Filtered UI Apps*/
5979 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5981 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5982 ptr1->appid, "uiapp");
5983 ret = __exec_db_query(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo);
5984 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5986 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5988 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5989 ptr2->appid, "svcapp");
5990 ret = __exec_db_query(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo);
5991 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5993 if (filtinfo->manifest_info->uiapplication) {
5994 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5995 filtinfo->manifest_info->uiapplication = ptr1;
5997 /*If the callback func return < 0 we break and no more call back is called*/
6000 appinfo->locale = strdup(locale);
6001 appinfo->uiapp_info = ptr1;
6002 appinfo->app_component = PMINFO_UI_APP;
6004 ret = __appinfo_check_installed_storage(appinfo);
6010 ret = app_cb((void *)appinfo, user_data);
6015 /*Filtered Service Apps*/
6016 if (filtinfo->manifest_info->serviceapplication) {
6017 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
6018 filtinfo->manifest_info->serviceapplication = ptr2;
6020 /*If the callback func return < 0 we break and no more call back is called*/
6023 appinfo->locale = strdup(locale);
6024 appinfo->svcapp_info = ptr2;
6025 appinfo->app_component = PMINFO_SVC_APP;
6026 ret = app_cb((void *)appinfo, user_data);
6041 sqlite3_close(pkginfo_db);
6046 __cleanup_pkginfo(info);
6047 __cleanup_pkginfo(filtinfo);
6051 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
6053 return (pkgmgrinfo_pkginfo_filter_create(handle));
6056 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
6058 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
6061 API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
6062 const char *key, const char *value)
6064 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
6065 retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
6066 /*value can be NULL. In that case all apps with specified key should be displayed*/
6070 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
6071 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
6072 retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
6074 tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6078 tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6081 /*If API is called multiple times, we should OR all conditions.*/
6082 filter->list = g_slist_append(filter->list, (gpointer)node);
6083 /*All memory will be freed in destroy API*/
6101 API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
6102 pkgmgrinfo_app_list_cb app_cb, void *user_data)
6104 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
6105 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
6106 char *syslocale = NULL;
6107 char *locale = NULL;
6108 char *condition = NULL;
6109 char *error_message = NULL;
6110 char query[MAX_QUERY_LEN] = {'\0'};
6111 char where[MAX_QUERY_LEN] = {'\0'};
6114 pkgmgr_pkginfo_x *info = NULL;
6115 pkgmgr_pkginfo_x *filtinfo = NULL;
6116 pkgmgr_appinfo_x *appinfo = NULL;
6117 uiapplication_x *ptr1 = NULL;
6118 serviceapplication_x *ptr2 = NULL;
6119 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
6120 sqlite3 *pkginfo_db = NULL;
6123 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
6124 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
6126 /*Get current locale*/
6127 syslocale = vconf_get_str(VCONFKEY_LANGSET);
6128 locale = __convert_system_locale_to_manifest_locale(syslocale);
6129 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
6131 /*Start constructing query*/
6132 memset(where, '\0', MAX_QUERY_LEN);
6133 memset(query, '\0', MAX_QUERY_LEN);
6134 snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
6135 /*Get where clause*/
6136 for (list = filter->list; list; list = g_slist_next(list)) {
6137 __get_metadata_filter_condition(list->data, &condition);
6139 strncat(where, condition, sizeof(where) - strlen(where) -1);
6143 if (g_slist_next(list)) {
6144 strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
6147 _LOGE("where = %s (%d)\n", where, strlen(where));
6148 if (strlen(where) > 0) {
6149 strncat(query, where, sizeof(query) - strlen(query) - 1);
6151 _LOGE("query = %s (%d)\n", query, strlen(query));
6152 /*To get filtered list*/
6153 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
6154 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6156 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
6157 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6159 /*To get detail app info for each member of filtered list*/
6160 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
6161 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6163 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
6164 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6166 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
6167 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6169 ret = sqlite3_exec(pkginfo_db, query, __app_list_cb, (void *)info, &error_message);
6170 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
6171 memset(query, '\0', MAX_QUERY_LEN);
6173 if (info->manifest_info->uiapplication) {
6174 LISTHEAD(info->manifest_info->uiapplication, ptr1);
6175 info->manifest_info->uiapplication = ptr1;
6177 if (info->manifest_info->serviceapplication) {
6178 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
6179 info->manifest_info->serviceapplication = ptr2;
6183 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
6185 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
6186 ptr1->appid, "uiapp");
6187 ret = sqlite3_exec(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message);
6188 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
6189 memset(query, '\0', MAX_QUERY_LEN);
6192 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
6194 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
6195 ptr2->appid, "svcapp");
6196 ret = sqlite3_exec(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message);
6197 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
6198 memset(query, '\0', MAX_QUERY_LEN);
6200 /*Filtered UI Apps*/
6201 if (filtinfo->manifest_info->uiapplication) {
6202 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
6203 filtinfo->manifest_info->uiapplication = ptr1;
6205 /*If the callback func return < 0 we break and no more call back is called*/
6208 appinfo->locale = strdup(locale);
6209 appinfo->uiapp_info = ptr1;
6210 appinfo->app_component = PMINFO_UI_APP;
6211 ret = app_cb((void *)appinfo, user_data);
6216 /*Filtered Service Apps*/
6217 if (filtinfo->manifest_info->serviceapplication) {
6218 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
6219 filtinfo->manifest_info->serviceapplication = ptr2;
6221 /*If the callback func return < 0 we break and no more call back is called*/
6224 appinfo->locale = strdup(locale);
6225 appinfo->svcapp_info = ptr2;
6226 appinfo->app_component = PMINFO_SVC_APP;
6227 ret = app_cb((void *)appinfo, user_data);
6242 sqlite3_free(error_message);
6243 sqlite3_close(pkginfo_db);
6248 __cleanup_pkginfo(info);
6249 __cleanup_pkginfo(filtinfo);
6253 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
6255 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6256 pkgmgr_certinfo_x *certinfo = NULL;
6257 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
6258 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
6259 *handle = (void *)certinfo;
6263 API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
6265 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
6266 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
6267 pkgmgr_certinfo_x *certinfo = NULL;
6268 char *error_message = NULL;
6269 int ret = PMINFO_R_OK;
6270 char query[MAX_QUERY_LEN] = {'\0'};
6275 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READONLY, NULL);
6276 if (ret != SQLITE_OK) {
6277 _LOGE("connect db [%s] failed!\n", CERT_DB);
6278 return PMINFO_R_ERROR;
6281 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6283 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6284 _LOGE("Don't execute query = %s error message = %s\n", query,
6286 sqlite3_free(error_message);
6287 ret = PMINFO_R_ERROR;
6291 _LOGE("Package not found in DB\n");
6292 ret = PMINFO_R_ERROR;
6295 certinfo = (pkgmgr_certinfo_x *)handle;
6296 /*populate certinfo from DB*/
6297 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
6298 ret = __exec_certinfo_query(query, (void *)certinfo);
6300 _LOGE("Package Cert Info DB Information retrieval failed\n");
6301 ret = PMINFO_R_ERROR;
6304 for (i = 0; i < MAX_CERT_TYPE; i++) {
6305 memset(query, '\0', MAX_QUERY_LEN);
6306 snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
6307 ret = __exec_certinfo_query(query, (void *)certinfo);
6309 _LOGE("Cert Info DB Information retrieval failed\n");
6310 ret = PMINFO_R_ERROR;
6313 if (certinfo->cert_value) {
6314 (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
6315 free(certinfo->cert_value);
6316 certinfo->cert_value = NULL;
6320 sqlite3_close(cert_db);
6324 API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
6326 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6327 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6328 retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6329 retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6330 pkgmgr_certinfo_x *certinfo = NULL;
6331 certinfo = (pkgmgr_certinfo_x *)handle;
6332 if ((certinfo->cert_info)[cert_type])
6333 *cert_value = (certinfo->cert_info)[cert_type];
6339 API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
6341 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6343 pkgmgr_certinfo_x *certinfo = NULL;
6344 certinfo = (pkgmgr_certinfo_x *)handle;
6345 if (certinfo->pkgid) {
6346 free(certinfo->pkgid);
6347 certinfo->pkgid = NULL;
6349 for (i = 0; i < MAX_CERT_TYPE; i++) {
6350 if ((certinfo->cert_info)[i]) {
6351 free((certinfo->cert_info)[i]);
6352 (certinfo->cert_info)[i] = NULL;
6360 API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
6362 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6363 pkgmgr_instcertinfo_x *certinfo = NULL;
6364 certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
6365 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
6366 *handle = (void *)certinfo;
6370 API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
6372 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6373 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6374 retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6375 retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6376 pkgmgr_instcertinfo_x *certinfo = NULL;
6377 certinfo = (pkgmgr_instcertinfo_x *)handle;
6378 (certinfo->cert_info)[cert_type] = strdup(cert_value);
6382 API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
6384 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
6385 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
6386 char *error_message = NULL;
6387 char query[MAX_QUERY_LEN] = {'\0'};
6388 char *vquery = NULL;
6393 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
6400 pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
6401 pkgmgr_certindexinfo_x *indexinfo = NULL;
6402 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
6403 if (indexinfo == NULL) {
6404 _LOGE("Out of Memory!!!");
6405 return PMINFO_R_ERROR;
6407 info->pkgid = strdup(pkgid);
6410 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL);
6411 if (ret != SQLITE_OK) {
6412 _LOGE("connect db [%s] failed!\n", CERT_DB);
6413 ret = PMINFO_R_ERROR;
6416 /*Begin Transaction*/
6417 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6418 if (ret != SQLITE_OK) {
6419 _LOGE("Failed to begin transaction\n");
6420 ret = PMINFO_R_ERROR;
6423 _LOGE("Transaction Begin\n");
6424 /*Check if request is to insert/update*/
6425 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6427 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6428 _LOGE("Don't execute query = %s error message = %s\n", query,
6430 sqlite3_free(error_message);
6431 ret = PMINFO_R_ERROR;
6436 We cant just issue update query directly. We need to manage index table also.
6437 Hence it is better to delete and insert again in case of update*/
6438 ret = __delete_certinfo(pkgid);
6440 _LOGE("Certificate Deletion Failed\n");
6442 for (i = 0; i < MAX_CERT_TYPE; i++) {
6443 if ((info->cert_info)[i]) {
6444 for (j = 0; j < i; j++) {
6445 if ( (info->cert_info)[j]) {
6446 if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
6447 (info->cert_id)[i] = (info->cert_id)[j];
6448 (info->is_new)[i] = 0;
6449 (info->ref_count)[i] = (info->ref_count)[j];
6456 memset(query, '\0', MAX_QUERY_LEN);
6457 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
6458 "where cert_info='%s'",(info->cert_info)[i]);
6459 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
6461 _LOGE("Cert Info DB Information retrieval failed\n");
6462 ret = PMINFO_R_ERROR;
6465 if (indexinfo->cert_id == 0) {
6466 /*New certificate. Get newid*/
6467 memset(query, '\0', MAX_QUERY_LEN);
6468 snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
6470 sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
6471 _LOGE("Don't execute query = %s error message = %s\n", query,
6473 sqlite3_free(error_message);
6474 ret = PMINFO_R_ERROR;
6482 indexinfo->cert_id = maxid;
6483 indexinfo->cert_ref_count = 1;
6487 (info->cert_id)[i] = indexinfo->cert_id;
6488 (info->is_new)[i] = is_new;
6489 (info->ref_count)[i] = indexinfo->cert_ref_count;
6490 _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
6491 indexinfo->cert_id = 0;
6492 indexinfo->cert_ref_count = 0;
6496 len = MAX_QUERY_LEN;
6497 for (i = 0; i < MAX_CERT_TYPE; i++) {
6498 if ((info->cert_info)[i])
6499 len+= strlen((info->cert_info)[i]);
6501 vquery = (char *)calloc(1, len);
6503 snprintf(vquery, len,
6504 "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
6505 "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
6506 "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
6507 info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
6508 (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
6509 (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
6510 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
6511 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
6513 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6514 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6516 sqlite3_free(error_message);
6517 ret = PMINFO_R_ERROR;
6520 /*Update index table info*/
6521 /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
6522 for (i = 0; i < MAX_CERT_TYPE; i++) {
6523 if ((info->cert_info)[i]) {
6524 memset(vquery, '\0', len);
6525 if ((info->is_new)[i]) {
6526 snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
6527 "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
6528 unique_id[c++] = (info->cert_id)[i];
6531 for (j = 0; j < MAX_CERT_TYPE; j++) {
6532 if ((info->cert_id)[i] == unique_id[j]) {
6533 /*Ref count has already been increased. Just continue*/
6537 if (j == MAX_CERT_TYPE)
6538 unique_id[c++] = (info->cert_id)[i];
6541 snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
6542 "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
6545 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6546 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6548 sqlite3_free(error_message);
6549 ret = PMINFO_R_ERROR;
6554 /*Commit transaction*/
6555 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6556 if (ret != SQLITE_OK) {
6557 _LOGE("Failed to commit transaction, Rollback now\n");
6558 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6559 ret = PMINFO_R_ERROR;
6562 _LOGE("Transaction Commit and End\n");
6565 sqlite3_close(cert_db);
6577 API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
6579 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6581 pkgmgr_instcertinfo_x *certinfo = NULL;
6582 certinfo = (pkgmgr_instcertinfo_x *)handle;
6583 if (certinfo->pkgid) {
6584 free(certinfo->pkgid);
6585 certinfo->pkgid = NULL;
6587 for (i = 0; i < MAX_CERT_TYPE; i++) {
6588 if ((certinfo->cert_info)[i]) {
6589 free((certinfo->cert_info)[i]);
6590 (certinfo->cert_info)[i] = NULL;
6598 API int pkgmgrinfo_delete_certinfo(const char *pkgid)
6600 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6603 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL);
6604 if (ret != SQLITE_OK) {
6605 _LOGE("connect db [%s] failed!\n", CERT_DB);
6606 ret = PMINFO_R_ERROR;
6609 /*Begin Transaction*/
6610 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6611 if (ret != SQLITE_OK) {
6612 _LOGE("Failed to begin transaction\n");
6613 ret = PMINFO_R_ERROR;
6616 _LOGE("Transaction Begin\n");
6617 ret = __delete_certinfo(pkgid);
6619 _LOGE("Certificate Deletion Failed\n");
6621 _LOGE("Certificate Deletion Success\n");
6623 /*Commit transaction*/
6624 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6625 if (ret != SQLITE_OK) {
6626 _LOGE("Failed to commit transaction, Rollback now\n");
6627 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6628 ret = PMINFO_R_ERROR;
6631 _LOGE("Transaction Commit and End\n");
6634 sqlite3_close(cert_db);
6638 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
6640 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
6641 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6643 char *manifest = NULL;
6644 manifest_x *mfx = NULL;
6646 manifest = pkgmgr_parser_get_manifest_file(pkgid);
6647 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
6649 mfx = pkgmgr_parser_process_manifest_xml(manifest);
6654 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
6656 *handle = (void *)mfx;
6661 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
6663 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
6664 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6666 int len = strlen(type);
6667 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6669 manifest_x *mfx = (manifest_x *)handle;
6671 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
6675 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
6677 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
6678 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6680 int len = strlen(version);
6681 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6683 manifest_x *mfx = (manifest_x *)handle;
6685 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
6689 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6691 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6692 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6694 manifest_x *mfx = (manifest_x *)handle;
6696 if (location == INSTALL_INTERNAL)
6697 strcpy(mfx->installlocation, "internal-only");
6698 else if (location == INSTALL_EXTERNAL)
6699 strcpy(mfx->installlocation, "prefer-external");
6704 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
6706 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6707 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6709 manifest_x *mfx = (manifest_x *)handle;
6711 mfx->package_size = strdup(size);
6716 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
6718 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6719 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6721 int len = strlen(label_txt);
6722 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6724 manifest_x *mfx = (manifest_x *)handle;
6726 label_x *label = calloc(1, sizeof(label_x));
6727 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6729 LISTADD(mfx->label, label);
6731 mfx->label->lang = strdup(locale);
6733 mfx->label->lang = strdup(DEFAULT_LOCALE);
6734 mfx->label->text = strdup(label_txt);
6739 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
6741 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6742 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6744 int len = strlen(icon_txt);
6745 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6747 manifest_x *mfx = (manifest_x *)handle;
6749 icon_x *icon = calloc(1, sizeof(icon_x));
6750 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6752 LISTADD(mfx->icon, icon);
6754 mfx->icon->lang = strdup(locale);
6756 mfx->icon->lang = strdup(DEFAULT_LOCALE);
6757 mfx->icon->text = strdup(icon_txt);
6762 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
6764 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6765 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6767 int len = strlen(desc_txt);
6768 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6770 manifest_x *mfx = (manifest_x *)handle;
6772 description_x *description = calloc(1, sizeof(description_x));
6773 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6775 LISTADD(mfx->description, description);
6777 mfx->description->lang = strdup(locale);
6779 mfx->description->lang = strdup(DEFAULT_LOCALE);
6780 mfx->description->text = strdup(desc_txt);
6785 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
6786 const char *author_email, const char *author_href, const char *locale)
6788 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6789 manifest_x *mfx = (manifest_x *)handle;
6790 author_x *author = calloc(1, sizeof(author_x));
6791 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6793 LISTADD(mfx->author, author);
6795 mfx->author->text = strdup(author_name);
6797 mfx->author->email = strdup(author_email);
6799 mfx->author->href = strdup(author_href);
6801 mfx->author->lang = strdup(locale);
6803 mfx->author->lang = strdup(DEFAULT_LOCALE);
6807 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
6809 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6810 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6812 manifest_x *mfx = (manifest_x *)handle;
6815 strcpy(mfx->removable, "false");
6816 else if (removable == 1)
6817 strcpy(mfx->removable, "true");
6822 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
6824 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6825 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6827 manifest_x *mfx = (manifest_x *)handle;
6830 strcpy(mfx->preload, "false");
6831 else if (preload == 1)
6832 strcpy(mfx->preload, "true");
6837 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6839 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6840 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6842 manifest_x *mfx = (manifest_x *)handle;
6844 if (location == INSTALL_INTERNAL)
6845 strcpy(mfx->installed_storage, "installed_internal");
6846 else if (location == INSTALL_EXTERNAL)
6847 strcpy(mfx->installed_storage, "installed_external");
6852 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6854 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6857 manifest_x *mfx = NULL;
6858 mfx = (manifest_x *)handle;
6860 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
6861 retvm_if(ret != 0, PMINFO_R_ERROR, "Failed to store info in DB\n");
6863 ret = __update_ail_appinfo(mfx);
6864 retvm_if(ret != 0, PMINFO_R_ERROR, "Failed to store info in DB\n");
6866 _LOGE("Successfully stored info in DB\n");
6870 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6872 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6874 manifest_x *mfx = NULL;
6875 mfx = (manifest_x *)handle;
6876 pkgmgr_parser_free_manifest_xml(mfx);
6880 API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
6882 /* Should be implemented later */
6886 API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
6888 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6890 char query[MAX_QUERY_LEN] = {'\0'};
6891 sqlite3 *pkginfo_db = NULL;
6893 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
6894 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
6896 /*Begin transaction*/
6897 ret = sqlite3_exec(pkginfo_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6898 if (ret != SQLITE_OK) {
6899 _LOGE("Failed to begin transaction\n");
6900 sqlite3_close(pkginfo_db);
6901 return PMINFO_R_ERROR;
6903 _LOGD("Transaction Begin\n");
6905 memset(query, '\0', MAX_QUERY_LEN);
6906 snprintf(query, MAX_QUERY_LEN,
6907 "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
6909 char *error_message = NULL;
6911 sqlite3_exec(pkginfo_db, query, NULL, NULL, &error_message)) {
6912 _LOGE("Don't execute query = %s error message = %s\n", query,
6914 sqlite3_free(error_message);
6915 return PMINFO_R_ERROR;
6917 sqlite3_free(error_message);
6919 /*Commit transaction*/
6920 ret = sqlite3_exec(pkginfo_db, "COMMIT", NULL, NULL, NULL);
6921 if (ret != SQLITE_OK) {
6922 _LOGE("Failed to commit transaction. Rollback now\n");
6923 sqlite3_exec(pkginfo_db, "ROLLBACK", NULL, NULL, NULL);
6924 sqlite3_close(pkginfo_db);
6925 return PMINFO_R_ERROR;
6927 _LOGD("Transaction Commit and End\n");
6928 sqlite3_close(pkginfo_db);
6934 API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
6936 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6937 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6938 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6939 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6940 int ret = PMINFO_R_OK;
6941 char query[MAX_QUERY_LEN] = {'\0'};
6942 char *error_message = NULL;
6943 pkgmgr_datacontrol_x *data = NULL;
6945 sqlite3 *datacontrol_info_db = NULL;
6948 ret = db_util_open(DATACONTROL_DB, &datacontrol_info_db, 0);
6949 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
6951 data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x));
6953 _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
6954 sqlite3_close(datacontrol_info_db);
6955 return PMINFO_R_ERROR;
6958 snprintf(query, MAX_QUERY_LEN,
6959 "select appinfo.package_name, datacontrol.access from appinfo, datacontrol where datacontrol.id=appinfo.unique_id and datacontrol.provider_id = '%s' and datacontrol.type='%s' COLLATE NOCASE",
6963 sqlite3_exec(datacontrol_info_db, query, __datacontrol_cb, (void *)data, &error_message)) {
6964 _LOGE("Don't execute query = %s error message = %s\n", query,
6966 sqlite3_free(error_message);
6967 sqlite3_close(datacontrol_info_db);
6968 return PMINFO_R_ERROR;
6971 *appid = (char *)data->appid;
6972 *access = (char *)data->access;
6974 sqlite3_close(datacontrol_info_db);
6979 API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
6981 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6983 char query[MAX_QUERY_LEN] = {'\0'};
6984 char *error_message = NULL;
6985 sqlite3 *pkginfo_db = NULL;
6988 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
6989 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
6991 /*Begin transaction*/
6992 ret = sqlite3_exec(pkginfo_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6993 if (ret != SQLITE_OK) {
6994 _LOGE("Failed to begin transaction\n");
6995 sqlite3_close(pkginfo_db);
6996 return PMINFO_R_ERROR;
6998 _LOGD("Transaction Begin\n");
7000 memset(query, '\0', MAX_QUERY_LEN);
7001 snprintf(query, MAX_QUERY_LEN, "update package_app_localized_info set app_label='%s' where app_id='%s'", label, appid);
7003 ret = sqlite3_exec(pkginfo_db, query, NULL, NULL, &error_message);
7004 if (ret != SQLITE_OK) {
7005 _LOGE("Don't execute query = %s error message = %s\n", query, error_message);
7006 sqlite3_free(error_message);
7007 return PMINFO_R_ERROR;
7010 /*Commit transaction*/
7011 ret = sqlite3_exec(pkginfo_db, "COMMIT", NULL, NULL, NULL);
7012 if (ret != SQLITE_OK) {
7013 _LOGE("Failed to commit transaction. Rollback now\n");
7014 sqlite3_exec(pkginfo_db, "ROLLBACK", NULL, NULL, NULL);
7015 sqlite3_close(pkginfo_db);
7016 return PMINFO_R_ERROR;
7018 _LOGD("Transaction Commit and End\n");
7019 sqlite3_close(pkginfo_db);
7024 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
7026 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
7027 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
7029 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
7030 val = (char *)info->uiapp_info->guestmode_visibility;
7032 if (strcasecmp(val, "true") == 0){
7034 }else if (strcasecmp(val, "false") == 0){
7043 API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
7045 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
7048 char *noti_string = NULL;
7050 char query[MAX_QUERY_LEN] = {'\0'};
7051 char *errmsg = NULL;
7052 sqlite3 *pkgmgr_parser_db;
7054 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
7055 val = (char *)info->uiapp_info->guestmode_visibility;
7058 db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db, SQLITE_OPEN_READWRITE, NULL);
7060 if (ret != SQLITE_OK) {
7061 _LOGE("DB Open Failed\n");
7062 return PMINFO_R_ERROR;
7065 /*TODO: Write to DB here*/
7067 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
7069 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
7071 if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
7072 _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
7074 sqlite3_close(pkgmgr_parser_db);
7075 return PMINFO_R_ERROR;
7077 sqlite3_close(pkgmgr_parser_db);
7078 len = strlen((char *)info->uiapp_info->appid) + 8;
7079 noti_string = calloc(1, len);
7080 if (noti_string == NULL){
7081 return PMINFO_R_ERROR;
7083 snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
7084 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
7085 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
7092 /* pkgmgrinfo client start*/
7093 API pkgmgrinfo_client *pkgmgrinfo_client_new(pkgmgrinfo_client_type ctype)
7096 char *errmsg = NULL;
7098 void *handle = NULL;
7099 pkgmgrinfo_client *(*__pkgmgr_client_new)(pkgmgrinfo_client_type ctype) = NULL;
7101 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7102 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7104 __pkgmgr_client_new = dlsym(handle, "pkgmgr_client_new");
7106 tryvm_if((errmsg != NULL) || (__pkgmgr_client_new == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7108 pc = __pkgmgr_client_new(ctype);
7109 tryvm_if(pc == NULL, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7113 return (pkgmgrinfo_client *) pc;
7116 API int pkgmgrinfo_client_set_status_type(pkgmgrinfo_client *pc, int status_type)
7119 char *errmsg = NULL;
7120 void *handle = NULL;
7121 int (*__pkgmgr_client_set_status_type)(pkgmgrinfo_client *pc, int status_type) = NULL;
7123 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7124 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7126 __pkgmgr_client_set_status_type = dlsym(handle, "pkgmgr_client_set_status_type");
7128 tryvm_if((errmsg != NULL) || (__pkgmgr_client_set_status_type == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7130 ret = __pkgmgr_client_set_status_type(pc, status_type);
7131 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7138 API int pkgmgrinfo_client_listen_status(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data)
7141 char *errmsg = NULL;
7142 void *handle = NULL;
7143 int (*__pkgmgr_client_listen_status)(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data) = NULL;
7145 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7146 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7148 __pkgmgr_client_listen_status = dlsym(handle, "pkgmgr_client_listen_status");
7150 tryvm_if((errmsg != NULL) || (__pkgmgr_client_listen_status == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7152 ret = __pkgmgr_client_listen_status(pc, event_cb, data);
7153 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7160 API int pkgmgrinfo_client_free(pkgmgrinfo_client *pc)
7163 char *errmsg = NULL;
7164 void *handle = NULL;
7165 int (*__pkgmgr_client_free)(pkgmgrinfo_client *pc) = NULL;
7167 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7168 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7170 __pkgmgr_client_free = dlsym(handle, "pkgmgr_client_free");
7172 tryvm_if((errmsg != NULL) || (__pkgmgr_client_free == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7174 ret = __pkgmgr_client_free(pc);
7175 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7182 API int pkgmgrinfo_client_request_enable_external_pkg(char *pkgid)
7185 DBusConnection *bus;
7186 DBusMessage *message;
7188 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
7190 if(__get_pkg_location(pkgid) != PMINFO_EXTERNAL_STORAGE)
7193 bus = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
7194 retvm_if(bus == NULL, PMINFO_R_EINVAL, "dbus_bus_get() failed.");
7196 message = dbus_message_new_method_call (SERVICE_NAME, PATH_NAME, INTERFACE_NAME, METHOD_NAME);
7197 retvm_if(message == NULL, PMINFO_R_EINVAL, "dbus_message_new_method_call() failed.");
7199 dbus_message_append_args(message, DBUS_TYPE_STRING, &pkgid, DBUS_TYPE_INVALID);
7201 ret = dbus_connection_send_with_reply_and_block(bus, message, -1, NULL);
7202 retvm_if(!ret, ret = PMINFO_R_EINVAL, "connection_send dbus fail");
7204 dbus_connection_flush(bus);
7205 dbus_message_unref(message);
7210 /* pkgmgrinfo client end*/