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 {
181 } pkgmgrinfo_appcontrol_x;
183 typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
185 char *pkgtype = "rpm";
186 __thread sqlite3 *manifest_db = NULL;
187 __thread sqlite3 *datacontrol_db = NULL;
188 __thread sqlite3 *cert_db = NULL;
190 static int __open_manifest_db();
191 static int __exec_pkginfo_query(char *query, void *data);
192 static int __exec_certinfo_query(char *query, void *data);
193 static int __exec_certindexinfo_query(char *query, void *data);
194 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname);
195 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname);
196 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname);
197 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname);
198 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname);
199 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname);
200 static int __count_cb(void *data, int ncols, char **coltxt, char **colname);
201 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
202 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
203 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname);
204 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname);
205 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data);
206 static void __cleanup_appinfo(pkgmgr_appinfo_x *data);
207 static char* __convert_system_locale_to_manifest_locale(char *syslocale);
208 static void __destroy_each_node(gpointer data, gpointer user_data);
209 static void __get_filter_condition(gpointer data, char **condition);
210 static void __get_metadata_filter_condition(gpointer data, char **condition);
211 static gint __compare_func(gconstpointer data1, gconstpointer data2);
212 static int __delete_certinfo(const char *pkgid);
214 static gint __compare_func(gconstpointer data1, gconstpointer data2)
216 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
217 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
218 if (node1->prop == node2->prop)
220 else if (node1->prop > node2->prop)
226 static int __count_cb(void *data, int ncols, char **coltxt, char **colname)
229 *p = atoi(coltxt[0]);
230 _LOGE("count value is %d\n", *p);
234 static void __destroy_each_node(gpointer data, gpointer user_data)
236 ret_if(data == NULL);
237 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
250 static void __get_metadata_filter_condition(gpointer data, char **condition)
252 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
253 char key[MAX_QUERY_LEN] = {'\0'};
254 char value[MAX_QUERY_LEN] = {'\0'};
256 snprintf(key, MAX_QUERY_LEN, "(package_app_app_metadata.md_key='%s'", node->key);
259 snprintf(value, MAX_QUERY_LEN, " AND package_app_app_metadata.md_value='%s')", node->value);
264 *condition = strdup(key);
268 static void __get_filter_condition(gpointer data, char **condition)
270 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
271 char buf[MAX_QUERY_LEN + 1] = {'\0'};
272 char temp[PKG_STRING_LEN_MAX] = {'\0'};
273 switch (node->prop) {
274 case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
275 snprintf(buf, MAX_QUERY_LEN, "package_info.package='%s'", node->value);
277 case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
278 snprintf(buf, MAX_QUERY_LEN, "package_info.package_type='%s'", node->value);
280 case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
281 snprintf(buf, MAX_QUERY_LEN, "package_info.package_version='%s'", node->value);
283 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
284 snprintf(buf, MAX_QUERY_LEN, "package_info.install_location='%s'", node->value);
286 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
287 snprintf(buf, MAX_QUERY_LEN, "package_info.installed_storage='%s'", node->value);
289 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
290 snprintf(buf, MAX_QUERY_LEN, "package_info.author_name='%s'", node->value);
292 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
293 snprintf(buf, MAX_QUERY_LEN, "package_info.author_href='%s'", node->value);
295 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
296 snprintf(buf, MAX_QUERY_LEN, "package_info.author_email='%s'", node->value);
298 case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
299 snprintf(buf, MAX_QUERY_LEN, "package_info.package_size='%s'", node->value);
301 case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
302 snprintf(buf, MAX_QUERY_LEN, "package_info.package_removable IN %s", node->value);
304 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
305 snprintf(buf, MAX_QUERY_LEN, "package_info.package_preload IN %s", node->value);
307 case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
308 snprintf(buf, MAX_QUERY_LEN, "package_info.package_readonly IN %s", node->value);
310 case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
311 snprintf(buf, MAX_QUERY_LEN, "package_info.package_update IN %s", node->value);
313 case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
314 snprintf(buf, MAX_QUERY_LEN, "package_info.package_appsetting IN %s", node->value);
316 case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
317 snprintf(buf, MAX_QUERY_LEN, "package_info.package_nodisplay IN %s", node->value);
320 case E_PMINFO_APPINFO_PROP_APP_ID:
321 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_id='%s'", node->value);
323 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
324 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_component='%s'", node->value);
326 case E_PMINFO_APPINFO_PROP_APP_EXEC:
327 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_exec='%s'", node->value);
329 case E_PMINFO_APPINFO_PROP_APP_ICON:
330 snprintf(buf, MAX_QUERY_LEN, "package_app_localized_info.app_icon='%s'", node->value);
332 case E_PMINFO_APPINFO_PROP_APP_TYPE:
333 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_type='%s'", node->value);
335 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
336 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
337 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.operation IN %s", temp);
339 case E_PMINFO_APPINFO_PROP_APP_URI:
340 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
341 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.uri_scheme IN %s", temp);
343 case E_PMINFO_APPINFO_PROP_APP_MIME:
344 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
345 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.mime_type IN %s", temp);
347 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
348 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
349 snprintf(buf, MAX_QUERY_LEN, "package_app_app_category.category IN %s", temp);
351 case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
352 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_nodisplay IN %s", node->value);
354 case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
355 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_multiple IN %s", node->value);
357 case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
358 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_onboot IN %s", node->value);
360 case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
361 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_autorestart IN %s", node->value);
363 case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
364 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_taskmanage IN %s", node->value);
366 case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
367 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_hwacceleration='%s'", node->value);
369 case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
370 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
373 _LOGE("Invalid Property Type\n");
377 *condition = strdup(buf);
381 static char* __convert_system_locale_to_manifest_locale(char *syslocale)
383 if (syslocale == NULL)
384 return strdup(DEFAULT_LOCALE);
386 locale = (char *)calloc(1, 6);
387 retvm_if(!locale, NULL, "Malloc Failed\n");
389 strncpy(locale, syslocale, 2);
390 strncat(locale, "-", 1);
391 locale[3] = syslocale[3] + 32;
392 locale[4] = syslocale[4] + 32;
396 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
398 ret_if(data == NULL);
400 free((void *)data->locale);
404 pkgmgr_parser_free_manifest_xml(data->manifest_info);
410 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
412 ret_if(data == NULL);
414 free((void *)data->package);
415 data->package = NULL;
418 free((void *)data->locale);
422 manifest_x *mfx = calloc(1, sizeof(manifest_x));
423 if (data->app_component == PMINFO_UI_APP)
424 mfx->uiapplication = data->uiapp_info;
425 else if (data->app_component == PMINFO_SVC_APP)
426 mfx->serviceapplication = data->svcapp_info;
427 pkgmgr_parser_free_manifest_xml(mfx);
433 static int __open_manifest_db()
436 if (access(MANIFEST_DB, F_OK) == 0) {
438 db_util_open_with_options(MANIFEST_DB, &manifest_db,
439 SQLITE_OPEN_READONLY, NULL);
440 retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", MANIFEST_DB);
443 _LOGE("Manifest DB does not exists !!\n");
447 static int __open_datacontrol_db()
450 if (access(DATACONTROL_DB, F_OK) == 0) {
452 db_util_open_with_options(DATACONTROL_DB, &datacontrol_db,
453 SQLITE_OPEN_READONLY, NULL);
454 retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", DATACONTROL_DB);
457 _LOGE("Datacontrol DB does not exists !!\n");
461 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
463 pkgmgr_pkginfo_x *udata = (pkgmgr_pkginfo_x *)data;
465 pkgmgr_pkginfo_x *info = NULL;
466 info = calloc(1, sizeof(pkgmgr_pkginfo_x));
467 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
469 LISTADD(udata, info);
470 for(i = 0; i < ncols; i++)
472 if (strcmp(colname[i], "package") == 0) {
474 info->manifest_info->package = strdup(coltxt[i]);
476 info->manifest_info->package = NULL;
484 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname)
486 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
489 uiapplication_x *uiapp = NULL;
490 serviceapplication_x *svcapp = NULL;
491 for(i = 0; i < ncols; i++)
493 if ((strcmp(colname[i], "app_component") == 0) ||
494 (strcmp(colname[i], "package_app_info.app_component") == 0)) {
496 if (strcmp(coltxt[i], "uiapp") == 0) {
497 uiapp = calloc(1, sizeof(uiapplication_x));
499 _LOGE("Out of Memory!!!\n");
502 LISTADD(info->manifest_info->uiapplication, uiapp);
503 for(j = 0; j < ncols; j++)
505 if ((strcmp(colname[j], "app_id") == 0) ||
506 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
508 info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
509 } else if (strcmp(colname[j], "package") == 0) {
511 info->manifest_info->uiapplication->package = strdup(coltxt[j]);
516 svcapp = calloc(1, sizeof(serviceapplication_x));
517 if (svcapp == NULL) {
518 _LOGE("Out of Memory!!!\n");
521 LISTADD(info->manifest_info->serviceapplication, svcapp);
522 for(j = 0; j < ncols; j++)
524 if ((strcmp(colname[j], "app_id") == 0) ||
525 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
527 info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
528 } else if (strcmp(colname[j], "package") == 0) {
530 info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
544 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
546 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
548 uiapplication_x *uiapp = NULL;
550 label_x *label = NULL;
552 uiapp = calloc(1, sizeof(uiapplication_x));
553 LISTADD(info->manifest_info->uiapplication, uiapp);
554 icon = calloc(1, sizeof(icon_x));
555 LISTADD(info->manifest_info->uiapplication->icon, icon);
556 label = calloc(1, sizeof(label_x));
557 LISTADD(info->manifest_info->uiapplication->label, label);
559 for(i = 0; i < ncols; i++)
561 if (strcmp(colname[i], "app_id") == 0) {
563 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
565 info->manifest_info->uiapplication->appid = NULL;
566 } else if (strcmp(colname[i], "app_exec") == 0) {
568 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
570 info->manifest_info->uiapplication->exec = NULL;
571 } else if (strcmp(colname[i], "app_type") == 0 ){
573 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
575 info->manifest_info->uiapplication->type = NULL;
576 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
578 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
580 info->manifest_info->uiapplication->nodisplay = NULL;
581 } else if (strcmp(colname[i], "app_multiple") == 0 ){
583 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
585 info->manifest_info->uiapplication->multiple = NULL;
586 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
588 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
590 info->manifest_info->uiapplication->taskmanage = NULL;
591 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
593 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
595 info->manifest_info->uiapplication->hwacceleration = NULL;
596 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
598 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
600 info->manifest_info->uiapplication->indicatordisplay = NULL;
601 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
603 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
605 info->manifest_info->uiapplication->portraitimg = NULL;
606 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
608 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
610 info->manifest_info->uiapplication->landscapeimg = NULL;
611 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
613 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
615 info->manifest_info->uiapplication->guestmode_visibility = NULL;
616 } else if (strcmp(colname[i], "package") == 0 ){
618 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
620 info->manifest_info->uiapplication->package = NULL;
621 } else if (strcmp(colname[i], "app_icon") == 0) {
623 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
625 info->manifest_info->uiapplication->icon->text = NULL;
626 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
628 info->manifest_info->uiapplication->enabled= strdup(coltxt[i]);
630 info->manifest_info->uiapplication->enabled = NULL;
631 } else if (strcmp(colname[i], "app_label") == 0 ) {
633 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
635 info->manifest_info->uiapplication->label->text = NULL;
636 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
638 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
640 info->manifest_info->uiapplication->recentimage = NULL;
641 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
643 info->manifest_info->uiapplication->mainapp = strdup(coltxt[i]);
645 info->manifest_info->uiapplication->mainapp = NULL;
646 } else if (strcmp(colname[i], "app_locale") == 0 ) {
648 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
649 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
652 info->manifest_info->uiapplication->icon->lang = NULL;
653 info->manifest_info->uiapplication->label->lang = NULL;
655 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
657 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
659 info->manifest_info->uiapplication->permission_type = NULL;
666 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
668 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
670 serviceapplication_x *svcapp = NULL;
672 label_x *label = NULL;
674 svcapp = calloc(1, sizeof(serviceapplication_x));
675 LISTADD(info->manifest_info->serviceapplication, svcapp);
676 icon = calloc(1, sizeof(icon_x));
677 LISTADD(info->manifest_info->serviceapplication->icon, icon);
678 label = calloc(1, sizeof(label_x));
679 LISTADD(info->manifest_info->serviceapplication->label, label);
680 for(i = 0; i < ncols; i++)
682 if (strcmp(colname[i], "app_id") == 0) {
684 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
686 info->manifest_info->serviceapplication->appid = NULL;
687 } else if (strcmp(colname[i], "app_exec") == 0) {
689 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
691 info->manifest_info->serviceapplication->exec = NULL;
692 } else if (strcmp(colname[i], "app_type") == 0 ){
694 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
696 info->manifest_info->serviceapplication->type = NULL;
697 } else if (strcmp(colname[i], "app_onboot") == 0 ){
699 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
701 info->manifest_info->serviceapplication->onboot = NULL;
702 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
704 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
706 info->manifest_info->serviceapplication->autorestart = NULL;
707 } else if (strcmp(colname[i], "package") == 0 ){
709 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
711 info->manifest_info->serviceapplication->package = NULL;
712 } else if (strcmp(colname[i], "app_icon") == 0) {
714 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
716 info->manifest_info->serviceapplication->icon->text = NULL;
717 } else if (strcmp(colname[i], "app_label") == 0 ) {
719 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
721 info->manifest_info->serviceapplication->label->text = NULL;
722 } else if (strcmp(colname[i], "app_locale") == 0 ) {
724 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
725 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
728 info->manifest_info->serviceapplication->icon->lang = NULL;
729 info->manifest_info->serviceapplication->label->lang = NULL;
731 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
733 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
735 info->manifest_info->serviceapplication->permission_type = NULL;
742 static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
744 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
747 uiapplication_x *uiapp = NULL;
748 serviceapplication_x *svcapp = NULL;
749 for(j = 0; j < ncols; j++)
751 if (strcmp(colname[j], "app_component") == 0) {
753 if (strcmp(coltxt[j], "uiapp") == 0) {
754 uiapp = calloc(1, sizeof(uiapplication_x));
756 _LOGE("Out of Memory!!!\n");
759 LISTADD(info->manifest_info->uiapplication, uiapp);
760 for(i = 0; i < ncols; i++)
762 if (strcmp(colname[i], "app_id") == 0) {
764 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
766 info->manifest_info->uiapplication->appid = NULL;
767 } else if (strcmp(colname[i], "app_exec") == 0) {
769 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
771 info->manifest_info->uiapplication->exec = NULL;
772 } else if (strcmp(colname[i], "app_type") == 0 ){
774 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
776 info->manifest_info->uiapplication->type = NULL;
777 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
779 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
781 info->manifest_info->uiapplication->nodisplay = NULL;
782 } else if (strcmp(colname[i], "app_multiple") == 0 ){
784 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
786 info->manifest_info->uiapplication->multiple = NULL;
787 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
789 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
791 info->manifest_info->uiapplication->taskmanage = NULL;
792 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
794 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
796 info->manifest_info->uiapplication->hwacceleration = NULL;
797 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
799 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
801 info->manifest_info->uiapplication->indicatordisplay = NULL;
802 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
804 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
806 info->manifest_info->uiapplication->portraitimg = NULL;
807 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
809 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
811 info->manifest_info->uiapplication->landscapeimg = NULL;
812 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
814 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
816 info->manifest_info->uiapplication->guestmode_visibility = NULL;
817 } else if (strcmp(colname[i], "package") == 0 ){
819 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
821 info->manifest_info->uiapplication->package = NULL;
822 } else if (strcmp(colname[i], "app_icon") == 0) {
824 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
826 info->manifest_info->uiapplication->icon->text = NULL;
827 } else if (strcmp(colname[i], "app_label") == 0 ) {
829 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
831 info->manifest_info->uiapplication->label->text = NULL;
832 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
834 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
836 info->manifest_info->uiapplication->recentimage = NULL;
837 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
839 info->manifest_info->uiapplication->mainapp= strdup(coltxt[i]);
841 info->manifest_info->uiapplication->mainapp = NULL;
842 } else if (strcmp(colname[i], "app_locale") == 0 ) {
844 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
845 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
848 info->manifest_info->uiapplication->icon->lang = NULL;
849 info->manifest_info->uiapplication->label->lang = NULL;
851 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
853 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
855 info->manifest_info->uiapplication->permission_type = NULL;
860 svcapp = calloc(1, sizeof(serviceapplication_x));
861 if (svcapp == NULL) {
862 _LOGE("Out of Memory!!!\n");
865 LISTADD(info->manifest_info->serviceapplication, svcapp);
866 for(i = 0; i < ncols; i++)
868 if (strcmp(colname[i], "app_id") == 0) {
870 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
872 info->manifest_info->serviceapplication->appid = NULL;
873 } else if (strcmp(colname[i], "app_exec") == 0) {
875 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
877 info->manifest_info->serviceapplication->exec = NULL;
878 } else if (strcmp(colname[i], "app_type") == 0 ){
880 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
882 info->manifest_info->serviceapplication->type = NULL;
883 } else if (strcmp(colname[i], "app_onboot") == 0 ){
885 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
887 info->manifest_info->serviceapplication->onboot = NULL;
888 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
890 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
892 info->manifest_info->serviceapplication->autorestart = NULL;
893 } else if (strcmp(colname[i], "package") == 0 ){
895 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
897 info->manifest_info->serviceapplication->package = NULL;
898 } else if (strcmp(colname[i], "app_icon") == 0) {
900 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
902 info->manifest_info->serviceapplication->icon->text = NULL;
903 } else if (strcmp(colname[i], "app_label") == 0 ) {
905 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
907 info->manifest_info->serviceapplication->label->text = NULL;
908 } else if (strcmp(colname[i], "app_locale") == 0 ) {
910 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
911 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
914 info->manifest_info->serviceapplication->icon->lang = NULL;
915 info->manifest_info->serviceapplication->label->lang = NULL;
917 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
919 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
921 info->manifest_info->serviceapplication->permission_type = NULL;
936 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname)
939 *p = atoi(coltxt[0]);
943 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname)
947 *p = atoi(coltxt[0]);
951 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
953 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
955 author_x *author = NULL;
957 label_x *label = NULL;
958 description_x *description = NULL;
959 privilege_x *privilege = NULL;
961 author = calloc(1, sizeof(author_x));
962 LISTADD(info->manifest_info->author, author);
963 icon = calloc(1, sizeof(icon_x));
964 LISTADD(info->manifest_info->icon, icon);
965 label = calloc(1, sizeof(label_x));
966 LISTADD(info->manifest_info->label, label);
967 description = calloc(1, sizeof(description_x));
968 LISTADD(info->manifest_info->description, description);
969 privilege = calloc(1, sizeof(privilege_x));
970 LISTADD(info->manifest_info->privileges->privilege, privilege);
971 for(i = 0; i < ncols; i++)
973 if (strcmp(colname[i], "package_version") == 0) {
975 info->manifest_info->version = strdup(coltxt[i]);
977 info->manifest_info->version = NULL;
978 } else if (strcmp(colname[i], "package_type") == 0) {
980 info->manifest_info->type = strdup(coltxt[i]);
982 info->manifest_info->type = NULL;
983 } else if (strcmp(colname[i], "install_location") == 0) {
985 info->manifest_info->installlocation = strdup(coltxt[i]);
987 info->manifest_info->installlocation = NULL;
988 } else if (strcmp(colname[i], "package_size") == 0) {
990 info->manifest_info->package_size = strdup(coltxt[i]);
992 info->manifest_info->package_size = NULL;
993 } else if (strcmp(colname[i], "author_email") == 0 ){
995 info->manifest_info->author->email = strdup(coltxt[i]);
997 info->manifest_info->author->email = NULL;
998 } else if (strcmp(colname[i], "author_href") == 0 ){
1000 info->manifest_info->author->href = strdup(coltxt[i]);
1002 info->manifest_info->author->href = NULL;
1003 } else if (strcmp(colname[i], "package_label") == 0 ){
1005 info->manifest_info->label->text = strdup(coltxt[i]);
1007 info->manifest_info->label->text = NULL;
1008 } else if (strcmp(colname[i], "package_icon") == 0 ){
1010 info->manifest_info->icon->text = strdup(coltxt[i]);
1012 info->manifest_info->icon->text = NULL;
1013 } else if (strcmp(colname[i], "package_description") == 0 ){
1015 info->manifest_info->description->text = strdup(coltxt[i]);
1017 info->manifest_info->description->text = NULL;
1018 } else if (strcmp(colname[i], "package_author") == 0 ){
1020 info->manifest_info->author->text = strdup(coltxt[i]);
1022 info->manifest_info->author->text = NULL;
1023 } else if (strcmp(colname[i], "package_removable") == 0 ){
1025 info->manifest_info->removable = strdup(coltxt[i]);
1027 info->manifest_info->removable = NULL;
1028 } else if (strcmp(colname[i], "package_preload") == 0 ){
1030 info->manifest_info->preload = strdup(coltxt[i]);
1032 info->manifest_info->preload = NULL;
1033 } else if (strcmp(colname[i], "package_readonly") == 0 ){
1035 info->manifest_info->readonly = strdup(coltxt[i]);
1037 info->manifest_info->readonly = NULL;
1038 } else if (strcmp(colname[i], "package_update") == 0 ){
1040 info->manifest_info->update= strdup(coltxt[i]);
1042 info->manifest_info->update = NULL;
1043 } else if (strcmp(colname[i], "package_appsetting") == 0 ){
1045 info->manifest_info->appsetting = strdup(coltxt[i]);
1047 info->manifest_info->appsetting = NULL;
1048 } else if (strcmp(colname[i], "installed_time") == 0 ){
1050 info->manifest_info->installed_time = strdup(coltxt[i]);
1052 info->manifest_info->installed_time = NULL;
1053 } else if (strcmp(colname[i], "mainapp_id") == 0 ){
1055 info->manifest_info->mainapp_id = strdup(coltxt[i]);
1057 info->manifest_info->mainapp_id = NULL;
1058 } else if (strcmp(colname[i], "root_path") == 0 ){
1060 info->manifest_info->root_path = strdup(coltxt[i]);
1062 info->manifest_info->root_path = NULL;
1063 } else if (strcmp(colname[i], "csc_path") == 0 ){
1065 info->manifest_info->csc_path = strdup(coltxt[i]);
1067 info->manifest_info->csc_path = NULL;
1068 } else if (strcmp(colname[i], "privilege") == 0 ){
1070 info->manifest_info->privileges->privilege->text = strdup(coltxt[i]);
1072 info->manifest_info->privileges->privilege->text = NULL;
1073 } else if (strcmp(colname[i], "package_locale") == 0 ){
1075 info->manifest_info->author->lang = strdup(coltxt[i]);
1076 info->manifest_info->icon->lang = strdup(coltxt[i]);
1077 info->manifest_info->label->lang = strdup(coltxt[i]);
1078 info->manifest_info->description->lang = strdup(coltxt[i]);
1081 info->manifest_info->author->lang = NULL;
1082 info->manifest_info->icon->lang = NULL;
1083 info->manifest_info->label->lang = NULL;
1084 info->manifest_info->description->lang = NULL;
1086 } else if (strcmp(colname[i], "package_url") == 0 ){
1088 info->manifest_info->package_url = strdup(coltxt[i]);
1090 info->manifest_info->package_url = NULL;
1098 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1100 if ( strcasecmp(comp, "uiapp") == 0)
1101 return PMINFO_UI_APP;
1102 else if ( strcasecmp(comp, "svcapp") == 0)
1103 return PMINFO_SVC_APP;
1108 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1110 pkgmgr_certindexinfo_x *info = (pkgmgr_certindexinfo_x *)data;
1112 for(i = 0; i < ncols; i++) {
1113 if (strcmp(colname[i], "cert_id") == 0) {
1115 info->cert_id = atoi(coltxt[i]);
1118 } else if (strcmp(colname[i], "cert_ref_count") == 0) {
1120 info->cert_ref_count = atoi(coltxt[i]);
1122 info->cert_ref_count = 0;
1128 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1130 pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)data;
1132 for(i = 0; i < ncols; i++)
1134 if (strcmp(colname[i], "package") == 0) {
1136 info->pkgid = strdup(coltxt[i]);
1139 } else if (strcmp(colname[i], "author_signer_cert") == 0) {
1141 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = atoi(coltxt[i]);
1143 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = 0;
1144 } else if (strcmp(colname[i], "author_im_cert") == 0) {
1146 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1148 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 0;
1149 } else if (strcmp(colname[i], "author_root_cert") == 0) {
1151 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = atoi(coltxt[i]);
1153 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = 0;
1154 } else if (strcmp(colname[i], "dist_signer_cert") == 0 ){
1156 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = atoi(coltxt[i]);
1158 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 0;
1159 } else if (strcmp(colname[i], "dist_im_cert") == 0 ){
1161 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1163 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 0;
1164 } else if (strcmp(colname[i], "dist_root_cert") == 0 ){
1166 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = atoi(coltxt[i]);
1168 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = 0;
1169 } else if (strcmp(colname[i], "dist2_signer_cert") == 0 ){
1171 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = atoi(coltxt[i]);
1173 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 0;
1174 } else if (strcmp(colname[i], "dist2_im_cert") == 0 ){
1176 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1178 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 0;
1179 } else if (strcmp(colname[i], "dist2_root_cert") == 0 ){
1181 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = atoi(coltxt[i]);
1183 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 0;
1184 } else if (strcmp(colname[i], "cert_info") == 0 ){
1186 info->cert_value = strdup(coltxt[i]);
1188 info->cert_value = NULL;
1195 static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1197 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1199 uiapplication_x *uiapp = NULL;
1200 uiapp = calloc(1, sizeof(uiapplication_x));
1201 if (uiapp == NULL) {
1202 _LOGE("Out of Memory!!!\n");
1206 LISTADD(info->uiapp_info, uiapp);
1208 for(i = 0; i < ncols; i++)
1210 if (strcmp(colname[i], "app_id") == 0) {
1211 /*appid being foreign key, is column in every table
1212 Hence appid gets strduped every time leading to memory leak.
1213 If appid is already set, just continue.*/
1214 if (info->uiapp_info->appid)
1217 info->uiapp_info->appid = strdup(coltxt[i]);
1219 info->uiapp_info->appid = NULL;
1220 } else if (strcmp(colname[i], "app_exec") == 0) {
1222 info->uiapp_info->exec = strdup(coltxt[i]);
1224 info->uiapp_info->exec = NULL;
1225 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1227 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1229 info->uiapp_info->nodisplay = NULL;
1230 } else if (strcmp(colname[i], "app_type") == 0 ) {
1232 info->uiapp_info->type = strdup(coltxt[i]);
1234 info->uiapp_info->type = NULL;
1235 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1237 info->uiapp_info->multiple = strdup(coltxt[i]);
1239 info->uiapp_info->multiple = NULL;
1240 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1242 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1244 info->uiapp_info->taskmanage = NULL;
1245 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1247 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1249 info->uiapp_info->hwacceleration = NULL;
1250 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1252 info->uiapp_info->enabled= strdup(coltxt[i]);
1254 info->uiapp_info->enabled = NULL;
1255 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1257 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1259 info->uiapp_info->indicatordisplay = NULL;
1260 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1262 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1264 info->uiapp_info->portraitimg = NULL;
1265 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1267 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1269 info->uiapp_info->landscapeimg = NULL;
1270 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1272 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1274 info->uiapp_info->guestmode_visibility = NULL;
1275 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1277 info->uiapp_info->recentimage = strdup(coltxt[i]);
1279 info->uiapp_info->recentimage = NULL;
1280 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1282 info->uiapp_info->mainapp = strdup(coltxt[i]);
1284 info->uiapp_info->mainapp = NULL;
1285 } else if (strcmp(colname[i], "package") == 0 ) {
1287 info->uiapp_info->package = strdup(coltxt[i]);
1289 info->uiapp_info->package = NULL;
1290 } else if (strcmp(colname[i], "app_component") == 0) {
1292 info->uiapp_info->app_component = strdup(coltxt[i]);
1294 info->uiapp_info->app_component = NULL;
1295 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1297 info->uiapp_info->permission_type = strdup(coltxt[i]);
1299 info->uiapp_info->permission_type = NULL;
1307 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1309 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1311 icon_x *icon = NULL;
1312 label_x *label = NULL;
1313 category_x *category = NULL;
1314 metadata_x *metadata = NULL;
1315 permission_x *permission = NULL;
1316 image_x *image = NULL;
1318 switch (info->app_component) {
1320 icon = calloc(1, sizeof(icon_x));
1321 LISTADD(info->uiapp_info->icon, icon);
1322 label = calloc(1, sizeof(label_x));
1323 LISTADD(info->uiapp_info->label, label);
1324 category = calloc(1, sizeof(category_x));
1325 LISTADD(info->uiapp_info->category, category);
1326 metadata = calloc(1, sizeof(metadata_x));
1327 LISTADD(info->uiapp_info->metadata, metadata);
1328 permission = calloc(1, sizeof(permission_x));
1329 LISTADD(info->uiapp_info->permission, permission);
1330 image = calloc(1, sizeof(image_x));
1331 LISTADD(info->uiapp_info->image, image);
1333 for(i = 0; i < ncols; i++)
1335 if (strcmp(colname[i], "app_id") == 0) {
1336 /*appid being foreign key, is column in every table
1337 Hence appid gets strduped every time leading to memory leak.
1338 If appid is already set, just continue.*/
1339 if (info->uiapp_info->appid)
1342 info->uiapp_info->appid = strdup(coltxt[i]);
1344 info->uiapp_info->appid = NULL;
1345 } else if (strcmp(colname[i], "app_exec") == 0) {
1347 info->uiapp_info->exec = strdup(coltxt[i]);
1349 info->uiapp_info->exec = NULL;
1350 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1352 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1354 info->uiapp_info->nodisplay = NULL;
1355 } else if (strcmp(colname[i], "app_type") == 0 ) {
1357 info->uiapp_info->type = strdup(coltxt[i]);
1359 info->uiapp_info->type = NULL;
1360 } else if (strcmp(colname[i], "app_icon_section") == 0 ) {
1362 info->uiapp_info->icon->section= strdup(coltxt[i]);
1364 info->uiapp_info->icon->section = NULL;
1365 } else if (strcmp(colname[i], "app_icon") == 0) {
1367 info->uiapp_info->icon->text = strdup(coltxt[i]);
1369 info->uiapp_info->icon->text = NULL;
1370 } else if (strcmp(colname[i], "app_label") == 0 ) {
1372 info->uiapp_info->label->text = strdup(coltxt[i]);
1374 info->uiapp_info->label->text = NULL;
1375 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1377 info->uiapp_info->multiple = strdup(coltxt[i]);
1379 info->uiapp_info->multiple = NULL;
1380 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1382 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1384 info->uiapp_info->taskmanage = NULL;
1385 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1387 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1389 info->uiapp_info->hwacceleration = NULL;
1390 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1392 info->uiapp_info->enabled= strdup(coltxt[i]);
1394 info->uiapp_info->enabled = NULL;
1395 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1397 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1399 info->uiapp_info->indicatordisplay = NULL;
1400 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1402 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1404 info->uiapp_info->portraitimg = NULL;
1405 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1407 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1409 info->uiapp_info->landscapeimg = NULL;
1410 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1412 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1414 info->uiapp_info->guestmode_visibility = NULL;
1415 } else if (strcmp(colname[i], "category") == 0 ) {
1417 info->uiapp_info->category->name = strdup(coltxt[i]);
1419 info->uiapp_info->category->name = NULL;
1420 } else if (strcmp(colname[i], "md_key") == 0 ) {
1422 info->uiapp_info->metadata->key = strdup(coltxt[i]);
1424 info->uiapp_info->metadata->key = NULL;
1425 } else if (strcmp(colname[i], "md_value") == 0 ) {
1427 info->uiapp_info->metadata->value = strdup(coltxt[i]);
1429 info->uiapp_info->metadata->value = NULL;
1430 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1432 info->uiapp_info->permission->type= strdup(coltxt[i]);
1434 info->uiapp_info->permission->type = NULL;
1435 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1437 info->uiapp_info->permission->value = strdup(coltxt[i]);
1439 info->uiapp_info->permission->value = NULL;
1440 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1442 info->uiapp_info->recentimage = strdup(coltxt[i]);
1444 info->uiapp_info->recentimage = NULL;
1445 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1447 info->uiapp_info->mainapp = strdup(coltxt[i]);
1449 info->uiapp_info->mainapp = NULL;
1450 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1452 info->uiapp_info->icon->lang = strdup(coltxt[i]);
1453 info->uiapp_info->label->lang = strdup(coltxt[i]);
1456 info->uiapp_info->icon->lang = NULL;
1457 info->uiapp_info->label->lang = NULL;
1459 } else if (strcmp(colname[i], "app_image") == 0) {
1461 info->uiapp_info->image->text= strdup(coltxt[i]);
1463 info->uiapp_info->image->text = NULL;
1464 } else if (strcmp(colname[i], "app_image_section") == 0) {
1466 info->uiapp_info->image->section= strdup(coltxt[i]);
1468 info->uiapp_info->image->section = NULL;
1469 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1471 info->uiapp_info->permission_type = strdup(coltxt[i]);
1473 info->uiapp_info->permission_type = NULL;
1478 case PMINFO_SVC_APP:
1479 icon = calloc(1, sizeof(icon_x));
1480 LISTADD(info->svcapp_info->icon, icon);
1481 label = calloc(1, sizeof(label_x));
1482 LISTADD(info->svcapp_info->label, label);
1483 category = calloc(1, sizeof(category_x));
1484 LISTADD(info->svcapp_info->category, category);
1485 metadata = calloc(1, sizeof(metadata_x));
1486 LISTADD(info->svcapp_info->metadata, metadata);
1487 permission = calloc(1, sizeof(permission_x));
1488 LISTADD(info->svcapp_info->permission, permission);
1489 for(i = 0; i < ncols; i++)
1491 if (strcmp(colname[i], "app_id") == 0) {
1492 /*appid being foreign key, is column in every table
1493 Hence appid gets strduped every time leading to memory leak.
1494 If appid is already set, just continue.*/
1495 if (info->svcapp_info->appid)
1498 info->svcapp_info->appid = strdup(coltxt[i]);
1500 info->svcapp_info->appid = NULL;
1501 } else if (strcmp(colname[i], "app_exec") == 0) {
1503 info->svcapp_info->exec = strdup(coltxt[i]);
1505 info->svcapp_info->exec = NULL;
1506 } else if (strcmp(colname[i], "app_icon") == 0) {
1508 info->svcapp_info->icon->text = strdup(coltxt[i]);
1510 info->svcapp_info->icon->text = NULL;
1511 } else if (strcmp(colname[i], "app_label") == 0 ) {
1513 info->svcapp_info->label->text = strdup(coltxt[i]);
1515 info->svcapp_info->label->text = NULL;
1516 } else if (strcmp(colname[i], "app_type") == 0 ) {
1518 info->svcapp_info->type = strdup(coltxt[i]);
1520 info->svcapp_info->type = NULL;
1521 } else if (strcmp(colname[i], "app_onboot") == 0 ) {
1523 info->svcapp_info->onboot = strdup(coltxt[i]);
1525 info->svcapp_info->onboot = NULL;
1526 } else if (strcmp(colname[i], "app_autorestart") == 0 ) {
1528 info->svcapp_info->autorestart = strdup(coltxt[i]);
1530 info->svcapp_info->autorestart = NULL;
1531 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1533 info->svcapp_info->enabled= strdup(coltxt[i]);
1535 info->svcapp_info->enabled = NULL;
1536 } else if (strcmp(colname[i], "category") == 0 ) {
1538 info->svcapp_info->category->name = strdup(coltxt[i]);
1540 info->svcapp_info->category->name = NULL;
1541 } else if (strcmp(colname[i], "md_key") == 0 ) {
1543 info->svcapp_info->metadata->key = strdup(coltxt[i]);
1545 info->svcapp_info->metadata->key = NULL;
1546 } else if (strcmp(colname[i], "md_value") == 0 ) {
1548 info->svcapp_info->metadata->value = strdup(coltxt[i]);
1550 info->svcapp_info->metadata->value = NULL;
1551 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1553 info->svcapp_info->permission->type= strdup(coltxt[i]);
1555 info->svcapp_info->permission->type = NULL;
1556 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1558 info->svcapp_info->permission->value = strdup(coltxt[i]);
1560 info->svcapp_info->permission->value = NULL;
1561 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1563 info->svcapp_info->icon->lang = strdup(coltxt[i]);
1564 info->svcapp_info->label->lang = strdup(coltxt[i]);
1567 info->svcapp_info->icon->lang = NULL;
1568 info->svcapp_info->label->lang = NULL;
1570 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1572 info->svcapp_info->permission_type = strdup(coltxt[i]);
1574 info->svcapp_info->permission_type = NULL;
1587 static int __appcomponent_cb(void *data, int ncols, char **coltxt, char **colname)
1589 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1591 for(i = 0; i < ncols; i++)
1593 if (strcmp(colname[i], "app_component") == 0) {
1594 info->app_component = __appcomponent_convert(coltxt[i]);
1595 } else if (strcmp(colname[i], "package") == 0) {
1596 info->package = strdup(coltxt[i]);
1603 static int __datacontrol_cb(void *data, int ncols, char **coltxt, char **colname)
1605 pkgmgr_datacontrol_x *info = (pkgmgr_datacontrol_x *)data;
1607 for(i = 0; i < ncols; i++)
1609 if (strcmp(colname[i], "PACKAGE_NAME") == 0) {
1611 info->appid = strdup(coltxt[i]);
1614 } else if (strcmp(colname[i], "ACCESS") == 0 ){
1616 info->access = strdup(coltxt[i]);
1618 info->access = NULL;
1625 static int __cert_cb(void *data, int ncols, char **coltxt, char **colname)
1627 pkgmgr_cert_x *info = (pkgmgr_cert_x *)data;
1630 for(i = 0; i < ncols; i++)
1632 if (strcmp(colname[i], "author_signer_cert") == 0) {
1634 info->cert_id = atoi(coltxt[i]);
1637 } else if (strcmp(colname[i], "package") == 0) {
1639 info->pkgid= strdup(coltxt[i]);
1648 /* get the first locale value*/
1649 static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
1651 pkgmgr_locale_x *info = (pkgmgr_locale_x *)data;
1654 info->locale = strdup(coltxt[0]);
1656 info->locale = NULL;
1661 static int __exec_pkginfo_query(char *query, void *data)
1663 char *error_message = NULL;
1665 sqlite3_exec(manifest_db, query, __pkginfo_cb, data, &error_message)) {
1666 _LOGE("Don't execute query = %s error message = %s\n", query,
1668 sqlite3_free(error_message);
1671 sqlite3_free(error_message);
1675 static int __exec_certinfo_query(char *query, void *data)
1677 char *error_message = NULL;
1679 sqlite3_exec(cert_db, query, __certinfo_cb, data, &error_message)) {
1680 _LOGE("Don't execute query = %s error message = %s\n", query,
1682 sqlite3_free(error_message);
1685 sqlite3_free(error_message);
1689 static int __exec_certindexinfo_query(char *query, void *data)
1691 char *error_message = NULL;
1693 sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
1694 _LOGE("Don't execute query = %s error message = %s\n", query,
1696 sqlite3_free(error_message);
1699 sqlite3_free(error_message);
1703 static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data)
1705 char *error_message = NULL;
1707 sqlite3_exec(db, query, callback, data, &error_message)) {
1708 _LOGE("Don't execute query = %s error message = %s\n", query,
1710 sqlite3_free(error_message);
1713 sqlite3_free(error_message);
1718 static int __child_element(xmlTextReaderPtr reader, int depth)
1720 int ret = xmlTextReaderRead(reader);
1721 int cur = xmlTextReaderDepth(reader);
1724 switch (xmlTextReaderNodeType(reader)) {
1725 case XML_READER_TYPE_ELEMENT:
1726 if (cur == depth + 1)
1729 case XML_READER_TYPE_TEXT:
1730 /*text is handled by each function separately*/
1731 if (cur == depth + 1)
1734 case XML_READER_TYPE_END_ELEMENT:
1743 ret = xmlTextReaderRead(reader);
1744 cur = xmlTextReaderDepth(reader);
1749 static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, char **colname)
1751 int *p = (int*)data;
1752 *p = atoi(coltxt[0]);
1756 static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale)
1758 int result_query = -1;
1760 char query[MAX_QUERY_LEN];
1762 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);
1763 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1764 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1765 return result_query;
1768 static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1770 int result_query = -1;
1772 char wildcard[2] = {'%','\0'};
1773 char query[MAX_QUERY_LEN];
1774 char lang[3] = {'\0'};
1775 strncpy(lang, locale, LANGUAGE_LENGTH);
1777 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);
1778 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1779 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1780 return result_query;
1783 static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1786 char wildcard[2] = {'%','\0'};
1787 char lang[3] = {'\0'};
1788 char query[MAX_QUERY_LEN];
1789 char *locale_new = NULL;
1790 pkgmgr_locale_x *info = NULL;
1792 info = (pkgmgr_locale_x *)malloc(sizeof(pkgmgr_locale_x));
1794 _LOGE("Out of Memory!!!\n");
1797 memset(info, '\0', sizeof(*info));
1799 strncpy(lang, locale, 2);
1800 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);
1801 ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
1802 tryvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1803 locale_new = info->locale;
1814 static char* __convert_syslocale_to_manifest_locale(char *syslocale)
1816 char *locale = malloc(6);
1818 _LOGE("Malloc Failed\n");
1822 sprintf(locale, "%c%c-%c%c", syslocale[0], syslocale[1], tolower(syslocale[3]), tolower(syslocale[4]));
1826 static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const char *syslocale)
1831 char *locale = NULL;
1832 char *locale_new = NULL;
1833 int check_result = 0;
1835 locale = __convert_syslocale_to_manifest_locale((char *)syslocale);
1837 /*check exact matching */
1838 check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale);
1841 if (check_result == 1) {
1842 _LOGD("%s find exact locale(%s)\n", appid, locale);
1846 /* fallback matching */
1847 check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
1848 if(check_result == 1) {
1849 locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
1850 _LOGD("%s found (%s) language-locale in DB by fallback!\n", appid, locale_new);
1852 if (locale_new == NULL)
1853 locale_new = strdup(DEFAULT_LOCALE);
1857 /* default locale */
1859 _LOGD("%s DEFAULT_LOCALE)\n", appid);
1860 return strdup(DEFAULT_LOCALE);
1863 long long _pkgmgr_calculate_dir_size(char *dirname)
1865 long long total = 0;
1867 int q = 0; /*quotient*/
1868 int r = 0; /*remainder*/
1870 struct dirent *ep = NULL;
1871 struct stat fileinfo;
1872 char abs_filename[FILENAME_MAX] = { 0, };
1873 retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL");
1875 dp = opendir(dirname);
1877 while ((ep = readdir(dp)) != NULL) {
1878 if (!strcmp(ep->d_name, ".") ||
1879 !strcmp(ep->d_name, "..")) {
1882 snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
1884 if (lstat(abs_filename, &fileinfo) < 0)
1885 perror(abs_filename);
1887 if (S_ISDIR(fileinfo.st_mode)) {
1888 total += fileinfo.st_size;
1889 if (strcmp(ep->d_name, ".")
1890 && strcmp(ep->d_name, "..")) {
1891 ret = _pkgmgr_calculate_dir_size
1893 total = total + ret;
1895 } else if (S_ISLNK(fileinfo.st_mode)) {
1898 /*It is a file. Calculate the actual
1899 size occupied (in terms of 4096 blocks)*/
1900 q = (fileinfo.st_size / BLOCK_SIZE);
1901 r = (fileinfo.st_size % BLOCK_SIZE);
1905 total += q * BLOCK_SIZE;
1911 _LOGE("Couldn't open the directory\n");
1918 static int __delete_certinfo(const char *pkgid)
1924 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
1925 char *error_message = NULL;
1926 char query[MAX_QUERY_LEN] = {'\0'};
1927 pkgmgr_certinfo_x *certinfo = NULL;
1928 pkgmgr_certindexinfo_x *indexinfo = NULL;
1929 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
1930 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
1931 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
1932 if (indexinfo == NULL) {
1933 _LOGE("Out of Memory!!!");
1934 ret = PMINFO_R_ERROR;
1937 /*populate certinfo from DB*/
1938 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
1939 ret = __exec_certinfo_query(query, (void *)certinfo);
1941 _LOGE("Package Cert Info DB Information retrieval failed\n");
1942 ret = PMINFO_R_ERROR;
1945 /*Update cert index table*/
1946 for (i = 0; i < MAX_CERT_TYPE; i++) {
1947 if ((certinfo->cert_id)[i]) {
1948 for (j = 0; j < MAX_CERT_TYPE; j++) {
1949 if ((certinfo->cert_id)[i] == unique_id[j]) {
1950 /*Ref count has already been updated. Just continue*/
1954 if (j == MAX_CERT_TYPE)
1955 unique_id[c++] = (certinfo->cert_id)[i];
1958 memset(query, '\0', MAX_QUERY_LEN);
1959 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
1960 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
1962 _LOGE("Cert Info DB Information retrieval failed\n");
1963 ret = PMINFO_R_ERROR;
1966 memset(query, '\0', MAX_QUERY_LEN);
1967 if (indexinfo->cert_ref_count > 1) {
1968 /*decrease ref count*/
1969 snprintf(query, MAX_QUERY_LEN, "update package_cert_index_info set cert_ref_count=%d where cert_id=%d ",
1970 indexinfo->cert_ref_count - 1, (certinfo->cert_id)[i]);
1972 /*delete this certificate as ref count is 1 and it will become 0*/
1973 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
1976 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
1977 _LOGE("Don't execute query = %s error message = %s\n", query,
1979 sqlite3_free(error_message);
1980 ret = PMINFO_R_ERROR;
1985 /*Now delete the entry from db*/
1986 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
1988 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
1989 _LOGE("Don't execute query = %s error message = %s\n", query,
1991 sqlite3_free(error_message);
1992 ret = PMINFO_R_ERROR;
2001 if (certinfo->pkgid) {
2002 free(certinfo->pkgid);
2003 certinfo->pkgid = NULL;
2005 for (i = 0; i < MAX_CERT_TYPE; i++) {
2006 if ((certinfo->cert_info)[i]) {
2007 free((certinfo->cert_info)[i]);
2008 (certinfo->cert_info)[i] = NULL;
2016 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
2018 retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
2019 char *error_message = NULL;
2020 int ret = PMINFO_R_OK;
2021 char query[MAX_QUERY_LEN] = {'\0'};
2022 char *syslocale = NULL;
2023 char *locale = NULL;
2024 pkgmgr_pkginfo_x *pkginfo = NULL;
2025 label_x *tmp1 = NULL;
2026 icon_x *tmp2 = NULL;
2027 description_x *tmp3 = NULL;
2028 author_x *tmp4 = NULL;
2029 privilege_x *tmp5 = NULL;
2031 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2032 if (syslocale == NULL) {
2033 _LOGE("current locale is NULL\n");
2034 ret = PMINFO_R_ERROR;
2037 locale = __convert_system_locale_to_manifest_locale(syslocale);
2038 if (locale == NULL) {
2039 _LOGE("manifest locale is NULL\n");
2040 ret = PMINFO_R_EINVAL;
2044 ret = __open_manifest_db();
2046 _LOGE("Fail to open manifest DB\n");
2047 ret = PMINFO_R_ERROR;
2050 pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2051 pkgmgr_pkginfo_x *node = NULL;
2052 pkgmgr_pkginfo_x *temp_node = NULL;
2054 snprintf(query, MAX_QUERY_LEN, "select * from package_info");
2056 sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
2057 _LOGE("Don't execute query = %s error message = %s\n", query,
2059 sqlite3_free(error_message);
2060 sqlite3_close(manifest_db);
2061 ret = PMINFO_R_ERROR;
2065 LISTHEAD(tmphead, node);
2067 for(node = node->next; node ; node = node->next) {
2069 pkginfo->locale = strdup(locale);
2070 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2071 if (pkginfo->manifest_info->privileges == NULL) {
2072 _LOGE("Failed to allocate memory for privileges info\n");
2073 ret = PMINFO_R_ERROR;
2076 /*populate manifest_info from DB*/
2077 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
2078 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2080 _LOGE("Package Info DB Information retrieval failed\n");
2081 ret = PMINFO_R_ERROR;
2084 memset(query, '\0', MAX_QUERY_LEN);
2085 /*populate privilege_info from DB*/
2086 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package);
2087 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2089 _LOGE("Package Privilege Info DB Information retrieval failed\n");
2090 ret = PMINFO_R_ERROR;
2093 memset(query, '\0', MAX_QUERY_LEN);
2094 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2095 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
2096 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2098 _LOGE("Package Info DB Information retrieval failed\n");
2099 ret = PMINFO_R_ERROR;
2102 /*Also store the values corresponding to default locales*/
2103 memset(query, '\0', MAX_QUERY_LEN);
2104 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2105 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
2106 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2108 _LOGE("Package Info DB Information retrieval failed\n");
2109 ret = PMINFO_R_ERROR;
2112 if (pkginfo->manifest_info->label) {
2113 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2114 pkginfo->manifest_info->label = tmp1;
2116 if (pkginfo->manifest_info->icon) {
2117 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2118 pkginfo->manifest_info->icon = tmp2;
2120 if (pkginfo->manifest_info->description) {
2121 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2122 pkginfo->manifest_info->description = tmp3;
2124 if (pkginfo->manifest_info->author) {
2125 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2126 pkginfo->manifest_info->author = tmp4;
2128 if (pkginfo->manifest_info->privileges->privilege) {
2129 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2130 pkginfo->manifest_info->privileges->privilege = tmp5;
2134 LISTHEAD(tmphead, node);
2136 for(node = node->next; node ; node = node->next) {
2138 ret = pkg_list_cb( (void *)pkginfo, user_data);
2146 sqlite3_close(manifest_db);
2155 LISTHEAD(tmphead, node);
2156 temp_node = node->next;
2159 temp_node = node->next;
2160 __cleanup_pkginfo(node);
2163 __cleanup_pkginfo(tmphead);
2168 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
2170 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
2171 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2172 pkgmgr_pkginfo_x *pkginfo = NULL;
2173 int ret = PMINFO_R_OK;
2174 char query[MAX_QUERY_LEN] = {'\0'};
2175 char *syslocale = NULL;
2176 char *locale = NULL;
2178 label_x *tmp1 = NULL;
2179 icon_x *tmp2 = NULL;
2180 description_x *tmp3 = NULL;
2181 author_x *tmp4 = NULL;
2182 privilege_x *tmp5 = NULL;
2183 sqlite3 *pkginfo_db = NULL;
2186 ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
2187 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2189 /*check pkgid exist on db*/
2190 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
2191 ret = __exec_db_query(pkginfo_db, query, __validate_cb, (void *)&exist);
2192 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
2193 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] not found in DB", pkgid);
2195 /*get system locale*/
2196 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2197 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
2199 /*get locale on db*/
2200 locale = __convert_system_locale_to_manifest_locale(syslocale);
2201 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
2203 pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2204 tryvm_if(pkginfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for pkginfo");
2206 pkginfo->locale = strdup(locale);
2208 pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
2209 tryvm_if(pkginfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for manifest info");
2211 pkginfo->manifest_info->package = strdup(pkgid);
2212 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2213 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info");
2215 /*populate manifest_info from DB*/
2216 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
2217 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2218 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2220 memset(query, '\0', MAX_QUERY_LEN);
2221 /*populate privilege_info from DB*/
2222 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
2223 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2224 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
2226 memset(query, '\0', MAX_QUERY_LEN);
2227 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2228 " package='%s' and package_locale='%s'", pkgid, locale);
2229 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2230 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2232 /*Also store the values corresponding to default locales*/
2233 memset(query, '\0', MAX_QUERY_LEN);
2234 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2235 " package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
2236 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2237 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2239 if (pkginfo->manifest_info->label) {
2240 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2241 pkginfo->manifest_info->label = tmp1;
2243 if (pkginfo->manifest_info->icon) {
2244 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2245 pkginfo->manifest_info->icon = tmp2;
2247 if (pkginfo->manifest_info->description) {
2248 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2249 pkginfo->manifest_info->description = tmp3;
2251 if (pkginfo->manifest_info->author) {
2252 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2253 pkginfo->manifest_info->author = tmp4;
2255 if (pkginfo->manifest_info->privileges->privilege) {
2256 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2257 pkginfo->manifest_info->privileges->privilege = tmp5;
2261 if (ret == PMINFO_R_OK)
2262 *handle = (void*)pkginfo;
2265 __cleanup_pkginfo(pkginfo);
2267 sqlite3_close(pkginfo_db);
2281 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
2283 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2284 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2285 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2286 if (info->manifest_info->package)
2287 *pkg_name = (char *)info->manifest_info->package;
2289 return PMINFO_R_ERROR;
2294 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
2296 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2297 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2298 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2299 if (info->manifest_info->package)
2300 *pkgid = (char *)info->manifest_info->package;
2302 return PMINFO_R_ERROR;
2307 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
2309 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2310 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2311 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2312 if (info->manifest_info->type)
2313 *type = (char *)info->manifest_info->type;
2319 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
2321 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2322 retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2323 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2324 *version = (char *)info->manifest_info->version;
2328 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
2330 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2331 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2333 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2334 val = (char *)info->manifest_info->installlocation;
2336 if (strcmp(val, "internal-only") == 0)
2337 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2338 else if (strcmp(val, "prefer-external") == 0)
2339 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2341 *location = PMINFO_INSTALL_LOCATION_AUTO;
2346 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
2348 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2349 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2351 char *location = NULL;
2352 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2353 location = (char *)info->manifest_info->installlocation;
2354 val = (char *)info->manifest_info->package_size;
2359 _LOGE("package size is not specified\n");
2360 return PMINFO_R_ERROR;
2365 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
2367 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2368 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2371 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
2372 long long rw_size = 0;
2373 long long ro_size= 0;
2374 long long tmp_size= 0;
2375 long long total_size= 0;
2376 struct stat fileinfo;
2379 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2381 return PMINFO_R_ERROR;
2384 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid);
2385 if (lstat(device_path, &fileinfo) == 0) {
2386 if (!S_ISLNK(fileinfo.st_mode)) {
2387 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2389 rw_size += tmp_size;
2393 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid);
2394 if (lstat(device_path, &fileinfo) == 0) {
2395 if (!S_ISLNK(fileinfo.st_mode)) {
2396 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2398 rw_size += tmp_size;
2402 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid);
2403 if (lstat(device_path, &fileinfo) == 0) {
2404 if (!S_ISLNK(fileinfo.st_mode)) {
2405 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2407 rw_size += tmp_size;
2411 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
2412 if (lstat(device_path, &fileinfo) == 0) {
2413 if (!S_ISLNK(fileinfo.st_mode)) {
2414 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2416 rw_size += tmp_size;
2420 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_PATH, pkgid);
2421 if (lstat(device_path, &fileinfo) == 0) {
2422 if (!S_ISLNK(fileinfo.st_mode)) {
2423 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2425 rw_size += tmp_size;
2429 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_PATH, pkgid);
2430 if (lstat(device_path, &fileinfo) == 0) {
2431 if (!S_ISLNK(fileinfo.st_mode)) {
2432 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2434 rw_size += tmp_size;
2439 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_PATH, pkgid);
2440 if (lstat(device_path, &fileinfo) == 0) {
2441 if (!S_ISLNK(fileinfo.st_mode)) {
2442 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2444 ro_size += tmp_size;
2448 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid);
2449 if (lstat(device_path, &fileinfo) == 0) {
2450 if (!S_ISLNK(fileinfo.st_mode)) {
2451 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2453 ro_size += tmp_size;
2457 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid);
2458 if (lstat(device_path, &fileinfo) == 0) {
2459 if (!S_ISLNK(fileinfo.st_mode)) {
2460 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2462 ro_size += tmp_size;
2466 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid);
2467 if (lstat(device_path, &fileinfo) == 0) {
2468 if (!S_ISLNK(fileinfo.st_mode)) {
2469 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2471 ro_size += tmp_size;
2475 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid);
2476 if (lstat(device_path, &fileinfo) == 0) {
2477 if (!S_ISLNK(fileinfo.st_mode)) {
2478 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2480 ro_size += tmp_size;
2484 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid);
2485 if (lstat(device_path, &fileinfo) == 0) {
2486 if (!S_ISLNK(fileinfo.st_mode)) {
2487 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2489 ro_size += tmp_size;
2494 total_size = rw_size + ro_size;
2495 *size = (int)total_size;
2500 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
2502 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2503 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2506 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
2507 long long total_size= 0;
2510 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2512 return PMINFO_R_ERROR;
2514 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
2515 if (access(device_path, R_OK) == 0)
2516 total_size = _pkgmgr_calculate_dir_size(device_path);
2518 return PMINFO_R_ERROR;
2520 *size = (int)total_size;
2525 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
2527 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2528 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2529 int ret = PMINFO_R_OK;
2530 char *locale = NULL;
2534 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2536 locale = info->locale;
2537 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2539 for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next)
2542 if (strcmp(ptr->lang, locale) == 0) {
2543 *icon = (char *)ptr->text;
2544 if (strcasecmp(*icon, "(null)") == 0) {
2545 locale = DEFAULT_LOCALE;
2549 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2550 *icon = (char *)ptr->text;
2559 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
2561 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2562 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2563 int ret = PMINFO_R_OK;
2564 char *locale = NULL;
2565 label_x *ptr = NULL;
2568 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2569 locale = info->locale;
2570 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2572 for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next)
2575 if (strcmp(ptr->lang, locale) == 0) {
2576 *label = (char *)ptr->text;
2577 if (strcasecmp(*label, "(null)") == 0) {
2578 locale = DEFAULT_LOCALE;
2582 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2583 *label = (char *)ptr->text;
2592 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
2594 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2595 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2596 char *locale = NULL;
2597 description_x *ptr = NULL;
2598 *description = NULL;
2600 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2601 locale = info->locale;
2602 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2604 for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next)
2607 if (strcmp(ptr->lang, locale) == 0) {
2608 *description = (char *)ptr->text;
2609 if (strcasecmp(*description, "(null)") == 0) {
2610 locale = DEFAULT_LOCALE;
2614 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2615 *description = (char *)ptr->text;
2623 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
2625 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2626 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2627 char *locale = NULL;
2628 author_x *ptr = NULL;
2629 *author_name = NULL;
2631 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2632 locale = info->locale;
2633 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2635 for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next)
2638 if (strcmp(ptr->lang, locale) == 0) {
2639 *author_name = (char *)ptr->text;
2640 if (strcasecmp(*author_name, "(null)") == 0) {
2641 locale = DEFAULT_LOCALE;
2645 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2646 *author_name = (char *)ptr->text;
2654 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
2656 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2657 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2658 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2659 *author_email = (char *)info->manifest_info->author->email;
2663 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
2665 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2666 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2667 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2668 *author_href = (char *)info->manifest_info->author->href;
2672 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
2674 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2675 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2678 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
2680 _LOGE("invalid func parameters\n");
2681 return PMINFO_R_ERROR;
2685 char app_mmc_path[FILENAME_MAX] = { 0, };
2686 char app_dir_path[FILENAME_MAX] = { 0, };
2687 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
2688 snprintf(app_dir_path, FILENAME_MAX,
2689 "%s%s", PKG_INSTALLATION_PATH, pkgid);
2690 snprintf(app_mmc_path, FILENAME_MAX,
2691 "%s%s", PKG_SD_PATH, pkgid);
2692 snprintf(app_mmc_internal_path, FILENAME_MAX,
2693 "%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
2695 /*check whether application is in external memory or not */
2696 fp = fopen(app_mmc_path, "r");
2698 _LOGE(" app path in external memory not accesible\n");
2702 *storage = PMINFO_EXTERNAL_STORAGE;
2706 /*check whether application is in internal or not */
2707 fp = fopen(app_dir_path, "r");
2709 _LOGE(" app path in internal memory not accesible\n");
2711 return PMINFO_R_ERROR;
2714 /*check whether the application is installed in SD card
2715 but SD card is not present*/
2716 fp = fopen(app_mmc_internal_path, "r");
2718 *storage = PMINFO_INTERNAL_STORAGE;
2722 *storage = PMINFO_EXTERNAL_STORAGE;
2728 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
2730 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2731 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2732 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2733 if (info->manifest_info->installed_time)
2734 *installed_time = atoi(info->manifest_info->installed_time);
2736 return PMINFO_R_ERROR;
2741 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
2743 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2744 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2745 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2746 *storeclientid = (char *)info->manifest_info->storeclient_id;
2750 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
2752 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2753 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2754 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2755 *mainappid = (char *)info->manifest_info->mainapp_id;
2759 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
2761 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2762 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2763 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2764 *url = (char *)info->manifest_info->package_url;
2768 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
2770 const char *val = NULL;
2771 const xmlChar *node;
2772 xmlTextReaderPtr reader;
2773 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2774 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2777 reader = xmlReaderForFile(manifest, NULL, 0);
2780 if (__child_element(reader, -1)) {
2781 node = xmlTextReaderConstName(reader);
2783 _LOGE("xmlTextReaderConstName value is NULL\n");
2784 xmlFreeTextReader(reader);
2786 return PMINFO_R_ERROR;
2789 if (!strcmp(ASC_CHAR(node), "manifest")) {
2790 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
2791 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
2797 _LOGE("package size is not specified\n");
2798 xmlFreeTextReader(reader);
2800 return PMINFO_R_ERROR;
2803 _LOGE("Unable to create xml reader\n");
2804 xmlFreeTextReader(reader);
2806 return PMINFO_R_ERROR;
2810 _LOGE("xmlReaderForFile value is NULL\n");
2812 return PMINFO_R_ERROR;
2815 xmlFreeTextReader(reader);
2821 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
2823 const char *val = NULL;
2824 const xmlChar *node;
2825 xmlTextReaderPtr reader;
2826 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2827 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2830 reader = xmlReaderForFile(manifest, NULL, 0);
2833 if ( __child_element(reader, -1)) {
2834 node = xmlTextReaderConstName(reader);
2836 _LOGE("xmlTextReaderConstName value is NULL\n");
2837 xmlFreeTextReader(reader);
2839 return PMINFO_R_ERROR;
2842 if (!strcmp(ASC_CHAR(node), "manifest")) {
2843 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
2844 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
2847 if (strcmp(val, "internal-only") == 0)
2848 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2849 else if (strcmp(val, "prefer-external") == 0)
2850 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2852 *location = PMINFO_INSTALL_LOCATION_AUTO;
2855 _LOGE("Unable to create xml reader\n");
2856 xmlFreeTextReader(reader);
2858 return PMINFO_R_ERROR;
2862 _LOGE("xmlReaderForFile value is NULL\n");
2864 return PMINFO_R_ERROR;
2867 xmlFreeTextReader(reader);
2874 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
2876 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2877 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2879 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2880 if (info->manifest_info->root_path)
2881 *path = (char *)info->manifest_info->root_path;
2883 return PMINFO_R_ERROR;
2888 API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
2890 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2891 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2893 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2894 if (info->manifest_info->csc_path)
2895 *path = (char *)info->manifest_info->csc_path;
2897 *path = (char *)info->manifest_info->csc_path;
2902 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)
2904 retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
2905 retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
2906 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2908 int ret = PMINFO_R_OK;
2909 char query[MAX_QUERY_LEN] = {'\0'};
2910 char *error_message = NULL;
2911 pkgmgr_cert_x *info= NULL;
2915 *compare_result = PMINFO_CERT_COMPARE_ERROR;
2916 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
2917 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
2919 ret = db_util_open_with_options(CERT_DB, &cert_db,
2920 SQLITE_OPEN_READONLY, NULL);
2921 if (ret != SQLITE_OK) {
2922 _LOGE("connect db [%s] failed!\n", CERT_DB);
2923 ret = PMINFO_R_ERROR;
2927 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
2929 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
2930 _LOGE("Don't execute query = %s error message = %s\n", query,
2932 ret = PMINFO_R_ERROR;
2939 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
2941 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
2942 _LOGE("Don't execute query = %s error message = %s\n", query,
2944 ret = PMINFO_R_ERROR;
2947 lcert = info->cert_id;
2950 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
2952 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
2953 _LOGE("Don't execute query = %s error message = %s\n", query,
2955 ret = PMINFO_R_ERROR;
2962 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
2964 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
2965 _LOGE("Don't execute query = %s error message = %s\n", query,
2967 ret = PMINFO_R_ERROR;
2970 rcert = info->cert_id;
2973 if ((lcert == 0) || (rcert == 0))
2975 if ((lcert == 0) && (rcert == 0))
2976 *compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
2977 else if (lcert == 0)
2978 *compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
2979 else if (rcert == 0)
2980 *compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
2983 *compare_result = PMINFO_CERT_COMPARE_MATCH;
2985 *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
2989 sqlite3_free(error_message);
2990 sqlite3_close(cert_db);
3003 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)
3005 retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
3006 retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
3007 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3009 int ret = PMINFO_R_OK;
3010 char query[MAX_QUERY_LEN] = {'\0'};
3011 char *error_message = NULL;
3012 pkgmgr_cert_x *info= NULL;
3014 char *lpkgid = NULL;
3015 char *rpkgid = NULL;
3017 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3018 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3020 ret = db_util_open_with_options(MANIFEST_DB, &manifest_db,
3021 SQLITE_OPEN_READONLY, NULL);
3022 if (ret != SQLITE_OK) {
3023 _LOGE("connect db [%s] failed!\n", MANIFEST_DB);
3024 ret = PMINFO_R_ERROR;
3028 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
3030 sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
3031 _LOGE("Don't execute query = %s error message = %s\n", query,
3033 ret = PMINFO_R_ERROR;
3040 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
3042 sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
3043 _LOGE("Don't execute query = %s error message = %s\n", query,
3045 ret = PMINFO_R_ERROR;
3048 lpkgid = strdup(info->pkgid);
3049 if (lpkgid == NULL) {
3050 _LOGE("Out of Memory\n");
3051 ret = PMINFO_R_ERROR;
3058 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
3060 sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
3061 _LOGE("Don't execute query = %s error message = %s\n", query,
3063 ret = PMINFO_R_ERROR;
3070 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
3072 sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
3073 _LOGE("Don't execute query = %s error message = %s\n", query,
3075 ret = PMINFO_R_ERROR;
3078 rpkgid = strdup(info->pkgid);
3079 if (rpkgid == NULL) {
3080 _LOGE("Out of Memory\n");
3081 ret = PMINFO_R_ERROR;
3087 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
3089 sqlite3_free(error_message);
3090 sqlite3_close(manifest_db);
3110 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
3112 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3113 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3115 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
3117 _LOGD("invalid func parameters\n");
3118 return PMINFO_R_ERROR;
3120 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
3123 char app_mmc_path[FILENAME_MAX] = { 0, };
3124 char app_dir_path[FILENAME_MAX] = { 0, };
3125 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
3126 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
3127 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
3128 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
3130 /*check whether application is in external memory or not */
3131 fp = fopen(app_mmc_path, "r");
3133 _LOGD(" app path in external memory not accesible\n");
3138 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
3142 /*check whether application is in internal or not */
3143 fp = fopen(app_dir_path, "r");
3145 _LOGD(" app path in internal memory not accesible\n");
3147 return PMINFO_R_ERROR;
3150 /*check whether the application is installed in SD card
3151 but SD card is not present*/
3152 fp = fopen(app_mmc_internal_path, "r");
3155 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
3160 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
3165 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
3169 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
3171 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3172 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3174 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3175 val = (char *)info->manifest_info->removable;
3177 if (strcasecmp(val, "true") == 0)
3179 else if (strcasecmp(val, "false") == 0)
3187 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
3189 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3190 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3193 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3195 val = (char *)info->manifest_info->installlocation;
3197 if (strcmp(val, "internal-only") == 0)
3199 else if (strcmp(val, "prefer-external") == 0)
3208 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
3210 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3211 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3213 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3214 val = (char *)info->manifest_info->preload;
3216 if (strcasecmp(val, "true") == 0)
3218 else if (strcasecmp(val, "false") == 0)
3226 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
3228 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3229 retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3231 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3232 val = (char *)info->manifest_info->readonly;
3234 if (strcasecmp(val, "true") == 0)
3236 else if (strcasecmp(val, "false") == 0)
3244 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
3246 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3247 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3250 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3251 val = (char *)info->manifest_info->update;
3253 if (strcasecmp(val, "true") == 0)
3255 else if (strcasecmp(val, "false") == 0)
3263 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
3265 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3266 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3267 __cleanup_pkginfo(info);
3271 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
3273 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
3275 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
3276 if (filter == NULL) {
3277 _LOGE("Out of Memory!!!");
3278 return PMINFO_R_ERROR;
3284 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
3286 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3287 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3289 g_slist_foreach(filter->list, __destroy_each_node, NULL);
3290 g_slist_free(filter->list);
3297 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
3298 const char *property, const int value)
3300 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3301 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3302 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3304 GSList *link = NULL;
3306 prop = _pminfo_pkginfo_convert_to_prop_int(property);
3307 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
3308 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
3309 _LOGE("Invalid Integer Property\n");
3310 return PMINFO_R_EINVAL;
3312 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3313 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3315 _LOGE("Out of Memory!!!\n");
3316 return PMINFO_R_ERROR;
3318 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3319 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3321 _LOGE("Out of Memory\n");
3324 return PMINFO_R_ERROR;
3328 /*If API is called multiple times for same property, we should override the previous values.
3329 Last value set will be used for filtering.*/
3330 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3332 filter->list = g_slist_delete_link(filter->list, link);
3333 filter->list = g_slist_append(filter->list, (gpointer)node);
3338 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
3339 const char *property, const bool value)
3341 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3342 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3344 GSList *link = NULL;
3346 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
3347 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
3348 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
3349 _LOGE("Invalid Boolean Property\n");
3350 return PMINFO_R_EINVAL;
3352 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3353 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3355 _LOGE("Out of Memory!!!\n");
3356 return PMINFO_R_ERROR;
3359 val = strndup("('true','True')", 15);
3361 val = strndup("('false','False')", 17);
3363 _LOGE("Out of Memory\n");
3366 return PMINFO_R_ERROR;
3370 /*If API is called multiple times for same property, we should override the previous values.
3371 Last value set will be used for filtering.*/
3372 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3374 filter->list = g_slist_delete_link(filter->list, link);
3375 filter->list = g_slist_append(filter->list, (gpointer)node);
3380 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
3381 const char *property, const char *value)
3383 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3384 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3385 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3387 GSList *link = NULL;
3389 prop = _pminfo_pkginfo_convert_to_prop_str(property);
3390 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
3391 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
3392 _LOGE("Invalid String Property\n");
3393 return PMINFO_R_EINVAL;
3395 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3396 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3398 _LOGE("Out of Memory!!!\n");
3399 return PMINFO_R_ERROR;
3401 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
3402 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
3403 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
3404 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
3405 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
3406 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
3407 else if (strcmp(value, "installed_internal") == 0)
3408 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
3409 else if (strcmp(value, "installed_external") == 0)
3410 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
3412 val = strndup(value, PKG_STRING_LEN_MAX - 1);
3414 _LOGE("Out of Memory\n");
3417 return PMINFO_R_ERROR;
3421 /*If API is called multiple times for same property, we should override the previous values.
3422 Last value set will be used for filtering.*/
3423 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3425 filter->list = g_slist_delete_link(filter->list, link);
3426 filter->list = g_slist_append(filter->list, (gpointer)node);
3431 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
3433 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3434 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3435 char *syslocale = NULL;
3436 char *locale = NULL;
3437 char *condition = NULL;
3438 char *error_message = NULL;
3439 char query[MAX_QUERY_LEN] = {'\0'};
3440 char where[MAX_QUERY_LEN] = {'\0'};
3444 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3445 /*Get current locale*/
3446 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3447 if (syslocale == NULL) {
3448 _LOGE("current locale is NULL\n");
3449 return PMINFO_R_ERROR;
3451 locale = __convert_system_locale_to_manifest_locale(syslocale);
3452 if (locale == NULL) {
3453 _LOGE("manifest locale is NULL\n");
3455 return PMINFO_R_ERROR;
3458 ret = __open_manifest_db();
3460 _LOGE("Fail to open manifest DB\n");
3461 ret = PMINFO_R_ERROR;
3465 /*Start constructing query*/
3466 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_PACKAGE, locale);
3468 /*Get where clause*/
3469 for (list = filter->list; list; list = g_slist_next(list)) {
3470 __get_filter_condition(list->data, &condition);
3472 strncat(where, condition, sizeof(where) - strlen(where) -1);
3473 where[sizeof(where) - 1] = '\0';
3477 if (g_slist_next(list)) {
3478 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3479 where[sizeof(where) - 1] = '\0';
3482 _LOGE("where = %s\n", where);
3483 if (strlen(where) > 0) {
3484 strncat(query, where, sizeof(query) - strlen(query) - 1);
3485 query[sizeof(query) - 1] = '\0';
3487 _LOGE("query = %s\n", query);
3491 sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
3492 _LOGE("Don't execute query = %s error message = %s\n", query,
3494 sqlite3_free(error_message);
3495 sqlite3_close(manifest_db);
3496 ret = PMINFO_R_ERROR;
3510 sqlite3_close(manifest_db);
3514 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
3515 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
3517 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3518 retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3519 char *syslocale = NULL;
3520 char *locale = NULL;
3521 char *condition = NULL;
3522 char *error_message = NULL;
3523 char query[MAX_QUERY_LEN] = {'\0'};
3524 char where[MAX_QUERY_LEN] = {'\0'};
3527 label_x *tmp1 = NULL;
3528 icon_x *tmp2 = NULL;
3529 description_x *tmp3 = NULL;
3530 author_x *tmp4 = NULL;
3531 privilege_x *tmp5 = NULL;
3532 pkgmgr_pkginfo_x *node = NULL;
3533 pkgmgr_pkginfo_x *tmphead = NULL;
3534 pkgmgr_pkginfo_x *pkginfo = NULL;
3536 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3537 /*Get current locale*/
3538 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3539 if (syslocale == NULL) {
3540 _LOGE("current locale is NULL\n");
3541 return PMINFO_R_ERROR;
3543 locale = __convert_system_locale_to_manifest_locale(syslocale);
3544 if (locale == NULL) {
3545 _LOGE("manifest locale is NULL\n");
3547 return PMINFO_R_ERROR;
3550 ret = __open_manifest_db();
3552 _LOGE("Fail to open manifest DB\n");
3553 ret = PMINFO_R_ERROR;
3556 /*Start constructing query*/
3557 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
3559 /*Get where clause*/
3560 for (list = filter->list; list; list = g_slist_next(list)) {
3561 __get_filter_condition(list->data, &condition);
3563 strncat(where, condition, sizeof(where) - strlen(where) -1);
3564 where[sizeof(where) - 1] = '\0';
3568 if (g_slist_next(list)) {
3569 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3570 where[sizeof(where) - 1] = '\0';
3573 _LOGE("where = %s\n", where);
3574 if (strlen(where) > 0) {
3575 strncat(query, where, sizeof(query) - strlen(query) - 1);
3576 query[sizeof(query) - 1] = '\0';
3578 _LOGE("query = %s\n", query);
3579 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
3580 if (tmphead == NULL) {
3581 _LOGE("Out of Memory!!!\n");
3582 ret = PMINFO_R_ERROR;
3587 sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
3588 _LOGE("Don't execute query = %s error message = %s\n", query,
3590 sqlite3_free(error_message);
3591 sqlite3_close(manifest_db);
3592 ret = PMINFO_R_ERROR;
3596 LISTHEAD(tmphead, node);
3597 for(node = node->next ; node ; node = node->next) {
3599 pkginfo->locale = strdup(locale);
3600 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
3601 if (pkginfo->manifest_info->privileges == NULL) {
3602 _LOGE("Failed to allocate memory for privileges info\n");
3603 ret = PMINFO_R_ERROR;
3607 /*populate manifest_info from DB*/
3608 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
3609 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3611 _LOGE("Package Info DB Information retrieval failed\n");
3612 ret = PMINFO_R_ERROR;
3615 memset(query, '\0', MAX_QUERY_LEN);
3616 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3617 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
3618 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3620 _LOGE("Package Info DB Information retrieval failed\n");
3621 ret = PMINFO_R_ERROR;
3624 /*Also store the values corresponding to default locales*/
3625 memset(query, '\0', MAX_QUERY_LEN);
3626 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3627 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
3628 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3630 _LOGE("Package Info DB Information retrieval failed\n");
3631 ret = PMINFO_R_ERROR;
3634 if (pkginfo->manifest_info->label) {
3635 LISTHEAD(pkginfo->manifest_info->label, tmp1);
3636 pkginfo->manifest_info->label = tmp1;
3638 if (pkginfo->manifest_info->icon) {
3639 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
3640 pkginfo->manifest_info->icon = tmp2;
3642 if (pkginfo->manifest_info->description) {
3643 LISTHEAD(pkginfo->manifest_info->description, tmp3);
3644 pkginfo->manifest_info->description = tmp3;
3646 if (pkginfo->manifest_info->author) {
3647 LISTHEAD(pkginfo->manifest_info->author, tmp4);
3648 pkginfo->manifest_info->author = tmp4;
3650 if (pkginfo->manifest_info->privileges->privilege) {
3651 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
3652 pkginfo->manifest_info->privileges->privilege = tmp5;
3656 LISTHEAD(tmphead, node);
3658 for(node = node->next ; node ; node = node->next) {
3660 ret = pkg_cb( (void *)pkginfo, user_data);
3675 sqlite3_close(manifest_db);
3676 __cleanup_pkginfo(tmphead);
3680 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
3681 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
3683 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3684 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3686 privilege_x *ptr = NULL;
3687 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3688 ptr = info->manifest_info->privileges->privilege;
3689 for (; ptr; ptr = ptr->next) {
3691 ret = privilege_func(ptr->text, user_data);
3699 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
3700 pkgmgrinfo_app_list_cb app_func, void *user_data)
3702 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3703 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
3704 retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
3706 char *syslocale = NULL;
3707 char *locale = NULL;
3709 char query[MAX_QUERY_LEN] = {'\0'};
3710 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3711 pkgmgr_pkginfo_x *allinfo = NULL;
3712 pkgmgr_appinfo_x *appinfo = NULL;
3713 icon_x *ptr1 = NULL;
3714 label_x *ptr2 = NULL;
3715 category_x *ptr3 = NULL;
3716 metadata_x *ptr4 = NULL;
3717 permission_x *ptr5 = NULL;
3718 image_x *ptr6 = NULL;
3719 sqlite3 *appinfo_db = NULL;
3721 /*get system locale*/
3722 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3723 tryvm_if(syslocale == NULL, ret = PMINFO_R_EINVAL, "current locale is NULL");
3725 /*get locale on db*/
3726 locale = __convert_system_locale_to_manifest_locale(syslocale);
3727 tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
3730 allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
3731 tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3733 /*calloc manifest_info*/
3734 allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
3735 tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
3738 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
3739 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3741 /*set component type*/
3742 if (component == PMINFO_UI_APP)
3743 appinfo->app_component = PMINFO_UI_APP;
3744 if (component == PMINFO_SVC_APP)
3745 appinfo->app_component = PMINFO_SVC_APP;
3746 if (component == PMINFO_ALL_APP)
3747 appinfo->app_component = PMINFO_ALL_APP;
3750 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
3751 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3753 appinfo->package = strdup(info->manifest_info->package);
3754 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
3755 "from package_app_info where " \
3756 "package='%s' and app_component='%s'",
3757 info->manifest_info->package,
3758 (appinfo->app_component==PMINFO_UI_APP ? "uiapp" : "svcapp"));
3762 /*Populate ui app info */
3763 ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
3764 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3766 uiapplication_x *tmp = NULL;
3767 if (info->manifest_info->uiapplication) {
3768 LISTHEAD(info->manifest_info->uiapplication, tmp);
3769 info->manifest_info->uiapplication = tmp;
3771 /*Populate localized info for default locales and call callback*/
3772 /*If the callback func return < 0 we break and no more call back is called*/
3775 appinfo->locale = strdup(locale);
3776 appinfo->uiapp_info = tmp;
3777 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
3781 locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
3784 memset(query, '\0', MAX_QUERY_LEN);
3785 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3786 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3787 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3789 memset(query, '\0', MAX_QUERY_LEN);
3790 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);
3791 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3792 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3794 /*store setting notification icon section*/
3795 memset(query, '\0', MAX_QUERY_LEN);
3796 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3797 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3798 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
3800 /*store app preview image info*/
3801 memset(query, '\0', MAX_QUERY_LEN);
3802 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
3803 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3804 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
3806 if (appinfo->uiapp_info->label) {
3807 LISTHEAD(appinfo->uiapp_info->label, ptr2);
3808 appinfo->uiapp_info->label = ptr2;
3810 if (appinfo->uiapp_info->icon) {
3811 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
3812 appinfo->uiapp_info->icon = ptr1;
3814 if (appinfo->uiapp_info->category) {
3815 LISTHEAD(appinfo->uiapp_info->category, ptr3);
3816 appinfo->uiapp_info->category = ptr3;
3818 if (appinfo->uiapp_info->metadata) {
3819 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
3820 appinfo->uiapp_info->metadata = ptr4;
3822 if (appinfo->uiapp_info->permission) {
3823 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
3824 appinfo->uiapp_info->permission = ptr5;
3826 if (appinfo->uiapp_info->image) {
3827 LISTHEAD(appinfo->uiapp_info->image, ptr6);
3828 appinfo->uiapp_info->image = ptr6;
3830 ret = app_func((void *)appinfo, user_data);
3836 case PMINFO_SVC_APP:
3837 /*Populate svc app info */
3838 ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
3839 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3841 serviceapplication_x *tmp1 = NULL;
3842 if (info->manifest_info->serviceapplication) {
3843 LISTHEAD(info->manifest_info->serviceapplication, tmp1);
3844 info->manifest_info->serviceapplication = tmp1;
3846 /*Populate localized info for default locales and call callback*/
3847 /*If the callback func return < 0 we break and no more call back is called*/
3850 appinfo->locale = strdup(locale);
3851 appinfo->svcapp_info = tmp1;
3852 memset(query, '\0', MAX_QUERY_LEN);
3853 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
3854 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3855 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
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->svcapp_info->appid, DEFAULT_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 if (appinfo->svcapp_info->label) {
3863 LISTHEAD(appinfo->svcapp_info->label, ptr2);
3864 appinfo->svcapp_info->label = ptr2;
3866 if (appinfo->svcapp_info->icon) {
3867 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
3868 appinfo->svcapp_info->icon = ptr1;
3870 if (appinfo->svcapp_info->category) {
3871 LISTHEAD(appinfo->svcapp_info->category, ptr3);
3872 appinfo->svcapp_info->category = ptr3;
3874 if (appinfo->svcapp_info->metadata) {
3875 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
3876 appinfo->svcapp_info->metadata = ptr4;
3878 if (appinfo->svcapp_info->permission) {
3879 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
3880 appinfo->svcapp_info->permission = ptr5;
3882 ret = app_func((void *)appinfo, user_data);
3888 case PMINFO_ALL_APP:
3889 memset(query, '\0', MAX_QUERY_LEN);
3890 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
3892 /*Populate all app info */
3893 ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo);
3894 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3897 appinfo->app_component = PMINFO_UI_APP;
3898 uiapplication_x *tmp2 = NULL;
3899 if (allinfo->manifest_info->uiapplication) {
3900 LISTHEAD(allinfo->manifest_info->uiapplication, tmp2);
3901 allinfo->manifest_info->uiapplication = tmp2;
3903 /*Populate localized info for default locales and call callback*/
3904 /*If the callback func return < 0 we break and no more call back is called*/
3907 appinfo->locale = strdup(locale);
3908 appinfo->uiapp_info = tmp2;
3909 memset(query, '\0', MAX_QUERY_LEN);
3910 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3911 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3912 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3914 memset(query, '\0', MAX_QUERY_LEN);
3915 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
3916 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3917 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3919 /*store setting notification icon section*/
3920 memset(query, '\0', MAX_QUERY_LEN);
3921 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3922 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3923 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
3925 /*store app preview image info*/
3926 memset(query, '\0', MAX_QUERY_LEN);
3927 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
3928 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3929 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
3931 if (appinfo->uiapp_info->label) {
3932 LISTHEAD(appinfo->uiapp_info->label, ptr2);
3933 appinfo->uiapp_info->label = ptr2;
3935 if (appinfo->uiapp_info->icon) {
3936 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
3937 appinfo->uiapp_info->icon = ptr1;
3939 if (appinfo->uiapp_info->category) {
3940 LISTHEAD(appinfo->uiapp_info->category, ptr3);
3941 appinfo->uiapp_info->category = ptr3;
3943 if (appinfo->uiapp_info->metadata) {
3944 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
3945 appinfo->uiapp_info->metadata = ptr4;
3947 if (appinfo->uiapp_info->permission) {
3948 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
3949 appinfo->uiapp_info->permission = ptr5;
3951 if (appinfo->uiapp_info->image) {
3952 LISTHEAD(appinfo->uiapp_info->image, ptr6);
3953 appinfo->uiapp_info->image = ptr6;
3955 ret = app_func((void *)appinfo, user_data);
3962 appinfo->app_component = PMINFO_SVC_APP;
3963 serviceapplication_x *tmp3 = NULL;
3964 if (allinfo->manifest_info->serviceapplication) {
3965 LISTHEAD(allinfo->manifest_info->serviceapplication, tmp3);
3966 allinfo->manifest_info->serviceapplication = tmp3;
3968 /*Populate localized info for default locales and call callback*/
3969 /*If the callback func return < 0 we break and no more call back is called*/
3972 appinfo->locale = strdup(locale);
3973 appinfo->svcapp_info = tmp3;
3974 memset(query, '\0', MAX_QUERY_LEN);
3975 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
3976 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3977 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3979 memset(query, '\0', MAX_QUERY_LEN);
3980 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);
3981 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3982 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3984 if (appinfo->svcapp_info->label) {
3985 LISTHEAD(appinfo->svcapp_info->label, ptr2);
3986 appinfo->svcapp_info->label = ptr2;
3988 if (appinfo->svcapp_info->icon) {
3989 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
3990 appinfo->svcapp_info->icon = ptr1;
3992 if (appinfo->svcapp_info->category) {
3993 LISTHEAD(appinfo->svcapp_info->category, ptr3);
3994 appinfo->svcapp_info->category = ptr3;
3996 if (appinfo->svcapp_info->metadata) {
3997 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
3998 appinfo->svcapp_info->metadata = ptr4;
4000 if (appinfo->svcapp_info->permission) {
4001 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
4002 appinfo->svcapp_info->permission = ptr5;
4004 ret = app_func((void *)appinfo, user_data);
4009 appinfo->app_component = PMINFO_ALL_APP;
4025 if (appinfo->package) {
4026 free((void *)appinfo->package);
4027 appinfo->package = NULL;
4032 __cleanup_pkginfo(allinfo);
4034 sqlite3_close(appinfo_db);
4038 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4040 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4042 int ret = PMINFO_R_OK;
4043 char query[MAX_QUERY_LEN] = {'\0'};
4044 pkgmgr_appinfo_x *info = NULL;
4045 pkgmgr_appinfo_x *appinfo = NULL;
4046 uiapplication_x *ptr1 = NULL;
4047 sqlite3 *appinfo_db = NULL;
4050 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4051 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4054 info = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4055 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4057 /*calloc uiapplication_x*/
4058 info->uiapp_info= (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4059 tryvm_if(info->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4062 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4063 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4065 /*query package_app_info*/
4066 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4067 ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
4068 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4070 LISTHEAD(info->uiapp_info, ptr1);
4073 for(ptr1 = ptr1->next ; ptr1 ; ptr1 = ptr1->next)
4075 appinfo->uiapp_info= ptr1;
4076 appinfo->package = strdup(ptr1->package);
4077 appinfo->app_component = PMINFO_UI_APP;
4079 ret = app_func((void *)appinfo, user_data);
4082 free((void *)appinfo->package);
4083 appinfo->package = NULL;
4087 sqlite3_close(appinfo_db);
4093 __cleanup_appinfo(info);
4097 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4099 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4101 int ret = PMINFO_R_OK;
4102 char query[MAX_QUERY_LEN] = {'\0'};
4103 char *syslocale = NULL;
4104 char *locale = NULL;
4105 pkgmgr_appinfo_x *appinfo = NULL;
4106 uiapplication_x *ptr1 = NULL;
4107 serviceapplication_x *ptr2 = NULL;
4108 label_x *tmp1 = NULL;
4109 icon_x *tmp2 = NULL;
4110 category_x *tmp3 = NULL;
4111 metadata_x *tmp4 = NULL;
4112 permission_x *tmp5 = NULL;
4113 image_x *tmp6 = NULL;
4114 sqlite3 *appinfo_db = NULL;
4116 /*get system locale*/
4117 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4118 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
4120 /*get locale on db*/
4121 locale = __convert_system_locale_to_manifest_locale(syslocale);
4122 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4125 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4126 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4129 pkgmgr_pkginfo_x *info = NULL;
4130 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4131 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4133 /*calloc manifest_info*/
4134 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4135 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4138 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4139 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4141 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4142 ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
4143 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4145 if (info->manifest_info->uiapplication) {
4146 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4147 info->manifest_info->uiapplication = ptr1;
4149 if (info->manifest_info->serviceapplication) {
4150 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4151 info->manifest_info->serviceapplication = ptr2;
4155 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4157 appinfo->locale = strdup(locale);
4158 appinfo->app_component = PMINFO_UI_APP;
4159 appinfo->package = strdup(ptr1->package);
4160 appinfo->uiapp_info = ptr1;
4161 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4162 "from package_app_info where " \
4163 "app_id='%s'", ptr1->appid);
4164 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4165 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4167 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
4171 locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
4174 memset(query, '\0', MAX_QUERY_LEN);
4175 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4176 "from package_app_localized_info where " \
4177 "app_id='%s' and app_locale='%s'",
4178 ptr1->appid, locale);
4179 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4180 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4182 memset(query, '\0', MAX_QUERY_LEN);
4183 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4184 "from package_app_localized_info where " \
4185 "app_id='%s' and app_locale='%s'",
4186 ptr1->appid, DEFAULT_LOCALE);
4188 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4189 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4191 /*store setting notification icon section*/
4192 memset(query, '\0', MAX_QUERY_LEN);
4193 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
4194 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4195 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4197 /*store app preview image info*/
4198 memset(query, '\0', MAX_QUERY_LEN);
4199 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
4200 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4201 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4203 if (appinfo->uiapp_info->label) {
4204 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4205 appinfo->uiapp_info->label = tmp1;
4207 if (appinfo->uiapp_info->icon) {
4208 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4209 appinfo->uiapp_info->icon= tmp2;
4211 if (appinfo->uiapp_info->category) {
4212 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4213 appinfo->uiapp_info->category = tmp3;
4215 if (appinfo->uiapp_info->metadata) {
4216 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4217 appinfo->uiapp_info->metadata = tmp4;
4219 if (appinfo->uiapp_info->permission) {
4220 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4221 appinfo->uiapp_info->permission = tmp5;
4223 if (appinfo->uiapp_info->image) {
4224 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4225 appinfo->uiapp_info->image = tmp6;
4227 ret = app_func((void *)appinfo, user_data);
4230 free((void *)appinfo->package);
4231 appinfo->package = NULL;
4234 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4236 appinfo->locale = strdup(locale);
4237 appinfo->app_component = PMINFO_SVC_APP;
4238 appinfo->package = strdup(ptr2->package);
4239 appinfo->svcapp_info = ptr2;
4240 memset(query, '\0', MAX_QUERY_LEN);
4241 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4242 "from package_app_info where " \
4243 "app_id='%s'", ptr2->appid);
4244 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4245 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
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 ptr2->appid, locale);
4252 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4253 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App 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 ptr2->appid, DEFAULT_LOCALE);
4260 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4261 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4263 if (appinfo->svcapp_info->label) {
4264 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4265 appinfo->svcapp_info->label = tmp1;
4267 if (appinfo->svcapp_info->icon) {
4268 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4269 appinfo->svcapp_info->icon= tmp2;
4271 if (appinfo->svcapp_info->category) {
4272 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4273 appinfo->svcapp_info->category = tmp3;
4275 if (appinfo->svcapp_info->metadata) {
4276 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4277 appinfo->svcapp_info->metadata = tmp4;
4279 if (appinfo->svcapp_info->permission) {
4280 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4281 appinfo->svcapp_info->permission = tmp5;
4283 ret = app_func((void *)appinfo, user_data);
4286 free((void *)appinfo->package);
4287 appinfo->package = NULL;
4300 sqlite3_close(appinfo_db);
4305 __cleanup_pkginfo(info);
4309 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
4311 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
4312 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4314 pkgmgr_appinfo_x *appinfo = NULL;
4315 char *syslocale = NULL;
4316 char *locale = NULL;
4319 label_x *tmp1 = NULL;
4320 icon_x *tmp2 = NULL;
4321 category_x *tmp3 = NULL;
4322 metadata_x *tmp4 = NULL;
4323 permission_x *tmp5 = NULL;
4324 image_x *tmp6 = NULL;
4325 char query[MAX_QUERY_LEN] = {'\0'};
4326 sqlite3 *appinfo_db = NULL;
4329 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4330 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4332 /*check appid exist on db*/
4333 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
4334 ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
4335 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
4336 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
4338 /*get system locale*/
4339 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4340 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
4342 /*get locale on db*/
4343 locale = __convert_system_locale_to_manifest_locale(syslocale);
4344 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4347 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4348 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
4350 /*check app_component from DB*/
4351 memset(query, '\0', MAX_QUERY_LEN);
4352 snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
4353 ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
4354 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4356 /*calloc app_component*/
4357 if (appinfo->app_component == PMINFO_UI_APP) {
4358 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4359 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
4361 appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
4362 tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
4364 appinfo->locale = strdup(locale);
4366 /*populate app_info from DB*/
4367 memset(query, '\0', MAX_QUERY_LEN);
4368 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
4369 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4370 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4372 memset(query, '\0', MAX_QUERY_LEN);
4373 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
4374 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4375 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4377 /*Also store the values corresponding to default locales*/
4378 memset(query, '\0', MAX_QUERY_LEN);
4379 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
4380 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4381 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4383 /*Populate app category*/
4384 memset(query, '\0', MAX_QUERY_LEN);
4385 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
4386 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4387 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
4389 /*Populate app metadata*/
4390 memset(query, '\0', MAX_QUERY_LEN);
4391 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
4392 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4393 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
4395 /*Populate app permission*/
4396 memset(query, '\0', MAX_QUERY_LEN);
4397 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
4398 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4399 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
4401 /*store setting notification icon section*/
4402 memset(query, '\0', MAX_QUERY_LEN);
4403 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
4404 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4405 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4407 /*store app preview image info*/
4408 memset(query, '\0', MAX_QUERY_LEN);
4409 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
4410 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4411 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4413 switch (appinfo->app_component) {
4415 if (appinfo->uiapp_info->label) {
4416 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4417 appinfo->uiapp_info->label = tmp1;
4419 if (appinfo->uiapp_info->icon) {
4420 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4421 appinfo->uiapp_info->icon = tmp2;
4423 if (appinfo->uiapp_info->category) {
4424 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4425 appinfo->uiapp_info->category = tmp3;
4427 if (appinfo->uiapp_info->metadata) {
4428 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4429 appinfo->uiapp_info->metadata = tmp4;
4431 if (appinfo->uiapp_info->permission) {
4432 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4433 appinfo->uiapp_info->permission = tmp5;
4435 if (appinfo->uiapp_info->image) {
4436 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4437 appinfo->uiapp_info->image = tmp6;
4440 case PMINFO_SVC_APP:
4441 if (appinfo->svcapp_info->label) {
4442 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4443 appinfo->svcapp_info->label = tmp1;
4445 if (appinfo->svcapp_info->icon) {
4446 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4447 appinfo->svcapp_info->icon = tmp2;
4449 if (appinfo->svcapp_info->category) {
4450 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4451 appinfo->svcapp_info->category = tmp3;
4453 if (appinfo->svcapp_info->metadata) {
4454 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4455 appinfo->svcapp_info->metadata = tmp4;
4457 if (appinfo->svcapp_info->permission) {
4458 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4459 appinfo->svcapp_info->permission = tmp5;
4469 if (ret == PMINFO_R_OK)
4470 *handle = (void*)appinfo;
4473 __cleanup_appinfo(appinfo);
4476 sqlite3_close(appinfo_db);
4489 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
4491 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4492 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4493 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4495 if (info->app_component == PMINFO_UI_APP)
4496 *appid = (char *)info->uiapp_info->appid;
4497 else if (info->app_component == PMINFO_SVC_APP)
4498 *appid = (char *)info->svcapp_info->appid;
4503 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
4505 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4506 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4507 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4509 *pkg_name = (char *)info->package;
4514 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
4516 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4517 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4518 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4520 *pkgid = (char *)info->package;
4525 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
4527 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4528 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4529 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4531 if (info->app_component == PMINFO_UI_APP)
4532 *exec = (char *)info->uiapp_info->exec;
4533 if (info->app_component == PMINFO_SVC_APP)
4534 *exec = (char *)info->svcapp_info->exec;
4540 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4542 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4543 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4544 char *locale = NULL;
4546 icon_x *start = NULL;
4549 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4550 locale = info->locale;
4551 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4553 if (info->app_component == PMINFO_UI_APP)
4554 start = info->uiapp_info->icon;
4555 if (info->app_component == PMINFO_SVC_APP)
4556 start = info->svcapp_info->icon;
4557 for(ptr = start; ptr != NULL; ptr = ptr->next)
4560 if (strcmp(ptr->lang, locale) == 0) {
4561 *icon = (char *)ptr->text;
4562 if (strcasecmp(*icon, "(null)") == 0) {
4563 locale = DEFAULT_LOCALE;
4567 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4568 *icon = (char *)ptr->text;
4577 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
4579 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4580 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4581 char *locale = NULL;
4582 label_x *ptr = NULL;
4583 label_x *start = NULL;
4586 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4587 locale = info->locale;
4588 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4590 if (info->app_component == PMINFO_UI_APP)
4591 start = info->uiapp_info->label;
4592 if (info->app_component == PMINFO_SVC_APP)
4593 start = info->svcapp_info->label;
4594 for(ptr = start; ptr != NULL; ptr = ptr->next)
4597 if (strcmp(ptr->lang, locale) == 0) {
4598 *label = (char *)ptr->text;
4599 if (strcasecmp(*label, "(null)") == 0) {
4600 locale = DEFAULT_LOCALE;
4604 } else if (strncasecmp(ptr->lang, locale, 2) == 0) {
4605 *label = (char *)ptr->text;
4606 if (strcasecmp(*label, "(null)") == 0) {
4607 locale = DEFAULT_LOCALE;
4611 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4612 *label = (char *)ptr->text;
4621 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
4623 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4624 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4625 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4627 if (info->app_component == PMINFO_UI_APP)
4628 *component = PMINFO_UI_APP;
4629 else if (info->app_component == PMINFO_SVC_APP)
4630 *component = PMINFO_SVC_APP;
4632 return PMINFO_R_ERROR;
4637 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
4639 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4640 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4641 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4643 if (info->app_component == PMINFO_UI_APP)
4644 *app_type = (char *)info->uiapp_info->type;
4645 if (info->app_component == PMINFO_SVC_APP)
4646 *app_type = (char *)info->svcapp_info->type;
4651 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
4652 int *operation_count, char ***operation)
4654 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4655 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4656 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4657 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4658 *operation_count = data->operation_count;
4659 *operation = data->operation;
4663 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
4664 int *uri_count, char ***uri)
4666 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4667 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4668 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4669 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4670 *uri_count = data->uri_count;
4675 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
4676 int *mime_count, char ***mime)
4678 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4679 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4680 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4681 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4682 *mime_count = data->mime_count;
4687 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4689 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4690 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4694 icon_x *start = NULL;
4695 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4697 start = info->uiapp_info->icon;
4699 for(ptr = start; ptr != NULL; ptr = ptr->next)
4702 val = (char *)ptr->section;
4703 if (strcmp(val, "setting") == 0){
4704 *icon = (char *)ptr->text;
4713 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4715 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4716 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4720 icon_x *start = NULL;
4721 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4723 start = info->uiapp_info->icon;
4725 for(ptr = start; ptr != NULL; ptr = ptr->next)
4728 val = (char *)ptr->section;
4730 if (strcmp(val, "notification") == 0){
4731 *icon = (char *)ptr->text;
4740 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
4742 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4743 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4745 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4746 val = (char *)info->uiapp_info->recentimage;
4748 if (strcasecmp(val, "capture") == 0)
4749 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
4750 else if (strcasecmp(val, "icon") == 0)
4751 *type = PMINFO_RECENTIMAGE_USE_ICON;
4753 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
4759 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
4761 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4762 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4765 image_x *ptr = NULL;
4766 image_x *start = NULL;
4767 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4769 start = info->uiapp_info->image;
4771 for(ptr = start; ptr != NULL; ptr = ptr->next)
4774 val = (char *)ptr->section;
4776 if (strcmp(val, "preview") == 0)
4777 *preview_img = (char *)ptr->text;
4785 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
4787 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4788 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4791 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4793 val = info->uiapp_info->permission_type;
4795 if (strcmp(val, "signature") == 0)
4796 *permission = PMINFO_PERMISSION_SIGNATURE;
4797 else if (strcmp(val, "privilege") == 0)
4798 *permission = PMINFO_PERMISSION_PRIVILEGE;
4800 *permission = PMINFO_PERMISSION_NORMAL;
4805 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
4806 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
4808 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4809 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4811 permission_x *ptr = NULL;
4812 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4813 if (info->app_component == PMINFO_UI_APP)
4814 ptr = info->uiapp_info->permission;
4815 else if (info->app_component == PMINFO_SVC_APP)
4816 ptr = info->svcapp_info->permission;
4818 return PMINFO_R_EINVAL;
4819 for (; ptr; ptr = ptr->next) {
4820 ret = permission_func(ptr->value, user_data);
4827 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
4828 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
4830 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4831 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4833 category_x *ptr = NULL;
4834 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4835 if (info->app_component == PMINFO_UI_APP)
4836 ptr = info->uiapp_info->category;
4837 else if (info->app_component == PMINFO_SVC_APP)
4838 ptr = info->svcapp_info->category;
4840 return PMINFO_R_EINVAL;
4841 for (; ptr; ptr = ptr->next) {
4842 ret = category_func(ptr->name, user_data);
4849 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
4850 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
4852 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4853 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4855 metadata_x *ptr = NULL;
4856 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4857 if (info->app_component == PMINFO_UI_APP)
4858 ptr = info->uiapp_info->metadata;
4859 else if (info->app_component == PMINFO_SVC_APP)
4860 ptr = info->svcapp_info->metadata;
4862 return PMINFO_R_EINVAL;
4863 for (; ptr; ptr = ptr->next) {
4864 ret = metadata_func(ptr->key, ptr->value, user_data);
4871 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
4872 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
4874 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4875 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4882 char *manifest = NULL;
4883 char **operation = NULL;
4886 appcontrol_x *appcontrol = NULL;
4887 manifest_x *mfx = NULL;
4888 operation_x *op = NULL;
4891 pkgmgrinfo_app_component component;
4892 pkgmgrinfo_appcontrol_x *ptr = NULL;
4893 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
4895 _LOGE("Failed to get package name\n");
4896 return PMINFO_R_ERROR;
4898 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
4900 _LOGE("Failed to get app component name\n");
4901 return PMINFO_R_ERROR;
4903 manifest = pkgmgr_parser_get_manifest_file(pkgid);
4904 if (manifest == NULL) {
4905 _LOGE("Failed to fetch package manifest file\n");
4906 return PMINFO_R_ERROR;
4908 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4910 _LOGE("Failed to parse package manifest file\n");
4913 return PMINFO_R_ERROR;
4916 ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
4918 _LOGE("Out of Memory!!!\n");
4919 pkgmgr_parser_free_manifest_xml(mfx);
4920 return PMINFO_R_ERROR;
4922 /*Get Operation, Uri, Mime*/
4923 switch (component) {
4925 if (mfx->uiapplication) {
4926 if (mfx->uiapplication->appcontrol) {
4927 appcontrol = mfx->uiapplication->appcontrol;
4931 case PMINFO_SVC_APP:
4932 if (mfx->serviceapplication) {
4933 if (mfx->serviceapplication->appcontrol) {
4934 appcontrol = mfx->serviceapplication->appcontrol;
4941 for (; appcontrol; appcontrol = appcontrol->next) {
4942 op = appcontrol->operation;
4943 for (; op; op = op->next)
4945 op = appcontrol->operation;
4947 ui = appcontrol->uri;
4948 for (; ui; ui = ui->next)
4950 ui = appcontrol->uri;
4952 mi = appcontrol->mime;
4953 for (; mi; mi = mi->next)
4955 mi = appcontrol->mime;
4957 operation = (char **)calloc(oc, sizeof(char *));
4958 for (i = 0; i < oc; i++) {
4959 operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
4963 uri = (char **)calloc(uc, sizeof(char *));
4964 for (i = 0; i < uc; i++) {
4965 uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
4969 mime = (char **)calloc(mc, sizeof(char *));
4970 for (i = 0; i < mc; i++) {
4971 mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
4974 /*populate appcontrol handle*/
4975 ptr->operation_count = oc;
4976 ptr->uri_count = uc;
4977 ptr->mime_count = mc;
4978 ptr->operation = operation;
4981 ret = appcontrol_func((void *)ptr, user_data);
4982 for (i = 0; i < oc; i++) {
4985 operation[i] = NULL;
4992 for (i = 0; i < uc; i++) {
5002 for (i = 0; i < mc; i++) {
5018 pkgmgr_parser_free_manifest_xml(mfx);
5026 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
5028 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5029 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5031 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5032 val = (char *)info->uiapp_info->nodisplay;
5034 if (strcasecmp(val, "true") == 0)
5036 else if (strcasecmp(val, "false") == 0)
5044 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
5046 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5047 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5049 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5050 val = (char *)info->uiapp_info->multiple;
5052 if (strcasecmp(val, "true") == 0)
5054 else if (strcasecmp(val, "false") == 0)
5062 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
5064 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5065 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5067 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5068 val = (char *)info->uiapp_info->indicatordisplay;
5070 if (strcasecmp(val, "true") == 0){
5071 *indicator_disp = 1;
5072 }else if (strcasecmp(val, "false") == 0){
5073 *indicator_disp = 0;
5075 *indicator_disp = 0;
5082 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
5084 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5085 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5086 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5087 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5089 if (info->app_component == PMINFO_UI_APP){
5090 *portrait_img = (char *)info->uiapp_info->portraitimg;
5091 *landscape_img = (char *)info->uiapp_info->landscapeimg;
5097 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
5099 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5100 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5102 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5103 val = (char *)info->uiapp_info->taskmanage;
5105 if (strcasecmp(val, "true") == 0)
5107 else if (strcasecmp(val, "false") == 0)
5115 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
5117 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5118 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5120 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5121 if (info->app_component == PMINFO_UI_APP)
5122 val = (char *)info->uiapp_info->enabled;
5123 else if (info->app_component == PMINFO_SVC_APP)
5124 val = (char *)info->uiapp_info->enabled;
5126 _LOGE("invalid component type\n");
5127 return PMINFO_R_EINVAL;
5131 if (strcasecmp(val, "true") == 0)
5133 else if (strcasecmp(val, "false") == 0)
5142 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
5144 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5145 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5147 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5148 val = (char *)info->uiapp_info->hwacceleration;
5150 if (strcasecmp(val, "not-use-GL") == 0)
5151 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
5152 else if (strcasecmp(val, "use-GL") == 0)
5153 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
5155 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
5160 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
5162 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5163 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5165 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5166 val = (char *)info->svcapp_info->onboot;
5168 if (strcasecmp(val, "true") == 0)
5170 else if (strcasecmp(val, "false") == 0)
5178 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
5180 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5181 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5183 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5184 val = (char *)info->svcapp_info->autorestart;
5186 if (strcasecmp(val, "true") == 0)
5188 else if (strcasecmp(val, "false") == 0)
5196 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
5198 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5199 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5201 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5202 val = (char *)info->uiapp_info->mainapp;
5204 if (strcasecmp(val, "true") == 0)
5206 else if (strcasecmp(val, "false") == 0)
5214 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
5216 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5217 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5218 __cleanup_appinfo(info);
5222 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
5224 return (pkgmgrinfo_pkginfo_filter_create(handle));
5227 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
5229 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5232 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
5233 const char *property, const int value)
5235 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5236 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5237 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
5239 GSList *link = NULL;
5241 prop = _pminfo_appinfo_convert_to_prop_int(property);
5242 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
5243 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
5244 _LOGE("Invalid Integer Property\n");
5245 return PMINFO_R_EINVAL;
5247 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5248 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5250 _LOGE("Out of Memory!!!\n");
5251 return PMINFO_R_ERROR;
5253 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
5254 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
5256 _LOGE("Out of Memory\n");
5259 return PMINFO_R_ERROR;
5263 /*If API is called multiple times for same property, we should override the previous values.
5264 Last value set will be used for filtering.*/
5265 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5267 filter->list = g_slist_delete_link(filter->list, link);
5268 filter->list = g_slist_append(filter->list, (gpointer)node);
5273 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
5274 const char *property, const bool value)
5276 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5277 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5279 GSList *link = NULL;
5281 prop = _pminfo_appinfo_convert_to_prop_bool(property);
5282 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
5283 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
5284 _LOGE("Invalid Boolean Property\n");
5285 return PMINFO_R_EINVAL;
5287 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5288 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5290 _LOGE("Out of Memory!!!\n");
5291 return PMINFO_R_ERROR;
5294 val = strndup("('true','True')", 15);
5296 val = strndup("('false','False')", 17);
5298 _LOGE("Out of Memory\n");
5301 return PMINFO_R_ERROR;
5305 /*If API is called multiple times for same property, we should override the previous values.
5306 Last value set will be used for filtering.*/
5307 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5309 filter->list = g_slist_delete_link(filter->list, link);
5310 filter->list = g_slist_append(filter->list, (gpointer)node);
5315 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
5316 const char *property, const char *value)
5318 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5319 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5320 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5322 pkgmgrinfo_node_x *ptr = NULL;
5323 char prev[PKG_STRING_LEN_MAX] = {'\0'};
5324 char temp[PKG_STRING_LEN_MAX] = {'\0'};
5325 GSList *link = NULL;
5327 prop = _pminfo_appinfo_convert_to_prop_str(property);
5328 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
5329 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
5330 _LOGE("Invalid String Property\n");
5331 return PMINFO_R_EINVAL;
5333 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5334 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5336 _LOGE("Out of Memory!!!\n");
5337 return PMINFO_R_ERROR;
5341 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
5342 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
5343 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
5345 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
5347 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5349 filter->list = g_slist_delete_link(filter->list, link);
5350 filter->list = g_slist_append(filter->list, (gpointer)node);
5352 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
5353 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
5354 case E_PMINFO_APPINFO_PROP_APP_URI:
5355 case E_PMINFO_APPINFO_PROP_APP_MIME:
5356 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
5358 _LOGE("Out of Memory\n");
5361 return PMINFO_R_ERROR;
5363 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5365 ptr = (pkgmgrinfo_node_x *)link->data;
5366 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
5367 _LOGE("Previous value is %s\n", prev);
5368 filter->list = g_slist_delete_link(filter->list, link);
5369 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
5370 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5371 _LOGE("New value is %s\n", val);
5373 filter->list = g_slist_append(filter->list, (gpointer)node);
5374 memset(temp, '\0', PKG_STRING_LEN_MAX);
5376 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
5377 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5378 _LOGE("First value is %s\n", val);
5380 filter->list = g_slist_append(filter->list, (gpointer)node);
5381 memset(temp, '\0', PKG_STRING_LEN_MAX);
5385 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
5386 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5388 filter->list = g_slist_delete_link(filter->list, link);
5389 filter->list = g_slist_append(filter->list, (gpointer)node);
5395 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
5397 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5398 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5399 char *syslocale = NULL;
5400 char *locale = NULL;
5401 char *condition = NULL;
5402 char *error_message = NULL;
5403 char query[MAX_QUERY_LEN] = {'\0'};
5404 char where[MAX_QUERY_LEN] = {'\0'};
5408 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5409 /*Get current locale*/
5410 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5411 if (syslocale == NULL) {
5412 _LOGE("current locale is NULL\n");
5413 return PMINFO_R_ERROR;
5415 locale = __convert_system_locale_to_manifest_locale(syslocale);
5416 if (locale == NULL) {
5417 _LOGE("manifest locale is NULL\n");
5419 return PMINFO_R_ERROR;
5422 ret = __open_manifest_db();
5424 _LOGE("Fail to open manifest DB\n");
5425 ret = PMINFO_R_ERROR;
5429 /*Start constructing query*/
5430 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_APP, locale);
5432 /*Get where clause*/
5433 for (list = filter->list; list; list = g_slist_next(list)) {
5434 __get_filter_condition(list->data, &condition);
5436 strncat(where, condition, sizeof(where) - strlen(where) -1);
5437 where[sizeof(where) - 1] = '\0';
5441 if (g_slist_next(list)) {
5442 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5443 where[sizeof(where) - 1] = '\0';
5446 _LOGE("where = %s\n", where);
5447 if (strlen(where) > 0) {
5448 strncat(query, where, sizeof(query) - strlen(query) - 1);
5449 query[sizeof(query) - 1] = '\0';
5451 _LOGE("query = %s\n", query);
5455 sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
5456 _LOGE("Don't execute query = %s error message = %s\n", query,
5458 sqlite3_free(error_message);
5459 sqlite3_close(manifest_db);
5460 ret = PMINFO_R_ERROR;
5474 sqlite3_close(manifest_db);
5478 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
5479 pkgmgrinfo_app_list_cb app_cb, void * user_data)
5481 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5482 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5483 char *syslocale = NULL;
5484 char *locale = NULL;
5485 char *condition = NULL;
5486 char *error_message = NULL;
5487 char query[MAX_QUERY_LEN] = {'\0'};
5488 char where[MAX_QUERY_LEN] = {'\0'};
5491 uiapplication_x *ptr1 = NULL;
5492 serviceapplication_x *ptr2 = NULL;
5493 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5494 /*Get current locale*/
5495 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5496 if (syslocale == NULL) {
5497 _LOGE("current locale is NULL\n");
5498 return PMINFO_R_ERROR;
5500 locale = __convert_system_locale_to_manifest_locale(syslocale);
5501 if (locale == NULL) {
5502 _LOGE("manifest locale is NULL\n");
5504 return PMINFO_R_ERROR;
5507 ret = __open_manifest_db();
5509 _LOGE("Fail to open manifest DB\n");
5510 ret = PMINFO_R_ERROR;
5513 /*Start constructing query*/
5514 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
5515 /*Get where clause*/
5516 for (list = filter->list; list; list = g_slist_next(list)) {
5517 __get_filter_condition(list->data, &condition);
5519 strncat(where, condition, sizeof(where) - strlen(where) -1);
5520 where[sizeof(where) - 1] = '\0';
5524 if (g_slist_next(list)) {
5525 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5526 where[sizeof(where) - 1] = '\0';
5529 _LOGE("where = %s\n", where);
5530 if (strlen(where) > 0) {
5531 strncat(query, where, sizeof(query) - strlen(query) - 1);
5532 query[sizeof(query) - 1] = '\0';
5534 _LOGE("query = %s\n", query);
5535 /*To get filtered list*/
5536 pkgmgr_pkginfo_x *info = NULL;
5537 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5539 _LOGE("Out of Memory!!!\n");
5540 ret = PMINFO_R_ERROR;
5543 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5544 if (info->manifest_info == NULL) {
5545 _LOGE("Out of Memory!!!\n");
5546 ret = PMINFO_R_ERROR;
5549 /*To get detail app info for each member of filtered list*/
5550 pkgmgr_pkginfo_x *filtinfo = NULL;
5551 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5552 if (filtinfo == NULL) {
5553 _LOGE("Out of Memory!!!\n");
5554 ret = PMINFO_R_ERROR;
5557 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5558 if (filtinfo->manifest_info == NULL) {
5559 _LOGE("Out of Memory!!!\n");
5560 ret = PMINFO_R_ERROR;
5563 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5564 if (appinfo == NULL) {
5565 _LOGE("Out of Memory!!!\n");
5566 ret = PMINFO_R_ERROR;
5570 sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) {
5571 _LOGE("Don't execute query = %s error message = %s\n", query,
5573 sqlite3_free(error_message);
5574 sqlite3_close(manifest_db);
5575 ret = PMINFO_R_ERROR;
5578 memset(query, '\0', MAX_QUERY_LEN);
5579 if (info->manifest_info->uiapplication) {
5580 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5581 info->manifest_info->uiapplication = ptr1;
5583 if (info->manifest_info->serviceapplication) {
5584 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5585 info->manifest_info->serviceapplication = ptr2;
5587 /*Filtered UI Apps*/
5588 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5590 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5591 ptr1->appid, "uiapp");
5593 sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
5594 _LOGE("Don't execute query = %s error message = %s\n", query,
5596 sqlite3_free(error_message);
5597 sqlite3_close(manifest_db);
5598 ret = PMINFO_R_ERROR;
5602 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5604 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5605 ptr2->appid, "svcapp");
5607 sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
5608 _LOGE("Don't execute query = %s error message = %s\n", query,
5610 sqlite3_free(error_message);
5611 sqlite3_close(manifest_db);
5612 ret = PMINFO_R_ERROR;
5616 if (filtinfo->manifest_info->uiapplication) {
5617 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5618 filtinfo->manifest_info->uiapplication = ptr1;
5620 /*If the callback func return < 0 we break and no more call back is called*/
5623 appinfo->locale = strdup(locale);
5624 appinfo->uiapp_info = ptr1;
5625 appinfo->app_component = PMINFO_UI_APP;
5626 ret = app_cb((void *)appinfo, user_data);
5631 /*Filtered Service Apps*/
5632 if (filtinfo->manifest_info->serviceapplication) {
5633 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5634 filtinfo->manifest_info->serviceapplication = ptr2;
5636 /*If the callback func return < 0 we break and no more call back is called*/
5639 appinfo->locale = strdup(locale);
5640 appinfo->svcapp_info = ptr2;
5641 appinfo->app_component = PMINFO_SVC_APP;
5642 ret = app_cb((void *)appinfo, user_data);
5657 sqlite3_close(manifest_db);
5662 __cleanup_pkginfo(info);
5663 __cleanup_pkginfo(filtinfo);
5667 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
5669 return (pkgmgrinfo_pkginfo_filter_create(handle));
5672 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
5674 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5677 API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
5678 const char *key, const char *value)
5680 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
5681 retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
5682 /*value can be NULL. In that case all apps with specified key should be displayed*/
5686 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5687 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5688 retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
5690 tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5694 tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5697 /*If API is called multiple times, we should OR all conditions.*/
5698 filter->list = g_slist_append(filter->list, (gpointer)node);
5699 /*All memory will be freed in destroy API*/
5717 API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
5718 pkgmgrinfo_app_list_cb app_cb, void *user_data)
5720 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
5721 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
5722 char *syslocale = NULL;
5723 char *locale = NULL;
5724 char *condition = NULL;
5725 char *error_message = NULL;
5726 char query[MAX_QUERY_LEN] = {'\0'};
5727 char where[MAX_QUERY_LEN] = {'\0'};
5730 pkgmgr_pkginfo_x *info = NULL;
5731 pkgmgr_pkginfo_x *filtinfo = NULL;
5732 pkgmgr_appinfo_x *appinfo = NULL;
5733 uiapplication_x *ptr1 = NULL;
5734 serviceapplication_x *ptr2 = NULL;
5735 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5737 /*Get current locale*/
5738 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5739 retvm_if(syslocale == NULL, PMINFO_R_ERROR, "current locale is NULL\n");
5740 locale = __convert_system_locale_to_manifest_locale(syslocale);
5741 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
5743 ret = __open_manifest_db();
5744 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Fail to open manifest DB\n");
5746 /*Start constructing query*/
5747 memset(where, '\0', MAX_QUERY_LEN);
5748 memset(query, '\0', MAX_QUERY_LEN);
5749 snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
5750 /*Get where clause*/
5751 for (list = filter->list; list; list = g_slist_next(list)) {
5752 __get_metadata_filter_condition(list->data, &condition);
5754 strncat(where, condition, sizeof(where) - strlen(where) -1);
5758 if (g_slist_next(list)) {
5759 strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
5762 _LOGE("where = %s (%d)\n", where, strlen(where));
5763 if (strlen(where) > 0) {
5764 strncat(query, where, sizeof(query) - strlen(query) - 1);
5766 _LOGE("query = %s (%d)\n", query, strlen(query));
5767 /*To get filtered list*/
5768 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5769 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5771 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5772 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5774 /*To get detail app info for each member of filtered list*/
5775 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5776 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5778 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5779 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5781 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5782 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5784 ret = sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message);
5785 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5786 memset(query, '\0', MAX_QUERY_LEN);
5788 if (info->manifest_info->uiapplication) {
5789 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5790 info->manifest_info->uiapplication = ptr1;
5792 if (info->manifest_info->serviceapplication) {
5793 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5794 info->manifest_info->serviceapplication = ptr2;
5798 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5800 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5801 ptr1->appid, "uiapp");
5802 ret = sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message);
5803 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5804 memset(query, '\0', MAX_QUERY_LEN);
5807 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5809 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5810 ptr2->appid, "svcapp");
5811 ret = sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message);
5812 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5813 memset(query, '\0', MAX_QUERY_LEN);
5815 /*Filtered UI Apps*/
5816 if (filtinfo->manifest_info->uiapplication) {
5817 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5818 filtinfo->manifest_info->uiapplication = ptr1;
5820 /*If the callback func return < 0 we break and no more call back is called*/
5823 appinfo->locale = strdup(locale);
5824 appinfo->uiapp_info = ptr1;
5825 appinfo->app_component = PMINFO_UI_APP;
5826 ret = app_cb((void *)appinfo, user_data);
5831 /*Filtered Service Apps*/
5832 if (filtinfo->manifest_info->serviceapplication) {
5833 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5834 filtinfo->manifest_info->serviceapplication = ptr2;
5836 /*If the callback func return < 0 we break and no more call back is called*/
5839 appinfo->locale = strdup(locale);
5840 appinfo->svcapp_info = ptr2;
5841 appinfo->app_component = PMINFO_SVC_APP;
5842 ret = app_cb((void *)appinfo, user_data);
5857 sqlite3_free(error_message);
5858 sqlite3_close(manifest_db);
5863 __cleanup_pkginfo(info);
5864 __cleanup_pkginfo(filtinfo);
5868 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
5870 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5871 pkgmgr_certinfo_x *certinfo = NULL;
5872 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
5873 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
5874 *handle = (void *)certinfo;
5878 API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
5880 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
5881 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
5882 pkgmgr_certinfo_x *certinfo = NULL;
5883 char *error_message = NULL;
5884 int ret = PMINFO_R_OK;
5885 char query[MAX_QUERY_LEN] = {'\0'};
5890 ret = db_util_open_with_options(CERT_DB, &cert_db,
5891 SQLITE_OPEN_READONLY, NULL);
5892 if (ret != SQLITE_OK) {
5893 _LOGE("connect db [%s] failed!\n", CERT_DB);
5894 return PMINFO_R_ERROR;
5897 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
5899 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
5900 _LOGE("Don't execute query = %s error message = %s\n", query,
5902 sqlite3_free(error_message);
5903 ret = PMINFO_R_ERROR;
5907 _LOGE("Package not found in DB\n");
5908 ret = PMINFO_R_ERROR;
5911 certinfo = (pkgmgr_certinfo_x *)handle;
5912 /*populate certinfo from DB*/
5913 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
5914 ret = __exec_certinfo_query(query, (void *)certinfo);
5916 _LOGE("Package Cert Info DB Information retrieval failed\n");
5917 ret = PMINFO_R_ERROR;
5920 for (i = 0; i < MAX_CERT_TYPE; i++) {
5921 memset(query, '\0', MAX_QUERY_LEN);
5922 snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
5923 ret = __exec_certinfo_query(query, (void *)certinfo);
5925 _LOGE("Cert Info DB Information retrieval failed\n");
5926 ret = PMINFO_R_ERROR;
5929 if (certinfo->cert_value) {
5930 (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
5931 free(certinfo->cert_value);
5932 certinfo->cert_value = NULL;
5936 sqlite3_close(cert_db);
5940 API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
5942 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5943 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5944 retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5945 retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5946 pkgmgr_certinfo_x *certinfo = NULL;
5947 certinfo = (pkgmgr_certinfo_x *)handle;
5948 if ((certinfo->cert_info)[cert_type])
5949 *cert_value = (certinfo->cert_info)[cert_type];
5955 API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
5957 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5959 pkgmgr_certinfo_x *certinfo = NULL;
5960 certinfo = (pkgmgr_certinfo_x *)handle;
5961 if (certinfo->pkgid) {
5962 free(certinfo->pkgid);
5963 certinfo->pkgid = NULL;
5965 for (i = 0; i < MAX_CERT_TYPE; i++) {
5966 if ((certinfo->cert_info)[i]) {
5967 free((certinfo->cert_info)[i]);
5968 (certinfo->cert_info)[i] = NULL;
5976 API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
5978 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5979 pkgmgr_instcertinfo_x *certinfo = NULL;
5980 certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
5981 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
5982 *handle = (void *)certinfo;
5986 API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
5988 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5989 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5990 retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5991 retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5992 pkgmgr_instcertinfo_x *certinfo = NULL;
5993 certinfo = (pkgmgr_instcertinfo_x *)handle;
5994 (certinfo->cert_info)[cert_type] = strdup(cert_value);
5998 API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
6000 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
6001 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
6002 char *error_message = NULL;
6003 char query[MAX_QUERY_LEN] = {'\0'};
6004 char *vquery = NULL;
6009 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
6016 pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
6017 pkgmgr_certindexinfo_x *indexinfo = NULL;
6018 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
6019 if (indexinfo == NULL) {
6020 _LOGE("Out of Memory!!!");
6021 return PMINFO_R_ERROR;
6023 info->pkgid = strdup(pkgid);
6026 ret = db_util_open_with_options(CERT_DB, &cert_db,
6027 SQLITE_OPEN_READWRITE, NULL);
6028 if (ret != SQLITE_OK) {
6029 _LOGE("connect db [%s] failed!\n", CERT_DB);
6030 ret = PMINFO_R_ERROR;
6033 /*Begin Transaction*/
6034 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6035 if (ret != SQLITE_OK) {
6036 _LOGE("Failed to begin transaction\n");
6037 ret = PMINFO_R_ERROR;
6040 _LOGE("Transaction Begin\n");
6041 /*Check if request is to insert/update*/
6042 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6044 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6045 _LOGE("Don't execute query = %s error message = %s\n", query,
6047 sqlite3_free(error_message);
6048 ret = PMINFO_R_ERROR;
6053 We cant just issue update query directly. We need to manage index table also.
6054 Hence it is better to delete and insert again in case of update*/
6055 ret = __delete_certinfo(pkgid);
6057 _LOGE("Certificate Deletion Failed\n");
6059 for (i = 0; i < MAX_CERT_TYPE; i++) {
6060 if ((info->cert_info)[i]) {
6061 for (j = 0; j < i; j++) {
6062 if ( (info->cert_info)[j]) {
6063 if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
6064 (info->cert_id)[i] = (info->cert_id)[j];
6065 (info->is_new)[i] = 0;
6066 (info->ref_count)[i] = (info->ref_count)[j];
6073 memset(query, '\0', MAX_QUERY_LEN);
6074 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
6075 "where cert_info='%s'",(info->cert_info)[i]);
6076 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
6078 _LOGE("Cert Info DB Information retrieval failed\n");
6079 ret = PMINFO_R_ERROR;
6082 if (indexinfo->cert_id == 0) {
6083 /*New certificate. Get newid*/
6084 memset(query, '\0', MAX_QUERY_LEN);
6085 snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
6087 sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
6088 _LOGE("Don't execute query = %s error message = %s\n", query,
6090 sqlite3_free(error_message);
6091 ret = PMINFO_R_ERROR;
6099 indexinfo->cert_id = maxid;
6100 indexinfo->cert_ref_count = 1;
6104 (info->cert_id)[i] = indexinfo->cert_id;
6105 (info->is_new)[i] = is_new;
6106 (info->ref_count)[i] = indexinfo->cert_ref_count;
6107 _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
6108 indexinfo->cert_id = 0;
6109 indexinfo->cert_ref_count = 0;
6113 len = MAX_QUERY_LEN;
6114 for (i = 0; i < MAX_CERT_TYPE; i++) {
6115 if ((info->cert_info)[i])
6116 len+= strlen((info->cert_info)[i]);
6118 vquery = (char *)calloc(1, len);
6120 snprintf(vquery, len,
6121 "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
6122 "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
6123 "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
6124 info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
6125 (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
6126 (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
6127 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
6128 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
6130 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6131 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6133 sqlite3_free(error_message);
6134 ret = PMINFO_R_ERROR;
6137 /*Update index table info*/
6138 /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
6139 for (i = 0; i < MAX_CERT_TYPE; i++) {
6140 if ((info->cert_info)[i]) {
6141 memset(vquery, '\0', len);
6142 if ((info->is_new)[i]) {
6143 snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
6144 "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
6145 unique_id[c++] = (info->cert_id)[i];
6148 for (j = 0; j < MAX_CERT_TYPE; j++) {
6149 if ((info->cert_id)[i] == unique_id[j]) {
6150 /*Ref count has already been increased. Just continue*/
6154 if (j == MAX_CERT_TYPE)
6155 unique_id[c++] = (info->cert_id)[i];
6158 snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
6159 "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
6162 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6163 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6165 sqlite3_free(error_message);
6166 ret = PMINFO_R_ERROR;
6171 /*Commit transaction*/
6172 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6173 if (ret != SQLITE_OK) {
6174 _LOGE("Failed to commit transaction, Rollback now\n");
6175 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6176 ret = PMINFO_R_ERROR;
6179 _LOGE("Transaction Commit and End\n");
6182 sqlite3_close(cert_db);
6194 API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
6196 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6198 pkgmgr_instcertinfo_x *certinfo = NULL;
6199 certinfo = (pkgmgr_instcertinfo_x *)handle;
6200 if (certinfo->pkgid) {
6201 free(certinfo->pkgid);
6202 certinfo->pkgid = NULL;
6204 for (i = 0; i < MAX_CERT_TYPE; i++) {
6205 if ((certinfo->cert_info)[i]) {
6206 free((certinfo->cert_info)[i]);
6207 (certinfo->cert_info)[i] = NULL;
6215 API int pkgmgrinfo_delete_certinfo(const char *pkgid)
6217 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6220 ret = db_util_open_with_options(CERT_DB, &cert_db,
6221 SQLITE_OPEN_READWRITE, NULL);
6222 if (ret != SQLITE_OK) {
6223 _LOGE("connect db [%s] failed!\n", CERT_DB);
6224 ret = PMINFO_R_ERROR;
6227 /*Begin Transaction*/
6228 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6229 if (ret != SQLITE_OK) {
6230 _LOGE("Failed to begin transaction\n");
6231 ret = PMINFO_R_ERROR;
6234 _LOGE("Transaction Begin\n");
6235 ret = __delete_certinfo(pkgid);
6237 _LOGE("Certificate Deletion Failed\n");
6239 _LOGE("Certificate Deletion Success\n");
6241 /*Commit transaction*/
6242 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6243 if (ret != SQLITE_OK) {
6244 _LOGE("Failed to commit transaction, Rollback now\n");
6245 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6246 ret = PMINFO_R_ERROR;
6249 _LOGE("Transaction Commit and End\n");
6252 sqlite3_close(cert_db);
6256 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
6258 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
6259 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6261 char *manifest = NULL;
6262 manifest_x *mfx = NULL;
6264 manifest = pkgmgr_parser_get_manifest_file(pkgid);
6265 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
6267 mfx = pkgmgr_parser_process_manifest_xml(manifest);
6272 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
6274 *handle = (void *)mfx;
6279 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
6281 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
6282 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6284 int len = strlen(type);
6285 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6287 manifest_x *mfx = (manifest_x *)handle;
6289 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
6293 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
6295 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
6296 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6298 int len = strlen(version);
6299 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6301 manifest_x *mfx = (manifest_x *)handle;
6303 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
6307 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6309 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6310 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6312 manifest_x *mfx = (manifest_x *)handle;
6314 if (location == INSTALL_INTERNAL)
6315 strcpy(mfx->installlocation, "internal-only");
6316 else if (location == INSTALL_EXTERNAL)
6317 strcpy(mfx->installlocation, "prefer-external");
6322 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
6324 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6325 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6327 manifest_x *mfx = (manifest_x *)handle;
6329 mfx->package_size = strdup(size);
6334 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
6336 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6337 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6339 int len = strlen(label_txt);
6340 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6342 manifest_x *mfx = (manifest_x *)handle;
6344 label_x *label = calloc(1, sizeof(label_x));
6345 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6347 LISTADD(mfx->label, label);
6349 mfx->label->lang = strdup(locale);
6351 mfx->label->lang = strdup(DEFAULT_LOCALE);
6352 mfx->label->text = strdup(label_txt);
6357 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
6359 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6360 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6362 int len = strlen(icon_txt);
6363 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6365 manifest_x *mfx = (manifest_x *)handle;
6367 icon_x *icon = calloc(1, sizeof(icon_x));
6368 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6370 LISTADD(mfx->icon, icon);
6372 mfx->icon->lang = strdup(locale);
6374 mfx->icon->lang = strdup(DEFAULT_LOCALE);
6375 mfx->icon->text = strdup(icon_txt);
6380 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
6382 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6383 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6385 int len = strlen(desc_txt);
6386 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6388 manifest_x *mfx = (manifest_x *)handle;
6390 description_x *description = calloc(1, sizeof(description_x));
6391 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6393 LISTADD(mfx->description, description);
6395 mfx->description->lang = strdup(locale);
6397 mfx->description->lang = strdup(DEFAULT_LOCALE);
6398 mfx->description->text = strdup(desc_txt);
6403 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
6404 const char *author_email, const char *author_href, const char *locale)
6406 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6407 manifest_x *mfx = (manifest_x *)handle;
6408 author_x *author = calloc(1, sizeof(author_x));
6409 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6411 LISTADD(mfx->author, author);
6413 mfx->author->text = strdup(author_name);
6415 mfx->author->email = strdup(author_email);
6417 mfx->author->href = strdup(author_href);
6419 mfx->author->lang = strdup(locale);
6421 mfx->author->lang = strdup(DEFAULT_LOCALE);
6425 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
6427 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6428 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6430 manifest_x *mfx = (manifest_x *)handle;
6433 strcpy(mfx->removable, "false");
6434 else if (removable == 1)
6435 strcpy(mfx->removable, "true");
6440 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
6442 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6443 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6445 manifest_x *mfx = (manifest_x *)handle;
6448 strcpy(mfx->preload, "false");
6449 else if (preload == 1)
6450 strcpy(mfx->preload, "true");
6455 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6457 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6458 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6460 manifest_x *mfx = (manifest_x *)handle;
6462 if (location == INSTALL_INTERNAL)
6463 strcpy(mfx->installed_storage, "installed_internal");
6464 else if (location == INSTALL_EXTERNAL)
6465 strcpy(mfx->installed_storage, "installed_external");
6470 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6472 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6475 manifest_x *mfx = NULL;
6476 mfx = (manifest_x *)handle;
6478 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
6480 _LOGE("Successfully stored info in DB\n");
6483 _LOGE("Failed to store info in DB\n");
6484 return PMINFO_R_ERROR;
6488 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6490 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6492 manifest_x *mfx = NULL;
6493 mfx = (manifest_x *)handle;
6494 pkgmgr_parser_free_manifest_xml(mfx);
6498 API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
6500 /* Should be implemented later */
6504 API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
6506 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6508 char query[MAX_QUERY_LEN] = {'\0'};
6509 ret = __open_manifest_db();
6511 if (access(MANIFEST_DB, F_OK) == 0) {
6512 ret = db_util_open(MANIFEST_DB, &manifest_db,
6513 DB_UTIL_REGISTER_HOOK_METHOD);
6514 if (ret != SQLITE_OK) {
6515 _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
6516 return PMINFO_R_ERROR;
6520 /*Begin transaction*/
6521 ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6522 if (ret != SQLITE_OK) {
6523 _LOGE("Failed to begin transaction\n");
6524 sqlite3_close(manifest_db);
6525 return PMINFO_R_ERROR;
6527 _LOGD("Transaction Begin\n");
6529 memset(query, '\0', MAX_QUERY_LEN);
6530 snprintf(query, MAX_QUERY_LEN,
6531 "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
6533 char *error_message = NULL;
6535 sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
6536 _LOGE("Don't execute query = %s error message = %s\n", query,
6538 sqlite3_free(error_message);
6539 return PMINFO_R_ERROR;
6541 sqlite3_free(error_message);
6543 /*Commit transaction*/
6544 ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
6545 if (ret != SQLITE_OK) {
6546 _LOGE("Failed to commit transaction. Rollback now\n");
6547 sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
6548 sqlite3_close(manifest_db);
6549 return PMINFO_R_ERROR;
6551 _LOGD("Transaction Commit and End\n");
6552 sqlite3_close(manifest_db);
6558 API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
6560 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6561 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6562 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6563 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6564 int ret = PMINFO_R_OK;
6565 char query[MAX_QUERY_LEN] = {'\0'};
6566 char *error_message = NULL;
6567 pkgmgr_datacontrol_x *data = NULL;
6569 ret = __open_datacontrol_db();
6571 _LOGE("Fail to open datacontrol DB\n");
6572 return PMINFO_R_ERROR;
6575 data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x));
6577 _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
6578 sqlite3_close(datacontrol_db);
6579 return PMINFO_R_ERROR;
6582 snprintf(query, MAX_QUERY_LEN,
6583 "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",
6587 sqlite3_exec(datacontrol_db, query, __datacontrol_cb, (void *)data, &error_message)) {
6588 _LOGE("Don't execute query = %s error message = %s\n", query,
6590 sqlite3_free(error_message);
6591 sqlite3_close(datacontrol_db);
6592 return PMINFO_R_ERROR;
6595 *appid = (char *)data->appid;
6596 *access = (char *)data->access;
6598 sqlite3_close(datacontrol_db);
6603 API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
6605 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6607 char query[MAX_QUERY_LEN] = {'\0'};
6608 char *error_message = NULL;
6609 ret = __open_manifest_db();
6611 if (access(MANIFEST_DB, F_OK) == 0) {
6612 ret = db_util_open(MANIFEST_DB, &manifest_db,
6613 DB_UTIL_REGISTER_HOOK_METHOD);
6614 if (ret != SQLITE_OK) {
6615 _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
6616 return PMINFO_R_ERROR;
6620 /*Begin transaction*/
6621 ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6622 if (ret != SQLITE_OK) {
6623 _LOGE("Failed to begin transaction\n");
6624 sqlite3_close(manifest_db);
6625 return PMINFO_R_ERROR;
6627 _LOGD("Transaction Begin\n");
6629 memset(query, '\0', MAX_QUERY_LEN);
6630 snprintf(query, MAX_QUERY_LEN,
6631 "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid);
6634 sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
6635 _LOGE("Don't execute query = %s error message = %s\n", query,
6637 sqlite3_free(error_message);
6638 return PMINFO_R_ERROR;
6641 /*Commit transaction*/
6642 ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
6643 if (ret != SQLITE_OK) {
6644 _LOGE("Failed to commit transaction. Rollback now\n");
6645 sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
6646 sqlite3_close(manifest_db);
6647 return PMINFO_R_ERROR;
6649 _LOGD("Transaction Commit and End\n");
6650 sqlite3_close(manifest_db);
6655 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
6657 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6658 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6660 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6661 val = (char *)info->uiapp_info->guestmode_visibility;
6663 if (strcasecmp(val, "true") == 0){
6665 }else if (strcasecmp(val, "false") == 0){
6674 API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
6676 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6679 char *noti_string = NULL;
6681 char query[MAX_QUERY_LEN] = {'\0'};
6682 char *errmsg = NULL;
6683 sqlite3 *pkgmgr_parser_db;
6685 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6686 val = (char *)info->uiapp_info->guestmode_visibility;
6689 db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db,
6690 SQLITE_OPEN_READWRITE, NULL);
6692 if (ret != SQLITE_OK) {
6693 _LOGE("DB Open Failed\n");
6694 return PMINFO_R_ERROR;
6697 /*TODO: Write to DB here*/
6699 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
6701 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
6703 if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
6704 _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
6706 sqlite3_close(pkgmgr_parser_db);
6707 return PMINFO_R_ERROR;
6709 sqlite3_close(pkgmgr_parser_db);
6710 len = strlen((char *)info->uiapp_info->appid) + 8;
6711 noti_string = calloc(1, len);
6712 if (noti_string == NULL){
6713 return PMINFO_R_ERROR;
6715 snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
6716 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
6717 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed