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], "privilege") == 0 ){
1065 info->manifest_info->privileges->privilege->text = strdup(coltxt[i]);
1067 info->manifest_info->privileges->privilege->text = NULL;
1068 } else if (strcmp(colname[i], "package_locale") == 0 ){
1070 info->manifest_info->author->lang = strdup(coltxt[i]);
1071 info->manifest_info->icon->lang = strdup(coltxt[i]);
1072 info->manifest_info->label->lang = strdup(coltxt[i]);
1073 info->manifest_info->description->lang = strdup(coltxt[i]);
1076 info->manifest_info->author->lang = NULL;
1077 info->manifest_info->icon->lang = NULL;
1078 info->manifest_info->label->lang = NULL;
1079 info->manifest_info->description->lang = NULL;
1081 } else if (strcmp(colname[i], "package_url") == 0 ){
1083 info->manifest_info->package_url = strdup(coltxt[i]);
1085 info->manifest_info->package_url = NULL;
1093 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1095 if ( strcasecmp(comp, "uiapp") == 0)
1096 return PMINFO_UI_APP;
1097 else if ( strcasecmp(comp, "svcapp") == 0)
1098 return PMINFO_SVC_APP;
1103 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1105 pkgmgr_certindexinfo_x *info = (pkgmgr_certindexinfo_x *)data;
1107 for(i = 0; i < ncols; i++) {
1108 if (strcmp(colname[i], "cert_id") == 0) {
1110 info->cert_id = atoi(coltxt[i]);
1113 } else if (strcmp(colname[i], "cert_ref_count") == 0) {
1115 info->cert_ref_count = atoi(coltxt[i]);
1117 info->cert_ref_count = 0;
1123 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1125 pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)data;
1127 for(i = 0; i < ncols; i++)
1129 if (strcmp(colname[i], "package") == 0) {
1131 info->pkgid = strdup(coltxt[i]);
1134 } else if (strcmp(colname[i], "author_signer_cert") == 0) {
1136 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = atoi(coltxt[i]);
1138 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = 0;
1139 } else if (strcmp(colname[i], "author_im_cert") == 0) {
1141 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1143 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 0;
1144 } else if (strcmp(colname[i], "author_root_cert") == 0) {
1146 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = atoi(coltxt[i]);
1148 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = 0;
1149 } else if (strcmp(colname[i], "dist_signer_cert") == 0 ){
1151 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = atoi(coltxt[i]);
1153 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 0;
1154 } else if (strcmp(colname[i], "dist_im_cert") == 0 ){
1156 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1158 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 0;
1159 } else if (strcmp(colname[i], "dist_root_cert") == 0 ){
1161 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = atoi(coltxt[i]);
1163 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = 0;
1164 } else if (strcmp(colname[i], "dist2_signer_cert") == 0 ){
1166 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = atoi(coltxt[i]);
1168 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 0;
1169 } else if (strcmp(colname[i], "dist2_im_cert") == 0 ){
1171 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1173 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 0;
1174 } else if (strcmp(colname[i], "dist2_root_cert") == 0 ){
1176 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = atoi(coltxt[i]);
1178 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 0;
1179 } else if (strcmp(colname[i], "cert_info") == 0 ){
1181 info->cert_value = strdup(coltxt[i]);
1183 info->cert_value = NULL;
1190 static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1192 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1194 uiapplication_x *uiapp = NULL;
1195 uiapp = calloc(1, sizeof(uiapplication_x));
1196 if (uiapp == NULL) {
1197 _LOGE("Out of Memory!!!\n");
1201 LISTADD(info->uiapp_info, uiapp);
1203 for(i = 0; i < ncols; i++)
1205 if (strcmp(colname[i], "app_id") == 0) {
1206 /*appid being foreign key, is column in every table
1207 Hence appid gets strduped every time leading to memory leak.
1208 If appid is already set, just continue.*/
1209 if (info->uiapp_info->appid)
1212 info->uiapp_info->appid = strdup(coltxt[i]);
1214 info->uiapp_info->appid = NULL;
1215 } else if (strcmp(colname[i], "app_exec") == 0) {
1217 info->uiapp_info->exec = strdup(coltxt[i]);
1219 info->uiapp_info->exec = NULL;
1220 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1222 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1224 info->uiapp_info->nodisplay = NULL;
1225 } else if (strcmp(colname[i], "app_type") == 0 ) {
1227 info->uiapp_info->type = strdup(coltxt[i]);
1229 info->uiapp_info->type = NULL;
1230 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1232 info->uiapp_info->multiple = strdup(coltxt[i]);
1234 info->uiapp_info->multiple = NULL;
1235 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1237 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1239 info->uiapp_info->taskmanage = NULL;
1240 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1242 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1244 info->uiapp_info->hwacceleration = NULL;
1245 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1247 info->uiapp_info->enabled= strdup(coltxt[i]);
1249 info->uiapp_info->enabled = NULL;
1250 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1252 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1254 info->uiapp_info->indicatordisplay = NULL;
1255 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1257 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1259 info->uiapp_info->portraitimg = NULL;
1260 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1262 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1264 info->uiapp_info->landscapeimg = NULL;
1265 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1267 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1269 info->uiapp_info->guestmode_visibility = NULL;
1270 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1272 info->uiapp_info->recentimage = strdup(coltxt[i]);
1274 info->uiapp_info->recentimage = NULL;
1275 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1277 info->uiapp_info->mainapp = strdup(coltxt[i]);
1279 info->uiapp_info->mainapp = NULL;
1280 } else if (strcmp(colname[i], "package") == 0 ) {
1282 info->uiapp_info->package = strdup(coltxt[i]);
1284 info->uiapp_info->package = NULL;
1285 } else if (strcmp(colname[i], "app_component") == 0) {
1287 info->uiapp_info->app_component = strdup(coltxt[i]);
1289 info->uiapp_info->app_component = NULL;
1290 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1292 info->uiapp_info->permission_type = strdup(coltxt[i]);
1294 info->uiapp_info->permission_type = NULL;
1302 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1304 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1306 icon_x *icon = NULL;
1307 label_x *label = NULL;
1308 category_x *category = NULL;
1309 metadata_x *metadata = NULL;
1310 permission_x *permission = NULL;
1311 image_x *image = NULL;
1313 switch (info->app_component) {
1315 icon = calloc(1, sizeof(icon_x));
1316 LISTADD(info->uiapp_info->icon, icon);
1317 label = calloc(1, sizeof(label_x));
1318 LISTADD(info->uiapp_info->label, label);
1319 category = calloc(1, sizeof(category_x));
1320 LISTADD(info->uiapp_info->category, category);
1321 metadata = calloc(1, sizeof(metadata_x));
1322 LISTADD(info->uiapp_info->metadata, metadata);
1323 permission = calloc(1, sizeof(permission_x));
1324 LISTADD(info->uiapp_info->permission, permission);
1325 image = calloc(1, sizeof(image_x));
1326 LISTADD(info->uiapp_info->image, image);
1328 for(i = 0; i < ncols; i++)
1330 if (strcmp(colname[i], "app_id") == 0) {
1331 /*appid being foreign key, is column in every table
1332 Hence appid gets strduped every time leading to memory leak.
1333 If appid is already set, just continue.*/
1334 if (info->uiapp_info->appid)
1337 info->uiapp_info->appid = strdup(coltxt[i]);
1339 info->uiapp_info->appid = NULL;
1340 } else if (strcmp(colname[i], "app_exec") == 0) {
1342 info->uiapp_info->exec = strdup(coltxt[i]);
1344 info->uiapp_info->exec = NULL;
1345 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1347 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1349 info->uiapp_info->nodisplay = NULL;
1350 } else if (strcmp(colname[i], "app_type") == 0 ) {
1352 info->uiapp_info->type = strdup(coltxt[i]);
1354 info->uiapp_info->type = NULL;
1355 } else if (strcmp(colname[i], "app_icon_section") == 0 ) {
1357 info->uiapp_info->icon->section= strdup(coltxt[i]);
1359 info->uiapp_info->icon->section = NULL;
1360 } else if (strcmp(colname[i], "app_icon") == 0) {
1362 info->uiapp_info->icon->text = strdup(coltxt[i]);
1364 info->uiapp_info->icon->text = NULL;
1365 } else if (strcmp(colname[i], "app_label") == 0 ) {
1367 info->uiapp_info->label->text = strdup(coltxt[i]);
1369 info->uiapp_info->label->text = NULL;
1370 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1372 info->uiapp_info->multiple = strdup(coltxt[i]);
1374 info->uiapp_info->multiple = NULL;
1375 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1377 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1379 info->uiapp_info->taskmanage = NULL;
1380 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1382 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1384 info->uiapp_info->hwacceleration = NULL;
1385 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1387 info->uiapp_info->enabled= strdup(coltxt[i]);
1389 info->uiapp_info->enabled = NULL;
1390 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1392 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1394 info->uiapp_info->indicatordisplay = NULL;
1395 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1397 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1399 info->uiapp_info->portraitimg = NULL;
1400 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1402 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1404 info->uiapp_info->landscapeimg = NULL;
1405 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1407 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1409 info->uiapp_info->guestmode_visibility = NULL;
1410 } else if (strcmp(colname[i], "category") == 0 ) {
1412 info->uiapp_info->category->name = strdup(coltxt[i]);
1414 info->uiapp_info->category->name = NULL;
1415 } else if (strcmp(colname[i], "md_key") == 0 ) {
1417 info->uiapp_info->metadata->key = strdup(coltxt[i]);
1419 info->uiapp_info->metadata->key = NULL;
1420 } else if (strcmp(colname[i], "md_value") == 0 ) {
1422 info->uiapp_info->metadata->value = strdup(coltxt[i]);
1424 info->uiapp_info->metadata->value = NULL;
1425 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1427 info->uiapp_info->permission->type= strdup(coltxt[i]);
1429 info->uiapp_info->permission->type = NULL;
1430 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1432 info->uiapp_info->permission->value = strdup(coltxt[i]);
1434 info->uiapp_info->permission->value = NULL;
1435 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1437 info->uiapp_info->recentimage = strdup(coltxt[i]);
1439 info->uiapp_info->recentimage = NULL;
1440 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1442 info->uiapp_info->mainapp = strdup(coltxt[i]);
1444 info->uiapp_info->mainapp = NULL;
1445 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1447 info->uiapp_info->icon->lang = strdup(coltxt[i]);
1448 info->uiapp_info->label->lang = strdup(coltxt[i]);
1451 info->uiapp_info->icon->lang = NULL;
1452 info->uiapp_info->label->lang = NULL;
1454 } else if (strcmp(colname[i], "app_image") == 0) {
1456 info->uiapp_info->image->text= strdup(coltxt[i]);
1458 info->uiapp_info->image->text = NULL;
1459 } else if (strcmp(colname[i], "app_image_section") == 0) {
1461 info->uiapp_info->image->section= strdup(coltxt[i]);
1463 info->uiapp_info->image->section = NULL;
1464 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1466 info->uiapp_info->permission_type = strdup(coltxt[i]);
1468 info->uiapp_info->permission_type = NULL;
1473 case PMINFO_SVC_APP:
1474 icon = calloc(1, sizeof(icon_x));
1475 LISTADD(info->svcapp_info->icon, icon);
1476 label = calloc(1, sizeof(label_x));
1477 LISTADD(info->svcapp_info->label, label);
1478 category = calloc(1, sizeof(category_x));
1479 LISTADD(info->svcapp_info->category, category);
1480 metadata = calloc(1, sizeof(metadata_x));
1481 LISTADD(info->svcapp_info->metadata, metadata);
1482 permission = calloc(1, sizeof(permission_x));
1483 LISTADD(info->svcapp_info->permission, permission);
1484 for(i = 0; i < ncols; i++)
1486 if (strcmp(colname[i], "app_id") == 0) {
1487 /*appid being foreign key, is column in every table
1488 Hence appid gets strduped every time leading to memory leak.
1489 If appid is already set, just continue.*/
1490 if (info->svcapp_info->appid)
1493 info->svcapp_info->appid = strdup(coltxt[i]);
1495 info->svcapp_info->appid = NULL;
1496 } else if (strcmp(colname[i], "app_exec") == 0) {
1498 info->svcapp_info->exec = strdup(coltxt[i]);
1500 info->svcapp_info->exec = NULL;
1501 } else if (strcmp(colname[i], "app_icon") == 0) {
1503 info->svcapp_info->icon->text = strdup(coltxt[i]);
1505 info->svcapp_info->icon->text = NULL;
1506 } else if (strcmp(colname[i], "app_label") == 0 ) {
1508 info->svcapp_info->label->text = strdup(coltxt[i]);
1510 info->svcapp_info->label->text = NULL;
1511 } else if (strcmp(colname[i], "app_type") == 0 ) {
1513 info->svcapp_info->type = strdup(coltxt[i]);
1515 info->svcapp_info->type = NULL;
1516 } else if (strcmp(colname[i], "app_onboot") == 0 ) {
1518 info->svcapp_info->onboot = strdup(coltxt[i]);
1520 info->svcapp_info->onboot = NULL;
1521 } else if (strcmp(colname[i], "app_autorestart") == 0 ) {
1523 info->svcapp_info->autorestart = strdup(coltxt[i]);
1525 info->svcapp_info->autorestart = NULL;
1526 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1528 info->svcapp_info->enabled= strdup(coltxt[i]);
1530 info->svcapp_info->enabled = NULL;
1531 } else if (strcmp(colname[i], "category") == 0 ) {
1533 info->svcapp_info->category->name = strdup(coltxt[i]);
1535 info->svcapp_info->category->name = NULL;
1536 } else if (strcmp(colname[i], "md_key") == 0 ) {
1538 info->svcapp_info->metadata->key = strdup(coltxt[i]);
1540 info->svcapp_info->metadata->key = NULL;
1541 } else if (strcmp(colname[i], "md_value") == 0 ) {
1543 info->svcapp_info->metadata->value = strdup(coltxt[i]);
1545 info->svcapp_info->metadata->value = NULL;
1546 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1548 info->svcapp_info->permission->type= strdup(coltxt[i]);
1550 info->svcapp_info->permission->type = NULL;
1551 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1553 info->svcapp_info->permission->value = strdup(coltxt[i]);
1555 info->svcapp_info->permission->value = NULL;
1556 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1558 info->svcapp_info->icon->lang = strdup(coltxt[i]);
1559 info->svcapp_info->label->lang = strdup(coltxt[i]);
1562 info->svcapp_info->icon->lang = NULL;
1563 info->svcapp_info->label->lang = NULL;
1565 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1567 info->svcapp_info->permission_type = strdup(coltxt[i]);
1569 info->svcapp_info->permission_type = NULL;
1582 static int __appcomponent_cb(void *data, int ncols, char **coltxt, char **colname)
1584 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1586 for(i = 0; i < ncols; i++)
1588 if (strcmp(colname[i], "app_component") == 0) {
1589 info->app_component = __appcomponent_convert(coltxt[i]);
1590 } else if (strcmp(colname[i], "package") == 0) {
1591 info->package = strdup(coltxt[i]);
1598 static int __datacontrol_cb(void *data, int ncols, char **coltxt, char **colname)
1600 pkgmgr_datacontrol_x *info = (pkgmgr_datacontrol_x *)data;
1602 for(i = 0; i < ncols; i++)
1604 if (strcmp(colname[i], "PACKAGE_NAME") == 0) {
1606 info->appid = strdup(coltxt[i]);
1609 } else if (strcmp(colname[i], "ACCESS") == 0 ){
1611 info->access = strdup(coltxt[i]);
1613 info->access = NULL;
1620 static int __cert_cb(void *data, int ncols, char **coltxt, char **colname)
1622 pkgmgr_cert_x *info = (pkgmgr_cert_x *)data;
1625 for(i = 0; i < ncols; i++)
1627 if (strcmp(colname[i], "author_signer_cert") == 0) {
1629 info->cert_id = atoi(coltxt[i]);
1632 } else if (strcmp(colname[i], "package") == 0) {
1634 info->pkgid= strdup(coltxt[i]);
1643 /* get the first locale value*/
1644 static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
1646 pkgmgr_locale_x *info = (pkgmgr_locale_x *)data;
1649 info->locale = strdup(coltxt[0]);
1651 info->locale = NULL;
1656 static int __exec_pkginfo_query(char *query, void *data)
1658 char *error_message = NULL;
1660 sqlite3_exec(manifest_db, query, __pkginfo_cb, data, &error_message)) {
1661 _LOGE("Don't execute query = %s error message = %s\n", query,
1663 sqlite3_free(error_message);
1666 sqlite3_free(error_message);
1670 static int __exec_certinfo_query(char *query, void *data)
1672 char *error_message = NULL;
1674 sqlite3_exec(cert_db, query, __certinfo_cb, data, &error_message)) {
1675 _LOGE("Don't execute query = %s error message = %s\n", query,
1677 sqlite3_free(error_message);
1680 sqlite3_free(error_message);
1684 static int __exec_certindexinfo_query(char *query, void *data)
1686 char *error_message = NULL;
1688 sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
1689 _LOGE("Don't execute query = %s error message = %s\n", query,
1691 sqlite3_free(error_message);
1694 sqlite3_free(error_message);
1698 static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data)
1700 char *error_message = NULL;
1702 sqlite3_exec(db, query, callback, data, &error_message)) {
1703 _LOGE("Don't execute query = %s error message = %s\n", query,
1705 sqlite3_free(error_message);
1708 sqlite3_free(error_message);
1713 static int __child_element(xmlTextReaderPtr reader, int depth)
1715 int ret = xmlTextReaderRead(reader);
1716 int cur = xmlTextReaderDepth(reader);
1719 switch (xmlTextReaderNodeType(reader)) {
1720 case XML_READER_TYPE_ELEMENT:
1721 if (cur == depth + 1)
1724 case XML_READER_TYPE_TEXT:
1725 /*text is handled by each function separately*/
1726 if (cur == depth + 1)
1729 case XML_READER_TYPE_END_ELEMENT:
1738 ret = xmlTextReaderRead(reader);
1739 cur = xmlTextReaderDepth(reader);
1744 static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, char **colname)
1746 int *p = (int*)data;
1747 *p = atoi(coltxt[0]);
1751 static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale)
1753 int result_query = -1;
1755 char query[MAX_QUERY_LEN];
1757 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);
1758 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1759 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1760 return result_query;
1763 static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1765 int result_query = -1;
1767 char wildcard[2] = {'%','\0'};
1768 char query[MAX_QUERY_LEN];
1769 char lang[3] = {'\0'};
1770 strncpy(lang, locale, LANGUAGE_LENGTH);
1772 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);
1773 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1774 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1775 return result_query;
1778 static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1781 char wildcard[2] = {'%','\0'};
1782 char lang[3] = {'\0'};
1783 char query[MAX_QUERY_LEN];
1784 char *locale_new = NULL;
1785 pkgmgr_locale_x *info = NULL;
1787 info = (pkgmgr_locale_x *)malloc(sizeof(pkgmgr_locale_x));
1789 _LOGE("Out of Memory!!!\n");
1792 memset(info, '\0', sizeof(*info));
1794 strncpy(lang, locale, 2);
1795 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);
1796 ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
1797 tryvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1798 locale_new = info->locale;
1809 static char* __convert_syslocale_to_manifest_locale(char *syslocale)
1811 char *locale = malloc(6);
1813 _LOGE("Malloc Failed\n");
1817 sprintf(locale, "%c%c-%c%c", syslocale[0], syslocale[1], tolower(syslocale[3]), tolower(syslocale[4]));
1821 static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const char *syslocale)
1826 char *locale = NULL;
1827 char *locale_new = NULL;
1828 int check_result = 0;
1830 locale = __convert_syslocale_to_manifest_locale((char *)syslocale);
1832 /*check exact matching */
1833 check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale);
1836 if (check_result == 1) {
1837 _LOGD("%s find exact locale(%s)\n", appid, locale);
1841 /* fallback matching */
1842 check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
1843 if(check_result == 1) {
1844 locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
1845 _LOGD("%s found (%s) language-locale in DB by fallback!\n", appid, locale_new);
1847 if (locale_new == NULL)
1848 locale_new = strdup(DEFAULT_LOCALE);
1852 /* default locale */
1854 _LOGD("%s DEFAULT_LOCALE)\n", appid);
1855 return strdup(DEFAULT_LOCALE);
1858 long long _pkgmgr_calculate_dir_size(char *dirname)
1860 long long total = 0;
1862 int q = 0; /*quotient*/
1863 int r = 0; /*remainder*/
1865 struct dirent *ep = NULL;
1866 struct stat fileinfo;
1867 char abs_filename[FILENAME_MAX] = { 0, };
1868 retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL");
1870 dp = opendir(dirname);
1872 while ((ep = readdir(dp)) != NULL) {
1873 if (!strcmp(ep->d_name, ".") ||
1874 !strcmp(ep->d_name, "..")) {
1877 snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
1879 if (lstat(abs_filename, &fileinfo) < 0)
1880 perror(abs_filename);
1882 if (S_ISDIR(fileinfo.st_mode)) {
1883 total += fileinfo.st_size;
1884 if (strcmp(ep->d_name, ".")
1885 && strcmp(ep->d_name, "..")) {
1886 ret = _pkgmgr_calculate_dir_size
1888 total = total + ret;
1890 } else if (S_ISLNK(fileinfo.st_mode)) {
1893 /*It is a file. Calculate the actual
1894 size occupied (in terms of 4096 blocks)*/
1895 q = (fileinfo.st_size / BLOCK_SIZE);
1896 r = (fileinfo.st_size % BLOCK_SIZE);
1900 total += q * BLOCK_SIZE;
1906 _LOGE("Couldn't open the directory\n");
1913 static int __delete_certinfo(const char *pkgid)
1919 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
1920 char *error_message = NULL;
1921 char query[MAX_QUERY_LEN] = {'\0'};
1922 pkgmgr_certinfo_x *certinfo = NULL;
1923 pkgmgr_certindexinfo_x *indexinfo = NULL;
1924 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
1925 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
1926 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
1927 if (indexinfo == NULL) {
1928 _LOGE("Out of Memory!!!");
1929 ret = PMINFO_R_ERROR;
1932 /*populate certinfo from DB*/
1933 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
1934 ret = __exec_certinfo_query(query, (void *)certinfo);
1936 _LOGE("Package Cert Info DB Information retrieval failed\n");
1937 ret = PMINFO_R_ERROR;
1940 /*Update cert index table*/
1941 for (i = 0; i < MAX_CERT_TYPE; i++) {
1942 if ((certinfo->cert_id)[i]) {
1943 for (j = 0; j < MAX_CERT_TYPE; j++) {
1944 if ((certinfo->cert_id)[i] == unique_id[j]) {
1945 /*Ref count has already been updated. Just continue*/
1949 if (j == MAX_CERT_TYPE)
1950 unique_id[c++] = (certinfo->cert_id)[i];
1953 memset(query, '\0', MAX_QUERY_LEN);
1954 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
1955 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
1957 _LOGE("Cert Info DB Information retrieval failed\n");
1958 ret = PMINFO_R_ERROR;
1961 memset(query, '\0', MAX_QUERY_LEN);
1962 if (indexinfo->cert_ref_count > 1) {
1963 /*decrease ref count*/
1964 snprintf(query, MAX_QUERY_LEN, "update package_cert_index_info set cert_ref_count=%d where cert_id=%d ",
1965 indexinfo->cert_ref_count - 1, (certinfo->cert_id)[i]);
1967 /*delete this certificate as ref count is 1 and it will become 0*/
1968 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
1971 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
1972 _LOGE("Don't execute query = %s error message = %s\n", query,
1974 sqlite3_free(error_message);
1975 ret = PMINFO_R_ERROR;
1980 /*Now delete the entry from db*/
1981 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
1983 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
1984 _LOGE("Don't execute query = %s error message = %s\n", query,
1986 sqlite3_free(error_message);
1987 ret = PMINFO_R_ERROR;
1996 if (certinfo->pkgid) {
1997 free(certinfo->pkgid);
1998 certinfo->pkgid = NULL;
2000 for (i = 0; i < MAX_CERT_TYPE; i++) {
2001 if ((certinfo->cert_info)[i]) {
2002 free((certinfo->cert_info)[i]);
2003 (certinfo->cert_info)[i] = NULL;
2011 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
2013 retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
2014 char *error_message = NULL;
2015 int ret = PMINFO_R_OK;
2016 char query[MAX_QUERY_LEN] = {'\0'};
2017 char *syslocale = NULL;
2018 char *locale = NULL;
2019 pkgmgr_pkginfo_x *pkginfo = NULL;
2020 label_x *tmp1 = NULL;
2021 icon_x *tmp2 = NULL;
2022 description_x *tmp3 = NULL;
2023 author_x *tmp4 = NULL;
2024 privilege_x *tmp5 = NULL;
2026 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2027 if (syslocale == NULL) {
2028 _LOGE("current locale is NULL\n");
2029 ret = PMINFO_R_ERROR;
2032 locale = __convert_system_locale_to_manifest_locale(syslocale);
2033 if (locale == NULL) {
2034 _LOGE("manifest locale is NULL\n");
2035 ret = PMINFO_R_EINVAL;
2039 ret = __open_manifest_db();
2041 _LOGE("Fail to open manifest DB\n");
2042 ret = PMINFO_R_ERROR;
2045 pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2046 pkgmgr_pkginfo_x *node = NULL;
2047 pkgmgr_pkginfo_x *temp_node = NULL;
2049 snprintf(query, MAX_QUERY_LEN, "select * from package_info");
2051 sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
2052 _LOGE("Don't execute query = %s error message = %s\n", query,
2054 sqlite3_free(error_message);
2055 sqlite3_close(manifest_db);
2056 ret = PMINFO_R_ERROR;
2060 LISTHEAD(tmphead, node);
2062 for(node = node->next; node ; node = node->next) {
2064 pkginfo->locale = strdup(locale);
2065 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2066 if (pkginfo->manifest_info->privileges == NULL) {
2067 _LOGE("Failed to allocate memory for privileges info\n");
2068 ret = PMINFO_R_ERROR;
2071 /*populate manifest_info from DB*/
2072 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
2073 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2075 _LOGE("Package Info DB Information retrieval failed\n");
2076 ret = PMINFO_R_ERROR;
2079 memset(query, '\0', MAX_QUERY_LEN);
2080 /*populate privilege_info from DB*/
2081 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package);
2082 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2084 _LOGE("Package Privilege Info DB Information retrieval failed\n");
2085 ret = PMINFO_R_ERROR;
2088 memset(query, '\0', MAX_QUERY_LEN);
2089 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2090 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
2091 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2093 _LOGE("Package Info DB Information retrieval failed\n");
2094 ret = PMINFO_R_ERROR;
2097 /*Also store the values corresponding to default locales*/
2098 memset(query, '\0', MAX_QUERY_LEN);
2099 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2100 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
2101 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2103 _LOGE("Package Info DB Information retrieval failed\n");
2104 ret = PMINFO_R_ERROR;
2107 if (pkginfo->manifest_info->label) {
2108 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2109 pkginfo->manifest_info->label = tmp1;
2111 if (pkginfo->manifest_info->icon) {
2112 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2113 pkginfo->manifest_info->icon = tmp2;
2115 if (pkginfo->manifest_info->description) {
2116 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2117 pkginfo->manifest_info->description = tmp3;
2119 if (pkginfo->manifest_info->author) {
2120 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2121 pkginfo->manifest_info->author = tmp4;
2123 if (pkginfo->manifest_info->privileges->privilege) {
2124 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2125 pkginfo->manifest_info->privileges->privilege = tmp5;
2129 LISTHEAD(tmphead, node);
2131 for(node = node->next; node ; node = node->next) {
2133 ret = pkg_list_cb( (void *)pkginfo, user_data);
2141 sqlite3_close(manifest_db);
2150 LISTHEAD(tmphead, node);
2151 temp_node = node->next;
2154 temp_node = node->next;
2155 __cleanup_pkginfo(node);
2158 __cleanup_pkginfo(tmphead);
2163 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
2165 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
2166 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2167 pkgmgr_pkginfo_x *pkginfo = NULL;
2168 int ret = PMINFO_R_OK;
2169 char query[MAX_QUERY_LEN] = {'\0'};
2170 char *syslocale = NULL;
2171 char *locale = NULL;
2173 label_x *tmp1 = NULL;
2174 icon_x *tmp2 = NULL;
2175 description_x *tmp3 = NULL;
2176 author_x *tmp4 = NULL;
2177 privilege_x *tmp5 = NULL;
2178 sqlite3 *pkginfo_db = NULL;
2181 ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
2182 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2184 /*check pkgid exist on db*/
2185 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
2186 ret = __exec_db_query(pkginfo_db, query, __validate_cb, (void *)&exist);
2187 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
2188 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] not found in DB", pkgid);
2190 /*get system locale*/
2191 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2192 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
2194 /*get locale on db*/
2195 locale = __convert_system_locale_to_manifest_locale(syslocale);
2196 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
2198 pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2199 tryvm_if(pkginfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for pkginfo");
2201 pkginfo->locale = strdup(locale);
2203 pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
2204 tryvm_if(pkginfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for manifest info");
2206 pkginfo->manifest_info->package = strdup(pkgid);
2207 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2208 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info");
2210 /*populate manifest_info from DB*/
2211 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
2212 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2213 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2215 memset(query, '\0', MAX_QUERY_LEN);
2216 /*populate privilege_info from DB*/
2217 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
2218 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2219 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
2221 memset(query, '\0', MAX_QUERY_LEN);
2222 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2223 " package='%s' and package_locale='%s'", pkgid, locale);
2224 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2225 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2227 /*Also store the values corresponding to default locales*/
2228 memset(query, '\0', MAX_QUERY_LEN);
2229 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2230 " package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
2231 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2232 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2234 if (pkginfo->manifest_info->label) {
2235 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2236 pkginfo->manifest_info->label = tmp1;
2238 if (pkginfo->manifest_info->icon) {
2239 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2240 pkginfo->manifest_info->icon = tmp2;
2242 if (pkginfo->manifest_info->description) {
2243 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2244 pkginfo->manifest_info->description = tmp3;
2246 if (pkginfo->manifest_info->author) {
2247 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2248 pkginfo->manifest_info->author = tmp4;
2250 if (pkginfo->manifest_info->privileges->privilege) {
2251 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2252 pkginfo->manifest_info->privileges->privilege = tmp5;
2256 if (ret == PMINFO_R_OK)
2257 *handle = (void*)pkginfo;
2260 __cleanup_pkginfo(pkginfo);
2262 sqlite3_close(pkginfo_db);
2276 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
2278 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2279 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2280 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2281 if (info->manifest_info->package)
2282 *pkg_name = (char *)info->manifest_info->package;
2284 return PMINFO_R_ERROR;
2289 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
2291 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2292 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2293 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2294 if (info->manifest_info->package)
2295 *pkgid = (char *)info->manifest_info->package;
2297 return PMINFO_R_ERROR;
2302 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
2304 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2305 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2306 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2307 if (info->manifest_info->type)
2308 *type = (char *)info->manifest_info->type;
2314 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
2316 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2317 retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2318 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2319 *version = (char *)info->manifest_info->version;
2323 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
2325 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2326 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2328 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2329 val = (char *)info->manifest_info->installlocation;
2331 if (strcmp(val, "internal-only") == 0)
2332 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2333 else if (strcmp(val, "prefer-external") == 0)
2334 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2336 *location = PMINFO_INSTALL_LOCATION_AUTO;
2341 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
2343 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2344 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2346 char *location = NULL;
2347 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2348 location = (char *)info->manifest_info->installlocation;
2349 val = (char *)info->manifest_info->package_size;
2354 _LOGE("package size is not specified\n");
2355 return PMINFO_R_ERROR;
2360 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
2362 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2363 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2366 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
2367 long long rw_size = 0;
2368 long long ro_size= 0;
2369 long long tmp_size= 0;
2370 long long total_size= 0;
2371 struct stat fileinfo;
2374 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2376 return PMINFO_R_ERROR;
2379 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid);
2380 if (lstat(device_path, &fileinfo) == 0) {
2381 if (!S_ISLNK(fileinfo.st_mode)) {
2382 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2384 rw_size += tmp_size;
2388 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid);
2389 if (lstat(device_path, &fileinfo) == 0) {
2390 if (!S_ISLNK(fileinfo.st_mode)) {
2391 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2393 rw_size += tmp_size;
2397 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid);
2398 if (lstat(device_path, &fileinfo) == 0) {
2399 if (!S_ISLNK(fileinfo.st_mode)) {
2400 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2402 rw_size += tmp_size;
2406 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
2407 if (lstat(device_path, &fileinfo) == 0) {
2408 if (!S_ISLNK(fileinfo.st_mode)) {
2409 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2411 rw_size += tmp_size;
2415 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_PATH, pkgid);
2416 if (lstat(device_path, &fileinfo) == 0) {
2417 if (!S_ISLNK(fileinfo.st_mode)) {
2418 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2420 rw_size += tmp_size;
2424 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_PATH, pkgid);
2425 if (lstat(device_path, &fileinfo) == 0) {
2426 if (!S_ISLNK(fileinfo.st_mode)) {
2427 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2429 rw_size += tmp_size;
2434 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_PATH, pkgid);
2435 if (lstat(device_path, &fileinfo) == 0) {
2436 if (!S_ISLNK(fileinfo.st_mode)) {
2437 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2439 ro_size += tmp_size;
2443 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid);
2444 if (lstat(device_path, &fileinfo) == 0) {
2445 if (!S_ISLNK(fileinfo.st_mode)) {
2446 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2448 ro_size += tmp_size;
2452 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid);
2453 if (lstat(device_path, &fileinfo) == 0) {
2454 if (!S_ISLNK(fileinfo.st_mode)) {
2455 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2457 ro_size += tmp_size;
2461 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid);
2462 if (lstat(device_path, &fileinfo) == 0) {
2463 if (!S_ISLNK(fileinfo.st_mode)) {
2464 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2466 ro_size += tmp_size;
2470 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid);
2471 if (lstat(device_path, &fileinfo) == 0) {
2472 if (!S_ISLNK(fileinfo.st_mode)) {
2473 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2475 ro_size += tmp_size;
2479 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid);
2480 if (lstat(device_path, &fileinfo) == 0) {
2481 if (!S_ISLNK(fileinfo.st_mode)) {
2482 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2484 ro_size += tmp_size;
2489 total_size = rw_size + ro_size;
2490 *size = (int)total_size;
2495 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
2497 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2498 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2501 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
2502 long long total_size= 0;
2505 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2507 return PMINFO_R_ERROR;
2509 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
2510 if (access(device_path, R_OK) == 0)
2511 total_size = _pkgmgr_calculate_dir_size(device_path);
2513 return PMINFO_R_ERROR;
2515 *size = (int)total_size;
2520 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
2522 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2523 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2524 int ret = PMINFO_R_OK;
2525 char *locale = NULL;
2529 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2531 locale = info->locale;
2532 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2534 for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next)
2537 if (strcmp(ptr->lang, locale) == 0) {
2538 *icon = (char *)ptr->text;
2539 if (strcasecmp(*icon, "(null)") == 0) {
2540 locale = DEFAULT_LOCALE;
2544 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2545 *icon = (char *)ptr->text;
2554 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
2556 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2557 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2558 int ret = PMINFO_R_OK;
2559 char *locale = NULL;
2560 label_x *ptr = NULL;
2563 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2564 locale = info->locale;
2565 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2567 for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next)
2570 if (strcmp(ptr->lang, locale) == 0) {
2571 *label = (char *)ptr->text;
2572 if (strcasecmp(*label, "(null)") == 0) {
2573 locale = DEFAULT_LOCALE;
2577 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2578 *label = (char *)ptr->text;
2587 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
2589 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2590 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2591 char *locale = NULL;
2592 description_x *ptr = NULL;
2593 *description = NULL;
2595 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2596 locale = info->locale;
2597 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2599 for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next)
2602 if (strcmp(ptr->lang, locale) == 0) {
2603 *description = (char *)ptr->text;
2604 if (strcasecmp(*description, "(null)") == 0) {
2605 locale = DEFAULT_LOCALE;
2609 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2610 *description = (char *)ptr->text;
2618 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
2620 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2621 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2622 char *locale = NULL;
2623 author_x *ptr = NULL;
2624 *author_name = NULL;
2626 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2627 locale = info->locale;
2628 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2630 for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next)
2633 if (strcmp(ptr->lang, locale) == 0) {
2634 *author_name = (char *)ptr->text;
2635 if (strcasecmp(*author_name, "(null)") == 0) {
2636 locale = DEFAULT_LOCALE;
2640 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2641 *author_name = (char *)ptr->text;
2649 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
2651 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2652 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2653 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2654 *author_email = (char *)info->manifest_info->author->email;
2658 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
2660 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2661 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2662 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2663 *author_href = (char *)info->manifest_info->author->href;
2667 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
2669 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2670 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2673 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
2675 _LOGE("invalid func parameters\n");
2676 return PMINFO_R_ERROR;
2680 char app_mmc_path[FILENAME_MAX] = { 0, };
2681 char app_dir_path[FILENAME_MAX] = { 0, };
2682 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
2683 snprintf(app_dir_path, FILENAME_MAX,
2684 "%s%s", PKG_INSTALLATION_PATH, pkgid);
2685 snprintf(app_mmc_path, FILENAME_MAX,
2686 "%s%s", PKG_SD_PATH, pkgid);
2687 snprintf(app_mmc_internal_path, FILENAME_MAX,
2688 "%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
2690 /*check whether application is in external memory or not */
2691 fp = fopen(app_mmc_path, "r");
2693 _LOGE(" app path in external memory not accesible\n");
2697 *storage = PMINFO_EXTERNAL_STORAGE;
2701 /*check whether application is in internal or not */
2702 fp = fopen(app_dir_path, "r");
2704 _LOGE(" app path in internal memory not accesible\n");
2706 return PMINFO_R_ERROR;
2709 /*check whether the application is installed in SD card
2710 but SD card is not present*/
2711 fp = fopen(app_mmc_internal_path, "r");
2713 *storage = PMINFO_INTERNAL_STORAGE;
2717 *storage = PMINFO_EXTERNAL_STORAGE;
2723 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
2725 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2726 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2727 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2728 if (info->manifest_info->installed_time)
2729 *installed_time = atoi(info->manifest_info->installed_time);
2731 return PMINFO_R_ERROR;
2736 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
2738 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2739 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2740 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2741 *storeclientid = (char *)info->manifest_info->storeclient_id;
2745 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
2747 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2748 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2749 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2750 *mainappid = (char *)info->manifest_info->mainapp_id;
2754 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
2756 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2757 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2758 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2759 *url = (char *)info->manifest_info->package_url;
2763 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
2765 const char *val = NULL;
2766 const xmlChar *node;
2767 xmlTextReaderPtr reader;
2768 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2769 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2772 reader = xmlReaderForFile(manifest, NULL, 0);
2775 if (__child_element(reader, -1)) {
2776 node = xmlTextReaderConstName(reader);
2778 _LOGE("xmlTextReaderConstName value is NULL\n");
2779 xmlFreeTextReader(reader);
2781 return PMINFO_R_ERROR;
2784 if (!strcmp(ASC_CHAR(node), "manifest")) {
2785 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
2786 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
2792 _LOGE("package size is not specified\n");
2793 xmlFreeTextReader(reader);
2795 return PMINFO_R_ERROR;
2798 _LOGE("Unable to create xml reader\n");
2799 xmlFreeTextReader(reader);
2801 return PMINFO_R_ERROR;
2805 _LOGE("xmlReaderForFile value is NULL\n");
2807 return PMINFO_R_ERROR;
2810 xmlFreeTextReader(reader);
2816 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
2818 const char *val = NULL;
2819 const xmlChar *node;
2820 xmlTextReaderPtr reader;
2821 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2822 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2825 reader = xmlReaderForFile(manifest, NULL, 0);
2828 if ( __child_element(reader, -1)) {
2829 node = xmlTextReaderConstName(reader);
2831 _LOGE("xmlTextReaderConstName value is NULL\n");
2832 xmlFreeTextReader(reader);
2834 return PMINFO_R_ERROR;
2837 if (!strcmp(ASC_CHAR(node), "manifest")) {
2838 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
2839 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
2842 if (strcmp(val, "internal-only") == 0)
2843 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2844 else if (strcmp(val, "prefer-external") == 0)
2845 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2847 *location = PMINFO_INSTALL_LOCATION_AUTO;
2850 _LOGE("Unable to create xml reader\n");
2851 xmlFreeTextReader(reader);
2853 return PMINFO_R_ERROR;
2857 _LOGE("xmlReaderForFile value is NULL\n");
2859 return PMINFO_R_ERROR;
2862 xmlFreeTextReader(reader);
2869 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
2871 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2872 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2874 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2875 if (info->manifest_info->root_path)
2876 *path = (char *)info->manifest_info->root_path;
2878 return PMINFO_R_ERROR;
2884 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)
2886 retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
2887 retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
2888 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2890 int ret = PMINFO_R_OK;
2891 char query[MAX_QUERY_LEN] = {'\0'};
2892 char *error_message = NULL;
2893 pkgmgr_cert_x *info= NULL;
2897 *compare_result = PMINFO_CERT_COMPARE_ERROR;
2898 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
2899 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
2901 ret = db_util_open_with_options(CERT_DB, &cert_db,
2902 SQLITE_OPEN_READONLY, NULL);
2903 if (ret != SQLITE_OK) {
2904 _LOGE("connect db [%s] failed!\n", CERT_DB);
2905 ret = PMINFO_R_ERROR;
2909 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
2911 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
2912 _LOGE("Don't execute query = %s error message = %s\n", query,
2914 ret = PMINFO_R_ERROR;
2921 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
2923 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
2924 _LOGE("Don't execute query = %s error message = %s\n", query,
2926 ret = PMINFO_R_ERROR;
2929 lcert = info->cert_id;
2932 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
2934 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
2935 _LOGE("Don't execute query = %s error message = %s\n", query,
2937 ret = PMINFO_R_ERROR;
2944 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
2946 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
2947 _LOGE("Don't execute query = %s error message = %s\n", query,
2949 ret = PMINFO_R_ERROR;
2952 rcert = info->cert_id;
2955 if ((lcert == 0) || (rcert == 0))
2957 if ((lcert == 0) && (rcert == 0))
2958 *compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
2959 else if (lcert == 0)
2960 *compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
2961 else if (rcert == 0)
2962 *compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
2965 *compare_result = PMINFO_CERT_COMPARE_MATCH;
2967 *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
2971 sqlite3_free(error_message);
2972 sqlite3_close(cert_db);
2985 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)
2987 retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
2988 retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
2989 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2991 int ret = PMINFO_R_OK;
2992 char query[MAX_QUERY_LEN] = {'\0'};
2993 char *error_message = NULL;
2994 pkgmgr_cert_x *info= NULL;
2996 char *lpkgid = NULL;
2997 char *rpkgid = NULL;
2999 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3000 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3002 ret = db_util_open_with_options(MANIFEST_DB, &manifest_db,
3003 SQLITE_OPEN_READONLY, NULL);
3004 if (ret != SQLITE_OK) {
3005 _LOGE("connect db [%s] failed!\n", MANIFEST_DB);
3006 ret = PMINFO_R_ERROR;
3010 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
3012 sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
3013 _LOGE("Don't execute query = %s error message = %s\n", query,
3015 ret = PMINFO_R_ERROR;
3022 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
3024 sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
3025 _LOGE("Don't execute query = %s error message = %s\n", query,
3027 ret = PMINFO_R_ERROR;
3030 lpkgid = strdup(info->pkgid);
3031 if (lpkgid == NULL) {
3032 _LOGE("Out of Memory\n");
3033 ret = PMINFO_R_ERROR;
3040 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
3042 sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
3043 _LOGE("Don't execute query = %s error message = %s\n", query,
3045 ret = PMINFO_R_ERROR;
3052 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
3054 sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
3055 _LOGE("Don't execute query = %s error message = %s\n", query,
3057 ret = PMINFO_R_ERROR;
3060 rpkgid = strdup(info->pkgid);
3061 if (rpkgid == NULL) {
3062 _LOGE("Out of Memory\n");
3063 ret = PMINFO_R_ERROR;
3069 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
3071 sqlite3_free(error_message);
3072 sqlite3_close(manifest_db);
3092 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
3094 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3095 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3097 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
3099 _LOGD("invalid func parameters\n");
3100 return PMINFO_R_ERROR;
3102 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
3105 char app_mmc_path[FILENAME_MAX] = { 0, };
3106 char app_dir_path[FILENAME_MAX] = { 0, };
3107 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
3108 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
3109 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
3110 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
3112 /*check whether application is in external memory or not */
3113 fp = fopen(app_mmc_path, "r");
3115 _LOGD(" app path in external memory not accesible\n");
3120 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
3124 /*check whether application is in internal or not */
3125 fp = fopen(app_dir_path, "r");
3127 _LOGD(" app path in internal memory not accesible\n");
3129 return PMINFO_R_ERROR;
3132 /*check whether the application is installed in SD card
3133 but SD card is not present*/
3134 fp = fopen(app_mmc_internal_path, "r");
3137 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
3142 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
3147 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
3151 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
3153 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3154 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3156 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3157 val = (char *)info->manifest_info->removable;
3159 if (strcasecmp(val, "true") == 0)
3161 else if (strcasecmp(val, "false") == 0)
3169 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
3171 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3172 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3175 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3177 val = (char *)info->manifest_info->installlocation;
3179 if (strcmp(val, "internal-only") == 0)
3181 else if (strcmp(val, "prefer-external") == 0)
3190 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
3192 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3193 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3195 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3196 val = (char *)info->manifest_info->preload;
3198 if (strcasecmp(val, "true") == 0)
3200 else if (strcasecmp(val, "false") == 0)
3208 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
3210 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3211 retvm_if(readonly == 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->readonly;
3216 if (strcasecmp(val, "true") == 0)
3218 else if (strcasecmp(val, "false") == 0)
3226 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
3228 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3229 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3232 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3233 val = (char *)info->manifest_info->update;
3235 if (strcasecmp(val, "true") == 0)
3237 else if (strcasecmp(val, "false") == 0)
3245 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
3247 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3248 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3249 __cleanup_pkginfo(info);
3253 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
3255 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
3257 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
3258 if (filter == NULL) {
3259 _LOGE("Out of Memory!!!");
3260 return PMINFO_R_ERROR;
3266 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
3268 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3269 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3271 g_slist_foreach(filter->list, __destroy_each_node, NULL);
3272 g_slist_free(filter->list);
3279 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
3280 const char *property, const int value)
3282 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3283 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3284 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3286 GSList *link = NULL;
3288 prop = _pminfo_pkginfo_convert_to_prop_int(property);
3289 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
3290 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
3291 _LOGE("Invalid Integer Property\n");
3292 return PMINFO_R_EINVAL;
3294 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3295 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3297 _LOGE("Out of Memory!!!\n");
3298 return PMINFO_R_ERROR;
3300 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3301 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3303 _LOGE("Out of Memory\n");
3306 return PMINFO_R_ERROR;
3310 /*If API is called multiple times for same property, we should override the previous values.
3311 Last value set will be used for filtering.*/
3312 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3314 filter->list = g_slist_delete_link(filter->list, link);
3315 filter->list = g_slist_append(filter->list, (gpointer)node);
3320 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
3321 const char *property, const bool value)
3323 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3324 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3326 GSList *link = NULL;
3328 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
3329 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
3330 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
3331 _LOGE("Invalid Boolean Property\n");
3332 return PMINFO_R_EINVAL;
3334 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3335 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3337 _LOGE("Out of Memory!!!\n");
3338 return PMINFO_R_ERROR;
3341 val = strndup("('true','True')", 15);
3343 val = strndup("('false','False')", 17);
3345 _LOGE("Out of Memory\n");
3348 return PMINFO_R_ERROR;
3352 /*If API is called multiple times for same property, we should override the previous values.
3353 Last value set will be used for filtering.*/
3354 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3356 filter->list = g_slist_delete_link(filter->list, link);
3357 filter->list = g_slist_append(filter->list, (gpointer)node);
3362 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
3363 const char *property, const char *value)
3365 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3366 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3367 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3369 GSList *link = NULL;
3371 prop = _pminfo_pkginfo_convert_to_prop_str(property);
3372 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
3373 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
3374 _LOGE("Invalid String Property\n");
3375 return PMINFO_R_EINVAL;
3377 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3378 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3380 _LOGE("Out of Memory!!!\n");
3381 return PMINFO_R_ERROR;
3383 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
3384 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
3385 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
3386 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
3387 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
3388 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
3389 else if (strcmp(value, "installed_internal") == 0)
3390 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
3391 else if (strcmp(value, "installed_external") == 0)
3392 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
3394 val = strndup(value, PKG_STRING_LEN_MAX - 1);
3396 _LOGE("Out of Memory\n");
3399 return PMINFO_R_ERROR;
3403 /*If API is called multiple times for same property, we should override the previous values.
3404 Last value set will be used for filtering.*/
3405 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3407 filter->list = g_slist_delete_link(filter->list, link);
3408 filter->list = g_slist_append(filter->list, (gpointer)node);
3413 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
3415 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3416 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3417 char *syslocale = NULL;
3418 char *locale = NULL;
3419 char *condition = NULL;
3420 char *error_message = NULL;
3421 char query[MAX_QUERY_LEN] = {'\0'};
3422 char where[MAX_QUERY_LEN] = {'\0'};
3426 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3427 /*Get current locale*/
3428 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3429 if (syslocale == NULL) {
3430 _LOGE("current locale is NULL\n");
3431 return PMINFO_R_ERROR;
3433 locale = __convert_system_locale_to_manifest_locale(syslocale);
3434 if (locale == NULL) {
3435 _LOGE("manifest locale is NULL\n");
3437 return PMINFO_R_ERROR;
3440 ret = __open_manifest_db();
3442 _LOGE("Fail to open manifest DB\n");
3443 ret = PMINFO_R_ERROR;
3447 /*Start constructing query*/
3448 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_PACKAGE, locale);
3450 /*Get where clause*/
3451 for (list = filter->list; list; list = g_slist_next(list)) {
3452 __get_filter_condition(list->data, &condition);
3454 strncat(where, condition, sizeof(where) - strlen(where) -1);
3455 where[sizeof(where) - 1] = '\0';
3459 if (g_slist_next(list)) {
3460 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3461 where[sizeof(where) - 1] = '\0';
3464 _LOGE("where = %s\n", where);
3465 if (strlen(where) > 0) {
3466 strncat(query, where, sizeof(query) - strlen(query) - 1);
3467 query[sizeof(query) - 1] = '\0';
3469 _LOGE("query = %s\n", query);
3473 sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
3474 _LOGE("Don't execute query = %s error message = %s\n", query,
3476 sqlite3_free(error_message);
3477 sqlite3_close(manifest_db);
3478 ret = PMINFO_R_ERROR;
3492 sqlite3_close(manifest_db);
3496 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
3497 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
3499 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3500 retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3501 char *syslocale = NULL;
3502 char *locale = NULL;
3503 char *condition = NULL;
3504 char *error_message = NULL;
3505 char query[MAX_QUERY_LEN] = {'\0'};
3506 char where[MAX_QUERY_LEN] = {'\0'};
3509 label_x *tmp1 = NULL;
3510 icon_x *tmp2 = NULL;
3511 description_x *tmp3 = NULL;
3512 author_x *tmp4 = NULL;
3513 privilege_x *tmp5 = NULL;
3514 pkgmgr_pkginfo_x *node = NULL;
3515 pkgmgr_pkginfo_x *tmphead = NULL;
3516 pkgmgr_pkginfo_x *pkginfo = NULL;
3518 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3519 /*Get current locale*/
3520 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3521 if (syslocale == NULL) {
3522 _LOGE("current locale is NULL\n");
3523 return PMINFO_R_ERROR;
3525 locale = __convert_system_locale_to_manifest_locale(syslocale);
3526 if (locale == NULL) {
3527 _LOGE("manifest locale is NULL\n");
3529 return PMINFO_R_ERROR;
3532 ret = __open_manifest_db();
3534 _LOGE("Fail to open manifest DB\n");
3535 ret = PMINFO_R_ERROR;
3538 /*Start constructing query*/
3539 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
3541 /*Get where clause*/
3542 for (list = filter->list; list; list = g_slist_next(list)) {
3543 __get_filter_condition(list->data, &condition);
3545 strncat(where, condition, sizeof(where) - strlen(where) -1);
3546 where[sizeof(where) - 1] = '\0';
3550 if (g_slist_next(list)) {
3551 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3552 where[sizeof(where) - 1] = '\0';
3555 _LOGE("where = %s\n", where);
3556 if (strlen(where) > 0) {
3557 strncat(query, where, sizeof(query) - strlen(query) - 1);
3558 query[sizeof(query) - 1] = '\0';
3560 _LOGE("query = %s\n", query);
3561 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
3562 if (tmphead == NULL) {
3563 _LOGE("Out of Memory!!!\n");
3564 ret = PMINFO_R_ERROR;
3569 sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
3570 _LOGE("Don't execute query = %s error message = %s\n", query,
3572 sqlite3_free(error_message);
3573 sqlite3_close(manifest_db);
3574 ret = PMINFO_R_ERROR;
3578 LISTHEAD(tmphead, node);
3579 for(node = node->next ; node ; node = node->next) {
3581 pkginfo->locale = strdup(locale);
3582 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
3583 if (pkginfo->manifest_info->privileges == NULL) {
3584 _LOGE("Failed to allocate memory for privileges info\n");
3585 ret = PMINFO_R_ERROR;
3589 /*populate manifest_info from DB*/
3590 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
3591 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3593 _LOGE("Package Info DB Information retrieval failed\n");
3594 ret = PMINFO_R_ERROR;
3597 memset(query, '\0', MAX_QUERY_LEN);
3598 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3599 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
3600 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3602 _LOGE("Package Info DB Information retrieval failed\n");
3603 ret = PMINFO_R_ERROR;
3606 /*Also store the values corresponding to default locales*/
3607 memset(query, '\0', MAX_QUERY_LEN);
3608 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3609 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
3610 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3612 _LOGE("Package Info DB Information retrieval failed\n");
3613 ret = PMINFO_R_ERROR;
3616 if (pkginfo->manifest_info->label) {
3617 LISTHEAD(pkginfo->manifest_info->label, tmp1);
3618 pkginfo->manifest_info->label = tmp1;
3620 if (pkginfo->manifest_info->icon) {
3621 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
3622 pkginfo->manifest_info->icon = tmp2;
3624 if (pkginfo->manifest_info->description) {
3625 LISTHEAD(pkginfo->manifest_info->description, tmp3);
3626 pkginfo->manifest_info->description = tmp3;
3628 if (pkginfo->manifest_info->author) {
3629 LISTHEAD(pkginfo->manifest_info->author, tmp4);
3630 pkginfo->manifest_info->author = tmp4;
3632 if (pkginfo->manifest_info->privileges->privilege) {
3633 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
3634 pkginfo->manifest_info->privileges->privilege = tmp5;
3638 LISTHEAD(tmphead, node);
3640 for(node = node->next ; node ; node = node->next) {
3642 ret = pkg_cb( (void *)pkginfo, user_data);
3657 sqlite3_close(manifest_db);
3658 __cleanup_pkginfo(tmphead);
3662 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
3663 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
3665 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3666 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3668 privilege_x *ptr = NULL;
3669 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3670 ptr = info->manifest_info->privileges->privilege;
3671 for (; ptr; ptr = ptr->next) {
3672 ret = privilege_func(ptr->text, user_data);
3679 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
3680 pkgmgrinfo_app_list_cb app_func, void *user_data)
3682 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3683 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
3684 retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
3686 char *syslocale = NULL;
3687 char *locale = NULL;
3689 char query[MAX_QUERY_LEN] = {'\0'};
3690 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3691 pkgmgr_pkginfo_x *allinfo = NULL;
3692 pkgmgr_appinfo_x *appinfo = NULL;
3693 icon_x *ptr1 = NULL;
3694 label_x *ptr2 = NULL;
3695 category_x *ptr3 = NULL;
3696 metadata_x *ptr4 = NULL;
3697 permission_x *ptr5 = NULL;
3698 image_x *ptr6 = NULL;
3699 sqlite3 *appinfo_db = NULL;
3701 /*get system locale*/
3702 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3703 tryvm_if(syslocale == NULL, ret = PMINFO_R_EINVAL, "current locale is NULL");
3705 /*get locale on db*/
3706 locale = __convert_system_locale_to_manifest_locale(syslocale);
3707 tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
3710 allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
3711 tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3713 /*calloc manifest_info*/
3714 allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
3715 tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
3718 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
3719 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3721 /*set component type*/
3722 if (component == PMINFO_UI_APP)
3723 appinfo->app_component = PMINFO_UI_APP;
3724 if (component == PMINFO_SVC_APP)
3725 appinfo->app_component = PMINFO_SVC_APP;
3726 if (component == PMINFO_ALL_APP)
3727 appinfo->app_component = PMINFO_ALL_APP;
3730 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
3731 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3733 appinfo->package = strdup(info->manifest_info->package);
3734 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
3735 "from package_app_info where " \
3736 "package='%s' and app_component='%s'",
3737 info->manifest_info->package,
3738 (appinfo->app_component==PMINFO_UI_APP ? "uiapp" : "svcapp"));
3742 /*Populate ui app info */
3743 ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
3744 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3746 uiapplication_x *tmp = NULL;
3747 if (info->manifest_info->uiapplication) {
3748 LISTHEAD(info->manifest_info->uiapplication, tmp);
3749 info->manifest_info->uiapplication = tmp;
3751 /*Populate localized info for default locales and call callback*/
3752 /*If the callback func return < 0 we break and no more call back is called*/
3755 appinfo->locale = strdup(locale);
3756 appinfo->uiapp_info = tmp;
3757 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
3761 locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
3764 memset(query, '\0', MAX_QUERY_LEN);
3765 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3766 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3767 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3769 memset(query, '\0', MAX_QUERY_LEN);
3770 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);
3771 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3772 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3774 /*store setting notification icon section*/
3775 memset(query, '\0', MAX_QUERY_LEN);
3776 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3777 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3778 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
3780 /*store app preview image info*/
3781 memset(query, '\0', MAX_QUERY_LEN);
3782 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
3783 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3784 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
3786 if (appinfo->uiapp_info->label) {
3787 LISTHEAD(appinfo->uiapp_info->label, ptr2);
3788 appinfo->uiapp_info->label = ptr2;
3790 if (appinfo->uiapp_info->icon) {
3791 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
3792 appinfo->uiapp_info->icon = ptr1;
3794 if (appinfo->uiapp_info->category) {
3795 LISTHEAD(appinfo->uiapp_info->category, ptr3);
3796 appinfo->uiapp_info->category = ptr3;
3798 if (appinfo->uiapp_info->metadata) {
3799 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
3800 appinfo->uiapp_info->metadata = ptr4;
3802 if (appinfo->uiapp_info->permission) {
3803 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
3804 appinfo->uiapp_info->permission = ptr5;
3806 if (appinfo->uiapp_info->image) {
3807 LISTHEAD(appinfo->uiapp_info->image, ptr6);
3808 appinfo->uiapp_info->image = ptr6;
3810 ret = app_func((void *)appinfo, user_data);
3816 case PMINFO_SVC_APP:
3817 /*Populate svc app info */
3818 ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
3819 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3821 serviceapplication_x *tmp1 = NULL;
3822 if (info->manifest_info->serviceapplication) {
3823 LISTHEAD(info->manifest_info->serviceapplication, tmp1);
3824 info->manifest_info->serviceapplication = tmp1;
3826 /*Populate localized info for default locales and call callback*/
3827 /*If the callback func return < 0 we break and no more call back is called*/
3830 appinfo->locale = strdup(locale);
3831 appinfo->svcapp_info = tmp1;
3832 memset(query, '\0', MAX_QUERY_LEN);
3833 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
3834 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3835 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3837 memset(query, '\0', MAX_QUERY_LEN);
3838 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);
3839 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3840 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3842 if (appinfo->svcapp_info->label) {
3843 LISTHEAD(appinfo->svcapp_info->label, ptr2);
3844 appinfo->svcapp_info->label = ptr2;
3846 if (appinfo->svcapp_info->icon) {
3847 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
3848 appinfo->svcapp_info->icon = ptr1;
3850 if (appinfo->svcapp_info->category) {
3851 LISTHEAD(appinfo->svcapp_info->category, ptr3);
3852 appinfo->svcapp_info->category = ptr3;
3854 if (appinfo->svcapp_info->metadata) {
3855 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
3856 appinfo->svcapp_info->metadata = ptr4;
3858 if (appinfo->svcapp_info->permission) {
3859 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
3860 appinfo->svcapp_info->permission = ptr5;
3862 ret = app_func((void *)appinfo, user_data);
3868 case PMINFO_ALL_APP:
3869 memset(query, '\0', MAX_QUERY_LEN);
3870 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
3872 /*Populate all app info */
3873 ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo);
3874 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3877 appinfo->app_component = PMINFO_UI_APP;
3878 uiapplication_x *tmp2 = NULL;
3879 if (allinfo->manifest_info->uiapplication) {
3880 LISTHEAD(allinfo->manifest_info->uiapplication, tmp2);
3881 allinfo->manifest_info->uiapplication = tmp2;
3883 /*Populate localized info for default locales and call callback*/
3884 /*If the callback func return < 0 we break and no more call back is called*/
3887 appinfo->locale = strdup(locale);
3888 appinfo->uiapp_info = tmp2;
3889 memset(query, '\0', MAX_QUERY_LEN);
3890 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3891 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3892 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3894 memset(query, '\0', MAX_QUERY_LEN);
3895 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);
3896 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3897 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3899 /*store setting notification icon section*/
3900 memset(query, '\0', MAX_QUERY_LEN);
3901 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3902 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3903 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
3905 /*store app preview image info*/
3906 memset(query, '\0', MAX_QUERY_LEN);
3907 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
3908 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3909 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
3911 if (appinfo->uiapp_info->label) {
3912 LISTHEAD(appinfo->uiapp_info->label, ptr2);
3913 appinfo->uiapp_info->label = ptr2;
3915 if (appinfo->uiapp_info->icon) {
3916 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
3917 appinfo->uiapp_info->icon = ptr1;
3919 if (appinfo->uiapp_info->category) {
3920 LISTHEAD(appinfo->uiapp_info->category, ptr3);
3921 appinfo->uiapp_info->category = ptr3;
3923 if (appinfo->uiapp_info->metadata) {
3924 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
3925 appinfo->uiapp_info->metadata = ptr4;
3927 if (appinfo->uiapp_info->permission) {
3928 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
3929 appinfo->uiapp_info->permission = ptr5;
3931 if (appinfo->uiapp_info->image) {
3932 LISTHEAD(appinfo->uiapp_info->image, ptr6);
3933 appinfo->uiapp_info->image = ptr6;
3935 ret = app_func((void *)appinfo, user_data);
3942 appinfo->app_component = PMINFO_SVC_APP;
3943 serviceapplication_x *tmp3 = NULL;
3944 if (allinfo->manifest_info->serviceapplication) {
3945 LISTHEAD(allinfo->manifest_info->serviceapplication, tmp3);
3946 allinfo->manifest_info->serviceapplication = tmp3;
3948 /*Populate localized info for default locales and call callback*/
3949 /*If the callback func return < 0 we break and no more call back is called*/
3952 appinfo->locale = strdup(locale);
3953 appinfo->svcapp_info = tmp3;
3954 memset(query, '\0', MAX_QUERY_LEN);
3955 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
3956 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3957 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3959 memset(query, '\0', MAX_QUERY_LEN);
3960 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);
3961 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3962 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3964 if (appinfo->svcapp_info->label) {
3965 LISTHEAD(appinfo->svcapp_info->label, ptr2);
3966 appinfo->svcapp_info->label = ptr2;
3968 if (appinfo->svcapp_info->icon) {
3969 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
3970 appinfo->svcapp_info->icon = ptr1;
3972 if (appinfo->svcapp_info->category) {
3973 LISTHEAD(appinfo->svcapp_info->category, ptr3);
3974 appinfo->svcapp_info->category = ptr3;
3976 if (appinfo->svcapp_info->metadata) {
3977 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
3978 appinfo->svcapp_info->metadata = ptr4;
3980 if (appinfo->svcapp_info->permission) {
3981 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
3982 appinfo->svcapp_info->permission = ptr5;
3984 ret = app_func((void *)appinfo, user_data);
3989 appinfo->app_component = PMINFO_ALL_APP;
4005 if (appinfo->package) {
4006 free((void *)appinfo->package);
4007 appinfo->package = NULL;
4012 __cleanup_pkginfo(allinfo);
4014 sqlite3_close(appinfo_db);
4018 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4020 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4022 int ret = PMINFO_R_OK;
4023 char query[MAX_QUERY_LEN] = {'\0'};
4024 pkgmgr_appinfo_x *info = NULL;
4025 pkgmgr_appinfo_x *appinfo = NULL;
4026 uiapplication_x *ptr1 = NULL;
4027 sqlite3 *appinfo_db = NULL;
4030 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4031 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4034 info = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4035 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4037 /*calloc uiapplication_x*/
4038 info->uiapp_info= (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4039 tryvm_if(info->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4042 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4043 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4045 /*query package_app_info*/
4046 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4047 ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
4048 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4050 LISTHEAD(info->uiapp_info, ptr1);
4053 for(ptr1 = ptr1->next ; ptr1 ; ptr1 = ptr1->next)
4055 appinfo->uiapp_info= ptr1;
4056 appinfo->package = strdup(ptr1->package);
4057 appinfo->app_component = PMINFO_UI_APP;
4059 ret = app_func((void *)appinfo, user_data);
4062 free((void *)appinfo->package);
4063 appinfo->package = NULL;
4067 sqlite3_close(appinfo_db);
4073 __cleanup_appinfo(info);
4077 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4079 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4081 int ret = PMINFO_R_OK;
4082 char query[MAX_QUERY_LEN] = {'\0'};
4083 char *syslocale = NULL;
4084 char *locale = NULL;
4085 pkgmgr_appinfo_x *appinfo = NULL;
4086 uiapplication_x *ptr1 = NULL;
4087 serviceapplication_x *ptr2 = NULL;
4088 label_x *tmp1 = NULL;
4089 icon_x *tmp2 = NULL;
4090 category_x *tmp3 = NULL;
4091 metadata_x *tmp4 = NULL;
4092 permission_x *tmp5 = NULL;
4093 image_x *tmp6 = NULL;
4094 sqlite3 *appinfo_db = NULL;
4096 /*get system locale*/
4097 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4098 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
4100 /*get locale on db*/
4101 locale = __convert_system_locale_to_manifest_locale(syslocale);
4102 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4105 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4106 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4109 pkgmgr_pkginfo_x *info = NULL;
4110 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4111 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4113 /*calloc manifest_info*/
4114 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4115 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4118 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4119 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4121 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4122 ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
4123 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4125 if (info->manifest_info->uiapplication) {
4126 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4127 info->manifest_info->uiapplication = ptr1;
4129 if (info->manifest_info->serviceapplication) {
4130 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4131 info->manifest_info->serviceapplication = ptr2;
4135 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4137 appinfo->locale = strdup(locale);
4138 appinfo->app_component = PMINFO_UI_APP;
4139 appinfo->package = strdup(ptr1->package);
4140 appinfo->uiapp_info = ptr1;
4141 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4142 "from package_app_info where " \
4143 "app_id='%s'", ptr1->appid);
4144 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4145 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4147 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
4151 locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
4154 memset(query, '\0', MAX_QUERY_LEN);
4155 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4156 "from package_app_localized_info where " \
4157 "app_id='%s' and app_locale='%s'",
4158 ptr1->appid, locale);
4159 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4160 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4162 memset(query, '\0', MAX_QUERY_LEN);
4163 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4164 "from package_app_localized_info where " \
4165 "app_id='%s' and app_locale='%s'",
4166 ptr1->appid, DEFAULT_LOCALE);
4168 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4169 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4171 /*store setting notification icon section*/
4172 memset(query, '\0', MAX_QUERY_LEN);
4173 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
4174 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4175 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4177 /*store app preview image info*/
4178 memset(query, '\0', MAX_QUERY_LEN);
4179 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
4180 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4181 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4183 if (appinfo->uiapp_info->label) {
4184 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4185 appinfo->uiapp_info->label = tmp1;
4187 if (appinfo->uiapp_info->icon) {
4188 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4189 appinfo->uiapp_info->icon= tmp2;
4191 if (appinfo->uiapp_info->category) {
4192 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4193 appinfo->uiapp_info->category = tmp3;
4195 if (appinfo->uiapp_info->metadata) {
4196 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4197 appinfo->uiapp_info->metadata = tmp4;
4199 if (appinfo->uiapp_info->permission) {
4200 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4201 appinfo->uiapp_info->permission = tmp5;
4203 if (appinfo->uiapp_info->image) {
4204 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4205 appinfo->uiapp_info->image = tmp6;
4207 ret = app_func((void *)appinfo, user_data);
4210 free((void *)appinfo->package);
4211 appinfo->package = NULL;
4214 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4216 appinfo->locale = strdup(locale);
4217 appinfo->app_component = PMINFO_SVC_APP;
4218 appinfo->package = strdup(ptr2->package);
4219 appinfo->svcapp_info = ptr2;
4220 memset(query, '\0', MAX_QUERY_LEN);
4221 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4222 "from package_app_info where " \
4223 "app_id='%s'", ptr2->appid);
4224 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4225 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4227 memset(query, '\0', MAX_QUERY_LEN);
4228 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4229 "from package_app_localized_info where " \
4230 "app_id='%s' and app_locale='%s'",
4231 ptr2->appid, locale);
4232 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4233 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4235 memset(query, '\0', MAX_QUERY_LEN);
4236 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4237 "from package_app_localized_info where " \
4238 "app_id='%s' and app_locale='%s'",
4239 ptr2->appid, DEFAULT_LOCALE);
4240 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4241 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4243 if (appinfo->svcapp_info->label) {
4244 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4245 appinfo->svcapp_info->label = tmp1;
4247 if (appinfo->svcapp_info->icon) {
4248 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4249 appinfo->svcapp_info->icon= tmp2;
4251 if (appinfo->svcapp_info->category) {
4252 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4253 appinfo->svcapp_info->category = tmp3;
4255 if (appinfo->svcapp_info->metadata) {
4256 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4257 appinfo->svcapp_info->metadata = tmp4;
4259 if (appinfo->svcapp_info->permission) {
4260 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4261 appinfo->svcapp_info->permission = tmp5;
4263 ret = app_func((void *)appinfo, user_data);
4266 free((void *)appinfo->package);
4267 appinfo->package = NULL;
4280 sqlite3_close(appinfo_db);
4285 __cleanup_pkginfo(info);
4289 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
4291 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
4292 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4294 pkgmgr_appinfo_x *appinfo = NULL;
4295 char *syslocale = NULL;
4296 char *locale = NULL;
4299 label_x *tmp1 = NULL;
4300 icon_x *tmp2 = NULL;
4301 category_x *tmp3 = NULL;
4302 metadata_x *tmp4 = NULL;
4303 permission_x *tmp5 = NULL;
4304 image_x *tmp6 = NULL;
4305 char query[MAX_QUERY_LEN] = {'\0'};
4306 sqlite3 *appinfo_db = NULL;
4309 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4310 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4312 /*check appid exist on db*/
4313 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
4314 ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
4315 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
4316 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
4318 /*get system locale*/
4319 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4320 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
4322 /*get locale on db*/
4323 locale = __convert_system_locale_to_manifest_locale(syslocale);
4324 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4327 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4328 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
4330 /*check app_component from DB*/
4331 memset(query, '\0', MAX_QUERY_LEN);
4332 snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
4333 ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
4334 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4336 /*calloc app_component*/
4337 if (appinfo->app_component == PMINFO_UI_APP) {
4338 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4339 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
4341 appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
4342 tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
4344 appinfo->locale = strdup(locale);
4346 /*populate app_info from DB*/
4347 memset(query, '\0', MAX_QUERY_LEN);
4348 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
4349 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4350 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4352 memset(query, '\0', MAX_QUERY_LEN);
4353 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
4354 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4355 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4357 /*Also store the values corresponding to default locales*/
4358 memset(query, '\0', MAX_QUERY_LEN);
4359 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
4360 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4361 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4363 /*Populate app category*/
4364 memset(query, '\0', MAX_QUERY_LEN);
4365 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
4366 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4367 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
4369 /*Populate app metadata*/
4370 memset(query, '\0', MAX_QUERY_LEN);
4371 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
4372 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4373 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
4375 /*Populate app permission*/
4376 memset(query, '\0', MAX_QUERY_LEN);
4377 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
4378 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4379 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
4381 /*store setting notification icon section*/
4382 memset(query, '\0', MAX_QUERY_LEN);
4383 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
4384 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4385 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4387 /*store app preview image info*/
4388 memset(query, '\0', MAX_QUERY_LEN);
4389 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
4390 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4391 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4393 switch (appinfo->app_component) {
4395 if (appinfo->uiapp_info->label) {
4396 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4397 appinfo->uiapp_info->label = tmp1;
4399 if (appinfo->uiapp_info->icon) {
4400 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4401 appinfo->uiapp_info->icon = tmp2;
4403 if (appinfo->uiapp_info->category) {
4404 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4405 appinfo->uiapp_info->category = tmp3;
4407 if (appinfo->uiapp_info->metadata) {
4408 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4409 appinfo->uiapp_info->metadata = tmp4;
4411 if (appinfo->uiapp_info->permission) {
4412 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4413 appinfo->uiapp_info->permission = tmp5;
4415 if (appinfo->uiapp_info->image) {
4416 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4417 appinfo->uiapp_info->image = tmp6;
4420 case PMINFO_SVC_APP:
4421 if (appinfo->svcapp_info->label) {
4422 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4423 appinfo->svcapp_info->label = tmp1;
4425 if (appinfo->svcapp_info->icon) {
4426 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4427 appinfo->svcapp_info->icon = tmp2;
4429 if (appinfo->svcapp_info->category) {
4430 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4431 appinfo->svcapp_info->category = tmp3;
4433 if (appinfo->svcapp_info->metadata) {
4434 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4435 appinfo->svcapp_info->metadata = tmp4;
4437 if (appinfo->svcapp_info->permission) {
4438 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4439 appinfo->svcapp_info->permission = tmp5;
4449 if (ret == PMINFO_R_OK)
4450 *handle = (void*)appinfo;
4453 __cleanup_appinfo(appinfo);
4456 sqlite3_close(appinfo_db);
4469 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
4471 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4472 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4473 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4475 if (info->app_component == PMINFO_UI_APP)
4476 *appid = (char *)info->uiapp_info->appid;
4477 else if (info->app_component == PMINFO_SVC_APP)
4478 *appid = (char *)info->svcapp_info->appid;
4483 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
4485 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4486 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4487 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4489 *pkg_name = (char *)info->package;
4494 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
4496 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4497 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4498 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4500 *pkgid = (char *)info->package;
4505 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
4507 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4508 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4509 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4511 if (info->app_component == PMINFO_UI_APP)
4512 *exec = (char *)info->uiapp_info->exec;
4513 if (info->app_component == PMINFO_SVC_APP)
4514 *exec = (char *)info->svcapp_info->exec;
4520 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4522 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4523 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4524 char *locale = NULL;
4526 icon_x *start = NULL;
4529 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4530 locale = info->locale;
4531 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4533 if (info->app_component == PMINFO_UI_APP)
4534 start = info->uiapp_info->icon;
4535 if (info->app_component == PMINFO_SVC_APP)
4536 start = info->svcapp_info->icon;
4537 for(ptr = start; ptr != NULL; ptr = ptr->next)
4540 if (strcmp(ptr->lang, locale) == 0) {
4541 *icon = (char *)ptr->text;
4542 if (strcasecmp(*icon, "(null)") == 0) {
4543 locale = DEFAULT_LOCALE;
4547 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4548 *icon = (char *)ptr->text;
4557 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
4559 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4560 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4561 char *locale = NULL;
4562 label_x *ptr = NULL;
4563 label_x *start = NULL;
4566 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4567 locale = info->locale;
4568 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4570 if (info->app_component == PMINFO_UI_APP)
4571 start = info->uiapp_info->label;
4572 if (info->app_component == PMINFO_SVC_APP)
4573 start = info->svcapp_info->label;
4574 for(ptr = start; ptr != NULL; ptr = ptr->next)
4577 if (strcmp(ptr->lang, locale) == 0) {
4578 *label = (char *)ptr->text;
4579 if (strcasecmp(*label, "(null)") == 0) {
4580 locale = DEFAULT_LOCALE;
4584 } else if (strncasecmp(ptr->lang, locale, 2) == 0) {
4585 *label = (char *)ptr->text;
4586 if (strcasecmp(*label, "(null)") == 0) {
4587 locale = DEFAULT_LOCALE;
4591 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4592 *label = (char *)ptr->text;
4601 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
4603 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4604 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4605 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4607 if (info->app_component == PMINFO_UI_APP)
4608 *component = PMINFO_UI_APP;
4609 else if (info->app_component == PMINFO_SVC_APP)
4610 *component = PMINFO_SVC_APP;
4612 return PMINFO_R_ERROR;
4617 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
4619 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4620 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4621 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4623 if (info->app_component == PMINFO_UI_APP)
4624 *app_type = (char *)info->uiapp_info->type;
4625 if (info->app_component == PMINFO_SVC_APP)
4626 *app_type = (char *)info->svcapp_info->type;
4631 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
4632 int *operation_count, char ***operation)
4634 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4635 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4636 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4637 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4638 *operation_count = data->operation_count;
4639 *operation = data->operation;
4643 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
4644 int *uri_count, char ***uri)
4646 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4647 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4648 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4649 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4650 *uri_count = data->uri_count;
4655 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
4656 int *mime_count, char ***mime)
4658 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4659 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4660 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4661 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4662 *mime_count = data->mime_count;
4667 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4669 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4670 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4674 icon_x *start = NULL;
4675 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4677 start = info->uiapp_info->icon;
4679 for(ptr = start; ptr != NULL; ptr = ptr->next)
4682 val = (char *)ptr->section;
4683 if (strcmp(val, "setting") == 0){
4684 *icon = (char *)ptr->text;
4693 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4695 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4696 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4700 icon_x *start = NULL;
4701 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4703 start = info->uiapp_info->icon;
4705 for(ptr = start; ptr != NULL; ptr = ptr->next)
4708 val = (char *)ptr->section;
4710 if (strcmp(val, "notification") == 0){
4711 *icon = (char *)ptr->text;
4720 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
4722 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4723 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4725 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4726 val = (char *)info->uiapp_info->recentimage;
4728 if (strcasecmp(val, "capture") == 0)
4729 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
4730 else if (strcasecmp(val, "icon") == 0)
4731 *type = PMINFO_RECENTIMAGE_USE_ICON;
4733 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
4739 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
4741 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4742 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4745 image_x *ptr = NULL;
4746 image_x *start = NULL;
4747 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4749 start = info->uiapp_info->image;
4751 for(ptr = start; ptr != NULL; ptr = ptr->next)
4754 val = (char *)ptr->section;
4756 if (strcmp(val, "preview") == 0)
4757 *preview_img = (char *)ptr->text;
4765 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
4767 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4768 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4771 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4773 val = info->uiapp_info->permission_type;
4775 if (strcmp(val, "signature") == 0)
4776 *permission = PMINFO_PERMISSION_SIGNATURE;
4777 else if (strcmp(val, "privilege") == 0)
4778 *permission = PMINFO_PERMISSION_PRIVILEGE;
4780 *permission = PMINFO_PERMISSION_NORMAL;
4785 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
4786 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
4788 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4789 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4791 permission_x *ptr = NULL;
4792 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4793 if (info->app_component == PMINFO_UI_APP)
4794 ptr = info->uiapp_info->permission;
4795 else if (info->app_component == PMINFO_SVC_APP)
4796 ptr = info->svcapp_info->permission;
4798 return PMINFO_R_EINVAL;
4799 for (; ptr; ptr = ptr->next) {
4800 ret = permission_func(ptr->value, user_data);
4807 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
4808 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
4810 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4811 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4813 category_x *ptr = NULL;
4814 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4815 if (info->app_component == PMINFO_UI_APP)
4816 ptr = info->uiapp_info->category;
4817 else if (info->app_component == PMINFO_SVC_APP)
4818 ptr = info->svcapp_info->category;
4820 return PMINFO_R_EINVAL;
4821 for (; ptr; ptr = ptr->next) {
4822 ret = category_func(ptr->name, user_data);
4829 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
4830 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
4832 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4833 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4835 metadata_x *ptr = NULL;
4836 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4837 if (info->app_component == PMINFO_UI_APP)
4838 ptr = info->uiapp_info->metadata;
4839 else if (info->app_component == PMINFO_SVC_APP)
4840 ptr = info->svcapp_info->metadata;
4842 return PMINFO_R_EINVAL;
4843 for (; ptr; ptr = ptr->next) {
4844 ret = metadata_func(ptr->key, ptr->value, user_data);
4851 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
4852 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
4854 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4855 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4862 char *manifest = NULL;
4863 char **operation = NULL;
4866 appcontrol_x *appcontrol = NULL;
4867 manifest_x *mfx = NULL;
4868 operation_x *op = NULL;
4871 pkgmgrinfo_app_component component;
4872 pkgmgrinfo_appcontrol_x *ptr = NULL;
4873 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
4875 _LOGE("Failed to get package name\n");
4876 return PMINFO_R_ERROR;
4878 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
4880 _LOGE("Failed to get app component name\n");
4881 return PMINFO_R_ERROR;
4883 manifest = pkgmgr_parser_get_manifest_file(pkgid);
4884 if (manifest == NULL) {
4885 _LOGE("Failed to fetch package manifest file\n");
4886 return PMINFO_R_ERROR;
4888 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4890 _LOGE("Failed to parse package manifest file\n");
4893 return PMINFO_R_ERROR;
4896 ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
4898 _LOGE("Out of Memory!!!\n");
4899 pkgmgr_parser_free_manifest_xml(mfx);
4900 return PMINFO_R_ERROR;
4902 /*Get Operation, Uri, Mime*/
4903 switch (component) {
4905 if (mfx->uiapplication) {
4906 if (mfx->uiapplication->appcontrol) {
4907 appcontrol = mfx->uiapplication->appcontrol;
4911 case PMINFO_SVC_APP:
4912 if (mfx->serviceapplication) {
4913 if (mfx->serviceapplication->appcontrol) {
4914 appcontrol = mfx->serviceapplication->appcontrol;
4921 for (; appcontrol; appcontrol = appcontrol->next) {
4922 op = appcontrol->operation;
4923 for (; op; op = op->next)
4925 op = appcontrol->operation;
4927 ui = appcontrol->uri;
4928 for (; ui; ui = ui->next)
4930 ui = appcontrol->uri;
4932 mi = appcontrol->mime;
4933 for (; mi; mi = mi->next)
4935 mi = appcontrol->mime;
4937 operation = (char **)calloc(oc, sizeof(char *));
4938 for (i = 0; i < oc; i++) {
4939 operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
4943 uri = (char **)calloc(uc, sizeof(char *));
4944 for (i = 0; i < uc; i++) {
4945 uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
4949 mime = (char **)calloc(mc, sizeof(char *));
4950 for (i = 0; i < mc; i++) {
4951 mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
4954 /*populate appcontrol handle*/
4955 ptr->operation_count = oc;
4956 ptr->uri_count = uc;
4957 ptr->mime_count = mc;
4958 ptr->operation = operation;
4961 ret = appcontrol_func((void *)ptr, user_data);
4962 for (i = 0; i < oc; i++) {
4965 operation[i] = NULL;
4972 for (i = 0; i < uc; i++) {
4982 for (i = 0; i < mc; i++) {
4998 pkgmgr_parser_free_manifest_xml(mfx);
5006 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
5008 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5009 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5011 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5012 val = (char *)info->uiapp_info->nodisplay;
5014 if (strcasecmp(val, "true") == 0)
5016 else if (strcasecmp(val, "false") == 0)
5024 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
5026 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5027 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5029 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5030 val = (char *)info->uiapp_info->multiple;
5032 if (strcasecmp(val, "true") == 0)
5034 else if (strcasecmp(val, "false") == 0)
5042 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
5044 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5045 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5047 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5048 val = (char *)info->uiapp_info->indicatordisplay;
5050 if (strcasecmp(val, "true") == 0){
5051 *indicator_disp = 1;
5052 }else if (strcasecmp(val, "false") == 0){
5053 *indicator_disp = 0;
5055 *indicator_disp = 0;
5062 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
5064 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5065 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5066 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5067 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5069 if (info->app_component == PMINFO_UI_APP){
5070 *portrait_img = (char *)info->uiapp_info->portraitimg;
5071 *landscape_img = (char *)info->uiapp_info->landscapeimg;
5077 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
5079 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5080 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5082 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5083 val = (char *)info->uiapp_info->taskmanage;
5085 if (strcasecmp(val, "true") == 0)
5087 else if (strcasecmp(val, "false") == 0)
5095 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
5097 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5098 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5100 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5101 if (info->app_component == PMINFO_UI_APP)
5102 val = (char *)info->uiapp_info->enabled;
5103 else if (info->app_component == PMINFO_SVC_APP)
5104 val = (char *)info->uiapp_info->enabled;
5106 _LOGE("invalid component type\n");
5107 return PMINFO_R_EINVAL;
5111 if (strcasecmp(val, "true") == 0)
5113 else if (strcasecmp(val, "false") == 0)
5122 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
5124 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5125 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5127 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5128 val = (char *)info->uiapp_info->hwacceleration;
5130 if (strcasecmp(val, "not-use-GL") == 0)
5131 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
5132 else if (strcasecmp(val, "use-GL") == 0)
5133 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
5135 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
5140 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
5142 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5143 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5145 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5146 val = (char *)info->svcapp_info->onboot;
5148 if (strcasecmp(val, "true") == 0)
5150 else if (strcasecmp(val, "false") == 0)
5158 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
5160 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5161 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5163 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5164 val = (char *)info->svcapp_info->autorestart;
5166 if (strcasecmp(val, "true") == 0)
5168 else if (strcasecmp(val, "false") == 0)
5176 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
5178 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5179 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5181 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5182 val = (char *)info->uiapp_info->mainapp;
5184 if (strcasecmp(val, "true") == 0)
5186 else if (strcasecmp(val, "false") == 0)
5194 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
5196 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5197 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5198 __cleanup_appinfo(info);
5202 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
5204 return (pkgmgrinfo_pkginfo_filter_create(handle));
5207 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
5209 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5212 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
5213 const char *property, const int value)
5215 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5216 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5217 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
5219 GSList *link = NULL;
5221 prop = _pminfo_appinfo_convert_to_prop_int(property);
5222 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
5223 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
5224 _LOGE("Invalid Integer Property\n");
5225 return PMINFO_R_EINVAL;
5227 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5228 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5230 _LOGE("Out of Memory!!!\n");
5231 return PMINFO_R_ERROR;
5233 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
5234 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
5236 _LOGE("Out of Memory\n");
5239 return PMINFO_R_ERROR;
5243 /*If API is called multiple times for same property, we should override the previous values.
5244 Last value set will be used for filtering.*/
5245 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5247 filter->list = g_slist_delete_link(filter->list, link);
5248 filter->list = g_slist_append(filter->list, (gpointer)node);
5253 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
5254 const char *property, const bool value)
5256 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5257 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5259 GSList *link = NULL;
5261 prop = _pminfo_appinfo_convert_to_prop_bool(property);
5262 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
5263 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
5264 _LOGE("Invalid Boolean Property\n");
5265 return PMINFO_R_EINVAL;
5267 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5268 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5270 _LOGE("Out of Memory!!!\n");
5271 return PMINFO_R_ERROR;
5274 val = strndup("('true','True')", 15);
5276 val = strndup("('false','False')", 17);
5278 _LOGE("Out of Memory\n");
5281 return PMINFO_R_ERROR;
5285 /*If API is called multiple times for same property, we should override the previous values.
5286 Last value set will be used for filtering.*/
5287 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5289 filter->list = g_slist_delete_link(filter->list, link);
5290 filter->list = g_slist_append(filter->list, (gpointer)node);
5295 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
5296 const char *property, const char *value)
5298 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5299 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5300 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5302 pkgmgrinfo_node_x *ptr = NULL;
5303 char prev[PKG_STRING_LEN_MAX] = {'\0'};
5304 char temp[PKG_STRING_LEN_MAX] = {'\0'};
5305 GSList *link = NULL;
5307 prop = _pminfo_appinfo_convert_to_prop_str(property);
5308 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
5309 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
5310 _LOGE("Invalid String Property\n");
5311 return PMINFO_R_EINVAL;
5313 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5314 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5316 _LOGE("Out of Memory!!!\n");
5317 return PMINFO_R_ERROR;
5321 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
5322 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
5323 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
5325 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
5327 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5329 filter->list = g_slist_delete_link(filter->list, link);
5330 filter->list = g_slist_append(filter->list, (gpointer)node);
5332 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
5333 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
5334 case E_PMINFO_APPINFO_PROP_APP_URI:
5335 case E_PMINFO_APPINFO_PROP_APP_MIME:
5336 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
5338 _LOGE("Out of Memory\n");
5341 return PMINFO_R_ERROR;
5343 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5345 ptr = (pkgmgrinfo_node_x *)link->data;
5346 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
5347 _LOGE("Previous value is %s\n", prev);
5348 filter->list = g_slist_delete_link(filter->list, link);
5349 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
5350 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5351 _LOGE("New value is %s\n", val);
5353 filter->list = g_slist_append(filter->list, (gpointer)node);
5354 memset(temp, '\0', PKG_STRING_LEN_MAX);
5356 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
5357 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5358 _LOGE("First value is %s\n", val);
5360 filter->list = g_slist_append(filter->list, (gpointer)node);
5361 memset(temp, '\0', PKG_STRING_LEN_MAX);
5365 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
5366 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5368 filter->list = g_slist_delete_link(filter->list, link);
5369 filter->list = g_slist_append(filter->list, (gpointer)node);
5375 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
5377 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5378 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5379 char *syslocale = NULL;
5380 char *locale = NULL;
5381 char *condition = NULL;
5382 char *error_message = NULL;
5383 char query[MAX_QUERY_LEN] = {'\0'};
5384 char where[MAX_QUERY_LEN] = {'\0'};
5388 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5389 /*Get current locale*/
5390 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5391 if (syslocale == NULL) {
5392 _LOGE("current locale is NULL\n");
5393 return PMINFO_R_ERROR;
5395 locale = __convert_system_locale_to_manifest_locale(syslocale);
5396 if (locale == NULL) {
5397 _LOGE("manifest locale is NULL\n");
5399 return PMINFO_R_ERROR;
5402 ret = __open_manifest_db();
5404 _LOGE("Fail to open manifest DB\n");
5405 ret = PMINFO_R_ERROR;
5409 /*Start constructing query*/
5410 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_APP, locale);
5412 /*Get where clause*/
5413 for (list = filter->list; list; list = g_slist_next(list)) {
5414 __get_filter_condition(list->data, &condition);
5416 strncat(where, condition, sizeof(where) - strlen(where) -1);
5417 where[sizeof(where) - 1] = '\0';
5421 if (g_slist_next(list)) {
5422 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5423 where[sizeof(where) - 1] = '\0';
5426 _LOGE("where = %s\n", where);
5427 if (strlen(where) > 0) {
5428 strncat(query, where, sizeof(query) - strlen(query) - 1);
5429 query[sizeof(query) - 1] = '\0';
5431 _LOGE("query = %s\n", query);
5435 sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
5436 _LOGE("Don't execute query = %s error message = %s\n", query,
5438 sqlite3_free(error_message);
5439 sqlite3_close(manifest_db);
5440 ret = PMINFO_R_ERROR;
5454 sqlite3_close(manifest_db);
5458 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
5459 pkgmgrinfo_app_list_cb app_cb, void * user_data)
5461 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5462 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5463 char *syslocale = NULL;
5464 char *locale = NULL;
5465 char *condition = NULL;
5466 char *error_message = NULL;
5467 char query[MAX_QUERY_LEN] = {'\0'};
5468 char where[MAX_QUERY_LEN] = {'\0'};
5471 uiapplication_x *ptr1 = NULL;
5472 serviceapplication_x *ptr2 = NULL;
5473 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5474 /*Get current locale*/
5475 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5476 if (syslocale == NULL) {
5477 _LOGE("current locale is NULL\n");
5478 return PMINFO_R_ERROR;
5480 locale = __convert_system_locale_to_manifest_locale(syslocale);
5481 if (locale == NULL) {
5482 _LOGE("manifest locale is NULL\n");
5484 return PMINFO_R_ERROR;
5487 ret = __open_manifest_db();
5489 _LOGE("Fail to open manifest DB\n");
5490 ret = PMINFO_R_ERROR;
5493 /*Start constructing query*/
5494 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
5495 /*Get where clause*/
5496 for (list = filter->list; list; list = g_slist_next(list)) {
5497 __get_filter_condition(list->data, &condition);
5499 strncat(where, condition, sizeof(where) - strlen(where) -1);
5500 where[sizeof(where) - 1] = '\0';
5504 if (g_slist_next(list)) {
5505 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5506 where[sizeof(where) - 1] = '\0';
5509 _LOGE("where = %s\n", where);
5510 if (strlen(where) > 0) {
5511 strncat(query, where, sizeof(query) - strlen(query) - 1);
5512 query[sizeof(query) - 1] = '\0';
5514 _LOGE("query = %s\n", query);
5515 /*To get filtered list*/
5516 pkgmgr_pkginfo_x *info = NULL;
5517 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5519 _LOGE("Out of Memory!!!\n");
5520 ret = PMINFO_R_ERROR;
5523 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5524 if (info->manifest_info == NULL) {
5525 _LOGE("Out of Memory!!!\n");
5526 ret = PMINFO_R_ERROR;
5529 /*To get detail app info for each member of filtered list*/
5530 pkgmgr_pkginfo_x *filtinfo = NULL;
5531 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5532 if (filtinfo == NULL) {
5533 _LOGE("Out of Memory!!!\n");
5534 ret = PMINFO_R_ERROR;
5537 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5538 if (filtinfo->manifest_info == NULL) {
5539 _LOGE("Out of Memory!!!\n");
5540 ret = PMINFO_R_ERROR;
5543 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5544 if (appinfo == NULL) {
5545 _LOGE("Out of Memory!!!\n");
5546 ret = PMINFO_R_ERROR;
5550 sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) {
5551 _LOGE("Don't execute query = %s error message = %s\n", query,
5553 sqlite3_free(error_message);
5554 sqlite3_close(manifest_db);
5555 ret = PMINFO_R_ERROR;
5558 memset(query, '\0', MAX_QUERY_LEN);
5559 if (info->manifest_info->uiapplication) {
5560 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5561 info->manifest_info->uiapplication = ptr1;
5563 if (info->manifest_info->serviceapplication) {
5564 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5565 info->manifest_info->serviceapplication = ptr2;
5567 /*Filtered UI Apps*/
5568 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5570 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5571 ptr1->appid, "uiapp");
5573 sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
5574 _LOGE("Don't execute query = %s error message = %s\n", query,
5576 sqlite3_free(error_message);
5577 sqlite3_close(manifest_db);
5578 ret = PMINFO_R_ERROR;
5582 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5584 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5585 ptr2->appid, "svcapp");
5587 sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
5588 _LOGE("Don't execute query = %s error message = %s\n", query,
5590 sqlite3_free(error_message);
5591 sqlite3_close(manifest_db);
5592 ret = PMINFO_R_ERROR;
5596 if (filtinfo->manifest_info->uiapplication) {
5597 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5598 filtinfo->manifest_info->uiapplication = ptr1;
5600 /*If the callback func return < 0 we break and no more call back is called*/
5603 appinfo->locale = strdup(locale);
5604 appinfo->uiapp_info = ptr1;
5605 appinfo->app_component = PMINFO_UI_APP;
5606 ret = app_cb((void *)appinfo, user_data);
5611 /*Filtered Service Apps*/
5612 if (filtinfo->manifest_info->serviceapplication) {
5613 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5614 filtinfo->manifest_info->serviceapplication = ptr2;
5616 /*If the callback func return < 0 we break and no more call back is called*/
5619 appinfo->locale = strdup(locale);
5620 appinfo->svcapp_info = ptr2;
5621 appinfo->app_component = PMINFO_SVC_APP;
5622 ret = app_cb((void *)appinfo, user_data);
5637 sqlite3_close(manifest_db);
5642 __cleanup_pkginfo(info);
5643 __cleanup_pkginfo(filtinfo);
5647 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
5649 return (pkgmgrinfo_pkginfo_filter_create(handle));
5652 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
5654 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5657 API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
5658 const char *key, const char *value)
5660 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
5661 retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
5662 /*value can be NULL. In that case all apps with specified key should be displayed*/
5666 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5667 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5668 retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
5670 tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5674 tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5677 /*If API is called multiple times, we should OR all conditions.*/
5678 filter->list = g_slist_append(filter->list, (gpointer)node);
5679 /*All memory will be freed in destroy API*/
5697 API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
5698 pkgmgrinfo_app_list_cb app_cb, void *user_data)
5700 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
5701 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
5702 char *syslocale = NULL;
5703 char *locale = NULL;
5704 char *condition = NULL;
5705 char *error_message = NULL;
5706 char query[MAX_QUERY_LEN] = {'\0'};
5707 char where[MAX_QUERY_LEN] = {'\0'};
5710 pkgmgr_pkginfo_x *info = NULL;
5711 pkgmgr_pkginfo_x *filtinfo = NULL;
5712 pkgmgr_appinfo_x *appinfo = NULL;
5713 uiapplication_x *ptr1 = NULL;
5714 serviceapplication_x *ptr2 = NULL;
5715 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5717 /*Get current locale*/
5718 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5719 retvm_if(syslocale == NULL, PMINFO_R_ERROR, "current locale is NULL\n");
5720 locale = __convert_system_locale_to_manifest_locale(syslocale);
5721 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
5723 ret = __open_manifest_db();
5724 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Fail to open manifest DB\n");
5726 /*Start constructing query*/
5727 memset(where, '\0', MAX_QUERY_LEN);
5728 memset(query, '\0', MAX_QUERY_LEN);
5729 snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
5730 /*Get where clause*/
5731 for (list = filter->list; list; list = g_slist_next(list)) {
5732 __get_metadata_filter_condition(list->data, &condition);
5734 strncat(where, condition, sizeof(where) - strlen(where) -1);
5738 if (g_slist_next(list)) {
5739 strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
5742 _LOGE("where = %s (%d)\n", where, strlen(where));
5743 if (strlen(where) > 0) {
5744 strncat(query, where, sizeof(query) - strlen(query) - 1);
5746 _LOGE("query = %s (%d)\n", query, strlen(query));
5747 /*To get filtered list*/
5748 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5749 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5751 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5752 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5754 /*To get detail app info for each member of filtered list*/
5755 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5756 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5758 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5759 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5761 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5762 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5764 ret = sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message);
5765 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5766 memset(query, '\0', MAX_QUERY_LEN);
5768 if (info->manifest_info->uiapplication) {
5769 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5770 info->manifest_info->uiapplication = ptr1;
5772 if (info->manifest_info->serviceapplication) {
5773 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5774 info->manifest_info->serviceapplication = ptr2;
5778 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5780 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5781 ptr1->appid, "uiapp");
5782 ret = sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message);
5783 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5784 memset(query, '\0', MAX_QUERY_LEN);
5787 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5789 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5790 ptr2->appid, "svcapp");
5791 ret = sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message);
5792 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5793 memset(query, '\0', MAX_QUERY_LEN);
5795 /*Filtered UI Apps*/
5796 if (filtinfo->manifest_info->uiapplication) {
5797 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5798 filtinfo->manifest_info->uiapplication = ptr1;
5800 /*If the callback func return < 0 we break and no more call back is called*/
5803 appinfo->locale = strdup(locale);
5804 appinfo->uiapp_info = ptr1;
5805 appinfo->app_component = PMINFO_UI_APP;
5806 ret = app_cb((void *)appinfo, user_data);
5811 /*Filtered Service Apps*/
5812 if (filtinfo->manifest_info->serviceapplication) {
5813 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5814 filtinfo->manifest_info->serviceapplication = ptr2;
5816 /*If the callback func return < 0 we break and no more call back is called*/
5819 appinfo->locale = strdup(locale);
5820 appinfo->svcapp_info = ptr2;
5821 appinfo->app_component = PMINFO_SVC_APP;
5822 ret = app_cb((void *)appinfo, user_data);
5837 sqlite3_free(error_message);
5838 sqlite3_close(manifest_db);
5843 __cleanup_pkginfo(info);
5844 __cleanup_pkginfo(filtinfo);
5848 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
5850 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5851 pkgmgr_certinfo_x *certinfo = NULL;
5852 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
5853 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
5854 *handle = (void *)certinfo;
5858 API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
5860 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
5861 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
5862 pkgmgr_certinfo_x *certinfo = NULL;
5863 char *error_message = NULL;
5864 int ret = PMINFO_R_OK;
5865 char query[MAX_QUERY_LEN] = {'\0'};
5870 ret = db_util_open_with_options(CERT_DB, &cert_db,
5871 SQLITE_OPEN_READONLY, NULL);
5872 if (ret != SQLITE_OK) {
5873 _LOGE("connect db [%s] failed!\n", CERT_DB);
5874 return PMINFO_R_ERROR;
5877 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
5879 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
5880 _LOGE("Don't execute query = %s error message = %s\n", query,
5882 sqlite3_free(error_message);
5883 ret = PMINFO_R_ERROR;
5887 _LOGE("Package not found in DB\n");
5888 ret = PMINFO_R_ERROR;
5891 certinfo = (pkgmgr_certinfo_x *)handle;
5892 /*populate certinfo from DB*/
5893 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
5894 ret = __exec_certinfo_query(query, (void *)certinfo);
5896 _LOGE("Package Cert Info DB Information retrieval failed\n");
5897 ret = PMINFO_R_ERROR;
5900 for (i = 0; i < MAX_CERT_TYPE; i++) {
5901 memset(query, '\0', MAX_QUERY_LEN);
5902 snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
5903 ret = __exec_certinfo_query(query, (void *)certinfo);
5905 _LOGE("Cert Info DB Information retrieval failed\n");
5906 ret = PMINFO_R_ERROR;
5909 if (certinfo->cert_value) {
5910 (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
5911 free(certinfo->cert_value);
5912 certinfo->cert_value = NULL;
5916 sqlite3_close(cert_db);
5920 API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
5922 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5923 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5924 retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5925 retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5926 pkgmgr_certinfo_x *certinfo = NULL;
5927 certinfo = (pkgmgr_certinfo_x *)handle;
5928 if ((certinfo->cert_info)[cert_type])
5929 *cert_value = (certinfo->cert_info)[cert_type];
5935 API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
5937 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5939 pkgmgr_certinfo_x *certinfo = NULL;
5940 certinfo = (pkgmgr_certinfo_x *)handle;
5941 if (certinfo->pkgid) {
5942 free(certinfo->pkgid);
5943 certinfo->pkgid = NULL;
5945 for (i = 0; i < MAX_CERT_TYPE; i++) {
5946 if ((certinfo->cert_info)[i]) {
5947 free((certinfo->cert_info)[i]);
5948 (certinfo->cert_info)[i] = NULL;
5956 API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
5958 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5959 pkgmgr_instcertinfo_x *certinfo = NULL;
5960 certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
5961 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
5962 *handle = (void *)certinfo;
5966 API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
5968 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5969 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5970 retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5971 retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5972 pkgmgr_instcertinfo_x *certinfo = NULL;
5973 certinfo = (pkgmgr_instcertinfo_x *)handle;
5974 (certinfo->cert_info)[cert_type] = strdup(cert_value);
5978 API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
5980 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
5981 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
5982 char *error_message = NULL;
5983 char query[MAX_QUERY_LEN] = {'\0'};
5984 char *vquery = NULL;
5989 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
5996 pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
5997 pkgmgr_certindexinfo_x *indexinfo = NULL;
5998 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
5999 if (indexinfo == NULL) {
6000 _LOGE("Out of Memory!!!");
6001 return PMINFO_R_ERROR;
6003 info->pkgid = strdup(pkgid);
6006 ret = db_util_open_with_options(CERT_DB, &cert_db,
6007 SQLITE_OPEN_READWRITE, NULL);
6008 if (ret != SQLITE_OK) {
6009 _LOGE("connect db [%s] failed!\n", CERT_DB);
6010 ret = PMINFO_R_ERROR;
6013 /*Begin Transaction*/
6014 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6015 if (ret != SQLITE_OK) {
6016 _LOGE("Failed to begin transaction\n");
6017 ret = PMINFO_R_ERROR;
6020 _LOGE("Transaction Begin\n");
6021 /*Check if request is to insert/update*/
6022 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6024 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6025 _LOGE("Don't execute query = %s error message = %s\n", query,
6027 sqlite3_free(error_message);
6028 ret = PMINFO_R_ERROR;
6033 We cant just issue update query directly. We need to manage index table also.
6034 Hence it is better to delete and insert again in case of update*/
6035 ret = __delete_certinfo(pkgid);
6037 _LOGE("Certificate Deletion Failed\n");
6039 for (i = 0; i < MAX_CERT_TYPE; i++) {
6040 if ((info->cert_info)[i]) {
6041 for (j = 0; j < i; j++) {
6042 if ( (info->cert_info)[j]) {
6043 if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
6044 (info->cert_id)[i] = (info->cert_id)[j];
6045 (info->is_new)[i] = 0;
6046 (info->ref_count)[i] = (info->ref_count)[j];
6053 memset(query, '\0', MAX_QUERY_LEN);
6054 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
6055 "where cert_info='%s'",(info->cert_info)[i]);
6056 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
6058 _LOGE("Cert Info DB Information retrieval failed\n");
6059 ret = PMINFO_R_ERROR;
6062 if (indexinfo->cert_id == 0) {
6063 /*New certificate. Get newid*/
6064 memset(query, '\0', MAX_QUERY_LEN);
6065 snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
6067 sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
6068 _LOGE("Don't execute query = %s error message = %s\n", query,
6070 sqlite3_free(error_message);
6071 ret = PMINFO_R_ERROR;
6079 indexinfo->cert_id = maxid;
6080 indexinfo->cert_ref_count = 1;
6084 (info->cert_id)[i] = indexinfo->cert_id;
6085 (info->is_new)[i] = is_new;
6086 (info->ref_count)[i] = indexinfo->cert_ref_count;
6087 _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
6088 indexinfo->cert_id = 0;
6089 indexinfo->cert_ref_count = 0;
6093 len = MAX_QUERY_LEN;
6094 for (i = 0; i < MAX_CERT_TYPE; i++) {
6095 if ((info->cert_info)[i])
6096 len+= strlen((info->cert_info)[i]);
6098 vquery = (char *)calloc(1, len);
6100 snprintf(vquery, len,
6101 "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
6102 "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
6103 "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
6104 info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
6105 (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
6106 (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
6107 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
6108 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
6110 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6111 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6113 sqlite3_free(error_message);
6114 ret = PMINFO_R_ERROR;
6117 /*Update index table info*/
6118 /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
6119 for (i = 0; i < MAX_CERT_TYPE; i++) {
6120 if ((info->cert_info)[i]) {
6121 memset(vquery, '\0', len);
6122 if ((info->is_new)[i]) {
6123 snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
6124 "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
6125 unique_id[c++] = (info->cert_id)[i];
6128 for (j = 0; j < MAX_CERT_TYPE; j++) {
6129 if ((info->cert_id)[i] == unique_id[j]) {
6130 /*Ref count has already been increased. Just continue*/
6134 if (j == MAX_CERT_TYPE)
6135 unique_id[c++] = (info->cert_id)[i];
6138 snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
6139 "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
6142 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6143 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6145 sqlite3_free(error_message);
6146 ret = PMINFO_R_ERROR;
6151 /*Commit transaction*/
6152 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6153 if (ret != SQLITE_OK) {
6154 _LOGE("Failed to commit transaction, Rollback now\n");
6155 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6156 ret = PMINFO_R_ERROR;
6159 _LOGE("Transaction Commit and End\n");
6162 sqlite3_close(cert_db);
6174 API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
6176 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6178 pkgmgr_instcertinfo_x *certinfo = NULL;
6179 certinfo = (pkgmgr_instcertinfo_x *)handle;
6180 if (certinfo->pkgid) {
6181 free(certinfo->pkgid);
6182 certinfo->pkgid = NULL;
6184 for (i = 0; i < MAX_CERT_TYPE; i++) {
6185 if ((certinfo->cert_info)[i]) {
6186 free((certinfo->cert_info)[i]);
6187 (certinfo->cert_info)[i] = NULL;
6195 API int pkgmgrinfo_delete_certinfo(const char *pkgid)
6197 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6200 ret = db_util_open_with_options(CERT_DB, &cert_db,
6201 SQLITE_OPEN_READWRITE, NULL);
6202 if (ret != SQLITE_OK) {
6203 _LOGE("connect db [%s] failed!\n", CERT_DB);
6204 ret = PMINFO_R_ERROR;
6207 /*Begin Transaction*/
6208 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6209 if (ret != SQLITE_OK) {
6210 _LOGE("Failed to begin transaction\n");
6211 ret = PMINFO_R_ERROR;
6214 _LOGE("Transaction Begin\n");
6215 ret = __delete_certinfo(pkgid);
6217 _LOGE("Certificate Deletion Failed\n");
6219 _LOGE("Certificate Deletion Success\n");
6221 /*Commit transaction*/
6222 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6223 if (ret != SQLITE_OK) {
6224 _LOGE("Failed to commit transaction, Rollback now\n");
6225 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6226 ret = PMINFO_R_ERROR;
6229 _LOGE("Transaction Commit and End\n");
6232 sqlite3_close(cert_db);
6236 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
6238 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
6239 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6241 char *manifest = NULL;
6242 manifest_x *mfx = NULL;
6244 manifest = pkgmgr_parser_get_manifest_file(pkgid);
6245 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
6247 mfx = pkgmgr_parser_process_manifest_xml(manifest);
6252 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
6254 *handle = (void *)mfx;
6259 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
6261 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
6262 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6264 int len = strlen(type);
6265 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6267 manifest_x *mfx = (manifest_x *)handle;
6269 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
6273 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
6275 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
6276 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6278 int len = strlen(version);
6279 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6281 manifest_x *mfx = (manifest_x *)handle;
6283 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
6287 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6289 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6290 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6292 manifest_x *mfx = (manifest_x *)handle;
6294 if (location == INSTALL_INTERNAL)
6295 strcpy(mfx->installlocation, "internal-only");
6296 else if (location == INSTALL_EXTERNAL)
6297 strcpy(mfx->installlocation, "prefer-external");
6302 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
6304 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6305 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6307 manifest_x *mfx = (manifest_x *)handle;
6309 mfx->package_size = strdup(size);
6314 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
6316 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6317 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6319 int len = strlen(label_txt);
6320 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6322 manifest_x *mfx = (manifest_x *)handle;
6324 label_x *label = calloc(1, sizeof(label_x));
6325 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6327 LISTADD(mfx->label, label);
6329 mfx->label->lang = strdup(locale);
6331 mfx->label->lang = strdup(DEFAULT_LOCALE);
6332 mfx->label->text = strdup(label_txt);
6337 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
6339 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6340 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6342 int len = strlen(icon_txt);
6343 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6345 manifest_x *mfx = (manifest_x *)handle;
6347 icon_x *icon = calloc(1, sizeof(icon_x));
6348 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6350 LISTADD(mfx->icon, icon);
6352 mfx->icon->lang = strdup(locale);
6354 mfx->icon->lang = strdup(DEFAULT_LOCALE);
6355 mfx->icon->text = strdup(icon_txt);
6360 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
6362 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6363 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6365 int len = strlen(desc_txt);
6366 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6368 manifest_x *mfx = (manifest_x *)handle;
6370 description_x *description = calloc(1, sizeof(description_x));
6371 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6373 LISTADD(mfx->description, description);
6375 mfx->description->lang = strdup(locale);
6377 mfx->description->lang = strdup(DEFAULT_LOCALE);
6378 mfx->description->text = strdup(desc_txt);
6383 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
6384 const char *author_email, const char *author_href, const char *locale)
6386 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6387 manifest_x *mfx = (manifest_x *)handle;
6388 author_x *author = calloc(1, sizeof(author_x));
6389 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6391 LISTADD(mfx->author, author);
6393 mfx->author->text = strdup(author_name);
6395 mfx->author->email = strdup(author_email);
6397 mfx->author->href = strdup(author_href);
6399 mfx->author->lang = strdup(locale);
6401 mfx->author->lang = strdup(DEFAULT_LOCALE);
6405 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
6407 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6408 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6410 manifest_x *mfx = (manifest_x *)handle;
6413 strcpy(mfx->removable, "false");
6414 else if (removable == 1)
6415 strcpy(mfx->removable, "true");
6420 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
6422 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6423 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6425 manifest_x *mfx = (manifest_x *)handle;
6428 strcpy(mfx->preload, "false");
6429 else if (preload == 1)
6430 strcpy(mfx->preload, "true");
6435 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6437 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6438 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6440 manifest_x *mfx = (manifest_x *)handle;
6442 if (location == INSTALL_INTERNAL)
6443 strcpy(mfx->installed_storage, "installed_internal");
6444 else if (location == INSTALL_EXTERNAL)
6445 strcpy(mfx->installed_storage, "installed_external");
6450 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6452 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6455 manifest_x *mfx = NULL;
6456 mfx = (manifest_x *)handle;
6458 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
6460 _LOGE("Successfully stored info in DB\n");
6463 _LOGE("Failed to store info in DB\n");
6464 return PMINFO_R_ERROR;
6468 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6470 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6472 manifest_x *mfx = NULL;
6473 mfx = (manifest_x *)handle;
6474 pkgmgr_parser_free_manifest_xml(mfx);
6478 API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
6480 /* Should be implemented later */
6484 API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
6486 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6488 char query[MAX_QUERY_LEN] = {'\0'};
6489 ret = __open_manifest_db();
6491 if (access(MANIFEST_DB, F_OK) == 0) {
6492 ret = db_util_open(MANIFEST_DB, &manifest_db,
6493 DB_UTIL_REGISTER_HOOK_METHOD);
6494 if (ret != SQLITE_OK) {
6495 _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
6496 return PMINFO_R_ERROR;
6500 /*Begin transaction*/
6501 ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6502 if (ret != SQLITE_OK) {
6503 _LOGE("Failed to begin transaction\n");
6504 sqlite3_close(manifest_db);
6505 return PMINFO_R_ERROR;
6507 _LOGD("Transaction Begin\n");
6509 memset(query, '\0', MAX_QUERY_LEN);
6510 snprintf(query, MAX_QUERY_LEN,
6511 "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
6513 char *error_message = NULL;
6515 sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
6516 _LOGE("Don't execute query = %s error message = %s\n", query,
6518 sqlite3_free(error_message);
6519 return PMINFO_R_ERROR;
6521 sqlite3_free(error_message);
6523 /*Commit transaction*/
6524 ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
6525 if (ret != SQLITE_OK) {
6526 _LOGE("Failed to commit transaction. Rollback now\n");
6527 sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
6528 sqlite3_close(manifest_db);
6529 return PMINFO_R_ERROR;
6531 _LOGD("Transaction Commit and End\n");
6532 sqlite3_close(manifest_db);
6538 API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
6540 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6541 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6542 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6543 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6544 int ret = PMINFO_R_OK;
6545 char query[MAX_QUERY_LEN] = {'\0'};
6546 char *error_message = NULL;
6547 pkgmgr_datacontrol_x *data = NULL;
6549 ret = __open_datacontrol_db();
6551 _LOGE("Fail to open datacontrol DB\n");
6552 return PMINFO_R_ERROR;
6555 data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x));
6557 _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
6558 sqlite3_close(datacontrol_db);
6559 return PMINFO_R_ERROR;
6562 snprintf(query, MAX_QUERY_LEN,
6563 "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",
6567 sqlite3_exec(datacontrol_db, query, __datacontrol_cb, (void *)data, &error_message)) {
6568 _LOGE("Don't execute query = %s error message = %s\n", query,
6570 sqlite3_free(error_message);
6571 sqlite3_close(datacontrol_db);
6572 return PMINFO_R_ERROR;
6575 *appid = (char *)data->appid;
6576 *access = (char *)data->access;
6578 sqlite3_close(datacontrol_db);
6583 API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
6585 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6587 char query[MAX_QUERY_LEN] = {'\0'};
6588 char *error_message = NULL;
6589 ret = __open_manifest_db();
6591 if (access(MANIFEST_DB, F_OK) == 0) {
6592 ret = db_util_open(MANIFEST_DB, &manifest_db,
6593 DB_UTIL_REGISTER_HOOK_METHOD);
6594 if (ret != SQLITE_OK) {
6595 _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
6596 return PMINFO_R_ERROR;
6600 /*Begin transaction*/
6601 ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6602 if (ret != SQLITE_OK) {
6603 _LOGE("Failed to begin transaction\n");
6604 sqlite3_close(manifest_db);
6605 return PMINFO_R_ERROR;
6607 _LOGD("Transaction Begin\n");
6609 memset(query, '\0', MAX_QUERY_LEN);
6610 snprintf(query, MAX_QUERY_LEN,
6611 "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid);
6614 sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
6615 _LOGE("Don't execute query = %s error message = %s\n", query,
6617 sqlite3_free(error_message);
6618 return PMINFO_R_ERROR;
6621 /*Commit transaction*/
6622 ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
6623 if (ret != SQLITE_OK) {
6624 _LOGE("Failed to commit transaction. Rollback now\n");
6625 sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
6626 sqlite3_close(manifest_db);
6627 return PMINFO_R_ERROR;
6629 _LOGD("Transaction Commit and End\n");
6630 sqlite3_close(manifest_db);
6635 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
6637 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6638 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6640 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6641 val = (char *)info->uiapp_info->guestmode_visibility;
6643 if (strcasecmp(val, "true") == 0){
6645 }else if (strcasecmp(val, "false") == 0){
6654 API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
6656 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6659 char *noti_string = NULL;
6661 char query[MAX_QUERY_LEN] = {'\0'};
6662 char *errmsg = NULL;
6663 sqlite3 *pkgmgr_parser_db;
6665 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6666 val = (char *)info->uiapp_info->guestmode_visibility;
6669 db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db,
6670 SQLITE_OPEN_READWRITE, NULL);
6672 if (ret != SQLITE_OK) {
6673 _LOGE("DB Open Failed\n");
6674 return PMINFO_R_ERROR;
6677 /*TODO: Write to DB here*/
6679 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
6681 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
6683 if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
6684 _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
6686 sqlite3_close(pkgmgr_parser_db);
6687 return PMINFO_R_ERROR;
6689 sqlite3_close(pkgmgr_parser_db);
6690 len = strlen((char *)info->uiapp_info->appid) + 8;
6691 noti_string = calloc(1, len);
6692 if (noti_string == NULL){
6693 return PMINFO_R_ERROR;
6695 snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
6696 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
6697 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed