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.
34 #include <libxml/parser.h>
35 #include <libxml/xmlreader.h>
36 #include <libxml/xmlschemas.h>
38 #include "pkgmgr_parser.h"
39 #include "pkgmgr-info-internal.h"
40 #include "pkgmgr-info-debug.h"
41 #include "pkgmgr-info.h"
42 #include "pkgmgr_parser_db.h"
46 #define ASC_CHAR(s) (const char *)s
47 #define XML_CHAR(s) (const xmlChar *)s
49 #define MANIFEST_DB "/opt/dbspace/.pkgmgr_parser.db"
50 #define MAX_QUERY_LEN 4096
51 #define MAX_CERT_TYPE 9
52 #define CERT_DB "/opt/dbspace/.pkgmgr_cert.db"
53 #define DATACONTROL_DB "/opt/usr/dbspace/.app-package.db"
54 #define PKG_TYPE_STRING_LEN_MAX 128
55 #define PKG_VERSION_STRING_LEN_MAX 128
56 #define PKG_VALUE_STRING_LEN_MAX 512
57 #define PKG_LOCALE_STRING_LEN_MAX 8
58 #define PKG_RW_PATH "/opt/usr/apps/"
59 #define PKG_RO_PATH "/usr/apps/"
60 #define BLOCK_SIZE 4096 /*in bytes*/
62 #define MMC_PATH "/opt/storage/sdcard"
63 #define PKG_SD_PATH MMC_PATH"/app2sd/"
64 #define PKG_INSTALLATION_PATH "/opt/usr/apps/"
66 #define FILTER_QUERY_COUNT_PACKAGE "select count(DISTINCT package_info.package) " \
67 "from package_info LEFT OUTER JOIN package_localized_info " \
68 "ON package_info.package=package_localized_info.package " \
69 "and package_localized_info.package_locale='%s' where "
71 #define FILTER_QUERY_LIST_PACKAGE "select DISTINCT package_info.package " \
72 "from package_info LEFT OUTER JOIN package_localized_info " \
73 "ON package_info.package=package_localized_info.package " \
74 "and package_localized_info.package_locale='%s' where "
76 #define FILTER_QUERY_COUNT_APP "select count(DISTINCT package_app_info.app_id) " \
77 "from package_app_info LEFT OUTER JOIN package_app_localized_info " \
78 "ON package_app_info.app_id=package_app_localized_info.app_id " \
79 "and package_app_localized_info.app_locale='%s' " \
80 "LEFT OUTER JOIN package_app_app_svc " \
81 "ON package_app_info.app_id=package_app_app_svc.app_id " \
82 "LEFT OUTER JOIN package_app_app_category " \
83 "ON package_app_info.app_id=package_app_app_category.app_id where "
85 #define FILTER_QUERY_LIST_APP "select DISTINCT package_app_info.app_id, package_app_info.app_component " \
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 METADATA_FILTER_QUERY_SELECT_CLAUSE "select DISTINCT package_app_info.app_id, package_app_info.app_component " \
95 "from package_app_info LEFT OUTER JOIN package_app_app_metadata " \
96 "ON package_app_info.app_id=package_app_app_metadata.app_id where "
98 #define METADATA_FILTER_QUERY_UNION_CLAUSE " UNION "METADATA_FILTER_QUERY_SELECT_CLAUSE
100 #define LANGUAGE_LENGTH 2
102 typedef struct _pkgmgr_instcertinfo_x {
104 char *cert_info[MAX_CERT_TYPE]; /*certificate data*/
105 int is_new[MAX_CERT_TYPE]; /*whether already exist in table or not*/
106 int ref_count[MAX_CERT_TYPE]; /*reference count of certificate data*/
107 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
108 } pkgmgr_instcertinfo_x;
110 typedef struct _pkgmgr_certindexinfo_x {
113 } pkgmgr_certindexinfo_x;
115 typedef struct _pkgmgr_pkginfo_x {
116 manifest_x *manifest_info;
119 struct _pkgmgr_pkginfo_x *prev;
120 struct _pkgmgr_pkginfo_x *next;
123 typedef struct _pkgmgr_cert_x {
128 typedef struct _pkgmgr_datacontrol_x {
131 } pkgmgr_datacontrol_x;
133 typedef struct _pkgmgr_iconpath_x {
138 typedef struct _pkgmgr_image_x {
142 typedef struct _pkgmgr_locale_x {
146 typedef struct _pkgmgr_appinfo_x {
149 pkgmgrinfo_app_component app_component;
151 uiapplication_x *uiapp_info;
152 serviceapplication_x *svcapp_info;
156 typedef struct _pkgmgr_certinfo_x {
159 char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
160 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
164 typedef struct _pkgmgrinfo_filter_x {
166 } pkgmgrinfo_filter_x;
168 typedef struct _pkgmgrinfo_node_x {
174 typedef struct _pkgmgrinfo_appcontrol_x {
183 } pkgmgrinfo_appcontrol_x;
185 typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
187 char *pkgtype = "rpm";
188 __thread sqlite3 *manifest_db = NULL;
189 __thread sqlite3 *datacontrol_db = NULL;
190 __thread sqlite3 *cert_db = NULL;
192 static int __open_manifest_db();
193 static int __exec_pkginfo_query(char *query, void *data);
194 static int __exec_certinfo_query(char *query, void *data);
195 static int __exec_certindexinfo_query(char *query, void *data);
196 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname);
197 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname);
198 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname);
199 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname);
200 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname);
201 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname);
202 static int __count_cb(void *data, int ncols, char **coltxt, char **colname);
203 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
204 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
205 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname);
206 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname);
207 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data);
208 static void __cleanup_appinfo(pkgmgr_appinfo_x *data);
209 static char* __convert_system_locale_to_manifest_locale(char *syslocale);
210 static void __destroy_each_node(gpointer data, gpointer user_data);
211 static void __get_filter_condition(gpointer data, char **condition);
212 static void __get_metadata_filter_condition(gpointer data, char **condition);
213 static gint __compare_func(gconstpointer data1, gconstpointer data2);
214 static int __delete_certinfo(const char *pkgid);
216 static gint __compare_func(gconstpointer data1, gconstpointer data2)
218 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
219 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
220 if (node1->prop == node2->prop)
222 else if (node1->prop > node2->prop)
228 static int __count_cb(void *data, int ncols, char **coltxt, char **colname)
231 *p = atoi(coltxt[0]);
232 _LOGE("count value is %d\n", *p);
236 static void __destroy_each_node(gpointer data, gpointer user_data)
238 ret_if(data == NULL);
239 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
252 static void __get_metadata_filter_condition(gpointer data, char **condition)
254 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
255 char key[MAX_QUERY_LEN] = {'\0'};
256 char value[MAX_QUERY_LEN] = {'\0'};
258 snprintf(key, MAX_QUERY_LEN, "(package_app_app_metadata.md_key='%s'", node->key);
261 snprintf(value, MAX_QUERY_LEN, " AND package_app_app_metadata.md_value='%s')", node->value);
266 *condition = strdup(key);
270 static void __get_filter_condition(gpointer data, char **condition)
272 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
273 char buf[MAX_QUERY_LEN + 1] = {'\0'};
274 char temp[PKG_STRING_LEN_MAX] = {'\0'};
275 switch (node->prop) {
276 case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
277 snprintf(buf, MAX_QUERY_LEN, "package_info.package='%s'", node->value);
279 case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
280 snprintf(buf, MAX_QUERY_LEN, "package_info.package_type='%s'", node->value);
282 case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
283 snprintf(buf, MAX_QUERY_LEN, "package_info.package_version='%s'", node->value);
285 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
286 snprintf(buf, MAX_QUERY_LEN, "package_info.install_location='%s'", node->value);
288 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
289 snprintf(buf, MAX_QUERY_LEN, "package_info.installed_storage='%s'", node->value);
291 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
292 snprintf(buf, MAX_QUERY_LEN, "package_info.author_name='%s'", node->value);
294 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
295 snprintf(buf, MAX_QUERY_LEN, "package_info.author_href='%s'", node->value);
297 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
298 snprintf(buf, MAX_QUERY_LEN, "package_info.author_email='%s'", node->value);
300 case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
301 snprintf(buf, MAX_QUERY_LEN, "package_info.package_size='%s'", node->value);
303 case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
304 snprintf(buf, MAX_QUERY_LEN, "package_info.package_removable IN %s", node->value);
306 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
307 snprintf(buf, MAX_QUERY_LEN, "package_info.package_preload IN %s", node->value);
309 case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
310 snprintf(buf, MAX_QUERY_LEN, "package_info.package_readonly IN %s", node->value);
312 case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
313 snprintf(buf, MAX_QUERY_LEN, "package_info.package_update IN %s", node->value);
315 case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
316 snprintf(buf, MAX_QUERY_LEN, "package_info.package_appsetting IN %s", node->value);
318 case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
319 snprintf(buf, MAX_QUERY_LEN, "package_info.package_nodisplay IN %s", node->value);
322 case E_PMINFO_APPINFO_PROP_APP_ID:
323 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_id='%s'", node->value);
325 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
326 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_component='%s'", node->value);
328 case E_PMINFO_APPINFO_PROP_APP_EXEC:
329 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_exec='%s'", node->value);
331 case E_PMINFO_APPINFO_PROP_APP_ICON:
332 snprintf(buf, MAX_QUERY_LEN, "package_app_localized_info.app_icon='%s'", node->value);
334 case E_PMINFO_APPINFO_PROP_APP_TYPE:
335 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_type='%s'", node->value);
337 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
338 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
339 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.operation IN %s", temp);
341 case E_PMINFO_APPINFO_PROP_APP_URI:
342 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
343 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.uri_scheme IN %s", temp);
345 case E_PMINFO_APPINFO_PROP_APP_MIME:
346 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
347 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.mime_type IN %s", temp);
349 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
350 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
351 snprintf(buf, MAX_QUERY_LEN, "package_app_app_category.category IN %s", temp);
353 case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
354 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_nodisplay IN %s", node->value);
356 case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
357 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_multiple IN %s", node->value);
359 case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
360 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_onboot IN %s", node->value);
362 case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
363 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_autorestart IN %s", node->value);
365 case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
366 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_taskmanage IN %s", node->value);
368 case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
369 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_hwacceleration='%s'", node->value);
371 case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
372 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
375 _LOGE("Invalid Property Type\n");
379 *condition = strdup(buf);
383 static char* __convert_system_locale_to_manifest_locale(char *syslocale)
385 if (syslocale == NULL)
386 return strdup(DEFAULT_LOCALE);
388 locale = (char *)calloc(1, 6);
389 retvm_if(!locale, NULL, "Malloc Failed\n");
391 strncpy(locale, syslocale, 2);
392 strncat(locale, "-", 1);
393 locale[3] = syslocale[3] + 32;
394 locale[4] = syslocale[4] + 32;
398 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
400 ret_if(data == NULL);
402 free((void *)data->locale);
406 pkgmgr_parser_free_manifest_xml(data->manifest_info);
412 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
414 ret_if(data == NULL);
416 free((void *)data->package);
417 data->package = NULL;
420 free((void *)data->locale);
424 manifest_x *mfx = calloc(1, sizeof(manifest_x));
425 if (data->app_component == PMINFO_UI_APP)
426 mfx->uiapplication = data->uiapp_info;
427 else if (data->app_component == PMINFO_SVC_APP)
428 mfx->serviceapplication = data->svcapp_info;
429 pkgmgr_parser_free_manifest_xml(mfx);
435 static int __open_manifest_db()
438 if (access(MANIFEST_DB, F_OK) == 0) {
440 db_util_open_with_options(MANIFEST_DB, &manifest_db,
441 SQLITE_OPEN_READONLY, NULL);
442 retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", MANIFEST_DB);
445 _LOGE("Manifest DB does not exists !!\n");
449 static int __open_datacontrol_db()
452 if (access(DATACONTROL_DB, F_OK) == 0) {
454 db_util_open_with_options(DATACONTROL_DB, &datacontrol_db,
455 SQLITE_OPEN_READONLY, NULL);
456 retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", DATACONTROL_DB);
459 _LOGE("Datacontrol DB does not exists !!\n");
463 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
465 pkgmgr_pkginfo_x *udata = (pkgmgr_pkginfo_x *)data;
467 pkgmgr_pkginfo_x *info = NULL;
468 info = calloc(1, sizeof(pkgmgr_pkginfo_x));
469 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
471 LISTADD(udata, info);
472 for(i = 0; i < ncols; i++)
474 if (strcmp(colname[i], "package") == 0) {
476 info->manifest_info->package = strdup(coltxt[i]);
478 info->manifest_info->package = NULL;
486 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname)
488 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
491 uiapplication_x *uiapp = NULL;
492 serviceapplication_x *svcapp = NULL;
493 for(i = 0; i < ncols; i++)
495 if ((strcmp(colname[i], "app_component") == 0) ||
496 (strcmp(colname[i], "package_app_info.app_component") == 0)) {
498 if (strcmp(coltxt[i], "uiapp") == 0) {
499 uiapp = calloc(1, sizeof(uiapplication_x));
501 _LOGE("Out of Memory!!!\n");
504 LISTADD(info->manifest_info->uiapplication, uiapp);
505 for(j = 0; j < ncols; j++)
507 if ((strcmp(colname[j], "app_id") == 0) ||
508 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
510 info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
511 } else if (strcmp(colname[j], "package") == 0) {
513 info->manifest_info->uiapplication->package = strdup(coltxt[j]);
518 svcapp = calloc(1, sizeof(serviceapplication_x));
519 if (svcapp == NULL) {
520 _LOGE("Out of Memory!!!\n");
523 LISTADD(info->manifest_info->serviceapplication, svcapp);
524 for(j = 0; j < ncols; j++)
526 if ((strcmp(colname[j], "app_id") == 0) ||
527 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
529 info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
530 } else if (strcmp(colname[j], "package") == 0) {
532 info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
546 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
548 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
550 uiapplication_x *uiapp = NULL;
552 label_x *label = NULL;
554 uiapp = calloc(1, sizeof(uiapplication_x));
555 LISTADD(info->manifest_info->uiapplication, uiapp);
556 icon = calloc(1, sizeof(icon_x));
557 LISTADD(info->manifest_info->uiapplication->icon, icon);
558 label = calloc(1, sizeof(label_x));
559 LISTADD(info->manifest_info->uiapplication->label, label);
561 for(i = 0; i < ncols; i++)
563 if (strcmp(colname[i], "app_id") == 0) {
565 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
567 info->manifest_info->uiapplication->appid = NULL;
568 } else if (strcmp(colname[i], "app_exec") == 0) {
570 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
572 info->manifest_info->uiapplication->exec = NULL;
573 } else if (strcmp(colname[i], "app_type") == 0 ){
575 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
577 info->manifest_info->uiapplication->type = NULL;
578 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
580 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
582 info->manifest_info->uiapplication->nodisplay = NULL;
583 } else if (strcmp(colname[i], "app_multiple") == 0 ){
585 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
587 info->manifest_info->uiapplication->multiple = NULL;
588 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
590 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
592 info->manifest_info->uiapplication->taskmanage = NULL;
593 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
595 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
597 info->manifest_info->uiapplication->hwacceleration = NULL;
598 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
600 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
602 info->manifest_info->uiapplication->indicatordisplay = NULL;
603 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
605 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
607 info->manifest_info->uiapplication->portraitimg = NULL;
608 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
610 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
612 info->manifest_info->uiapplication->landscapeimg = NULL;
613 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
615 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
617 info->manifest_info->uiapplication->guestmode_visibility = NULL;
618 } else if (strcmp(colname[i], "package") == 0 ){
620 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
622 info->manifest_info->uiapplication->package = NULL;
623 } else if (strcmp(colname[i], "app_icon") == 0) {
625 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
627 info->manifest_info->uiapplication->icon->text = NULL;
628 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
630 info->manifest_info->uiapplication->enabled= strdup(coltxt[i]);
632 info->manifest_info->uiapplication->enabled = NULL;
633 } else if (strcmp(colname[i], "app_label") == 0 ) {
635 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
637 info->manifest_info->uiapplication->label->text = NULL;
638 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
640 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
642 info->manifest_info->uiapplication->recentimage = NULL;
643 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
645 info->manifest_info->uiapplication->mainapp = strdup(coltxt[i]);
647 info->manifest_info->uiapplication->mainapp = NULL;
648 } else if (strcmp(colname[i], "app_locale") == 0 ) {
650 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
651 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
654 info->manifest_info->uiapplication->icon->lang = NULL;
655 info->manifest_info->uiapplication->label->lang = NULL;
657 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
659 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
661 info->manifest_info->uiapplication->permission_type = NULL;
662 } else if (strcmp(colname[i], "component_type") == 0 ) {
664 info->manifest_info->uiapplication->component_type = strdup(coltxt[i]);
666 info->manifest_info->uiapplication->component_type = NULL;
667 } else if (strcmp(colname[i], "app_preload") == 0 ) {
669 info->manifest_info->uiapplication->preload = strdup(coltxt[i]);
671 info->manifest_info->uiapplication->preload = NULL;
672 } else if (strcmp(colname[i], "app_submode") == 0 ) {
674 info->manifest_info->uiapplication->submode = strdup(coltxt[i]);
676 info->manifest_info->uiapplication->submode = NULL;
677 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
679 info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[i]);
681 info->manifest_info->uiapplication->submode_mainid = NULL;
688 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
690 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
692 serviceapplication_x *svcapp = NULL;
694 label_x *label = NULL;
696 svcapp = calloc(1, sizeof(serviceapplication_x));
697 LISTADD(info->manifest_info->serviceapplication, svcapp);
698 icon = calloc(1, sizeof(icon_x));
699 LISTADD(info->manifest_info->serviceapplication->icon, icon);
700 label = calloc(1, sizeof(label_x));
701 LISTADD(info->manifest_info->serviceapplication->label, label);
702 for(i = 0; i < ncols; i++)
704 if (strcmp(colname[i], "app_id") == 0) {
706 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
708 info->manifest_info->serviceapplication->appid = NULL;
709 } else if (strcmp(colname[i], "app_exec") == 0) {
711 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
713 info->manifest_info->serviceapplication->exec = NULL;
714 } else if (strcmp(colname[i], "app_type") == 0 ){
716 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
718 info->manifest_info->serviceapplication->type = NULL;
719 } else if (strcmp(colname[i], "app_onboot") == 0 ){
721 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
723 info->manifest_info->serviceapplication->onboot = NULL;
724 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
726 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
728 info->manifest_info->serviceapplication->autorestart = NULL;
729 } else if (strcmp(colname[i], "package") == 0 ){
731 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
733 info->manifest_info->serviceapplication->package = NULL;
734 } else if (strcmp(colname[i], "app_icon") == 0) {
736 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
738 info->manifest_info->serviceapplication->icon->text = NULL;
739 } else if (strcmp(colname[i], "app_label") == 0 ) {
741 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
743 info->manifest_info->serviceapplication->label->text = NULL;
744 } else if (strcmp(colname[i], "app_locale") == 0 ) {
746 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
747 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
750 info->manifest_info->serviceapplication->icon->lang = NULL;
751 info->manifest_info->serviceapplication->label->lang = NULL;
753 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
755 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
757 info->manifest_info->serviceapplication->permission_type = NULL;
764 static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
766 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
769 uiapplication_x *uiapp = NULL;
770 serviceapplication_x *svcapp = NULL;
771 for(j = 0; j < ncols; j++)
773 if (strcmp(colname[j], "app_component") == 0) {
775 if (strcmp(coltxt[j], "uiapp") == 0) {
776 uiapp = calloc(1, sizeof(uiapplication_x));
778 _LOGE("Out of Memory!!!\n");
781 LISTADD(info->manifest_info->uiapplication, uiapp);
782 for(i = 0; i < ncols; i++)
784 if (strcmp(colname[i], "app_id") == 0) {
786 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
788 info->manifest_info->uiapplication->appid = NULL;
789 } else if (strcmp(colname[i], "app_exec") == 0) {
791 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
793 info->manifest_info->uiapplication->exec = NULL;
794 } else if (strcmp(colname[i], "app_type") == 0 ){
796 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
798 info->manifest_info->uiapplication->type = NULL;
799 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
801 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
803 info->manifest_info->uiapplication->nodisplay = NULL;
804 } else if (strcmp(colname[i], "app_multiple") == 0 ){
806 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
808 info->manifest_info->uiapplication->multiple = NULL;
809 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
811 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
813 info->manifest_info->uiapplication->taskmanage = NULL;
814 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
816 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
818 info->manifest_info->uiapplication->hwacceleration = NULL;
819 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
821 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
823 info->manifest_info->uiapplication->indicatordisplay = NULL;
824 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
826 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
828 info->manifest_info->uiapplication->portraitimg = NULL;
829 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
831 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
833 info->manifest_info->uiapplication->landscapeimg = NULL;
834 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
836 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
838 info->manifest_info->uiapplication->guestmode_visibility = NULL;
839 } else if (strcmp(colname[i], "package") == 0 ){
841 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
843 info->manifest_info->uiapplication->package = NULL;
844 } else if (strcmp(colname[i], "app_icon") == 0) {
846 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
848 info->manifest_info->uiapplication->icon->text = NULL;
849 } else if (strcmp(colname[i], "app_label") == 0 ) {
851 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
853 info->manifest_info->uiapplication->label->text = NULL;
854 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
856 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
858 info->manifest_info->uiapplication->recentimage = NULL;
859 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
861 info->manifest_info->uiapplication->mainapp= strdup(coltxt[i]);
863 info->manifest_info->uiapplication->mainapp = NULL;
864 } else if (strcmp(colname[i], "app_locale") == 0 ) {
866 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
867 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
870 info->manifest_info->uiapplication->icon->lang = NULL;
871 info->manifest_info->uiapplication->label->lang = NULL;
873 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
875 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
877 info->manifest_info->uiapplication->permission_type = NULL;
882 svcapp = calloc(1, sizeof(serviceapplication_x));
883 if (svcapp == NULL) {
884 _LOGE("Out of Memory!!!\n");
887 LISTADD(info->manifest_info->serviceapplication, svcapp);
888 for(i = 0; i < ncols; i++)
890 if (strcmp(colname[i], "app_id") == 0) {
892 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
894 info->manifest_info->serviceapplication->appid = NULL;
895 } else if (strcmp(colname[i], "app_exec") == 0) {
897 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
899 info->manifest_info->serviceapplication->exec = NULL;
900 } else if (strcmp(colname[i], "app_type") == 0 ){
902 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
904 info->manifest_info->serviceapplication->type = NULL;
905 } else if (strcmp(colname[i], "app_onboot") == 0 ){
907 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
909 info->manifest_info->serviceapplication->onboot = NULL;
910 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
912 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
914 info->manifest_info->serviceapplication->autorestart = NULL;
915 } else if (strcmp(colname[i], "package") == 0 ){
917 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
919 info->manifest_info->serviceapplication->package = NULL;
920 } else if (strcmp(colname[i], "app_icon") == 0) {
922 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
924 info->manifest_info->serviceapplication->icon->text = NULL;
925 } else if (strcmp(colname[i], "app_label") == 0 ) {
927 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
929 info->manifest_info->serviceapplication->label->text = NULL;
930 } else if (strcmp(colname[i], "app_locale") == 0 ) {
932 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
933 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
936 info->manifest_info->serviceapplication->icon->lang = NULL;
937 info->manifest_info->serviceapplication->label->lang = NULL;
939 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
941 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
943 info->manifest_info->serviceapplication->permission_type = NULL;
958 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname)
961 *p = atoi(coltxt[0]);
965 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname)
969 *p = atoi(coltxt[0]);
973 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
975 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
977 author_x *author = NULL;
979 label_x *label = NULL;
980 description_x *description = NULL;
981 privilege_x *privilege = NULL;
983 author = calloc(1, sizeof(author_x));
984 LISTADD(info->manifest_info->author, author);
985 icon = calloc(1, sizeof(icon_x));
986 LISTADD(info->manifest_info->icon, icon);
987 label = calloc(1, sizeof(label_x));
988 LISTADD(info->manifest_info->label, label);
989 description = calloc(1, sizeof(description_x));
990 LISTADD(info->manifest_info->description, description);
991 privilege = calloc(1, sizeof(privilege_x));
992 LISTADD(info->manifest_info->privileges->privilege, privilege);
993 for(i = 0; i < ncols; i++)
995 if (strcmp(colname[i], "package_version") == 0) {
997 info->manifest_info->version = strdup(coltxt[i]);
999 info->manifest_info->version = NULL;
1000 } else if (strcmp(colname[i], "package_type") == 0) {
1002 info->manifest_info->type = strdup(coltxt[i]);
1004 info->manifest_info->type = NULL;
1005 } else if (strcmp(colname[i], "install_location") == 0) {
1007 info->manifest_info->installlocation = strdup(coltxt[i]);
1009 info->manifest_info->installlocation = NULL;
1010 } else if (strcmp(colname[i], "package_size") == 0) {
1012 info->manifest_info->package_size = strdup(coltxt[i]);
1014 info->manifest_info->package_size = NULL;
1015 } else if (strcmp(colname[i], "author_email") == 0 ){
1017 info->manifest_info->author->email = strdup(coltxt[i]);
1019 info->manifest_info->author->email = NULL;
1020 } else if (strcmp(colname[i], "author_href") == 0 ){
1022 info->manifest_info->author->href = strdup(coltxt[i]);
1024 info->manifest_info->author->href = NULL;
1025 } else if (strcmp(colname[i], "package_label") == 0 ){
1027 info->manifest_info->label->text = strdup(coltxt[i]);
1029 info->manifest_info->label->text = NULL;
1030 } else if (strcmp(colname[i], "package_icon") == 0 ){
1032 info->manifest_info->icon->text = strdup(coltxt[i]);
1034 info->manifest_info->icon->text = NULL;
1035 } else if (strcmp(colname[i], "package_description") == 0 ){
1037 info->manifest_info->description->text = strdup(coltxt[i]);
1039 info->manifest_info->description->text = NULL;
1040 } else if (strcmp(colname[i], "package_author") == 0 ){
1042 info->manifest_info->author->text = strdup(coltxt[i]);
1044 info->manifest_info->author->text = NULL;
1045 } else if (strcmp(colname[i], "package_removable") == 0 ){
1047 info->manifest_info->removable = strdup(coltxt[i]);
1049 info->manifest_info->removable = NULL;
1050 } else if (strcmp(colname[i], "package_preload") == 0 ){
1052 info->manifest_info->preload = strdup(coltxt[i]);
1054 info->manifest_info->preload = NULL;
1055 } else if (strcmp(colname[i], "package_readonly") == 0 ){
1057 info->manifest_info->readonly = strdup(coltxt[i]);
1059 info->manifest_info->readonly = NULL;
1060 } else if (strcmp(colname[i], "package_update") == 0 ){
1062 info->manifest_info->update= strdup(coltxt[i]);
1064 info->manifest_info->update = NULL;
1065 } else if (strcmp(colname[i], "package_appsetting") == 0 ){
1067 info->manifest_info->appsetting = strdup(coltxt[i]);
1069 info->manifest_info->appsetting = NULL;
1070 } else if (strcmp(colname[i], "installed_time") == 0 ){
1072 info->manifest_info->installed_time = strdup(coltxt[i]);
1074 info->manifest_info->installed_time = NULL;
1075 } else if (strcmp(colname[i], "mainapp_id") == 0 ){
1077 info->manifest_info->mainapp_id = strdup(coltxt[i]);
1079 info->manifest_info->mainapp_id = NULL;
1080 } else if (strcmp(colname[i], "root_path") == 0 ){
1082 info->manifest_info->root_path = strdup(coltxt[i]);
1084 info->manifest_info->root_path = NULL;
1085 } else if (strcmp(colname[i], "csc_path") == 0 ){
1087 info->manifest_info->csc_path = strdup(coltxt[i]);
1089 info->manifest_info->csc_path = NULL;
1090 } else if (strcmp(colname[i], "privilege") == 0 ){
1092 info->manifest_info->privileges->privilege->text = strdup(coltxt[i]);
1094 info->manifest_info->privileges->privilege->text = NULL;
1095 } else if (strcmp(colname[i], "package_locale") == 0 ){
1097 info->manifest_info->author->lang = strdup(coltxt[i]);
1098 info->manifest_info->icon->lang = strdup(coltxt[i]);
1099 info->manifest_info->label->lang = strdup(coltxt[i]);
1100 info->manifest_info->description->lang = strdup(coltxt[i]);
1103 info->manifest_info->author->lang = NULL;
1104 info->manifest_info->icon->lang = NULL;
1105 info->manifest_info->label->lang = NULL;
1106 info->manifest_info->description->lang = NULL;
1108 } else if (strcmp(colname[i], "package_url") == 0 ){
1110 info->manifest_info->package_url = strdup(coltxt[i]);
1112 info->manifest_info->package_url = NULL;
1120 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1122 if ( strcasecmp(comp, "uiapp") == 0)
1123 return PMINFO_UI_APP;
1124 else if ( strcasecmp(comp, "svcapp") == 0)
1125 return PMINFO_SVC_APP;
1130 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1132 pkgmgr_certindexinfo_x *info = (pkgmgr_certindexinfo_x *)data;
1134 for(i = 0; i < ncols; i++) {
1135 if (strcmp(colname[i], "cert_id") == 0) {
1137 info->cert_id = atoi(coltxt[i]);
1140 } else if (strcmp(colname[i], "cert_ref_count") == 0) {
1142 info->cert_ref_count = atoi(coltxt[i]);
1144 info->cert_ref_count = 0;
1150 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1152 pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)data;
1154 for(i = 0; i < ncols; i++)
1156 if (strcmp(colname[i], "package") == 0) {
1158 info->pkgid = strdup(coltxt[i]);
1161 } else if (strcmp(colname[i], "author_signer_cert") == 0) {
1163 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = atoi(coltxt[i]);
1165 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = 0;
1166 } else if (strcmp(colname[i], "author_im_cert") == 0) {
1168 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1170 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 0;
1171 } else if (strcmp(colname[i], "author_root_cert") == 0) {
1173 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = atoi(coltxt[i]);
1175 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = 0;
1176 } else if (strcmp(colname[i], "dist_signer_cert") == 0 ){
1178 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = atoi(coltxt[i]);
1180 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 0;
1181 } else if (strcmp(colname[i], "dist_im_cert") == 0 ){
1183 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1185 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 0;
1186 } else if (strcmp(colname[i], "dist_root_cert") == 0 ){
1188 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = atoi(coltxt[i]);
1190 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = 0;
1191 } else if (strcmp(colname[i], "dist2_signer_cert") == 0 ){
1193 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = atoi(coltxt[i]);
1195 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 0;
1196 } else if (strcmp(colname[i], "dist2_im_cert") == 0 ){
1198 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1200 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 0;
1201 } else if (strcmp(colname[i], "dist2_root_cert") == 0 ){
1203 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = atoi(coltxt[i]);
1205 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 0;
1206 } else if (strcmp(colname[i], "cert_info") == 0 ){
1208 info->cert_value = strdup(coltxt[i]);
1210 info->cert_value = NULL;
1217 static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1219 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1221 uiapplication_x *uiapp = NULL;
1222 uiapp = calloc(1, sizeof(uiapplication_x));
1223 if (uiapp == NULL) {
1224 _LOGE("Out of Memory!!!\n");
1228 LISTADD(info->uiapp_info, uiapp);
1230 for(i = 0; i < ncols; i++)
1232 if (strcmp(colname[i], "app_id") == 0) {
1233 /*appid being foreign key, is column in every table
1234 Hence appid gets strduped every time leading to memory leak.
1235 If appid is already set, just continue.*/
1236 if (info->uiapp_info->appid)
1239 info->uiapp_info->appid = strdup(coltxt[i]);
1241 info->uiapp_info->appid = NULL;
1242 } else if (strcmp(colname[i], "app_exec") == 0) {
1244 info->uiapp_info->exec = strdup(coltxt[i]);
1246 info->uiapp_info->exec = NULL;
1247 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1249 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1251 info->uiapp_info->nodisplay = NULL;
1252 } else if (strcmp(colname[i], "app_type") == 0 ) {
1254 info->uiapp_info->type = strdup(coltxt[i]);
1256 info->uiapp_info->type = NULL;
1257 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1259 info->uiapp_info->multiple = strdup(coltxt[i]);
1261 info->uiapp_info->multiple = NULL;
1262 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1264 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1266 info->uiapp_info->taskmanage = NULL;
1267 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1269 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1271 info->uiapp_info->hwacceleration = NULL;
1272 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1274 info->uiapp_info->enabled= strdup(coltxt[i]);
1276 info->uiapp_info->enabled = NULL;
1277 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1279 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1281 info->uiapp_info->indicatordisplay = NULL;
1282 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1284 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1286 info->uiapp_info->portraitimg = NULL;
1287 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1289 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1291 info->uiapp_info->landscapeimg = NULL;
1292 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1294 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1296 info->uiapp_info->guestmode_visibility = NULL;
1297 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1299 info->uiapp_info->recentimage = strdup(coltxt[i]);
1301 info->uiapp_info->recentimage = NULL;
1302 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1304 info->uiapp_info->mainapp = strdup(coltxt[i]);
1306 info->uiapp_info->mainapp = NULL;
1307 } else if (strcmp(colname[i], "package") == 0 ) {
1309 info->uiapp_info->package = strdup(coltxt[i]);
1311 info->uiapp_info->package = NULL;
1312 } else if (strcmp(colname[i], "app_component") == 0) {
1314 info->uiapp_info->app_component = strdup(coltxt[i]);
1316 info->uiapp_info->app_component = NULL;
1317 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1319 info->uiapp_info->permission_type = strdup(coltxt[i]);
1321 info->uiapp_info->permission_type = NULL;
1322 } else if (strcmp(colname[i], "component_type") == 0 ) {
1324 info->uiapp_info->component_type = strdup(coltxt[i]);
1326 info->uiapp_info->component_type = NULL;
1327 } else if (strcmp(colname[i], "app_preload") == 0 ) {
1329 info->uiapp_info->preload = strdup(coltxt[i]);
1331 info->uiapp_info->preload = NULL;
1332 } else if (strcmp(colname[i], "app_submode") == 0 ) {
1334 info->uiapp_info->submode = strdup(coltxt[i]);
1336 info->uiapp_info->submode = NULL;
1337 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
1339 info->uiapp_info->submode_mainid = strdup(coltxt[i]);
1341 info->uiapp_info->submode_mainid = NULL;
1349 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1351 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1353 icon_x *icon = NULL;
1354 label_x *label = NULL;
1355 category_x *category = NULL;
1356 metadata_x *metadata = NULL;
1357 permission_x *permission = NULL;
1358 image_x *image = NULL;
1360 switch (info->app_component) {
1362 icon = calloc(1, sizeof(icon_x));
1363 LISTADD(info->uiapp_info->icon, icon);
1364 label = calloc(1, sizeof(label_x));
1365 LISTADD(info->uiapp_info->label, label);
1366 category = calloc(1, sizeof(category_x));
1367 LISTADD(info->uiapp_info->category, category);
1368 metadata = calloc(1, sizeof(metadata_x));
1369 LISTADD(info->uiapp_info->metadata, metadata);
1370 permission = calloc(1, sizeof(permission_x));
1371 LISTADD(info->uiapp_info->permission, permission);
1372 image = calloc(1, sizeof(image_x));
1373 LISTADD(info->uiapp_info->image, image);
1375 for(i = 0; i < ncols; i++)
1377 if (strcmp(colname[i], "app_id") == 0) {
1378 /*appid being foreign key, is column in every table
1379 Hence appid gets strduped every time leading to memory leak.
1380 If appid is already set, just continue.*/
1381 if (info->uiapp_info->appid)
1384 info->uiapp_info->appid = strdup(coltxt[i]);
1386 info->uiapp_info->appid = NULL;
1387 } else if (strcmp(colname[i], "app_exec") == 0) {
1389 info->uiapp_info->exec = strdup(coltxt[i]);
1391 info->uiapp_info->exec = NULL;
1392 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1394 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1396 info->uiapp_info->nodisplay = NULL;
1397 } else if (strcmp(colname[i], "app_type") == 0 ) {
1399 info->uiapp_info->type = strdup(coltxt[i]);
1401 info->uiapp_info->type = NULL;
1402 } else if (strcmp(colname[i], "app_icon_section") == 0 ) {
1404 info->uiapp_info->icon->section= strdup(coltxt[i]);
1406 info->uiapp_info->icon->section = NULL;
1407 } else if (strcmp(colname[i], "app_icon") == 0) {
1409 info->uiapp_info->icon->text = strdup(coltxt[i]);
1411 info->uiapp_info->icon->text = NULL;
1412 } else if (strcmp(colname[i], "app_label") == 0 ) {
1414 info->uiapp_info->label->text = strdup(coltxt[i]);
1416 info->uiapp_info->label->text = NULL;
1417 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1419 info->uiapp_info->multiple = strdup(coltxt[i]);
1421 info->uiapp_info->multiple = NULL;
1422 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1424 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1426 info->uiapp_info->taskmanage = NULL;
1427 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1429 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1431 info->uiapp_info->hwacceleration = NULL;
1432 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1434 info->uiapp_info->enabled= strdup(coltxt[i]);
1436 info->uiapp_info->enabled = NULL;
1437 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1439 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1441 info->uiapp_info->indicatordisplay = NULL;
1442 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1444 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1446 info->uiapp_info->portraitimg = NULL;
1447 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1449 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1451 info->uiapp_info->landscapeimg = NULL;
1452 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1454 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1456 info->uiapp_info->guestmode_visibility = NULL;
1457 } else if (strcmp(colname[i], "category") == 0 ) {
1459 info->uiapp_info->category->name = strdup(coltxt[i]);
1461 info->uiapp_info->category->name = NULL;
1462 } else if (strcmp(colname[i], "md_key") == 0 ) {
1464 info->uiapp_info->metadata->key = strdup(coltxt[i]);
1466 info->uiapp_info->metadata->key = NULL;
1467 } else if (strcmp(colname[i], "md_value") == 0 ) {
1469 info->uiapp_info->metadata->value = strdup(coltxt[i]);
1471 info->uiapp_info->metadata->value = NULL;
1472 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1474 info->uiapp_info->permission->type= strdup(coltxt[i]);
1476 info->uiapp_info->permission->type = NULL;
1477 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1479 info->uiapp_info->permission->value = strdup(coltxt[i]);
1481 info->uiapp_info->permission->value = NULL;
1482 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1484 info->uiapp_info->recentimage = strdup(coltxt[i]);
1486 info->uiapp_info->recentimage = NULL;
1487 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1489 info->uiapp_info->mainapp = strdup(coltxt[i]);
1491 info->uiapp_info->mainapp = NULL;
1492 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1494 info->uiapp_info->icon->lang = strdup(coltxt[i]);
1495 info->uiapp_info->label->lang = strdup(coltxt[i]);
1498 info->uiapp_info->icon->lang = NULL;
1499 info->uiapp_info->label->lang = NULL;
1501 } else if (strcmp(colname[i], "app_image") == 0) {
1503 info->uiapp_info->image->text= strdup(coltxt[i]);
1505 info->uiapp_info->image->text = NULL;
1506 } else if (strcmp(colname[i], "app_image_section") == 0) {
1508 info->uiapp_info->image->section= strdup(coltxt[i]);
1510 info->uiapp_info->image->section = NULL;
1511 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1513 info->uiapp_info->permission_type = strdup(coltxt[i]);
1515 info->uiapp_info->permission_type = NULL;
1516 } else if (strcmp(colname[i], "component_type") == 0 ) {
1518 info->uiapp_info->component_type = strdup(coltxt[i]);
1520 info->uiapp_info->component_type = NULL;
1521 } else if (strcmp(colname[i], "app_preload") == 0 ) {
1523 info->uiapp_info->preload = strdup(coltxt[i]);
1525 info->uiapp_info->preload = NULL;
1526 } else if (strcmp(colname[i], "app_submode") == 0 ) {
1528 info->uiapp_info->submode = strdup(coltxt[i]);
1530 info->uiapp_info->submode = NULL;
1531 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
1533 info->uiapp_info->submode_mainid = strdup(coltxt[i]);
1535 info->uiapp_info->submode_mainid = NULL;
1540 case PMINFO_SVC_APP:
1541 icon = calloc(1, sizeof(icon_x));
1542 LISTADD(info->svcapp_info->icon, icon);
1543 label = calloc(1, sizeof(label_x));
1544 LISTADD(info->svcapp_info->label, label);
1545 category = calloc(1, sizeof(category_x));
1546 LISTADD(info->svcapp_info->category, category);
1547 metadata = calloc(1, sizeof(metadata_x));
1548 LISTADD(info->svcapp_info->metadata, metadata);
1549 permission = calloc(1, sizeof(permission_x));
1550 LISTADD(info->svcapp_info->permission, permission);
1551 for(i = 0; i < ncols; i++)
1553 if (strcmp(colname[i], "app_id") == 0) {
1554 /*appid being foreign key, is column in every table
1555 Hence appid gets strduped every time leading to memory leak.
1556 If appid is already set, just continue.*/
1557 if (info->svcapp_info->appid)
1560 info->svcapp_info->appid = strdup(coltxt[i]);
1562 info->svcapp_info->appid = NULL;
1563 } else if (strcmp(colname[i], "app_exec") == 0) {
1565 info->svcapp_info->exec = strdup(coltxt[i]);
1567 info->svcapp_info->exec = NULL;
1568 } else if (strcmp(colname[i], "app_icon") == 0) {
1570 info->svcapp_info->icon->text = strdup(coltxt[i]);
1572 info->svcapp_info->icon->text = NULL;
1573 } else if (strcmp(colname[i], "app_label") == 0 ) {
1575 info->svcapp_info->label->text = strdup(coltxt[i]);
1577 info->svcapp_info->label->text = NULL;
1578 } else if (strcmp(colname[i], "app_type") == 0 ) {
1580 info->svcapp_info->type = strdup(coltxt[i]);
1582 info->svcapp_info->type = NULL;
1583 } else if (strcmp(colname[i], "app_onboot") == 0 ) {
1585 info->svcapp_info->onboot = strdup(coltxt[i]);
1587 info->svcapp_info->onboot = NULL;
1588 } else if (strcmp(colname[i], "app_autorestart") == 0 ) {
1590 info->svcapp_info->autorestart = strdup(coltxt[i]);
1592 info->svcapp_info->autorestart = NULL;
1593 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1595 info->svcapp_info->enabled= strdup(coltxt[i]);
1597 info->svcapp_info->enabled = NULL;
1598 } else if (strcmp(colname[i], "category") == 0 ) {
1600 info->svcapp_info->category->name = strdup(coltxt[i]);
1602 info->svcapp_info->category->name = NULL;
1603 } else if (strcmp(colname[i], "md_key") == 0 ) {
1605 info->svcapp_info->metadata->key = strdup(coltxt[i]);
1607 info->svcapp_info->metadata->key = NULL;
1608 } else if (strcmp(colname[i], "md_value") == 0 ) {
1610 info->svcapp_info->metadata->value = strdup(coltxt[i]);
1612 info->svcapp_info->metadata->value = NULL;
1613 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1615 info->svcapp_info->permission->type= strdup(coltxt[i]);
1617 info->svcapp_info->permission->type = NULL;
1618 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1620 info->svcapp_info->permission->value = strdup(coltxt[i]);
1622 info->svcapp_info->permission->value = NULL;
1623 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1625 info->svcapp_info->icon->lang = strdup(coltxt[i]);
1626 info->svcapp_info->label->lang = strdup(coltxt[i]);
1629 info->svcapp_info->icon->lang = NULL;
1630 info->svcapp_info->label->lang = NULL;
1632 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1634 info->svcapp_info->permission_type = strdup(coltxt[i]);
1636 info->svcapp_info->permission_type = NULL;
1649 static int __appcomponent_cb(void *data, int ncols, char **coltxt, char **colname)
1651 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1653 for(i = 0; i < ncols; i++)
1655 if (strcmp(colname[i], "app_component") == 0) {
1656 info->app_component = __appcomponent_convert(coltxt[i]);
1657 } else if (strcmp(colname[i], "package") == 0) {
1658 info->package = strdup(coltxt[i]);
1665 static int __datacontrol_cb(void *data, int ncols, char **coltxt, char **colname)
1667 pkgmgr_datacontrol_x *info = (pkgmgr_datacontrol_x *)data;
1669 for(i = 0; i < ncols; i++)
1671 if (strcmp(colname[i], "PACKAGE_NAME") == 0) {
1673 info->appid = strdup(coltxt[i]);
1676 } else if (strcmp(colname[i], "ACCESS") == 0 ){
1678 info->access = strdup(coltxt[i]);
1680 info->access = NULL;
1687 static int __cert_cb(void *data, int ncols, char **coltxt, char **colname)
1689 pkgmgr_cert_x *info = (pkgmgr_cert_x *)data;
1692 for(i = 0; i < ncols; i++)
1694 if (strcmp(colname[i], "author_signer_cert") == 0) {
1696 info->cert_id = atoi(coltxt[i]);
1699 } else if (strcmp(colname[i], "package") == 0) {
1701 info->pkgid= strdup(coltxt[i]);
1710 /* get the first locale value*/
1711 static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
1713 pkgmgr_locale_x *info = (pkgmgr_locale_x *)data;
1716 info->locale = strdup(coltxt[0]);
1718 info->locale = NULL;
1723 static int __exec_pkginfo_query(char *query, void *data)
1725 char *error_message = NULL;
1727 sqlite3_exec(manifest_db, query, __pkginfo_cb, data, &error_message)) {
1728 _LOGE("Don't execute query = %s error message = %s\n", query,
1730 sqlite3_free(error_message);
1733 sqlite3_free(error_message);
1737 static int __exec_certinfo_query(char *query, void *data)
1739 char *error_message = NULL;
1741 sqlite3_exec(cert_db, query, __certinfo_cb, data, &error_message)) {
1742 _LOGE("Don't execute query = %s error message = %s\n", query,
1744 sqlite3_free(error_message);
1747 sqlite3_free(error_message);
1751 static int __exec_certindexinfo_query(char *query, void *data)
1753 char *error_message = NULL;
1755 sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
1756 _LOGE("Don't execute query = %s error message = %s\n", query,
1758 sqlite3_free(error_message);
1761 sqlite3_free(error_message);
1765 static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data)
1767 char *error_message = NULL;
1769 sqlite3_exec(db, query, callback, data, &error_message)) {
1770 _LOGE("Don't execute query = %s error message = %s\n", query,
1772 sqlite3_free(error_message);
1775 sqlite3_free(error_message);
1780 static int __child_element(xmlTextReaderPtr reader, int depth)
1782 int ret = xmlTextReaderRead(reader);
1783 int cur = xmlTextReaderDepth(reader);
1786 switch (xmlTextReaderNodeType(reader)) {
1787 case XML_READER_TYPE_ELEMENT:
1788 if (cur == depth + 1)
1791 case XML_READER_TYPE_TEXT:
1792 /*text is handled by each function separately*/
1793 if (cur == depth + 1)
1796 case XML_READER_TYPE_END_ELEMENT:
1805 ret = xmlTextReaderRead(reader);
1806 cur = xmlTextReaderDepth(reader);
1811 static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, char **colname)
1813 int *p = (int*)data;
1814 *p = atoi(coltxt[0]);
1818 static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale)
1820 int result_query = -1;
1822 char query[MAX_QUERY_LEN];
1824 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);
1825 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1826 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1827 return result_query;
1830 static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1832 int result_query = -1;
1834 char wildcard[2] = {'%','\0'};
1835 char query[MAX_QUERY_LEN];
1836 char lang[3] = {'\0'};
1837 strncpy(lang, locale, LANGUAGE_LENGTH);
1839 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);
1840 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1841 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1842 return result_query;
1845 static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1848 char wildcard[2] = {'%','\0'};
1849 char lang[3] = {'\0'};
1850 char query[MAX_QUERY_LEN];
1851 char *locale_new = NULL;
1852 pkgmgr_locale_x *info = NULL;
1854 info = (pkgmgr_locale_x *)malloc(sizeof(pkgmgr_locale_x));
1856 _LOGE("Out of Memory!!!\n");
1859 memset(info, '\0', sizeof(*info));
1861 strncpy(lang, locale, 2);
1862 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);
1863 ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
1864 tryvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1865 locale_new = info->locale;
1876 static char* __convert_syslocale_to_manifest_locale(char *syslocale)
1878 char *locale = malloc(6);
1880 _LOGE("Malloc Failed\n");
1884 sprintf(locale, "%c%c-%c%c", syslocale[0], syslocale[1], tolower(syslocale[3]), tolower(syslocale[4]));
1888 static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const char *syslocale)
1893 char *locale = NULL;
1894 char *locale_new = NULL;
1895 int check_result = 0;
1897 locale = __convert_syslocale_to_manifest_locale((char *)syslocale);
1899 /*check exact matching */
1900 check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale);
1903 if (check_result == 1) {
1904 _LOGD("%s find exact locale(%s)\n", appid, locale);
1908 /* fallback matching */
1909 check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
1910 if(check_result == 1) {
1911 locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
1913 if (locale_new == NULL)
1914 locale_new = strdup(DEFAULT_LOCALE);
1918 /* default locale */
1920 return strdup(DEFAULT_LOCALE);
1923 long long _pkgmgr_calculate_dir_size(char *dirname)
1925 long long total = 0;
1927 int q = 0; /*quotient*/
1928 int r = 0; /*remainder*/
1930 struct dirent *ep = NULL;
1931 struct stat fileinfo;
1932 char abs_filename[FILENAME_MAX] = { 0, };
1933 retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL");
1935 dp = opendir(dirname);
1937 while ((ep = readdir(dp)) != NULL) {
1938 if (!strcmp(ep->d_name, ".") ||
1939 !strcmp(ep->d_name, "..")) {
1942 snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
1944 if (lstat(abs_filename, &fileinfo) < 0)
1945 perror(abs_filename);
1947 if (S_ISDIR(fileinfo.st_mode)) {
1948 total += fileinfo.st_size;
1949 if (strcmp(ep->d_name, ".")
1950 && strcmp(ep->d_name, "..")) {
1951 ret = _pkgmgr_calculate_dir_size
1953 total = total + ret;
1955 } else if (S_ISLNK(fileinfo.st_mode)) {
1958 /*It is a file. Calculate the actual
1959 size occupied (in terms of 4096 blocks)*/
1960 q = (fileinfo.st_size / BLOCK_SIZE);
1961 r = (fileinfo.st_size % BLOCK_SIZE);
1965 total += q * BLOCK_SIZE;
1971 _LOGE("Couldn't open the directory\n");
1978 static int __delete_certinfo(const char *pkgid)
1984 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
1985 char *error_message = NULL;
1986 char query[MAX_QUERY_LEN] = {'\0'};
1987 pkgmgr_certinfo_x *certinfo = NULL;
1988 pkgmgr_certindexinfo_x *indexinfo = NULL;
1989 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
1990 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
1991 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
1992 if (indexinfo == NULL) {
1993 _LOGE("Out of Memory!!!");
1994 ret = PMINFO_R_ERROR;
1997 /*populate certinfo from DB*/
1998 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
1999 ret = __exec_certinfo_query(query, (void *)certinfo);
2001 _LOGE("Package Cert Info DB Information retrieval failed\n");
2002 ret = PMINFO_R_ERROR;
2005 /*Update cert index table*/
2006 for (i = 0; i < MAX_CERT_TYPE; i++) {
2007 if ((certinfo->cert_id)[i]) {
2008 for (j = 0; j < MAX_CERT_TYPE; j++) {
2009 if ((certinfo->cert_id)[i] == unique_id[j]) {
2010 /*Ref count has already been updated. Just continue*/
2014 if (j == MAX_CERT_TYPE)
2015 unique_id[c++] = (certinfo->cert_id)[i];
2018 memset(query, '\0', MAX_QUERY_LEN);
2019 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
2020 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
2022 _LOGE("Cert Info DB Information retrieval failed\n");
2023 ret = PMINFO_R_ERROR;
2026 memset(query, '\0', MAX_QUERY_LEN);
2027 if (indexinfo->cert_ref_count > 1) {
2028 /*decrease ref count*/
2029 snprintf(query, MAX_QUERY_LEN, "update package_cert_index_info set cert_ref_count=%d where cert_id=%d ",
2030 indexinfo->cert_ref_count - 1, (certinfo->cert_id)[i]);
2032 /*delete this certificate as ref count is 1 and it will become 0*/
2033 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
2036 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
2037 _LOGE("Don't execute query = %s error message = %s\n", query,
2039 sqlite3_free(error_message);
2040 ret = PMINFO_R_ERROR;
2045 /*Now delete the entry from db*/
2046 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
2048 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
2049 _LOGE("Don't execute query = %s error message = %s\n", query,
2051 sqlite3_free(error_message);
2052 ret = PMINFO_R_ERROR;
2061 if (certinfo->pkgid) {
2062 free(certinfo->pkgid);
2063 certinfo->pkgid = NULL;
2065 for (i = 0; i < MAX_CERT_TYPE; i++) {
2066 if ((certinfo->cert_info)[i]) {
2067 free((certinfo->cert_info)[i]);
2068 (certinfo->cert_info)[i] = NULL;
2076 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
2078 retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
2079 char *error_message = NULL;
2080 int ret = PMINFO_R_OK;
2081 char query[MAX_QUERY_LEN] = {'\0'};
2082 char *syslocale = NULL;
2083 char *locale = NULL;
2084 pkgmgr_pkginfo_x *pkginfo = NULL;
2085 label_x *tmp1 = NULL;
2086 icon_x *tmp2 = NULL;
2087 description_x *tmp3 = NULL;
2088 author_x *tmp4 = NULL;
2089 privilege_x *tmp5 = NULL;
2091 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2092 if (syslocale == NULL) {
2093 _LOGE("current locale is NULL\n");
2094 ret = PMINFO_R_ERROR;
2097 locale = __convert_system_locale_to_manifest_locale(syslocale);
2098 if (locale == NULL) {
2099 _LOGE("manifest locale is NULL\n");
2100 ret = PMINFO_R_EINVAL;
2104 ret = __open_manifest_db();
2106 _LOGE("Fail to open manifest DB\n");
2107 ret = PMINFO_R_ERROR;
2110 pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2111 pkgmgr_pkginfo_x *node = NULL;
2112 pkgmgr_pkginfo_x *temp_node = NULL;
2114 snprintf(query, MAX_QUERY_LEN, "select * from package_info");
2116 sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
2117 _LOGE("Don't execute query = %s error message = %s\n", query,
2119 sqlite3_free(error_message);
2120 sqlite3_close(manifest_db);
2121 ret = PMINFO_R_ERROR;
2125 LISTHEAD(tmphead, node);
2127 for(node = node->next; node ; node = node->next) {
2129 pkginfo->locale = strdup(locale);
2130 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2131 if (pkginfo->manifest_info->privileges == NULL) {
2132 _LOGE("Failed to allocate memory for privileges info\n");
2133 ret = PMINFO_R_ERROR;
2136 /*populate manifest_info from DB*/
2137 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
2138 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2140 _LOGE("Package Info DB Information retrieval failed\n");
2141 ret = PMINFO_R_ERROR;
2144 memset(query, '\0', MAX_QUERY_LEN);
2145 /*populate privilege_info from DB*/
2146 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package);
2147 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2149 _LOGE("Package Privilege Info DB Information retrieval failed\n");
2150 ret = PMINFO_R_ERROR;
2153 memset(query, '\0', MAX_QUERY_LEN);
2154 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2155 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
2156 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2158 _LOGE("Package Info DB Information retrieval failed\n");
2159 ret = PMINFO_R_ERROR;
2162 /*Also store the values corresponding to default locales*/
2163 memset(query, '\0', MAX_QUERY_LEN);
2164 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2165 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
2166 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2168 _LOGE("Package Info DB Information retrieval failed\n");
2169 ret = PMINFO_R_ERROR;
2172 if (pkginfo->manifest_info->label) {
2173 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2174 pkginfo->manifest_info->label = tmp1;
2176 if (pkginfo->manifest_info->icon) {
2177 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2178 pkginfo->manifest_info->icon = tmp2;
2180 if (pkginfo->manifest_info->description) {
2181 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2182 pkginfo->manifest_info->description = tmp3;
2184 if (pkginfo->manifest_info->author) {
2185 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2186 pkginfo->manifest_info->author = tmp4;
2188 if (pkginfo->manifest_info->privileges->privilege) {
2189 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2190 pkginfo->manifest_info->privileges->privilege = tmp5;
2194 LISTHEAD(tmphead, node);
2196 for(node = node->next; node ; node = node->next) {
2198 ret = pkg_list_cb( (void *)pkginfo, user_data);
2206 sqlite3_close(manifest_db);
2215 LISTHEAD(tmphead, node);
2216 temp_node = node->next;
2219 temp_node = node->next;
2220 __cleanup_pkginfo(node);
2223 __cleanup_pkginfo(tmphead);
2228 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
2230 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
2231 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2232 pkgmgr_pkginfo_x *pkginfo = NULL;
2233 int ret = PMINFO_R_OK;
2234 char query[MAX_QUERY_LEN] = {'\0'};
2235 char *syslocale = NULL;
2236 char *locale = NULL;
2238 label_x *tmp1 = NULL;
2239 icon_x *tmp2 = NULL;
2240 description_x *tmp3 = NULL;
2241 author_x *tmp4 = NULL;
2242 privilege_x *tmp5 = NULL;
2243 sqlite3 *pkginfo_db = NULL;
2246 ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
2247 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2249 /*check pkgid exist on db*/
2250 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
2251 ret = __exec_db_query(pkginfo_db, query, __validate_cb, (void *)&exist);
2252 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
2253 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] not found in DB", pkgid);
2255 /*get system locale*/
2256 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2257 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
2259 /*get locale on db*/
2260 locale = __convert_system_locale_to_manifest_locale(syslocale);
2261 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
2263 pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2264 tryvm_if(pkginfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for pkginfo");
2266 pkginfo->locale = strdup(locale);
2268 pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
2269 tryvm_if(pkginfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for manifest info");
2271 pkginfo->manifest_info->package = strdup(pkgid);
2272 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2273 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info");
2275 /*populate manifest_info from DB*/
2276 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
2277 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2278 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2280 memset(query, '\0', MAX_QUERY_LEN);
2281 /*populate privilege_info from DB*/
2282 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
2283 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2284 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
2286 memset(query, '\0', MAX_QUERY_LEN);
2287 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2288 " package='%s' and package_locale='%s'", pkgid, locale);
2289 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2290 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2292 /*Also store the values corresponding to default locales*/
2293 memset(query, '\0', MAX_QUERY_LEN);
2294 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2295 " package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
2296 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2297 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2299 if (pkginfo->manifest_info->label) {
2300 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2301 pkginfo->manifest_info->label = tmp1;
2303 if (pkginfo->manifest_info->icon) {
2304 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2305 pkginfo->manifest_info->icon = tmp2;
2307 if (pkginfo->manifest_info->description) {
2308 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2309 pkginfo->manifest_info->description = tmp3;
2311 if (pkginfo->manifest_info->author) {
2312 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2313 pkginfo->manifest_info->author = tmp4;
2315 if (pkginfo->manifest_info->privileges->privilege) {
2316 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2317 pkginfo->manifest_info->privileges->privilege = tmp5;
2321 if (ret == PMINFO_R_OK)
2322 *handle = (void*)pkginfo;
2325 __cleanup_pkginfo(pkginfo);
2327 sqlite3_close(pkginfo_db);
2341 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
2343 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2344 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2345 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2346 if (info->manifest_info->package)
2347 *pkg_name = (char *)info->manifest_info->package;
2349 return PMINFO_R_ERROR;
2354 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
2356 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2357 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2358 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2359 if (info->manifest_info->package)
2360 *pkgid = (char *)info->manifest_info->package;
2362 return PMINFO_R_ERROR;
2367 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
2369 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2370 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2371 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2372 if (info->manifest_info->type)
2373 *type = (char *)info->manifest_info->type;
2379 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
2381 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2382 retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2383 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2384 *version = (char *)info->manifest_info->version;
2388 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
2390 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2391 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2393 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2394 val = (char *)info->manifest_info->installlocation;
2396 if (strcmp(val, "internal-only") == 0)
2397 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2398 else if (strcmp(val, "prefer-external") == 0)
2399 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2401 *location = PMINFO_INSTALL_LOCATION_AUTO;
2406 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
2408 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2409 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2411 char *location = NULL;
2412 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2413 location = (char *)info->manifest_info->installlocation;
2414 val = (char *)info->manifest_info->package_size;
2419 _LOGE("package size is not specified\n");
2420 return PMINFO_R_ERROR;
2425 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
2427 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2428 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2431 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
2432 long long rw_size = 0;
2433 long long ro_size= 0;
2434 long long tmp_size= 0;
2435 long long total_size= 0;
2436 struct stat fileinfo;
2439 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2441 return PMINFO_R_ERROR;
2444 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid);
2445 if (lstat(device_path, &fileinfo) == 0) {
2446 if (!S_ISLNK(fileinfo.st_mode)) {
2447 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2449 rw_size += tmp_size;
2453 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid);
2454 if (lstat(device_path, &fileinfo) == 0) {
2455 if (!S_ISLNK(fileinfo.st_mode)) {
2456 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2458 rw_size += tmp_size;
2462 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid);
2463 if (lstat(device_path, &fileinfo) == 0) {
2464 if (!S_ISLNK(fileinfo.st_mode)) {
2465 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2467 rw_size += tmp_size;
2471 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
2472 if (lstat(device_path, &fileinfo) == 0) {
2473 if (!S_ISLNK(fileinfo.st_mode)) {
2474 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2476 rw_size += tmp_size;
2480 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_PATH, pkgid);
2481 if (lstat(device_path, &fileinfo) == 0) {
2482 if (!S_ISLNK(fileinfo.st_mode)) {
2483 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2485 rw_size += tmp_size;
2489 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_PATH, pkgid);
2490 if (lstat(device_path, &fileinfo) == 0) {
2491 if (!S_ISLNK(fileinfo.st_mode)) {
2492 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2494 rw_size += tmp_size;
2499 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_PATH, pkgid);
2500 if (lstat(device_path, &fileinfo) == 0) {
2501 if (!S_ISLNK(fileinfo.st_mode)) {
2502 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2504 ro_size += tmp_size;
2508 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid);
2509 if (lstat(device_path, &fileinfo) == 0) {
2510 if (!S_ISLNK(fileinfo.st_mode)) {
2511 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2513 ro_size += tmp_size;
2517 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid);
2518 if (lstat(device_path, &fileinfo) == 0) {
2519 if (!S_ISLNK(fileinfo.st_mode)) {
2520 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2522 ro_size += tmp_size;
2526 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid);
2527 if (lstat(device_path, &fileinfo) == 0) {
2528 if (!S_ISLNK(fileinfo.st_mode)) {
2529 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2531 ro_size += tmp_size;
2535 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid);
2536 if (lstat(device_path, &fileinfo) == 0) {
2537 if (!S_ISLNK(fileinfo.st_mode)) {
2538 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2540 ro_size += tmp_size;
2544 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid);
2545 if (lstat(device_path, &fileinfo) == 0) {
2546 if (!S_ISLNK(fileinfo.st_mode)) {
2547 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2549 ro_size += tmp_size;
2554 total_size = rw_size + ro_size;
2555 *size = (int)total_size;
2560 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
2562 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2563 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2566 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
2567 long long total_size= 0;
2570 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2572 return PMINFO_R_ERROR;
2574 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
2575 if (access(device_path, R_OK) == 0)
2576 total_size = _pkgmgr_calculate_dir_size(device_path);
2578 return PMINFO_R_ERROR;
2580 *size = (int)total_size;
2585 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
2587 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2588 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2589 int ret = PMINFO_R_OK;
2590 char *locale = NULL;
2594 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2596 locale = info->locale;
2597 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2599 for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next)
2602 if (strcmp(ptr->lang, locale) == 0) {
2603 *icon = (char *)ptr->text;
2604 if (strcasecmp(*icon, "(null)") == 0) {
2605 locale = DEFAULT_LOCALE;
2609 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2610 *icon = (char *)ptr->text;
2619 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
2621 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2622 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2623 int ret = PMINFO_R_OK;
2624 char *locale = NULL;
2625 label_x *ptr = NULL;
2628 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2629 locale = info->locale;
2630 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2632 for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next)
2635 if (strcmp(ptr->lang, locale) == 0) {
2636 *label = (char *)ptr->text;
2637 if (strcasecmp(*label, "(null)") == 0) {
2638 locale = DEFAULT_LOCALE;
2642 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2643 *label = (char *)ptr->text;
2652 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
2654 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2655 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2656 char *locale = NULL;
2657 description_x *ptr = NULL;
2658 *description = NULL;
2660 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2661 locale = info->locale;
2662 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2664 for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next)
2667 if (strcmp(ptr->lang, locale) == 0) {
2668 *description = (char *)ptr->text;
2669 if (strcasecmp(*description, "(null)") == 0) {
2670 locale = DEFAULT_LOCALE;
2674 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2675 *description = (char *)ptr->text;
2683 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
2685 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2686 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2687 char *locale = NULL;
2688 author_x *ptr = NULL;
2689 *author_name = NULL;
2691 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2692 locale = info->locale;
2693 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2695 for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next)
2698 if (strcmp(ptr->lang, locale) == 0) {
2699 *author_name = (char *)ptr->text;
2700 if (strcasecmp(*author_name, "(null)") == 0) {
2701 locale = DEFAULT_LOCALE;
2705 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2706 *author_name = (char *)ptr->text;
2714 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
2716 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2717 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2718 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2719 *author_email = (char *)info->manifest_info->author->email;
2723 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
2725 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2726 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2727 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2728 *author_href = (char *)info->manifest_info->author->href;
2732 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
2734 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2735 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2738 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
2740 _LOGE("invalid func parameters\n");
2741 return PMINFO_R_ERROR;
2745 char app_mmc_path[FILENAME_MAX] = { 0, };
2746 char app_dir_path[FILENAME_MAX] = { 0, };
2747 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
2748 snprintf(app_dir_path, FILENAME_MAX,
2749 "%s%s", PKG_INSTALLATION_PATH, pkgid);
2750 snprintf(app_mmc_path, FILENAME_MAX,
2751 "%s%s", PKG_SD_PATH, pkgid);
2752 snprintf(app_mmc_internal_path, FILENAME_MAX,
2753 "%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
2755 /*check whether application is in external memory or not */
2756 fp = fopen(app_mmc_path, "r");
2760 *storage = PMINFO_EXTERNAL_STORAGE;
2764 /*check whether application is in internal or not */
2765 fp = fopen(app_dir_path, "r");
2768 return PMINFO_R_ERROR;
2771 /*check whether the application is installed in SD card
2772 but SD card is not present*/
2773 fp = fopen(app_mmc_internal_path, "r");
2775 *storage = PMINFO_INTERNAL_STORAGE;
2779 *storage = PMINFO_EXTERNAL_STORAGE;
2785 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
2787 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2788 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2789 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2790 if (info->manifest_info->installed_time)
2791 *installed_time = atoi(info->manifest_info->installed_time);
2793 return PMINFO_R_ERROR;
2798 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
2800 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2801 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2802 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2803 *storeclientid = (char *)info->manifest_info->storeclient_id;
2807 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
2809 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2810 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2811 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2812 *mainappid = (char *)info->manifest_info->mainapp_id;
2816 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
2818 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2819 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2820 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2821 *url = (char *)info->manifest_info->package_url;
2825 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
2827 const char *val = NULL;
2828 const xmlChar *node;
2829 xmlTextReaderPtr reader;
2830 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2831 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2834 reader = xmlReaderForFile(manifest, NULL, 0);
2837 if (__child_element(reader, -1)) {
2838 node = xmlTextReaderConstName(reader);
2840 _LOGE("xmlTextReaderConstName value is NULL\n");
2841 xmlFreeTextReader(reader);
2843 return PMINFO_R_ERROR;
2846 if (!strcmp(ASC_CHAR(node), "manifest")) {
2847 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
2848 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
2854 _LOGE("package size is not specified\n");
2855 xmlFreeTextReader(reader);
2857 return PMINFO_R_ERROR;
2860 _LOGE("Unable to create xml reader\n");
2861 xmlFreeTextReader(reader);
2863 return PMINFO_R_ERROR;
2867 _LOGE("xmlReaderForFile value is NULL\n");
2869 return PMINFO_R_ERROR;
2872 xmlFreeTextReader(reader);
2878 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
2880 const char *val = NULL;
2881 const xmlChar *node;
2882 xmlTextReaderPtr reader;
2883 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2884 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2887 reader = xmlReaderForFile(manifest, NULL, 0);
2890 if ( __child_element(reader, -1)) {
2891 node = xmlTextReaderConstName(reader);
2893 _LOGE("xmlTextReaderConstName value is NULL\n");
2894 xmlFreeTextReader(reader);
2896 return PMINFO_R_ERROR;
2899 if (!strcmp(ASC_CHAR(node), "manifest")) {
2900 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
2901 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
2904 if (strcmp(val, "internal-only") == 0)
2905 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2906 else if (strcmp(val, "prefer-external") == 0)
2907 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2909 *location = PMINFO_INSTALL_LOCATION_AUTO;
2912 _LOGE("Unable to create xml reader\n");
2913 xmlFreeTextReader(reader);
2915 return PMINFO_R_ERROR;
2919 _LOGE("xmlReaderForFile value is NULL\n");
2921 return PMINFO_R_ERROR;
2924 xmlFreeTextReader(reader);
2931 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
2933 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2934 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2936 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2937 if (info->manifest_info->root_path)
2938 *path = (char *)info->manifest_info->root_path;
2940 return PMINFO_R_ERROR;
2945 API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
2947 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2948 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2950 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2951 if (info->manifest_info->csc_path)
2952 *path = (char *)info->manifest_info->csc_path;
2954 *path = (char *)info->manifest_info->csc_path;
2959 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)
2961 retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
2962 retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
2963 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2965 int ret = PMINFO_R_OK;
2966 char query[MAX_QUERY_LEN] = {'\0'};
2967 char *error_message = NULL;
2968 pkgmgr_cert_x *info= NULL;
2972 *compare_result = PMINFO_CERT_COMPARE_ERROR;
2973 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
2974 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
2976 ret = db_util_open_with_options(CERT_DB, &cert_db,
2977 SQLITE_OPEN_READONLY, NULL);
2978 if (ret != SQLITE_OK) {
2979 _LOGE("connect db [%s] failed!\n", CERT_DB);
2980 ret = PMINFO_R_ERROR;
2984 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
2986 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
2987 _LOGE("Don't execute query = %s error message = %s\n", query,
2989 ret = PMINFO_R_ERROR;
2996 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
2998 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
2999 _LOGE("Don't execute query = %s error message = %s\n", query,
3001 ret = PMINFO_R_ERROR;
3004 lcert = info->cert_id;
3007 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
3009 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
3010 _LOGE("Don't execute query = %s error message = %s\n", query,
3012 ret = PMINFO_R_ERROR;
3019 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
3021 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
3022 _LOGE("Don't execute query = %s error message = %s\n", query,
3024 ret = PMINFO_R_ERROR;
3027 rcert = info->cert_id;
3030 if ((lcert == 0) || (rcert == 0))
3032 if ((lcert == 0) && (rcert == 0))
3033 *compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
3034 else if (lcert == 0)
3035 *compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
3036 else if (rcert == 0)
3037 *compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
3040 *compare_result = PMINFO_CERT_COMPARE_MATCH;
3042 *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
3046 sqlite3_free(error_message);
3047 sqlite3_close(cert_db);
3060 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)
3062 retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
3063 retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
3064 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3066 int ret = PMINFO_R_OK;
3067 char query[MAX_QUERY_LEN] = {'\0'};
3068 char *error_message = NULL;
3069 pkgmgr_cert_x *info= NULL;
3071 char *lpkgid = NULL;
3072 char *rpkgid = NULL;
3074 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3075 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3077 ret = db_util_open_with_options(MANIFEST_DB, &manifest_db,
3078 SQLITE_OPEN_READONLY, NULL);
3079 if (ret != SQLITE_OK) {
3080 _LOGE("connect db [%s] failed!\n", MANIFEST_DB);
3081 ret = PMINFO_R_ERROR;
3085 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
3087 sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
3088 _LOGE("Don't execute query = %s error message = %s\n", query,
3090 ret = PMINFO_R_ERROR;
3097 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
3099 sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
3100 _LOGE("Don't execute query = %s error message = %s\n", query,
3102 ret = PMINFO_R_ERROR;
3105 lpkgid = strdup(info->pkgid);
3106 if (lpkgid == NULL) {
3107 _LOGE("Out of Memory\n");
3108 ret = PMINFO_R_ERROR;
3115 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
3117 sqlite3_exec(manifest_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 package from package_app_info where app_id='%s' ", rhs_app_id);
3129 sqlite3_exec(manifest_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 rpkgid = strdup(info->pkgid);
3136 if (rpkgid == NULL) {
3137 _LOGE("Out of Memory\n");
3138 ret = PMINFO_R_ERROR;
3144 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
3146 sqlite3_free(error_message);
3147 sqlite3_close(manifest_db);
3167 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
3169 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3170 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3172 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
3174 _LOGD("invalid func parameters\n");
3175 return PMINFO_R_ERROR;
3177 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
3180 char app_mmc_path[FILENAME_MAX] = { 0, };
3181 char app_dir_path[FILENAME_MAX] = { 0, };
3182 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
3183 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
3184 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
3185 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
3187 /*check whether application is in external memory or not */
3188 fp = fopen(app_mmc_path, "r");
3190 _LOGD(" app path in external memory not accesible\n");
3195 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
3199 /*check whether application is in internal or not */
3200 fp = fopen(app_dir_path, "r");
3202 _LOGD(" app path in internal memory not accesible\n");
3204 return PMINFO_R_ERROR;
3207 /*check whether the application is installed in SD card
3208 but SD card is not present*/
3209 fp = fopen(app_mmc_internal_path, "r");
3212 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
3217 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
3222 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
3226 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
3228 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3229 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3231 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3232 val = (char *)info->manifest_info->removable;
3234 if (strcasecmp(val, "true") == 0)
3236 else if (strcasecmp(val, "false") == 0)
3244 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
3246 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3247 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3250 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3252 val = (char *)info->manifest_info->installlocation;
3254 if (strcmp(val, "internal-only") == 0)
3256 else if (strcmp(val, "prefer-external") == 0)
3265 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
3267 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3268 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3270 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3271 val = (char *)info->manifest_info->preload;
3273 if (strcasecmp(val, "true") == 0)
3275 else if (strcasecmp(val, "false") == 0)
3283 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
3285 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3286 retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3288 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3289 val = (char *)info->manifest_info->readonly;
3291 if (strcasecmp(val, "true") == 0)
3293 else if (strcasecmp(val, "false") == 0)
3301 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
3303 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3304 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3307 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3308 val = (char *)info->manifest_info->update;
3310 if (strcasecmp(val, "true") == 0)
3312 else if (strcasecmp(val, "false") == 0)
3320 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
3322 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3323 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3324 __cleanup_pkginfo(info);
3328 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
3330 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
3332 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
3333 if (filter == NULL) {
3334 _LOGE("Out of Memory!!!");
3335 return PMINFO_R_ERROR;
3341 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
3343 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3344 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3346 g_slist_foreach(filter->list, __destroy_each_node, NULL);
3347 g_slist_free(filter->list);
3354 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
3355 const char *property, const int value)
3357 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3358 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3359 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3361 GSList *link = NULL;
3363 prop = _pminfo_pkginfo_convert_to_prop_int(property);
3364 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
3365 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
3366 _LOGE("Invalid Integer Property\n");
3367 return PMINFO_R_EINVAL;
3369 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3370 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3372 _LOGE("Out of Memory!!!\n");
3373 return PMINFO_R_ERROR;
3375 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3376 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3378 _LOGE("Out of Memory\n");
3381 return PMINFO_R_ERROR;
3385 /*If API is called multiple times for same property, we should override the previous values.
3386 Last value set will be used for filtering.*/
3387 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3389 filter->list = g_slist_delete_link(filter->list, link);
3390 filter->list = g_slist_append(filter->list, (gpointer)node);
3395 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
3396 const char *property, const bool value)
3398 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3399 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3401 GSList *link = NULL;
3403 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
3404 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
3405 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
3406 _LOGE("Invalid Boolean Property\n");
3407 return PMINFO_R_EINVAL;
3409 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3410 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3412 _LOGE("Out of Memory!!!\n");
3413 return PMINFO_R_ERROR;
3416 val = strndup("('true','True')", 15);
3418 val = strndup("('false','False')", 17);
3420 _LOGE("Out of Memory\n");
3423 return PMINFO_R_ERROR;
3427 /*If API is called multiple times for same property, we should override the previous values.
3428 Last value set will be used for filtering.*/
3429 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3431 filter->list = g_slist_delete_link(filter->list, link);
3432 filter->list = g_slist_append(filter->list, (gpointer)node);
3437 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
3438 const char *property, const char *value)
3440 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3441 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3442 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3444 GSList *link = NULL;
3446 prop = _pminfo_pkginfo_convert_to_prop_str(property);
3447 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
3448 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
3449 _LOGE("Invalid String Property\n");
3450 return PMINFO_R_EINVAL;
3452 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3453 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3455 _LOGE("Out of Memory!!!\n");
3456 return PMINFO_R_ERROR;
3458 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
3459 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
3460 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
3461 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
3462 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
3463 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
3464 else if (strcmp(value, "installed_internal") == 0)
3465 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
3466 else if (strcmp(value, "installed_external") == 0)
3467 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
3469 val = strndup(value, PKG_STRING_LEN_MAX - 1);
3471 _LOGE("Out of Memory\n");
3474 return PMINFO_R_ERROR;
3478 /*If API is called multiple times for same property, we should override the previous values.
3479 Last value set will be used for filtering.*/
3480 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3482 filter->list = g_slist_delete_link(filter->list, link);
3483 filter->list = g_slist_append(filter->list, (gpointer)node);
3488 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
3490 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3491 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3492 char *syslocale = NULL;
3493 char *locale = NULL;
3494 char *condition = NULL;
3495 char *error_message = NULL;
3496 char query[MAX_QUERY_LEN] = {'\0'};
3497 char where[MAX_QUERY_LEN] = {'\0'};
3501 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3502 /*Get current locale*/
3503 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3504 if (syslocale == NULL) {
3505 _LOGE("current locale is NULL\n");
3506 return PMINFO_R_ERROR;
3508 locale = __convert_system_locale_to_manifest_locale(syslocale);
3509 if (locale == NULL) {
3510 _LOGE("manifest locale is NULL\n");
3512 return PMINFO_R_ERROR;
3515 ret = __open_manifest_db();
3517 _LOGE("Fail to open manifest DB\n");
3518 ret = PMINFO_R_ERROR;
3522 /*Start constructing query*/
3523 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_PACKAGE, locale);
3525 /*Get where clause*/
3526 for (list = filter->list; list; list = g_slist_next(list)) {
3527 __get_filter_condition(list->data, &condition);
3529 strncat(where, condition, sizeof(where) - strlen(where) -1);
3530 where[sizeof(where) - 1] = '\0';
3534 if (g_slist_next(list)) {
3535 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3536 where[sizeof(where) - 1] = '\0';
3539 _LOGE("where = %s\n", where);
3540 if (strlen(where) > 0) {
3541 strncat(query, where, sizeof(query) - strlen(query) - 1);
3542 query[sizeof(query) - 1] = '\0';
3544 _LOGE("query = %s\n", query);
3548 sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
3549 _LOGE("Don't execute query = %s error message = %s\n", query,
3551 sqlite3_free(error_message);
3552 sqlite3_close(manifest_db);
3553 ret = PMINFO_R_ERROR;
3567 sqlite3_close(manifest_db);
3571 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
3572 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
3574 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3575 retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3576 char *syslocale = NULL;
3577 char *locale = NULL;
3578 char *condition = NULL;
3579 char *error_message = NULL;
3580 char query[MAX_QUERY_LEN] = {'\0'};
3581 char where[MAX_QUERY_LEN] = {'\0'};
3584 label_x *tmp1 = NULL;
3585 icon_x *tmp2 = NULL;
3586 description_x *tmp3 = NULL;
3587 author_x *tmp4 = NULL;
3588 privilege_x *tmp5 = NULL;
3589 pkgmgr_pkginfo_x *node = NULL;
3590 pkgmgr_pkginfo_x *tmphead = NULL;
3591 pkgmgr_pkginfo_x *pkginfo = NULL;
3593 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3594 /*Get current locale*/
3595 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3596 if (syslocale == NULL) {
3597 _LOGE("current locale is NULL\n");
3598 return PMINFO_R_ERROR;
3600 locale = __convert_system_locale_to_manifest_locale(syslocale);
3601 if (locale == NULL) {
3602 _LOGE("manifest locale is NULL\n");
3604 return PMINFO_R_ERROR;
3607 ret = __open_manifest_db();
3609 _LOGE("Fail to open manifest DB\n");
3610 ret = PMINFO_R_ERROR;
3613 /*Start constructing query*/
3614 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
3616 /*Get where clause*/
3617 for (list = filter->list; list; list = g_slist_next(list)) {
3618 __get_filter_condition(list->data, &condition);
3620 strncat(where, condition, sizeof(where) - strlen(where) -1);
3621 where[sizeof(where) - 1] = '\0';
3625 if (g_slist_next(list)) {
3626 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3627 where[sizeof(where) - 1] = '\0';
3630 _LOGE("where = %s\n", where);
3631 if (strlen(where) > 0) {
3632 strncat(query, where, sizeof(query) - strlen(query) - 1);
3633 query[sizeof(query) - 1] = '\0';
3635 _LOGE("query = %s\n", query);
3636 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
3637 if (tmphead == NULL) {
3638 _LOGE("Out of Memory!!!\n");
3639 ret = PMINFO_R_ERROR;
3644 sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
3645 _LOGE("Don't execute query = %s error message = %s\n", query,
3647 sqlite3_free(error_message);
3648 sqlite3_close(manifest_db);
3649 ret = PMINFO_R_ERROR;
3653 LISTHEAD(tmphead, node);
3654 for(node = node->next ; node ; node = node->next) {
3656 pkginfo->locale = strdup(locale);
3657 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
3658 if (pkginfo->manifest_info->privileges == NULL) {
3659 _LOGE("Failed to allocate memory for privileges info\n");
3660 ret = PMINFO_R_ERROR;
3664 /*populate manifest_info from DB*/
3665 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
3666 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3668 _LOGE("Package Info DB Information retrieval failed\n");
3669 ret = PMINFO_R_ERROR;
3672 memset(query, '\0', MAX_QUERY_LEN);
3673 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3674 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
3675 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3677 _LOGE("Package Info DB Information retrieval failed\n");
3678 ret = PMINFO_R_ERROR;
3681 /*Also store the values corresponding to default locales*/
3682 memset(query, '\0', MAX_QUERY_LEN);
3683 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3684 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
3685 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3687 _LOGE("Package Info DB Information retrieval failed\n");
3688 ret = PMINFO_R_ERROR;
3691 if (pkginfo->manifest_info->label) {
3692 LISTHEAD(pkginfo->manifest_info->label, tmp1);
3693 pkginfo->manifest_info->label = tmp1;
3695 if (pkginfo->manifest_info->icon) {
3696 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
3697 pkginfo->manifest_info->icon = tmp2;
3699 if (pkginfo->manifest_info->description) {
3700 LISTHEAD(pkginfo->manifest_info->description, tmp3);
3701 pkginfo->manifest_info->description = tmp3;
3703 if (pkginfo->manifest_info->author) {
3704 LISTHEAD(pkginfo->manifest_info->author, tmp4);
3705 pkginfo->manifest_info->author = tmp4;
3707 if (pkginfo->manifest_info->privileges->privilege) {
3708 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
3709 pkginfo->manifest_info->privileges->privilege = tmp5;
3713 LISTHEAD(tmphead, node);
3715 for(node = node->next ; node ; node = node->next) {
3717 ret = pkg_cb( (void *)pkginfo, user_data);
3732 sqlite3_close(manifest_db);
3733 __cleanup_pkginfo(tmphead);
3737 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
3738 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
3740 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3741 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3743 privilege_x *ptr = NULL;
3744 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3745 ptr = info->manifest_info->privileges->privilege;
3746 for (; ptr; ptr = ptr->next) {
3748 ret = privilege_func(ptr->text, user_data);
3756 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
3757 pkgmgrinfo_app_list_cb app_func, void *user_data)
3759 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3760 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
3761 retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
3763 char *syslocale = NULL;
3764 char *locale = NULL;
3766 char query[MAX_QUERY_LEN] = {'\0'};
3767 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3768 pkgmgr_pkginfo_x *allinfo = NULL;
3769 pkgmgr_appinfo_x *appinfo = NULL;
3770 icon_x *ptr1 = NULL;
3771 label_x *ptr2 = NULL;
3772 category_x *ptr3 = NULL;
3773 metadata_x *ptr4 = NULL;
3774 permission_x *ptr5 = NULL;
3775 image_x *ptr6 = NULL;
3776 sqlite3 *appinfo_db = NULL;
3778 /*get system locale*/
3779 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3780 tryvm_if(syslocale == NULL, ret = PMINFO_R_EINVAL, "current locale is NULL");
3782 /*get locale on db*/
3783 locale = __convert_system_locale_to_manifest_locale(syslocale);
3784 tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
3787 allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
3788 tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3790 /*calloc manifest_info*/
3791 allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
3792 tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
3795 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
3796 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3798 /*set component type*/
3799 if (component == PMINFO_UI_APP)
3800 appinfo->app_component = PMINFO_UI_APP;
3801 if (component == PMINFO_SVC_APP)
3802 appinfo->app_component = PMINFO_SVC_APP;
3803 if (component == PMINFO_ALL_APP)
3804 appinfo->app_component = PMINFO_ALL_APP;
3807 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
3808 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3810 appinfo->package = strdup(info->manifest_info->package);
3811 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
3812 "from package_app_info where " \
3813 "package='%s' and app_component='%s'",
3814 info->manifest_info->package,
3815 (appinfo->app_component==PMINFO_UI_APP ? "uiapp" : "svcapp"));
3819 /*Populate ui app info */
3820 ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
3821 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3823 uiapplication_x *tmp = NULL;
3824 if (info->manifest_info->uiapplication) {
3825 LISTHEAD(info->manifest_info->uiapplication, tmp);
3826 info->manifest_info->uiapplication = tmp;
3828 /*Populate localized info for default locales and call callback*/
3829 /*If the callback func return < 0 we break and no more call back is called*/
3832 appinfo->locale = strdup(locale);
3833 appinfo->uiapp_info = tmp;
3834 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
3838 locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
3841 memset(query, '\0', MAX_QUERY_LEN);
3842 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3843 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3844 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3846 memset(query, '\0', MAX_QUERY_LEN);
3847 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);
3848 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3849 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3851 /*store setting notification icon section*/
3852 memset(query, '\0', MAX_QUERY_LEN);
3853 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3854 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3855 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
3857 /*store app preview image info*/
3858 memset(query, '\0', MAX_QUERY_LEN);
3859 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
3860 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3861 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
3863 if (appinfo->uiapp_info->label) {
3864 LISTHEAD(appinfo->uiapp_info->label, ptr2);
3865 appinfo->uiapp_info->label = ptr2;
3867 if (appinfo->uiapp_info->icon) {
3868 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
3869 appinfo->uiapp_info->icon = ptr1;
3871 if (appinfo->uiapp_info->category) {
3872 LISTHEAD(appinfo->uiapp_info->category, ptr3);
3873 appinfo->uiapp_info->category = ptr3;
3875 if (appinfo->uiapp_info->metadata) {
3876 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
3877 appinfo->uiapp_info->metadata = ptr4;
3879 if (appinfo->uiapp_info->permission) {
3880 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
3881 appinfo->uiapp_info->permission = ptr5;
3883 if (appinfo->uiapp_info->image) {
3884 LISTHEAD(appinfo->uiapp_info->image, ptr6);
3885 appinfo->uiapp_info->image = ptr6;
3887 ret = app_func((void *)appinfo, user_data);
3893 case PMINFO_SVC_APP:
3894 /*Populate svc app info */
3895 ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
3896 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3898 serviceapplication_x *tmp1 = NULL;
3899 if (info->manifest_info->serviceapplication) {
3900 LISTHEAD(info->manifest_info->serviceapplication, tmp1);
3901 info->manifest_info->serviceapplication = tmp1;
3903 /*Populate localized info for default locales and call callback*/
3904 /*If the callback func return < 0 we break and no more call back is called*/
3907 appinfo->locale = strdup(locale);
3908 appinfo->svcapp_info = tmp1;
3909 memset(query, '\0', MAX_QUERY_LEN);
3910 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
3911 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3912 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3914 memset(query, '\0', MAX_QUERY_LEN);
3915 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);
3916 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3917 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3919 if (appinfo->svcapp_info->label) {
3920 LISTHEAD(appinfo->svcapp_info->label, ptr2);
3921 appinfo->svcapp_info->label = ptr2;
3923 if (appinfo->svcapp_info->icon) {
3924 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
3925 appinfo->svcapp_info->icon = ptr1;
3927 if (appinfo->svcapp_info->category) {
3928 LISTHEAD(appinfo->svcapp_info->category, ptr3);
3929 appinfo->svcapp_info->category = ptr3;
3931 if (appinfo->svcapp_info->metadata) {
3932 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
3933 appinfo->svcapp_info->metadata = ptr4;
3935 if (appinfo->svcapp_info->permission) {
3936 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
3937 appinfo->svcapp_info->permission = ptr5;
3939 ret = app_func((void *)appinfo, user_data);
3945 case PMINFO_ALL_APP:
3946 memset(query, '\0', MAX_QUERY_LEN);
3947 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
3949 /*Populate all app info */
3950 ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo);
3951 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3954 appinfo->app_component = PMINFO_UI_APP;
3955 uiapplication_x *tmp2 = NULL;
3956 if (allinfo->manifest_info->uiapplication) {
3957 LISTHEAD(allinfo->manifest_info->uiapplication, tmp2);
3958 allinfo->manifest_info->uiapplication = tmp2;
3960 /*Populate localized info for default locales and call callback*/
3961 /*If the callback func return < 0 we break and no more call back is called*/
3964 appinfo->locale = strdup(locale);
3965 appinfo->uiapp_info = tmp2;
3966 memset(query, '\0', MAX_QUERY_LEN);
3967 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3968 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3969 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3971 memset(query, '\0', MAX_QUERY_LEN);
3972 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);
3973 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3974 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3976 /*store setting notification icon section*/
3977 memset(query, '\0', MAX_QUERY_LEN);
3978 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3979 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3980 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
3982 /*store app preview image info*/
3983 memset(query, '\0', MAX_QUERY_LEN);
3984 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
3985 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3986 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
3988 if (appinfo->uiapp_info->label) {
3989 LISTHEAD(appinfo->uiapp_info->label, ptr2);
3990 appinfo->uiapp_info->label = ptr2;
3992 if (appinfo->uiapp_info->icon) {
3993 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
3994 appinfo->uiapp_info->icon = ptr1;
3996 if (appinfo->uiapp_info->category) {
3997 LISTHEAD(appinfo->uiapp_info->category, ptr3);
3998 appinfo->uiapp_info->category = ptr3;
4000 if (appinfo->uiapp_info->metadata) {
4001 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
4002 appinfo->uiapp_info->metadata = ptr4;
4004 if (appinfo->uiapp_info->permission) {
4005 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
4006 appinfo->uiapp_info->permission = ptr5;
4008 if (appinfo->uiapp_info->image) {
4009 LISTHEAD(appinfo->uiapp_info->image, ptr6);
4010 appinfo->uiapp_info->image = ptr6;
4012 ret = app_func((void *)appinfo, user_data);
4019 appinfo->app_component = PMINFO_SVC_APP;
4020 serviceapplication_x *tmp3 = NULL;
4021 if (allinfo->manifest_info->serviceapplication) {
4022 LISTHEAD(allinfo->manifest_info->serviceapplication, tmp3);
4023 allinfo->manifest_info->serviceapplication = tmp3;
4025 /*Populate localized info for default locales and call callback*/
4026 /*If the callback func return < 0 we break and no more call back is called*/
4029 appinfo->locale = strdup(locale);
4030 appinfo->svcapp_info = tmp3;
4031 memset(query, '\0', MAX_QUERY_LEN);
4032 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
4033 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4034 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4036 memset(query, '\0', MAX_QUERY_LEN);
4037 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);
4038 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4039 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4041 if (appinfo->svcapp_info->label) {
4042 LISTHEAD(appinfo->svcapp_info->label, ptr2);
4043 appinfo->svcapp_info->label = ptr2;
4045 if (appinfo->svcapp_info->icon) {
4046 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
4047 appinfo->svcapp_info->icon = ptr1;
4049 if (appinfo->svcapp_info->category) {
4050 LISTHEAD(appinfo->svcapp_info->category, ptr3);
4051 appinfo->svcapp_info->category = ptr3;
4053 if (appinfo->svcapp_info->metadata) {
4054 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
4055 appinfo->svcapp_info->metadata = ptr4;
4057 if (appinfo->svcapp_info->permission) {
4058 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
4059 appinfo->svcapp_info->permission = ptr5;
4061 ret = app_func((void *)appinfo, user_data);
4066 appinfo->app_component = PMINFO_ALL_APP;
4082 if (appinfo->package) {
4083 free((void *)appinfo->package);
4084 appinfo->package = NULL;
4089 __cleanup_pkginfo(allinfo);
4091 sqlite3_close(appinfo_db);
4095 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4097 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4099 int ret = PMINFO_R_OK;
4100 char query[MAX_QUERY_LEN] = {'\0'};
4101 pkgmgr_appinfo_x *info = NULL;
4102 pkgmgr_appinfo_x *appinfo = NULL;
4103 uiapplication_x *ptr1 = NULL;
4104 sqlite3 *appinfo_db = NULL;
4107 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4108 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4111 info = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4112 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4114 /*calloc uiapplication_x*/
4115 info->uiapp_info= (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4116 tryvm_if(info->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4119 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4120 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4122 /*query package_app_info*/
4123 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4124 ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
4125 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4127 LISTHEAD(info->uiapp_info, ptr1);
4130 for(ptr1 = ptr1->next ; ptr1 ; ptr1 = ptr1->next)
4132 appinfo->uiapp_info= ptr1;
4133 appinfo->package = strdup(ptr1->package);
4134 appinfo->app_component = PMINFO_UI_APP;
4136 ret = app_func((void *)appinfo, user_data);
4139 free((void *)appinfo->package);
4140 appinfo->package = NULL;
4144 sqlite3_close(appinfo_db);
4150 __cleanup_appinfo(info);
4154 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4156 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4158 int ret = PMINFO_R_OK;
4159 char query[MAX_QUERY_LEN] = {'\0'};
4160 char *syslocale = NULL;
4161 char *locale = NULL;
4162 pkgmgr_appinfo_x *appinfo = NULL;
4163 uiapplication_x *ptr1 = NULL;
4164 serviceapplication_x *ptr2 = NULL;
4165 label_x *tmp1 = NULL;
4166 icon_x *tmp2 = NULL;
4167 category_x *tmp3 = NULL;
4168 metadata_x *tmp4 = NULL;
4169 permission_x *tmp5 = NULL;
4170 image_x *tmp6 = NULL;
4171 sqlite3 *appinfo_db = NULL;
4173 /*get system locale*/
4174 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4175 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
4177 /*get locale on db*/
4178 locale = __convert_system_locale_to_manifest_locale(syslocale);
4179 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4182 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4183 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4186 pkgmgr_pkginfo_x *info = NULL;
4187 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4188 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4190 /*calloc manifest_info*/
4191 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4192 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4195 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4196 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4198 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4199 ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
4200 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4202 if (info->manifest_info->uiapplication) {
4203 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4204 info->manifest_info->uiapplication = ptr1;
4206 if (info->manifest_info->serviceapplication) {
4207 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4208 info->manifest_info->serviceapplication = ptr2;
4212 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4214 appinfo->locale = strdup(locale);
4215 appinfo->app_component = PMINFO_UI_APP;
4216 appinfo->package = strdup(ptr1->package);
4217 appinfo->uiapp_info = ptr1;
4218 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4219 "from package_app_info where " \
4220 "app_id='%s'", ptr1->appid);
4221 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4222 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4224 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
4228 locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
4231 memset(query, '\0', MAX_QUERY_LEN);
4232 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4233 "from package_app_localized_info where " \
4234 "app_id='%s' and app_locale='%s'",
4235 ptr1->appid, locale);
4236 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4237 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4239 memset(query, '\0', MAX_QUERY_LEN);
4240 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4241 "from package_app_localized_info where " \
4242 "app_id='%s' and app_locale='%s'",
4243 ptr1->appid, DEFAULT_LOCALE);
4245 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4246 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4248 /*store setting notification icon section*/
4249 memset(query, '\0', MAX_QUERY_LEN);
4250 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
4251 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4252 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4254 /*store app preview image info*/
4255 memset(query, '\0', MAX_QUERY_LEN);
4256 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
4257 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4258 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4260 if (appinfo->uiapp_info->label) {
4261 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4262 appinfo->uiapp_info->label = tmp1;
4264 if (appinfo->uiapp_info->icon) {
4265 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4266 appinfo->uiapp_info->icon= tmp2;
4268 if (appinfo->uiapp_info->category) {
4269 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4270 appinfo->uiapp_info->category = tmp3;
4272 if (appinfo->uiapp_info->metadata) {
4273 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4274 appinfo->uiapp_info->metadata = tmp4;
4276 if (appinfo->uiapp_info->permission) {
4277 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4278 appinfo->uiapp_info->permission = tmp5;
4280 if (appinfo->uiapp_info->image) {
4281 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4282 appinfo->uiapp_info->image = tmp6;
4284 ret = app_func((void *)appinfo, user_data);
4287 free((void *)appinfo->package);
4288 appinfo->package = NULL;
4291 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4293 appinfo->locale = strdup(locale);
4294 appinfo->app_component = PMINFO_SVC_APP;
4295 appinfo->package = strdup(ptr2->package);
4296 appinfo->svcapp_info = ptr2;
4297 memset(query, '\0', MAX_QUERY_LEN);
4298 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4299 "from package_app_info where " \
4300 "app_id='%s'", ptr2->appid);
4301 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4302 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4304 memset(query, '\0', MAX_QUERY_LEN);
4305 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4306 "from package_app_localized_info where " \
4307 "app_id='%s' and app_locale='%s'",
4308 ptr2->appid, locale);
4309 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4310 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4312 memset(query, '\0', MAX_QUERY_LEN);
4313 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4314 "from package_app_localized_info where " \
4315 "app_id='%s' and app_locale='%s'",
4316 ptr2->appid, DEFAULT_LOCALE);
4317 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4318 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4320 if (appinfo->svcapp_info->label) {
4321 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4322 appinfo->svcapp_info->label = tmp1;
4324 if (appinfo->svcapp_info->icon) {
4325 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4326 appinfo->svcapp_info->icon= tmp2;
4328 if (appinfo->svcapp_info->category) {
4329 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4330 appinfo->svcapp_info->category = tmp3;
4332 if (appinfo->svcapp_info->metadata) {
4333 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4334 appinfo->svcapp_info->metadata = tmp4;
4336 if (appinfo->svcapp_info->permission) {
4337 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4338 appinfo->svcapp_info->permission = tmp5;
4340 ret = app_func((void *)appinfo, user_data);
4343 free((void *)appinfo->package);
4344 appinfo->package = NULL;
4357 sqlite3_close(appinfo_db);
4362 __cleanup_pkginfo(info);
4366 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
4368 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
4369 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4371 pkgmgr_appinfo_x *appinfo = NULL;
4372 char *syslocale = NULL;
4373 char *locale = NULL;
4376 label_x *tmp1 = NULL;
4377 icon_x *tmp2 = NULL;
4378 category_x *tmp3 = NULL;
4379 metadata_x *tmp4 = NULL;
4380 permission_x *tmp5 = NULL;
4381 image_x *tmp6 = NULL;
4382 char query[MAX_QUERY_LEN] = {'\0'};
4383 sqlite3 *appinfo_db = NULL;
4386 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4387 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4389 /*check appid exist on db*/
4390 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
4391 ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
4392 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
4393 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
4395 /*get system locale*/
4396 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4397 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
4399 /*get locale on db*/
4400 locale = __convert_system_locale_to_manifest_locale(syslocale);
4401 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4404 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4405 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
4407 /*check app_component from DB*/
4408 memset(query, '\0', MAX_QUERY_LEN);
4409 snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
4410 ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
4411 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4413 /*calloc app_component*/
4414 if (appinfo->app_component == PMINFO_UI_APP) {
4415 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4416 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
4418 appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
4419 tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
4421 appinfo->locale = strdup(locale);
4423 /*populate app_info from DB*/
4424 memset(query, '\0', MAX_QUERY_LEN);
4425 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
4426 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4427 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4429 memset(query, '\0', MAX_QUERY_LEN);
4430 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
4431 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4432 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4434 /*Also store the values corresponding to default locales*/
4435 memset(query, '\0', MAX_QUERY_LEN);
4436 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
4437 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4438 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4440 /*Populate app category*/
4441 memset(query, '\0', MAX_QUERY_LEN);
4442 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
4443 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4444 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
4446 /*Populate app metadata*/
4447 memset(query, '\0', MAX_QUERY_LEN);
4448 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
4449 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4450 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
4452 /*Populate app permission*/
4453 memset(query, '\0', MAX_QUERY_LEN);
4454 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
4455 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4456 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
4458 /*store setting notification icon section*/
4459 memset(query, '\0', MAX_QUERY_LEN);
4460 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
4461 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4462 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4464 /*store app preview image info*/
4465 memset(query, '\0', MAX_QUERY_LEN);
4466 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
4467 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4468 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4470 switch (appinfo->app_component) {
4472 if (appinfo->uiapp_info->label) {
4473 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4474 appinfo->uiapp_info->label = tmp1;
4476 if (appinfo->uiapp_info->icon) {
4477 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4478 appinfo->uiapp_info->icon = tmp2;
4480 if (appinfo->uiapp_info->category) {
4481 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4482 appinfo->uiapp_info->category = tmp3;
4484 if (appinfo->uiapp_info->metadata) {
4485 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4486 appinfo->uiapp_info->metadata = tmp4;
4488 if (appinfo->uiapp_info->permission) {
4489 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4490 appinfo->uiapp_info->permission = tmp5;
4492 if (appinfo->uiapp_info->image) {
4493 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4494 appinfo->uiapp_info->image = tmp6;
4497 case PMINFO_SVC_APP:
4498 if (appinfo->svcapp_info->label) {
4499 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4500 appinfo->svcapp_info->label = tmp1;
4502 if (appinfo->svcapp_info->icon) {
4503 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4504 appinfo->svcapp_info->icon = tmp2;
4506 if (appinfo->svcapp_info->category) {
4507 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4508 appinfo->svcapp_info->category = tmp3;
4510 if (appinfo->svcapp_info->metadata) {
4511 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4512 appinfo->svcapp_info->metadata = tmp4;
4514 if (appinfo->svcapp_info->permission) {
4515 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4516 appinfo->svcapp_info->permission = tmp5;
4526 if (ret == PMINFO_R_OK)
4527 *handle = (void*)appinfo;
4530 __cleanup_appinfo(appinfo);
4533 sqlite3_close(appinfo_db);
4546 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
4548 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4549 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4550 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4552 if (info->app_component == PMINFO_UI_APP)
4553 *appid = (char *)info->uiapp_info->appid;
4554 else if (info->app_component == PMINFO_SVC_APP)
4555 *appid = (char *)info->svcapp_info->appid;
4560 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
4562 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4563 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4564 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4566 *pkg_name = (char *)info->package;
4571 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
4573 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4574 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4575 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4577 *pkgid = (char *)info->package;
4582 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
4584 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4585 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4586 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4588 if (info->app_component == PMINFO_UI_APP)
4589 *exec = (char *)info->uiapp_info->exec;
4590 if (info->app_component == PMINFO_SVC_APP)
4591 *exec = (char *)info->svcapp_info->exec;
4597 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4599 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4600 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4601 char *locale = NULL;
4603 icon_x *start = NULL;
4606 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4607 locale = info->locale;
4608 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4610 if (info->app_component == PMINFO_UI_APP)
4611 start = info->uiapp_info->icon;
4612 if (info->app_component == PMINFO_SVC_APP)
4613 start = info->svcapp_info->icon;
4614 for(ptr = start; ptr != NULL; ptr = ptr->next)
4617 if (strcmp(ptr->lang, locale) == 0) {
4618 *icon = (char *)ptr->text;
4619 if (strcasecmp(*icon, "(null)") == 0) {
4620 locale = DEFAULT_LOCALE;
4624 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4625 *icon = (char *)ptr->text;
4634 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
4636 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4637 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4638 char *locale = NULL;
4639 label_x *ptr = NULL;
4640 label_x *start = NULL;
4643 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4644 locale = info->locale;
4645 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4647 if (info->app_component == PMINFO_UI_APP)
4648 start = info->uiapp_info->label;
4649 if (info->app_component == PMINFO_SVC_APP)
4650 start = info->svcapp_info->label;
4651 for(ptr = start; ptr != NULL; ptr = ptr->next)
4654 if (strcmp(ptr->lang, locale) == 0) {
4655 *label = (char *)ptr->text;
4656 if (strcasecmp(*label, "(null)") == 0) {
4657 locale = DEFAULT_LOCALE;
4661 } else if (strncasecmp(ptr->lang, locale, 2) == 0) {
4662 *label = (char *)ptr->text;
4663 if (strcasecmp(*label, "(null)") == 0) {
4664 locale = DEFAULT_LOCALE;
4668 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4669 *label = (char *)ptr->text;
4678 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
4680 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4681 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4682 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4684 if (info->app_component == PMINFO_UI_APP)
4685 *component = PMINFO_UI_APP;
4686 else if (info->app_component == PMINFO_SVC_APP)
4687 *component = PMINFO_SVC_APP;
4689 return PMINFO_R_ERROR;
4694 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
4696 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4697 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4698 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4700 if (info->app_component == PMINFO_UI_APP)
4701 *app_type = (char *)info->uiapp_info->type;
4702 if (info->app_component == PMINFO_SVC_APP)
4703 *app_type = (char *)info->svcapp_info->type;
4708 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
4709 int *operation_count, char ***operation)
4711 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4712 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4713 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4714 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4715 *operation_count = data->operation_count;
4716 *operation = data->operation;
4720 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
4721 int *uri_count, char ***uri)
4723 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4724 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4725 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4726 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4727 *uri_count = data->uri_count;
4732 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
4733 int *mime_count, char ***mime)
4735 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4736 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4737 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4738 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4739 *mime_count = data->mime_count;
4744 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
4745 int *subapp_count, char ***subapp)
4747 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4748 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4749 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4750 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4751 *subapp_count = data->subapp_count;
4752 *subapp = data->subapp;
4756 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4758 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4759 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4763 icon_x *start = NULL;
4764 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4766 start = info->uiapp_info->icon;
4768 for(ptr = start; ptr != NULL; ptr = ptr->next)
4771 val = (char *)ptr->section;
4772 if (strcmp(val, "setting") == 0){
4773 *icon = (char *)ptr->text;
4782 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4784 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4785 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4789 icon_x *start = NULL;
4790 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4792 start = info->uiapp_info->icon;
4794 for(ptr = start; ptr != NULL; ptr = ptr->next)
4797 val = (char *)ptr->section;
4799 if (strcmp(val, "notification") == 0){
4800 *icon = (char *)ptr->text;
4809 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
4811 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4812 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4814 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4815 val = (char *)info->uiapp_info->recentimage;
4817 if (strcasecmp(val, "capture") == 0)
4818 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
4819 else if (strcasecmp(val, "icon") == 0)
4820 *type = PMINFO_RECENTIMAGE_USE_ICON;
4822 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
4828 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
4830 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4831 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4834 image_x *ptr = NULL;
4835 image_x *start = NULL;
4836 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4838 start = info->uiapp_info->image;
4840 for(ptr = start; ptr != NULL; ptr = ptr->next)
4843 val = (char *)ptr->section;
4845 if (strcmp(val, "preview") == 0)
4846 *preview_img = (char *)ptr->text;
4854 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
4856 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4857 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4860 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4862 val = info->uiapp_info->permission_type;
4864 if (strcmp(val, "signature") == 0)
4865 *permission = PMINFO_PERMISSION_SIGNATURE;
4866 else if (strcmp(val, "privilege") == 0)
4867 *permission = PMINFO_PERMISSION_PRIVILEGE;
4869 *permission = PMINFO_PERMISSION_NORMAL;
4874 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
4876 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4877 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4878 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4880 *component_type = (char *)info->uiapp_info->component_type;
4885 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
4887 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4888 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4890 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4891 val = (char *)info->uiapp_info->hwacceleration;
4893 if (strcasecmp(val, "not-use-GL") == 0)
4894 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
4895 else if (strcasecmp(val, "use-GL") == 0)
4896 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
4898 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
4903 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
4905 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4906 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4907 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4908 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4910 if (info->app_component == PMINFO_UI_APP){
4911 *portrait_img = (char *)info->uiapp_info->portraitimg;
4912 *landscape_img = (char *)info->uiapp_info->landscapeimg;
4918 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
4920 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4921 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4922 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4924 *submode_mainid = (char *)info->uiapp_info->submode_mainid;
4929 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
4930 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
4932 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4933 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4935 permission_x *ptr = NULL;
4936 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4937 if (info->app_component == PMINFO_UI_APP)
4938 ptr = info->uiapp_info->permission;
4939 else if (info->app_component == PMINFO_SVC_APP)
4940 ptr = info->svcapp_info->permission;
4942 return PMINFO_R_EINVAL;
4943 for (; ptr; ptr = ptr->next) {
4944 ret = permission_func(ptr->value, user_data);
4951 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
4952 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
4954 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4955 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4957 category_x *ptr = NULL;
4958 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4959 if (info->app_component == PMINFO_UI_APP)
4960 ptr = info->uiapp_info->category;
4961 else if (info->app_component == PMINFO_SVC_APP)
4962 ptr = info->svcapp_info->category;
4964 return PMINFO_R_EINVAL;
4965 for (; ptr; ptr = ptr->next) {
4966 ret = category_func(ptr->name, user_data);
4973 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
4974 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
4976 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4977 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4979 metadata_x *ptr = NULL;
4980 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4981 if (info->app_component == PMINFO_UI_APP)
4982 ptr = info->uiapp_info->metadata;
4983 else if (info->app_component == PMINFO_SVC_APP)
4984 ptr = info->svcapp_info->metadata;
4986 return PMINFO_R_EINVAL;
4987 for (; ptr; ptr = ptr->next) {
4988 ret = metadata_func(ptr->key, ptr->value, user_data);
4995 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
4996 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
4998 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4999 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5007 char *manifest = NULL;
5008 char **operation = NULL;
5011 char **subapp = NULL;
5012 appcontrol_x *appcontrol = NULL;
5013 manifest_x *mfx = NULL;
5014 operation_x *op = NULL;
5017 subapp_x *sa = NULL;
5018 pkgmgrinfo_app_component component;
5019 pkgmgrinfo_appcontrol_x *ptr = NULL;
5020 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
5022 _LOGE("Failed to get package name\n");
5023 return PMINFO_R_ERROR;
5025 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
5027 _LOGE("Failed to get app component name\n");
5028 return PMINFO_R_ERROR;
5030 manifest = pkgmgr_parser_get_manifest_file(pkgid);
5031 if (manifest == NULL) {
5032 _LOGE("Failed to fetch package manifest file\n");
5033 return PMINFO_R_ERROR;
5035 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5037 _LOGE("Failed to parse package manifest file\n");
5040 return PMINFO_R_ERROR;
5043 ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
5045 _LOGE("Out of Memory!!!\n");
5046 pkgmgr_parser_free_manifest_xml(mfx);
5047 return PMINFO_R_ERROR;
5049 /*Get Operation, Uri, Mime*/
5050 switch (component) {
5052 if (mfx->uiapplication) {
5053 if (mfx->uiapplication->appsvc) {
5054 appcontrol = mfx->uiapplication->appsvc;
5058 case PMINFO_SVC_APP:
5059 if (mfx->serviceapplication) {
5060 if (mfx->serviceapplication->appsvc) {
5061 appcontrol = mfx->serviceapplication->appsvc;
5068 for (; appcontrol; appcontrol = appcontrol->next) {
5069 op = appcontrol->operation;
5070 for (; op; op = op->next)
5072 op = appcontrol->operation;
5074 ui = appcontrol->uri;
5075 for (; ui; ui = ui->next)
5077 ui = appcontrol->uri;
5079 mi = appcontrol->mime;
5080 for (; mi; mi = mi->next)
5082 mi = appcontrol->mime;
5084 sa = appcontrol->subapp;
5085 for (; sa; sa = sa->next)
5087 sa = appcontrol->subapp;
5089 operation = (char **)calloc(oc, sizeof(char *));
5090 for (i = 0; i < oc; i++) {
5091 operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
5095 uri = (char **)calloc(uc, sizeof(char *));
5096 for (i = 0; i < uc; i++) {
5097 uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
5101 mime = (char **)calloc(mc, sizeof(char *));
5102 for (i = 0; i < mc; i++) {
5103 mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
5107 subapp = (char **)calloc(sc, sizeof(char *));
5108 for (i = 0; i < sc; i++) {
5109 subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
5113 /*populate appcontrol handle*/
5114 ptr->operation_count = oc;
5115 ptr->uri_count = uc;
5116 ptr->mime_count = mc;
5117 ptr->subapp_count = sc;
5118 ptr->operation = operation;
5121 ptr->subapp = subapp;
5123 ret = appcontrol_func((void *)ptr, user_data);
5124 for (i = 0; i < oc; i++) {
5127 operation[i] = NULL;
5134 for (i = 0; i < uc; i++) {
5144 for (i = 0; i < mc; i++) {
5154 for (i = 0; i < sc; i++) {
5171 pkgmgr_parser_free_manifest_xml(mfx);
5179 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
5181 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5182 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5184 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5185 val = (char *)info->uiapp_info->nodisplay;
5187 if (strcasecmp(val, "true") == 0)
5189 else if (strcasecmp(val, "false") == 0)
5197 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
5199 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5200 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5202 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5203 val = (char *)info->uiapp_info->multiple;
5205 if (strcasecmp(val, "true") == 0)
5207 else if (strcasecmp(val, "false") == 0)
5215 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
5217 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5218 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5220 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5221 val = (char *)info->uiapp_info->indicatordisplay;
5223 if (strcasecmp(val, "true") == 0){
5224 *indicator_disp = 1;
5225 }else if (strcasecmp(val, "false") == 0){
5226 *indicator_disp = 0;
5228 *indicator_disp = 0;
5234 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
5236 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5237 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5239 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5240 val = (char *)info->uiapp_info->taskmanage;
5242 if (strcasecmp(val, "true") == 0)
5244 else if (strcasecmp(val, "false") == 0)
5252 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
5254 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5255 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5257 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5258 if (info->app_component == PMINFO_UI_APP)
5259 val = (char *)info->uiapp_info->enabled;
5260 else if (info->app_component == PMINFO_SVC_APP)
5261 val = (char *)info->uiapp_info->enabled;
5263 _LOGE("invalid component type\n");
5264 return PMINFO_R_EINVAL;
5268 if (strcasecmp(val, "true") == 0)
5270 else if (strcasecmp(val, "false") == 0)
5279 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
5281 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5282 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5284 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5285 val = (char *)info->svcapp_info->onboot;
5287 if (strcasecmp(val, "true") == 0)
5289 else if (strcasecmp(val, "false") == 0)
5297 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
5299 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5300 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5302 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5303 val = (char *)info->svcapp_info->autorestart;
5305 if (strcasecmp(val, "true") == 0)
5307 else if (strcasecmp(val, "false") == 0)
5315 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
5317 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5318 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5320 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5321 val = (char *)info->uiapp_info->mainapp;
5323 if (strcasecmp(val, "true") == 0)
5325 else if (strcasecmp(val, "false") == 0)
5333 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
5335 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5336 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5338 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5339 val = (char *)info->uiapp_info->preload;
5341 if (strcasecmp(val, "true") == 0)
5343 else if (strcasecmp(val, "false") == 0)
5351 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
5353 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5354 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5356 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5357 val = (char *)info->uiapp_info->submode;
5359 if (strcasecmp(val, "true") == 0)
5361 else if (strcasecmp(val, "false") == 0)
5369 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
5371 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5372 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5373 __cleanup_appinfo(info);
5377 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
5379 return (pkgmgrinfo_pkginfo_filter_create(handle));
5382 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
5384 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5387 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
5388 const char *property, const int value)
5390 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5391 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5392 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
5394 GSList *link = NULL;
5396 prop = _pminfo_appinfo_convert_to_prop_int(property);
5397 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
5398 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
5399 _LOGE("Invalid Integer Property\n");
5400 return PMINFO_R_EINVAL;
5402 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5403 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5405 _LOGE("Out of Memory!!!\n");
5406 return PMINFO_R_ERROR;
5408 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
5409 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
5411 _LOGE("Out of Memory\n");
5414 return PMINFO_R_ERROR;
5418 /*If API is called multiple times for same property, we should override the previous values.
5419 Last value set will be used for filtering.*/
5420 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5422 filter->list = g_slist_delete_link(filter->list, link);
5423 filter->list = g_slist_append(filter->list, (gpointer)node);
5428 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
5429 const char *property, const bool value)
5431 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5432 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5434 GSList *link = NULL;
5436 prop = _pminfo_appinfo_convert_to_prop_bool(property);
5437 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
5438 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
5439 _LOGE("Invalid Boolean Property\n");
5440 return PMINFO_R_EINVAL;
5442 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5443 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5445 _LOGE("Out of Memory!!!\n");
5446 return PMINFO_R_ERROR;
5449 val = strndup("('true','True')", 15);
5451 val = strndup("('false','False')", 17);
5453 _LOGE("Out of Memory\n");
5456 return PMINFO_R_ERROR;
5460 /*If API is called multiple times for same property, we should override the previous values.
5461 Last value set will be used for filtering.*/
5462 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5464 filter->list = g_slist_delete_link(filter->list, link);
5465 filter->list = g_slist_append(filter->list, (gpointer)node);
5470 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
5471 const char *property, const char *value)
5473 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5474 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5475 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5477 pkgmgrinfo_node_x *ptr = NULL;
5478 char prev[PKG_STRING_LEN_MAX] = {'\0'};
5479 char temp[PKG_STRING_LEN_MAX] = {'\0'};
5480 GSList *link = NULL;
5482 prop = _pminfo_appinfo_convert_to_prop_str(property);
5483 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
5484 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
5485 _LOGE("Invalid String Property\n");
5486 return PMINFO_R_EINVAL;
5488 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5489 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5491 _LOGE("Out of Memory!!!\n");
5492 return PMINFO_R_ERROR;
5496 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
5497 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
5498 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
5500 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
5502 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5504 filter->list = g_slist_delete_link(filter->list, link);
5505 filter->list = g_slist_append(filter->list, (gpointer)node);
5507 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
5508 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
5509 case E_PMINFO_APPINFO_PROP_APP_URI:
5510 case E_PMINFO_APPINFO_PROP_APP_MIME:
5511 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
5513 _LOGE("Out of Memory\n");
5516 return PMINFO_R_ERROR;
5518 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5520 ptr = (pkgmgrinfo_node_x *)link->data;
5521 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
5522 _LOGE("Previous value is %s\n", prev);
5523 filter->list = g_slist_delete_link(filter->list, link);
5524 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
5525 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5526 _LOGE("New value is %s\n", val);
5528 filter->list = g_slist_append(filter->list, (gpointer)node);
5529 memset(temp, '\0', PKG_STRING_LEN_MAX);
5531 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
5532 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5533 _LOGE("First value is %s\n", val);
5535 filter->list = g_slist_append(filter->list, (gpointer)node);
5536 memset(temp, '\0', PKG_STRING_LEN_MAX);
5540 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
5541 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5543 filter->list = g_slist_delete_link(filter->list, link);
5544 filter->list = g_slist_append(filter->list, (gpointer)node);
5550 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
5552 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5553 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5554 char *syslocale = NULL;
5555 char *locale = NULL;
5556 char *condition = NULL;
5557 char *error_message = NULL;
5558 char query[MAX_QUERY_LEN] = {'\0'};
5559 char where[MAX_QUERY_LEN] = {'\0'};
5563 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5564 /*Get current locale*/
5565 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5566 if (syslocale == NULL) {
5567 _LOGE("current locale is NULL\n");
5568 return PMINFO_R_ERROR;
5570 locale = __convert_system_locale_to_manifest_locale(syslocale);
5571 if (locale == NULL) {
5572 _LOGE("manifest locale is NULL\n");
5574 return PMINFO_R_ERROR;
5577 ret = __open_manifest_db();
5579 _LOGE("Fail to open manifest DB\n");
5580 ret = PMINFO_R_ERROR;
5584 /*Start constructing query*/
5585 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_APP, locale);
5587 /*Get where clause*/
5588 for (list = filter->list; list; list = g_slist_next(list)) {
5589 __get_filter_condition(list->data, &condition);
5591 strncat(where, condition, sizeof(where) - strlen(where) -1);
5592 where[sizeof(where) - 1] = '\0';
5596 if (g_slist_next(list)) {
5597 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5598 where[sizeof(where) - 1] = '\0';
5601 _LOGE("where = %s\n", where);
5602 if (strlen(where) > 0) {
5603 strncat(query, where, sizeof(query) - strlen(query) - 1);
5604 query[sizeof(query) - 1] = '\0';
5606 _LOGE("query = %s\n", query);
5610 sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
5611 _LOGE("Don't execute query = %s error message = %s\n", query,
5613 sqlite3_free(error_message);
5614 sqlite3_close(manifest_db);
5615 ret = PMINFO_R_ERROR;
5629 sqlite3_close(manifest_db);
5633 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
5634 pkgmgrinfo_app_list_cb app_cb, void * user_data)
5636 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5637 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5638 char *syslocale = NULL;
5639 char *locale = NULL;
5640 char *condition = NULL;
5641 char *error_message = NULL;
5642 char query[MAX_QUERY_LEN] = {'\0'};
5643 char where[MAX_QUERY_LEN] = {'\0'};
5646 uiapplication_x *ptr1 = NULL;
5647 serviceapplication_x *ptr2 = NULL;
5648 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5649 /*Get current locale*/
5650 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5651 if (syslocale == NULL) {
5652 _LOGE("current locale is NULL\n");
5653 return PMINFO_R_ERROR;
5655 locale = __convert_system_locale_to_manifest_locale(syslocale);
5656 if (locale == NULL) {
5657 _LOGE("manifest locale is NULL\n");
5659 return PMINFO_R_ERROR;
5662 ret = __open_manifest_db();
5664 _LOGE("Fail to open manifest DB\n");
5665 ret = PMINFO_R_ERROR;
5668 /*Start constructing query*/
5669 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
5670 /*Get where clause*/
5671 for (list = filter->list; list; list = g_slist_next(list)) {
5672 __get_filter_condition(list->data, &condition);
5674 strncat(where, condition, sizeof(where) - strlen(where) -1);
5675 where[sizeof(where) - 1] = '\0';
5679 if (g_slist_next(list)) {
5680 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5681 where[sizeof(where) - 1] = '\0';
5684 _LOGE("where = %s\n", where);
5685 if (strlen(where) > 0) {
5686 strncat(query, where, sizeof(query) - strlen(query) - 1);
5687 query[sizeof(query) - 1] = '\0';
5689 _LOGE("query = %s\n", query);
5690 /*To get filtered list*/
5691 pkgmgr_pkginfo_x *info = NULL;
5692 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5694 _LOGE("Out of Memory!!!\n");
5695 ret = PMINFO_R_ERROR;
5698 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5699 if (info->manifest_info == NULL) {
5700 _LOGE("Out of Memory!!!\n");
5701 ret = PMINFO_R_ERROR;
5704 /*To get detail app info for each member of filtered list*/
5705 pkgmgr_pkginfo_x *filtinfo = NULL;
5706 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5707 if (filtinfo == NULL) {
5708 _LOGE("Out of Memory!!!\n");
5709 ret = PMINFO_R_ERROR;
5712 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5713 if (filtinfo->manifest_info == NULL) {
5714 _LOGE("Out of Memory!!!\n");
5715 ret = PMINFO_R_ERROR;
5718 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5719 if (appinfo == NULL) {
5720 _LOGE("Out of Memory!!!\n");
5721 ret = PMINFO_R_ERROR;
5725 sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) {
5726 _LOGE("Don't execute query = %s error message = %s\n", query,
5728 sqlite3_free(error_message);
5729 sqlite3_close(manifest_db);
5730 ret = PMINFO_R_ERROR;
5733 memset(query, '\0', MAX_QUERY_LEN);
5734 if (info->manifest_info->uiapplication) {
5735 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5736 info->manifest_info->uiapplication = ptr1;
5738 if (info->manifest_info->serviceapplication) {
5739 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5740 info->manifest_info->serviceapplication = ptr2;
5742 /*Filtered UI Apps*/
5743 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5745 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5746 ptr1->appid, "uiapp");
5748 sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
5749 _LOGE("Don't execute query = %s error message = %s\n", query,
5751 sqlite3_free(error_message);
5752 sqlite3_close(manifest_db);
5753 ret = PMINFO_R_ERROR;
5757 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5759 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5760 ptr2->appid, "svcapp");
5762 sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
5763 _LOGE("Don't execute query = %s error message = %s\n", query,
5765 sqlite3_free(error_message);
5766 sqlite3_close(manifest_db);
5767 ret = PMINFO_R_ERROR;
5771 if (filtinfo->manifest_info->uiapplication) {
5772 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5773 filtinfo->manifest_info->uiapplication = ptr1;
5775 /*If the callback func return < 0 we break and no more call back is called*/
5778 appinfo->locale = strdup(locale);
5779 appinfo->uiapp_info = ptr1;
5780 appinfo->app_component = PMINFO_UI_APP;
5781 ret = app_cb((void *)appinfo, user_data);
5786 /*Filtered Service Apps*/
5787 if (filtinfo->manifest_info->serviceapplication) {
5788 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5789 filtinfo->manifest_info->serviceapplication = ptr2;
5791 /*If the callback func return < 0 we break and no more call back is called*/
5794 appinfo->locale = strdup(locale);
5795 appinfo->svcapp_info = ptr2;
5796 appinfo->app_component = PMINFO_SVC_APP;
5797 ret = app_cb((void *)appinfo, user_data);
5812 sqlite3_close(manifest_db);
5817 __cleanup_pkginfo(info);
5818 __cleanup_pkginfo(filtinfo);
5822 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
5824 return (pkgmgrinfo_pkginfo_filter_create(handle));
5827 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
5829 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5832 API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
5833 const char *key, const char *value)
5835 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
5836 retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
5837 /*value can be NULL. In that case all apps with specified key should be displayed*/
5841 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5842 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5843 retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
5845 tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5849 tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5852 /*If API is called multiple times, we should OR all conditions.*/
5853 filter->list = g_slist_append(filter->list, (gpointer)node);
5854 /*All memory will be freed in destroy API*/
5872 API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
5873 pkgmgrinfo_app_list_cb app_cb, void *user_data)
5875 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
5876 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
5877 char *syslocale = NULL;
5878 char *locale = NULL;
5879 char *condition = NULL;
5880 char *error_message = NULL;
5881 char query[MAX_QUERY_LEN] = {'\0'};
5882 char where[MAX_QUERY_LEN] = {'\0'};
5885 pkgmgr_pkginfo_x *info = NULL;
5886 pkgmgr_pkginfo_x *filtinfo = NULL;
5887 pkgmgr_appinfo_x *appinfo = NULL;
5888 uiapplication_x *ptr1 = NULL;
5889 serviceapplication_x *ptr2 = NULL;
5890 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5892 /*Get current locale*/
5893 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5894 retvm_if(syslocale == NULL, PMINFO_R_ERROR, "current locale is NULL\n");
5895 locale = __convert_system_locale_to_manifest_locale(syslocale);
5896 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
5898 ret = __open_manifest_db();
5899 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Fail to open manifest DB\n");
5901 /*Start constructing query*/
5902 memset(where, '\0', MAX_QUERY_LEN);
5903 memset(query, '\0', MAX_QUERY_LEN);
5904 snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
5905 /*Get where clause*/
5906 for (list = filter->list; list; list = g_slist_next(list)) {
5907 __get_metadata_filter_condition(list->data, &condition);
5909 strncat(where, condition, sizeof(where) - strlen(where) -1);
5913 if (g_slist_next(list)) {
5914 strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
5917 _LOGE("where = %s (%d)\n", where, strlen(where));
5918 if (strlen(where) > 0) {
5919 strncat(query, where, sizeof(query) - strlen(query) - 1);
5921 _LOGE("query = %s (%d)\n", query, strlen(query));
5922 /*To get filtered list*/
5923 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5924 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5926 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5927 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5929 /*To get detail app info for each member of filtered list*/
5930 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5931 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5933 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5934 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5936 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5937 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5939 ret = sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message);
5940 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5941 memset(query, '\0', MAX_QUERY_LEN);
5943 if (info->manifest_info->uiapplication) {
5944 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5945 info->manifest_info->uiapplication = ptr1;
5947 if (info->manifest_info->serviceapplication) {
5948 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5949 info->manifest_info->serviceapplication = ptr2;
5953 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5955 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5956 ptr1->appid, "uiapp");
5957 ret = sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message);
5958 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5959 memset(query, '\0', MAX_QUERY_LEN);
5962 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5964 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5965 ptr2->appid, "svcapp");
5966 ret = sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message);
5967 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5968 memset(query, '\0', MAX_QUERY_LEN);
5970 /*Filtered UI Apps*/
5971 if (filtinfo->manifest_info->uiapplication) {
5972 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5973 filtinfo->manifest_info->uiapplication = ptr1;
5975 /*If the callback func return < 0 we break and no more call back is called*/
5978 appinfo->locale = strdup(locale);
5979 appinfo->uiapp_info = ptr1;
5980 appinfo->app_component = PMINFO_UI_APP;
5981 ret = app_cb((void *)appinfo, user_data);
5986 /*Filtered Service Apps*/
5987 if (filtinfo->manifest_info->serviceapplication) {
5988 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5989 filtinfo->manifest_info->serviceapplication = ptr2;
5991 /*If the callback func return < 0 we break and no more call back is called*/
5994 appinfo->locale = strdup(locale);
5995 appinfo->svcapp_info = ptr2;
5996 appinfo->app_component = PMINFO_SVC_APP;
5997 ret = app_cb((void *)appinfo, user_data);
6012 sqlite3_free(error_message);
6013 sqlite3_close(manifest_db);
6018 __cleanup_pkginfo(info);
6019 __cleanup_pkginfo(filtinfo);
6023 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
6025 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6026 pkgmgr_certinfo_x *certinfo = NULL;
6027 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
6028 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
6029 *handle = (void *)certinfo;
6033 API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
6035 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
6036 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
6037 pkgmgr_certinfo_x *certinfo = NULL;
6038 char *error_message = NULL;
6039 int ret = PMINFO_R_OK;
6040 char query[MAX_QUERY_LEN] = {'\0'};
6045 ret = db_util_open_with_options(CERT_DB, &cert_db,
6046 SQLITE_OPEN_READONLY, NULL);
6047 if (ret != SQLITE_OK) {
6048 _LOGE("connect db [%s] failed!\n", CERT_DB);
6049 return PMINFO_R_ERROR;
6052 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6054 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6055 _LOGE("Don't execute query = %s error message = %s\n", query,
6057 sqlite3_free(error_message);
6058 ret = PMINFO_R_ERROR;
6062 _LOGE("Package not found in DB\n");
6063 ret = PMINFO_R_ERROR;
6066 certinfo = (pkgmgr_certinfo_x *)handle;
6067 /*populate certinfo from DB*/
6068 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
6069 ret = __exec_certinfo_query(query, (void *)certinfo);
6071 _LOGE("Package Cert Info DB Information retrieval failed\n");
6072 ret = PMINFO_R_ERROR;
6075 for (i = 0; i < MAX_CERT_TYPE; i++) {
6076 memset(query, '\0', MAX_QUERY_LEN);
6077 snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
6078 ret = __exec_certinfo_query(query, (void *)certinfo);
6080 _LOGE("Cert Info DB Information retrieval failed\n");
6081 ret = PMINFO_R_ERROR;
6084 if (certinfo->cert_value) {
6085 (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
6086 free(certinfo->cert_value);
6087 certinfo->cert_value = NULL;
6091 sqlite3_close(cert_db);
6095 API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
6097 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6098 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6099 retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6100 retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6101 pkgmgr_certinfo_x *certinfo = NULL;
6102 certinfo = (pkgmgr_certinfo_x *)handle;
6103 if ((certinfo->cert_info)[cert_type])
6104 *cert_value = (certinfo->cert_info)[cert_type];
6110 API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
6112 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6114 pkgmgr_certinfo_x *certinfo = NULL;
6115 certinfo = (pkgmgr_certinfo_x *)handle;
6116 if (certinfo->pkgid) {
6117 free(certinfo->pkgid);
6118 certinfo->pkgid = NULL;
6120 for (i = 0; i < MAX_CERT_TYPE; i++) {
6121 if ((certinfo->cert_info)[i]) {
6122 free((certinfo->cert_info)[i]);
6123 (certinfo->cert_info)[i] = NULL;
6131 API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
6133 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6134 pkgmgr_instcertinfo_x *certinfo = NULL;
6135 certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
6136 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
6137 *handle = (void *)certinfo;
6141 API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
6143 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6144 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6145 retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6146 retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6147 pkgmgr_instcertinfo_x *certinfo = NULL;
6148 certinfo = (pkgmgr_instcertinfo_x *)handle;
6149 (certinfo->cert_info)[cert_type] = strdup(cert_value);
6153 API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
6155 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
6156 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
6157 char *error_message = NULL;
6158 char query[MAX_QUERY_LEN] = {'\0'};
6159 char *vquery = NULL;
6164 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
6171 pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
6172 pkgmgr_certindexinfo_x *indexinfo = NULL;
6173 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
6174 if (indexinfo == NULL) {
6175 _LOGE("Out of Memory!!!");
6176 return PMINFO_R_ERROR;
6178 info->pkgid = strdup(pkgid);
6181 ret = db_util_open_with_options(CERT_DB, &cert_db,
6182 SQLITE_OPEN_READWRITE, NULL);
6183 if (ret != SQLITE_OK) {
6184 _LOGE("connect db [%s] failed!\n", CERT_DB);
6185 ret = PMINFO_R_ERROR;
6188 /*Begin Transaction*/
6189 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6190 if (ret != SQLITE_OK) {
6191 _LOGE("Failed to begin transaction\n");
6192 ret = PMINFO_R_ERROR;
6195 _LOGE("Transaction Begin\n");
6196 /*Check if request is to insert/update*/
6197 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6199 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6200 _LOGE("Don't execute query = %s error message = %s\n", query,
6202 sqlite3_free(error_message);
6203 ret = PMINFO_R_ERROR;
6208 We cant just issue update query directly. We need to manage index table also.
6209 Hence it is better to delete and insert again in case of update*/
6210 ret = __delete_certinfo(pkgid);
6212 _LOGE("Certificate Deletion Failed\n");
6214 for (i = 0; i < MAX_CERT_TYPE; i++) {
6215 if ((info->cert_info)[i]) {
6216 for (j = 0; j < i; j++) {
6217 if ( (info->cert_info)[j]) {
6218 if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
6219 (info->cert_id)[i] = (info->cert_id)[j];
6220 (info->is_new)[i] = 0;
6221 (info->ref_count)[i] = (info->ref_count)[j];
6228 memset(query, '\0', MAX_QUERY_LEN);
6229 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
6230 "where cert_info='%s'",(info->cert_info)[i]);
6231 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
6233 _LOGE("Cert Info DB Information retrieval failed\n");
6234 ret = PMINFO_R_ERROR;
6237 if (indexinfo->cert_id == 0) {
6238 /*New certificate. Get newid*/
6239 memset(query, '\0', MAX_QUERY_LEN);
6240 snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
6242 sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
6243 _LOGE("Don't execute query = %s error message = %s\n", query,
6245 sqlite3_free(error_message);
6246 ret = PMINFO_R_ERROR;
6254 indexinfo->cert_id = maxid;
6255 indexinfo->cert_ref_count = 1;
6259 (info->cert_id)[i] = indexinfo->cert_id;
6260 (info->is_new)[i] = is_new;
6261 (info->ref_count)[i] = indexinfo->cert_ref_count;
6262 _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
6263 indexinfo->cert_id = 0;
6264 indexinfo->cert_ref_count = 0;
6268 len = MAX_QUERY_LEN;
6269 for (i = 0; i < MAX_CERT_TYPE; i++) {
6270 if ((info->cert_info)[i])
6271 len+= strlen((info->cert_info)[i]);
6273 vquery = (char *)calloc(1, len);
6275 snprintf(vquery, len,
6276 "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
6277 "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
6278 "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
6279 info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
6280 (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
6281 (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
6282 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
6283 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
6285 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6286 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6288 sqlite3_free(error_message);
6289 ret = PMINFO_R_ERROR;
6292 /*Update index table info*/
6293 /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
6294 for (i = 0; i < MAX_CERT_TYPE; i++) {
6295 if ((info->cert_info)[i]) {
6296 memset(vquery, '\0', len);
6297 if ((info->is_new)[i]) {
6298 snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
6299 "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
6300 unique_id[c++] = (info->cert_id)[i];
6303 for (j = 0; j < MAX_CERT_TYPE; j++) {
6304 if ((info->cert_id)[i] == unique_id[j]) {
6305 /*Ref count has already been increased. Just continue*/
6309 if (j == MAX_CERT_TYPE)
6310 unique_id[c++] = (info->cert_id)[i];
6313 snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
6314 "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
6317 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6318 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6320 sqlite3_free(error_message);
6321 ret = PMINFO_R_ERROR;
6326 /*Commit transaction*/
6327 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6328 if (ret != SQLITE_OK) {
6329 _LOGE("Failed to commit transaction, Rollback now\n");
6330 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6331 ret = PMINFO_R_ERROR;
6334 _LOGE("Transaction Commit and End\n");
6337 sqlite3_close(cert_db);
6349 API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
6351 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6353 pkgmgr_instcertinfo_x *certinfo = NULL;
6354 certinfo = (pkgmgr_instcertinfo_x *)handle;
6355 if (certinfo->pkgid) {
6356 free(certinfo->pkgid);
6357 certinfo->pkgid = NULL;
6359 for (i = 0; i < MAX_CERT_TYPE; i++) {
6360 if ((certinfo->cert_info)[i]) {
6361 free((certinfo->cert_info)[i]);
6362 (certinfo->cert_info)[i] = NULL;
6370 API int pkgmgrinfo_delete_certinfo(const char *pkgid)
6372 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6375 ret = db_util_open_with_options(CERT_DB, &cert_db,
6376 SQLITE_OPEN_READWRITE, NULL);
6377 if (ret != SQLITE_OK) {
6378 _LOGE("connect db [%s] failed!\n", CERT_DB);
6379 ret = PMINFO_R_ERROR;
6382 /*Begin Transaction*/
6383 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6384 if (ret != SQLITE_OK) {
6385 _LOGE("Failed to begin transaction\n");
6386 ret = PMINFO_R_ERROR;
6389 _LOGE("Transaction Begin\n");
6390 ret = __delete_certinfo(pkgid);
6392 _LOGE("Certificate Deletion Failed\n");
6394 _LOGE("Certificate Deletion Success\n");
6396 /*Commit transaction*/
6397 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6398 if (ret != SQLITE_OK) {
6399 _LOGE("Failed to commit transaction, Rollback now\n");
6400 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6401 ret = PMINFO_R_ERROR;
6404 _LOGE("Transaction Commit and End\n");
6407 sqlite3_close(cert_db);
6411 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
6413 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
6414 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6416 char *manifest = NULL;
6417 manifest_x *mfx = NULL;
6419 manifest = pkgmgr_parser_get_manifest_file(pkgid);
6420 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
6422 mfx = pkgmgr_parser_process_manifest_xml(manifest);
6427 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
6429 *handle = (void *)mfx;
6434 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
6436 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
6437 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6439 int len = strlen(type);
6440 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6442 manifest_x *mfx = (manifest_x *)handle;
6444 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
6448 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
6450 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
6451 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6453 int len = strlen(version);
6454 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6456 manifest_x *mfx = (manifest_x *)handle;
6458 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
6462 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6464 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6465 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6467 manifest_x *mfx = (manifest_x *)handle;
6469 if (location == INSTALL_INTERNAL)
6470 strcpy(mfx->installlocation, "internal-only");
6471 else if (location == INSTALL_EXTERNAL)
6472 strcpy(mfx->installlocation, "prefer-external");
6477 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
6479 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6480 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6482 manifest_x *mfx = (manifest_x *)handle;
6484 mfx->package_size = strdup(size);
6489 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
6491 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6492 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6494 int len = strlen(label_txt);
6495 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6497 manifest_x *mfx = (manifest_x *)handle;
6499 label_x *label = calloc(1, sizeof(label_x));
6500 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6502 LISTADD(mfx->label, label);
6504 mfx->label->lang = strdup(locale);
6506 mfx->label->lang = strdup(DEFAULT_LOCALE);
6507 mfx->label->text = strdup(label_txt);
6512 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
6514 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6515 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6517 int len = strlen(icon_txt);
6518 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6520 manifest_x *mfx = (manifest_x *)handle;
6522 icon_x *icon = calloc(1, sizeof(icon_x));
6523 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6525 LISTADD(mfx->icon, icon);
6527 mfx->icon->lang = strdup(locale);
6529 mfx->icon->lang = strdup(DEFAULT_LOCALE);
6530 mfx->icon->text = strdup(icon_txt);
6535 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
6537 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6538 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6540 int len = strlen(desc_txt);
6541 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6543 manifest_x *mfx = (manifest_x *)handle;
6545 description_x *description = calloc(1, sizeof(description_x));
6546 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6548 LISTADD(mfx->description, description);
6550 mfx->description->lang = strdup(locale);
6552 mfx->description->lang = strdup(DEFAULT_LOCALE);
6553 mfx->description->text = strdup(desc_txt);
6558 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
6559 const char *author_email, const char *author_href, const char *locale)
6561 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6562 manifest_x *mfx = (manifest_x *)handle;
6563 author_x *author = calloc(1, sizeof(author_x));
6564 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6566 LISTADD(mfx->author, author);
6568 mfx->author->text = strdup(author_name);
6570 mfx->author->email = strdup(author_email);
6572 mfx->author->href = strdup(author_href);
6574 mfx->author->lang = strdup(locale);
6576 mfx->author->lang = strdup(DEFAULT_LOCALE);
6580 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
6582 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6583 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6585 manifest_x *mfx = (manifest_x *)handle;
6588 strcpy(mfx->removable, "false");
6589 else if (removable == 1)
6590 strcpy(mfx->removable, "true");
6595 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
6597 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6598 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6600 manifest_x *mfx = (manifest_x *)handle;
6603 strcpy(mfx->preload, "false");
6604 else if (preload == 1)
6605 strcpy(mfx->preload, "true");
6610 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6612 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6613 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6615 manifest_x *mfx = (manifest_x *)handle;
6617 if (location == INSTALL_INTERNAL)
6618 strcpy(mfx->installed_storage, "installed_internal");
6619 else if (location == INSTALL_EXTERNAL)
6620 strcpy(mfx->installed_storage, "installed_external");
6625 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6627 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6630 manifest_x *mfx = NULL;
6631 mfx = (manifest_x *)handle;
6633 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
6635 _LOGE("Successfully stored info in DB\n");
6638 _LOGE("Failed to store info in DB\n");
6639 return PMINFO_R_ERROR;
6643 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6645 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6647 manifest_x *mfx = NULL;
6648 mfx = (manifest_x *)handle;
6649 pkgmgr_parser_free_manifest_xml(mfx);
6653 API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
6655 /* Should be implemented later */
6659 API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
6661 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6663 char query[MAX_QUERY_LEN] = {'\0'};
6664 ret = __open_manifest_db();
6666 if (access(MANIFEST_DB, F_OK) == 0) {
6667 ret = db_util_open(MANIFEST_DB, &manifest_db,
6668 DB_UTIL_REGISTER_HOOK_METHOD);
6669 if (ret != SQLITE_OK) {
6670 _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
6671 return PMINFO_R_ERROR;
6675 /*Begin transaction*/
6676 ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6677 if (ret != SQLITE_OK) {
6678 _LOGE("Failed to begin transaction\n");
6679 sqlite3_close(manifest_db);
6680 return PMINFO_R_ERROR;
6682 _LOGD("Transaction Begin\n");
6684 memset(query, '\0', MAX_QUERY_LEN);
6685 snprintf(query, MAX_QUERY_LEN,
6686 "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
6688 char *error_message = NULL;
6690 sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
6691 _LOGE("Don't execute query = %s error message = %s\n", query,
6693 sqlite3_free(error_message);
6694 return PMINFO_R_ERROR;
6696 sqlite3_free(error_message);
6698 /*Commit transaction*/
6699 ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
6700 if (ret != SQLITE_OK) {
6701 _LOGE("Failed to commit transaction. Rollback now\n");
6702 sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
6703 sqlite3_close(manifest_db);
6704 return PMINFO_R_ERROR;
6706 _LOGD("Transaction Commit and End\n");
6707 sqlite3_close(manifest_db);
6713 API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
6715 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6716 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6717 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6718 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6719 int ret = PMINFO_R_OK;
6720 char query[MAX_QUERY_LEN] = {'\0'};
6721 char *error_message = NULL;
6722 pkgmgr_datacontrol_x *data = NULL;
6724 ret = __open_datacontrol_db();
6726 _LOGE("Fail to open datacontrol DB\n");
6727 return PMINFO_R_ERROR;
6730 data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x));
6732 _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
6733 sqlite3_close(datacontrol_db);
6734 return PMINFO_R_ERROR;
6737 snprintf(query, MAX_QUERY_LEN,
6738 "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",
6742 sqlite3_exec(datacontrol_db, query, __datacontrol_cb, (void *)data, &error_message)) {
6743 _LOGE("Don't execute query = %s error message = %s\n", query,
6745 sqlite3_free(error_message);
6746 sqlite3_close(datacontrol_db);
6747 return PMINFO_R_ERROR;
6750 *appid = (char *)data->appid;
6751 *access = (char *)data->access;
6753 sqlite3_close(datacontrol_db);
6758 API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
6760 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6762 char query[MAX_QUERY_LEN] = {'\0'};
6763 char *error_message = NULL;
6764 ret = __open_manifest_db();
6766 if (access(MANIFEST_DB, F_OK) == 0) {
6767 ret = db_util_open(MANIFEST_DB, &manifest_db,
6768 DB_UTIL_REGISTER_HOOK_METHOD);
6769 if (ret != SQLITE_OK) {
6770 _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
6771 return PMINFO_R_ERROR;
6775 /*Begin transaction*/
6776 ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6777 if (ret != SQLITE_OK) {
6778 _LOGE("Failed to begin transaction\n");
6779 sqlite3_close(manifest_db);
6780 return PMINFO_R_ERROR;
6782 _LOGD("Transaction Begin\n");
6784 memset(query, '\0', MAX_QUERY_LEN);
6785 snprintf(query, MAX_QUERY_LEN,
6786 "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid);
6789 sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
6790 _LOGE("Don't execute query = %s error message = %s\n", query,
6792 sqlite3_free(error_message);
6793 return PMINFO_R_ERROR;
6796 /*Commit transaction*/
6797 ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
6798 if (ret != SQLITE_OK) {
6799 _LOGE("Failed to commit transaction. Rollback now\n");
6800 sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
6801 sqlite3_close(manifest_db);
6802 return PMINFO_R_ERROR;
6804 _LOGD("Transaction Commit and End\n");
6805 sqlite3_close(manifest_db);
6810 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
6812 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6813 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6815 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6816 val = (char *)info->uiapp_info->guestmode_visibility;
6818 if (strcasecmp(val, "true") == 0){
6820 }else if (strcasecmp(val, "false") == 0){
6829 API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
6831 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6834 char *noti_string = NULL;
6836 char query[MAX_QUERY_LEN] = {'\0'};
6837 char *errmsg = NULL;
6838 sqlite3 *pkgmgr_parser_db;
6840 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6841 val = (char *)info->uiapp_info->guestmode_visibility;
6844 db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db,
6845 SQLITE_OPEN_READWRITE, NULL);
6847 if (ret != SQLITE_OK) {
6848 _LOGE("DB Open Failed\n");
6849 return PMINFO_R_ERROR;
6852 /*TODO: Write to DB here*/
6854 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
6856 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
6858 if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
6859 _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
6861 sqlite3_close(pkgmgr_parser_db);
6862 return PMINFO_R_ERROR;
6864 sqlite3_close(pkgmgr_parser_db);
6865 len = strlen((char *)info->uiapp_info->appid) + 8;
6866 noti_string = calloc(1, len);
6867 if (noti_string == NULL){
6868 return PMINFO_R_ERROR;
6870 snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
6871 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
6872 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed