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);
2659 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2660 retvm_if(ret < 0, PMINFO_R_ERROR, "get pkgid fail");
2662 *size = __reqeust_get_size(pkgid, PM_GET_TOTAL_SIZE);
2667 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
2669 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2670 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2676 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2677 val = (char *)info->manifest_info->package_size;
2678 if (strcmp(val, "true") == 0) {
2679 *size = atoi(info->manifest_info->package_data_size);
2682 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2683 retvm_if(ret < 0, PMINFO_R_ERROR, "get pkgid fail");
2685 *size = __reqeust_get_size(pkgid, PM_GET_DATA_SIZE);
2690 API int pkgmgrinfo_pkginfo_get_size_info(pkgmgrinfo_pkginfo_h handle, int *total_size, int *data_size)
2692 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2693 retvm_if(total_size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2694 retvm_if(data_size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2701 char* package_size_info = NULL;
2703 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2705 val = (char *)info->manifest_info->package_size;
2706 if (strcmp(val, "true") == 0) {
2707 *total_size = atoi(info->manifest_info->package_total_size);
2708 *data_size = atoi(info->manifest_info->package_data_size);
2711 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2712 retvm_if(ret < 0, PMINFO_R_ERROR, "get pkgid fail");
2714 ret = __reqeust_get_size(pkgid, PM_GET_TOTAL_AND_DATA);
2715 retvm_if(ret < 0, PMINFO_R_ERROR, "fail reqeust size info");
2717 ret = __get_package_size_info(&package_size_info);
2718 retvm_if(ret != 0 || package_size_info == NULL, PMINFO_R_ERROR, "__get_package_size_info() failed");
2720 __get_package_size(package_size_info, pkgid, &total_tmp, &data_tmp);
2721 *total_size = total_tmp;
2722 *data_size = data_tmp;
2724 free(package_size_info);
2730 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
2732 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2733 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2734 int ret = PMINFO_R_OK;
2735 char *locale = NULL;
2739 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2741 locale = info->locale;
2742 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2744 for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next)
2747 if (strcmp(ptr->lang, locale) == 0) {
2748 *icon = (char *)ptr->text;
2749 if (strcasecmp(*icon, "(null)") == 0) {
2750 locale = DEFAULT_LOCALE;
2754 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2755 *icon = (char *)ptr->text;
2764 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
2766 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2767 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2768 int ret = PMINFO_R_OK;
2769 char *locale = NULL;
2770 label_x *ptr = NULL;
2773 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2774 locale = info->locale;
2775 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2777 for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next)
2780 if (strcmp(ptr->lang, locale) == 0) {
2781 *label = (char *)ptr->text;
2782 if (strcasecmp(*label, "(null)") == 0) {
2783 locale = DEFAULT_LOCALE;
2787 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2788 *label = (char *)ptr->text;
2797 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
2799 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2800 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2801 char *locale = NULL;
2802 description_x *ptr = NULL;
2803 *description = NULL;
2805 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2806 locale = info->locale;
2807 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2809 for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next)
2812 if (strcmp(ptr->lang, locale) == 0) {
2813 *description = (char *)ptr->text;
2814 if (strcasecmp(*description, PKGMGR_PARSER_EMPTY_STR) == 0) {
2815 locale = DEFAULT_LOCALE;
2819 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2820 *description = (char *)ptr->text;
2828 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
2830 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2831 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2832 char *locale = NULL;
2833 author_x *ptr = NULL;
2834 *author_name = NULL;
2836 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2837 locale = info->locale;
2838 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2840 for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next)
2843 if (strcmp(ptr->lang, locale) == 0) {
2844 *author_name = (char *)ptr->text;
2845 if (strcasecmp(*author_name, PKGMGR_PARSER_EMPTY_STR) == 0) {
2846 locale = DEFAULT_LOCALE;
2850 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2851 *author_name = (char *)ptr->text;
2859 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
2861 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2862 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2863 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2864 *author_email = (char *)info->manifest_info->author->email;
2868 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
2870 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2871 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2872 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2873 *author_href = (char *)info->manifest_info->author->href;
2877 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
2879 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2880 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2882 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2884 if (strcmp(info->manifest_info->installed_storage,"installed_internal") == 0)
2885 *storage = PMINFO_INTERNAL_STORAGE;
2886 else if (strcmp(info->manifest_info->installed_storage,"installed_external") == 0)
2887 *storage = PMINFO_EXTERNAL_STORAGE;
2889 return PMINFO_R_ERROR;
2894 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
2896 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2897 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2898 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2899 if (info->manifest_info->installed_time)
2900 *installed_time = atoi(info->manifest_info->installed_time);
2902 return PMINFO_R_ERROR;
2907 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
2909 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2910 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2911 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2912 *storeclientid = (char *)info->manifest_info->storeclient_id;
2916 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
2918 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2919 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2920 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2921 *mainappid = (char *)info->manifest_info->mainapp_id;
2925 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
2927 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2928 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2929 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2930 *url = (char *)info->manifest_info->package_url;
2934 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
2936 const char *val = NULL;
2937 const xmlChar *node;
2938 xmlTextReaderPtr reader;
2939 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2940 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2943 reader = xmlReaderForFile(manifest, NULL, 0);
2946 if (__child_element(reader, -1)) {
2947 node = xmlTextReaderConstName(reader);
2949 _LOGE("xmlTextReaderConstName value is NULL\n");
2950 xmlFreeTextReader(reader);
2952 return PMINFO_R_ERROR;
2955 if (!strcmp(ASC_CHAR(node), "manifest")) {
2956 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
2957 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
2963 _LOGE("package size is not specified\n");
2964 xmlFreeTextReader(reader);
2966 return PMINFO_R_ERROR;
2969 _LOGE("Unable to create xml reader\n");
2970 xmlFreeTextReader(reader);
2972 return PMINFO_R_ERROR;
2976 _LOGE("xmlReaderForFile value is NULL\n");
2978 return PMINFO_R_ERROR;
2981 xmlFreeTextReader(reader);
2987 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
2989 const char *val = NULL;
2990 const xmlChar *node;
2991 xmlTextReaderPtr reader;
2992 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2993 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2996 reader = xmlReaderForFile(manifest, NULL, 0);
2999 if ( __child_element(reader, -1)) {
3000 node = xmlTextReaderConstName(reader);
3002 _LOGE("xmlTextReaderConstName value is NULL\n");
3003 xmlFreeTextReader(reader);
3005 return PMINFO_R_ERROR;
3008 if (!strcmp(ASC_CHAR(node), "manifest")) {
3009 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
3010 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
3013 if (strcmp(val, "internal-only") == 0)
3014 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
3015 else if (strcmp(val, "prefer-external") == 0)
3016 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
3018 *location = PMINFO_INSTALL_LOCATION_AUTO;
3021 _LOGE("Unable to create xml reader\n");
3022 xmlFreeTextReader(reader);
3024 return PMINFO_R_ERROR;
3028 _LOGE("xmlReaderForFile value is NULL\n");
3030 return PMINFO_R_ERROR;
3033 xmlFreeTextReader(reader);
3040 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
3042 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3043 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3045 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3046 if (info->manifest_info->root_path)
3047 *path = (char *)info->manifest_info->root_path;
3049 return PMINFO_R_ERROR;
3054 API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
3056 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3057 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3059 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3060 if (info->manifest_info->csc_path)
3061 *path = (char *)info->manifest_info->csc_path;
3063 *path = (char *)info->manifest_info->csc_path;
3068 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)
3070 retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
3071 retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
3072 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3074 int ret = PMINFO_R_OK;
3075 char query[MAX_QUERY_LEN] = {'\0'};
3076 char *error_message = NULL;
3077 pkgmgr_cert_x *info= NULL;
3081 *compare_result = PMINFO_CERT_COMPARE_ERROR;
3082 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3083 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3085 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READONLY, NULL);
3086 if (ret != SQLITE_OK) {
3087 _LOGE("connect db [%s] failed!\n", CERT_DB);
3088 ret = PMINFO_R_ERROR;
3092 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
3094 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
3095 _LOGE("Don't execute query = %s error message = %s\n", query,
3097 ret = PMINFO_R_ERROR;
3104 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
3106 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
3107 _LOGE("Don't execute query = %s error message = %s\n", query,
3109 ret = PMINFO_R_ERROR;
3112 lcert = info->cert_id;
3115 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
3117 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
3118 _LOGE("Don't execute query = %s error message = %s\n", query,
3120 ret = PMINFO_R_ERROR;
3127 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
3129 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
3130 _LOGE("Don't execute query = %s error message = %s\n", query,
3132 ret = PMINFO_R_ERROR;
3135 rcert = info->cert_id;
3138 if ((lcert == 0) || (rcert == 0))
3140 if ((lcert == 0) && (rcert == 0))
3141 *compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
3142 else if (lcert == 0)
3143 *compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
3144 else if (rcert == 0)
3145 *compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
3148 *compare_result = PMINFO_CERT_COMPARE_MATCH;
3150 *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
3154 sqlite3_free(error_message);
3155 sqlite3_close(cert_db);
3168 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)
3170 retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
3171 retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
3172 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3174 int ret = PMINFO_R_OK;
3175 char query[MAX_QUERY_LEN] = {'\0'};
3176 char *error_message = NULL;
3177 pkgmgr_cert_x *info= NULL;
3179 char *lpkgid = NULL;
3180 char *rpkgid = NULL;
3181 sqlite3 *pkginfo_db = NULL;
3183 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3184 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3186 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3187 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3189 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
3191 sqlite3_exec(pkginfo_db, query, __validate_cb, (void *)&exist, &error_message)) {
3192 _LOGE("Don't execute query = %s error message = %s\n", query,
3194 ret = PMINFO_R_ERROR;
3201 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
3203 sqlite3_exec(pkginfo_db, query, __cert_cb, (void *)info, &error_message)) {
3204 _LOGE("Don't execute query = %s error message = %s\n", query,
3206 ret = PMINFO_R_ERROR;
3209 lpkgid = strdup(info->pkgid);
3210 if (lpkgid == NULL) {
3211 _LOGE("Out of Memory\n");
3212 ret = PMINFO_R_ERROR;
3219 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
3221 sqlite3_exec(pkginfo_db, query, __validate_cb, (void *)&exist, &error_message)) {
3222 _LOGE("Don't execute query = %s error message = %s\n", query,
3224 ret = PMINFO_R_ERROR;
3231 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
3233 sqlite3_exec(pkginfo_db, query, __cert_cb, (void *)info, &error_message)) {
3234 _LOGE("Don't execute query = %s error message = %s\n", query,
3236 ret = PMINFO_R_ERROR;
3239 rpkgid = strdup(info->pkgid);
3240 if (rpkgid == NULL) {
3241 _LOGE("Out of Memory\n");
3242 ret = PMINFO_R_ERROR;
3248 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
3251 sqlite3_free(error_message);
3252 sqlite3_close(pkginfo_db);
3272 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
3274 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3275 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3277 #if 0 //smack issue occured, check later
3279 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
3281 _LOGD("invalid func parameters\n");
3282 return PMINFO_R_ERROR;
3284 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
3287 char app_mmc_path[FILENAME_MAX] = { 0, };
3288 char app_dir_path[FILENAME_MAX] = { 0, };
3289 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
3290 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
3291 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
3292 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
3294 /*check whether application is in external memory or not */
3295 fp = fopen(app_mmc_path, "r");
3297 _LOGD(" app path in external memory not accesible\n");
3302 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
3306 /*check whether application is in internal or not */
3307 fp = fopen(app_dir_path, "r");
3309 _LOGD(" app path in internal memory not accesible\n");
3311 return PMINFO_R_ERROR;
3314 /*check whether the application is installed in SD card
3315 but SD card is not present*/
3316 fp = fopen(app_mmc_internal_path, "r");
3319 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
3324 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
3329 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
3336 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
3338 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3339 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3341 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3342 val = (char *)info->manifest_info->removable;
3344 if (strcasecmp(val, "true") == 0)
3346 else if (strcasecmp(val, "false") == 0)
3354 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
3356 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3357 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3360 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3362 val = (char *)info->manifest_info->installlocation;
3364 if (strcmp(val, "internal-only") == 0)
3366 else if (strcmp(val, "prefer-external") == 0)
3375 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
3377 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3378 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3380 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3381 val = (char *)info->manifest_info->preload;
3383 if (strcasecmp(val, "true") == 0)
3385 else if (strcasecmp(val, "false") == 0)
3393 API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
3395 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3396 retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3399 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3400 val = (char *)info->manifest_info->system;
3402 if (strcasecmp(val, "true") == 0)
3404 else if (strcasecmp(val, "false") == 0)
3413 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
3415 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3416 retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3418 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3419 val = (char *)info->manifest_info->readonly;
3421 if (strcasecmp(val, "true") == 0)
3423 else if (strcasecmp(val, "false") == 0)
3431 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
3433 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3434 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3437 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3438 val = (char *)info->manifest_info->update;
3440 if (strcasecmp(val, "true") == 0)
3442 else if (strcasecmp(val, "false") == 0)
3450 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
3452 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3453 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3454 __cleanup_pkginfo(info);
3458 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
3460 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
3462 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
3463 if (filter == NULL) {
3464 _LOGE("Out of Memory!!!");
3465 return PMINFO_R_ERROR;
3471 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
3473 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3474 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3476 g_slist_foreach(filter->list, __destroy_each_node, NULL);
3477 g_slist_free(filter->list);
3482 if (access(PKG_SIZE_INFO_FILE, F_OK) == 0) {
3483 char info_file[PKG_VALUE_STRING_LEN_MAX] = { 0, };
3484 snprintf(info_file, PKG_VALUE_STRING_LEN_MAX, "%s", PKG_SIZE_INFO_FILE);
3491 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
3492 const char *property, const int value)
3494 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3495 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3496 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3498 GSList *link = NULL;
3500 prop = _pminfo_pkginfo_convert_to_prop_int(property);
3501 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
3502 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
3503 _LOGE("Invalid Integer Property\n");
3504 return PMINFO_R_EINVAL;
3506 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3507 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3509 _LOGE("Out of Memory!!!\n");
3510 return PMINFO_R_ERROR;
3512 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3513 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3515 _LOGE("Out of Memory\n");
3518 return PMINFO_R_ERROR;
3522 /*If API is called multiple times for same property, we should override the previous values.
3523 Last value set will be used for filtering.*/
3524 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3526 filter->list = g_slist_delete_link(filter->list, link);
3527 filter->list = g_slist_append(filter->list, (gpointer)node);
3532 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
3533 const char *property, const bool value)
3535 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3536 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3538 GSList *link = NULL;
3540 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
3541 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
3542 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
3543 _LOGE("Invalid Boolean Property\n");
3544 return PMINFO_R_EINVAL;
3546 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3547 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3549 _LOGE("Out of Memory!!!\n");
3550 return PMINFO_R_ERROR;
3553 val = strndup("('true','True')", 15);
3555 val = strndup("('false','False')", 17);
3557 _LOGE("Out of Memory\n");
3560 return PMINFO_R_ERROR;
3564 /*If API is called multiple times for same property, we should override the previous values.
3565 Last value set will be used for filtering.*/
3566 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3568 filter->list = g_slist_delete_link(filter->list, link);
3569 filter->list = g_slist_append(filter->list, (gpointer)node);
3574 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
3575 const char *property, const char *value)
3577 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3578 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3579 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3581 GSList *link = NULL;
3583 prop = _pminfo_pkginfo_convert_to_prop_str(property);
3584 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
3585 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
3586 _LOGE("Invalid String Property\n");
3587 return PMINFO_R_EINVAL;
3589 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3590 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3592 _LOGE("Out of Memory!!!\n");
3593 return PMINFO_R_ERROR;
3595 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
3596 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
3597 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
3598 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
3599 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
3600 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
3601 else if (strcmp(value, "installed_internal") == 0)
3602 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
3603 else if (strcmp(value, "installed_external") == 0)
3604 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
3606 val = strndup(value, PKG_STRING_LEN_MAX - 1);
3608 _LOGE("Out of Memory\n");
3611 return PMINFO_R_ERROR;
3615 /*If API is called multiple times for same property, we should override the previous values.
3616 Last value set will be used for filtering.*/
3617 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3619 filter->list = g_slist_delete_link(filter->list, link);
3620 filter->list = g_slist_append(filter->list, (gpointer)node);
3625 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
3627 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3628 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3629 char *syslocale = NULL;
3630 char *locale = NULL;
3631 char *condition = NULL;
3632 char query[MAX_QUERY_LEN] = {'\0'};
3633 char where[MAX_QUERY_LEN] = {'\0'};
3636 pkgmgr_pkginfo_x *node = NULL;
3637 pkgmgr_pkginfo_x *tmphead = NULL;
3638 pkgmgr_pkginfo_x *pkginfo = NULL;
3639 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3640 sqlite3 *pkginfo_db = NULL;
3641 int filter_count = 0;
3644 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3645 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3647 /*get system locale*/
3648 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3649 locale = __convert_system_locale_to_manifest_locale(syslocale);
3650 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
3652 /*Start constructing query*/
3653 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
3655 /*Get where clause*/
3656 for (list = filter->list; list; list = g_slist_next(list)) {
3657 __get_filter_condition(list->data, &condition);
3659 strncat(where, condition, sizeof(where) - strlen(where) -1);
3660 where[sizeof(where) - 1] = '\0';
3664 if (g_slist_next(list)) {
3665 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3666 where[sizeof(where) - 1] = '\0';
3669 _LOGE("where = %s\n", where);
3670 if (strlen(where) > 0) {
3671 strncat(query, where, sizeof(query) - strlen(query) - 1);
3672 query[sizeof(query) - 1] = '\0';
3674 _LOGE("query = %s\n", query);
3676 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
3677 tryvm_if(tmphead == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3679 ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead);
3680 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3682 LISTHEAD(tmphead, node);
3683 for(node = node->next ; node ; node = node->next) {
3685 pkginfo->locale = strdup(locale);
3686 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
3687 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info\n");
3689 /*populate manifest_info from DB*/
3690 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
3691 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3692 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3694 memset(query, '\0', MAX_QUERY_LEN);
3695 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3696 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
3697 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3698 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3700 /*Also store the values corresponding to default locales*/
3701 memset(query, '\0', MAX_QUERY_LEN);
3702 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3703 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
3704 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3705 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3708 LISTHEAD(tmphead, node);
3710 for(node = node->next ; node ; node = node->next) {
3712 ret = __pkginfo_check_installed_storage(pkginfo);
3718 *count = filter_count;
3730 sqlite3_close(pkginfo_db);
3731 __cleanup_pkginfo(tmphead);
3735 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
3736 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
3738 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3739 retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3740 char *syslocale = NULL;
3741 char *locale = NULL;
3742 char *condition = NULL;
3743 char query[MAX_QUERY_LEN] = {'\0'};
3744 char where[MAX_QUERY_LEN] = {'\0'};
3747 label_x *tmp1 = NULL;
3748 icon_x *tmp2 = NULL;
3749 description_x *tmp3 = NULL;
3750 author_x *tmp4 = NULL;
3751 privilege_x *tmp5 = NULL;
3752 pkgmgr_pkginfo_x *node = NULL;
3753 pkgmgr_pkginfo_x *tmphead = NULL;
3754 pkgmgr_pkginfo_x *pkginfo = NULL;
3755 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3756 sqlite3 *pkginfo_db = NULL;
3757 const char* package_size_info = NULL;
3758 bool is_setting = false;
3761 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3762 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3764 /*get system locale*/
3765 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3766 locale = __convert_system_locale_to_manifest_locale(syslocale);
3767 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
3769 /*Start constructing query*/
3770 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
3772 /*Get where clause*/
3773 for (list = filter->list; list; list = g_slist_next(list)) {
3774 __get_filter_condition(list->data, &condition);
3776 strncat(where, condition, sizeof(where) - strlen(where) -1);
3777 where[sizeof(where) - 1] = '\0';
3779 if (strstr(condition, "package_info.package_nodisplay"))
3785 if (g_slist_next(list)) {
3786 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3787 where[sizeof(where) - 1] = '\0';
3790 _LOGE("where = %s\n", where);
3791 if (strlen(where) > 0) {
3792 strncat(query, where, sizeof(query) - strlen(query) - 1);
3793 query[sizeof(query) - 1] = '\0';
3795 _LOGE("query = %s\n", query);
3797 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
3798 tryvm_if(tmphead == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3800 ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead);
3801 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3804 ret = __reqeust_get_size("size_info", PM_GET_SIZE_INFO);
3805 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "fail reqeust size info");
3807 ret = __get_package_size_info(&package_size_info);
3808 tryvm_if(ret != 0 || package_size_info == NULL, ret = PMINFO_R_ERROR, "__get_package_size_info() failed");
3809 _LOGD("is_setting is true, get package size info success!! ");
3812 LISTHEAD(tmphead, node);
3813 for(node = node->next ; node ; node = node->next) {
3815 pkginfo->locale = strdup(locale);
3816 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
3817 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info\n");
3819 /*populate manifest_info from DB*/
3820 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
3821 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3822 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3824 memset(query, '\0', MAX_QUERY_LEN);
3825 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3826 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
3827 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3828 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3830 /*Also store the values corresponding to default locales*/
3831 memset(query, '\0', MAX_QUERY_LEN);
3832 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3833 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
3834 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3835 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3837 if (pkginfo->manifest_info->label) {
3838 LISTHEAD(pkginfo->manifest_info->label, tmp1);
3839 pkginfo->manifest_info->label = tmp1;
3841 if (pkginfo->manifest_info->icon) {
3842 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
3843 pkginfo->manifest_info->icon = tmp2;
3845 if (pkginfo->manifest_info->description) {
3846 LISTHEAD(pkginfo->manifest_info->description, tmp3);
3847 pkginfo->manifest_info->description = tmp3;
3849 if (pkginfo->manifest_info->author) {
3850 LISTHEAD(pkginfo->manifest_info->author, tmp4);
3851 pkginfo->manifest_info->author = tmp4;
3853 if (pkginfo->manifest_info->privileges->privilege) {
3854 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
3855 pkginfo->manifest_info->privileges->privilege = tmp5;
3858 __set_package_size_info(pkginfo->manifest_info, package_size_info);
3862 LISTHEAD(tmphead, node);
3864 for(node = node->next ; node ; node = node->next) {
3867 ret = __pkginfo_check_installed_storage(pkginfo);
3871 ret = pkg_cb( (void *)pkginfo, user_data);
3886 if (package_size_info) {
3887 free(package_size_info);
3890 sqlite3_close(pkginfo_db);
3891 __cleanup_pkginfo(tmphead);
3895 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
3896 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
3898 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3899 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3901 privilege_x *ptr = NULL;
3902 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3903 ptr = info->manifest_info->privileges->privilege;
3904 for (; ptr; ptr = ptr->next) {
3906 ret = privilege_func(ptr->text, user_data);
3914 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
3915 pkgmgrinfo_app_list_cb app_func, void *user_data)
3917 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3918 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
3919 retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
3921 char *syslocale = NULL;
3922 char *locale = NULL;
3924 char query[MAX_QUERY_LEN] = {'\0'};
3925 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3926 pkgmgr_pkginfo_x *allinfo = NULL;
3927 pkgmgr_appinfo_x *appinfo = NULL;
3928 icon_x *ptr1 = NULL;
3929 label_x *ptr2 = NULL;
3930 category_x *ptr3 = NULL;
3931 metadata_x *ptr4 = NULL;
3932 permission_x *ptr5 = NULL;
3933 image_x *ptr6 = NULL;
3934 sqlite3 *appinfo_db = NULL;
3936 /*check installed storage*/
3937 ret = __pkginfo_check_installed_storage(info);
3938 retvm_if(ret < 0, PMINFO_R_EINVAL, "[%s] is installed external, but is not in mmc", info->manifest_info->package);
3940 /*get system locale*/
3941 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3942 locale = __convert_system_locale_to_manifest_locale(syslocale);
3943 tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
3946 allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
3947 tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3949 /*calloc manifest_info*/
3950 allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
3951 tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
3954 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
3955 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3957 /*set component type*/
3958 if (component == PMINFO_UI_APP)
3959 appinfo->app_component = PMINFO_UI_APP;
3960 if (component == PMINFO_SVC_APP)
3961 appinfo->app_component = PMINFO_SVC_APP;
3962 if (component == PMINFO_ALL_APP)
3963 appinfo->app_component = PMINFO_ALL_APP;
3966 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
3967 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3969 appinfo->package = strdup(info->manifest_info->package);
3970 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
3971 "from package_app_info where " \
3972 "package='%s' and app_component='%s'",
3973 info->manifest_info->package,
3974 (appinfo->app_component==PMINFO_UI_APP ? "uiapp" : "svcapp"));
3978 /*Populate ui app info */
3979 ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
3980 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3982 uiapplication_x *tmp = NULL;
3983 if (info->manifest_info->uiapplication) {
3984 LISTHEAD(info->manifest_info->uiapplication, tmp);
3985 info->manifest_info->uiapplication = tmp;
3987 /*Populate localized info for default locales and call callback*/
3988 /*If the callback func return < 0 we break and no more call back is called*/
3991 appinfo->locale = strdup(locale);
3992 appinfo->uiapp_info = tmp;
3993 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
3997 locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
4000 memset(query, '\0', MAX_QUERY_LEN);
4001 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
4002 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4003 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4005 memset(query, '\0', MAX_QUERY_LEN);
4006 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);
4007 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4008 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4010 /*store setting notification icon section*/
4011 memset(query, '\0', MAX_QUERY_LEN);
4012 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
4013 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4014 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4016 /*store app preview image info*/
4017 memset(query, '\0', MAX_QUERY_LEN);
4018 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
4019 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4020 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4022 if (appinfo->uiapp_info->label) {
4023 LISTHEAD(appinfo->uiapp_info->label, ptr2);
4024 appinfo->uiapp_info->label = ptr2;
4026 if (appinfo->uiapp_info->icon) {
4027 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
4028 appinfo->uiapp_info->icon = ptr1;
4030 if (appinfo->uiapp_info->category) {
4031 LISTHEAD(appinfo->uiapp_info->category, ptr3);
4032 appinfo->uiapp_info->category = ptr3;
4034 if (appinfo->uiapp_info->metadata) {
4035 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
4036 appinfo->uiapp_info->metadata = ptr4;
4038 if (appinfo->uiapp_info->permission) {
4039 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
4040 appinfo->uiapp_info->permission = ptr5;
4042 if (appinfo->uiapp_info->image) {
4043 LISTHEAD(appinfo->uiapp_info->image, ptr6);
4044 appinfo->uiapp_info->image = ptr6;
4046 ret = app_func((void *)appinfo, user_data);
4052 case PMINFO_SVC_APP:
4053 /*Populate svc app info */
4054 ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
4055 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
4057 serviceapplication_x *tmp1 = NULL;
4058 if (info->manifest_info->serviceapplication) {
4059 LISTHEAD(info->manifest_info->serviceapplication, tmp1);
4060 info->manifest_info->serviceapplication = tmp1;
4062 /*Populate localized info for default locales and call callback*/
4063 /*If the callback func return < 0 we break and no more call back is called*/
4066 appinfo->locale = strdup(locale);
4067 appinfo->svcapp_info = tmp1;
4068 memset(query, '\0', MAX_QUERY_LEN);
4069 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
4070 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4071 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4073 memset(query, '\0', MAX_QUERY_LEN);
4074 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);
4075 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4076 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4078 if (appinfo->svcapp_info->label) {
4079 LISTHEAD(appinfo->svcapp_info->label, ptr2);
4080 appinfo->svcapp_info->label = ptr2;
4082 if (appinfo->svcapp_info->icon) {
4083 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
4084 appinfo->svcapp_info->icon = ptr1;
4086 if (appinfo->svcapp_info->category) {
4087 LISTHEAD(appinfo->svcapp_info->category, ptr3);
4088 appinfo->svcapp_info->category = ptr3;
4090 if (appinfo->svcapp_info->metadata) {
4091 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
4092 appinfo->svcapp_info->metadata = ptr4;
4094 if (appinfo->svcapp_info->permission) {
4095 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
4096 appinfo->svcapp_info->permission = ptr5;
4098 ret = app_func((void *)appinfo, user_data);
4104 case PMINFO_ALL_APP:
4105 memset(query, '\0', MAX_QUERY_LEN);
4106 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
4108 /*Populate all app info */
4109 ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo);
4110 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
4113 appinfo->app_component = PMINFO_UI_APP;
4114 uiapplication_x *tmp2 = NULL;
4115 if (allinfo->manifest_info->uiapplication) {
4116 LISTHEAD(allinfo->manifest_info->uiapplication, tmp2);
4117 allinfo->manifest_info->uiapplication = tmp2;
4119 /*Populate localized info for default locales and call callback*/
4120 /*If the callback func return < 0 we break and no more call back is called*/
4123 appinfo->locale = strdup(locale);
4124 appinfo->uiapp_info = tmp2;
4125 memset(query, '\0', MAX_QUERY_LEN);
4126 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
4127 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4128 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4130 memset(query, '\0', MAX_QUERY_LEN);
4131 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);
4132 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4133 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4135 /*store setting notification icon section*/
4136 memset(query, '\0', MAX_QUERY_LEN);
4137 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
4138 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4139 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4141 /*store app preview image info*/
4142 memset(query, '\0', MAX_QUERY_LEN);
4143 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
4144 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4145 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4147 if (appinfo->uiapp_info->label) {
4148 LISTHEAD(appinfo->uiapp_info->label, ptr2);
4149 appinfo->uiapp_info->label = ptr2;
4151 if (appinfo->uiapp_info->icon) {
4152 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
4153 appinfo->uiapp_info->icon = ptr1;
4155 if (appinfo->uiapp_info->category) {
4156 LISTHEAD(appinfo->uiapp_info->category, ptr3);
4157 appinfo->uiapp_info->category = ptr3;
4159 if (appinfo->uiapp_info->metadata) {
4160 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
4161 appinfo->uiapp_info->metadata = ptr4;
4163 if (appinfo->uiapp_info->permission) {
4164 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
4165 appinfo->uiapp_info->permission = ptr5;
4167 if (appinfo->uiapp_info->image) {
4168 LISTHEAD(appinfo->uiapp_info->image, ptr6);
4169 appinfo->uiapp_info->image = ptr6;
4171 ret = app_func((void *)appinfo, user_data);
4178 appinfo->app_component = PMINFO_SVC_APP;
4179 serviceapplication_x *tmp3 = NULL;
4180 if (allinfo->manifest_info->serviceapplication) {
4181 LISTHEAD(allinfo->manifest_info->serviceapplication, tmp3);
4182 allinfo->manifest_info->serviceapplication = tmp3;
4184 /*Populate localized info for default locales and call callback*/
4185 /*If the callback func return < 0 we break and no more call back is called*/
4188 appinfo->locale = strdup(locale);
4189 appinfo->svcapp_info = tmp3;
4190 memset(query, '\0', MAX_QUERY_LEN);
4191 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
4192 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4193 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4195 memset(query, '\0', MAX_QUERY_LEN);
4196 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);
4197 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4198 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4200 if (appinfo->svcapp_info->label) {
4201 LISTHEAD(appinfo->svcapp_info->label, ptr2);
4202 appinfo->svcapp_info->label = ptr2;
4204 if (appinfo->svcapp_info->icon) {
4205 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
4206 appinfo->svcapp_info->icon = ptr1;
4208 if (appinfo->svcapp_info->category) {
4209 LISTHEAD(appinfo->svcapp_info->category, ptr3);
4210 appinfo->svcapp_info->category = ptr3;
4212 if (appinfo->svcapp_info->metadata) {
4213 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
4214 appinfo->svcapp_info->metadata = ptr4;
4216 if (appinfo->svcapp_info->permission) {
4217 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
4218 appinfo->svcapp_info->permission = ptr5;
4220 ret = app_func((void *)appinfo, user_data);
4225 appinfo->app_component = PMINFO_ALL_APP;
4241 if (appinfo->package) {
4242 free((void *)appinfo->package);
4243 appinfo->package = NULL;
4248 __cleanup_pkginfo(allinfo);
4250 sqlite3_close(appinfo_db);
4254 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4256 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4258 int ret = PMINFO_R_OK;
4259 char query[MAX_QUERY_LEN] = {'\0'};
4260 pkgmgr_appinfo_x *appinfo = NULL;
4261 uiapplication_x *ptr1 = NULL;
4262 serviceapplication_x *ptr2 = NULL;
4263 sqlite3 *appinfo_db = NULL;
4266 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
4267 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4270 pkgmgr_pkginfo_x *info = NULL;
4271 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4272 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4274 /*calloc manifest_info*/
4275 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4276 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4279 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4280 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4282 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4283 ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
4284 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4286 if (info->manifest_info->uiapplication) {
4287 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4288 info->manifest_info->uiapplication = ptr1;
4290 if (info->manifest_info->serviceapplication) {
4291 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4292 info->manifest_info->serviceapplication = ptr2;
4296 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4298 appinfo->app_component = PMINFO_UI_APP;
4299 appinfo->package = strdup(ptr1->package);
4300 appinfo->uiapp_info = ptr1;
4302 ret = __appinfo_check_installed_storage(appinfo);
4306 ret = app_func((void *)appinfo, user_data);
4309 free((void *)appinfo->package);
4310 appinfo->package = NULL;
4313 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4315 appinfo->app_component = PMINFO_SVC_APP;
4316 appinfo->package = strdup(ptr2->package);
4317 appinfo->svcapp_info = ptr2;
4319 ret = app_func((void *)appinfo, user_data);
4322 free((void *)appinfo->package);
4323 appinfo->package = NULL;
4328 sqlite3_close(appinfo_db);
4334 __cleanup_pkginfo(info);
4338 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4340 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4342 int ret = PMINFO_R_OK;
4343 char query[MAX_QUERY_LEN] = {'\0'};
4344 char *syslocale = NULL;
4345 char *locale = NULL;
4346 pkgmgr_appinfo_x *appinfo = NULL;
4347 uiapplication_x *ptr1 = NULL;
4348 serviceapplication_x *ptr2 = NULL;
4349 label_x *tmp1 = NULL;
4350 icon_x *tmp2 = NULL;
4351 category_x *tmp3 = NULL;
4352 metadata_x *tmp4 = NULL;
4353 permission_x *tmp5 = NULL;
4354 image_x *tmp6 = NULL;
4355 sqlite3 *appinfo_db = NULL;
4357 /*get system locale*/
4358 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4359 locale = __convert_system_locale_to_manifest_locale(syslocale);
4360 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4363 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
4364 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4367 pkgmgr_pkginfo_x *info = NULL;
4368 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4369 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4371 /*calloc manifest_info*/
4372 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4373 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4376 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4377 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4379 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4380 ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
4381 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4383 if (info->manifest_info->uiapplication) {
4384 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4385 info->manifest_info->uiapplication = ptr1;
4387 if (info->manifest_info->serviceapplication) {
4388 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4389 info->manifest_info->serviceapplication = ptr2;
4393 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4395 appinfo->locale = strdup(locale);
4396 appinfo->app_component = PMINFO_UI_APP;
4397 appinfo->package = strdup(ptr1->package);
4398 appinfo->uiapp_info = ptr1;
4399 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4400 "from package_app_info where " \
4401 "app_id='%s'", ptr1->appid);
4402 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4403 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4405 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
4409 locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
4412 memset(query, '\0', MAX_QUERY_LEN);
4413 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4414 "from package_app_localized_info where " \
4415 "app_id='%s' and app_locale='%s'",
4416 ptr1->appid, locale);
4417 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4418 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4420 memset(query, '\0', MAX_QUERY_LEN);
4421 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4422 "from package_app_localized_info where " \
4423 "app_id='%s' and app_locale='%s'",
4424 ptr1->appid, DEFAULT_LOCALE);
4426 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4427 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4429 /*store setting notification icon section*/
4430 memset(query, '\0', MAX_QUERY_LEN);
4431 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
4432 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4433 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4435 /*store app preview image info*/
4436 memset(query, '\0', MAX_QUERY_LEN);
4437 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
4438 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4439 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4441 if (appinfo->uiapp_info->label) {
4442 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4443 appinfo->uiapp_info->label = tmp1;
4445 if (appinfo->uiapp_info->icon) {
4446 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4447 appinfo->uiapp_info->icon= tmp2;
4449 if (appinfo->uiapp_info->category) {
4450 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4451 appinfo->uiapp_info->category = tmp3;
4453 if (appinfo->uiapp_info->metadata) {
4454 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4455 appinfo->uiapp_info->metadata = tmp4;
4457 if (appinfo->uiapp_info->permission) {
4458 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4459 appinfo->uiapp_info->permission = tmp5;
4461 if (appinfo->uiapp_info->image) {
4462 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4463 appinfo->uiapp_info->image = tmp6;
4466 ret = __appinfo_check_installed_storage(appinfo);
4470 ret = app_func((void *)appinfo, user_data);
4473 free((void *)appinfo->package);
4474 appinfo->package = NULL;
4477 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4479 appinfo->locale = strdup(locale);
4480 appinfo->app_component = PMINFO_SVC_APP;
4481 appinfo->package = strdup(ptr2->package);
4482 appinfo->svcapp_info = ptr2;
4483 memset(query, '\0', MAX_QUERY_LEN);
4484 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4485 "from package_app_info where " \
4486 "app_id='%s'", ptr2->appid);
4487 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4488 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4490 memset(query, '\0', MAX_QUERY_LEN);
4491 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4492 "from package_app_localized_info where " \
4493 "app_id='%s' and app_locale='%s'",
4494 ptr2->appid, locale);
4495 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4496 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4498 memset(query, '\0', MAX_QUERY_LEN);
4499 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4500 "from package_app_localized_info where " \
4501 "app_id='%s' and app_locale='%s'",
4502 ptr2->appid, DEFAULT_LOCALE);
4503 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4504 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4506 if (appinfo->svcapp_info->label) {
4507 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4508 appinfo->svcapp_info->label = tmp1;
4510 if (appinfo->svcapp_info->icon) {
4511 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4512 appinfo->svcapp_info->icon= tmp2;
4514 if (appinfo->svcapp_info->category) {
4515 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4516 appinfo->svcapp_info->category = tmp3;
4518 if (appinfo->svcapp_info->metadata) {
4519 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4520 appinfo->svcapp_info->metadata = tmp4;
4522 if (appinfo->svcapp_info->permission) {
4523 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4524 appinfo->svcapp_info->permission = tmp5;
4526 ret = app_func((void *)appinfo, user_data);
4529 free((void *)appinfo->package);
4530 appinfo->package = NULL;
4543 sqlite3_close(appinfo_db);
4548 __cleanup_pkginfo(info);
4552 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
4554 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
4555 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4557 pkgmgr_appinfo_x *appinfo = NULL;
4558 char *syslocale = NULL;
4559 char *locale = NULL;
4562 label_x *tmp1 = NULL;
4563 icon_x *tmp2 = NULL;
4564 category_x *tmp3 = NULL;
4565 metadata_x *tmp4 = NULL;
4566 permission_x *tmp5 = NULL;
4567 image_x *tmp6 = NULL;
4568 char query[MAX_QUERY_LEN] = {'\0'};
4569 sqlite3 *appinfo_db = NULL;
4572 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
4573 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4575 /*check appid exist on db*/
4576 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
4577 ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
4578 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
4579 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
4581 /*get system locale*/
4582 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4583 locale = __convert_system_locale_to_manifest_locale(syslocale);
4584 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4587 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4588 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
4590 /*check app_component from DB*/
4591 memset(query, '\0', MAX_QUERY_LEN);
4592 snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
4593 ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
4594 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4596 /*calloc app_component*/
4597 if (appinfo->app_component == PMINFO_UI_APP) {
4598 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4599 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
4601 appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
4602 tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
4604 appinfo->locale = strdup(locale);
4606 /*populate app_info from DB*/
4607 memset(query, '\0', MAX_QUERY_LEN);
4608 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info 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 Info DB Information retrieval failed");
4612 memset(query, '\0', MAX_QUERY_LEN);
4613 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
4614 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4615 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4617 /*Also store the values corresponding to default locales*/
4618 memset(query, '\0', MAX_QUERY_LEN);
4619 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
4620 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4621 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4623 /*Populate app category*/
4624 memset(query, '\0', MAX_QUERY_LEN);
4625 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
4626 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4627 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
4629 /*Populate app metadata*/
4630 memset(query, '\0', MAX_QUERY_LEN);
4631 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
4632 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4633 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
4635 /*Populate app permission*/
4636 memset(query, '\0', MAX_QUERY_LEN);
4637 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
4638 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4639 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
4641 /*store setting notification icon section*/
4642 memset(query, '\0', MAX_QUERY_LEN);
4643 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
4644 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4645 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4647 /*store app preview image info*/
4648 memset(query, '\0', MAX_QUERY_LEN);
4649 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
4650 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4651 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4653 ret = __appinfo_check_installed_storage(appinfo);
4654 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "[%s] is installed external, but is not in mmc", appinfo->package);
4656 switch (appinfo->app_component) {
4658 if (appinfo->uiapp_info->label) {
4659 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4660 appinfo->uiapp_info->label = tmp1;
4662 if (appinfo->uiapp_info->icon) {
4663 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4664 appinfo->uiapp_info->icon = tmp2;
4666 if (appinfo->uiapp_info->category) {
4667 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4668 appinfo->uiapp_info->category = tmp3;
4670 if (appinfo->uiapp_info->metadata) {
4671 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4672 appinfo->uiapp_info->metadata = tmp4;
4674 if (appinfo->uiapp_info->permission) {
4675 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4676 appinfo->uiapp_info->permission = tmp5;
4678 if (appinfo->uiapp_info->image) {
4679 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4680 appinfo->uiapp_info->image = tmp6;
4683 case PMINFO_SVC_APP:
4684 if (appinfo->svcapp_info->label) {
4685 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4686 appinfo->svcapp_info->label = tmp1;
4688 if (appinfo->svcapp_info->icon) {
4689 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4690 appinfo->svcapp_info->icon = tmp2;
4692 if (appinfo->svcapp_info->category) {
4693 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4694 appinfo->svcapp_info->category = tmp3;
4696 if (appinfo->svcapp_info->metadata) {
4697 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4698 appinfo->svcapp_info->metadata = tmp4;
4700 if (appinfo->svcapp_info->permission) {
4701 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4702 appinfo->svcapp_info->permission = tmp5;
4712 if (ret == PMINFO_R_OK)
4713 *handle = (void*)appinfo;
4716 __cleanup_appinfo(appinfo);
4719 sqlite3_close(appinfo_db);
4732 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
4734 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4735 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4736 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4738 if (info->app_component == PMINFO_UI_APP)
4739 *appid = (char *)info->uiapp_info->appid;
4740 else if (info->app_component == PMINFO_SVC_APP)
4741 *appid = (char *)info->svcapp_info->appid;
4746 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
4748 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4749 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4750 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4752 *pkg_name = (char *)info->package;
4757 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
4759 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4760 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4761 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4763 *pkgid = (char *)info->package;
4768 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
4770 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4771 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4772 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4774 if (info->app_component == PMINFO_UI_APP)
4775 *exec = (char *)info->uiapp_info->exec;
4776 if (info->app_component == PMINFO_SVC_APP)
4777 *exec = (char *)info->svcapp_info->exec;
4783 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4785 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4786 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4787 char *locale = NULL;
4789 icon_x *start = NULL;
4792 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4793 locale = info->locale;
4794 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4796 if (info->app_component == PMINFO_UI_APP)
4797 start = info->uiapp_info->icon;
4798 if (info->app_component == PMINFO_SVC_APP)
4799 start = info->svcapp_info->icon;
4800 for(ptr = start; ptr != NULL; ptr = ptr->next)
4803 if (strcmp(ptr->lang, locale) == 0) {
4804 *icon = (char *)ptr->text;
4805 if (strcasecmp(*icon, "(null)") == 0) {
4806 locale = DEFAULT_LOCALE;
4810 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4811 *icon = (char *)ptr->text;
4820 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
4822 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4823 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4824 char *locale = NULL;
4825 label_x *ptr = NULL;
4826 label_x *start = NULL;
4829 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4830 locale = info->locale;
4831 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4833 if (info->app_component == PMINFO_UI_APP)
4834 start = info->uiapp_info->label;
4835 if (info->app_component == PMINFO_SVC_APP)
4836 start = info->svcapp_info->label;
4837 for(ptr = start; ptr != NULL; ptr = ptr->next)
4840 if (strcmp(ptr->lang, locale) == 0) {
4841 *label = (char *)ptr->text;
4842 if (strcasecmp(*label, "(null)") == 0) {
4843 locale = DEFAULT_LOCALE;
4847 } else if (strncasecmp(ptr->lang, locale, 2) == 0) {
4848 *label = (char *)ptr->text;
4849 if (strcasecmp(*label, "(null)") == 0) {
4850 locale = DEFAULT_LOCALE;
4854 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4855 *label = (char *)ptr->text;
4864 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
4866 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4867 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4868 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4870 if (info->app_component == PMINFO_UI_APP)
4871 *component = PMINFO_UI_APP;
4872 else if (info->app_component == PMINFO_SVC_APP)
4873 *component = PMINFO_SVC_APP;
4875 return PMINFO_R_ERROR;
4880 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
4882 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4883 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4884 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4886 if (info->app_component == PMINFO_UI_APP)
4887 *app_type = (char *)info->uiapp_info->type;
4888 if (info->app_component == PMINFO_SVC_APP)
4889 *app_type = (char *)info->svcapp_info->type;
4894 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
4895 int *operation_count, char ***operation)
4897 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4898 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4899 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4900 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4901 *operation_count = data->operation_count;
4902 *operation = data->operation;
4906 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
4907 int *uri_count, char ***uri)
4909 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4910 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4911 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4912 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4913 *uri_count = data->uri_count;
4918 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
4919 int *mime_count, char ***mime)
4921 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4922 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4923 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4924 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4925 *mime_count = data->mime_count;
4930 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
4931 int *subapp_count, char ***subapp)
4933 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4934 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4935 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4936 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4937 *subapp_count = data->subapp_count;
4938 *subapp = data->subapp;
4942 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4944 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4945 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4949 icon_x *start = NULL;
4950 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4952 start = info->uiapp_info->icon;
4954 for(ptr = start; ptr != NULL; ptr = ptr->next)
4957 val = (char *)ptr->section;
4958 if (strcmp(val, "setting") == 0){
4959 *icon = (char *)ptr->text;
4968 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4970 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4971 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4975 icon_x *start = NULL;
4976 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4978 start = info->uiapp_info->icon;
4980 for(ptr = start; ptr != NULL; ptr = ptr->next)
4983 val = (char *)ptr->section;
4985 if (strcmp(val, "notification") == 0){
4986 *icon = (char *)ptr->text;
4995 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
4997 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4998 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5000 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5001 val = (char *)info->uiapp_info->recentimage;
5003 if (strcasecmp(val, "capture") == 0)
5004 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
5005 else if (strcasecmp(val, "icon") == 0)
5006 *type = PMINFO_RECENTIMAGE_USE_ICON;
5008 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
5014 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
5016 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5017 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5020 image_x *ptr = NULL;
5021 image_x *start = NULL;
5022 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5024 start = info->uiapp_info->image;
5026 for(ptr = start; ptr != NULL; ptr = ptr->next)
5029 val = (char *)ptr->section;
5031 if (strcmp(val, "preview") == 0)
5032 *preview_img = (char *)ptr->text;
5040 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
5042 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5043 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5046 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5048 if (info->app_component == PMINFO_UI_APP)
5049 val = info->uiapp_info->permission_type;
5050 else if (info->app_component == PMINFO_SVC_APP)
5051 val = info->svcapp_info->permission_type;
5053 return PMINFO_R_ERROR;
5055 if (strcmp(val, "signature") == 0)
5056 *permission = PMINFO_PERMISSION_SIGNATURE;
5057 else if (strcmp(val, "privilege") == 0)
5058 *permission = PMINFO_PERMISSION_PRIVILEGE;
5060 *permission = PMINFO_PERMISSION_NORMAL;
5065 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
5067 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5068 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5069 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5071 *component_type = (char *)info->uiapp_info->component_type;
5076 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
5078 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5079 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5081 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5082 val = (char *)info->uiapp_info->hwacceleration;
5084 if (strcasecmp(val, "not-use-GL") == 0)
5085 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
5086 else if (strcasecmp(val, "use-GL") == 0)
5087 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
5089 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
5094 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
5096 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5097 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5099 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5100 val = (char *)info->uiapp_info->screenreader;
5102 if (strcasecmp(val, "screenreader-off") == 0)
5103 *screenreader = PMINFO_SCREENREADER_OFF;
5104 else if (strcasecmp(val, "screenreader-on") == 0)
5105 *screenreader = PMINFO_SCREENREADER_ON;
5107 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
5112 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
5114 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5115 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5116 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5117 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5119 if (info->app_component == PMINFO_UI_APP){
5120 *portrait_img = (char *)info->uiapp_info->portraitimg;
5121 *landscape_img = (char *)info->uiapp_info->landscapeimg;
5127 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
5129 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5130 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5131 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5133 *submode_mainid = (char *)info->uiapp_info->submode_mainid;
5138 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
5139 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
5141 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5142 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5144 permission_x *ptr = NULL;
5145 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5146 if (info->app_component == PMINFO_UI_APP)
5147 ptr = info->uiapp_info->permission;
5148 else if (info->app_component == PMINFO_SVC_APP)
5149 ptr = info->svcapp_info->permission;
5151 return PMINFO_R_EINVAL;
5152 for (; ptr; ptr = ptr->next) {
5154 ret = permission_func(ptr->value, user_data);
5162 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
5163 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
5165 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5166 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5168 category_x *ptr = NULL;
5169 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5170 if (info->app_component == PMINFO_UI_APP)
5171 ptr = info->uiapp_info->category;
5172 else if (info->app_component == PMINFO_SVC_APP)
5173 ptr = info->svcapp_info->category;
5175 return PMINFO_R_EINVAL;
5176 for (; ptr; ptr = ptr->next) {
5178 ret = category_func(ptr->name, user_data);
5186 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
5187 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
5189 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5190 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5192 metadata_x *ptr = NULL;
5193 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5194 if (info->app_component == PMINFO_UI_APP)
5195 ptr = info->uiapp_info->metadata;
5196 else if (info->app_component == PMINFO_SVC_APP)
5197 ptr = info->svcapp_info->metadata;
5199 return PMINFO_R_EINVAL;
5200 for (; ptr; ptr = ptr->next) {
5202 ret = metadata_func(ptr->key, ptr->value, user_data);
5210 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
5211 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
5213 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5214 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5222 char *manifest = NULL;
5223 char **operation = NULL;
5226 char **subapp = NULL;
5227 appcontrol_x *appcontrol = NULL;
5228 manifest_x *mfx = NULL;
5229 operation_x *op = NULL;
5232 subapp_x *sa = NULL;
5233 pkgmgrinfo_app_component component;
5234 pkgmgrinfo_appcontrol_x *ptr = NULL;
5235 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
5237 _LOGE("Failed to get package name\n");
5238 return PMINFO_R_ERROR;
5240 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
5242 _LOGE("Failed to get app component name\n");
5243 return PMINFO_R_ERROR;
5245 manifest = pkgmgr_parser_get_manifest_file(pkgid);
5246 if (manifest == NULL) {
5247 _LOGE("Failed to fetch package manifest file\n");
5248 return PMINFO_R_ERROR;
5250 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5252 _LOGE("Failed to parse package manifest file\n");
5255 return PMINFO_R_ERROR;
5258 ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
5260 _LOGE("Out of Memory!!!\n");
5261 pkgmgr_parser_free_manifest_xml(mfx);
5262 return PMINFO_R_ERROR;
5264 /*Get Operation, Uri, Mime*/
5265 switch (component) {
5267 if (mfx->uiapplication) {
5268 if (mfx->uiapplication->appsvc) {
5269 appcontrol = mfx->uiapplication->appsvc;
5273 case PMINFO_SVC_APP:
5274 if (mfx->serviceapplication) {
5275 if (mfx->serviceapplication->appsvc) {
5276 appcontrol = mfx->serviceapplication->appsvc;
5283 for (; appcontrol; appcontrol = appcontrol->next) {
5284 op = appcontrol->operation;
5285 for (; op; op = op->next)
5287 op = appcontrol->operation;
5289 ui = appcontrol->uri;
5290 for (; ui; ui = ui->next)
5292 ui = appcontrol->uri;
5294 mi = appcontrol->mime;
5295 for (; mi; mi = mi->next)
5297 mi = appcontrol->mime;
5299 sa = appcontrol->subapp;
5300 for (; sa; sa = sa->next)
5302 sa = appcontrol->subapp;
5304 operation = (char **)calloc(oc, sizeof(char *));
5305 for (i = 0; i < oc; i++) {
5306 operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
5310 uri = (char **)calloc(uc, sizeof(char *));
5311 for (i = 0; i < uc; i++) {
5312 uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
5316 mime = (char **)calloc(mc, sizeof(char *));
5317 for (i = 0; i < mc; i++) {
5318 mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
5322 subapp = (char **)calloc(sc, sizeof(char *));
5323 for (i = 0; i < sc; i++) {
5324 subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
5328 /*populate appcontrol handle*/
5329 ptr->operation_count = oc;
5330 ptr->uri_count = uc;
5331 ptr->mime_count = mc;
5332 ptr->subapp_count = sc;
5333 ptr->operation = operation;
5336 ptr->subapp = subapp;
5338 ret = appcontrol_func((void *)ptr, user_data);
5339 for (i = 0; i < oc; i++) {
5342 operation[i] = NULL;
5349 for (i = 0; i < uc; i++) {
5359 for (i = 0; i < mc; i++) {
5369 for (i = 0; i < sc; i++) {
5386 pkgmgr_parser_free_manifest_xml(mfx);
5394 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
5396 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5397 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5399 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5400 val = (char *)info->uiapp_info->nodisplay;
5402 if (strcasecmp(val, "true") == 0)
5404 else if (strcasecmp(val, "false") == 0)
5412 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
5414 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5415 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5417 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5418 val = (char *)info->uiapp_info->multiple;
5420 if (strcasecmp(val, "true") == 0)
5422 else if (strcasecmp(val, "false") == 0)
5430 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
5432 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5433 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5435 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5436 val = (char *)info->uiapp_info->indicatordisplay;
5438 if (strcasecmp(val, "true") == 0){
5439 *indicator_disp = 1;
5440 }else if (strcasecmp(val, "false") == 0){
5441 *indicator_disp = 0;
5443 *indicator_disp = 0;
5449 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
5451 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5452 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5454 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5455 val = (char *)info->uiapp_info->taskmanage;
5457 if (strcasecmp(val, "true") == 0)
5459 else if (strcasecmp(val, "false") == 0)
5467 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
5469 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5470 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5472 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5473 if (info->app_component == PMINFO_UI_APP)
5474 val = (char *)info->uiapp_info->enabled;
5475 else if (info->app_component == PMINFO_SVC_APP)
5476 val = (char *)info->uiapp_info->enabled;
5478 _LOGE("invalid component type\n");
5479 return PMINFO_R_EINVAL;
5483 if (strcasecmp(val, "true") == 0)
5485 else if (strcasecmp(val, "false") == 0)
5494 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
5496 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5497 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5499 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5500 val = (char *)info->svcapp_info->onboot;
5502 if (strcasecmp(val, "true") == 0)
5504 else if (strcasecmp(val, "false") == 0)
5512 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
5514 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5515 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5517 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5518 val = (char *)info->svcapp_info->autorestart;
5520 if (strcasecmp(val, "true") == 0)
5522 else if (strcasecmp(val, "false") == 0)
5530 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
5532 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5533 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5535 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5536 val = (char *)info->uiapp_info->mainapp;
5538 if (strcasecmp(val, "true") == 0)
5540 else if (strcasecmp(val, "false") == 0)
5548 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
5550 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5551 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5553 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5554 val = (char *)info->uiapp_info->preload;
5556 if (strcasecmp(val, "true") == 0)
5558 else if (strcasecmp(val, "false") == 0)
5566 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
5568 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5569 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5571 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5572 val = (char *)info->uiapp_info->submode;
5574 if (strcasecmp(val, "true") == 0)
5576 else if (strcasecmp(val, "false") == 0)
5584 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
5586 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5587 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5588 __cleanup_appinfo(info);
5592 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
5594 return (pkgmgrinfo_pkginfo_filter_create(handle));
5597 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
5599 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5602 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
5603 const char *property, const int value)
5605 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5606 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5607 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
5609 GSList *link = NULL;
5611 prop = _pminfo_appinfo_convert_to_prop_int(property);
5612 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
5613 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
5614 _LOGE("Invalid Integer Property\n");
5615 return PMINFO_R_EINVAL;
5617 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5618 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5620 _LOGE("Out of Memory!!!\n");
5621 return PMINFO_R_ERROR;
5623 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
5624 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
5626 _LOGE("Out of Memory\n");
5629 return PMINFO_R_ERROR;
5633 /*If API is called multiple times for same property, we should override the previous values.
5634 Last value set will be used for filtering.*/
5635 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5637 filter->list = g_slist_delete_link(filter->list, link);
5638 filter->list = g_slist_append(filter->list, (gpointer)node);
5643 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
5644 const char *property, const bool value)
5646 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5647 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5649 GSList *link = NULL;
5651 prop = _pminfo_appinfo_convert_to_prop_bool(property);
5652 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
5653 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
5654 _LOGE("Invalid Boolean Property\n");
5655 return PMINFO_R_EINVAL;
5657 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5658 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5660 _LOGE("Out of Memory!!!\n");
5661 return PMINFO_R_ERROR;
5664 val = strndup("('true','True')", 15);
5666 val = strndup("('false','False')", 17);
5668 _LOGE("Out of Memory\n");
5671 return PMINFO_R_ERROR;
5675 /*If API is called multiple times for same property, we should override the previous values.
5676 Last value set will be used for filtering.*/
5677 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5679 filter->list = g_slist_delete_link(filter->list, link);
5680 filter->list = g_slist_append(filter->list, (gpointer)node);
5685 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
5686 const char *property, const char *value)
5688 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5689 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5690 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5692 pkgmgrinfo_node_x *ptr = NULL;
5693 char prev[PKG_STRING_LEN_MAX] = {'\0'};
5694 char temp[PKG_STRING_LEN_MAX] = {'\0'};
5695 GSList *link = NULL;
5697 prop = _pminfo_appinfo_convert_to_prop_str(property);
5698 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
5699 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
5700 _LOGE("Invalid String Property\n");
5701 return PMINFO_R_EINVAL;
5703 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5704 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5706 _LOGE("Out of Memory!!!\n");
5707 return PMINFO_R_ERROR;
5711 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
5712 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
5713 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
5715 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
5717 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5719 filter->list = g_slist_delete_link(filter->list, link);
5720 filter->list = g_slist_append(filter->list, (gpointer)node);
5722 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
5723 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
5724 case E_PMINFO_APPINFO_PROP_APP_URI:
5725 case E_PMINFO_APPINFO_PROP_APP_MIME:
5726 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
5728 _LOGE("Out of Memory\n");
5731 return PMINFO_R_ERROR;
5733 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5735 ptr = (pkgmgrinfo_node_x *)link->data;
5736 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
5737 _LOGE("Previous value is %s\n", prev);
5738 filter->list = g_slist_delete_link(filter->list, link);
5739 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
5740 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5741 _LOGE("New value is %s\n", val);
5743 filter->list = g_slist_append(filter->list, (gpointer)node);
5744 memset(temp, '\0', PKG_STRING_LEN_MAX);
5746 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
5747 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5748 _LOGE("First value is %s\n", val);
5750 filter->list = g_slist_append(filter->list, (gpointer)node);
5751 memset(temp, '\0', PKG_STRING_LEN_MAX);
5755 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
5756 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5758 filter->list = g_slist_delete_link(filter->list, link);
5759 filter->list = g_slist_append(filter->list, (gpointer)node);
5765 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
5767 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5768 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5769 char *syslocale = NULL;
5770 char *locale = NULL;
5771 char *condition = NULL;
5772 char query[MAX_QUERY_LEN] = {'\0'};
5773 char where[MAX_QUERY_LEN] = {'\0'};
5776 uiapplication_x *ptr1 = NULL;
5777 serviceapplication_x *ptr2 = NULL;
5778 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5779 sqlite3 *pkginfo_db = NULL;
5780 int filter_count = 0;
5783 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
5784 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
5786 /*get system locale*/
5787 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5788 locale = __convert_system_locale_to_manifest_locale(syslocale);
5789 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
5791 /*Start constructing query*/
5792 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
5793 /*Get where clause*/
5794 for (list = filter->list; list; list = g_slist_next(list)) {
5795 __get_filter_condition(list->data, &condition);
5797 strncat(where, condition, sizeof(where) - strlen(where) -1);
5798 where[sizeof(where) - 1] = '\0';
5802 if (g_slist_next(list)) {
5803 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5804 where[sizeof(where) - 1] = '\0';
5807 _LOGE("where = %s\n", where);
5808 if (strlen(where) > 0) {
5809 strncat(query, where, sizeof(query) - strlen(query) - 1);
5810 query[sizeof(query) - 1] = '\0';
5812 // SECURE_LOGD("query = %s\n", query);
5813 /*To get filtered list*/
5814 pkgmgr_pkginfo_x *info = NULL;
5815 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5816 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5818 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5819 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5821 /*To get detail app info for each member of filtered list*/
5822 pkgmgr_pkginfo_x *filtinfo = NULL;
5823 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5824 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5826 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5827 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5829 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5830 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5832 ret = __exec_db_query(pkginfo_db, query, __app_list_cb, (void *)info);
5833 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5835 memset(query, '\0', MAX_QUERY_LEN);
5836 if (info->manifest_info->uiapplication) {
5837 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5838 info->manifest_info->uiapplication = ptr1;
5840 if (info->manifest_info->serviceapplication) {
5841 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5842 info->manifest_info->serviceapplication = ptr2;
5844 /*Filtered UI Apps*/
5845 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5847 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5848 ptr1->appid, "uiapp");
5849 ret = __exec_db_query(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo);
5850 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5852 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5854 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5855 ptr2->appid, "svcapp");
5856 ret = __exec_db_query(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo);
5857 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5859 if (filtinfo->manifest_info->uiapplication) {
5860 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5861 filtinfo->manifest_info->uiapplication = ptr1;
5863 /*If the callback func return < 0 we break and no more call back is called*/
5866 appinfo->locale = strdup(locale);
5867 appinfo->uiapp_info = ptr1;
5868 appinfo->app_component = PMINFO_UI_APP;
5870 ret = __appinfo_check_installed_storage(appinfo);
5880 /*Filtered Service Apps*/
5881 if (filtinfo->manifest_info->serviceapplication) {
5882 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5883 filtinfo->manifest_info->serviceapplication = ptr2;
5885 /*If the callback func return < 0 we break and no more call back is called*/
5888 appinfo->locale = strdup(locale);
5889 appinfo->svcapp_info = ptr2;
5890 appinfo->app_component = PMINFO_SVC_APP;
5894 *count = filter_count;
5906 sqlite3_close(pkginfo_db);
5911 __cleanup_pkginfo(info);
5912 __cleanup_pkginfo(filtinfo);
5916 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
5917 pkgmgrinfo_app_list_cb app_cb, void * user_data)
5919 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5920 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5921 char *syslocale = NULL;
5922 char *locale = NULL;
5923 char *condition = NULL;
5924 char query[MAX_QUERY_LEN] = {'\0'};
5925 char where[MAX_QUERY_LEN] = {'\0'};
5928 uiapplication_x *ptr1 = NULL;
5929 serviceapplication_x *ptr2 = NULL;
5930 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5931 sqlite3 *pkginfo_db = NULL;
5934 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
5935 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
5937 /*get system locale*/
5938 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5939 locale = __convert_system_locale_to_manifest_locale(syslocale);
5940 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
5942 /*Start constructing query*/
5943 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
5944 /*Get where clause*/
5945 for (list = filter->list; list; list = g_slist_next(list)) {
5946 __get_filter_condition(list->data, &condition);
5948 strncat(where, condition, sizeof(where) - strlen(where) -1);
5949 where[sizeof(where) - 1] = '\0';
5953 if (g_slist_next(list)) {
5954 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5955 where[sizeof(where) - 1] = '\0';
5958 _LOGE("where = %s\n", where);
5959 if (strlen(where) > 0) {
5960 strncat(query, where, sizeof(query) - strlen(query) - 1);
5961 query[sizeof(query) - 1] = '\0';
5963 _LOGE("query = %s\n", query);
5964 /*To get filtered list*/
5965 pkgmgr_pkginfo_x *info = NULL;
5966 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5967 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5969 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5970 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5972 /*To get detail app info for each member of filtered list*/
5973 pkgmgr_pkginfo_x *filtinfo = NULL;
5974 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5975 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5977 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5978 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5980 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5981 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5983 ret = __exec_db_query(pkginfo_db, query, __app_list_cb, (void *)info);
5984 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5986 memset(query, '\0', MAX_QUERY_LEN);
5987 if (info->manifest_info->uiapplication) {
5988 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5989 info->manifest_info->uiapplication = ptr1;
5991 if (info->manifest_info->serviceapplication) {
5992 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5993 info->manifest_info->serviceapplication = ptr2;
5995 /*Filtered UI Apps*/
5996 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5998 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5999 ptr1->appid, "uiapp");
6000 ret = __exec_db_query(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo);
6001 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
6003 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
6005 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
6006 ptr2->appid, "svcapp");
6007 ret = __exec_db_query(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo);
6008 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
6010 if (filtinfo->manifest_info->uiapplication) {
6011 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
6012 filtinfo->manifest_info->uiapplication = ptr1;
6014 /*If the callback func return < 0 we break and no more call back is called*/
6017 appinfo->locale = strdup(locale);
6018 appinfo->uiapp_info = ptr1;
6019 appinfo->app_component = PMINFO_UI_APP;
6021 ret = __appinfo_check_installed_storage(appinfo);
6027 ret = app_cb((void *)appinfo, user_data);
6032 /*Filtered Service Apps*/
6033 if (filtinfo->manifest_info->serviceapplication) {
6034 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
6035 filtinfo->manifest_info->serviceapplication = ptr2;
6037 /*If the callback func return < 0 we break and no more call back is called*/
6040 appinfo->locale = strdup(locale);
6041 appinfo->svcapp_info = ptr2;
6042 appinfo->app_component = PMINFO_SVC_APP;
6043 ret = app_cb((void *)appinfo, user_data);
6058 sqlite3_close(pkginfo_db);
6063 __cleanup_pkginfo(info);
6064 __cleanup_pkginfo(filtinfo);
6068 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
6070 return (pkgmgrinfo_pkginfo_filter_create(handle));
6073 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
6075 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
6078 API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
6079 const char *key, const char *value)
6081 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
6082 retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
6083 /*value can be NULL. In that case all apps with specified key should be displayed*/
6087 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
6088 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
6089 retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
6091 tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6095 tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6098 /*If API is called multiple times, we should OR all conditions.*/
6099 filter->list = g_slist_append(filter->list, (gpointer)node);
6100 /*All memory will be freed in destroy API*/
6118 API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
6119 pkgmgrinfo_app_list_cb app_cb, void *user_data)
6121 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
6122 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
6123 char *syslocale = NULL;
6124 char *locale = NULL;
6125 char *condition = NULL;
6126 char *error_message = NULL;
6127 char query[MAX_QUERY_LEN] = {'\0'};
6128 char where[MAX_QUERY_LEN] = {'\0'};
6131 pkgmgr_pkginfo_x *info = NULL;
6132 pkgmgr_pkginfo_x *filtinfo = NULL;
6133 pkgmgr_appinfo_x *appinfo = NULL;
6134 uiapplication_x *ptr1 = NULL;
6135 serviceapplication_x *ptr2 = NULL;
6136 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
6137 sqlite3 *pkginfo_db = NULL;
6140 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
6141 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
6143 /*Get current locale*/
6144 syslocale = vconf_get_str(VCONFKEY_LANGSET);
6145 locale = __convert_system_locale_to_manifest_locale(syslocale);
6146 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
6148 /*Start constructing query*/
6149 memset(where, '\0', MAX_QUERY_LEN);
6150 memset(query, '\0', MAX_QUERY_LEN);
6151 snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
6152 /*Get where clause*/
6153 for (list = filter->list; list; list = g_slist_next(list)) {
6154 __get_metadata_filter_condition(list->data, &condition);
6156 strncat(where, condition, sizeof(where) - strlen(where) -1);
6160 if (g_slist_next(list)) {
6161 strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
6164 _LOGE("where = %s (%d)\n", where, strlen(where));
6165 if (strlen(where) > 0) {
6166 strncat(query, where, sizeof(query) - strlen(query) - 1);
6168 _LOGE("query = %s (%d)\n", query, strlen(query));
6169 /*To get filtered list*/
6170 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
6171 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6173 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
6174 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6176 /*To get detail app info for each member of filtered list*/
6177 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
6178 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6180 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
6181 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6183 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
6184 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6186 ret = sqlite3_exec(pkginfo_db, query, __app_list_cb, (void *)info, &error_message);
6187 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
6188 memset(query, '\0', MAX_QUERY_LEN);
6190 if (info->manifest_info->uiapplication) {
6191 LISTHEAD(info->manifest_info->uiapplication, ptr1);
6192 info->manifest_info->uiapplication = ptr1;
6194 if (info->manifest_info->serviceapplication) {
6195 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
6196 info->manifest_info->serviceapplication = ptr2;
6200 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
6202 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
6203 ptr1->appid, "uiapp");
6204 ret = sqlite3_exec(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message);
6205 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
6206 memset(query, '\0', MAX_QUERY_LEN);
6209 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
6211 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
6212 ptr2->appid, "svcapp");
6213 ret = sqlite3_exec(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message);
6214 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
6215 memset(query, '\0', MAX_QUERY_LEN);
6217 /*Filtered UI Apps*/
6218 if (filtinfo->manifest_info->uiapplication) {
6219 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
6220 filtinfo->manifest_info->uiapplication = ptr1;
6222 /*If the callback func return < 0 we break and no more call back is called*/
6225 appinfo->locale = strdup(locale);
6226 appinfo->uiapp_info = ptr1;
6227 appinfo->app_component = PMINFO_UI_APP;
6228 ret = app_cb((void *)appinfo, user_data);
6233 /*Filtered Service Apps*/
6234 if (filtinfo->manifest_info->serviceapplication) {
6235 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
6236 filtinfo->manifest_info->serviceapplication = ptr2;
6238 /*If the callback func return < 0 we break and no more call back is called*/
6241 appinfo->locale = strdup(locale);
6242 appinfo->svcapp_info = ptr2;
6243 appinfo->app_component = PMINFO_SVC_APP;
6244 ret = app_cb((void *)appinfo, user_data);
6259 sqlite3_free(error_message);
6260 sqlite3_close(pkginfo_db);
6265 __cleanup_pkginfo(info);
6266 __cleanup_pkginfo(filtinfo);
6270 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
6272 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6273 pkgmgr_certinfo_x *certinfo = NULL;
6274 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
6275 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
6276 *handle = (void *)certinfo;
6280 API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
6282 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
6283 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
6284 pkgmgr_certinfo_x *certinfo = NULL;
6285 char *error_message = NULL;
6286 int ret = PMINFO_R_OK;
6287 char query[MAX_QUERY_LEN] = {'\0'};
6292 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READONLY, NULL);
6293 if (ret != SQLITE_OK) {
6294 _LOGE("connect db [%s] failed!\n", CERT_DB);
6295 return PMINFO_R_ERROR;
6298 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6300 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6301 _LOGE("Don't execute query = %s error message = %s\n", query,
6303 sqlite3_free(error_message);
6304 ret = PMINFO_R_ERROR;
6308 _LOGE("Package not found in DB\n");
6309 ret = PMINFO_R_ERROR;
6312 certinfo = (pkgmgr_certinfo_x *)handle;
6313 /*populate certinfo from DB*/
6314 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
6315 ret = __exec_certinfo_query(query, (void *)certinfo);
6317 _LOGE("Package Cert Info DB Information retrieval failed\n");
6318 ret = PMINFO_R_ERROR;
6321 for (i = 0; i < MAX_CERT_TYPE; i++) {
6322 memset(query, '\0', MAX_QUERY_LEN);
6323 snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
6324 ret = __exec_certinfo_query(query, (void *)certinfo);
6326 _LOGE("Cert Info DB Information retrieval failed\n");
6327 ret = PMINFO_R_ERROR;
6330 if (certinfo->cert_value) {
6331 (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
6332 free(certinfo->cert_value);
6333 certinfo->cert_value = NULL;
6337 sqlite3_close(cert_db);
6341 API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
6343 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6344 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6345 retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6346 retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6347 pkgmgr_certinfo_x *certinfo = NULL;
6348 certinfo = (pkgmgr_certinfo_x *)handle;
6349 if ((certinfo->cert_info)[cert_type])
6350 *cert_value = (certinfo->cert_info)[cert_type];
6356 API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
6358 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6360 pkgmgr_certinfo_x *certinfo = NULL;
6361 certinfo = (pkgmgr_certinfo_x *)handle;
6362 if (certinfo->pkgid) {
6363 free(certinfo->pkgid);
6364 certinfo->pkgid = NULL;
6366 for (i = 0; i < MAX_CERT_TYPE; i++) {
6367 if ((certinfo->cert_info)[i]) {
6368 free((certinfo->cert_info)[i]);
6369 (certinfo->cert_info)[i] = NULL;
6377 API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
6379 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6380 pkgmgr_instcertinfo_x *certinfo = NULL;
6381 certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
6382 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
6383 *handle = (void *)certinfo;
6387 API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
6389 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6390 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6391 retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6392 retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6393 pkgmgr_instcertinfo_x *certinfo = NULL;
6394 certinfo = (pkgmgr_instcertinfo_x *)handle;
6395 (certinfo->cert_info)[cert_type] = strdup(cert_value);
6399 API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
6401 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
6402 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
6403 char *error_message = NULL;
6404 char query[MAX_QUERY_LEN] = {'\0'};
6405 char *vquery = NULL;
6410 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
6417 pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
6418 pkgmgr_certindexinfo_x *indexinfo = NULL;
6419 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
6420 if (indexinfo == NULL) {
6421 _LOGE("Out of Memory!!!");
6422 return PMINFO_R_ERROR;
6424 info->pkgid = strdup(pkgid);
6427 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL);
6428 if (ret != SQLITE_OK) {
6429 _LOGE("connect db [%s] failed!\n", CERT_DB);
6430 ret = PMINFO_R_ERROR;
6433 /*Begin Transaction*/
6434 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6435 if (ret != SQLITE_OK) {
6436 _LOGE("Failed to begin transaction\n");
6437 ret = PMINFO_R_ERROR;
6440 _LOGE("Transaction Begin\n");
6441 /*Check if request is to insert/update*/
6442 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6444 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6445 _LOGE("Don't execute query = %s error message = %s\n", query,
6447 sqlite3_free(error_message);
6448 ret = PMINFO_R_ERROR;
6453 We cant just issue update query directly. We need to manage index table also.
6454 Hence it is better to delete and insert again in case of update*/
6455 ret = __delete_certinfo(pkgid);
6457 _LOGE("Certificate Deletion Failed\n");
6459 for (i = 0; i < MAX_CERT_TYPE; i++) {
6460 if ((info->cert_info)[i]) {
6461 for (j = 0; j < i; j++) {
6462 if ( (info->cert_info)[j]) {
6463 if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
6464 (info->cert_id)[i] = (info->cert_id)[j];
6465 (info->is_new)[i] = 0;
6466 (info->ref_count)[i] = (info->ref_count)[j];
6473 memset(query, '\0', MAX_QUERY_LEN);
6474 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
6475 "where cert_info='%s'",(info->cert_info)[i]);
6476 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
6478 _LOGE("Cert Info DB Information retrieval failed\n");
6479 ret = PMINFO_R_ERROR;
6482 if (indexinfo->cert_id == 0) {
6483 /*New certificate. Get newid*/
6484 memset(query, '\0', MAX_QUERY_LEN);
6485 snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
6487 sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
6488 _LOGE("Don't execute query = %s error message = %s\n", query,
6490 sqlite3_free(error_message);
6491 ret = PMINFO_R_ERROR;
6499 indexinfo->cert_id = maxid;
6500 indexinfo->cert_ref_count = 1;
6504 (info->cert_id)[i] = indexinfo->cert_id;
6505 (info->is_new)[i] = is_new;
6506 (info->ref_count)[i] = indexinfo->cert_ref_count;
6507 _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
6508 indexinfo->cert_id = 0;
6509 indexinfo->cert_ref_count = 0;
6513 len = MAX_QUERY_LEN;
6514 for (i = 0; i < MAX_CERT_TYPE; i++) {
6515 if ((info->cert_info)[i])
6516 len+= strlen((info->cert_info)[i]);
6518 vquery = (char *)calloc(1, len);
6520 snprintf(vquery, len,
6521 "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
6522 "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
6523 "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
6524 info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
6525 (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
6526 (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
6527 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
6528 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
6530 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6531 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6533 sqlite3_free(error_message);
6534 ret = PMINFO_R_ERROR;
6537 /*Update index table info*/
6538 /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
6539 for (i = 0; i < MAX_CERT_TYPE; i++) {
6540 if ((info->cert_info)[i]) {
6541 memset(vquery, '\0', len);
6542 if ((info->is_new)[i]) {
6543 snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
6544 "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
6545 unique_id[c++] = (info->cert_id)[i];
6548 for (j = 0; j < MAX_CERT_TYPE; j++) {
6549 if ((info->cert_id)[i] == unique_id[j]) {
6550 /*Ref count has already been increased. Just continue*/
6554 if (j == MAX_CERT_TYPE)
6555 unique_id[c++] = (info->cert_id)[i];
6558 snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
6559 "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
6562 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6563 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6565 sqlite3_free(error_message);
6566 ret = PMINFO_R_ERROR;
6571 /*Commit transaction*/
6572 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6573 if (ret != SQLITE_OK) {
6574 _LOGE("Failed to commit transaction, Rollback now\n");
6575 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6576 ret = PMINFO_R_ERROR;
6579 _LOGE("Transaction Commit and End\n");
6582 sqlite3_close(cert_db);
6594 API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
6596 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6598 pkgmgr_instcertinfo_x *certinfo = NULL;
6599 certinfo = (pkgmgr_instcertinfo_x *)handle;
6600 if (certinfo->pkgid) {
6601 free(certinfo->pkgid);
6602 certinfo->pkgid = NULL;
6604 for (i = 0; i < MAX_CERT_TYPE; i++) {
6605 if ((certinfo->cert_info)[i]) {
6606 free((certinfo->cert_info)[i]);
6607 (certinfo->cert_info)[i] = NULL;
6615 API int pkgmgrinfo_delete_certinfo(const char *pkgid)
6617 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6620 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL);
6621 if (ret != SQLITE_OK) {
6622 _LOGE("connect db [%s] failed!\n", CERT_DB);
6623 ret = PMINFO_R_ERROR;
6626 /*Begin Transaction*/
6627 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6628 if (ret != SQLITE_OK) {
6629 _LOGE("Failed to begin transaction\n");
6630 ret = PMINFO_R_ERROR;
6633 _LOGE("Transaction Begin\n");
6634 ret = __delete_certinfo(pkgid);
6636 _LOGE("Certificate Deletion Failed\n");
6638 _LOGE("Certificate Deletion Success\n");
6640 /*Commit transaction*/
6641 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6642 if (ret != SQLITE_OK) {
6643 _LOGE("Failed to commit transaction, Rollback now\n");
6644 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6645 ret = PMINFO_R_ERROR;
6648 _LOGE("Transaction Commit and End\n");
6651 sqlite3_close(cert_db);
6655 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
6657 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
6658 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6660 char *manifest = NULL;
6661 manifest_x *mfx = NULL;
6663 manifest = pkgmgr_parser_get_manifest_file(pkgid);
6664 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
6666 mfx = pkgmgr_parser_process_manifest_xml(manifest);
6671 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
6673 *handle = (void *)mfx;
6678 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
6680 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
6681 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6683 int len = strlen(type);
6684 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6686 manifest_x *mfx = (manifest_x *)handle;
6688 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
6692 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
6694 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
6695 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6697 int len = strlen(version);
6698 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6700 manifest_x *mfx = (manifest_x *)handle;
6702 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
6706 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6708 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6709 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6711 manifest_x *mfx = (manifest_x *)handle;
6713 if (location == INSTALL_INTERNAL)
6714 strcpy(mfx->installlocation, "internal-only");
6715 else if (location == INSTALL_EXTERNAL)
6716 strcpy(mfx->installlocation, "prefer-external");
6721 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
6723 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6724 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6726 manifest_x *mfx = (manifest_x *)handle;
6728 mfx->package_size = strdup(size);
6733 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
6735 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6736 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6738 int len = strlen(label_txt);
6739 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6741 manifest_x *mfx = (manifest_x *)handle;
6743 label_x *label = calloc(1, sizeof(label_x));
6744 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6746 LISTADD(mfx->label, label);
6748 mfx->label->lang = strdup(locale);
6750 mfx->label->lang = strdup(DEFAULT_LOCALE);
6751 mfx->label->text = strdup(label_txt);
6756 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
6758 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6759 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6761 int len = strlen(icon_txt);
6762 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6764 manifest_x *mfx = (manifest_x *)handle;
6766 icon_x *icon = calloc(1, sizeof(icon_x));
6767 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6769 LISTADD(mfx->icon, icon);
6771 mfx->icon->lang = strdup(locale);
6773 mfx->icon->lang = strdup(DEFAULT_LOCALE);
6774 mfx->icon->text = strdup(icon_txt);
6779 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
6781 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6782 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6784 int len = strlen(desc_txt);
6785 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6787 manifest_x *mfx = (manifest_x *)handle;
6789 description_x *description = calloc(1, sizeof(description_x));
6790 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6792 LISTADD(mfx->description, description);
6794 mfx->description->lang = strdup(locale);
6796 mfx->description->lang = strdup(DEFAULT_LOCALE);
6797 mfx->description->text = strdup(desc_txt);
6802 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
6803 const char *author_email, const char *author_href, const char *locale)
6805 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6806 manifest_x *mfx = (manifest_x *)handle;
6807 author_x *author = calloc(1, sizeof(author_x));
6808 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6810 LISTADD(mfx->author, author);
6812 mfx->author->text = strdup(author_name);
6814 mfx->author->email = strdup(author_email);
6816 mfx->author->href = strdup(author_href);
6818 mfx->author->lang = strdup(locale);
6820 mfx->author->lang = strdup(DEFAULT_LOCALE);
6824 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
6826 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6827 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6829 manifest_x *mfx = (manifest_x *)handle;
6832 strcpy(mfx->removable, "false");
6833 else if (removable == 1)
6834 strcpy(mfx->removable, "true");
6839 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
6841 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6842 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6844 manifest_x *mfx = (manifest_x *)handle;
6847 strcpy(mfx->preload, "false");
6848 else if (preload == 1)
6849 strcpy(mfx->preload, "true");
6854 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6856 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6857 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6859 manifest_x *mfx = (manifest_x *)handle;
6861 if (location == INSTALL_INTERNAL)
6862 strcpy(mfx->installed_storage, "installed_internal");
6863 else if (location == INSTALL_EXTERNAL)
6864 strcpy(mfx->installed_storage, "installed_external");
6869 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6871 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6874 manifest_x *mfx = NULL;
6875 mfx = (manifest_x *)handle;
6877 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
6878 retvm_if(ret != 0, PMINFO_R_ERROR, "Failed to store info in DB\n");
6880 ret = __update_ail_appinfo(mfx);
6881 retvm_if(ret != 0, PMINFO_R_ERROR, "Failed to store info in DB\n");
6883 _LOGE("Successfully stored info in DB\n");
6887 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6889 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6891 manifest_x *mfx = NULL;
6892 mfx = (manifest_x *)handle;
6893 pkgmgr_parser_free_manifest_xml(mfx);
6897 API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
6899 /* Should be implemented later */
6903 API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
6905 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6907 char query[MAX_QUERY_LEN] = {'\0'};
6908 sqlite3 *pkginfo_db = NULL;
6910 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
6911 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
6913 /*Begin transaction*/
6914 ret = sqlite3_exec(pkginfo_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6915 if (ret != SQLITE_OK) {
6916 _LOGE("Failed to begin transaction\n");
6917 sqlite3_close(pkginfo_db);
6918 return PMINFO_R_ERROR;
6920 _LOGD("Transaction Begin\n");
6922 memset(query, '\0', MAX_QUERY_LEN);
6923 snprintf(query, MAX_QUERY_LEN,
6924 "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
6926 char *error_message = NULL;
6928 sqlite3_exec(pkginfo_db, query, NULL, NULL, &error_message)) {
6929 _LOGE("Don't execute query = %s error message = %s\n", query,
6931 sqlite3_free(error_message);
6932 return PMINFO_R_ERROR;
6934 sqlite3_free(error_message);
6936 /*Commit transaction*/
6937 ret = sqlite3_exec(pkginfo_db, "COMMIT", NULL, NULL, NULL);
6938 if (ret != SQLITE_OK) {
6939 _LOGE("Failed to commit transaction. Rollback now\n");
6940 sqlite3_exec(pkginfo_db, "ROLLBACK", NULL, NULL, NULL);
6941 sqlite3_close(pkginfo_db);
6942 return PMINFO_R_ERROR;
6944 _LOGD("Transaction Commit and End\n");
6945 sqlite3_close(pkginfo_db);
6951 API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
6953 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6954 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6955 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6956 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6957 int ret = PMINFO_R_OK;
6958 char query[MAX_QUERY_LEN] = {'\0'};
6959 char *error_message = NULL;
6960 pkgmgr_datacontrol_x *data = NULL;
6962 sqlite3 *datacontrol_info_db = NULL;
6965 ret = db_util_open(DATACONTROL_DB, &datacontrol_info_db, 0);
6966 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
6968 data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x));
6970 _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
6971 sqlite3_close(datacontrol_info_db);
6972 return PMINFO_R_ERROR;
6975 snprintf(query, MAX_QUERY_LEN,
6976 "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",
6980 sqlite3_exec(datacontrol_info_db, query, __datacontrol_cb, (void *)data, &error_message)) {
6981 _LOGE("Don't execute query = %s error message = %s\n", query,
6983 sqlite3_free(error_message);
6984 sqlite3_close(datacontrol_info_db);
6985 return PMINFO_R_ERROR;
6988 *appid = (char *)data->appid;
6989 *access = (char *)data->access;
6991 sqlite3_close(datacontrol_info_db);
6996 API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
6998 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
7000 char query[MAX_QUERY_LEN] = {'\0'};
7001 char *error_message = NULL;
7002 sqlite3 *pkginfo_db = NULL;
7005 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
7006 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
7008 /*Begin transaction*/
7009 ret = sqlite3_exec(pkginfo_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
7010 if (ret != SQLITE_OK) {
7011 _LOGE("Failed to begin transaction\n");
7012 sqlite3_close(pkginfo_db);
7013 return PMINFO_R_ERROR;
7015 _LOGD("Transaction Begin\n");
7017 memset(query, '\0', MAX_QUERY_LEN);
7018 snprintf(query, MAX_QUERY_LEN, "update package_app_localized_info set app_label='%s' where app_id='%s'", label, appid);
7020 ret = sqlite3_exec(pkginfo_db, query, NULL, NULL, &error_message);
7021 if (ret != SQLITE_OK) {
7022 _LOGE("Don't execute query = %s error message = %s\n", query, error_message);
7023 sqlite3_free(error_message);
7024 return PMINFO_R_ERROR;
7027 /*Commit transaction*/
7028 ret = sqlite3_exec(pkginfo_db, "COMMIT", NULL, NULL, NULL);
7029 if (ret != SQLITE_OK) {
7030 _LOGE("Failed to commit transaction. Rollback now\n");
7031 sqlite3_exec(pkginfo_db, "ROLLBACK", NULL, NULL, NULL);
7032 sqlite3_close(pkginfo_db);
7033 return PMINFO_R_ERROR;
7035 _LOGD("Transaction Commit and End\n");
7036 sqlite3_close(pkginfo_db);
7041 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
7043 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
7044 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
7046 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
7047 val = (char *)info->uiapp_info->guestmode_visibility;
7049 if (strcasecmp(val, "true") == 0){
7051 }else if (strcasecmp(val, "false") == 0){
7060 API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
7062 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
7065 char *noti_string = NULL;
7067 char query[MAX_QUERY_LEN] = {'\0'};
7068 char *errmsg = NULL;
7069 sqlite3 *pkgmgr_parser_db;
7071 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
7072 val = (char *)info->uiapp_info->guestmode_visibility;
7075 db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db, SQLITE_OPEN_READWRITE, NULL);
7077 if (ret != SQLITE_OK) {
7078 _LOGE("DB Open Failed\n");
7079 return PMINFO_R_ERROR;
7082 /*TODO: Write to DB here*/
7084 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
7086 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
7088 if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
7089 _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
7091 sqlite3_close(pkgmgr_parser_db);
7092 return PMINFO_R_ERROR;
7094 sqlite3_close(pkgmgr_parser_db);
7095 len = strlen((char *)info->uiapp_info->appid) + 8;
7096 noti_string = calloc(1, len);
7097 if (noti_string == NULL){
7098 return PMINFO_R_ERROR;
7100 snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
7101 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
7102 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
7109 /* pkgmgrinfo client start*/
7110 API pkgmgrinfo_client *pkgmgrinfo_client_new(pkgmgrinfo_client_type ctype)
7113 char *errmsg = NULL;
7115 void *handle = NULL;
7116 pkgmgrinfo_client *(*__pkgmgr_client_new)(pkgmgrinfo_client_type ctype) = NULL;
7118 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7119 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7121 __pkgmgr_client_new = dlsym(handle, "pkgmgr_client_new");
7123 tryvm_if((errmsg != NULL) || (__pkgmgr_client_new == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7125 pc = __pkgmgr_client_new(ctype);
7126 tryvm_if(pc == NULL, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7130 return (pkgmgrinfo_client *) pc;
7133 API int pkgmgrinfo_client_set_status_type(pkgmgrinfo_client *pc, int status_type)
7136 char *errmsg = NULL;
7137 void *handle = NULL;
7138 int (*__pkgmgr_client_set_status_type)(pkgmgrinfo_client *pc, int status_type) = NULL;
7140 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7141 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7143 __pkgmgr_client_set_status_type = dlsym(handle, "pkgmgr_client_set_status_type");
7145 tryvm_if((errmsg != NULL) || (__pkgmgr_client_set_status_type == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7147 ret = __pkgmgr_client_set_status_type(pc, status_type);
7148 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7155 API int pkgmgrinfo_client_listen_status(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data)
7158 char *errmsg = NULL;
7159 void *handle = NULL;
7160 int (*__pkgmgr_client_listen_status)(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data) = NULL;
7162 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7163 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7165 __pkgmgr_client_listen_status = dlsym(handle, "pkgmgr_client_listen_status");
7167 tryvm_if((errmsg != NULL) || (__pkgmgr_client_listen_status == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7169 ret = __pkgmgr_client_listen_status(pc, event_cb, data);
7170 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7177 API int pkgmgrinfo_client_free(pkgmgrinfo_client *pc)
7180 char *errmsg = NULL;
7181 void *handle = NULL;
7182 int (*__pkgmgr_client_free)(pkgmgrinfo_client *pc) = NULL;
7184 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7185 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7187 __pkgmgr_client_free = dlsym(handle, "pkgmgr_client_free");
7189 tryvm_if((errmsg != NULL) || (__pkgmgr_client_free == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7191 ret = __pkgmgr_client_free(pc);
7192 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7199 API int pkgmgrinfo_client_request_enable_external_pkg(char *pkgid)
7202 DBusConnection *bus;
7203 DBusMessage *message;
7205 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
7207 if(__get_pkg_location(pkgid) != PMINFO_EXTERNAL_STORAGE)
7210 bus = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
7211 retvm_if(bus == NULL, PMINFO_R_EINVAL, "dbus_bus_get() failed.");
7213 message = dbus_message_new_method_call (SERVICE_NAME, PATH_NAME, INTERFACE_NAME, METHOD_NAME);
7214 retvm_if(message == NULL, PMINFO_R_EINVAL, "dbus_message_new_method_call() failed.");
7216 dbus_message_append_args(message, DBUS_TYPE_STRING, &pkgid, DBUS_TYPE_INVALID);
7218 ret = dbus_connection_send_with_reply_and_block(bus, message, -1, NULL);
7219 retvm_if(!ret, ret = PMINFO_R_EINVAL, "connection_send dbus fail");
7221 dbus_connection_flush(bus);
7222 dbus_message_unref(message);
7227 /* pkgmgrinfo client end*/