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_SCREENREADER:
372 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_screenreader='%s'", node->value);
374 case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
375 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
378 _LOGE("Invalid Property Type\n");
382 *condition = strdup(buf);
386 static char* __convert_system_locale_to_manifest_locale(char *syslocale)
388 if (syslocale == NULL)
389 return strdup(DEFAULT_LOCALE);
391 locale = (char *)calloc(1, 6);
392 retvm_if(!locale, NULL, "Malloc Failed\n");
394 strncpy(locale, syslocale, 2);
395 strncat(locale, "-", 1);
396 locale[3] = syslocale[3] + 32;
397 locale[4] = syslocale[4] + 32;
401 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
403 ret_if(data == NULL);
405 free((void *)data->locale);
409 pkgmgr_parser_free_manifest_xml(data->manifest_info);
415 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
417 ret_if(data == NULL);
419 free((void *)data->package);
420 data->package = NULL;
423 free((void *)data->locale);
427 manifest_x *mfx = calloc(1, sizeof(manifest_x));
428 if (data->app_component == PMINFO_UI_APP)
429 mfx->uiapplication = data->uiapp_info;
430 else if (data->app_component == PMINFO_SVC_APP)
431 mfx->serviceapplication = data->svcapp_info;
432 pkgmgr_parser_free_manifest_xml(mfx);
438 static int __open_manifest_db()
441 if (access(MANIFEST_DB, F_OK) == 0) {
443 db_util_open_with_options(MANIFEST_DB, &manifest_db,
444 SQLITE_OPEN_READONLY, NULL);
445 retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", MANIFEST_DB);
448 _LOGE("Manifest DB does not exists !!\n");
452 static int __open_datacontrol_db()
455 if (access(DATACONTROL_DB, F_OK) == 0) {
457 db_util_open_with_options(DATACONTROL_DB, &datacontrol_db,
458 SQLITE_OPEN_READONLY, NULL);
459 retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", DATACONTROL_DB);
462 _LOGE("Datacontrol DB does not exists !!\n");
466 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
468 pkgmgr_pkginfo_x *udata = (pkgmgr_pkginfo_x *)data;
470 pkgmgr_pkginfo_x *info = NULL;
471 info = calloc(1, sizeof(pkgmgr_pkginfo_x));
472 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
474 LISTADD(udata, info);
475 for(i = 0; i < ncols; i++)
477 if (strcmp(colname[i], "package") == 0) {
479 info->manifest_info->package = strdup(coltxt[i]);
481 info->manifest_info->package = NULL;
489 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname)
491 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
494 uiapplication_x *uiapp = NULL;
495 serviceapplication_x *svcapp = NULL;
496 for(i = 0; i < ncols; i++)
498 if ((strcmp(colname[i], "app_component") == 0) ||
499 (strcmp(colname[i], "package_app_info.app_component") == 0)) {
501 if (strcmp(coltxt[i], "uiapp") == 0) {
502 uiapp = calloc(1, sizeof(uiapplication_x));
504 _LOGE("Out of Memory!!!\n");
507 LISTADD(info->manifest_info->uiapplication, uiapp);
508 for(j = 0; j < ncols; j++)
510 if ((strcmp(colname[j], "app_id") == 0) ||
511 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
513 info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
514 } else if (strcmp(colname[j], "package") == 0) {
516 info->manifest_info->uiapplication->package = strdup(coltxt[j]);
521 svcapp = calloc(1, sizeof(serviceapplication_x));
522 if (svcapp == NULL) {
523 _LOGE("Out of Memory!!!\n");
526 LISTADD(info->manifest_info->serviceapplication, svcapp);
527 for(j = 0; j < ncols; j++)
529 if ((strcmp(colname[j], "app_id") == 0) ||
530 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
532 info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
533 } else if (strcmp(colname[j], "package") == 0) {
535 info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
549 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
551 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
553 uiapplication_x *uiapp = NULL;
555 label_x *label = NULL;
557 uiapp = calloc(1, sizeof(uiapplication_x));
558 LISTADD(info->manifest_info->uiapplication, uiapp);
559 icon = calloc(1, sizeof(icon_x));
560 LISTADD(info->manifest_info->uiapplication->icon, icon);
561 label = calloc(1, sizeof(label_x));
562 LISTADD(info->manifest_info->uiapplication->label, label);
564 for(i = 0; i < ncols; i++)
566 if (strcmp(colname[i], "app_id") == 0) {
568 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
570 info->manifest_info->uiapplication->appid = NULL;
571 } else if (strcmp(colname[i], "app_exec") == 0) {
573 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
575 info->manifest_info->uiapplication->exec = NULL;
576 } else if (strcmp(colname[i], "app_type") == 0 ){
578 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
580 info->manifest_info->uiapplication->type = NULL;
581 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
583 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
585 info->manifest_info->uiapplication->nodisplay = NULL;
586 } else if (strcmp(colname[i], "app_multiple") == 0 ){
588 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
590 info->manifest_info->uiapplication->multiple = NULL;
591 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
593 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
595 info->manifest_info->uiapplication->taskmanage = NULL;
596 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
598 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
600 info->manifest_info->uiapplication->hwacceleration = NULL;
601 } else if (strcmp(colname[i], "app_screenreader") == 0 ){
603 info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
605 info->manifest_info->uiapplication->screenreader = NULL;
606 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
608 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
610 info->manifest_info->uiapplication->indicatordisplay = NULL;
611 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
613 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
615 info->manifest_info->uiapplication->portraitimg = NULL;
616 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
618 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
620 info->manifest_info->uiapplication->landscapeimg = NULL;
621 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
623 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
625 info->manifest_info->uiapplication->guestmode_visibility = NULL;
626 } else if (strcmp(colname[i], "package") == 0 ){
628 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
630 info->manifest_info->uiapplication->package = NULL;
631 } else if (strcmp(colname[i], "app_icon") == 0) {
633 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
635 info->manifest_info->uiapplication->icon->text = NULL;
636 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
638 info->manifest_info->uiapplication->enabled= strdup(coltxt[i]);
640 info->manifest_info->uiapplication->enabled = NULL;
641 } else if (strcmp(colname[i], "app_label") == 0 ) {
643 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
645 info->manifest_info->uiapplication->label->text = NULL;
646 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
648 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
650 info->manifest_info->uiapplication->recentimage = NULL;
651 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
653 info->manifest_info->uiapplication->mainapp = strdup(coltxt[i]);
655 info->manifest_info->uiapplication->mainapp = NULL;
656 } else if (strcmp(colname[i], "app_locale") == 0 ) {
658 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
659 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
662 info->manifest_info->uiapplication->icon->lang = NULL;
663 info->manifest_info->uiapplication->label->lang = NULL;
665 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
667 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
669 info->manifest_info->uiapplication->permission_type = NULL;
670 } else if (strcmp(colname[i], "component_type") == 0 ) {
672 info->manifest_info->uiapplication->component_type = strdup(coltxt[i]);
674 info->manifest_info->uiapplication->component_type = NULL;
675 } else if (strcmp(colname[i], "app_preload") == 0 ) {
677 info->manifest_info->uiapplication->preload = strdup(coltxt[i]);
679 info->manifest_info->uiapplication->preload = NULL;
680 } else if (strcmp(colname[i], "app_submode") == 0 ) {
682 info->manifest_info->uiapplication->submode = strdup(coltxt[i]);
684 info->manifest_info->uiapplication->submode = NULL;
685 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
687 info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[i]);
689 info->manifest_info->uiapplication->submode_mainid = NULL;
696 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
698 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
700 serviceapplication_x *svcapp = NULL;
702 label_x *label = NULL;
704 svcapp = calloc(1, sizeof(serviceapplication_x));
705 LISTADD(info->manifest_info->serviceapplication, svcapp);
706 icon = calloc(1, sizeof(icon_x));
707 LISTADD(info->manifest_info->serviceapplication->icon, icon);
708 label = calloc(1, sizeof(label_x));
709 LISTADD(info->manifest_info->serviceapplication->label, label);
710 for(i = 0; i < ncols; i++)
712 if (strcmp(colname[i], "app_id") == 0) {
714 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
716 info->manifest_info->serviceapplication->appid = NULL;
717 } else if (strcmp(colname[i], "app_exec") == 0) {
719 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
721 info->manifest_info->serviceapplication->exec = NULL;
722 } else if (strcmp(colname[i], "app_type") == 0 ){
724 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
726 info->manifest_info->serviceapplication->type = NULL;
727 } else if (strcmp(colname[i], "app_onboot") == 0 ){
729 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
731 info->manifest_info->serviceapplication->onboot = NULL;
732 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
734 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
736 info->manifest_info->serviceapplication->autorestart = NULL;
737 } else if (strcmp(colname[i], "package") == 0 ){
739 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
741 info->manifest_info->serviceapplication->package = NULL;
742 } else if (strcmp(colname[i], "app_icon") == 0) {
744 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
746 info->manifest_info->serviceapplication->icon->text = NULL;
747 } else if (strcmp(colname[i], "app_label") == 0 ) {
749 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
751 info->manifest_info->serviceapplication->label->text = NULL;
752 } else if (strcmp(colname[i], "app_locale") == 0 ) {
754 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
755 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
758 info->manifest_info->serviceapplication->icon->lang = NULL;
759 info->manifest_info->serviceapplication->label->lang = NULL;
761 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
763 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
765 info->manifest_info->serviceapplication->permission_type = NULL;
772 static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
774 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
777 uiapplication_x *uiapp = NULL;
778 serviceapplication_x *svcapp = NULL;
779 for(j = 0; j < ncols; j++)
781 if (strcmp(colname[j], "app_component") == 0) {
783 if (strcmp(coltxt[j], "uiapp") == 0) {
784 uiapp = calloc(1, sizeof(uiapplication_x));
786 _LOGE("Out of Memory!!!\n");
789 LISTADD(info->manifest_info->uiapplication, uiapp);
790 for(i = 0; i < ncols; i++)
792 if (strcmp(colname[i], "app_id") == 0) {
794 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
796 info->manifest_info->uiapplication->appid = NULL;
797 } else if (strcmp(colname[i], "app_exec") == 0) {
799 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
801 info->manifest_info->uiapplication->exec = NULL;
802 } else if (strcmp(colname[i], "app_type") == 0 ){
804 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
806 info->manifest_info->uiapplication->type = NULL;
807 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
809 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
811 info->manifest_info->uiapplication->nodisplay = NULL;
812 } else if (strcmp(colname[i], "app_multiple") == 0 ){
814 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
816 info->manifest_info->uiapplication->multiple = NULL;
817 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
819 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
821 info->manifest_info->uiapplication->taskmanage = NULL;
822 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
824 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
826 info->manifest_info->uiapplication->hwacceleration = NULL;
827 } else if (strcmp(colname[i], "app_screenreader") == 0 ){
829 info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
831 info->manifest_info->uiapplication->screenreader = NULL;
832 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
834 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
836 info->manifest_info->uiapplication->indicatordisplay = NULL;
837 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
839 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
841 info->manifest_info->uiapplication->portraitimg = NULL;
842 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
844 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
846 info->manifest_info->uiapplication->landscapeimg = NULL;
847 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
849 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
851 info->manifest_info->uiapplication->guestmode_visibility = NULL;
852 } else if (strcmp(colname[i], "package") == 0 ){
854 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
856 info->manifest_info->uiapplication->package = NULL;
857 } else if (strcmp(colname[i], "app_icon") == 0) {
859 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
861 info->manifest_info->uiapplication->icon->text = NULL;
862 } else if (strcmp(colname[i], "app_label") == 0 ) {
864 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
866 info->manifest_info->uiapplication->label->text = NULL;
867 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
869 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
871 info->manifest_info->uiapplication->recentimage = NULL;
872 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
874 info->manifest_info->uiapplication->mainapp= strdup(coltxt[i]);
876 info->manifest_info->uiapplication->mainapp = NULL;
877 } else if (strcmp(colname[i], "app_locale") == 0 ) {
879 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
880 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
883 info->manifest_info->uiapplication->icon->lang = NULL;
884 info->manifest_info->uiapplication->label->lang = NULL;
886 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
888 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
890 info->manifest_info->uiapplication->permission_type = NULL;
895 svcapp = calloc(1, sizeof(serviceapplication_x));
896 if (svcapp == NULL) {
897 _LOGE("Out of Memory!!!\n");
900 LISTADD(info->manifest_info->serviceapplication, svcapp);
901 for(i = 0; i < ncols; i++)
903 if (strcmp(colname[i], "app_id") == 0) {
905 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
907 info->manifest_info->serviceapplication->appid = NULL;
908 } else if (strcmp(colname[i], "app_exec") == 0) {
910 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
912 info->manifest_info->serviceapplication->exec = NULL;
913 } else if (strcmp(colname[i], "app_type") == 0 ){
915 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
917 info->manifest_info->serviceapplication->type = NULL;
918 } else if (strcmp(colname[i], "app_onboot") == 0 ){
920 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
922 info->manifest_info->serviceapplication->onboot = NULL;
923 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
925 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
927 info->manifest_info->serviceapplication->autorestart = NULL;
928 } else if (strcmp(colname[i], "package") == 0 ){
930 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
932 info->manifest_info->serviceapplication->package = NULL;
933 } else if (strcmp(colname[i], "app_icon") == 0) {
935 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
937 info->manifest_info->serviceapplication->icon->text = NULL;
938 } else if (strcmp(colname[i], "app_label") == 0 ) {
940 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
942 info->manifest_info->serviceapplication->label->text = NULL;
943 } else if (strcmp(colname[i], "app_locale") == 0 ) {
945 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
946 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
949 info->manifest_info->serviceapplication->icon->lang = NULL;
950 info->manifest_info->serviceapplication->label->lang = NULL;
952 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
954 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
956 info->manifest_info->serviceapplication->permission_type = NULL;
971 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname)
974 *p = atoi(coltxt[0]);
978 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname)
982 *p = atoi(coltxt[0]);
986 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
988 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
990 author_x *author = NULL;
992 label_x *label = NULL;
993 description_x *description = NULL;
994 privilege_x *privilege = NULL;
996 author = calloc(1, sizeof(author_x));
997 LISTADD(info->manifest_info->author, author);
998 icon = calloc(1, sizeof(icon_x));
999 LISTADD(info->manifest_info->icon, icon);
1000 label = calloc(1, sizeof(label_x));
1001 LISTADD(info->manifest_info->label, label);
1002 description = calloc(1, sizeof(description_x));
1003 LISTADD(info->manifest_info->description, description);
1004 privilege = calloc(1, sizeof(privilege_x));
1005 LISTADD(info->manifest_info->privileges->privilege, privilege);
1006 for(i = 0; i < ncols; i++)
1008 if (strcmp(colname[i], "package_version") == 0) {
1010 info->manifest_info->version = strdup(coltxt[i]);
1012 info->manifest_info->version = NULL;
1013 } else if (strcmp(colname[i], "package_type") == 0) {
1015 info->manifest_info->type = strdup(coltxt[i]);
1017 info->manifest_info->type = NULL;
1018 } else if (strcmp(colname[i], "install_location") == 0) {
1020 info->manifest_info->installlocation = strdup(coltxt[i]);
1022 info->manifest_info->installlocation = NULL;
1023 } else if (strcmp(colname[i], "package_size") == 0) {
1025 info->manifest_info->package_size = strdup(coltxt[i]);
1027 info->manifest_info->package_size = NULL;
1028 } else if (strcmp(colname[i], "author_email") == 0 ){
1030 info->manifest_info->author->email = strdup(coltxt[i]);
1032 info->manifest_info->author->email = NULL;
1033 } else if (strcmp(colname[i], "author_href") == 0 ){
1035 info->manifest_info->author->href = strdup(coltxt[i]);
1037 info->manifest_info->author->href = NULL;
1038 } else if (strcmp(colname[i], "package_label") == 0 ){
1040 info->manifest_info->label->text = strdup(coltxt[i]);
1042 info->manifest_info->label->text = NULL;
1043 } else if (strcmp(colname[i], "package_icon") == 0 ){
1045 info->manifest_info->icon->text = strdup(coltxt[i]);
1047 info->manifest_info->icon->text = NULL;
1048 } else if (strcmp(colname[i], "package_description") == 0 ){
1050 info->manifest_info->description->text = strdup(coltxt[i]);
1052 info->manifest_info->description->text = NULL;
1053 } else if (strcmp(colname[i], "package_author") == 0 ){
1055 info->manifest_info->author->text = strdup(coltxt[i]);
1057 info->manifest_info->author->text = NULL;
1058 } else if (strcmp(colname[i], "package_removable") == 0 ){
1060 info->manifest_info->removable = strdup(coltxt[i]);
1062 info->manifest_info->removable = NULL;
1063 } else if (strcmp(colname[i], "package_preload") == 0 ){
1065 info->manifest_info->preload = strdup(coltxt[i]);
1067 info->manifest_info->preload = NULL;
1068 } else if (strcmp(colname[i], "package_readonly") == 0 ){
1070 info->manifest_info->readonly = strdup(coltxt[i]);
1072 info->manifest_info->readonly = NULL;
1073 } else if (strcmp(colname[i], "package_update") == 0 ){
1075 info->manifest_info->update= strdup(coltxt[i]);
1077 info->manifest_info->update = NULL;
1078 } else if (strcmp(colname[i], "package_appsetting") == 0 ){
1080 info->manifest_info->appsetting = strdup(coltxt[i]);
1082 info->manifest_info->appsetting = NULL;
1083 } else if (strcmp(colname[i], "installed_time") == 0 ){
1085 info->manifest_info->installed_time = strdup(coltxt[i]);
1087 info->manifest_info->installed_time = NULL;
1088 } else if (strcmp(colname[i], "installed_storage") == 0 ){
1090 info->manifest_info->installed_storage = strdup(coltxt[i]);
1092 info->manifest_info->installed_storage = NULL;
1093 } else if (strcmp(colname[i], "mainapp_id") == 0 ){
1095 info->manifest_info->mainapp_id = strdup(coltxt[i]);
1097 info->manifest_info->mainapp_id = NULL;
1098 } else if (strcmp(colname[i], "root_path") == 0 ){
1100 info->manifest_info->root_path = strdup(coltxt[i]);
1102 info->manifest_info->root_path = NULL;
1103 } else if (strcmp(colname[i], "csc_path") == 0 ){
1105 info->manifest_info->csc_path = strdup(coltxt[i]);
1107 info->manifest_info->csc_path = NULL;
1108 } else if (strcmp(colname[i], "privilege") == 0 ){
1110 info->manifest_info->privileges->privilege->text = strdup(coltxt[i]);
1112 info->manifest_info->privileges->privilege->text = NULL;
1113 } else if (strcmp(colname[i], "package_locale") == 0 ){
1115 info->manifest_info->author->lang = strdup(coltxt[i]);
1116 info->manifest_info->icon->lang = strdup(coltxt[i]);
1117 info->manifest_info->label->lang = strdup(coltxt[i]);
1118 info->manifest_info->description->lang = strdup(coltxt[i]);
1121 info->manifest_info->author->lang = NULL;
1122 info->manifest_info->icon->lang = NULL;
1123 info->manifest_info->label->lang = NULL;
1124 info->manifest_info->description->lang = NULL;
1126 } else if (strcmp(colname[i], "package_url") == 0 ){
1128 info->manifest_info->package_url = strdup(coltxt[i]);
1130 info->manifest_info->package_url = NULL;
1138 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1140 if ( strcasecmp(comp, "uiapp") == 0)
1141 return PMINFO_UI_APP;
1142 else if ( strcasecmp(comp, "svcapp") == 0)
1143 return PMINFO_SVC_APP;
1148 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1150 pkgmgr_certindexinfo_x *info = (pkgmgr_certindexinfo_x *)data;
1152 for(i = 0; i < ncols; i++) {
1153 if (strcmp(colname[i], "cert_id") == 0) {
1155 info->cert_id = atoi(coltxt[i]);
1158 } else if (strcmp(colname[i], "cert_ref_count") == 0) {
1160 info->cert_ref_count = atoi(coltxt[i]);
1162 info->cert_ref_count = 0;
1168 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1170 pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)data;
1172 for(i = 0; i < ncols; i++)
1174 if (strcmp(colname[i], "package") == 0) {
1176 info->pkgid = strdup(coltxt[i]);
1179 } else if (strcmp(colname[i], "author_signer_cert") == 0) {
1181 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = atoi(coltxt[i]);
1183 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = 0;
1184 } else if (strcmp(colname[i], "author_im_cert") == 0) {
1186 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1188 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 0;
1189 } else if (strcmp(colname[i], "author_root_cert") == 0) {
1191 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = atoi(coltxt[i]);
1193 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = 0;
1194 } else if (strcmp(colname[i], "dist_signer_cert") == 0 ){
1196 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = atoi(coltxt[i]);
1198 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 0;
1199 } else if (strcmp(colname[i], "dist_im_cert") == 0 ){
1201 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1203 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 0;
1204 } else if (strcmp(colname[i], "dist_root_cert") == 0 ){
1206 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = atoi(coltxt[i]);
1208 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = 0;
1209 } else if (strcmp(colname[i], "dist2_signer_cert") == 0 ){
1211 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = atoi(coltxt[i]);
1213 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 0;
1214 } else if (strcmp(colname[i], "dist2_im_cert") == 0 ){
1216 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1218 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 0;
1219 } else if (strcmp(colname[i], "dist2_root_cert") == 0 ){
1221 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = atoi(coltxt[i]);
1223 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 0;
1224 } else if (strcmp(colname[i], "cert_info") == 0 ){
1226 info->cert_value = strdup(coltxt[i]);
1228 info->cert_value = NULL;
1235 static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1237 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1239 uiapplication_x *uiapp = NULL;
1240 uiapp = calloc(1, sizeof(uiapplication_x));
1241 if (uiapp == NULL) {
1242 _LOGE("Out of Memory!!!\n");
1246 LISTADD(info->uiapp_info, uiapp);
1248 for(i = 0; i < ncols; i++)
1250 if (strcmp(colname[i], "app_id") == 0) {
1251 /*appid being foreign key, is column in every table
1252 Hence appid gets strduped every time leading to memory leak.
1253 If appid is already set, just continue.*/
1254 if (info->uiapp_info->appid)
1257 info->uiapp_info->appid = strdup(coltxt[i]);
1259 info->uiapp_info->appid = NULL;
1260 } else if (strcmp(colname[i], "app_exec") == 0) {
1262 info->uiapp_info->exec = strdup(coltxt[i]);
1264 info->uiapp_info->exec = NULL;
1265 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1267 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1269 info->uiapp_info->nodisplay = NULL;
1270 } else if (strcmp(colname[i], "app_type") == 0 ) {
1272 info->uiapp_info->type = strdup(coltxt[i]);
1274 info->uiapp_info->type = NULL;
1275 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1277 info->uiapp_info->multiple = strdup(coltxt[i]);
1279 info->uiapp_info->multiple = NULL;
1280 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1282 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1284 info->uiapp_info->taskmanage = NULL;
1285 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1287 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1289 info->uiapp_info->hwacceleration = NULL;
1290 } else if (strcmp(colname[i], "app_screenreader") == 0 ) {
1292 info->uiapp_info->screenreader = strdup(coltxt[i]);
1294 info->uiapp_info->screenreader = NULL;
1295 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1297 info->uiapp_info->enabled= strdup(coltxt[i]);
1299 info->uiapp_info->enabled = NULL;
1300 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1302 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1304 info->uiapp_info->indicatordisplay = NULL;
1305 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1307 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1309 info->uiapp_info->portraitimg = NULL;
1310 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1312 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1314 info->uiapp_info->landscapeimg = NULL;
1315 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1317 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1319 info->uiapp_info->guestmode_visibility = NULL;
1320 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1322 info->uiapp_info->recentimage = strdup(coltxt[i]);
1324 info->uiapp_info->recentimage = NULL;
1325 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1327 info->uiapp_info->mainapp = strdup(coltxt[i]);
1329 info->uiapp_info->mainapp = NULL;
1330 } else if (strcmp(colname[i], "package") == 0 ) {
1332 info->uiapp_info->package = strdup(coltxt[i]);
1334 info->uiapp_info->package = NULL;
1335 } else if (strcmp(colname[i], "app_component") == 0) {
1337 info->uiapp_info->app_component = strdup(coltxt[i]);
1339 info->uiapp_info->app_component = NULL;
1340 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1342 info->uiapp_info->permission_type = strdup(coltxt[i]);
1344 info->uiapp_info->permission_type = NULL;
1345 } else if (strcmp(colname[i], "component_type") == 0 ) {
1347 info->uiapp_info->component_type = strdup(coltxt[i]);
1349 info->uiapp_info->component_type = NULL;
1350 } else if (strcmp(colname[i], "app_preload") == 0 ) {
1352 info->uiapp_info->preload = strdup(coltxt[i]);
1354 info->uiapp_info->preload = NULL;
1355 } else if (strcmp(colname[i], "app_submode") == 0 ) {
1357 info->uiapp_info->submode = strdup(coltxt[i]);
1359 info->uiapp_info->submode = NULL;
1360 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
1362 info->uiapp_info->submode_mainid = strdup(coltxt[i]);
1364 info->uiapp_info->submode_mainid = NULL;
1372 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1374 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1376 icon_x *icon = NULL;
1377 label_x *label = NULL;
1378 category_x *category = NULL;
1379 metadata_x *metadata = NULL;
1380 permission_x *permission = NULL;
1381 image_x *image = NULL;
1383 switch (info->app_component) {
1385 icon = calloc(1, sizeof(icon_x));
1386 LISTADD(info->uiapp_info->icon, icon);
1387 label = calloc(1, sizeof(label_x));
1388 LISTADD(info->uiapp_info->label, label);
1389 category = calloc(1, sizeof(category_x));
1390 LISTADD(info->uiapp_info->category, category);
1391 metadata = calloc(1, sizeof(metadata_x));
1392 LISTADD(info->uiapp_info->metadata, metadata);
1393 permission = calloc(1, sizeof(permission_x));
1394 LISTADD(info->uiapp_info->permission, permission);
1395 image = calloc(1, sizeof(image_x));
1396 LISTADD(info->uiapp_info->image, image);
1398 for(i = 0; i < ncols; i++)
1400 if (strcmp(colname[i], "app_id") == 0) {
1401 /*appid being foreign key, is column in every table
1402 Hence appid gets strduped every time leading to memory leak.
1403 If appid is already set, just continue.*/
1404 if (info->uiapp_info->appid)
1407 info->uiapp_info->appid = strdup(coltxt[i]);
1409 info->uiapp_info->appid = NULL;
1410 } else if (strcmp(colname[i], "app_exec") == 0) {
1412 info->uiapp_info->exec = strdup(coltxt[i]);
1414 info->uiapp_info->exec = NULL;
1415 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1417 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1419 info->uiapp_info->nodisplay = NULL;
1420 } else if (strcmp(colname[i], "app_type") == 0 ) {
1422 info->uiapp_info->type = strdup(coltxt[i]);
1424 info->uiapp_info->type = NULL;
1425 } else if (strcmp(colname[i], "app_icon_section") == 0 ) {
1427 info->uiapp_info->icon->section= strdup(coltxt[i]);
1429 info->uiapp_info->icon->section = NULL;
1430 } else if (strcmp(colname[i], "app_icon") == 0) {
1432 info->uiapp_info->icon->text = strdup(coltxt[i]);
1434 info->uiapp_info->icon->text = NULL;
1435 } else if (strcmp(colname[i], "app_label") == 0 ) {
1437 info->uiapp_info->label->text = strdup(coltxt[i]);
1439 info->uiapp_info->label->text = NULL;
1440 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1442 info->uiapp_info->multiple = strdup(coltxt[i]);
1444 info->uiapp_info->multiple = NULL;
1445 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1447 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1449 info->uiapp_info->taskmanage = NULL;
1450 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1452 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1454 info->uiapp_info->hwacceleration = NULL;
1455 } else if (strcmp(colname[i], "app_screenreader") == 0 ) {
1457 info->uiapp_info->screenreader = strdup(coltxt[i]);
1459 info->uiapp_info->screenreader = NULL;
1460 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1462 info->uiapp_info->enabled= strdup(coltxt[i]);
1464 info->uiapp_info->enabled = NULL;
1465 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1467 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1469 info->uiapp_info->indicatordisplay = NULL;
1470 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1472 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1474 info->uiapp_info->portraitimg = NULL;
1475 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1477 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1479 info->uiapp_info->landscapeimg = NULL;
1480 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1482 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1484 info->uiapp_info->guestmode_visibility = NULL;
1485 } else if (strcmp(colname[i], "category") == 0 ) {
1487 info->uiapp_info->category->name = strdup(coltxt[i]);
1489 info->uiapp_info->category->name = NULL;
1490 } else if (strcmp(colname[i], "md_key") == 0 ) {
1492 info->uiapp_info->metadata->key = strdup(coltxt[i]);
1494 info->uiapp_info->metadata->key = NULL;
1495 } else if (strcmp(colname[i], "md_value") == 0 ) {
1497 info->uiapp_info->metadata->value = strdup(coltxt[i]);
1499 info->uiapp_info->metadata->value = NULL;
1500 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1502 info->uiapp_info->permission->type= strdup(coltxt[i]);
1504 info->uiapp_info->permission->type = NULL;
1505 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1507 info->uiapp_info->permission->value = strdup(coltxt[i]);
1509 info->uiapp_info->permission->value = NULL;
1510 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1512 info->uiapp_info->recentimage = strdup(coltxt[i]);
1514 info->uiapp_info->recentimage = NULL;
1515 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1517 info->uiapp_info->mainapp = strdup(coltxt[i]);
1519 info->uiapp_info->mainapp = NULL;
1520 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1522 info->uiapp_info->icon->lang = strdup(coltxt[i]);
1523 info->uiapp_info->label->lang = strdup(coltxt[i]);
1526 info->uiapp_info->icon->lang = NULL;
1527 info->uiapp_info->label->lang = NULL;
1529 } else if (strcmp(colname[i], "app_image") == 0) {
1531 info->uiapp_info->image->text= strdup(coltxt[i]);
1533 info->uiapp_info->image->text = NULL;
1534 } else if (strcmp(colname[i], "app_image_section") == 0) {
1536 info->uiapp_info->image->section= strdup(coltxt[i]);
1538 info->uiapp_info->image->section = NULL;
1539 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1541 info->uiapp_info->permission_type = strdup(coltxt[i]);
1543 info->uiapp_info->permission_type = NULL;
1544 } else if (strcmp(colname[i], "component_type") == 0 ) {
1546 info->uiapp_info->component_type = strdup(coltxt[i]);
1548 info->uiapp_info->component_type = NULL;
1549 } else if (strcmp(colname[i], "app_preload") == 0 ) {
1551 info->uiapp_info->preload = strdup(coltxt[i]);
1553 info->uiapp_info->preload = NULL;
1554 } else if (strcmp(colname[i], "app_submode") == 0 ) {
1556 info->uiapp_info->submode = strdup(coltxt[i]);
1558 info->uiapp_info->submode = NULL;
1559 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
1561 info->uiapp_info->submode_mainid = strdup(coltxt[i]);
1563 info->uiapp_info->submode_mainid = NULL;
1568 case PMINFO_SVC_APP:
1569 icon = calloc(1, sizeof(icon_x));
1570 LISTADD(info->svcapp_info->icon, icon);
1571 label = calloc(1, sizeof(label_x));
1572 LISTADD(info->svcapp_info->label, label);
1573 category = calloc(1, sizeof(category_x));
1574 LISTADD(info->svcapp_info->category, category);
1575 metadata = calloc(1, sizeof(metadata_x));
1576 LISTADD(info->svcapp_info->metadata, metadata);
1577 permission = calloc(1, sizeof(permission_x));
1578 LISTADD(info->svcapp_info->permission, permission);
1579 for(i = 0; i < ncols; i++)
1581 if (strcmp(colname[i], "app_id") == 0) {
1582 /*appid being foreign key, is column in every table
1583 Hence appid gets strduped every time leading to memory leak.
1584 If appid is already set, just continue.*/
1585 if (info->svcapp_info->appid)
1588 info->svcapp_info->appid = strdup(coltxt[i]);
1590 info->svcapp_info->appid = NULL;
1591 } else if (strcmp(colname[i], "app_exec") == 0) {
1593 info->svcapp_info->exec = strdup(coltxt[i]);
1595 info->svcapp_info->exec = NULL;
1596 } else if (strcmp(colname[i], "app_icon") == 0) {
1598 info->svcapp_info->icon->text = strdup(coltxt[i]);
1600 info->svcapp_info->icon->text = NULL;
1601 } else if (strcmp(colname[i], "app_label") == 0 ) {
1603 info->svcapp_info->label->text = strdup(coltxt[i]);
1605 info->svcapp_info->label->text = NULL;
1606 } else if (strcmp(colname[i], "app_type") == 0 ) {
1608 info->svcapp_info->type = strdup(coltxt[i]);
1610 info->svcapp_info->type = NULL;
1611 } else if (strcmp(colname[i], "app_onboot") == 0 ) {
1613 info->svcapp_info->onboot = strdup(coltxt[i]);
1615 info->svcapp_info->onboot = NULL;
1616 } else if (strcmp(colname[i], "app_autorestart") == 0 ) {
1618 info->svcapp_info->autorestart = strdup(coltxt[i]);
1620 info->svcapp_info->autorestart = NULL;
1621 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1623 info->svcapp_info->enabled= strdup(coltxt[i]);
1625 info->svcapp_info->enabled = NULL;
1626 } else if (strcmp(colname[i], "category") == 0 ) {
1628 info->svcapp_info->category->name = strdup(coltxt[i]);
1630 info->svcapp_info->category->name = NULL;
1631 } else if (strcmp(colname[i], "md_key") == 0 ) {
1633 info->svcapp_info->metadata->key = strdup(coltxt[i]);
1635 info->svcapp_info->metadata->key = NULL;
1636 } else if (strcmp(colname[i], "md_value") == 0 ) {
1638 info->svcapp_info->metadata->value = strdup(coltxt[i]);
1640 info->svcapp_info->metadata->value = NULL;
1641 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1643 info->svcapp_info->permission->type= strdup(coltxt[i]);
1645 info->svcapp_info->permission->type = NULL;
1646 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1648 info->svcapp_info->permission->value = strdup(coltxt[i]);
1650 info->svcapp_info->permission->value = NULL;
1651 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1653 info->svcapp_info->icon->lang = strdup(coltxt[i]);
1654 info->svcapp_info->label->lang = strdup(coltxt[i]);
1657 info->svcapp_info->icon->lang = NULL;
1658 info->svcapp_info->label->lang = NULL;
1660 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1662 info->svcapp_info->permission_type = strdup(coltxt[i]);
1664 info->svcapp_info->permission_type = NULL;
1677 static int __appcomponent_cb(void *data, int ncols, char **coltxt, char **colname)
1679 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1681 for(i = 0; i < ncols; i++)
1683 if (strcmp(colname[i], "app_component") == 0) {
1684 info->app_component = __appcomponent_convert(coltxt[i]);
1685 } else if (strcmp(colname[i], "package") == 0) {
1686 info->package = strdup(coltxt[i]);
1693 static int __datacontrol_cb(void *data, int ncols, char **coltxt, char **colname)
1695 pkgmgr_datacontrol_x *info = (pkgmgr_datacontrol_x *)data;
1697 for(i = 0; i < ncols; i++)
1699 if (strcmp(colname[i], "PACKAGE_NAME") == 0) {
1701 info->appid = strdup(coltxt[i]);
1704 } else if (strcmp(colname[i], "ACCESS") == 0 ){
1706 info->access = strdup(coltxt[i]);
1708 info->access = NULL;
1715 static int __cert_cb(void *data, int ncols, char **coltxt, char **colname)
1717 pkgmgr_cert_x *info = (pkgmgr_cert_x *)data;
1720 for(i = 0; i < ncols; i++)
1722 if (strcmp(colname[i], "author_signer_cert") == 0) {
1724 info->cert_id = atoi(coltxt[i]);
1727 } else if (strcmp(colname[i], "package") == 0) {
1729 info->pkgid= strdup(coltxt[i]);
1738 /* get the first locale value*/
1739 static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
1741 pkgmgr_locale_x *info = (pkgmgr_locale_x *)data;
1744 info->locale = strdup(coltxt[0]);
1746 info->locale = NULL;
1751 static int __exec_pkginfo_query(char *query, void *data)
1753 char *error_message = NULL;
1755 sqlite3_exec(manifest_db, query, __pkginfo_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_certinfo_query(char *query, void *data)
1767 char *error_message = NULL;
1769 sqlite3_exec(cert_db, query, __certinfo_cb, 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);
1779 static int __exec_certindexinfo_query(char *query, void *data)
1781 char *error_message = NULL;
1783 sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
1784 _LOGE("Don't execute query = %s error message = %s\n", query,
1786 sqlite3_free(error_message);
1789 sqlite3_free(error_message);
1793 static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data)
1795 char *error_message = NULL;
1797 sqlite3_exec(db, query, callback, data, &error_message)) {
1798 _LOGE("Don't execute query = %s error message = %s\n", query,
1800 sqlite3_free(error_message);
1803 sqlite3_free(error_message);
1808 static int __child_element(xmlTextReaderPtr reader, int depth)
1810 int ret = xmlTextReaderRead(reader);
1811 int cur = xmlTextReaderDepth(reader);
1814 switch (xmlTextReaderNodeType(reader)) {
1815 case XML_READER_TYPE_ELEMENT:
1816 if (cur == depth + 1)
1819 case XML_READER_TYPE_TEXT:
1820 /*text is handled by each function separately*/
1821 if (cur == depth + 1)
1824 case XML_READER_TYPE_END_ELEMENT:
1833 ret = xmlTextReaderRead(reader);
1834 cur = xmlTextReaderDepth(reader);
1839 static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, char **colname)
1841 int *p = (int*)data;
1842 *p = atoi(coltxt[0]);
1846 static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale)
1848 int result_query = -1;
1850 char query[MAX_QUERY_LEN];
1852 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);
1853 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1854 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1855 return result_query;
1858 static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1860 int result_query = -1;
1862 char wildcard[2] = {'%','\0'};
1863 char query[MAX_QUERY_LEN];
1864 char lang[3] = {'\0'};
1865 strncpy(lang, locale, LANGUAGE_LENGTH);
1867 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);
1868 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1869 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1870 return result_query;
1873 static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1876 char wildcard[2] = {'%','\0'};
1877 char lang[3] = {'\0'};
1878 char query[MAX_QUERY_LEN];
1879 char *locale_new = NULL;
1880 pkgmgr_locale_x *info = NULL;
1882 info = (pkgmgr_locale_x *)malloc(sizeof(pkgmgr_locale_x));
1884 _LOGE("Out of Memory!!!\n");
1887 memset(info, '\0', sizeof(*info));
1889 strncpy(lang, locale, 2);
1890 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);
1891 ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
1892 tryvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1893 locale_new = info->locale;
1904 static char* __convert_syslocale_to_manifest_locale(char *syslocale)
1906 char *locale = malloc(6);
1908 _LOGE("Malloc Failed\n");
1912 sprintf(locale, "%c%c-%c%c", syslocale[0], syslocale[1], tolower(syslocale[3]), tolower(syslocale[4]));
1916 static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const char *syslocale)
1921 char *locale = NULL;
1922 char *locale_new = NULL;
1923 int check_result = 0;
1925 locale = __convert_syslocale_to_manifest_locale((char *)syslocale);
1927 /*check exact matching */
1928 check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale);
1931 if (check_result == 1) {
1932 _LOGD("%s find exact locale(%s)\n", appid, locale);
1936 /* fallback matching */
1937 check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
1938 if(check_result == 1) {
1939 locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
1941 if (locale_new == NULL)
1942 locale_new = strdup(DEFAULT_LOCALE);
1946 /* default locale */
1948 return strdup(DEFAULT_LOCALE);
1951 long long _pkgmgr_calculate_dir_size(char *dirname)
1953 long long total = 0;
1955 int q = 0; /*quotient*/
1956 int r = 0; /*remainder*/
1958 struct dirent *ep = NULL;
1959 struct stat fileinfo;
1960 char abs_filename[FILENAME_MAX] = { 0, };
1961 retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL");
1963 dp = opendir(dirname);
1965 while ((ep = readdir(dp)) != NULL) {
1966 if (!strcmp(ep->d_name, ".") ||
1967 !strcmp(ep->d_name, "..")) {
1970 snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
1972 if (lstat(abs_filename, &fileinfo) < 0)
1973 perror(abs_filename);
1975 if (S_ISDIR(fileinfo.st_mode)) {
1976 total += fileinfo.st_size;
1977 if (strcmp(ep->d_name, ".")
1978 && strcmp(ep->d_name, "..")) {
1979 ret = _pkgmgr_calculate_dir_size
1981 total = total + ret;
1983 } else if (S_ISLNK(fileinfo.st_mode)) {
1986 /*It is a file. Calculate the actual
1987 size occupied (in terms of 4096 blocks)*/
1988 q = (fileinfo.st_size / BLOCK_SIZE);
1989 r = (fileinfo.st_size % BLOCK_SIZE);
1993 total += q * BLOCK_SIZE;
1999 _LOGE("Couldn't open the directory\n");
2006 static int __delete_certinfo(const char *pkgid)
2012 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
2013 char *error_message = NULL;
2014 char query[MAX_QUERY_LEN] = {'\0'};
2015 pkgmgr_certinfo_x *certinfo = NULL;
2016 pkgmgr_certindexinfo_x *indexinfo = NULL;
2017 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
2018 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
2019 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
2020 if (indexinfo == NULL) {
2021 _LOGE("Out of Memory!!!");
2022 ret = PMINFO_R_ERROR;
2025 /*populate certinfo from DB*/
2026 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
2027 ret = __exec_certinfo_query(query, (void *)certinfo);
2029 _LOGE("Package Cert Info DB Information retrieval failed\n");
2030 ret = PMINFO_R_ERROR;
2033 /*Update cert index table*/
2034 for (i = 0; i < MAX_CERT_TYPE; i++) {
2035 if ((certinfo->cert_id)[i]) {
2036 for (j = 0; j < MAX_CERT_TYPE; j++) {
2037 if ((certinfo->cert_id)[i] == unique_id[j]) {
2038 /*Ref count has already been updated. Just continue*/
2042 if (j == MAX_CERT_TYPE)
2043 unique_id[c++] = (certinfo->cert_id)[i];
2046 memset(query, '\0', MAX_QUERY_LEN);
2047 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
2048 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
2050 _LOGE("Cert Info DB Information retrieval failed\n");
2051 ret = PMINFO_R_ERROR;
2054 memset(query, '\0', MAX_QUERY_LEN);
2055 if (indexinfo->cert_ref_count > 1) {
2056 /*decrease ref count*/
2057 snprintf(query, MAX_QUERY_LEN, "update package_cert_index_info set cert_ref_count=%d where cert_id=%d ",
2058 indexinfo->cert_ref_count - 1, (certinfo->cert_id)[i]);
2060 /*delete this certificate as ref count is 1 and it will become 0*/
2061 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
2064 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
2065 _LOGE("Don't execute query = %s error message = %s\n", query,
2067 sqlite3_free(error_message);
2068 ret = PMINFO_R_ERROR;
2073 /*Now delete the entry from db*/
2074 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
2076 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
2077 _LOGE("Don't execute query = %s error message = %s\n", query,
2079 sqlite3_free(error_message);
2080 ret = PMINFO_R_ERROR;
2089 if (certinfo->pkgid) {
2090 free(certinfo->pkgid);
2091 certinfo->pkgid = NULL;
2093 for (i = 0; i < MAX_CERT_TYPE; i++) {
2094 if ((certinfo->cert_info)[i]) {
2095 free((certinfo->cert_info)[i]);
2096 (certinfo->cert_info)[i] = NULL;
2104 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
2106 retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
2107 char *error_message = NULL;
2108 int ret = PMINFO_R_OK;
2109 char query[MAX_QUERY_LEN] = {'\0'};
2110 char *syslocale = NULL;
2111 char *locale = NULL;
2112 pkgmgr_pkginfo_x *pkginfo = NULL;
2113 label_x *tmp1 = NULL;
2114 icon_x *tmp2 = NULL;
2115 description_x *tmp3 = NULL;
2116 author_x *tmp4 = NULL;
2117 privilege_x *tmp5 = NULL;
2119 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2120 if (syslocale == NULL) {
2121 _LOGE("current locale is NULL\n");
2122 ret = PMINFO_R_ERROR;
2125 locale = __convert_system_locale_to_manifest_locale(syslocale);
2126 if (locale == NULL) {
2127 _LOGE("manifest locale is NULL\n");
2128 ret = PMINFO_R_EINVAL;
2132 ret = __open_manifest_db();
2134 _LOGE("Fail to open manifest DB\n");
2135 ret = PMINFO_R_ERROR;
2138 pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2139 pkgmgr_pkginfo_x *node = NULL;
2140 pkgmgr_pkginfo_x *temp_node = NULL;
2142 snprintf(query, MAX_QUERY_LEN, "select * from package_info");
2144 sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
2145 _LOGE("Don't execute query = %s error message = %s\n", query,
2147 sqlite3_free(error_message);
2148 sqlite3_close(manifest_db);
2149 ret = PMINFO_R_ERROR;
2153 LISTHEAD(tmphead, node);
2155 for(node = node->next; node ; node = node->next) {
2157 pkginfo->locale = strdup(locale);
2158 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2159 if (pkginfo->manifest_info->privileges == NULL) {
2160 _LOGE("Failed to allocate memory for privileges info\n");
2161 ret = PMINFO_R_ERROR;
2164 /*populate manifest_info from DB*/
2165 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
2166 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2168 _LOGE("Package Info DB Information retrieval failed\n");
2169 ret = PMINFO_R_ERROR;
2172 memset(query, '\0', MAX_QUERY_LEN);
2173 /*populate privilege_info from DB*/
2174 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package);
2175 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2177 _LOGE("Package Privilege Info DB Information retrieval failed\n");
2178 ret = PMINFO_R_ERROR;
2181 memset(query, '\0', MAX_QUERY_LEN);
2182 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2183 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
2184 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2186 _LOGE("Package Info DB Information retrieval failed\n");
2187 ret = PMINFO_R_ERROR;
2190 /*Also store the values corresponding to default locales*/
2191 memset(query, '\0', MAX_QUERY_LEN);
2192 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2193 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
2194 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2196 _LOGE("Package Info DB Information retrieval failed\n");
2197 ret = PMINFO_R_ERROR;
2200 if (pkginfo->manifest_info->label) {
2201 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2202 pkginfo->manifest_info->label = tmp1;
2204 if (pkginfo->manifest_info->icon) {
2205 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2206 pkginfo->manifest_info->icon = tmp2;
2208 if (pkginfo->manifest_info->description) {
2209 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2210 pkginfo->manifest_info->description = tmp3;
2212 if (pkginfo->manifest_info->author) {
2213 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2214 pkginfo->manifest_info->author = tmp4;
2216 if (pkginfo->manifest_info->privileges->privilege) {
2217 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2218 pkginfo->manifest_info->privileges->privilege = tmp5;
2222 LISTHEAD(tmphead, node);
2224 for(node = node->next; node ; node = node->next) {
2226 ret = pkg_list_cb( (void *)pkginfo, user_data);
2234 sqlite3_close(manifest_db);
2243 LISTHEAD(tmphead, node);
2244 temp_node = node->next;
2247 temp_node = node->next;
2248 __cleanup_pkginfo(node);
2251 __cleanup_pkginfo(tmphead);
2256 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
2258 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
2259 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2260 pkgmgr_pkginfo_x *pkginfo = NULL;
2261 int ret = PMINFO_R_OK;
2262 char query[MAX_QUERY_LEN] = {'\0'};
2263 char *syslocale = NULL;
2264 char *locale = NULL;
2266 label_x *tmp1 = NULL;
2267 icon_x *tmp2 = NULL;
2268 description_x *tmp3 = NULL;
2269 author_x *tmp4 = NULL;
2270 privilege_x *tmp5 = NULL;
2271 sqlite3 *pkginfo_db = NULL;
2274 ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
2275 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2277 /*check pkgid exist on db*/
2278 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
2279 ret = __exec_db_query(pkginfo_db, query, __validate_cb, (void *)&exist);
2280 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
2281 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] not found in DB", pkgid);
2283 /*get system locale*/
2284 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2285 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
2287 /*get locale on db*/
2288 locale = __convert_system_locale_to_manifest_locale(syslocale);
2289 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
2291 pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2292 tryvm_if(pkginfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for pkginfo");
2294 pkginfo->locale = strdup(locale);
2296 pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
2297 tryvm_if(pkginfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for manifest info");
2299 pkginfo->manifest_info->package = strdup(pkgid);
2300 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2301 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info");
2303 /*populate manifest_info from DB*/
2304 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
2305 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2306 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2308 memset(query, '\0', MAX_QUERY_LEN);
2309 /*populate privilege_info from DB*/
2310 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
2311 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2312 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
2314 memset(query, '\0', MAX_QUERY_LEN);
2315 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2316 " package='%s' and package_locale='%s'", pkgid, locale);
2317 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2318 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2320 /*Also store the values corresponding to default locales*/
2321 memset(query, '\0', MAX_QUERY_LEN);
2322 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2323 " package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
2324 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2325 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2327 if (pkginfo->manifest_info->label) {
2328 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2329 pkginfo->manifest_info->label = tmp1;
2331 if (pkginfo->manifest_info->icon) {
2332 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2333 pkginfo->manifest_info->icon = tmp2;
2335 if (pkginfo->manifest_info->description) {
2336 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2337 pkginfo->manifest_info->description = tmp3;
2339 if (pkginfo->manifest_info->author) {
2340 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2341 pkginfo->manifest_info->author = tmp4;
2343 if (pkginfo->manifest_info->privileges->privilege) {
2344 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2345 pkginfo->manifest_info->privileges->privilege = tmp5;
2349 if (ret == PMINFO_R_OK)
2350 *handle = (void*)pkginfo;
2353 __cleanup_pkginfo(pkginfo);
2355 sqlite3_close(pkginfo_db);
2369 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
2371 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2372 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2373 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2374 if (info->manifest_info->package)
2375 *pkg_name = (char *)info->manifest_info->package;
2377 return PMINFO_R_ERROR;
2382 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
2384 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2385 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2386 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2387 if (info->manifest_info->package)
2388 *pkgid = (char *)info->manifest_info->package;
2390 return PMINFO_R_ERROR;
2395 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
2397 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2398 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2399 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2400 if (info->manifest_info->type)
2401 *type = (char *)info->manifest_info->type;
2407 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
2409 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2410 retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2411 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2412 *version = (char *)info->manifest_info->version;
2416 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
2418 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2419 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2421 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2422 val = (char *)info->manifest_info->installlocation;
2424 if (strcmp(val, "internal-only") == 0)
2425 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2426 else if (strcmp(val, "prefer-external") == 0)
2427 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2429 *location = PMINFO_INSTALL_LOCATION_AUTO;
2434 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
2436 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2437 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2439 char *location = NULL;
2440 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2441 location = (char *)info->manifest_info->installlocation;
2442 val = (char *)info->manifest_info->package_size;
2447 _LOGE("package size is not specified\n");
2448 return PMINFO_R_ERROR;
2453 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
2455 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2456 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2459 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
2460 long long rw_size = 0;
2461 long long ro_size= 0;
2462 long long tmp_size= 0;
2463 long long total_size= 0;
2464 struct stat fileinfo;
2467 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2469 return PMINFO_R_ERROR;
2472 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid);
2473 if (lstat(device_path, &fileinfo) == 0) {
2474 if (!S_ISLNK(fileinfo.st_mode)) {
2475 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2477 rw_size += tmp_size;
2481 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid);
2482 if (lstat(device_path, &fileinfo) == 0) {
2483 if (!S_ISLNK(fileinfo.st_mode)) {
2484 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2486 rw_size += tmp_size;
2490 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid);
2491 if (lstat(device_path, &fileinfo) == 0) {
2492 if (!S_ISLNK(fileinfo.st_mode)) {
2493 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2495 rw_size += tmp_size;
2499 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_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 rw_size += tmp_size;
2508 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_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 rw_size += tmp_size;
2517 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_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 rw_size += tmp_size;
2527 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_PATH, pkgid);
2528 if (lstat(device_path, &fileinfo) == 0) {
2529 if (!S_ISLNK(fileinfo.st_mode)) {
2530 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2532 ro_size += tmp_size;
2536 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid);
2537 if (lstat(device_path, &fileinfo) == 0) {
2538 if (!S_ISLNK(fileinfo.st_mode)) {
2539 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2541 ro_size += tmp_size;
2545 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid);
2546 if (lstat(device_path, &fileinfo) == 0) {
2547 if (!S_ISLNK(fileinfo.st_mode)) {
2548 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2550 ro_size += tmp_size;
2554 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid);
2555 if (lstat(device_path, &fileinfo) == 0) {
2556 if (!S_ISLNK(fileinfo.st_mode)) {
2557 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2559 ro_size += tmp_size;
2563 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid);
2564 if (lstat(device_path, &fileinfo) == 0) {
2565 if (!S_ISLNK(fileinfo.st_mode)) {
2566 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2568 ro_size += tmp_size;
2572 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid);
2573 if (lstat(device_path, &fileinfo) == 0) {
2574 if (!S_ISLNK(fileinfo.st_mode)) {
2575 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2577 ro_size += tmp_size;
2582 total_size = rw_size + ro_size;
2583 *size = (int)total_size;
2588 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
2590 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2591 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2594 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
2595 long long total_size= 0;
2598 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2600 return PMINFO_R_ERROR;
2602 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
2603 if (access(device_path, R_OK) == 0)
2604 total_size = _pkgmgr_calculate_dir_size(device_path);
2606 return PMINFO_R_ERROR;
2608 *size = (int)total_size;
2613 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
2615 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2616 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2617 int ret = PMINFO_R_OK;
2618 char *locale = NULL;
2622 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2624 locale = info->locale;
2625 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2627 for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next)
2630 if (strcmp(ptr->lang, locale) == 0) {
2631 *icon = (char *)ptr->text;
2632 if (strcasecmp(*icon, "(null)") == 0) {
2633 locale = DEFAULT_LOCALE;
2637 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2638 *icon = (char *)ptr->text;
2647 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
2649 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2650 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2651 int ret = PMINFO_R_OK;
2652 char *locale = NULL;
2653 label_x *ptr = NULL;
2656 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2657 locale = info->locale;
2658 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2660 for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next)
2663 if (strcmp(ptr->lang, locale) == 0) {
2664 *label = (char *)ptr->text;
2665 if (strcasecmp(*label, "(null)") == 0) {
2666 locale = DEFAULT_LOCALE;
2670 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2671 *label = (char *)ptr->text;
2680 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
2682 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2683 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2684 char *locale = NULL;
2685 description_x *ptr = NULL;
2686 *description = NULL;
2688 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2689 locale = info->locale;
2690 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2692 for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next)
2695 if (strcmp(ptr->lang, locale) == 0) {
2696 *description = (char *)ptr->text;
2697 if (strcasecmp(*description, "(null)") == 0) {
2698 locale = DEFAULT_LOCALE;
2702 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2703 *description = (char *)ptr->text;
2711 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
2713 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2714 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2715 char *locale = NULL;
2716 author_x *ptr = NULL;
2717 *author_name = NULL;
2719 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2720 locale = info->locale;
2721 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2723 for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next)
2726 if (strcmp(ptr->lang, locale) == 0) {
2727 *author_name = (char *)ptr->text;
2728 if (strcasecmp(*author_name, "(null)") == 0) {
2729 locale = DEFAULT_LOCALE;
2733 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2734 *author_name = (char *)ptr->text;
2742 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
2744 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2745 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2746 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2747 *author_email = (char *)info->manifest_info->author->email;
2751 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
2753 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2754 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2755 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2756 *author_href = (char *)info->manifest_info->author->href;
2760 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
2762 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2763 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2765 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2767 if (strcmp(info->manifest_info->installed_storage,"installed_internal") == 0)
2768 *storage = PMINFO_INTERNAL_STORAGE;
2769 else if (strcmp(info->manifest_info->installed_storage,"installed_external") == 0)
2770 *storage = PMINFO_EXTERNAL_STORAGE;
2772 return PMINFO_R_ERROR;
2777 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
2779 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2780 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2781 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2782 if (info->manifest_info->installed_time)
2783 *installed_time = atoi(info->manifest_info->installed_time);
2785 return PMINFO_R_ERROR;
2790 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
2792 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2793 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2794 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2795 *storeclientid = (char *)info->manifest_info->storeclient_id;
2799 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
2801 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2802 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2803 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2804 *mainappid = (char *)info->manifest_info->mainapp_id;
2808 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
2810 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2811 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2812 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2813 *url = (char *)info->manifest_info->package_url;
2817 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
2819 const char *val = NULL;
2820 const xmlChar *node;
2821 xmlTextReaderPtr reader;
2822 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2823 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2826 reader = xmlReaderForFile(manifest, NULL, 0);
2829 if (__child_element(reader, -1)) {
2830 node = xmlTextReaderConstName(reader);
2832 _LOGE("xmlTextReaderConstName value is NULL\n");
2833 xmlFreeTextReader(reader);
2835 return PMINFO_R_ERROR;
2838 if (!strcmp(ASC_CHAR(node), "manifest")) {
2839 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
2840 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
2846 _LOGE("package size is not specified\n");
2847 xmlFreeTextReader(reader);
2849 return PMINFO_R_ERROR;
2852 _LOGE("Unable to create xml reader\n");
2853 xmlFreeTextReader(reader);
2855 return PMINFO_R_ERROR;
2859 _LOGE("xmlReaderForFile value is NULL\n");
2861 return PMINFO_R_ERROR;
2864 xmlFreeTextReader(reader);
2870 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
2872 const char *val = NULL;
2873 const xmlChar *node;
2874 xmlTextReaderPtr reader;
2875 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2876 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2879 reader = xmlReaderForFile(manifest, NULL, 0);
2882 if ( __child_element(reader, -1)) {
2883 node = xmlTextReaderConstName(reader);
2885 _LOGE("xmlTextReaderConstName value is NULL\n");
2886 xmlFreeTextReader(reader);
2888 return PMINFO_R_ERROR;
2891 if (!strcmp(ASC_CHAR(node), "manifest")) {
2892 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
2893 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
2896 if (strcmp(val, "internal-only") == 0)
2897 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2898 else if (strcmp(val, "prefer-external") == 0)
2899 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2901 *location = PMINFO_INSTALL_LOCATION_AUTO;
2904 _LOGE("Unable to create xml reader\n");
2905 xmlFreeTextReader(reader);
2907 return PMINFO_R_ERROR;
2911 _LOGE("xmlReaderForFile value is NULL\n");
2913 return PMINFO_R_ERROR;
2916 xmlFreeTextReader(reader);
2923 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
2925 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2926 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2928 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2929 if (info->manifest_info->root_path)
2930 *path = (char *)info->manifest_info->root_path;
2932 return PMINFO_R_ERROR;
2937 API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
2939 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2940 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2942 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2943 if (info->manifest_info->csc_path)
2944 *path = (char *)info->manifest_info->csc_path;
2946 *path = (char *)info->manifest_info->csc_path;
2951 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)
2953 retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
2954 retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
2955 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2957 int ret = PMINFO_R_OK;
2958 char query[MAX_QUERY_LEN] = {'\0'};
2959 char *error_message = NULL;
2960 pkgmgr_cert_x *info= NULL;
2964 *compare_result = PMINFO_CERT_COMPARE_ERROR;
2965 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
2966 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
2968 ret = db_util_open_with_options(CERT_DB, &cert_db,
2969 SQLITE_OPEN_READONLY, NULL);
2970 if (ret != SQLITE_OK) {
2971 _LOGE("connect db [%s] failed!\n", CERT_DB);
2972 ret = PMINFO_R_ERROR;
2976 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
2978 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
2979 _LOGE("Don't execute query = %s error message = %s\n", query,
2981 ret = PMINFO_R_ERROR;
2988 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
2990 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
2991 _LOGE("Don't execute query = %s error message = %s\n", query,
2993 ret = PMINFO_R_ERROR;
2996 lcert = info->cert_id;
2999 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
3001 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
3002 _LOGE("Don't execute query = %s error message = %s\n", query,
3004 ret = PMINFO_R_ERROR;
3011 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
3013 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
3014 _LOGE("Don't execute query = %s error message = %s\n", query,
3016 ret = PMINFO_R_ERROR;
3019 rcert = info->cert_id;
3022 if ((lcert == 0) || (rcert == 0))
3024 if ((lcert == 0) && (rcert == 0))
3025 *compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
3026 else if (lcert == 0)
3027 *compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
3028 else if (rcert == 0)
3029 *compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
3032 *compare_result = PMINFO_CERT_COMPARE_MATCH;
3034 *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
3038 sqlite3_free(error_message);
3039 sqlite3_close(cert_db);
3052 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)
3054 retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
3055 retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
3056 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3058 int ret = PMINFO_R_OK;
3059 char query[MAX_QUERY_LEN] = {'\0'};
3060 char *error_message = NULL;
3061 pkgmgr_cert_x *info= NULL;
3063 char *lpkgid = NULL;
3064 char *rpkgid = NULL;
3066 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3067 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3069 ret = db_util_open_with_options(MANIFEST_DB, &manifest_db,
3070 SQLITE_OPEN_READONLY, NULL);
3071 if (ret != SQLITE_OK) {
3072 _LOGE("connect db [%s] failed!\n", MANIFEST_DB);
3073 ret = PMINFO_R_ERROR;
3077 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
3079 sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
3080 _LOGE("Don't execute query = %s error message = %s\n", query,
3082 ret = PMINFO_R_ERROR;
3089 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
3091 sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
3092 _LOGE("Don't execute query = %s error message = %s\n", query,
3094 ret = PMINFO_R_ERROR;
3097 lpkgid = strdup(info->pkgid);
3098 if (lpkgid == NULL) {
3099 _LOGE("Out of Memory\n");
3100 ret = PMINFO_R_ERROR;
3107 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
3109 sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
3110 _LOGE("Don't execute query = %s error message = %s\n", query,
3112 ret = PMINFO_R_ERROR;
3119 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
3121 sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
3122 _LOGE("Don't execute query = %s error message = %s\n", query,
3124 ret = PMINFO_R_ERROR;
3127 rpkgid = strdup(info->pkgid);
3128 if (rpkgid == NULL) {
3129 _LOGE("Out of Memory\n");
3130 ret = PMINFO_R_ERROR;
3136 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
3138 sqlite3_free(error_message);
3139 sqlite3_close(manifest_db);
3159 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
3161 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3162 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3164 #if 0 //smack issue occured, check later
3166 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
3168 _LOGD("invalid func parameters\n");
3169 return PMINFO_R_ERROR;
3171 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
3174 char app_mmc_path[FILENAME_MAX] = { 0, };
3175 char app_dir_path[FILENAME_MAX] = { 0, };
3176 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
3177 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
3178 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
3179 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
3181 /*check whether application is in external memory or not */
3182 fp = fopen(app_mmc_path, "r");
3184 _LOGD(" app path in external memory not accesible\n");
3189 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
3193 /*check whether application is in internal or not */
3194 fp = fopen(app_dir_path, "r");
3196 _LOGD(" app path in internal memory not accesible\n");
3198 return PMINFO_R_ERROR;
3201 /*check whether the application is installed in SD card
3202 but SD card is not present*/
3203 fp = fopen(app_mmc_internal_path, "r");
3206 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
3211 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
3216 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
3223 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
3225 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3226 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3228 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3229 val = (char *)info->manifest_info->removable;
3231 if (strcasecmp(val, "true") == 0)
3233 else if (strcasecmp(val, "false") == 0)
3241 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
3243 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3244 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3247 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3249 val = (char *)info->manifest_info->installlocation;
3251 if (strcmp(val, "internal-only") == 0)
3253 else if (strcmp(val, "prefer-external") == 0)
3262 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
3264 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3265 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3267 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3268 val = (char *)info->manifest_info->preload;
3270 if (strcasecmp(val, "true") == 0)
3272 else if (strcasecmp(val, "false") == 0)
3280 API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
3282 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3283 retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3285 char *preload = NULL;
3286 char *removable = NULL;
3287 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3288 preload = (char *)info->manifest_info->preload;
3289 removable = (char *)info->manifest_info->removable;
3291 if ((strcasecmp(preload, "true") == 0) && (strcasecmp(removable, "false") == 0))
3299 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
3301 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3302 retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3304 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3305 val = (char *)info->manifest_info->readonly;
3307 if (strcasecmp(val, "true") == 0)
3309 else if (strcasecmp(val, "false") == 0)
3317 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
3319 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3320 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3323 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3324 val = (char *)info->manifest_info->update;
3326 if (strcasecmp(val, "true") == 0)
3328 else if (strcasecmp(val, "false") == 0)
3336 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
3338 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3339 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3340 __cleanup_pkginfo(info);
3344 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
3346 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
3348 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
3349 if (filter == NULL) {
3350 _LOGE("Out of Memory!!!");
3351 return PMINFO_R_ERROR;
3357 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
3359 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3360 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3362 g_slist_foreach(filter->list, __destroy_each_node, NULL);
3363 g_slist_free(filter->list);
3370 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
3371 const char *property, const int value)
3373 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3374 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3375 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3377 GSList *link = NULL;
3379 prop = _pminfo_pkginfo_convert_to_prop_int(property);
3380 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
3381 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
3382 _LOGE("Invalid Integer Property\n");
3383 return PMINFO_R_EINVAL;
3385 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3386 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3388 _LOGE("Out of Memory!!!\n");
3389 return PMINFO_R_ERROR;
3391 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3392 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3394 _LOGE("Out of Memory\n");
3397 return PMINFO_R_ERROR;
3401 /*If API is called multiple times for same property, we should override the previous values.
3402 Last value set will be used for filtering.*/
3403 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3405 filter->list = g_slist_delete_link(filter->list, link);
3406 filter->list = g_slist_append(filter->list, (gpointer)node);
3411 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
3412 const char *property, const bool value)
3414 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3415 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3417 GSList *link = NULL;
3419 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
3420 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
3421 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
3422 _LOGE("Invalid Boolean Property\n");
3423 return PMINFO_R_EINVAL;
3425 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3426 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3428 _LOGE("Out of Memory!!!\n");
3429 return PMINFO_R_ERROR;
3432 val = strndup("('true','True')", 15);
3434 val = strndup("('false','False')", 17);
3436 _LOGE("Out of Memory\n");
3439 return PMINFO_R_ERROR;
3443 /*If API is called multiple times for same property, we should override the previous values.
3444 Last value set will be used for filtering.*/
3445 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3447 filter->list = g_slist_delete_link(filter->list, link);
3448 filter->list = g_slist_append(filter->list, (gpointer)node);
3453 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
3454 const char *property, const char *value)
3456 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3457 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3458 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3460 GSList *link = NULL;
3462 prop = _pminfo_pkginfo_convert_to_prop_str(property);
3463 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
3464 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
3465 _LOGE("Invalid String Property\n");
3466 return PMINFO_R_EINVAL;
3468 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3469 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3471 _LOGE("Out of Memory!!!\n");
3472 return PMINFO_R_ERROR;
3474 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
3475 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
3476 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
3477 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
3478 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
3479 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
3480 else if (strcmp(value, "installed_internal") == 0)
3481 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
3482 else if (strcmp(value, "installed_external") == 0)
3483 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
3485 val = strndup(value, PKG_STRING_LEN_MAX - 1);
3487 _LOGE("Out of Memory\n");
3490 return PMINFO_R_ERROR;
3494 /*If API is called multiple times for same property, we should override the previous values.
3495 Last value set will be used for filtering.*/
3496 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3498 filter->list = g_slist_delete_link(filter->list, link);
3499 filter->list = g_slist_append(filter->list, (gpointer)node);
3504 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
3506 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3507 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3508 char *syslocale = NULL;
3509 char *locale = NULL;
3510 char *condition = NULL;
3511 char *error_message = NULL;
3512 char query[MAX_QUERY_LEN] = {'\0'};
3513 char where[MAX_QUERY_LEN] = {'\0'};
3517 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3518 /*Get current locale*/
3519 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3520 if (syslocale == NULL) {
3521 _LOGE("current locale is NULL\n");
3522 return PMINFO_R_ERROR;
3524 locale = __convert_system_locale_to_manifest_locale(syslocale);
3525 if (locale == NULL) {
3526 _LOGE("manifest locale is NULL\n");
3528 return PMINFO_R_ERROR;
3531 ret = __open_manifest_db();
3533 _LOGE("Fail to open manifest DB\n");
3534 ret = PMINFO_R_ERROR;
3538 /*Start constructing query*/
3539 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_PACKAGE, locale);
3541 /*Get where clause*/
3542 for (list = filter->list; list; list = g_slist_next(list)) {
3543 __get_filter_condition(list->data, &condition);
3545 strncat(where, condition, sizeof(where) - strlen(where) -1);
3546 where[sizeof(where) - 1] = '\0';
3550 if (g_slist_next(list)) {
3551 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3552 where[sizeof(where) - 1] = '\0';
3555 _LOGE("where = %s\n", where);
3556 if (strlen(where) > 0) {
3557 strncat(query, where, sizeof(query) - strlen(query) - 1);
3558 query[sizeof(query) - 1] = '\0';
3560 _LOGE("query = %s\n", query);
3564 sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
3565 _LOGE("Don't execute query = %s error message = %s\n", query,
3567 sqlite3_free(error_message);
3568 sqlite3_close(manifest_db);
3569 ret = PMINFO_R_ERROR;
3583 sqlite3_close(manifest_db);
3587 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
3588 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
3590 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3591 retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3592 char *syslocale = NULL;
3593 char *locale = NULL;
3594 char *condition = NULL;
3595 char *error_message = NULL;
3596 char query[MAX_QUERY_LEN] = {'\0'};
3597 char where[MAX_QUERY_LEN] = {'\0'};
3600 label_x *tmp1 = NULL;
3601 icon_x *tmp2 = NULL;
3602 description_x *tmp3 = NULL;
3603 author_x *tmp4 = NULL;
3604 privilege_x *tmp5 = NULL;
3605 pkgmgr_pkginfo_x *node = NULL;
3606 pkgmgr_pkginfo_x *tmphead = NULL;
3607 pkgmgr_pkginfo_x *pkginfo = NULL;
3609 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3610 /*Get current locale*/
3611 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3612 if (syslocale == NULL) {
3613 _LOGE("current locale is NULL\n");
3614 return PMINFO_R_ERROR;
3616 locale = __convert_system_locale_to_manifest_locale(syslocale);
3617 if (locale == NULL) {
3618 _LOGE("manifest locale is NULL\n");
3620 return PMINFO_R_ERROR;
3623 ret = __open_manifest_db();
3625 _LOGE("Fail to open manifest DB\n");
3626 ret = PMINFO_R_ERROR;
3629 /*Start constructing query*/
3630 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
3632 /*Get where clause*/
3633 for (list = filter->list; list; list = g_slist_next(list)) {
3634 __get_filter_condition(list->data, &condition);
3636 strncat(where, condition, sizeof(where) - strlen(where) -1);
3637 where[sizeof(where) - 1] = '\0';
3641 if (g_slist_next(list)) {
3642 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3643 where[sizeof(where) - 1] = '\0';
3646 _LOGE("where = %s\n", where);
3647 if (strlen(where) > 0) {
3648 strncat(query, where, sizeof(query) - strlen(query) - 1);
3649 query[sizeof(query) - 1] = '\0';
3651 _LOGE("query = %s\n", query);
3652 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
3653 if (tmphead == NULL) {
3654 _LOGE("Out of Memory!!!\n");
3655 ret = PMINFO_R_ERROR;
3660 sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
3661 _LOGE("Don't execute query = %s error message = %s\n", query,
3663 sqlite3_free(error_message);
3664 sqlite3_close(manifest_db);
3665 ret = PMINFO_R_ERROR;
3669 LISTHEAD(tmphead, node);
3670 for(node = node->next ; node ; node = node->next) {
3672 pkginfo->locale = strdup(locale);
3673 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
3674 if (pkginfo->manifest_info->privileges == NULL) {
3675 _LOGE("Failed to allocate memory for privileges info\n");
3676 ret = PMINFO_R_ERROR;
3680 /*populate manifest_info from DB*/
3681 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
3682 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3684 _LOGE("Package Info DB Information retrieval failed\n");
3685 ret = PMINFO_R_ERROR;
3688 memset(query, '\0', MAX_QUERY_LEN);
3689 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3690 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
3691 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3693 _LOGE("Package Info DB Information retrieval failed\n");
3694 ret = PMINFO_R_ERROR;
3697 /*Also store the values corresponding to default locales*/
3698 memset(query, '\0', MAX_QUERY_LEN);
3699 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3700 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
3701 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3703 _LOGE("Package Info DB Information retrieval failed\n");
3704 ret = PMINFO_R_ERROR;
3707 if (pkginfo->manifest_info->label) {
3708 LISTHEAD(pkginfo->manifest_info->label, tmp1);
3709 pkginfo->manifest_info->label = tmp1;
3711 if (pkginfo->manifest_info->icon) {
3712 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
3713 pkginfo->manifest_info->icon = tmp2;
3715 if (pkginfo->manifest_info->description) {
3716 LISTHEAD(pkginfo->manifest_info->description, tmp3);
3717 pkginfo->manifest_info->description = tmp3;
3719 if (pkginfo->manifest_info->author) {
3720 LISTHEAD(pkginfo->manifest_info->author, tmp4);
3721 pkginfo->manifest_info->author = tmp4;
3723 if (pkginfo->manifest_info->privileges->privilege) {
3724 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
3725 pkginfo->manifest_info->privileges->privilege = tmp5;
3729 LISTHEAD(tmphead, node);
3731 for(node = node->next ; node ; node = node->next) {
3733 ret = pkg_cb( (void *)pkginfo, user_data);
3748 sqlite3_close(manifest_db);
3749 __cleanup_pkginfo(tmphead);
3753 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
3754 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
3756 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3757 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3759 privilege_x *ptr = NULL;
3760 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3761 ptr = info->manifest_info->privileges->privilege;
3762 for (; ptr; ptr = ptr->next) {
3764 ret = privilege_func(ptr->text, user_data);
3772 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
3773 pkgmgrinfo_app_list_cb app_func, void *user_data)
3775 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3776 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
3777 retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
3779 char *syslocale = NULL;
3780 char *locale = NULL;
3782 char query[MAX_QUERY_LEN] = {'\0'};
3783 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3784 pkgmgr_pkginfo_x *allinfo = NULL;
3785 pkgmgr_appinfo_x *appinfo = NULL;
3786 icon_x *ptr1 = NULL;
3787 label_x *ptr2 = NULL;
3788 category_x *ptr3 = NULL;
3789 metadata_x *ptr4 = NULL;
3790 permission_x *ptr5 = NULL;
3791 image_x *ptr6 = NULL;
3792 sqlite3 *appinfo_db = NULL;
3794 /*get system locale*/
3795 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3796 tryvm_if(syslocale == NULL, ret = PMINFO_R_EINVAL, "current locale is NULL");
3798 /*get locale on db*/
3799 locale = __convert_system_locale_to_manifest_locale(syslocale);
3800 tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
3803 allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
3804 tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3806 /*calloc manifest_info*/
3807 allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
3808 tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
3811 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
3812 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3814 /*set component type*/
3815 if (component == PMINFO_UI_APP)
3816 appinfo->app_component = PMINFO_UI_APP;
3817 if (component == PMINFO_SVC_APP)
3818 appinfo->app_component = PMINFO_SVC_APP;
3819 if (component == PMINFO_ALL_APP)
3820 appinfo->app_component = PMINFO_ALL_APP;
3823 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
3824 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3826 appinfo->package = strdup(info->manifest_info->package);
3827 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
3828 "from package_app_info where " \
3829 "package='%s' and app_component='%s'",
3830 info->manifest_info->package,
3831 (appinfo->app_component==PMINFO_UI_APP ? "uiapp" : "svcapp"));
3835 /*Populate ui app info */
3836 ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
3837 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3839 uiapplication_x *tmp = NULL;
3840 if (info->manifest_info->uiapplication) {
3841 LISTHEAD(info->manifest_info->uiapplication, tmp);
3842 info->manifest_info->uiapplication = tmp;
3844 /*Populate localized info for default locales and call callback*/
3845 /*If the callback func return < 0 we break and no more call back is called*/
3848 appinfo->locale = strdup(locale);
3849 appinfo->uiapp_info = tmp;
3850 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
3854 locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
3857 memset(query, '\0', MAX_QUERY_LEN);
3858 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3859 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3860 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3862 memset(query, '\0', MAX_QUERY_LEN);
3863 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);
3864 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3865 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3867 /*store setting notification icon section*/
3868 memset(query, '\0', MAX_QUERY_LEN);
3869 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3870 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3871 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
3873 /*store app preview image info*/
3874 memset(query, '\0', MAX_QUERY_LEN);
3875 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
3876 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3877 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
3879 if (appinfo->uiapp_info->label) {
3880 LISTHEAD(appinfo->uiapp_info->label, ptr2);
3881 appinfo->uiapp_info->label = ptr2;
3883 if (appinfo->uiapp_info->icon) {
3884 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
3885 appinfo->uiapp_info->icon = ptr1;
3887 if (appinfo->uiapp_info->category) {
3888 LISTHEAD(appinfo->uiapp_info->category, ptr3);
3889 appinfo->uiapp_info->category = ptr3;
3891 if (appinfo->uiapp_info->metadata) {
3892 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
3893 appinfo->uiapp_info->metadata = ptr4;
3895 if (appinfo->uiapp_info->permission) {
3896 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
3897 appinfo->uiapp_info->permission = ptr5;
3899 if (appinfo->uiapp_info->image) {
3900 LISTHEAD(appinfo->uiapp_info->image, ptr6);
3901 appinfo->uiapp_info->image = ptr6;
3903 ret = app_func((void *)appinfo, user_data);
3909 case PMINFO_SVC_APP:
3910 /*Populate svc app info */
3911 ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
3912 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3914 serviceapplication_x *tmp1 = NULL;
3915 if (info->manifest_info->serviceapplication) {
3916 LISTHEAD(info->manifest_info->serviceapplication, tmp1);
3917 info->manifest_info->serviceapplication = tmp1;
3919 /*Populate localized info for default locales and call callback*/
3920 /*If the callback func return < 0 we break and no more call back is called*/
3923 appinfo->locale = strdup(locale);
3924 appinfo->svcapp_info = tmp1;
3925 memset(query, '\0', MAX_QUERY_LEN);
3926 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
3927 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3928 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3930 memset(query, '\0', MAX_QUERY_LEN);
3931 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);
3932 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3933 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3935 if (appinfo->svcapp_info->label) {
3936 LISTHEAD(appinfo->svcapp_info->label, ptr2);
3937 appinfo->svcapp_info->label = ptr2;
3939 if (appinfo->svcapp_info->icon) {
3940 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
3941 appinfo->svcapp_info->icon = ptr1;
3943 if (appinfo->svcapp_info->category) {
3944 LISTHEAD(appinfo->svcapp_info->category, ptr3);
3945 appinfo->svcapp_info->category = ptr3;
3947 if (appinfo->svcapp_info->metadata) {
3948 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
3949 appinfo->svcapp_info->metadata = ptr4;
3951 if (appinfo->svcapp_info->permission) {
3952 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
3953 appinfo->svcapp_info->permission = ptr5;
3955 ret = app_func((void *)appinfo, user_data);
3961 case PMINFO_ALL_APP:
3962 memset(query, '\0', MAX_QUERY_LEN);
3963 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
3965 /*Populate all app info */
3966 ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo);
3967 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3970 appinfo->app_component = PMINFO_UI_APP;
3971 uiapplication_x *tmp2 = NULL;
3972 if (allinfo->manifest_info->uiapplication) {
3973 LISTHEAD(allinfo->manifest_info->uiapplication, tmp2);
3974 allinfo->manifest_info->uiapplication = tmp2;
3976 /*Populate localized info for default locales and call callback*/
3977 /*If the callback func return < 0 we break and no more call back is called*/
3980 appinfo->locale = strdup(locale);
3981 appinfo->uiapp_info = tmp2;
3982 memset(query, '\0', MAX_QUERY_LEN);
3983 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3984 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3985 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3987 memset(query, '\0', MAX_QUERY_LEN);
3988 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);
3989 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3990 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3992 /*store setting notification icon section*/
3993 memset(query, '\0', MAX_QUERY_LEN);
3994 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3995 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3996 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
3998 /*store app preview image info*/
3999 memset(query, '\0', MAX_QUERY_LEN);
4000 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
4001 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4002 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4004 if (appinfo->uiapp_info->label) {
4005 LISTHEAD(appinfo->uiapp_info->label, ptr2);
4006 appinfo->uiapp_info->label = ptr2;
4008 if (appinfo->uiapp_info->icon) {
4009 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
4010 appinfo->uiapp_info->icon = ptr1;
4012 if (appinfo->uiapp_info->category) {
4013 LISTHEAD(appinfo->uiapp_info->category, ptr3);
4014 appinfo->uiapp_info->category = ptr3;
4016 if (appinfo->uiapp_info->metadata) {
4017 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
4018 appinfo->uiapp_info->metadata = ptr4;
4020 if (appinfo->uiapp_info->permission) {
4021 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
4022 appinfo->uiapp_info->permission = ptr5;
4024 if (appinfo->uiapp_info->image) {
4025 LISTHEAD(appinfo->uiapp_info->image, ptr6);
4026 appinfo->uiapp_info->image = ptr6;
4028 ret = app_func((void *)appinfo, user_data);
4035 appinfo->app_component = PMINFO_SVC_APP;
4036 serviceapplication_x *tmp3 = NULL;
4037 if (allinfo->manifest_info->serviceapplication) {
4038 LISTHEAD(allinfo->manifest_info->serviceapplication, tmp3);
4039 allinfo->manifest_info->serviceapplication = tmp3;
4041 /*Populate localized info for default locales and call callback*/
4042 /*If the callback func return < 0 we break and no more call back is called*/
4045 appinfo->locale = strdup(locale);
4046 appinfo->svcapp_info = tmp3;
4047 memset(query, '\0', MAX_QUERY_LEN);
4048 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
4049 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4050 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4052 memset(query, '\0', MAX_QUERY_LEN);
4053 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);
4054 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4055 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4057 if (appinfo->svcapp_info->label) {
4058 LISTHEAD(appinfo->svcapp_info->label, ptr2);
4059 appinfo->svcapp_info->label = ptr2;
4061 if (appinfo->svcapp_info->icon) {
4062 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
4063 appinfo->svcapp_info->icon = ptr1;
4065 if (appinfo->svcapp_info->category) {
4066 LISTHEAD(appinfo->svcapp_info->category, ptr3);
4067 appinfo->svcapp_info->category = ptr3;
4069 if (appinfo->svcapp_info->metadata) {
4070 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
4071 appinfo->svcapp_info->metadata = ptr4;
4073 if (appinfo->svcapp_info->permission) {
4074 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
4075 appinfo->svcapp_info->permission = ptr5;
4077 ret = app_func((void *)appinfo, user_data);
4082 appinfo->app_component = PMINFO_ALL_APP;
4098 if (appinfo->package) {
4099 free((void *)appinfo->package);
4100 appinfo->package = NULL;
4105 __cleanup_pkginfo(allinfo);
4107 sqlite3_close(appinfo_db);
4111 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4113 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4115 int ret = PMINFO_R_OK;
4116 char query[MAX_QUERY_LEN] = {'\0'};
4117 pkgmgr_appinfo_x *info = NULL;
4118 pkgmgr_appinfo_x *appinfo = NULL;
4119 uiapplication_x *ptr1 = NULL;
4120 sqlite3 *appinfo_db = NULL;
4123 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4124 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4127 info = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4128 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4130 /*calloc uiapplication_x*/
4131 info->uiapp_info= (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4132 tryvm_if(info->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4135 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4136 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4138 /*query package_app_info*/
4139 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4140 ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
4141 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4143 LISTHEAD(info->uiapp_info, ptr1);
4146 for(ptr1 = ptr1->next ; ptr1 ; ptr1 = ptr1->next)
4148 appinfo->uiapp_info= ptr1;
4149 appinfo->package = strdup(ptr1->package);
4150 appinfo->app_component = PMINFO_UI_APP;
4152 ret = app_func((void *)appinfo, user_data);
4155 free((void *)appinfo->package);
4156 appinfo->package = NULL;
4160 sqlite3_close(appinfo_db);
4166 __cleanup_appinfo(info);
4170 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4172 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4174 int ret = PMINFO_R_OK;
4175 char query[MAX_QUERY_LEN] = {'\0'};
4176 char *syslocale = NULL;
4177 char *locale = NULL;
4178 pkgmgr_appinfo_x *appinfo = NULL;
4179 uiapplication_x *ptr1 = NULL;
4180 serviceapplication_x *ptr2 = NULL;
4181 label_x *tmp1 = NULL;
4182 icon_x *tmp2 = NULL;
4183 category_x *tmp3 = NULL;
4184 metadata_x *tmp4 = NULL;
4185 permission_x *tmp5 = NULL;
4186 image_x *tmp6 = NULL;
4187 sqlite3 *appinfo_db = NULL;
4189 /*get system locale*/
4190 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4191 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
4193 /*get locale on db*/
4194 locale = __convert_system_locale_to_manifest_locale(syslocale);
4195 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4198 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4199 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4202 pkgmgr_pkginfo_x *info = NULL;
4203 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4204 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4206 /*calloc manifest_info*/
4207 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4208 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4211 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4212 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4214 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4215 ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
4216 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4218 if (info->manifest_info->uiapplication) {
4219 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4220 info->manifest_info->uiapplication = ptr1;
4222 if (info->manifest_info->serviceapplication) {
4223 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4224 info->manifest_info->serviceapplication = ptr2;
4228 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4230 appinfo->locale = strdup(locale);
4231 appinfo->app_component = PMINFO_UI_APP;
4232 appinfo->package = strdup(ptr1->package);
4233 appinfo->uiapp_info = ptr1;
4234 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4235 "from package_app_info where " \
4236 "app_id='%s'", ptr1->appid);
4237 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4238 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4240 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
4244 locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
4247 memset(query, '\0', MAX_QUERY_LEN);
4248 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4249 "from package_app_localized_info where " \
4250 "app_id='%s' and app_locale='%s'",
4251 ptr1->appid, locale);
4252 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4253 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4255 memset(query, '\0', MAX_QUERY_LEN);
4256 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4257 "from package_app_localized_info where " \
4258 "app_id='%s' and app_locale='%s'",
4259 ptr1->appid, DEFAULT_LOCALE);
4261 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4262 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4264 /*store setting notification icon section*/
4265 memset(query, '\0', MAX_QUERY_LEN);
4266 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
4267 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4268 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4270 /*store app preview image info*/
4271 memset(query, '\0', MAX_QUERY_LEN);
4272 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
4273 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4274 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4276 if (appinfo->uiapp_info->label) {
4277 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4278 appinfo->uiapp_info->label = tmp1;
4280 if (appinfo->uiapp_info->icon) {
4281 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4282 appinfo->uiapp_info->icon= tmp2;
4284 if (appinfo->uiapp_info->category) {
4285 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4286 appinfo->uiapp_info->category = tmp3;
4288 if (appinfo->uiapp_info->metadata) {
4289 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4290 appinfo->uiapp_info->metadata = tmp4;
4292 if (appinfo->uiapp_info->permission) {
4293 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4294 appinfo->uiapp_info->permission = tmp5;
4296 if (appinfo->uiapp_info->image) {
4297 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4298 appinfo->uiapp_info->image = tmp6;
4300 ret = app_func((void *)appinfo, user_data);
4303 free((void *)appinfo->package);
4304 appinfo->package = NULL;
4307 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4309 appinfo->locale = strdup(locale);
4310 appinfo->app_component = PMINFO_SVC_APP;
4311 appinfo->package = strdup(ptr2->package);
4312 appinfo->svcapp_info = ptr2;
4313 memset(query, '\0', MAX_QUERY_LEN);
4314 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4315 "from package_app_info where " \
4316 "app_id='%s'", ptr2->appid);
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 memset(query, '\0', MAX_QUERY_LEN);
4321 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4322 "from package_app_localized_info where " \
4323 "app_id='%s' and app_locale='%s'",
4324 ptr2->appid, locale);
4325 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4326 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4328 memset(query, '\0', MAX_QUERY_LEN);
4329 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4330 "from package_app_localized_info where " \
4331 "app_id='%s' and app_locale='%s'",
4332 ptr2->appid, DEFAULT_LOCALE);
4333 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4334 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4336 if (appinfo->svcapp_info->label) {
4337 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4338 appinfo->svcapp_info->label = tmp1;
4340 if (appinfo->svcapp_info->icon) {
4341 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4342 appinfo->svcapp_info->icon= tmp2;
4344 if (appinfo->svcapp_info->category) {
4345 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4346 appinfo->svcapp_info->category = tmp3;
4348 if (appinfo->svcapp_info->metadata) {
4349 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4350 appinfo->svcapp_info->metadata = tmp4;
4352 if (appinfo->svcapp_info->permission) {
4353 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4354 appinfo->svcapp_info->permission = tmp5;
4356 ret = app_func((void *)appinfo, user_data);
4359 free((void *)appinfo->package);
4360 appinfo->package = NULL;
4373 sqlite3_close(appinfo_db);
4378 __cleanup_pkginfo(info);
4382 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
4384 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
4385 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4387 pkgmgr_appinfo_x *appinfo = NULL;
4388 char *syslocale = NULL;
4389 char *locale = NULL;
4392 label_x *tmp1 = NULL;
4393 icon_x *tmp2 = NULL;
4394 category_x *tmp3 = NULL;
4395 metadata_x *tmp4 = NULL;
4396 permission_x *tmp5 = NULL;
4397 image_x *tmp6 = NULL;
4398 char query[MAX_QUERY_LEN] = {'\0'};
4399 sqlite3 *appinfo_db = NULL;
4402 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4403 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4405 /*check appid exist on db*/
4406 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
4407 ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
4408 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
4409 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
4411 /*get system locale*/
4412 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4413 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
4415 /*get locale on db*/
4416 locale = __convert_system_locale_to_manifest_locale(syslocale);
4417 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4420 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4421 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
4423 /*check app_component from DB*/
4424 memset(query, '\0', MAX_QUERY_LEN);
4425 snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
4426 ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
4427 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4429 /*calloc app_component*/
4430 if (appinfo->app_component == PMINFO_UI_APP) {
4431 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4432 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
4434 appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
4435 tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
4437 appinfo->locale = strdup(locale);
4439 /*populate app_info from DB*/
4440 memset(query, '\0', MAX_QUERY_LEN);
4441 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
4442 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4443 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4445 memset(query, '\0', MAX_QUERY_LEN);
4446 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
4447 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4448 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4450 /*Also store the values corresponding to default locales*/
4451 memset(query, '\0', MAX_QUERY_LEN);
4452 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
4453 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4454 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4456 /*Populate app category*/
4457 memset(query, '\0', MAX_QUERY_LEN);
4458 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
4459 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4460 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
4462 /*Populate app metadata*/
4463 memset(query, '\0', MAX_QUERY_LEN);
4464 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
4465 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4466 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
4468 /*Populate app permission*/
4469 memset(query, '\0', MAX_QUERY_LEN);
4470 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
4471 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4472 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
4474 /*store setting notification icon section*/
4475 memset(query, '\0', MAX_QUERY_LEN);
4476 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
4477 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4478 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4480 /*store app preview image info*/
4481 memset(query, '\0', MAX_QUERY_LEN);
4482 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
4483 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4484 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4486 switch (appinfo->app_component) {
4488 if (appinfo->uiapp_info->label) {
4489 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4490 appinfo->uiapp_info->label = tmp1;
4492 if (appinfo->uiapp_info->icon) {
4493 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4494 appinfo->uiapp_info->icon = tmp2;
4496 if (appinfo->uiapp_info->category) {
4497 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4498 appinfo->uiapp_info->category = tmp3;
4500 if (appinfo->uiapp_info->metadata) {
4501 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4502 appinfo->uiapp_info->metadata = tmp4;
4504 if (appinfo->uiapp_info->permission) {
4505 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4506 appinfo->uiapp_info->permission = tmp5;
4508 if (appinfo->uiapp_info->image) {
4509 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4510 appinfo->uiapp_info->image = tmp6;
4513 case PMINFO_SVC_APP:
4514 if (appinfo->svcapp_info->label) {
4515 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4516 appinfo->svcapp_info->label = tmp1;
4518 if (appinfo->svcapp_info->icon) {
4519 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4520 appinfo->svcapp_info->icon = tmp2;
4522 if (appinfo->svcapp_info->category) {
4523 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4524 appinfo->svcapp_info->category = tmp3;
4526 if (appinfo->svcapp_info->metadata) {
4527 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4528 appinfo->svcapp_info->metadata = tmp4;
4530 if (appinfo->svcapp_info->permission) {
4531 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4532 appinfo->svcapp_info->permission = tmp5;
4542 if (ret == PMINFO_R_OK)
4543 *handle = (void*)appinfo;
4546 __cleanup_appinfo(appinfo);
4549 sqlite3_close(appinfo_db);
4562 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
4564 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4565 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4566 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4568 if (info->app_component == PMINFO_UI_APP)
4569 *appid = (char *)info->uiapp_info->appid;
4570 else if (info->app_component == PMINFO_SVC_APP)
4571 *appid = (char *)info->svcapp_info->appid;
4576 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
4578 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4579 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4580 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4582 *pkg_name = (char *)info->package;
4587 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
4589 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4590 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4591 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4593 *pkgid = (char *)info->package;
4598 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
4600 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4601 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4602 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4604 if (info->app_component == PMINFO_UI_APP)
4605 *exec = (char *)info->uiapp_info->exec;
4606 if (info->app_component == PMINFO_SVC_APP)
4607 *exec = (char *)info->svcapp_info->exec;
4613 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4615 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4616 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4617 char *locale = NULL;
4619 icon_x *start = NULL;
4622 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4623 locale = info->locale;
4624 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4626 if (info->app_component == PMINFO_UI_APP)
4627 start = info->uiapp_info->icon;
4628 if (info->app_component == PMINFO_SVC_APP)
4629 start = info->svcapp_info->icon;
4630 for(ptr = start; ptr != NULL; ptr = ptr->next)
4633 if (strcmp(ptr->lang, locale) == 0) {
4634 *icon = (char *)ptr->text;
4635 if (strcasecmp(*icon, "(null)") == 0) {
4636 locale = DEFAULT_LOCALE;
4640 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4641 *icon = (char *)ptr->text;
4650 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
4652 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4653 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4654 char *locale = NULL;
4655 label_x *ptr = NULL;
4656 label_x *start = NULL;
4659 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4660 locale = info->locale;
4661 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4663 if (info->app_component == PMINFO_UI_APP)
4664 start = info->uiapp_info->label;
4665 if (info->app_component == PMINFO_SVC_APP)
4666 start = info->svcapp_info->label;
4667 for(ptr = start; ptr != NULL; ptr = ptr->next)
4670 if (strcmp(ptr->lang, locale) == 0) {
4671 *label = (char *)ptr->text;
4672 if (strcasecmp(*label, "(null)") == 0) {
4673 locale = DEFAULT_LOCALE;
4677 } else if (strncasecmp(ptr->lang, locale, 2) == 0) {
4678 *label = (char *)ptr->text;
4679 if (strcasecmp(*label, "(null)") == 0) {
4680 locale = DEFAULT_LOCALE;
4684 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4685 *label = (char *)ptr->text;
4694 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
4696 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4697 retvm_if(component == 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 *component = PMINFO_UI_APP;
4702 else if (info->app_component == PMINFO_SVC_APP)
4703 *component = PMINFO_SVC_APP;
4705 return PMINFO_R_ERROR;
4710 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
4712 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4713 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4714 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4716 if (info->app_component == PMINFO_UI_APP)
4717 *app_type = (char *)info->uiapp_info->type;
4718 if (info->app_component == PMINFO_SVC_APP)
4719 *app_type = (char *)info->svcapp_info->type;
4724 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
4725 int *operation_count, char ***operation)
4727 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4728 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4729 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4730 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4731 *operation_count = data->operation_count;
4732 *operation = data->operation;
4736 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
4737 int *uri_count, char ***uri)
4739 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4740 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4741 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4742 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4743 *uri_count = data->uri_count;
4748 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
4749 int *mime_count, char ***mime)
4751 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4752 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4753 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4754 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4755 *mime_count = data->mime_count;
4760 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
4761 int *subapp_count, char ***subapp)
4763 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4764 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4765 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4766 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4767 *subapp_count = data->subapp_count;
4768 *subapp = data->subapp;
4772 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4774 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4775 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4779 icon_x *start = NULL;
4780 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4782 start = info->uiapp_info->icon;
4784 for(ptr = start; ptr != NULL; ptr = ptr->next)
4787 val = (char *)ptr->section;
4788 if (strcmp(val, "setting") == 0){
4789 *icon = (char *)ptr->text;
4798 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4800 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4801 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4805 icon_x *start = NULL;
4806 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4808 start = info->uiapp_info->icon;
4810 for(ptr = start; ptr != NULL; ptr = ptr->next)
4813 val = (char *)ptr->section;
4815 if (strcmp(val, "notification") == 0){
4816 *icon = (char *)ptr->text;
4825 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
4827 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4828 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4830 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4831 val = (char *)info->uiapp_info->recentimage;
4833 if (strcasecmp(val, "capture") == 0)
4834 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
4835 else if (strcasecmp(val, "icon") == 0)
4836 *type = PMINFO_RECENTIMAGE_USE_ICON;
4838 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
4844 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
4846 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4847 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4850 image_x *ptr = NULL;
4851 image_x *start = NULL;
4852 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4854 start = info->uiapp_info->image;
4856 for(ptr = start; ptr != NULL; ptr = ptr->next)
4859 val = (char *)ptr->section;
4861 if (strcmp(val, "preview") == 0)
4862 *preview_img = (char *)ptr->text;
4870 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
4872 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4873 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4876 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4878 val = info->uiapp_info->permission_type;
4880 if (strcmp(val, "signature") == 0)
4881 *permission = PMINFO_PERMISSION_SIGNATURE;
4882 else if (strcmp(val, "privilege") == 0)
4883 *permission = PMINFO_PERMISSION_PRIVILEGE;
4885 *permission = PMINFO_PERMISSION_NORMAL;
4890 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
4892 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4893 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4894 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4896 *component_type = (char *)info->uiapp_info->component_type;
4901 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
4903 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4904 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4906 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4907 val = (char *)info->uiapp_info->hwacceleration;
4909 if (strcasecmp(val, "not-use-GL") == 0)
4910 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
4911 else if (strcasecmp(val, "use-GL") == 0)
4912 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
4914 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
4919 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
4921 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4922 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4924 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4925 val = (char *)info->uiapp_info->screenreader;
4927 if (strcasecmp(val, "screenreader-off") == 0)
4928 *screenreader = PMINFO_SCREENREADER_OFF;
4929 else if (strcasecmp(val, "screenreader-on") == 0)
4930 *screenreader = PMINFO_SCREENREADER_ON;
4932 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
4937 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
4939 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4940 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4941 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4942 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4944 if (info->app_component == PMINFO_UI_APP){
4945 *portrait_img = (char *)info->uiapp_info->portraitimg;
4946 *landscape_img = (char *)info->uiapp_info->landscapeimg;
4952 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
4954 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4955 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4956 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4958 *submode_mainid = (char *)info->uiapp_info->submode_mainid;
4963 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
4964 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
4966 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4967 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4969 permission_x *ptr = NULL;
4970 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4971 if (info->app_component == PMINFO_UI_APP)
4972 ptr = info->uiapp_info->permission;
4973 else if (info->app_component == PMINFO_SVC_APP)
4974 ptr = info->svcapp_info->permission;
4976 return PMINFO_R_EINVAL;
4977 for (; ptr; ptr = ptr->next) {
4978 ret = permission_func(ptr->value, user_data);
4985 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
4986 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
4988 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4989 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4991 category_x *ptr = NULL;
4992 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4993 if (info->app_component == PMINFO_UI_APP)
4994 ptr = info->uiapp_info->category;
4995 else if (info->app_component == PMINFO_SVC_APP)
4996 ptr = info->svcapp_info->category;
4998 return PMINFO_R_EINVAL;
4999 for (; ptr; ptr = ptr->next) {
5000 ret = category_func(ptr->name, user_data);
5007 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
5008 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
5010 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5011 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5013 metadata_x *ptr = NULL;
5014 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5015 if (info->app_component == PMINFO_UI_APP)
5016 ptr = info->uiapp_info->metadata;
5017 else if (info->app_component == PMINFO_SVC_APP)
5018 ptr = info->svcapp_info->metadata;
5020 return PMINFO_R_EINVAL;
5021 for (; ptr; ptr = ptr->next) {
5023 ret = metadata_func(ptr->key, ptr->value, user_data);
5031 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
5032 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
5034 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5035 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5043 char *manifest = NULL;
5044 char **operation = NULL;
5047 char **subapp = NULL;
5048 appcontrol_x *appcontrol = NULL;
5049 manifest_x *mfx = NULL;
5050 operation_x *op = NULL;
5053 subapp_x *sa = NULL;
5054 pkgmgrinfo_app_component component;
5055 pkgmgrinfo_appcontrol_x *ptr = NULL;
5056 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
5058 _LOGE("Failed to get package name\n");
5059 return PMINFO_R_ERROR;
5061 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
5063 _LOGE("Failed to get app component name\n");
5064 return PMINFO_R_ERROR;
5066 manifest = pkgmgr_parser_get_manifest_file(pkgid);
5067 if (manifest == NULL) {
5068 _LOGE("Failed to fetch package manifest file\n");
5069 return PMINFO_R_ERROR;
5071 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5073 _LOGE("Failed to parse package manifest file\n");
5076 return PMINFO_R_ERROR;
5079 ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
5081 _LOGE("Out of Memory!!!\n");
5082 pkgmgr_parser_free_manifest_xml(mfx);
5083 return PMINFO_R_ERROR;
5085 /*Get Operation, Uri, Mime*/
5086 switch (component) {
5088 if (mfx->uiapplication) {
5089 if (mfx->uiapplication->appsvc) {
5090 appcontrol = mfx->uiapplication->appsvc;
5094 case PMINFO_SVC_APP:
5095 if (mfx->serviceapplication) {
5096 if (mfx->serviceapplication->appsvc) {
5097 appcontrol = mfx->serviceapplication->appsvc;
5104 for (; appcontrol; appcontrol = appcontrol->next) {
5105 op = appcontrol->operation;
5106 for (; op; op = op->next)
5108 op = appcontrol->operation;
5110 ui = appcontrol->uri;
5111 for (; ui; ui = ui->next)
5113 ui = appcontrol->uri;
5115 mi = appcontrol->mime;
5116 for (; mi; mi = mi->next)
5118 mi = appcontrol->mime;
5120 sa = appcontrol->subapp;
5121 for (; sa; sa = sa->next)
5123 sa = appcontrol->subapp;
5125 operation = (char **)calloc(oc, sizeof(char *));
5126 for (i = 0; i < oc; i++) {
5127 operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
5131 uri = (char **)calloc(uc, sizeof(char *));
5132 for (i = 0; i < uc; i++) {
5133 uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
5137 mime = (char **)calloc(mc, sizeof(char *));
5138 for (i = 0; i < mc; i++) {
5139 mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
5143 subapp = (char **)calloc(sc, sizeof(char *));
5144 for (i = 0; i < sc; i++) {
5145 subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
5149 /*populate appcontrol handle*/
5150 ptr->operation_count = oc;
5151 ptr->uri_count = uc;
5152 ptr->mime_count = mc;
5153 ptr->subapp_count = sc;
5154 ptr->operation = operation;
5157 ptr->subapp = subapp;
5159 ret = appcontrol_func((void *)ptr, user_data);
5160 for (i = 0; i < oc; i++) {
5163 operation[i] = NULL;
5170 for (i = 0; i < uc; i++) {
5180 for (i = 0; i < mc; i++) {
5190 for (i = 0; i < sc; i++) {
5207 pkgmgr_parser_free_manifest_xml(mfx);
5215 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
5217 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5218 retvm_if(nodisplay == 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->nodisplay;
5223 if (strcasecmp(val, "true") == 0)
5225 else if (strcasecmp(val, "false") == 0)
5233 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
5235 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5236 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5238 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5239 val = (char *)info->uiapp_info->multiple;
5241 if (strcasecmp(val, "true") == 0)
5243 else if (strcasecmp(val, "false") == 0)
5251 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
5253 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5254 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5256 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5257 val = (char *)info->uiapp_info->indicatordisplay;
5259 if (strcasecmp(val, "true") == 0){
5260 *indicator_disp = 1;
5261 }else if (strcasecmp(val, "false") == 0){
5262 *indicator_disp = 0;
5264 *indicator_disp = 0;
5270 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
5272 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5273 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5275 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5276 val = (char *)info->uiapp_info->taskmanage;
5278 if (strcasecmp(val, "true") == 0)
5280 else if (strcasecmp(val, "false") == 0)
5288 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
5290 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5291 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5293 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5294 if (info->app_component == PMINFO_UI_APP)
5295 val = (char *)info->uiapp_info->enabled;
5296 else if (info->app_component == PMINFO_SVC_APP)
5297 val = (char *)info->uiapp_info->enabled;
5299 _LOGE("invalid component type\n");
5300 return PMINFO_R_EINVAL;
5304 if (strcasecmp(val, "true") == 0)
5306 else if (strcasecmp(val, "false") == 0)
5315 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
5317 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5318 retvm_if(onboot == 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->svcapp_info->onboot;
5323 if (strcasecmp(val, "true") == 0)
5325 else if (strcasecmp(val, "false") == 0)
5333 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
5335 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5336 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5338 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5339 val = (char *)info->svcapp_info->autorestart;
5341 if (strcasecmp(val, "true") == 0)
5343 else if (strcasecmp(val, "false") == 0)
5351 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
5353 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5354 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5356 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5357 val = (char *)info->uiapp_info->mainapp;
5359 if (strcasecmp(val, "true") == 0)
5361 else if (strcasecmp(val, "false") == 0)
5369 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
5371 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5372 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5374 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5375 val = (char *)info->uiapp_info->preload;
5377 if (strcasecmp(val, "true") == 0)
5379 else if (strcasecmp(val, "false") == 0)
5387 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
5389 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5390 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5392 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5393 val = (char *)info->uiapp_info->submode;
5395 if (strcasecmp(val, "true") == 0)
5397 else if (strcasecmp(val, "false") == 0)
5405 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
5407 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5408 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5409 __cleanup_appinfo(info);
5413 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
5415 return (pkgmgrinfo_pkginfo_filter_create(handle));
5418 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
5420 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5423 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
5424 const char *property, const int value)
5426 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5427 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5428 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
5430 GSList *link = NULL;
5432 prop = _pminfo_appinfo_convert_to_prop_int(property);
5433 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
5434 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
5435 _LOGE("Invalid Integer Property\n");
5436 return PMINFO_R_EINVAL;
5438 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5439 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5441 _LOGE("Out of Memory!!!\n");
5442 return PMINFO_R_ERROR;
5444 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
5445 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
5447 _LOGE("Out of Memory\n");
5450 return PMINFO_R_ERROR;
5454 /*If API is called multiple times for same property, we should override the previous values.
5455 Last value set will be used for filtering.*/
5456 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5458 filter->list = g_slist_delete_link(filter->list, link);
5459 filter->list = g_slist_append(filter->list, (gpointer)node);
5464 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
5465 const char *property, const bool value)
5467 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5468 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5470 GSList *link = NULL;
5472 prop = _pminfo_appinfo_convert_to_prop_bool(property);
5473 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
5474 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
5475 _LOGE("Invalid Boolean Property\n");
5476 return PMINFO_R_EINVAL;
5478 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5479 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5481 _LOGE("Out of Memory!!!\n");
5482 return PMINFO_R_ERROR;
5485 val = strndup("('true','True')", 15);
5487 val = strndup("('false','False')", 17);
5489 _LOGE("Out of Memory\n");
5492 return PMINFO_R_ERROR;
5496 /*If API is called multiple times for same property, we should override the previous values.
5497 Last value set will be used for filtering.*/
5498 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5500 filter->list = g_slist_delete_link(filter->list, link);
5501 filter->list = g_slist_append(filter->list, (gpointer)node);
5506 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
5507 const char *property, const char *value)
5509 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5510 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5511 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5513 pkgmgrinfo_node_x *ptr = NULL;
5514 char prev[PKG_STRING_LEN_MAX] = {'\0'};
5515 char temp[PKG_STRING_LEN_MAX] = {'\0'};
5516 GSList *link = NULL;
5518 prop = _pminfo_appinfo_convert_to_prop_str(property);
5519 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
5520 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
5521 _LOGE("Invalid String Property\n");
5522 return PMINFO_R_EINVAL;
5524 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5525 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5527 _LOGE("Out of Memory!!!\n");
5528 return PMINFO_R_ERROR;
5532 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
5533 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
5534 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
5536 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
5538 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5540 filter->list = g_slist_delete_link(filter->list, link);
5541 filter->list = g_slist_append(filter->list, (gpointer)node);
5543 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
5544 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
5545 case E_PMINFO_APPINFO_PROP_APP_URI:
5546 case E_PMINFO_APPINFO_PROP_APP_MIME:
5547 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
5549 _LOGE("Out of Memory\n");
5552 return PMINFO_R_ERROR;
5554 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5556 ptr = (pkgmgrinfo_node_x *)link->data;
5557 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
5558 _LOGE("Previous value is %s\n", prev);
5559 filter->list = g_slist_delete_link(filter->list, link);
5560 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
5561 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5562 _LOGE("New value is %s\n", val);
5564 filter->list = g_slist_append(filter->list, (gpointer)node);
5565 memset(temp, '\0', PKG_STRING_LEN_MAX);
5567 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
5568 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5569 _LOGE("First value is %s\n", val);
5571 filter->list = g_slist_append(filter->list, (gpointer)node);
5572 memset(temp, '\0', PKG_STRING_LEN_MAX);
5576 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
5577 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5579 filter->list = g_slist_delete_link(filter->list, link);
5580 filter->list = g_slist_append(filter->list, (gpointer)node);
5586 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
5588 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5589 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5590 char *syslocale = NULL;
5591 char *locale = NULL;
5592 char *condition = NULL;
5593 char *error_message = NULL;
5594 char query[MAX_QUERY_LEN] = {'\0'};
5595 char where[MAX_QUERY_LEN] = {'\0'};
5599 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5600 /*Get current locale*/
5601 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5602 if (syslocale == NULL) {
5603 _LOGE("current locale is NULL\n");
5604 return PMINFO_R_ERROR;
5606 locale = __convert_system_locale_to_manifest_locale(syslocale);
5607 if (locale == NULL) {
5608 _LOGE("manifest locale is NULL\n");
5610 return PMINFO_R_ERROR;
5613 ret = __open_manifest_db();
5615 _LOGE("Fail to open manifest DB\n");
5616 ret = PMINFO_R_ERROR;
5620 /*Start constructing query*/
5621 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_APP, locale);
5623 /*Get where clause*/
5624 for (list = filter->list; list; list = g_slist_next(list)) {
5625 __get_filter_condition(list->data, &condition);
5627 strncat(where, condition, sizeof(where) - strlen(where) -1);
5628 where[sizeof(where) - 1] = '\0';
5632 if (g_slist_next(list)) {
5633 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5634 where[sizeof(where) - 1] = '\0';
5637 _LOGE("where = %s\n", where);
5638 if (strlen(where) > 0) {
5639 strncat(query, where, sizeof(query) - strlen(query) - 1);
5640 query[sizeof(query) - 1] = '\0';
5642 _LOGE("query = %s\n", query);
5646 sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
5647 _LOGE("Don't execute query = %s error message = %s\n", query,
5649 sqlite3_free(error_message);
5650 sqlite3_close(manifest_db);
5651 ret = PMINFO_R_ERROR;
5665 sqlite3_close(manifest_db);
5669 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
5670 pkgmgrinfo_app_list_cb app_cb, void * user_data)
5672 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5673 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5674 char *syslocale = NULL;
5675 char *locale = NULL;
5676 char *condition = NULL;
5677 char *error_message = NULL;
5678 char query[MAX_QUERY_LEN] = {'\0'};
5679 char where[MAX_QUERY_LEN] = {'\0'};
5682 uiapplication_x *ptr1 = NULL;
5683 serviceapplication_x *ptr2 = NULL;
5684 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5685 /*Get current locale*/
5686 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5687 if (syslocale == NULL) {
5688 _LOGE("current locale is NULL\n");
5689 return PMINFO_R_ERROR;
5691 locale = __convert_system_locale_to_manifest_locale(syslocale);
5692 if (locale == NULL) {
5693 _LOGE("manifest locale is NULL\n");
5695 return PMINFO_R_ERROR;
5698 ret = __open_manifest_db();
5700 _LOGE("Fail to open manifest DB\n");
5701 ret = PMINFO_R_ERROR;
5704 /*Start constructing query*/
5705 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
5706 /*Get where clause*/
5707 for (list = filter->list; list; list = g_slist_next(list)) {
5708 __get_filter_condition(list->data, &condition);
5710 strncat(where, condition, sizeof(where) - strlen(where) -1);
5711 where[sizeof(where) - 1] = '\0';
5715 if (g_slist_next(list)) {
5716 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5717 where[sizeof(where) - 1] = '\0';
5720 _LOGE("where = %s\n", where);
5721 if (strlen(where) > 0) {
5722 strncat(query, where, sizeof(query) - strlen(query) - 1);
5723 query[sizeof(query) - 1] = '\0';
5725 _LOGE("query = %s\n", query);
5726 /*To get filtered list*/
5727 pkgmgr_pkginfo_x *info = NULL;
5728 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5730 _LOGE("Out of Memory!!!\n");
5731 ret = PMINFO_R_ERROR;
5734 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5735 if (info->manifest_info == NULL) {
5736 _LOGE("Out of Memory!!!\n");
5737 ret = PMINFO_R_ERROR;
5740 /*To get detail app info for each member of filtered list*/
5741 pkgmgr_pkginfo_x *filtinfo = NULL;
5742 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5743 if (filtinfo == NULL) {
5744 _LOGE("Out of Memory!!!\n");
5745 ret = PMINFO_R_ERROR;
5748 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5749 if (filtinfo->manifest_info == NULL) {
5750 _LOGE("Out of Memory!!!\n");
5751 ret = PMINFO_R_ERROR;
5754 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5755 if (appinfo == NULL) {
5756 _LOGE("Out of Memory!!!\n");
5757 ret = PMINFO_R_ERROR;
5761 sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) {
5762 _LOGE("Don't execute query = %s error message = %s\n", query,
5764 sqlite3_free(error_message);
5765 sqlite3_close(manifest_db);
5766 ret = PMINFO_R_ERROR;
5769 memset(query, '\0', MAX_QUERY_LEN);
5770 if (info->manifest_info->uiapplication) {
5771 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5772 info->manifest_info->uiapplication = ptr1;
5774 if (info->manifest_info->serviceapplication) {
5775 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5776 info->manifest_info->serviceapplication = ptr2;
5778 /*Filtered UI Apps*/
5779 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5781 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5782 ptr1->appid, "uiapp");
5784 sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
5785 _LOGE("Don't execute query = %s error message = %s\n", query,
5787 sqlite3_free(error_message);
5788 sqlite3_close(manifest_db);
5789 ret = PMINFO_R_ERROR;
5793 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5795 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5796 ptr2->appid, "svcapp");
5798 sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
5799 _LOGE("Don't execute query = %s error message = %s\n", query,
5801 sqlite3_free(error_message);
5802 sqlite3_close(manifest_db);
5803 ret = PMINFO_R_ERROR;
5807 if (filtinfo->manifest_info->uiapplication) {
5808 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5809 filtinfo->manifest_info->uiapplication = ptr1;
5811 /*If the callback func return < 0 we break and no more call back is called*/
5814 appinfo->locale = strdup(locale);
5815 appinfo->uiapp_info = ptr1;
5816 appinfo->app_component = PMINFO_UI_APP;
5817 ret = app_cb((void *)appinfo, user_data);
5822 /*Filtered Service Apps*/
5823 if (filtinfo->manifest_info->serviceapplication) {
5824 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5825 filtinfo->manifest_info->serviceapplication = ptr2;
5827 /*If the callback func return < 0 we break and no more call back is called*/
5830 appinfo->locale = strdup(locale);
5831 appinfo->svcapp_info = ptr2;
5832 appinfo->app_component = PMINFO_SVC_APP;
5833 ret = app_cb((void *)appinfo, user_data);
5848 sqlite3_close(manifest_db);
5853 __cleanup_pkginfo(info);
5854 __cleanup_pkginfo(filtinfo);
5858 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
5860 return (pkgmgrinfo_pkginfo_filter_create(handle));
5863 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
5865 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5868 API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
5869 const char *key, const char *value)
5871 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
5872 retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
5873 /*value can be NULL. In that case all apps with specified key should be displayed*/
5877 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5878 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5879 retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
5881 tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5885 tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5888 /*If API is called multiple times, we should OR all conditions.*/
5889 filter->list = g_slist_append(filter->list, (gpointer)node);
5890 /*All memory will be freed in destroy API*/
5908 API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
5909 pkgmgrinfo_app_list_cb app_cb, void *user_data)
5911 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
5912 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
5913 char *syslocale = NULL;
5914 char *locale = NULL;
5915 char *condition = NULL;
5916 char *error_message = NULL;
5917 char query[MAX_QUERY_LEN] = {'\0'};
5918 char where[MAX_QUERY_LEN] = {'\0'};
5921 pkgmgr_pkginfo_x *info = NULL;
5922 pkgmgr_pkginfo_x *filtinfo = NULL;
5923 pkgmgr_appinfo_x *appinfo = NULL;
5924 uiapplication_x *ptr1 = NULL;
5925 serviceapplication_x *ptr2 = NULL;
5926 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5928 /*Get current locale*/
5929 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5930 retvm_if(syslocale == NULL, PMINFO_R_ERROR, "current locale is NULL\n");
5931 locale = __convert_system_locale_to_manifest_locale(syslocale);
5932 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
5934 ret = __open_manifest_db();
5935 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Fail to open manifest DB\n");
5937 /*Start constructing query*/
5938 memset(where, '\0', MAX_QUERY_LEN);
5939 memset(query, '\0', MAX_QUERY_LEN);
5940 snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
5941 /*Get where clause*/
5942 for (list = filter->list; list; list = g_slist_next(list)) {
5943 __get_metadata_filter_condition(list->data, &condition);
5945 strncat(where, condition, sizeof(where) - strlen(where) -1);
5949 if (g_slist_next(list)) {
5950 strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
5953 _LOGE("where = %s (%d)\n", where, strlen(where));
5954 if (strlen(where) > 0) {
5955 strncat(query, where, sizeof(query) - strlen(query) - 1);
5957 _LOGE("query = %s (%d)\n", query, strlen(query));
5958 /*To get filtered list*/
5959 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5960 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5962 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5963 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5965 /*To get detail app info for each member of filtered list*/
5966 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5967 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5969 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5970 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5972 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5973 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5975 ret = sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message);
5976 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5977 memset(query, '\0', MAX_QUERY_LEN);
5979 if (info->manifest_info->uiapplication) {
5980 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5981 info->manifest_info->uiapplication = ptr1;
5983 if (info->manifest_info->serviceapplication) {
5984 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5985 info->manifest_info->serviceapplication = ptr2;
5989 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5991 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5992 ptr1->appid, "uiapp");
5993 ret = sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message);
5994 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5995 memset(query, '\0', MAX_QUERY_LEN);
5998 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
6000 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
6001 ptr2->appid, "svcapp");
6002 ret = sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message);
6003 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
6004 memset(query, '\0', MAX_QUERY_LEN);
6006 /*Filtered UI Apps*/
6007 if (filtinfo->manifest_info->uiapplication) {
6008 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
6009 filtinfo->manifest_info->uiapplication = ptr1;
6011 /*If the callback func return < 0 we break and no more call back is called*/
6014 appinfo->locale = strdup(locale);
6015 appinfo->uiapp_info = ptr1;
6016 appinfo->app_component = PMINFO_UI_APP;
6017 ret = app_cb((void *)appinfo, user_data);
6022 /*Filtered Service Apps*/
6023 if (filtinfo->manifest_info->serviceapplication) {
6024 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
6025 filtinfo->manifest_info->serviceapplication = ptr2;
6027 /*If the callback func return < 0 we break and no more call back is called*/
6030 appinfo->locale = strdup(locale);
6031 appinfo->svcapp_info = ptr2;
6032 appinfo->app_component = PMINFO_SVC_APP;
6033 ret = app_cb((void *)appinfo, user_data);
6048 sqlite3_free(error_message);
6049 sqlite3_close(manifest_db);
6054 __cleanup_pkginfo(info);
6055 __cleanup_pkginfo(filtinfo);
6059 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
6061 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6062 pkgmgr_certinfo_x *certinfo = NULL;
6063 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
6064 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
6065 *handle = (void *)certinfo;
6069 API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
6071 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
6072 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
6073 pkgmgr_certinfo_x *certinfo = NULL;
6074 char *error_message = NULL;
6075 int ret = PMINFO_R_OK;
6076 char query[MAX_QUERY_LEN] = {'\0'};
6081 ret = db_util_open_with_options(CERT_DB, &cert_db,
6082 SQLITE_OPEN_READONLY, NULL);
6083 if (ret != SQLITE_OK) {
6084 _LOGE("connect db [%s] failed!\n", CERT_DB);
6085 return PMINFO_R_ERROR;
6088 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6090 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6091 _LOGE("Don't execute query = %s error message = %s\n", query,
6093 sqlite3_free(error_message);
6094 ret = PMINFO_R_ERROR;
6098 _LOGE("Package not found in DB\n");
6099 ret = PMINFO_R_ERROR;
6102 certinfo = (pkgmgr_certinfo_x *)handle;
6103 /*populate certinfo from DB*/
6104 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
6105 ret = __exec_certinfo_query(query, (void *)certinfo);
6107 _LOGE("Package Cert Info DB Information retrieval failed\n");
6108 ret = PMINFO_R_ERROR;
6111 for (i = 0; i < MAX_CERT_TYPE; i++) {
6112 memset(query, '\0', MAX_QUERY_LEN);
6113 snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
6114 ret = __exec_certinfo_query(query, (void *)certinfo);
6116 _LOGE("Cert Info DB Information retrieval failed\n");
6117 ret = PMINFO_R_ERROR;
6120 if (certinfo->cert_value) {
6121 (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
6122 free(certinfo->cert_value);
6123 certinfo->cert_value = NULL;
6127 sqlite3_close(cert_db);
6131 API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
6133 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6134 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6135 retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6136 retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6137 pkgmgr_certinfo_x *certinfo = NULL;
6138 certinfo = (pkgmgr_certinfo_x *)handle;
6139 if ((certinfo->cert_info)[cert_type])
6140 *cert_value = (certinfo->cert_info)[cert_type];
6146 API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
6148 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6150 pkgmgr_certinfo_x *certinfo = NULL;
6151 certinfo = (pkgmgr_certinfo_x *)handle;
6152 if (certinfo->pkgid) {
6153 free(certinfo->pkgid);
6154 certinfo->pkgid = NULL;
6156 for (i = 0; i < MAX_CERT_TYPE; i++) {
6157 if ((certinfo->cert_info)[i]) {
6158 free((certinfo->cert_info)[i]);
6159 (certinfo->cert_info)[i] = NULL;
6167 API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
6169 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6170 pkgmgr_instcertinfo_x *certinfo = NULL;
6171 certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
6172 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
6173 *handle = (void *)certinfo;
6177 API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
6179 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6180 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6181 retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6182 retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6183 pkgmgr_instcertinfo_x *certinfo = NULL;
6184 certinfo = (pkgmgr_instcertinfo_x *)handle;
6185 (certinfo->cert_info)[cert_type] = strdup(cert_value);
6189 API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
6191 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
6192 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
6193 char *error_message = NULL;
6194 char query[MAX_QUERY_LEN] = {'\0'};
6195 char *vquery = NULL;
6200 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
6207 pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
6208 pkgmgr_certindexinfo_x *indexinfo = NULL;
6209 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
6210 if (indexinfo == NULL) {
6211 _LOGE("Out of Memory!!!");
6212 return PMINFO_R_ERROR;
6214 info->pkgid = strdup(pkgid);
6217 ret = db_util_open_with_options(CERT_DB, &cert_db,
6218 SQLITE_OPEN_READWRITE, NULL);
6219 if (ret != SQLITE_OK) {
6220 _LOGE("connect db [%s] failed!\n", CERT_DB);
6221 ret = PMINFO_R_ERROR;
6224 /*Begin Transaction*/
6225 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6226 if (ret != SQLITE_OK) {
6227 _LOGE("Failed to begin transaction\n");
6228 ret = PMINFO_R_ERROR;
6231 _LOGE("Transaction Begin\n");
6232 /*Check if request is to insert/update*/
6233 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6235 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6236 _LOGE("Don't execute query = %s error message = %s\n", query,
6238 sqlite3_free(error_message);
6239 ret = PMINFO_R_ERROR;
6244 We cant just issue update query directly. We need to manage index table also.
6245 Hence it is better to delete and insert again in case of update*/
6246 ret = __delete_certinfo(pkgid);
6248 _LOGE("Certificate Deletion Failed\n");
6250 for (i = 0; i < MAX_CERT_TYPE; i++) {
6251 if ((info->cert_info)[i]) {
6252 for (j = 0; j < i; j++) {
6253 if ( (info->cert_info)[j]) {
6254 if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
6255 (info->cert_id)[i] = (info->cert_id)[j];
6256 (info->is_new)[i] = 0;
6257 (info->ref_count)[i] = (info->ref_count)[j];
6264 memset(query, '\0', MAX_QUERY_LEN);
6265 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
6266 "where cert_info='%s'",(info->cert_info)[i]);
6267 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
6269 _LOGE("Cert Info DB Information retrieval failed\n");
6270 ret = PMINFO_R_ERROR;
6273 if (indexinfo->cert_id == 0) {
6274 /*New certificate. Get newid*/
6275 memset(query, '\0', MAX_QUERY_LEN);
6276 snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
6278 sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
6279 _LOGE("Don't execute query = %s error message = %s\n", query,
6281 sqlite3_free(error_message);
6282 ret = PMINFO_R_ERROR;
6290 indexinfo->cert_id = maxid;
6291 indexinfo->cert_ref_count = 1;
6295 (info->cert_id)[i] = indexinfo->cert_id;
6296 (info->is_new)[i] = is_new;
6297 (info->ref_count)[i] = indexinfo->cert_ref_count;
6298 _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
6299 indexinfo->cert_id = 0;
6300 indexinfo->cert_ref_count = 0;
6304 len = MAX_QUERY_LEN;
6305 for (i = 0; i < MAX_CERT_TYPE; i++) {
6306 if ((info->cert_info)[i])
6307 len+= strlen((info->cert_info)[i]);
6309 vquery = (char *)calloc(1, len);
6311 snprintf(vquery, len,
6312 "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
6313 "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
6314 "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
6315 info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
6316 (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
6317 (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
6318 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
6319 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
6321 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6322 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6324 sqlite3_free(error_message);
6325 ret = PMINFO_R_ERROR;
6328 /*Update index table info*/
6329 /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
6330 for (i = 0; i < MAX_CERT_TYPE; i++) {
6331 if ((info->cert_info)[i]) {
6332 memset(vquery, '\0', len);
6333 if ((info->is_new)[i]) {
6334 snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
6335 "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
6336 unique_id[c++] = (info->cert_id)[i];
6339 for (j = 0; j < MAX_CERT_TYPE; j++) {
6340 if ((info->cert_id)[i] == unique_id[j]) {
6341 /*Ref count has already been increased. Just continue*/
6345 if (j == MAX_CERT_TYPE)
6346 unique_id[c++] = (info->cert_id)[i];
6349 snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
6350 "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
6353 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6354 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6356 sqlite3_free(error_message);
6357 ret = PMINFO_R_ERROR;
6362 /*Commit transaction*/
6363 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6364 if (ret != SQLITE_OK) {
6365 _LOGE("Failed to commit transaction, Rollback now\n");
6366 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6367 ret = PMINFO_R_ERROR;
6370 _LOGE("Transaction Commit and End\n");
6373 sqlite3_close(cert_db);
6385 API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
6387 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6389 pkgmgr_instcertinfo_x *certinfo = NULL;
6390 certinfo = (pkgmgr_instcertinfo_x *)handle;
6391 if (certinfo->pkgid) {
6392 free(certinfo->pkgid);
6393 certinfo->pkgid = NULL;
6395 for (i = 0; i < MAX_CERT_TYPE; i++) {
6396 if ((certinfo->cert_info)[i]) {
6397 free((certinfo->cert_info)[i]);
6398 (certinfo->cert_info)[i] = NULL;
6406 API int pkgmgrinfo_delete_certinfo(const char *pkgid)
6408 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6411 ret = db_util_open_with_options(CERT_DB, &cert_db,
6412 SQLITE_OPEN_READWRITE, NULL);
6413 if (ret != SQLITE_OK) {
6414 _LOGE("connect db [%s] failed!\n", CERT_DB);
6415 ret = PMINFO_R_ERROR;
6418 /*Begin Transaction*/
6419 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6420 if (ret != SQLITE_OK) {
6421 _LOGE("Failed to begin transaction\n");
6422 ret = PMINFO_R_ERROR;
6425 _LOGE("Transaction Begin\n");
6426 ret = __delete_certinfo(pkgid);
6428 _LOGE("Certificate Deletion Failed\n");
6430 _LOGE("Certificate Deletion Success\n");
6432 /*Commit transaction*/
6433 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6434 if (ret != SQLITE_OK) {
6435 _LOGE("Failed to commit transaction, Rollback now\n");
6436 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6437 ret = PMINFO_R_ERROR;
6440 _LOGE("Transaction Commit and End\n");
6443 sqlite3_close(cert_db);
6447 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
6449 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
6450 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6452 char *manifest = NULL;
6453 manifest_x *mfx = NULL;
6455 manifest = pkgmgr_parser_get_manifest_file(pkgid);
6456 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
6458 mfx = pkgmgr_parser_process_manifest_xml(manifest);
6463 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
6465 *handle = (void *)mfx;
6470 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
6472 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
6473 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6475 int len = strlen(type);
6476 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6478 manifest_x *mfx = (manifest_x *)handle;
6480 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
6484 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
6486 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
6487 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6489 int len = strlen(version);
6490 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6492 manifest_x *mfx = (manifest_x *)handle;
6494 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
6498 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6500 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6501 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6503 manifest_x *mfx = (manifest_x *)handle;
6505 if (location == INSTALL_INTERNAL)
6506 strcpy(mfx->installlocation, "internal-only");
6507 else if (location == INSTALL_EXTERNAL)
6508 strcpy(mfx->installlocation, "prefer-external");
6513 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
6515 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6516 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6518 manifest_x *mfx = (manifest_x *)handle;
6520 mfx->package_size = strdup(size);
6525 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
6527 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6528 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6530 int len = strlen(label_txt);
6531 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6533 manifest_x *mfx = (manifest_x *)handle;
6535 label_x *label = calloc(1, sizeof(label_x));
6536 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6538 LISTADD(mfx->label, label);
6540 mfx->label->lang = strdup(locale);
6542 mfx->label->lang = strdup(DEFAULT_LOCALE);
6543 mfx->label->text = strdup(label_txt);
6548 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
6550 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6551 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6553 int len = strlen(icon_txt);
6554 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6556 manifest_x *mfx = (manifest_x *)handle;
6558 icon_x *icon = calloc(1, sizeof(icon_x));
6559 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6561 LISTADD(mfx->icon, icon);
6563 mfx->icon->lang = strdup(locale);
6565 mfx->icon->lang = strdup(DEFAULT_LOCALE);
6566 mfx->icon->text = strdup(icon_txt);
6571 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
6573 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6574 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6576 int len = strlen(desc_txt);
6577 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6579 manifest_x *mfx = (manifest_x *)handle;
6581 description_x *description = calloc(1, sizeof(description_x));
6582 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6584 LISTADD(mfx->description, description);
6586 mfx->description->lang = strdup(locale);
6588 mfx->description->lang = strdup(DEFAULT_LOCALE);
6589 mfx->description->text = strdup(desc_txt);
6594 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
6595 const char *author_email, const char *author_href, const char *locale)
6597 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6598 manifest_x *mfx = (manifest_x *)handle;
6599 author_x *author = calloc(1, sizeof(author_x));
6600 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6602 LISTADD(mfx->author, author);
6604 mfx->author->text = strdup(author_name);
6606 mfx->author->email = strdup(author_email);
6608 mfx->author->href = strdup(author_href);
6610 mfx->author->lang = strdup(locale);
6612 mfx->author->lang = strdup(DEFAULT_LOCALE);
6616 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
6618 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6619 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6621 manifest_x *mfx = (manifest_x *)handle;
6624 strcpy(mfx->removable, "false");
6625 else if (removable == 1)
6626 strcpy(mfx->removable, "true");
6631 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
6633 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6634 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6636 manifest_x *mfx = (manifest_x *)handle;
6639 strcpy(mfx->preload, "false");
6640 else if (preload == 1)
6641 strcpy(mfx->preload, "true");
6646 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6648 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6649 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6651 manifest_x *mfx = (manifest_x *)handle;
6653 if (location == INSTALL_INTERNAL)
6654 strcpy(mfx->installed_storage, "installed_internal");
6655 else if (location == INSTALL_EXTERNAL)
6656 strcpy(mfx->installed_storage, "installed_external");
6661 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6663 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6666 manifest_x *mfx = NULL;
6667 mfx = (manifest_x *)handle;
6669 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
6671 _LOGE("Successfully stored info in DB\n");
6674 _LOGE("Failed to store info in DB\n");
6675 return PMINFO_R_ERROR;
6679 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6681 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6683 manifest_x *mfx = NULL;
6684 mfx = (manifest_x *)handle;
6685 pkgmgr_parser_free_manifest_xml(mfx);
6689 API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
6691 /* Should be implemented later */
6695 API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
6697 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6699 char query[MAX_QUERY_LEN] = {'\0'};
6700 ret = __open_manifest_db();
6702 if (access(MANIFEST_DB, F_OK) == 0) {
6703 ret = db_util_open(MANIFEST_DB, &manifest_db,
6704 DB_UTIL_REGISTER_HOOK_METHOD);
6705 if (ret != SQLITE_OK) {
6706 _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
6707 return PMINFO_R_ERROR;
6711 /*Begin transaction*/
6712 ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6713 if (ret != SQLITE_OK) {
6714 _LOGE("Failed to begin transaction\n");
6715 sqlite3_close(manifest_db);
6716 return PMINFO_R_ERROR;
6718 _LOGD("Transaction Begin\n");
6720 memset(query, '\0', MAX_QUERY_LEN);
6721 snprintf(query, MAX_QUERY_LEN,
6722 "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
6724 char *error_message = NULL;
6726 sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
6727 _LOGE("Don't execute query = %s error message = %s\n", query,
6729 sqlite3_free(error_message);
6730 return PMINFO_R_ERROR;
6732 sqlite3_free(error_message);
6734 /*Commit transaction*/
6735 ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
6736 if (ret != SQLITE_OK) {
6737 _LOGE("Failed to commit transaction. Rollback now\n");
6738 sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
6739 sqlite3_close(manifest_db);
6740 return PMINFO_R_ERROR;
6742 _LOGD("Transaction Commit and End\n");
6743 sqlite3_close(manifest_db);
6749 API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
6751 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6752 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6753 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6754 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6755 int ret = PMINFO_R_OK;
6756 char query[MAX_QUERY_LEN] = {'\0'};
6757 char *error_message = NULL;
6758 pkgmgr_datacontrol_x *data = NULL;
6760 ret = __open_datacontrol_db();
6762 _LOGE("Fail to open datacontrol DB\n");
6763 return PMINFO_R_ERROR;
6766 data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x));
6768 _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
6769 sqlite3_close(datacontrol_db);
6770 return PMINFO_R_ERROR;
6773 snprintf(query, MAX_QUERY_LEN,
6774 "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",
6778 sqlite3_exec(datacontrol_db, query, __datacontrol_cb, (void *)data, &error_message)) {
6779 _LOGE("Don't execute query = %s error message = %s\n", query,
6781 sqlite3_free(error_message);
6782 sqlite3_close(datacontrol_db);
6783 return PMINFO_R_ERROR;
6786 *appid = (char *)data->appid;
6787 *access = (char *)data->access;
6789 sqlite3_close(datacontrol_db);
6794 API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
6796 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6798 char query[MAX_QUERY_LEN] = {'\0'};
6799 char *error_message = NULL;
6800 ret = __open_manifest_db();
6802 if (access(MANIFEST_DB, F_OK) == 0) {
6803 ret = db_util_open(MANIFEST_DB, &manifest_db,
6804 DB_UTIL_REGISTER_HOOK_METHOD);
6805 if (ret != SQLITE_OK) {
6806 _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
6807 return PMINFO_R_ERROR;
6811 /*Begin transaction*/
6812 ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6813 if (ret != SQLITE_OK) {
6814 _LOGE("Failed to begin transaction\n");
6815 sqlite3_close(manifest_db);
6816 return PMINFO_R_ERROR;
6818 _LOGD("Transaction Begin\n");
6820 memset(query, '\0', MAX_QUERY_LEN);
6821 snprintf(query, MAX_QUERY_LEN,
6822 "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid);
6825 sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
6826 _LOGE("Don't execute query = %s error message = %s\n", query,
6828 sqlite3_free(error_message);
6829 return PMINFO_R_ERROR;
6832 /*Commit transaction*/
6833 ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
6834 if (ret != SQLITE_OK) {
6835 _LOGE("Failed to commit transaction. Rollback now\n");
6836 sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
6837 sqlite3_close(manifest_db);
6838 return PMINFO_R_ERROR;
6840 _LOGD("Transaction Commit and End\n");
6841 sqlite3_close(manifest_db);
6846 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
6848 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6849 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6851 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6852 val = (char *)info->uiapp_info->guestmode_visibility;
6854 if (strcasecmp(val, "true") == 0){
6856 }else if (strcasecmp(val, "false") == 0){
6865 API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
6867 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6870 char *noti_string = NULL;
6872 char query[MAX_QUERY_LEN] = {'\0'};
6873 char *errmsg = NULL;
6874 sqlite3 *pkgmgr_parser_db;
6876 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6877 val = (char *)info->uiapp_info->guestmode_visibility;
6880 db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db,
6881 SQLITE_OPEN_READWRITE, NULL);
6883 if (ret != SQLITE_OK) {
6884 _LOGE("DB Open Failed\n");
6885 return PMINFO_R_ERROR;
6888 /*TODO: Write to DB here*/
6890 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
6892 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
6894 if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
6895 _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
6897 sqlite3_close(pkgmgr_parser_db);
6898 return PMINFO_R_ERROR;
6900 sqlite3_close(pkgmgr_parser_db);
6901 len = strlen((char *)info->uiapp_info->appid) + 8;
6902 noti_string = calloc(1, len);
6903 if (noti_string == NULL){
6904 return PMINFO_R_ERROR;
6906 snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
6907 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
6908 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed