4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
34 #include <libxml/parser.h>
35 #include <libxml/xmlreader.h>
36 #include <libxml/xmlschemas.h>
38 #include "pkgmgr_parser.h"
39 #include "pkgmgr-info-internal.h"
40 #include "pkgmgr-info-debug.h"
41 #include "pkgmgr-info.h"
42 #include "pkgmgr_parser_db.h"
46 #define ASC_CHAR(s) (const char *)s
47 #define XML_CHAR(s) (const xmlChar *)s
49 #define MANIFEST_DB "/opt/dbspace/.pkgmgr_parser.db"
50 #define MAX_QUERY_LEN 4096
51 #define MAX_CERT_TYPE 9
52 #define CERT_DB "/opt/dbspace/.pkgmgr_cert.db"
53 #define DATACONTROL_DB "/opt/usr/dbspace/.app-package.db"
54 #define PKG_TYPE_STRING_LEN_MAX 128
55 #define PKG_VERSION_STRING_LEN_MAX 128
56 #define PKG_VALUE_STRING_LEN_MAX 512
57 #define PKG_LOCALE_STRING_LEN_MAX 8
58 #define PKG_RW_PATH "/opt/usr/apps/"
59 #define PKG_RO_PATH "/usr/apps/"
60 #define BLOCK_SIZE 4096 /*in bytes*/
62 #define MMC_PATH "/opt/storage/sdcard"
63 #define PKG_SD_PATH MMC_PATH"/app2sd/"
64 #define PKG_INSTALLATION_PATH "/opt/usr/apps/"
66 #define FILTER_QUERY_COUNT_PACKAGE "select count(DISTINCT package_info.package) " \
67 "from package_info LEFT OUTER JOIN package_localized_info " \
68 "ON package_info.package=package_localized_info.package " \
69 "and package_localized_info.package_locale='%s' where "
71 #define FILTER_QUERY_LIST_PACKAGE "select DISTINCT package_info.package " \
72 "from package_info LEFT OUTER JOIN package_localized_info " \
73 "ON package_info.package=package_localized_info.package " \
74 "and package_localized_info.package_locale='%s' where "
76 #define FILTER_QUERY_COUNT_APP "select count(DISTINCT package_app_info.app_id) " \
77 "from package_app_info LEFT OUTER JOIN package_app_localized_info " \
78 "ON package_app_info.app_id=package_app_localized_info.app_id " \
79 "and package_app_localized_info.app_locale='%s' " \
80 "LEFT OUTER JOIN package_app_app_svc " \
81 "ON package_app_info.app_id=package_app_app_svc.app_id " \
82 "LEFT OUTER JOIN package_app_app_category " \
83 "ON package_app_info.app_id=package_app_app_category.app_id where "
85 #define FILTER_QUERY_LIST_APP "select DISTINCT package_app_info.app_id, package_app_info.app_component " \
86 "from package_app_info LEFT OUTER JOIN package_app_localized_info " \
87 "ON package_app_info.app_id=package_app_localized_info.app_id " \
88 "and package_app_localized_info.app_locale='%s' " \
89 "LEFT OUTER JOIN package_app_app_svc " \
90 "ON package_app_info.app_id=package_app_app_svc.app_id " \
91 "LEFT OUTER JOIN package_app_app_category " \
92 "ON package_app_info.app_id=package_app_app_category.app_id where "
94 #define METADATA_FILTER_QUERY_SELECT_CLAUSE "select DISTINCT package_app_info.app_id, package_app_info.app_component " \
95 "from package_app_info LEFT OUTER JOIN package_app_app_metadata " \
96 "ON package_app_info.app_id=package_app_app_metadata.app_id where "
98 #define METADATA_FILTER_QUERY_UNION_CLAUSE " UNION "METADATA_FILTER_QUERY_SELECT_CLAUSE
100 #define LANGUAGE_LENGTH 2
102 typedef struct _pkgmgr_instcertinfo_x {
104 char *cert_info[MAX_CERT_TYPE]; /*certificate data*/
105 int is_new[MAX_CERT_TYPE]; /*whether already exist in table or not*/
106 int ref_count[MAX_CERT_TYPE]; /*reference count of certificate data*/
107 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
108 } pkgmgr_instcertinfo_x;
110 typedef struct _pkgmgr_certindexinfo_x {
113 } pkgmgr_certindexinfo_x;
115 typedef struct _pkgmgr_pkginfo_x {
116 manifest_x *manifest_info;
119 struct _pkgmgr_pkginfo_x *prev;
120 struct _pkgmgr_pkginfo_x *next;
123 typedef struct _pkgmgr_cert_x {
128 typedef struct _pkgmgr_datacontrol_x {
131 } pkgmgr_datacontrol_x;
133 typedef struct _pkgmgr_iconpath_x {
138 typedef struct _pkgmgr_image_x {
142 typedef struct _pkgmgr_locale_x {
146 typedef struct _pkgmgr_appinfo_x {
149 pkgmgrinfo_app_component app_component;
151 uiapplication_x *uiapp_info;
152 serviceapplication_x *svcapp_info;
156 typedef struct _pkgmgr_certinfo_x {
159 char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
160 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
164 typedef struct _pkgmgrinfo_filter_x {
166 } pkgmgrinfo_filter_x;
168 typedef struct _pkgmgrinfo_node_x {
174 typedef struct _pkgmgrinfo_appcontrol_x {
181 } pkgmgrinfo_appcontrol_x;
183 typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
185 char *pkgtype = "rpm";
186 __thread sqlite3 *manifest_db = NULL;
187 __thread sqlite3 *datacontrol_db = NULL;
188 __thread sqlite3 *cert_db = NULL;
190 static int __open_manifest_db();
191 static int __exec_pkginfo_query(char *query, void *data);
192 static int __exec_certinfo_query(char *query, void *data);
193 static int __exec_certindexinfo_query(char *query, void *data);
194 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname);
195 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname);
196 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname);
197 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname);
198 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname);
199 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname);
200 static int __count_cb(void *data, int ncols, char **coltxt, char **colname);
201 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
202 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
203 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname);
204 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname);
205 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data);
206 static void __cleanup_appinfo(pkgmgr_appinfo_x *data);
207 static char* __convert_system_locale_to_manifest_locale(char *syslocale);
208 static void __destroy_each_node(gpointer data, gpointer user_data);
209 static void __get_filter_condition(gpointer data, char **condition);
210 static void __get_metadata_filter_condition(gpointer data, char **condition);
211 static gint __compare_func(gconstpointer data1, gconstpointer data2);
212 static int __delete_certinfo(const char *pkgid);
214 static gint __compare_func(gconstpointer data1, gconstpointer data2)
216 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
217 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
218 if (node1->prop == node2->prop)
220 else if (node1->prop > node2->prop)
226 static int __count_cb(void *data, int ncols, char **coltxt, char **colname)
229 *p = atoi(coltxt[0]);
230 _LOGE("count value is %d\n", *p);
234 static void __destroy_each_node(gpointer data, gpointer user_data)
236 ret_if(data == NULL);
237 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
250 static void __get_metadata_filter_condition(gpointer data, char **condition)
252 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
253 char key[MAX_QUERY_LEN] = {'\0'};
254 char value[MAX_QUERY_LEN] = {'\0'};
256 snprintf(key, MAX_QUERY_LEN, "(package_app_app_metadata.md_key='%s'", node->key);
259 snprintf(value, MAX_QUERY_LEN, " AND package_app_app_metadata.md_value='%s')", node->value);
264 *condition = strdup(key);
268 static void __get_filter_condition(gpointer data, char **condition)
270 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
271 char buf[MAX_QUERY_LEN + 1] = {'\0'};
272 char temp[PKG_STRING_LEN_MAX] = {'\0'};
273 switch (node->prop) {
274 case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
275 snprintf(buf, MAX_QUERY_LEN, "package_info.package='%s'", node->value);
277 case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
278 snprintf(buf, MAX_QUERY_LEN, "package_info.package_type='%s'", node->value);
280 case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
281 snprintf(buf, MAX_QUERY_LEN, "package_info.package_version='%s'", node->value);
283 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
284 snprintf(buf, MAX_QUERY_LEN, "package_info.install_location='%s'", node->value);
286 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
287 snprintf(buf, MAX_QUERY_LEN, "package_info.installed_storage='%s'", node->value);
289 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
290 snprintf(buf, MAX_QUERY_LEN, "package_info.author_name='%s'", node->value);
292 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
293 snprintf(buf, MAX_QUERY_LEN, "package_info.author_href='%s'", node->value);
295 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
296 snprintf(buf, MAX_QUERY_LEN, "package_info.author_email='%s'", node->value);
298 case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
299 snprintf(buf, MAX_QUERY_LEN, "package_info.package_size='%s'", node->value);
301 case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
302 snprintf(buf, MAX_QUERY_LEN, "package_info.package_removable IN %s", node->value);
304 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
305 snprintf(buf, MAX_QUERY_LEN, "package_info.package_preload IN %s", node->value);
307 case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
308 snprintf(buf, MAX_QUERY_LEN, "package_info.package_readonly IN %s", node->value);
310 case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
311 snprintf(buf, MAX_QUERY_LEN, "package_info.package_update IN %s", node->value);
313 case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
314 snprintf(buf, MAX_QUERY_LEN, "package_info.package_appsetting IN %s", node->value);
316 case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
317 snprintf(buf, MAX_QUERY_LEN, "package_info.package_nodisplay IN %s", node->value);
320 case E_PMINFO_APPINFO_PROP_APP_ID:
321 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_id='%s'", node->value);
323 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
324 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_component='%s'", node->value);
326 case E_PMINFO_APPINFO_PROP_APP_EXEC:
327 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_exec='%s'", node->value);
329 case E_PMINFO_APPINFO_PROP_APP_ICON:
330 snprintf(buf, MAX_QUERY_LEN, "package_app_localized_info.app_icon='%s'", node->value);
332 case E_PMINFO_APPINFO_PROP_APP_TYPE:
333 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_type='%s'", node->value);
335 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
336 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
337 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.operation IN %s", temp);
339 case E_PMINFO_APPINFO_PROP_APP_URI:
340 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
341 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.uri_scheme IN %s", temp);
343 case E_PMINFO_APPINFO_PROP_APP_MIME:
344 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
345 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.mime_type IN %s", temp);
347 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
348 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
349 snprintf(buf, MAX_QUERY_LEN, "package_app_app_category.category IN %s", temp);
351 case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
352 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_nodisplay IN %s", node->value);
354 case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
355 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_multiple IN %s", node->value);
357 case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
358 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_onboot IN %s", node->value);
360 case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
361 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_autorestart IN %s", node->value);
363 case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
364 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_taskmanage IN %s", node->value);
366 case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
367 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_hwacceleration='%s'", node->value);
369 case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
370 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
373 _LOGE("Invalid Property Type\n");
377 *condition = strdup(buf);
381 static char* __convert_system_locale_to_manifest_locale(char *syslocale)
383 if (syslocale == NULL)
384 return strdup(DEFAULT_LOCALE);
386 locale = (char *)calloc(1, 6);
387 retvm_if(!locale, NULL, "Malloc Failed\n");
389 strncpy(locale, syslocale, 2);
390 strncat(locale, "-", 1);
391 locale[3] = syslocale[3] + 32;
392 locale[4] = syslocale[4] + 32;
396 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
398 ret_if(data == NULL);
400 free((void *)data->locale);
404 pkgmgr_parser_free_manifest_xml(data->manifest_info);
410 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
412 ret_if(data == NULL);
414 free((void *)data->package);
415 data->package = NULL;
418 free((void *)data->locale);
422 manifest_x *mfx = calloc(1, sizeof(manifest_x));
423 if (data->app_component == PMINFO_UI_APP)
424 mfx->uiapplication = data->uiapp_info;
425 else if (data->app_component == PMINFO_SVC_APP)
426 mfx->serviceapplication = data->svcapp_info;
427 pkgmgr_parser_free_manifest_xml(mfx);
433 static int __open_manifest_db()
436 if (access(MANIFEST_DB, F_OK) == 0) {
438 db_util_open_with_options(MANIFEST_DB, &manifest_db,
439 SQLITE_OPEN_READONLY, NULL);
440 retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", MANIFEST_DB);
443 _LOGE("Manifest DB does not exists !!\n");
447 static int __open_datacontrol_db()
450 if (access(DATACONTROL_DB, F_OK) == 0) {
452 db_util_open_with_options(DATACONTROL_DB, &datacontrol_db,
453 SQLITE_OPEN_READONLY, NULL);
454 retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", DATACONTROL_DB);
457 _LOGE("Datacontrol DB does not exists !!\n");
461 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
463 pkgmgr_pkginfo_x *udata = (pkgmgr_pkginfo_x *)data;
465 pkgmgr_pkginfo_x *info = NULL;
466 info = calloc(1, sizeof(pkgmgr_pkginfo_x));
467 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
469 LISTADD(udata, info);
470 for(i = 0; i < ncols; i++)
472 if (strcmp(colname[i], "package") == 0) {
474 info->manifest_info->package = strdup(coltxt[i]);
476 info->manifest_info->package = NULL;
484 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname)
486 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
489 uiapplication_x *uiapp = NULL;
490 serviceapplication_x *svcapp = NULL;
491 for(i = 0; i < ncols; i++)
493 if ((strcmp(colname[i], "app_component") == 0) ||
494 (strcmp(colname[i], "package_app_info.app_component") == 0)) {
496 if (strcmp(coltxt[i], "uiapp") == 0) {
497 uiapp = calloc(1, sizeof(uiapplication_x));
499 _LOGE("Out of Memory!!!\n");
502 LISTADD(info->manifest_info->uiapplication, uiapp);
503 for(j = 0; j < ncols; j++)
505 if ((strcmp(colname[j], "app_id") == 0) ||
506 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
508 info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
509 } else if (strcmp(colname[j], "package") == 0) {
511 info->manifest_info->uiapplication->package = strdup(coltxt[j]);
516 svcapp = calloc(1, sizeof(serviceapplication_x));
517 if (svcapp == NULL) {
518 _LOGE("Out of Memory!!!\n");
521 LISTADD(info->manifest_info->serviceapplication, svcapp);
522 for(j = 0; j < ncols; j++)
524 if ((strcmp(colname[j], "app_id") == 0) ||
525 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
527 info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
528 } else if (strcmp(colname[j], "package") == 0) {
530 info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
544 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
546 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
548 uiapplication_x *uiapp = NULL;
550 label_x *label = NULL;
552 uiapp = calloc(1, sizeof(uiapplication_x));
553 LISTADD(info->manifest_info->uiapplication, uiapp);
554 icon = calloc(1, sizeof(icon_x));
555 LISTADD(info->manifest_info->uiapplication->icon, icon);
556 label = calloc(1, sizeof(label_x));
557 LISTADD(info->manifest_info->uiapplication->label, label);
559 for(i = 0; i < ncols; i++)
561 if (strcmp(colname[i], "app_id") == 0) {
563 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
565 info->manifest_info->uiapplication->appid = NULL;
566 } else if (strcmp(colname[i], "app_exec") == 0) {
568 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
570 info->manifest_info->uiapplication->exec = NULL;
571 } else if (strcmp(colname[i], "app_type") == 0 ){
573 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
575 info->manifest_info->uiapplication->type = NULL;
576 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
578 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
580 info->manifest_info->uiapplication->nodisplay = NULL;
581 } else if (strcmp(colname[i], "app_multiple") == 0 ){
583 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
585 info->manifest_info->uiapplication->multiple = NULL;
586 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
588 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
590 info->manifest_info->uiapplication->taskmanage = NULL;
591 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
593 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
595 info->manifest_info->uiapplication->hwacceleration = NULL;
596 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
598 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
600 info->manifest_info->uiapplication->indicatordisplay = NULL;
601 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
603 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
605 info->manifest_info->uiapplication->portraitimg = NULL;
606 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
608 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
610 info->manifest_info->uiapplication->landscapeimg = NULL;
611 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
613 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
615 info->manifest_info->uiapplication->guestmode_visibility = NULL;
616 } else if (strcmp(colname[i], "package") == 0 ){
618 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
620 info->manifest_info->uiapplication->package = NULL;
621 } else if (strcmp(colname[i], "app_icon") == 0) {
623 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
625 info->manifest_info->uiapplication->icon->text = NULL;
626 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
628 info->manifest_info->uiapplication->enabled= strdup(coltxt[i]);
630 info->manifest_info->uiapplication->enabled = NULL;
631 } else if (strcmp(colname[i], "app_label") == 0 ) {
633 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
635 info->manifest_info->uiapplication->label->text = NULL;
636 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
638 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
640 info->manifest_info->uiapplication->recentimage = NULL;
641 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
643 info->manifest_info->uiapplication->mainapp = strdup(coltxt[i]);
645 info->manifest_info->uiapplication->mainapp = NULL;
646 } else if (strcmp(colname[i], "app_locale") == 0 ) {
648 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
649 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
652 info->manifest_info->uiapplication->icon->lang = NULL;
653 info->manifest_info->uiapplication->label->lang = NULL;
655 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
657 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
659 info->manifest_info->uiapplication->permission_type = NULL;
666 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
668 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
670 serviceapplication_x *svcapp = NULL;
672 label_x *label = NULL;
674 svcapp = calloc(1, sizeof(serviceapplication_x));
675 LISTADD(info->manifest_info->serviceapplication, svcapp);
676 icon = calloc(1, sizeof(icon_x));
677 LISTADD(info->manifest_info->serviceapplication->icon, icon);
678 label = calloc(1, sizeof(label_x));
679 LISTADD(info->manifest_info->serviceapplication->label, label);
680 for(i = 0; i < ncols; i++)
682 if (strcmp(colname[i], "app_id") == 0) {
684 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
686 info->manifest_info->serviceapplication->appid = NULL;
687 } else if (strcmp(colname[i], "app_exec") == 0) {
689 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
691 info->manifest_info->serviceapplication->exec = NULL;
692 } else if (strcmp(colname[i], "app_type") == 0 ){
694 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
696 info->manifest_info->serviceapplication->type = NULL;
697 } else if (strcmp(colname[i], "app_onboot") == 0 ){
699 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
701 info->manifest_info->serviceapplication->onboot = NULL;
702 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
704 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
706 info->manifest_info->serviceapplication->autorestart = NULL;
707 } else if (strcmp(colname[i], "package") == 0 ){
709 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
711 info->manifest_info->serviceapplication->package = NULL;
712 } else if (strcmp(colname[i], "app_icon") == 0) {
714 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
716 info->manifest_info->serviceapplication->icon->text = NULL;
717 } else if (strcmp(colname[i], "app_label") == 0 ) {
719 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
721 info->manifest_info->serviceapplication->label->text = NULL;
722 } else if (strcmp(colname[i], "app_locale") == 0 ) {
724 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
725 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
728 info->manifest_info->serviceapplication->icon->lang = NULL;
729 info->manifest_info->serviceapplication->label->lang = NULL;
731 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
733 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
735 info->manifest_info->serviceapplication->permission_type = NULL;
742 static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
744 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
747 uiapplication_x *uiapp = NULL;
748 serviceapplication_x *svcapp = NULL;
749 for(j = 0; j < ncols; j++)
751 if (strcmp(colname[j], "app_component") == 0) {
753 if (strcmp(coltxt[j], "uiapp") == 0) {
754 uiapp = calloc(1, sizeof(uiapplication_x));
756 _LOGE("Out of Memory!!!\n");
759 LISTADD(info->manifest_info->uiapplication, uiapp);
760 for(i = 0; i < ncols; i++)
762 if (strcmp(colname[i], "app_id") == 0) {
764 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
766 info->manifest_info->uiapplication->appid = NULL;
767 } else if (strcmp(colname[i], "app_exec") == 0) {
769 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
771 info->manifest_info->uiapplication->exec = NULL;
772 } else if (strcmp(colname[i], "app_type") == 0 ){
774 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
776 info->manifest_info->uiapplication->type = NULL;
777 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
779 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
781 info->manifest_info->uiapplication->nodisplay = NULL;
782 } else if (strcmp(colname[i], "app_multiple") == 0 ){
784 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
786 info->manifest_info->uiapplication->multiple = NULL;
787 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
789 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
791 info->manifest_info->uiapplication->taskmanage = NULL;
792 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
794 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
796 info->manifest_info->uiapplication->hwacceleration = NULL;
797 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
799 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
801 info->manifest_info->uiapplication->indicatordisplay = NULL;
802 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
804 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
806 info->manifest_info->uiapplication->portraitimg = NULL;
807 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
809 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
811 info->manifest_info->uiapplication->landscapeimg = NULL;
812 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
814 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
816 info->manifest_info->uiapplication->guestmode_visibility = NULL;
817 } else if (strcmp(colname[i], "package") == 0 ){
819 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
821 info->manifest_info->uiapplication->package = NULL;
822 } else if (strcmp(colname[i], "app_icon") == 0) {
824 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
826 info->manifest_info->uiapplication->icon->text = NULL;
827 } else if (strcmp(colname[i], "app_label") == 0 ) {
829 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
831 info->manifest_info->uiapplication->label->text = NULL;
832 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
834 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
836 info->manifest_info->uiapplication->recentimage = NULL;
837 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
839 info->manifest_info->uiapplication->mainapp= strdup(coltxt[i]);
841 info->manifest_info->uiapplication->mainapp = NULL;
842 } else if (strcmp(colname[i], "app_locale") == 0 ) {
844 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
845 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
848 info->manifest_info->uiapplication->icon->lang = NULL;
849 info->manifest_info->uiapplication->label->lang = NULL;
851 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
853 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
855 info->manifest_info->uiapplication->permission_type = NULL;
860 svcapp = calloc(1, sizeof(serviceapplication_x));
861 if (svcapp == NULL) {
862 _LOGE("Out of Memory!!!\n");
865 LISTADD(info->manifest_info->serviceapplication, svcapp);
866 for(i = 0; i < ncols; i++)
868 if (strcmp(colname[i], "app_id") == 0) {
870 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
872 info->manifest_info->serviceapplication->appid = NULL;
873 } else if (strcmp(colname[i], "app_exec") == 0) {
875 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
877 info->manifest_info->serviceapplication->exec = NULL;
878 } else if (strcmp(colname[i], "app_type") == 0 ){
880 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
882 info->manifest_info->serviceapplication->type = NULL;
883 } else if (strcmp(colname[i], "app_onboot") == 0 ){
885 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
887 info->manifest_info->serviceapplication->onboot = NULL;
888 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
890 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
892 info->manifest_info->serviceapplication->autorestart = NULL;
893 } else if (strcmp(colname[i], "package") == 0 ){
895 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
897 info->manifest_info->serviceapplication->package = NULL;
898 } else if (strcmp(colname[i], "app_icon") == 0) {
900 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
902 info->manifest_info->serviceapplication->icon->text = NULL;
903 } else if (strcmp(colname[i], "app_label") == 0 ) {
905 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
907 info->manifest_info->serviceapplication->label->text = NULL;
908 } else if (strcmp(colname[i], "app_locale") == 0 ) {
910 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
911 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
914 info->manifest_info->serviceapplication->icon->lang = NULL;
915 info->manifest_info->serviceapplication->label->lang = NULL;
917 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
919 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
921 info->manifest_info->serviceapplication->permission_type = NULL;
936 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname)
939 *p = atoi(coltxt[0]);
943 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname)
947 *p = atoi(coltxt[0]);
951 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
953 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
955 author_x *author = NULL;
957 label_x *label = NULL;
958 description_x *description = NULL;
959 privilege_x *privilege = NULL;
961 author = calloc(1, sizeof(author_x));
962 LISTADD(info->manifest_info->author, author);
963 icon = calloc(1, sizeof(icon_x));
964 LISTADD(info->manifest_info->icon, icon);
965 label = calloc(1, sizeof(label_x));
966 LISTADD(info->manifest_info->label, label);
967 description = calloc(1, sizeof(description_x));
968 LISTADD(info->manifest_info->description, description);
969 privilege = calloc(1, sizeof(privilege_x));
970 LISTADD(info->manifest_info->privileges->privilege, privilege);
971 for(i = 0; i < ncols; i++)
973 if (strcmp(colname[i], "package_version") == 0) {
975 info->manifest_info->version = strdup(coltxt[i]);
977 info->manifest_info->version = NULL;
978 } else if (strcmp(colname[i], "package_type") == 0) {
980 info->manifest_info->type = strdup(coltxt[i]);
982 info->manifest_info->type = NULL;
983 } else if (strcmp(colname[i], "install_location") == 0) {
985 info->manifest_info->installlocation = strdup(coltxt[i]);
987 info->manifest_info->installlocation = NULL;
988 } else if (strcmp(colname[i], "package_size") == 0) {
990 info->manifest_info->package_size = strdup(coltxt[i]);
992 info->manifest_info->package_size = NULL;
993 } else if (strcmp(colname[i], "author_email") == 0 ){
995 info->manifest_info->author->email = strdup(coltxt[i]);
997 info->manifest_info->author->email = NULL;
998 } else if (strcmp(colname[i], "author_href") == 0 ){
1000 info->manifest_info->author->href = strdup(coltxt[i]);
1002 info->manifest_info->author->href = NULL;
1003 } else if (strcmp(colname[i], "package_label") == 0 ){
1005 info->manifest_info->label->text = strdup(coltxt[i]);
1007 info->manifest_info->label->text = NULL;
1008 } else if (strcmp(colname[i], "package_icon") == 0 ){
1010 info->manifest_info->icon->text = strdup(coltxt[i]);
1012 info->manifest_info->icon->text = NULL;
1013 } else if (strcmp(colname[i], "package_description") == 0 ){
1015 info->manifest_info->description->text = strdup(coltxt[i]);
1017 info->manifest_info->description->text = NULL;
1018 } else if (strcmp(colname[i], "package_author") == 0 ){
1020 info->manifest_info->author->text = strdup(coltxt[i]);
1022 info->manifest_info->author->text = NULL;
1023 } else if (strcmp(colname[i], "package_removable") == 0 ){
1025 info->manifest_info->removable = strdup(coltxt[i]);
1027 info->manifest_info->removable = NULL;
1028 } else if (strcmp(colname[i], "package_preload") == 0 ){
1030 info->manifest_info->preload = strdup(coltxt[i]);
1032 info->manifest_info->preload = NULL;
1033 } else if (strcmp(colname[i], "package_readonly") == 0 ){
1035 info->manifest_info->readonly = strdup(coltxt[i]);
1037 info->manifest_info->readonly = NULL;
1038 } else if (strcmp(colname[i], "package_update") == 0 ){
1040 info->manifest_info->update= strdup(coltxt[i]);
1042 info->manifest_info->update = NULL;
1043 } else if (strcmp(colname[i], "package_appsetting") == 0 ){
1045 info->manifest_info->appsetting = strdup(coltxt[i]);
1047 info->manifest_info->appsetting = NULL;
1048 } else if (strcmp(colname[i], "installed_time") == 0 ){
1050 info->manifest_info->installed_time = strdup(coltxt[i]);
1052 info->manifest_info->installed_time = NULL;
1053 } else if (strcmp(colname[i], "mainapp_id") == 0 ){
1055 info->manifest_info->mainapp_id = strdup(coltxt[i]);
1057 info->manifest_info->mainapp_id = NULL;
1058 } else if (strcmp(colname[i], "root_path") == 0 ){
1060 info->manifest_info->root_path = strdup(coltxt[i]);
1062 info->manifest_info->root_path = NULL;
1063 } else if (strcmp(colname[i], "csc_path") == 0 ){
1065 info->manifest_info->csc_path = strdup(coltxt[i]);
1067 info->manifest_info->csc_path = NULL;
1068 } else if (strcmp(colname[i], "privilege") == 0 ){
1070 info->manifest_info->privileges->privilege->text = strdup(coltxt[i]);
1072 info->manifest_info->privileges->privilege->text = NULL;
1073 } else if (strcmp(colname[i], "package_locale") == 0 ){
1075 info->manifest_info->author->lang = strdup(coltxt[i]);
1076 info->manifest_info->icon->lang = strdup(coltxt[i]);
1077 info->manifest_info->label->lang = strdup(coltxt[i]);
1078 info->manifest_info->description->lang = strdup(coltxt[i]);
1081 info->manifest_info->author->lang = NULL;
1082 info->manifest_info->icon->lang = NULL;
1083 info->manifest_info->label->lang = NULL;
1084 info->manifest_info->description->lang = NULL;
1086 } else if (strcmp(colname[i], "package_url") == 0 ){
1088 info->manifest_info->package_url = strdup(coltxt[i]);
1090 info->manifest_info->package_url = NULL;
1098 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1100 if ( strcasecmp(comp, "uiapp") == 0)
1101 return PMINFO_UI_APP;
1102 else if ( strcasecmp(comp, "svcapp") == 0)
1103 return PMINFO_SVC_APP;
1108 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1110 pkgmgr_certindexinfo_x *info = (pkgmgr_certindexinfo_x *)data;
1112 for(i = 0; i < ncols; i++) {
1113 if (strcmp(colname[i], "cert_id") == 0) {
1115 info->cert_id = atoi(coltxt[i]);
1118 } else if (strcmp(colname[i], "cert_ref_count") == 0) {
1120 info->cert_ref_count = atoi(coltxt[i]);
1122 info->cert_ref_count = 0;
1128 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1130 pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)data;
1132 for(i = 0; i < ncols; i++)
1134 if (strcmp(colname[i], "package") == 0) {
1136 info->pkgid = strdup(coltxt[i]);
1139 } else if (strcmp(colname[i], "author_signer_cert") == 0) {
1141 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = atoi(coltxt[i]);
1143 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = 0;
1144 } else if (strcmp(colname[i], "author_im_cert") == 0) {
1146 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1148 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 0;
1149 } else if (strcmp(colname[i], "author_root_cert") == 0) {
1151 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = atoi(coltxt[i]);
1153 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = 0;
1154 } else if (strcmp(colname[i], "dist_signer_cert") == 0 ){
1156 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = atoi(coltxt[i]);
1158 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 0;
1159 } else if (strcmp(colname[i], "dist_im_cert") == 0 ){
1161 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1163 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 0;
1164 } else if (strcmp(colname[i], "dist_root_cert") == 0 ){
1166 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = atoi(coltxt[i]);
1168 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = 0;
1169 } else if (strcmp(colname[i], "dist2_signer_cert") == 0 ){
1171 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = atoi(coltxt[i]);
1173 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 0;
1174 } else if (strcmp(colname[i], "dist2_im_cert") == 0 ){
1176 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1178 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 0;
1179 } else if (strcmp(colname[i], "dist2_root_cert") == 0 ){
1181 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = atoi(coltxt[i]);
1183 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 0;
1184 } else if (strcmp(colname[i], "cert_info") == 0 ){
1186 info->cert_value = strdup(coltxt[i]);
1188 info->cert_value = NULL;
1195 static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1197 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1199 uiapplication_x *uiapp = NULL;
1200 uiapp = calloc(1, sizeof(uiapplication_x));
1201 if (uiapp == NULL) {
1202 _LOGE("Out of Memory!!!\n");
1206 LISTADD(info->uiapp_info, uiapp);
1208 for(i = 0; i < ncols; i++)
1210 if (strcmp(colname[i], "app_id") == 0) {
1211 /*appid being foreign key, is column in every table
1212 Hence appid gets strduped every time leading to memory leak.
1213 If appid is already set, just continue.*/
1214 if (info->uiapp_info->appid)
1217 info->uiapp_info->appid = strdup(coltxt[i]);
1219 info->uiapp_info->appid = NULL;
1220 } else if (strcmp(colname[i], "app_exec") == 0) {
1222 info->uiapp_info->exec = strdup(coltxt[i]);
1224 info->uiapp_info->exec = NULL;
1225 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1227 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1229 info->uiapp_info->nodisplay = NULL;
1230 } else if (strcmp(colname[i], "app_type") == 0 ) {
1232 info->uiapp_info->type = strdup(coltxt[i]);
1234 info->uiapp_info->type = NULL;
1235 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1237 info->uiapp_info->multiple = strdup(coltxt[i]);
1239 info->uiapp_info->multiple = NULL;
1240 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1242 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1244 info->uiapp_info->taskmanage = NULL;
1245 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1247 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1249 info->uiapp_info->hwacceleration = NULL;
1250 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1252 info->uiapp_info->enabled= strdup(coltxt[i]);
1254 info->uiapp_info->enabled = NULL;
1255 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1257 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1259 info->uiapp_info->indicatordisplay = NULL;
1260 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1262 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1264 info->uiapp_info->portraitimg = NULL;
1265 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1267 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1269 info->uiapp_info->landscapeimg = NULL;
1270 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1272 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1274 info->uiapp_info->guestmode_visibility = NULL;
1275 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1277 info->uiapp_info->recentimage = strdup(coltxt[i]);
1279 info->uiapp_info->recentimage = NULL;
1280 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1282 info->uiapp_info->mainapp = strdup(coltxt[i]);
1284 info->uiapp_info->mainapp = NULL;
1285 } else if (strcmp(colname[i], "package") == 0 ) {
1287 info->uiapp_info->package = strdup(coltxt[i]);
1289 info->uiapp_info->package = NULL;
1290 } else if (strcmp(colname[i], "app_component") == 0) {
1292 info->uiapp_info->app_component = strdup(coltxt[i]);
1294 info->uiapp_info->app_component = NULL;
1295 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1297 info->uiapp_info->permission_type = strdup(coltxt[i]);
1299 info->uiapp_info->permission_type = NULL;
1307 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1309 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1311 icon_x *icon = NULL;
1312 label_x *label = NULL;
1313 category_x *category = NULL;
1314 metadata_x *metadata = NULL;
1315 permission_x *permission = NULL;
1316 image_x *image = NULL;
1318 switch (info->app_component) {
1320 icon = calloc(1, sizeof(icon_x));
1321 LISTADD(info->uiapp_info->icon, icon);
1322 label = calloc(1, sizeof(label_x));
1323 LISTADD(info->uiapp_info->label, label);
1324 category = calloc(1, sizeof(category_x));
1325 LISTADD(info->uiapp_info->category, category);
1326 metadata = calloc(1, sizeof(metadata_x));
1327 LISTADD(info->uiapp_info->metadata, metadata);
1328 permission = calloc(1, sizeof(permission_x));
1329 LISTADD(info->uiapp_info->permission, permission);
1330 image = calloc(1, sizeof(image_x));
1331 LISTADD(info->uiapp_info->image, image);
1333 for(i = 0; i < ncols; i++)
1335 if (strcmp(colname[i], "app_id") == 0) {
1336 /*appid being foreign key, is column in every table
1337 Hence appid gets strduped every time leading to memory leak.
1338 If appid is already set, just continue.*/
1339 if (info->uiapp_info->appid)
1342 info->uiapp_info->appid = strdup(coltxt[i]);
1344 info->uiapp_info->appid = NULL;
1345 } else if (strcmp(colname[i], "app_exec") == 0) {
1347 info->uiapp_info->exec = strdup(coltxt[i]);
1349 info->uiapp_info->exec = NULL;
1350 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1352 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1354 info->uiapp_info->nodisplay = NULL;
1355 } else if (strcmp(colname[i], "app_type") == 0 ) {
1357 info->uiapp_info->type = strdup(coltxt[i]);
1359 info->uiapp_info->type = NULL;
1360 } else if (strcmp(colname[i], "app_icon_section") == 0 ) {
1362 info->uiapp_info->icon->section= strdup(coltxt[i]);
1364 info->uiapp_info->icon->section = NULL;
1365 } else if (strcmp(colname[i], "app_icon") == 0) {
1367 info->uiapp_info->icon->text = strdup(coltxt[i]);
1369 info->uiapp_info->icon->text = NULL;
1370 } else if (strcmp(colname[i], "app_label") == 0 ) {
1372 info->uiapp_info->label->text = strdup(coltxt[i]);
1374 info->uiapp_info->label->text = NULL;
1375 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1377 info->uiapp_info->multiple = strdup(coltxt[i]);
1379 info->uiapp_info->multiple = NULL;
1380 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1382 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1384 info->uiapp_info->taskmanage = NULL;
1385 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1387 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1389 info->uiapp_info->hwacceleration = NULL;
1390 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1392 info->uiapp_info->enabled= strdup(coltxt[i]);
1394 info->uiapp_info->enabled = NULL;
1395 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1397 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1399 info->uiapp_info->indicatordisplay = NULL;
1400 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1402 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1404 info->uiapp_info->portraitimg = NULL;
1405 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1407 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1409 info->uiapp_info->landscapeimg = NULL;
1410 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1412 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1414 info->uiapp_info->guestmode_visibility = NULL;
1415 } else if (strcmp(colname[i], "category") == 0 ) {
1417 info->uiapp_info->category->name = strdup(coltxt[i]);
1419 info->uiapp_info->category->name = NULL;
1420 } else if (strcmp(colname[i], "md_key") == 0 ) {
1422 info->uiapp_info->metadata->key = strdup(coltxt[i]);
1424 info->uiapp_info->metadata->key = NULL;
1425 } else if (strcmp(colname[i], "md_value") == 0 ) {
1427 info->uiapp_info->metadata->value = strdup(coltxt[i]);
1429 info->uiapp_info->metadata->value = NULL;
1430 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1432 info->uiapp_info->permission->type= strdup(coltxt[i]);
1434 info->uiapp_info->permission->type = NULL;
1435 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1437 info->uiapp_info->permission->value = strdup(coltxt[i]);
1439 info->uiapp_info->permission->value = NULL;
1440 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1442 info->uiapp_info->recentimage = strdup(coltxt[i]);
1444 info->uiapp_info->recentimage = NULL;
1445 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1447 info->uiapp_info->mainapp = strdup(coltxt[i]);
1449 info->uiapp_info->mainapp = NULL;
1450 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1452 info->uiapp_info->icon->lang = strdup(coltxt[i]);
1453 info->uiapp_info->label->lang = strdup(coltxt[i]);
1456 info->uiapp_info->icon->lang = NULL;
1457 info->uiapp_info->label->lang = NULL;
1459 } else if (strcmp(colname[i], "app_image") == 0) {
1461 info->uiapp_info->image->text= strdup(coltxt[i]);
1463 info->uiapp_info->image->text = NULL;
1464 } else if (strcmp(colname[i], "app_image_section") == 0) {
1466 info->uiapp_info->image->section= strdup(coltxt[i]);
1468 info->uiapp_info->image->section = NULL;
1469 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1471 info->uiapp_info->permission_type = strdup(coltxt[i]);
1473 info->uiapp_info->permission_type = NULL;
1478 case PMINFO_SVC_APP:
1479 icon = calloc(1, sizeof(icon_x));
1480 LISTADD(info->svcapp_info->icon, icon);
1481 label = calloc(1, sizeof(label_x));
1482 LISTADD(info->svcapp_info->label, label);
1483 category = calloc(1, sizeof(category_x));
1484 LISTADD(info->svcapp_info->category, category);
1485 metadata = calloc(1, sizeof(metadata_x));
1486 LISTADD(info->svcapp_info->metadata, metadata);
1487 permission = calloc(1, sizeof(permission_x));
1488 LISTADD(info->svcapp_info->permission, permission);
1489 for(i = 0; i < ncols; i++)
1491 if (strcmp(colname[i], "app_id") == 0) {
1492 /*appid being foreign key, is column in every table
1493 Hence appid gets strduped every time leading to memory leak.
1494 If appid is already set, just continue.*/
1495 if (info->svcapp_info->appid)
1498 info->svcapp_info->appid = strdup(coltxt[i]);
1500 info->svcapp_info->appid = NULL;
1501 } else if (strcmp(colname[i], "app_exec") == 0) {
1503 info->svcapp_info->exec = strdup(coltxt[i]);
1505 info->svcapp_info->exec = NULL;
1506 } else if (strcmp(colname[i], "app_icon") == 0) {
1508 info->svcapp_info->icon->text = strdup(coltxt[i]);
1510 info->svcapp_info->icon->text = NULL;
1511 } else if (strcmp(colname[i], "app_label") == 0 ) {
1513 info->svcapp_info->label->text = strdup(coltxt[i]);
1515 info->svcapp_info->label->text = NULL;
1516 } else if (strcmp(colname[i], "app_type") == 0 ) {
1518 info->svcapp_info->type = strdup(coltxt[i]);
1520 info->svcapp_info->type = NULL;
1521 } else if (strcmp(colname[i], "app_onboot") == 0 ) {
1523 info->svcapp_info->onboot = strdup(coltxt[i]);
1525 info->svcapp_info->onboot = NULL;
1526 } else if (strcmp(colname[i], "app_autorestart") == 0 ) {
1528 info->svcapp_info->autorestart = strdup(coltxt[i]);
1530 info->svcapp_info->autorestart = NULL;
1531 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1533 info->svcapp_info->enabled= strdup(coltxt[i]);
1535 info->svcapp_info->enabled = NULL;
1536 } else if (strcmp(colname[i], "category") == 0 ) {
1538 info->svcapp_info->category->name = strdup(coltxt[i]);
1540 info->svcapp_info->category->name = NULL;
1541 } else if (strcmp(colname[i], "md_key") == 0 ) {
1543 info->svcapp_info->metadata->key = strdup(coltxt[i]);
1545 info->svcapp_info->metadata->key = NULL;
1546 } else if (strcmp(colname[i], "md_value") == 0 ) {
1548 info->svcapp_info->metadata->value = strdup(coltxt[i]);
1550 info->svcapp_info->metadata->value = NULL;
1551 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1553 info->svcapp_info->permission->type= strdup(coltxt[i]);
1555 info->svcapp_info->permission->type = NULL;
1556 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1558 info->svcapp_info->permission->value = strdup(coltxt[i]);
1560 info->svcapp_info->permission->value = NULL;
1561 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1563 info->svcapp_info->icon->lang = strdup(coltxt[i]);
1564 info->svcapp_info->label->lang = strdup(coltxt[i]);
1567 info->svcapp_info->icon->lang = NULL;
1568 info->svcapp_info->label->lang = NULL;
1570 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1572 info->svcapp_info->permission_type = strdup(coltxt[i]);
1574 info->svcapp_info->permission_type = NULL;
1587 static int __appcomponent_cb(void *data, int ncols, char **coltxt, char **colname)
1589 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1591 for(i = 0; i < ncols; i++)
1593 if (strcmp(colname[i], "app_component") == 0) {
1594 info->app_component = __appcomponent_convert(coltxt[i]);
1595 } else if (strcmp(colname[i], "package") == 0) {
1596 info->package = strdup(coltxt[i]);
1603 static int __datacontrol_cb(void *data, int ncols, char **coltxt, char **colname)
1605 pkgmgr_datacontrol_x *info = (pkgmgr_datacontrol_x *)data;
1607 for(i = 0; i < ncols; i++)
1609 if (strcmp(colname[i], "PACKAGE_NAME") == 0) {
1611 info->appid = strdup(coltxt[i]);
1614 } else if (strcmp(colname[i], "ACCESS") == 0 ){
1616 info->access = strdup(coltxt[i]);
1618 info->access = NULL;
1625 static int __cert_cb(void *data, int ncols, char **coltxt, char **colname)
1627 pkgmgr_cert_x *info = (pkgmgr_cert_x *)data;
1630 for(i = 0; i < ncols; i++)
1632 if (strcmp(colname[i], "author_signer_cert") == 0) {
1634 info->cert_id = atoi(coltxt[i]);
1637 } else if (strcmp(colname[i], "package") == 0) {
1639 info->pkgid= strdup(coltxt[i]);
1648 /* get the first locale value*/
1649 static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
1651 pkgmgr_locale_x *info = (pkgmgr_locale_x *)data;
1654 info->locale = strdup(coltxt[0]);
1656 info->locale = NULL;
1661 static int __exec_pkginfo_query(char *query, void *data)
1663 char *error_message = NULL;
1665 sqlite3_exec(manifest_db, query, __pkginfo_cb, data, &error_message)) {
1666 _LOGE("Don't execute query = %s error message = %s\n", query,
1668 sqlite3_free(error_message);
1671 sqlite3_free(error_message);
1675 static int __exec_certinfo_query(char *query, void *data)
1677 char *error_message = NULL;
1679 sqlite3_exec(cert_db, query, __certinfo_cb, data, &error_message)) {
1680 _LOGE("Don't execute query = %s error message = %s\n", query,
1682 sqlite3_free(error_message);
1685 sqlite3_free(error_message);
1689 static int __exec_certindexinfo_query(char *query, void *data)
1691 char *error_message = NULL;
1693 sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
1694 _LOGE("Don't execute query = %s error message = %s\n", query,
1696 sqlite3_free(error_message);
1699 sqlite3_free(error_message);
1703 static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data)
1705 char *error_message = NULL;
1707 sqlite3_exec(db, query, callback, data, &error_message)) {
1708 _LOGE("Don't execute query = %s error message = %s\n", query,
1710 sqlite3_free(error_message);
1713 sqlite3_free(error_message);
1718 static int __child_element(xmlTextReaderPtr reader, int depth)
1720 int ret = xmlTextReaderRead(reader);
1721 int cur = xmlTextReaderDepth(reader);
1724 switch (xmlTextReaderNodeType(reader)) {
1725 case XML_READER_TYPE_ELEMENT:
1726 if (cur == depth + 1)
1729 case XML_READER_TYPE_TEXT:
1730 /*text is handled by each function separately*/
1731 if (cur == depth + 1)
1734 case XML_READER_TYPE_END_ELEMENT:
1743 ret = xmlTextReaderRead(reader);
1744 cur = xmlTextReaderDepth(reader);
1749 static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, char **colname)
1751 int *p = (int*)data;
1752 *p = atoi(coltxt[0]);
1756 static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale)
1758 int result_query = -1;
1760 char query[MAX_QUERY_LEN];
1762 snprintf(query, MAX_QUERY_LEN, "select exists(select app_locale from package_app_localized_info where app_id='%s' and app_locale='%s')", appid, locale);
1763 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1764 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1765 return result_query;
1768 static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1770 int result_query = -1;
1772 char wildcard[2] = {'%','\0'};
1773 char query[MAX_QUERY_LEN];
1774 char lang[3] = {'\0'};
1775 strncpy(lang, locale, LANGUAGE_LENGTH);
1777 snprintf(query, MAX_QUERY_LEN, "select exists(select app_locale from package_app_localized_info where app_id='%s' and app_locale like '%s%s')", appid, lang, wildcard);
1778 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1779 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1780 return result_query;
1783 static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1786 char wildcard[2] = {'%','\0'};
1787 char lang[3] = {'\0'};
1788 char query[MAX_QUERY_LEN];
1789 char *locale_new = NULL;
1790 pkgmgr_locale_x *info = NULL;
1792 info = (pkgmgr_locale_x *)malloc(sizeof(pkgmgr_locale_x));
1794 _LOGE("Out of Memory!!!\n");
1797 memset(info, '\0', sizeof(*info));
1799 strncpy(lang, locale, 2);
1800 snprintf(query, MAX_QUERY_LEN, "select app_locale from package_app_localized_info where app_id='%s' and app_locale like '%s%s'", appid, lang, wildcard);
1801 ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
1802 tryvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1803 locale_new = info->locale;
1814 static char* __convert_syslocale_to_manifest_locale(char *syslocale)
1816 char *locale = malloc(6);
1818 _LOGE("Malloc Failed\n");
1822 sprintf(locale, "%c%c-%c%c", syslocale[0], syslocale[1], tolower(syslocale[3]), tolower(syslocale[4]));
1826 static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const char *syslocale)
1831 char *locale = NULL;
1832 char *locale_new = NULL;
1833 int check_result = 0;
1835 locale = __convert_syslocale_to_manifest_locale((char *)syslocale);
1837 /*check exact matching */
1838 check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale);
1841 if (check_result == 1) {
1842 _LOGD("%s find exact locale(%s)\n", appid, locale);
1846 /* fallback matching */
1847 check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
1848 if(check_result == 1) {
1849 locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
1850 _LOGD("%s found (%s) language-locale in DB by fallback!\n", appid, locale_new);
1852 if (locale_new == NULL)
1853 locale_new = strdup(DEFAULT_LOCALE);
1857 /* default locale */
1859 _LOGD("%s DEFAULT_LOCALE)\n", appid);
1860 return strdup(DEFAULT_LOCALE);
1863 long long _pkgmgr_calculate_dir_size(char *dirname)
1865 long long total = 0;
1867 int q = 0; /*quotient*/
1868 int r = 0; /*remainder*/
1870 struct dirent *ep = NULL;
1871 struct stat fileinfo;
1872 char abs_filename[FILENAME_MAX] = { 0, };
1873 retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL");
1875 dp = opendir(dirname);
1877 while ((ep = readdir(dp)) != NULL) {
1878 if (!strcmp(ep->d_name, ".") ||
1879 !strcmp(ep->d_name, "..")) {
1882 snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
1884 if (lstat(abs_filename, &fileinfo) < 0)
1885 perror(abs_filename);
1887 if (S_ISDIR(fileinfo.st_mode)) {
1888 total += fileinfo.st_size;
1889 if (strcmp(ep->d_name, ".")
1890 && strcmp(ep->d_name, "..")) {
1891 ret = _pkgmgr_calculate_dir_size
1893 total = total + ret;
1895 } else if (S_ISLNK(fileinfo.st_mode)) {
1898 /*It is a file. Calculate the actual
1899 size occupied (in terms of 4096 blocks)*/
1900 q = (fileinfo.st_size / BLOCK_SIZE);
1901 r = (fileinfo.st_size % BLOCK_SIZE);
1905 total += q * BLOCK_SIZE;
1911 _LOGE("Couldn't open the directory\n");
1918 static int __delete_certinfo(const char *pkgid)
1924 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
1925 char *error_message = NULL;
1926 char query[MAX_QUERY_LEN] = {'\0'};
1927 pkgmgr_certinfo_x *certinfo = NULL;
1928 pkgmgr_certindexinfo_x *indexinfo = NULL;
1929 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
1930 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
1931 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
1932 if (indexinfo == NULL) {
1933 _LOGE("Out of Memory!!!");
1934 ret = PMINFO_R_ERROR;
1937 /*populate certinfo from DB*/
1938 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
1939 ret = __exec_certinfo_query(query, (void *)certinfo);
1941 _LOGE("Package Cert Info DB Information retrieval failed\n");
1942 ret = PMINFO_R_ERROR;
1945 /*Update cert index table*/
1946 for (i = 0; i < MAX_CERT_TYPE; i++) {
1947 if ((certinfo->cert_id)[i]) {
1948 for (j = 0; j < MAX_CERT_TYPE; j++) {
1949 if ((certinfo->cert_id)[i] == unique_id[j]) {
1950 /*Ref count has already been updated. Just continue*/
1954 if (j == MAX_CERT_TYPE)
1955 unique_id[c++] = (certinfo->cert_id)[i];
1958 memset(query, '\0', MAX_QUERY_LEN);
1959 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
1960 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
1962 _LOGE("Cert Info DB Information retrieval failed\n");
1963 ret = PMINFO_R_ERROR;
1966 memset(query, '\0', MAX_QUERY_LEN);
1967 if (indexinfo->cert_ref_count > 1) {
1968 /*decrease ref count*/
1969 snprintf(query, MAX_QUERY_LEN, "update package_cert_index_info set cert_ref_count=%d where cert_id=%d ",
1970 indexinfo->cert_ref_count - 1, (certinfo->cert_id)[i]);
1972 /*delete this certificate as ref count is 1 and it will become 0*/
1973 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
1976 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
1977 _LOGE("Don't execute query = %s error message = %s\n", query,
1979 sqlite3_free(error_message);
1980 ret = PMINFO_R_ERROR;
1985 /*Now delete the entry from db*/
1986 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
1988 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
1989 _LOGE("Don't execute query = %s error message = %s\n", query,
1991 sqlite3_free(error_message);
1992 ret = PMINFO_R_ERROR;
2001 if (certinfo->pkgid) {
2002 free(certinfo->pkgid);
2003 certinfo->pkgid = NULL;
2005 for (i = 0; i < MAX_CERT_TYPE; i++) {
2006 if ((certinfo->cert_info)[i]) {
2007 free((certinfo->cert_info)[i]);
2008 (certinfo->cert_info)[i] = NULL;
2016 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
2018 retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
2019 char *error_message = NULL;
2020 int ret = PMINFO_R_OK;
2021 char query[MAX_QUERY_LEN] = {'\0'};
2022 char *syslocale = NULL;
2023 char *locale = NULL;
2024 pkgmgr_pkginfo_x *pkginfo = NULL;
2025 label_x *tmp1 = NULL;
2026 icon_x *tmp2 = NULL;
2027 description_x *tmp3 = NULL;
2028 author_x *tmp4 = NULL;
2029 privilege_x *tmp5 = NULL;
2031 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2032 if (syslocale == NULL) {
2033 _LOGE("current locale is NULL\n");
2034 ret = PMINFO_R_ERROR;
2037 locale = __convert_system_locale_to_manifest_locale(syslocale);
2038 if (locale == NULL) {
2039 _LOGE("manifest locale is NULL\n");
2040 ret = PMINFO_R_EINVAL;
2044 ret = __open_manifest_db();
2046 _LOGE("Fail to open manifest DB\n");
2047 ret = PMINFO_R_ERROR;
2050 pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2051 pkgmgr_pkginfo_x *node = NULL;
2052 pkgmgr_pkginfo_x *temp_node = NULL;
2054 snprintf(query, MAX_QUERY_LEN, "select * from package_info");
2056 sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
2057 _LOGE("Don't execute query = %s error message = %s\n", query,
2059 sqlite3_free(error_message);
2060 sqlite3_close(manifest_db);
2061 ret = PMINFO_R_ERROR;
2065 LISTHEAD(tmphead, node);
2067 for(node = node->next; node ; node = node->next) {
2069 pkginfo->locale = strdup(locale);
2070 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2071 if (pkginfo->manifest_info->privileges == NULL) {
2072 _LOGE("Failed to allocate memory for privileges info\n");
2073 ret = PMINFO_R_ERROR;
2076 /*populate manifest_info from DB*/
2077 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
2078 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2080 _LOGE("Package Info DB Information retrieval failed\n");
2081 ret = PMINFO_R_ERROR;
2084 memset(query, '\0', MAX_QUERY_LEN);
2085 /*populate privilege_info from DB*/
2086 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package);
2087 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2089 _LOGE("Package Privilege Info DB Information retrieval failed\n");
2090 ret = PMINFO_R_ERROR;
2093 memset(query, '\0', MAX_QUERY_LEN);
2094 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2095 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
2096 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2098 _LOGE("Package Info DB Information retrieval failed\n");
2099 ret = PMINFO_R_ERROR;
2102 /*Also store the values corresponding to default locales*/
2103 memset(query, '\0', MAX_QUERY_LEN);
2104 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2105 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
2106 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2108 _LOGE("Package Info DB Information retrieval failed\n");
2109 ret = PMINFO_R_ERROR;
2112 if (pkginfo->manifest_info->label) {
2113 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2114 pkginfo->manifest_info->label = tmp1;
2116 if (pkginfo->manifest_info->icon) {
2117 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2118 pkginfo->manifest_info->icon = tmp2;
2120 if (pkginfo->manifest_info->description) {
2121 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2122 pkginfo->manifest_info->description = tmp3;
2124 if (pkginfo->manifest_info->author) {
2125 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2126 pkginfo->manifest_info->author = tmp4;
2128 if (pkginfo->manifest_info->privileges->privilege) {
2129 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2130 pkginfo->manifest_info->privileges->privilege = tmp5;
2134 LISTHEAD(tmphead, node);
2136 for(node = node->next; node ; node = node->next) {
2138 ret = pkg_list_cb( (void *)pkginfo, user_data);
2146 sqlite3_close(manifest_db);
2155 LISTHEAD(tmphead, node);
2156 temp_node = node->next;
2159 temp_node = node->next;
2160 __cleanup_pkginfo(node);
2163 __cleanup_pkginfo(tmphead);
2168 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
2170 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
2171 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2172 pkgmgr_pkginfo_x *pkginfo = NULL;
2173 int ret = PMINFO_R_OK;
2174 char query[MAX_QUERY_LEN] = {'\0'};
2175 char *syslocale = NULL;
2176 char *locale = NULL;
2178 label_x *tmp1 = NULL;
2179 icon_x *tmp2 = NULL;
2180 description_x *tmp3 = NULL;
2181 author_x *tmp4 = NULL;
2182 privilege_x *tmp5 = NULL;
2183 sqlite3 *pkginfo_db = NULL;
2186 ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
2187 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2189 /*check pkgid exist on db*/
2190 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
2191 ret = __exec_db_query(pkginfo_db, query, __validate_cb, (void *)&exist);
2192 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
2193 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] not found in DB", pkgid);
2195 /*get system locale*/
2196 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2197 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
2199 /*get locale on db*/
2200 locale = __convert_system_locale_to_manifest_locale(syslocale);
2201 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
2203 pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2204 tryvm_if(pkginfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for pkginfo");
2206 pkginfo->locale = strdup(locale);
2208 pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
2209 tryvm_if(pkginfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for manifest info");
2211 pkginfo->manifest_info->package = strdup(pkgid);
2212 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2213 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info");
2215 /*populate manifest_info from DB*/
2216 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
2217 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2218 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2220 memset(query, '\0', MAX_QUERY_LEN);
2221 /*populate privilege_info from DB*/
2222 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
2223 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2224 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
2226 memset(query, '\0', MAX_QUERY_LEN);
2227 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2228 " package='%s' and package_locale='%s'", pkgid, locale);
2229 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2230 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2232 /*Also store the values corresponding to default locales*/
2233 memset(query, '\0', MAX_QUERY_LEN);
2234 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2235 " package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
2236 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2237 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2239 if (pkginfo->manifest_info->label) {
2240 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2241 pkginfo->manifest_info->label = tmp1;
2243 if (pkginfo->manifest_info->icon) {
2244 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2245 pkginfo->manifest_info->icon = tmp2;
2247 if (pkginfo->manifest_info->description) {
2248 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2249 pkginfo->manifest_info->description = tmp3;
2251 if (pkginfo->manifest_info->author) {
2252 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2253 pkginfo->manifest_info->author = tmp4;
2255 if (pkginfo->manifest_info->privileges->privilege) {
2256 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2257 pkginfo->manifest_info->privileges->privilege = tmp5;
2261 if (ret == PMINFO_R_OK)
2262 *handle = (void*)pkginfo;
2265 __cleanup_pkginfo(pkginfo);
2267 sqlite3_close(pkginfo_db);
2281 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
2283 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2284 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2285 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2286 if (info->manifest_info->package)
2287 *pkg_name = (char *)info->manifest_info->package;
2289 return PMINFO_R_ERROR;
2294 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
2296 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2297 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2298 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2299 if (info->manifest_info->package)
2300 *pkgid = (char *)info->manifest_info->package;
2302 return PMINFO_R_ERROR;
2307 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
2309 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2310 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2311 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2312 if (info->manifest_info->type)
2313 *type = (char *)info->manifest_info->type;
2319 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
2321 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2322 retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2323 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2324 *version = (char *)info->manifest_info->version;
2328 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
2330 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2331 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2333 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2334 val = (char *)info->manifest_info->installlocation;
2336 if (strcmp(val, "internal-only") == 0)
2337 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2338 else if (strcmp(val, "prefer-external") == 0)
2339 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2341 *location = PMINFO_INSTALL_LOCATION_AUTO;
2346 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
2348 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2349 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2351 char *location = NULL;
2352 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2353 location = (char *)info->manifest_info->installlocation;
2354 val = (char *)info->manifest_info->package_size;
2359 _LOGE("package size is not specified\n");
2360 return PMINFO_R_ERROR;
2365 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
2367 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2368 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2371 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
2372 long long rw_size = 0;
2373 long long ro_size= 0;
2374 long long tmp_size= 0;
2375 long long total_size= 0;
2376 struct stat fileinfo;
2379 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2381 return PMINFO_R_ERROR;
2384 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid);
2385 if (lstat(device_path, &fileinfo) == 0) {
2386 if (!S_ISLNK(fileinfo.st_mode)) {
2387 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2389 rw_size += tmp_size;
2393 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid);
2394 if (lstat(device_path, &fileinfo) == 0) {
2395 if (!S_ISLNK(fileinfo.st_mode)) {
2396 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2398 rw_size += tmp_size;
2402 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid);
2403 if (lstat(device_path, &fileinfo) == 0) {
2404 if (!S_ISLNK(fileinfo.st_mode)) {
2405 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2407 rw_size += tmp_size;
2411 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
2412 if (lstat(device_path, &fileinfo) == 0) {
2413 if (!S_ISLNK(fileinfo.st_mode)) {
2414 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2416 rw_size += tmp_size;
2420 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_PATH, pkgid);
2421 if (lstat(device_path, &fileinfo) == 0) {
2422 if (!S_ISLNK(fileinfo.st_mode)) {
2423 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2425 rw_size += tmp_size;
2429 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_PATH, pkgid);
2430 if (lstat(device_path, &fileinfo) == 0) {
2431 if (!S_ISLNK(fileinfo.st_mode)) {
2432 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2434 rw_size += tmp_size;
2439 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_PATH, pkgid);
2440 if (lstat(device_path, &fileinfo) == 0) {
2441 if (!S_ISLNK(fileinfo.st_mode)) {
2442 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2444 ro_size += tmp_size;
2448 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid);
2449 if (lstat(device_path, &fileinfo) == 0) {
2450 if (!S_ISLNK(fileinfo.st_mode)) {
2451 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2453 ro_size += tmp_size;
2457 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid);
2458 if (lstat(device_path, &fileinfo) == 0) {
2459 if (!S_ISLNK(fileinfo.st_mode)) {
2460 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2462 ro_size += tmp_size;
2466 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid);
2467 if (lstat(device_path, &fileinfo) == 0) {
2468 if (!S_ISLNK(fileinfo.st_mode)) {
2469 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2471 ro_size += tmp_size;
2475 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid);
2476 if (lstat(device_path, &fileinfo) == 0) {
2477 if (!S_ISLNK(fileinfo.st_mode)) {
2478 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2480 ro_size += tmp_size;
2484 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid);
2485 if (lstat(device_path, &fileinfo) == 0) {
2486 if (!S_ISLNK(fileinfo.st_mode)) {
2487 tmp_size = _pkgmgr_calculate_dir_size(device_path);
2489 ro_size += tmp_size;
2494 total_size = rw_size + ro_size;
2495 *size = (int)total_size;
2500 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
2502 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2503 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2506 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
2507 long long total_size= 0;
2510 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
2512 return PMINFO_R_ERROR;
2514 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
2515 if (access(device_path, R_OK) == 0)
2516 total_size = _pkgmgr_calculate_dir_size(device_path);
2518 return PMINFO_R_ERROR;
2520 *size = (int)total_size;
2525 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
2527 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2528 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2529 int ret = PMINFO_R_OK;
2530 char *locale = NULL;
2534 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2536 locale = info->locale;
2537 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2539 for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next)
2542 if (strcmp(ptr->lang, locale) == 0) {
2543 *icon = (char *)ptr->text;
2544 if (strcasecmp(*icon, "(null)") == 0) {
2545 locale = DEFAULT_LOCALE;
2549 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2550 *icon = (char *)ptr->text;
2559 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
2561 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2562 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2563 int ret = PMINFO_R_OK;
2564 char *locale = NULL;
2565 label_x *ptr = NULL;
2568 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2569 locale = info->locale;
2570 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2572 for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next)
2575 if (strcmp(ptr->lang, locale) == 0) {
2576 *label = (char *)ptr->text;
2577 if (strcasecmp(*label, "(null)") == 0) {
2578 locale = DEFAULT_LOCALE;
2582 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2583 *label = (char *)ptr->text;
2592 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
2594 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2595 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2596 char *locale = NULL;
2597 description_x *ptr = NULL;
2598 *description = NULL;
2600 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2601 locale = info->locale;
2602 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2604 for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next)
2607 if (strcmp(ptr->lang, locale) == 0) {
2608 *description = (char *)ptr->text;
2609 if (strcasecmp(*description, "(null)") == 0) {
2610 locale = DEFAULT_LOCALE;
2614 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2615 *description = (char *)ptr->text;
2623 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
2625 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2626 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2627 char *locale = NULL;
2628 author_x *ptr = NULL;
2629 *author_name = NULL;
2631 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2632 locale = info->locale;
2633 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2635 for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next)
2638 if (strcmp(ptr->lang, locale) == 0) {
2639 *author_name = (char *)ptr->text;
2640 if (strcasecmp(*author_name, "(null)") == 0) {
2641 locale = DEFAULT_LOCALE;
2645 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2646 *author_name = (char *)ptr->text;
2654 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
2656 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2657 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2658 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2659 *author_email = (char *)info->manifest_info->author->email;
2663 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
2665 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2666 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2667 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2668 *author_href = (char *)info->manifest_info->author->href;
2672 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
2674 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2675 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2678 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
2680 _LOGE("invalid func parameters\n");
2681 return PMINFO_R_ERROR;
2685 char app_mmc_path[FILENAME_MAX] = { 0, };
2686 char app_dir_path[FILENAME_MAX] = { 0, };
2687 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
2688 snprintf(app_dir_path, FILENAME_MAX,
2689 "%s%s", PKG_INSTALLATION_PATH, pkgid);
2690 snprintf(app_mmc_path, FILENAME_MAX,
2691 "%s%s", PKG_SD_PATH, pkgid);
2692 snprintf(app_mmc_internal_path, FILENAME_MAX,
2693 "%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
2695 /*check whether application is in external memory or not */
2696 fp = fopen(app_mmc_path, "r");
2700 *storage = PMINFO_EXTERNAL_STORAGE;
2704 /*check whether application is in internal or not */
2705 fp = fopen(app_dir_path, "r");
2708 return PMINFO_R_ERROR;
2711 /*check whether the application is installed in SD card
2712 but SD card is not present*/
2713 fp = fopen(app_mmc_internal_path, "r");
2715 *storage = PMINFO_INTERNAL_STORAGE;
2719 *storage = PMINFO_EXTERNAL_STORAGE;
2725 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
2727 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2728 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2729 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2730 if (info->manifest_info->installed_time)
2731 *installed_time = atoi(info->manifest_info->installed_time);
2733 return PMINFO_R_ERROR;
2738 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
2740 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2741 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2742 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2743 *storeclientid = (char *)info->manifest_info->storeclient_id;
2747 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
2749 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2750 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2751 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2752 *mainappid = (char *)info->manifest_info->mainapp_id;
2756 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
2758 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2759 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2760 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2761 *url = (char *)info->manifest_info->package_url;
2765 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
2767 const char *val = NULL;
2768 const xmlChar *node;
2769 xmlTextReaderPtr reader;
2770 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2771 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2774 reader = xmlReaderForFile(manifest, NULL, 0);
2777 if (__child_element(reader, -1)) {
2778 node = xmlTextReaderConstName(reader);
2780 _LOGE("xmlTextReaderConstName value is NULL\n");
2781 xmlFreeTextReader(reader);
2783 return PMINFO_R_ERROR;
2786 if (!strcmp(ASC_CHAR(node), "manifest")) {
2787 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
2788 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
2794 _LOGE("package size is not specified\n");
2795 xmlFreeTextReader(reader);
2797 return PMINFO_R_ERROR;
2800 _LOGE("Unable to create xml reader\n");
2801 xmlFreeTextReader(reader);
2803 return PMINFO_R_ERROR;
2807 _LOGE("xmlReaderForFile value is NULL\n");
2809 return PMINFO_R_ERROR;
2812 xmlFreeTextReader(reader);
2818 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
2820 const char *val = NULL;
2821 const xmlChar *node;
2822 xmlTextReaderPtr reader;
2823 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2824 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2827 reader = xmlReaderForFile(manifest, NULL, 0);
2830 if ( __child_element(reader, -1)) {
2831 node = xmlTextReaderConstName(reader);
2833 _LOGE("xmlTextReaderConstName value is NULL\n");
2834 xmlFreeTextReader(reader);
2836 return PMINFO_R_ERROR;
2839 if (!strcmp(ASC_CHAR(node), "manifest")) {
2840 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
2841 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
2844 if (strcmp(val, "internal-only") == 0)
2845 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2846 else if (strcmp(val, "prefer-external") == 0)
2847 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2849 *location = PMINFO_INSTALL_LOCATION_AUTO;
2852 _LOGE("Unable to create xml reader\n");
2853 xmlFreeTextReader(reader);
2855 return PMINFO_R_ERROR;
2859 _LOGE("xmlReaderForFile value is NULL\n");
2861 return PMINFO_R_ERROR;
2864 xmlFreeTextReader(reader);
2871 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
2873 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2874 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2876 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2877 if (info->manifest_info->root_path)
2878 *path = (char *)info->manifest_info->root_path;
2880 return PMINFO_R_ERROR;
2885 API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
2887 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2888 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2890 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2891 if (info->manifest_info->csc_path)
2892 *path = (char *)info->manifest_info->csc_path;
2894 *path = (char *)info->manifest_info->csc_path;
2899 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)
2901 retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
2902 retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
2903 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2905 int ret = PMINFO_R_OK;
2906 char query[MAX_QUERY_LEN] = {'\0'};
2907 char *error_message = NULL;
2908 pkgmgr_cert_x *info= NULL;
2912 *compare_result = PMINFO_CERT_COMPARE_ERROR;
2913 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
2914 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
2916 ret = db_util_open_with_options(CERT_DB, &cert_db,
2917 SQLITE_OPEN_READONLY, NULL);
2918 if (ret != SQLITE_OK) {
2919 _LOGE("connect db [%s] failed!\n", CERT_DB);
2920 ret = PMINFO_R_ERROR;
2924 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
2926 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
2927 _LOGE("Don't execute query = %s error message = %s\n", query,
2929 ret = PMINFO_R_ERROR;
2936 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
2938 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
2939 _LOGE("Don't execute query = %s error message = %s\n", query,
2941 ret = PMINFO_R_ERROR;
2944 lcert = info->cert_id;
2947 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
2949 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
2950 _LOGE("Don't execute query = %s error message = %s\n", query,
2952 ret = PMINFO_R_ERROR;
2959 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
2961 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
2962 _LOGE("Don't execute query = %s error message = %s\n", query,
2964 ret = PMINFO_R_ERROR;
2967 rcert = info->cert_id;
2970 if ((lcert == 0) || (rcert == 0))
2972 if ((lcert == 0) && (rcert == 0))
2973 *compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
2974 else if (lcert == 0)
2975 *compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
2976 else if (rcert == 0)
2977 *compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
2980 *compare_result = PMINFO_CERT_COMPARE_MATCH;
2982 *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
2986 sqlite3_free(error_message);
2987 sqlite3_close(cert_db);
3000 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)
3002 retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
3003 retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
3004 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3006 int ret = PMINFO_R_OK;
3007 char query[MAX_QUERY_LEN] = {'\0'};
3008 char *error_message = NULL;
3009 pkgmgr_cert_x *info= NULL;
3011 char *lpkgid = NULL;
3012 char *rpkgid = NULL;
3014 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3015 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3017 ret = db_util_open_with_options(MANIFEST_DB, &manifest_db,
3018 SQLITE_OPEN_READONLY, NULL);
3019 if (ret != SQLITE_OK) {
3020 _LOGE("connect db [%s] failed!\n", MANIFEST_DB);
3021 ret = PMINFO_R_ERROR;
3025 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
3027 sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
3028 _LOGE("Don't execute query = %s error message = %s\n", query,
3030 ret = PMINFO_R_ERROR;
3037 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
3039 sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
3040 _LOGE("Don't execute query = %s error message = %s\n", query,
3042 ret = PMINFO_R_ERROR;
3045 lpkgid = strdup(info->pkgid);
3046 if (lpkgid == NULL) {
3047 _LOGE("Out of Memory\n");
3048 ret = PMINFO_R_ERROR;
3055 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
3057 sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
3058 _LOGE("Don't execute query = %s error message = %s\n", query,
3060 ret = PMINFO_R_ERROR;
3067 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
3069 sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
3070 _LOGE("Don't execute query = %s error message = %s\n", query,
3072 ret = PMINFO_R_ERROR;
3075 rpkgid = strdup(info->pkgid);
3076 if (rpkgid == NULL) {
3077 _LOGE("Out of Memory\n");
3078 ret = PMINFO_R_ERROR;
3084 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
3086 sqlite3_free(error_message);
3087 sqlite3_close(manifest_db);
3107 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
3109 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3110 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3112 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
3114 _LOGD("invalid func parameters\n");
3115 return PMINFO_R_ERROR;
3117 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
3120 char app_mmc_path[FILENAME_MAX] = { 0, };
3121 char app_dir_path[FILENAME_MAX] = { 0, };
3122 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
3123 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
3124 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
3125 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
3127 /*check whether application is in external memory or not */
3128 fp = fopen(app_mmc_path, "r");
3130 _LOGD(" app path in external memory not accesible\n");
3135 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
3139 /*check whether application is in internal or not */
3140 fp = fopen(app_dir_path, "r");
3142 _LOGD(" app path in internal memory not accesible\n");
3144 return PMINFO_R_ERROR;
3147 /*check whether the application is installed in SD card
3148 but SD card is not present*/
3149 fp = fopen(app_mmc_internal_path, "r");
3152 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
3157 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
3162 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
3166 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
3168 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3169 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3171 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3172 val = (char *)info->manifest_info->removable;
3174 if (strcasecmp(val, "true") == 0)
3176 else if (strcasecmp(val, "false") == 0)
3184 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
3186 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3187 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3190 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3192 val = (char *)info->manifest_info->installlocation;
3194 if (strcmp(val, "internal-only") == 0)
3196 else if (strcmp(val, "prefer-external") == 0)
3205 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
3207 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3208 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3210 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3211 val = (char *)info->manifest_info->preload;
3213 if (strcasecmp(val, "true") == 0)
3215 else if (strcasecmp(val, "false") == 0)
3223 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
3225 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3226 retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3228 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3229 val = (char *)info->manifest_info->readonly;
3231 if (strcasecmp(val, "true") == 0)
3233 else if (strcasecmp(val, "false") == 0)
3241 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
3243 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3244 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3247 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3248 val = (char *)info->manifest_info->update;
3250 if (strcasecmp(val, "true") == 0)
3252 else if (strcasecmp(val, "false") == 0)
3260 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
3262 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3263 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3264 __cleanup_pkginfo(info);
3268 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
3270 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
3272 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
3273 if (filter == NULL) {
3274 _LOGE("Out of Memory!!!");
3275 return PMINFO_R_ERROR;
3281 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
3283 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3284 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3286 g_slist_foreach(filter->list, __destroy_each_node, NULL);
3287 g_slist_free(filter->list);
3294 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
3295 const char *property, const int value)
3297 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3298 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3299 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3301 GSList *link = NULL;
3303 prop = _pminfo_pkginfo_convert_to_prop_int(property);
3304 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
3305 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
3306 _LOGE("Invalid Integer Property\n");
3307 return PMINFO_R_EINVAL;
3309 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3310 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3312 _LOGE("Out of Memory!!!\n");
3313 return PMINFO_R_ERROR;
3315 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3316 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3318 _LOGE("Out of Memory\n");
3321 return PMINFO_R_ERROR;
3325 /*If API is called multiple times for same property, we should override the previous values.
3326 Last value set will be used for filtering.*/
3327 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3329 filter->list = g_slist_delete_link(filter->list, link);
3330 filter->list = g_slist_append(filter->list, (gpointer)node);
3335 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
3336 const char *property, const bool value)
3338 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3339 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3341 GSList *link = NULL;
3343 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
3344 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
3345 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
3346 _LOGE("Invalid Boolean Property\n");
3347 return PMINFO_R_EINVAL;
3349 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3350 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3352 _LOGE("Out of Memory!!!\n");
3353 return PMINFO_R_ERROR;
3356 val = strndup("('true','True')", 15);
3358 val = strndup("('false','False')", 17);
3360 _LOGE("Out of Memory\n");
3363 return PMINFO_R_ERROR;
3367 /*If API is called multiple times for same property, we should override the previous values.
3368 Last value set will be used for filtering.*/
3369 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3371 filter->list = g_slist_delete_link(filter->list, link);
3372 filter->list = g_slist_append(filter->list, (gpointer)node);
3377 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
3378 const char *property, const char *value)
3380 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3381 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3382 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3384 GSList *link = NULL;
3386 prop = _pminfo_pkginfo_convert_to_prop_str(property);
3387 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
3388 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
3389 _LOGE("Invalid String Property\n");
3390 return PMINFO_R_EINVAL;
3392 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3393 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3395 _LOGE("Out of Memory!!!\n");
3396 return PMINFO_R_ERROR;
3398 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
3399 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
3400 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
3401 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
3402 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
3403 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
3404 else if (strcmp(value, "installed_internal") == 0)
3405 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
3406 else if (strcmp(value, "installed_external") == 0)
3407 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
3409 val = strndup(value, PKG_STRING_LEN_MAX - 1);
3411 _LOGE("Out of Memory\n");
3414 return PMINFO_R_ERROR;
3418 /*If API is called multiple times for same property, we should override the previous values.
3419 Last value set will be used for filtering.*/
3420 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3422 filter->list = g_slist_delete_link(filter->list, link);
3423 filter->list = g_slist_append(filter->list, (gpointer)node);
3428 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
3430 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3431 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3432 char *syslocale = NULL;
3433 char *locale = NULL;
3434 char *condition = NULL;
3435 char *error_message = NULL;
3436 char query[MAX_QUERY_LEN] = {'\0'};
3437 char where[MAX_QUERY_LEN] = {'\0'};
3441 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3442 /*Get current locale*/
3443 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3444 if (syslocale == NULL) {
3445 _LOGE("current locale is NULL\n");
3446 return PMINFO_R_ERROR;
3448 locale = __convert_system_locale_to_manifest_locale(syslocale);
3449 if (locale == NULL) {
3450 _LOGE("manifest locale is NULL\n");
3452 return PMINFO_R_ERROR;
3455 ret = __open_manifest_db();
3457 _LOGE("Fail to open manifest DB\n");
3458 ret = PMINFO_R_ERROR;
3462 /*Start constructing query*/
3463 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_PACKAGE, locale);
3465 /*Get where clause*/
3466 for (list = filter->list; list; list = g_slist_next(list)) {
3467 __get_filter_condition(list->data, &condition);
3469 strncat(where, condition, sizeof(where) - strlen(where) -1);
3470 where[sizeof(where) - 1] = '\0';
3474 if (g_slist_next(list)) {
3475 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3476 where[sizeof(where) - 1] = '\0';
3479 _LOGE("where = %s\n", where);
3480 if (strlen(where) > 0) {
3481 strncat(query, where, sizeof(query) - strlen(query) - 1);
3482 query[sizeof(query) - 1] = '\0';
3484 _LOGE("query = %s\n", query);
3488 sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
3489 _LOGE("Don't execute query = %s error message = %s\n", query,
3491 sqlite3_free(error_message);
3492 sqlite3_close(manifest_db);
3493 ret = PMINFO_R_ERROR;
3507 sqlite3_close(manifest_db);
3511 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
3512 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
3514 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3515 retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3516 char *syslocale = NULL;
3517 char *locale = NULL;
3518 char *condition = NULL;
3519 char *error_message = NULL;
3520 char query[MAX_QUERY_LEN] = {'\0'};
3521 char where[MAX_QUERY_LEN] = {'\0'};
3524 label_x *tmp1 = NULL;
3525 icon_x *tmp2 = NULL;
3526 description_x *tmp3 = NULL;
3527 author_x *tmp4 = NULL;
3528 privilege_x *tmp5 = NULL;
3529 pkgmgr_pkginfo_x *node = NULL;
3530 pkgmgr_pkginfo_x *tmphead = NULL;
3531 pkgmgr_pkginfo_x *pkginfo = NULL;
3533 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3534 /*Get current locale*/
3535 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3536 if (syslocale == NULL) {
3537 _LOGE("current locale is NULL\n");
3538 return PMINFO_R_ERROR;
3540 locale = __convert_system_locale_to_manifest_locale(syslocale);
3541 if (locale == NULL) {
3542 _LOGE("manifest locale is NULL\n");
3544 return PMINFO_R_ERROR;
3547 ret = __open_manifest_db();
3549 _LOGE("Fail to open manifest DB\n");
3550 ret = PMINFO_R_ERROR;
3553 /*Start constructing query*/
3554 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
3556 /*Get where clause*/
3557 for (list = filter->list; list; list = g_slist_next(list)) {
3558 __get_filter_condition(list->data, &condition);
3560 strncat(where, condition, sizeof(where) - strlen(where) -1);
3561 where[sizeof(where) - 1] = '\0';
3565 if (g_slist_next(list)) {
3566 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3567 where[sizeof(where) - 1] = '\0';
3570 _LOGE("where = %s\n", where);
3571 if (strlen(where) > 0) {
3572 strncat(query, where, sizeof(query) - strlen(query) - 1);
3573 query[sizeof(query) - 1] = '\0';
3575 _LOGE("query = %s\n", query);
3576 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
3577 if (tmphead == NULL) {
3578 _LOGE("Out of Memory!!!\n");
3579 ret = PMINFO_R_ERROR;
3584 sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
3585 _LOGE("Don't execute query = %s error message = %s\n", query,
3587 sqlite3_free(error_message);
3588 sqlite3_close(manifest_db);
3589 ret = PMINFO_R_ERROR;
3593 LISTHEAD(tmphead, node);
3594 for(node = node->next ; node ; node = node->next) {
3596 pkginfo->locale = strdup(locale);
3597 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
3598 if (pkginfo->manifest_info->privileges == NULL) {
3599 _LOGE("Failed to allocate memory for privileges info\n");
3600 ret = PMINFO_R_ERROR;
3604 /*populate manifest_info from DB*/
3605 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
3606 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3608 _LOGE("Package Info DB Information retrieval failed\n");
3609 ret = PMINFO_R_ERROR;
3612 memset(query, '\0', MAX_QUERY_LEN);
3613 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3614 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
3615 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3617 _LOGE("Package Info DB Information retrieval failed\n");
3618 ret = PMINFO_R_ERROR;
3621 /*Also store the values corresponding to default locales*/
3622 memset(query, '\0', MAX_QUERY_LEN);
3623 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3624 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
3625 ret = __exec_pkginfo_query(query, (void *)pkginfo);
3627 _LOGE("Package Info DB Information retrieval failed\n");
3628 ret = PMINFO_R_ERROR;
3631 if (pkginfo->manifest_info->label) {
3632 LISTHEAD(pkginfo->manifest_info->label, tmp1);
3633 pkginfo->manifest_info->label = tmp1;
3635 if (pkginfo->manifest_info->icon) {
3636 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
3637 pkginfo->manifest_info->icon = tmp2;
3639 if (pkginfo->manifest_info->description) {
3640 LISTHEAD(pkginfo->manifest_info->description, tmp3);
3641 pkginfo->manifest_info->description = tmp3;
3643 if (pkginfo->manifest_info->author) {
3644 LISTHEAD(pkginfo->manifest_info->author, tmp4);
3645 pkginfo->manifest_info->author = tmp4;
3647 if (pkginfo->manifest_info->privileges->privilege) {
3648 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
3649 pkginfo->manifest_info->privileges->privilege = tmp5;
3653 LISTHEAD(tmphead, node);
3655 for(node = node->next ; node ; node = node->next) {
3657 ret = pkg_cb( (void *)pkginfo, user_data);
3672 sqlite3_close(manifest_db);
3673 __cleanup_pkginfo(tmphead);
3677 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
3678 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
3680 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3681 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3683 privilege_x *ptr = NULL;
3684 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3685 ptr = info->manifest_info->privileges->privilege;
3686 for (; ptr; ptr = ptr->next) {
3688 ret = privilege_func(ptr->text, user_data);
3696 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
3697 pkgmgrinfo_app_list_cb app_func, void *user_data)
3699 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3700 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
3701 retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
3703 char *syslocale = NULL;
3704 char *locale = NULL;
3706 char query[MAX_QUERY_LEN] = {'\0'};
3707 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3708 pkgmgr_pkginfo_x *allinfo = NULL;
3709 pkgmgr_appinfo_x *appinfo = NULL;
3710 icon_x *ptr1 = NULL;
3711 label_x *ptr2 = NULL;
3712 category_x *ptr3 = NULL;
3713 metadata_x *ptr4 = NULL;
3714 permission_x *ptr5 = NULL;
3715 image_x *ptr6 = NULL;
3716 sqlite3 *appinfo_db = NULL;
3718 /*get system locale*/
3719 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3720 tryvm_if(syslocale == NULL, ret = PMINFO_R_EINVAL, "current locale is NULL");
3722 /*get locale on db*/
3723 locale = __convert_system_locale_to_manifest_locale(syslocale);
3724 tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
3727 allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
3728 tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3730 /*calloc manifest_info*/
3731 allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
3732 tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
3735 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
3736 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3738 /*set component type*/
3739 if (component == PMINFO_UI_APP)
3740 appinfo->app_component = PMINFO_UI_APP;
3741 if (component == PMINFO_SVC_APP)
3742 appinfo->app_component = PMINFO_SVC_APP;
3743 if (component == PMINFO_ALL_APP)
3744 appinfo->app_component = PMINFO_ALL_APP;
3747 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
3748 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3750 appinfo->package = strdup(info->manifest_info->package);
3751 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
3752 "from package_app_info where " \
3753 "package='%s' and app_component='%s'",
3754 info->manifest_info->package,
3755 (appinfo->app_component==PMINFO_UI_APP ? "uiapp" : "svcapp"));
3759 /*Populate ui app info */
3760 ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
3761 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3763 uiapplication_x *tmp = NULL;
3764 if (info->manifest_info->uiapplication) {
3765 LISTHEAD(info->manifest_info->uiapplication, tmp);
3766 info->manifest_info->uiapplication = tmp;
3768 /*Populate localized info for default locales and call callback*/
3769 /*If the callback func return < 0 we break and no more call back is called*/
3772 appinfo->locale = strdup(locale);
3773 appinfo->uiapp_info = tmp;
3774 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
3778 locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
3781 memset(query, '\0', MAX_QUERY_LEN);
3782 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3783 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3784 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3786 memset(query, '\0', MAX_QUERY_LEN);
3787 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);
3788 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3789 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3791 /*store setting notification icon section*/
3792 memset(query, '\0', MAX_QUERY_LEN);
3793 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3794 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3795 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
3797 /*store app preview image info*/
3798 memset(query, '\0', MAX_QUERY_LEN);
3799 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
3800 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3801 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
3803 if (appinfo->uiapp_info->label) {
3804 LISTHEAD(appinfo->uiapp_info->label, ptr2);
3805 appinfo->uiapp_info->label = ptr2;
3807 if (appinfo->uiapp_info->icon) {
3808 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
3809 appinfo->uiapp_info->icon = ptr1;
3811 if (appinfo->uiapp_info->category) {
3812 LISTHEAD(appinfo->uiapp_info->category, ptr3);
3813 appinfo->uiapp_info->category = ptr3;
3815 if (appinfo->uiapp_info->metadata) {
3816 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
3817 appinfo->uiapp_info->metadata = ptr4;
3819 if (appinfo->uiapp_info->permission) {
3820 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
3821 appinfo->uiapp_info->permission = ptr5;
3823 if (appinfo->uiapp_info->image) {
3824 LISTHEAD(appinfo->uiapp_info->image, ptr6);
3825 appinfo->uiapp_info->image = ptr6;
3827 ret = app_func((void *)appinfo, user_data);
3833 case PMINFO_SVC_APP:
3834 /*Populate svc app info */
3835 ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
3836 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3838 serviceapplication_x *tmp1 = NULL;
3839 if (info->manifest_info->serviceapplication) {
3840 LISTHEAD(info->manifest_info->serviceapplication, tmp1);
3841 info->manifest_info->serviceapplication = tmp1;
3843 /*Populate localized info for default locales and call callback*/
3844 /*If the callback func return < 0 we break and no more call back is called*/
3847 appinfo->locale = strdup(locale);
3848 appinfo->svcapp_info = tmp1;
3849 memset(query, '\0', MAX_QUERY_LEN);
3850 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
3851 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3852 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3854 memset(query, '\0', MAX_QUERY_LEN);
3855 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);
3856 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3857 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3859 if (appinfo->svcapp_info->label) {
3860 LISTHEAD(appinfo->svcapp_info->label, ptr2);
3861 appinfo->svcapp_info->label = ptr2;
3863 if (appinfo->svcapp_info->icon) {
3864 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
3865 appinfo->svcapp_info->icon = ptr1;
3867 if (appinfo->svcapp_info->category) {
3868 LISTHEAD(appinfo->svcapp_info->category, ptr3);
3869 appinfo->svcapp_info->category = ptr3;
3871 if (appinfo->svcapp_info->metadata) {
3872 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
3873 appinfo->svcapp_info->metadata = ptr4;
3875 if (appinfo->svcapp_info->permission) {
3876 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
3877 appinfo->svcapp_info->permission = ptr5;
3879 ret = app_func((void *)appinfo, user_data);
3885 case PMINFO_ALL_APP:
3886 memset(query, '\0', MAX_QUERY_LEN);
3887 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
3889 /*Populate all app info */
3890 ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo);
3891 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3894 appinfo->app_component = PMINFO_UI_APP;
3895 uiapplication_x *tmp2 = NULL;
3896 if (allinfo->manifest_info->uiapplication) {
3897 LISTHEAD(allinfo->manifest_info->uiapplication, tmp2);
3898 allinfo->manifest_info->uiapplication = tmp2;
3900 /*Populate localized info for default locales and call callback*/
3901 /*If the callback func return < 0 we break and no more call back is called*/
3904 appinfo->locale = strdup(locale);
3905 appinfo->uiapp_info = tmp2;
3906 memset(query, '\0', MAX_QUERY_LEN);
3907 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3908 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3909 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3911 memset(query, '\0', MAX_QUERY_LEN);
3912 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);
3913 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3914 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3916 /*store setting notification icon section*/
3917 memset(query, '\0', MAX_QUERY_LEN);
3918 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3919 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3920 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
3922 /*store app preview image info*/
3923 memset(query, '\0', MAX_QUERY_LEN);
3924 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
3925 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3926 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
3928 if (appinfo->uiapp_info->label) {
3929 LISTHEAD(appinfo->uiapp_info->label, ptr2);
3930 appinfo->uiapp_info->label = ptr2;
3932 if (appinfo->uiapp_info->icon) {
3933 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
3934 appinfo->uiapp_info->icon = ptr1;
3936 if (appinfo->uiapp_info->category) {
3937 LISTHEAD(appinfo->uiapp_info->category, ptr3);
3938 appinfo->uiapp_info->category = ptr3;
3940 if (appinfo->uiapp_info->metadata) {
3941 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
3942 appinfo->uiapp_info->metadata = ptr4;
3944 if (appinfo->uiapp_info->permission) {
3945 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
3946 appinfo->uiapp_info->permission = ptr5;
3948 if (appinfo->uiapp_info->image) {
3949 LISTHEAD(appinfo->uiapp_info->image, ptr6);
3950 appinfo->uiapp_info->image = ptr6;
3952 ret = app_func((void *)appinfo, user_data);
3959 appinfo->app_component = PMINFO_SVC_APP;
3960 serviceapplication_x *tmp3 = NULL;
3961 if (allinfo->manifest_info->serviceapplication) {
3962 LISTHEAD(allinfo->manifest_info->serviceapplication, tmp3);
3963 allinfo->manifest_info->serviceapplication = tmp3;
3965 /*Populate localized info for default locales and call callback*/
3966 /*If the callback func return < 0 we break and no more call back is called*/
3969 appinfo->locale = strdup(locale);
3970 appinfo->svcapp_info = tmp3;
3971 memset(query, '\0', MAX_QUERY_LEN);
3972 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
3973 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3974 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3976 memset(query, '\0', MAX_QUERY_LEN);
3977 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);
3978 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3979 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3981 if (appinfo->svcapp_info->label) {
3982 LISTHEAD(appinfo->svcapp_info->label, ptr2);
3983 appinfo->svcapp_info->label = ptr2;
3985 if (appinfo->svcapp_info->icon) {
3986 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
3987 appinfo->svcapp_info->icon = ptr1;
3989 if (appinfo->svcapp_info->category) {
3990 LISTHEAD(appinfo->svcapp_info->category, ptr3);
3991 appinfo->svcapp_info->category = ptr3;
3993 if (appinfo->svcapp_info->metadata) {
3994 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
3995 appinfo->svcapp_info->metadata = ptr4;
3997 if (appinfo->svcapp_info->permission) {
3998 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
3999 appinfo->svcapp_info->permission = ptr5;
4001 ret = app_func((void *)appinfo, user_data);
4006 appinfo->app_component = PMINFO_ALL_APP;
4022 if (appinfo->package) {
4023 free((void *)appinfo->package);
4024 appinfo->package = NULL;
4029 __cleanup_pkginfo(allinfo);
4031 sqlite3_close(appinfo_db);
4035 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4037 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4039 int ret = PMINFO_R_OK;
4040 char query[MAX_QUERY_LEN] = {'\0'};
4041 pkgmgr_appinfo_x *info = NULL;
4042 pkgmgr_appinfo_x *appinfo = NULL;
4043 uiapplication_x *ptr1 = NULL;
4044 sqlite3 *appinfo_db = NULL;
4047 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4048 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4051 info = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4052 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4054 /*calloc uiapplication_x*/
4055 info->uiapp_info= (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4056 tryvm_if(info->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4059 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4060 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4062 /*query package_app_info*/
4063 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4064 ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
4065 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4067 LISTHEAD(info->uiapp_info, ptr1);
4070 for(ptr1 = ptr1->next ; ptr1 ; ptr1 = ptr1->next)
4072 appinfo->uiapp_info= ptr1;
4073 appinfo->package = strdup(ptr1->package);
4074 appinfo->app_component = PMINFO_UI_APP;
4076 ret = app_func((void *)appinfo, user_data);
4079 free((void *)appinfo->package);
4080 appinfo->package = NULL;
4084 sqlite3_close(appinfo_db);
4090 __cleanup_appinfo(info);
4094 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4096 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4098 int ret = PMINFO_R_OK;
4099 char query[MAX_QUERY_LEN] = {'\0'};
4100 char *syslocale = NULL;
4101 char *locale = NULL;
4102 pkgmgr_appinfo_x *appinfo = NULL;
4103 uiapplication_x *ptr1 = NULL;
4104 serviceapplication_x *ptr2 = NULL;
4105 label_x *tmp1 = NULL;
4106 icon_x *tmp2 = NULL;
4107 category_x *tmp3 = NULL;
4108 metadata_x *tmp4 = NULL;
4109 permission_x *tmp5 = NULL;
4110 image_x *tmp6 = NULL;
4111 sqlite3 *appinfo_db = NULL;
4113 /*get system locale*/
4114 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4115 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
4117 /*get locale on db*/
4118 locale = __convert_system_locale_to_manifest_locale(syslocale);
4119 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4122 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4123 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4126 pkgmgr_pkginfo_x *info = NULL;
4127 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4128 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4130 /*calloc manifest_info*/
4131 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4132 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4135 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4136 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4138 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4139 ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
4140 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4142 if (info->manifest_info->uiapplication) {
4143 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4144 info->manifest_info->uiapplication = ptr1;
4146 if (info->manifest_info->serviceapplication) {
4147 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4148 info->manifest_info->serviceapplication = ptr2;
4152 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4154 appinfo->locale = strdup(locale);
4155 appinfo->app_component = PMINFO_UI_APP;
4156 appinfo->package = strdup(ptr1->package);
4157 appinfo->uiapp_info = ptr1;
4158 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4159 "from package_app_info where " \
4160 "app_id='%s'", ptr1->appid);
4161 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4162 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4164 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
4168 locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
4171 memset(query, '\0', MAX_QUERY_LEN);
4172 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4173 "from package_app_localized_info where " \
4174 "app_id='%s' and app_locale='%s'",
4175 ptr1->appid, locale);
4176 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4177 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4179 memset(query, '\0', MAX_QUERY_LEN);
4180 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4181 "from package_app_localized_info where " \
4182 "app_id='%s' and app_locale='%s'",
4183 ptr1->appid, DEFAULT_LOCALE);
4185 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4186 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4188 /*store setting notification icon section*/
4189 memset(query, '\0', MAX_QUERY_LEN);
4190 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
4191 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4192 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4194 /*store app preview image info*/
4195 memset(query, '\0', MAX_QUERY_LEN);
4196 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
4197 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4198 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4200 if (appinfo->uiapp_info->label) {
4201 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4202 appinfo->uiapp_info->label = tmp1;
4204 if (appinfo->uiapp_info->icon) {
4205 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4206 appinfo->uiapp_info->icon= tmp2;
4208 if (appinfo->uiapp_info->category) {
4209 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4210 appinfo->uiapp_info->category = tmp3;
4212 if (appinfo->uiapp_info->metadata) {
4213 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4214 appinfo->uiapp_info->metadata = tmp4;
4216 if (appinfo->uiapp_info->permission) {
4217 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4218 appinfo->uiapp_info->permission = tmp5;
4220 if (appinfo->uiapp_info->image) {
4221 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4222 appinfo->uiapp_info->image = tmp6;
4224 ret = app_func((void *)appinfo, user_data);
4227 free((void *)appinfo->package);
4228 appinfo->package = NULL;
4231 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4233 appinfo->locale = strdup(locale);
4234 appinfo->app_component = PMINFO_SVC_APP;
4235 appinfo->package = strdup(ptr2->package);
4236 appinfo->svcapp_info = ptr2;
4237 memset(query, '\0', MAX_QUERY_LEN);
4238 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4239 "from package_app_info where " \
4240 "app_id='%s'", ptr2->appid);
4241 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4242 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4244 memset(query, '\0', MAX_QUERY_LEN);
4245 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4246 "from package_app_localized_info where " \
4247 "app_id='%s' and app_locale='%s'",
4248 ptr2->appid, locale);
4249 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4250 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4252 memset(query, '\0', MAX_QUERY_LEN);
4253 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4254 "from package_app_localized_info where " \
4255 "app_id='%s' and app_locale='%s'",
4256 ptr2->appid, DEFAULT_LOCALE);
4257 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4258 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4260 if (appinfo->svcapp_info->label) {
4261 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4262 appinfo->svcapp_info->label = tmp1;
4264 if (appinfo->svcapp_info->icon) {
4265 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4266 appinfo->svcapp_info->icon= tmp2;
4268 if (appinfo->svcapp_info->category) {
4269 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4270 appinfo->svcapp_info->category = tmp3;
4272 if (appinfo->svcapp_info->metadata) {
4273 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4274 appinfo->svcapp_info->metadata = tmp4;
4276 if (appinfo->svcapp_info->permission) {
4277 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4278 appinfo->svcapp_info->permission = tmp5;
4280 ret = app_func((void *)appinfo, user_data);
4283 free((void *)appinfo->package);
4284 appinfo->package = NULL;
4297 sqlite3_close(appinfo_db);
4302 __cleanup_pkginfo(info);
4306 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
4308 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
4309 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4311 pkgmgr_appinfo_x *appinfo = NULL;
4312 char *syslocale = NULL;
4313 char *locale = NULL;
4316 label_x *tmp1 = NULL;
4317 icon_x *tmp2 = NULL;
4318 category_x *tmp3 = NULL;
4319 metadata_x *tmp4 = NULL;
4320 permission_x *tmp5 = NULL;
4321 image_x *tmp6 = NULL;
4322 char query[MAX_QUERY_LEN] = {'\0'};
4323 sqlite3 *appinfo_db = NULL;
4326 ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
4327 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4329 /*check appid exist on db*/
4330 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
4331 ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
4332 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
4333 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
4335 /*get system locale*/
4336 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4337 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
4339 /*get locale on db*/
4340 locale = __convert_system_locale_to_manifest_locale(syslocale);
4341 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4344 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4345 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
4347 /*check app_component from DB*/
4348 memset(query, '\0', MAX_QUERY_LEN);
4349 snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
4350 ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
4351 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4353 /*calloc app_component*/
4354 if (appinfo->app_component == PMINFO_UI_APP) {
4355 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4356 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
4358 appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
4359 tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
4361 appinfo->locale = strdup(locale);
4363 /*populate app_info from DB*/
4364 memset(query, '\0', MAX_QUERY_LEN);
4365 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info 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 Info DB Information retrieval failed");
4369 memset(query, '\0', MAX_QUERY_LEN);
4370 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
4371 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4372 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4374 /*Also store the values corresponding to default locales*/
4375 memset(query, '\0', MAX_QUERY_LEN);
4376 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
4377 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4378 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4380 /*Populate app category*/
4381 memset(query, '\0', MAX_QUERY_LEN);
4382 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
4383 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4384 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
4386 /*Populate app metadata*/
4387 memset(query, '\0', MAX_QUERY_LEN);
4388 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
4389 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4390 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
4392 /*Populate app permission*/
4393 memset(query, '\0', MAX_QUERY_LEN);
4394 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
4395 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4396 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
4398 /*store setting notification icon section*/
4399 memset(query, '\0', MAX_QUERY_LEN);
4400 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
4401 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4402 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4404 /*store app preview image info*/
4405 memset(query, '\0', MAX_QUERY_LEN);
4406 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
4407 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4408 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4410 switch (appinfo->app_component) {
4412 if (appinfo->uiapp_info->label) {
4413 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4414 appinfo->uiapp_info->label = tmp1;
4416 if (appinfo->uiapp_info->icon) {
4417 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4418 appinfo->uiapp_info->icon = tmp2;
4420 if (appinfo->uiapp_info->category) {
4421 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4422 appinfo->uiapp_info->category = tmp3;
4424 if (appinfo->uiapp_info->metadata) {
4425 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4426 appinfo->uiapp_info->metadata = tmp4;
4428 if (appinfo->uiapp_info->permission) {
4429 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4430 appinfo->uiapp_info->permission = tmp5;
4432 if (appinfo->uiapp_info->image) {
4433 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4434 appinfo->uiapp_info->image = tmp6;
4437 case PMINFO_SVC_APP:
4438 if (appinfo->svcapp_info->label) {
4439 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4440 appinfo->svcapp_info->label = tmp1;
4442 if (appinfo->svcapp_info->icon) {
4443 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4444 appinfo->svcapp_info->icon = tmp2;
4446 if (appinfo->svcapp_info->category) {
4447 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4448 appinfo->svcapp_info->category = tmp3;
4450 if (appinfo->svcapp_info->metadata) {
4451 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4452 appinfo->svcapp_info->metadata = tmp4;
4454 if (appinfo->svcapp_info->permission) {
4455 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4456 appinfo->svcapp_info->permission = tmp5;
4466 if (ret == PMINFO_R_OK)
4467 *handle = (void*)appinfo;
4470 __cleanup_appinfo(appinfo);
4473 sqlite3_close(appinfo_db);
4486 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
4488 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4489 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4490 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4492 if (info->app_component == PMINFO_UI_APP)
4493 *appid = (char *)info->uiapp_info->appid;
4494 else if (info->app_component == PMINFO_SVC_APP)
4495 *appid = (char *)info->svcapp_info->appid;
4500 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
4502 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4503 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4504 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4506 *pkg_name = (char *)info->package;
4511 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
4513 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4514 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4515 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4517 *pkgid = (char *)info->package;
4522 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
4524 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4525 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4526 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4528 if (info->app_component == PMINFO_UI_APP)
4529 *exec = (char *)info->uiapp_info->exec;
4530 if (info->app_component == PMINFO_SVC_APP)
4531 *exec = (char *)info->svcapp_info->exec;
4537 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4539 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4540 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4541 char *locale = NULL;
4543 icon_x *start = NULL;
4546 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4547 locale = info->locale;
4548 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4550 if (info->app_component == PMINFO_UI_APP)
4551 start = info->uiapp_info->icon;
4552 if (info->app_component == PMINFO_SVC_APP)
4553 start = info->svcapp_info->icon;
4554 for(ptr = start; ptr != NULL; ptr = ptr->next)
4557 if (strcmp(ptr->lang, locale) == 0) {
4558 *icon = (char *)ptr->text;
4559 if (strcasecmp(*icon, "(null)") == 0) {
4560 locale = DEFAULT_LOCALE;
4564 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4565 *icon = (char *)ptr->text;
4574 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
4576 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4577 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4578 char *locale = NULL;
4579 label_x *ptr = NULL;
4580 label_x *start = NULL;
4583 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4584 locale = info->locale;
4585 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4587 if (info->app_component == PMINFO_UI_APP)
4588 start = info->uiapp_info->label;
4589 if (info->app_component == PMINFO_SVC_APP)
4590 start = info->svcapp_info->label;
4591 for(ptr = start; ptr != NULL; ptr = ptr->next)
4594 if (strcmp(ptr->lang, locale) == 0) {
4595 *label = (char *)ptr->text;
4596 if (strcasecmp(*label, "(null)") == 0) {
4597 locale = DEFAULT_LOCALE;
4601 } else if (strncasecmp(ptr->lang, locale, 2) == 0) {
4602 *label = (char *)ptr->text;
4603 if (strcasecmp(*label, "(null)") == 0) {
4604 locale = DEFAULT_LOCALE;
4608 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4609 *label = (char *)ptr->text;
4618 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
4620 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4621 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4622 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4624 if (info->app_component == PMINFO_UI_APP)
4625 *component = PMINFO_UI_APP;
4626 else if (info->app_component == PMINFO_SVC_APP)
4627 *component = PMINFO_SVC_APP;
4629 return PMINFO_R_ERROR;
4634 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
4636 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4637 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4638 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4640 if (info->app_component == PMINFO_UI_APP)
4641 *app_type = (char *)info->uiapp_info->type;
4642 if (info->app_component == PMINFO_SVC_APP)
4643 *app_type = (char *)info->svcapp_info->type;
4648 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
4649 int *operation_count, char ***operation)
4651 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4652 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4653 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4654 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4655 *operation_count = data->operation_count;
4656 *operation = data->operation;
4660 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
4661 int *uri_count, char ***uri)
4663 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4664 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4665 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4666 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4667 *uri_count = data->uri_count;
4672 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
4673 int *mime_count, char ***mime)
4675 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4676 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4677 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4678 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4679 *mime_count = data->mime_count;
4684 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4686 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4687 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4691 icon_x *start = NULL;
4692 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4694 start = info->uiapp_info->icon;
4696 for(ptr = start; ptr != NULL; ptr = ptr->next)
4699 val = (char *)ptr->section;
4700 if (strcmp(val, "setting") == 0){
4701 *icon = (char *)ptr->text;
4710 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4712 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4713 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4717 icon_x *start = NULL;
4718 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4720 start = info->uiapp_info->icon;
4722 for(ptr = start; ptr != NULL; ptr = ptr->next)
4725 val = (char *)ptr->section;
4727 if (strcmp(val, "notification") == 0){
4728 *icon = (char *)ptr->text;
4737 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
4739 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4740 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4742 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4743 val = (char *)info->uiapp_info->recentimage;
4745 if (strcasecmp(val, "capture") == 0)
4746 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
4747 else if (strcasecmp(val, "icon") == 0)
4748 *type = PMINFO_RECENTIMAGE_USE_ICON;
4750 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
4756 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
4758 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4759 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4762 image_x *ptr = NULL;
4763 image_x *start = NULL;
4764 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4766 start = info->uiapp_info->image;
4768 for(ptr = start; ptr != NULL; ptr = ptr->next)
4771 val = (char *)ptr->section;
4773 if (strcmp(val, "preview") == 0)
4774 *preview_img = (char *)ptr->text;
4782 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
4784 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4785 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4788 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4790 val = info->uiapp_info->permission_type;
4792 if (strcmp(val, "signature") == 0)
4793 *permission = PMINFO_PERMISSION_SIGNATURE;
4794 else if (strcmp(val, "privilege") == 0)
4795 *permission = PMINFO_PERMISSION_PRIVILEGE;
4797 *permission = PMINFO_PERMISSION_NORMAL;
4802 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
4803 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
4805 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4806 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4808 permission_x *ptr = NULL;
4809 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4810 if (info->app_component == PMINFO_UI_APP)
4811 ptr = info->uiapp_info->permission;
4812 else if (info->app_component == PMINFO_SVC_APP)
4813 ptr = info->svcapp_info->permission;
4815 return PMINFO_R_EINVAL;
4816 for (; ptr; ptr = ptr->next) {
4817 ret = permission_func(ptr->value, user_data);
4824 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
4825 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
4827 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4828 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4830 category_x *ptr = NULL;
4831 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4832 if (info->app_component == PMINFO_UI_APP)
4833 ptr = info->uiapp_info->category;
4834 else if (info->app_component == PMINFO_SVC_APP)
4835 ptr = info->svcapp_info->category;
4837 return PMINFO_R_EINVAL;
4838 for (; ptr; ptr = ptr->next) {
4839 ret = category_func(ptr->name, user_data);
4846 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
4847 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
4849 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4850 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4852 metadata_x *ptr = NULL;
4853 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4854 if (info->app_component == PMINFO_UI_APP)
4855 ptr = info->uiapp_info->metadata;
4856 else if (info->app_component == PMINFO_SVC_APP)
4857 ptr = info->svcapp_info->metadata;
4859 return PMINFO_R_EINVAL;
4860 for (; ptr; ptr = ptr->next) {
4861 ret = metadata_func(ptr->key, ptr->value, user_data);
4868 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
4869 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
4871 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4872 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4879 char *manifest = NULL;
4880 char **operation = NULL;
4883 appcontrol_x *appcontrol = NULL;
4884 manifest_x *mfx = NULL;
4885 operation_x *op = NULL;
4888 pkgmgrinfo_app_component component;
4889 pkgmgrinfo_appcontrol_x *ptr = NULL;
4890 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
4892 _LOGE("Failed to get package name\n");
4893 return PMINFO_R_ERROR;
4895 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
4897 _LOGE("Failed to get app component name\n");
4898 return PMINFO_R_ERROR;
4900 manifest = pkgmgr_parser_get_manifest_file(pkgid);
4901 if (manifest == NULL) {
4902 _LOGE("Failed to fetch package manifest file\n");
4903 return PMINFO_R_ERROR;
4905 mfx = pkgmgr_parser_process_manifest_xml(manifest);
4907 _LOGE("Failed to parse package manifest file\n");
4910 return PMINFO_R_ERROR;
4913 ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
4915 _LOGE("Out of Memory!!!\n");
4916 pkgmgr_parser_free_manifest_xml(mfx);
4917 return PMINFO_R_ERROR;
4919 /*Get Operation, Uri, Mime*/
4920 switch (component) {
4922 if (mfx->uiapplication) {
4923 if (mfx->uiapplication->appcontrol) {
4924 appcontrol = mfx->uiapplication->appcontrol;
4928 case PMINFO_SVC_APP:
4929 if (mfx->serviceapplication) {
4930 if (mfx->serviceapplication->appcontrol) {
4931 appcontrol = mfx->serviceapplication->appcontrol;
4938 for (; appcontrol; appcontrol = appcontrol->next) {
4939 op = appcontrol->operation;
4940 for (; op; op = op->next)
4942 op = appcontrol->operation;
4944 ui = appcontrol->uri;
4945 for (; ui; ui = ui->next)
4947 ui = appcontrol->uri;
4949 mi = appcontrol->mime;
4950 for (; mi; mi = mi->next)
4952 mi = appcontrol->mime;
4954 operation = (char **)calloc(oc, sizeof(char *));
4955 for (i = 0; i < oc; i++) {
4956 operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
4960 uri = (char **)calloc(uc, sizeof(char *));
4961 for (i = 0; i < uc; i++) {
4962 uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
4966 mime = (char **)calloc(mc, sizeof(char *));
4967 for (i = 0; i < mc; i++) {
4968 mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
4971 /*populate appcontrol handle*/
4972 ptr->operation_count = oc;
4973 ptr->uri_count = uc;
4974 ptr->mime_count = mc;
4975 ptr->operation = operation;
4978 ret = appcontrol_func((void *)ptr, user_data);
4979 for (i = 0; i < oc; i++) {
4982 operation[i] = NULL;
4989 for (i = 0; i < uc; i++) {
4999 for (i = 0; i < mc; i++) {
5015 pkgmgr_parser_free_manifest_xml(mfx);
5023 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
5025 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5026 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5028 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5029 val = (char *)info->uiapp_info->nodisplay;
5031 if (strcasecmp(val, "true") == 0)
5033 else if (strcasecmp(val, "false") == 0)
5041 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
5043 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5044 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5046 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5047 val = (char *)info->uiapp_info->multiple;
5049 if (strcasecmp(val, "true") == 0)
5051 else if (strcasecmp(val, "false") == 0)
5059 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
5061 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5062 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5064 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5065 val = (char *)info->uiapp_info->indicatordisplay;
5067 if (strcasecmp(val, "true") == 0){
5068 *indicator_disp = 1;
5069 }else if (strcasecmp(val, "false") == 0){
5070 *indicator_disp = 0;
5072 *indicator_disp = 0;
5079 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
5081 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5082 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5083 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5084 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5086 if (info->app_component == PMINFO_UI_APP){
5087 *portrait_img = (char *)info->uiapp_info->portraitimg;
5088 *landscape_img = (char *)info->uiapp_info->landscapeimg;
5094 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
5096 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5097 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5099 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5100 val = (char *)info->uiapp_info->taskmanage;
5102 if (strcasecmp(val, "true") == 0)
5104 else if (strcasecmp(val, "false") == 0)
5112 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
5114 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5115 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5117 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5118 if (info->app_component == PMINFO_UI_APP)
5119 val = (char *)info->uiapp_info->enabled;
5120 else if (info->app_component == PMINFO_SVC_APP)
5121 val = (char *)info->uiapp_info->enabled;
5123 _LOGE("invalid component type\n");
5124 return PMINFO_R_EINVAL;
5128 if (strcasecmp(val, "true") == 0)
5130 else if (strcasecmp(val, "false") == 0)
5139 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
5141 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5142 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5144 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5145 val = (char *)info->uiapp_info->hwacceleration;
5147 if (strcasecmp(val, "not-use-GL") == 0)
5148 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
5149 else if (strcasecmp(val, "use-GL") == 0)
5150 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
5152 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
5157 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
5159 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5160 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5162 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5163 val = (char *)info->svcapp_info->onboot;
5165 if (strcasecmp(val, "true") == 0)
5167 else if (strcasecmp(val, "false") == 0)
5175 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
5177 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5178 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5180 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5181 val = (char *)info->svcapp_info->autorestart;
5183 if (strcasecmp(val, "true") == 0)
5185 else if (strcasecmp(val, "false") == 0)
5193 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
5195 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5196 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5198 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5199 val = (char *)info->uiapp_info->mainapp;
5201 if (strcasecmp(val, "true") == 0)
5203 else if (strcasecmp(val, "false") == 0)
5211 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
5213 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5214 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5215 __cleanup_appinfo(info);
5219 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
5221 return (pkgmgrinfo_pkginfo_filter_create(handle));
5224 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
5226 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5229 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
5230 const char *property, const int value)
5232 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5233 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5234 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
5236 GSList *link = NULL;
5238 prop = _pminfo_appinfo_convert_to_prop_int(property);
5239 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
5240 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
5241 _LOGE("Invalid Integer Property\n");
5242 return PMINFO_R_EINVAL;
5244 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5245 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5247 _LOGE("Out of Memory!!!\n");
5248 return PMINFO_R_ERROR;
5250 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
5251 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
5253 _LOGE("Out of Memory\n");
5256 return PMINFO_R_ERROR;
5260 /*If API is called multiple times for same property, we should override the previous values.
5261 Last value set will be used for filtering.*/
5262 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5264 filter->list = g_slist_delete_link(filter->list, link);
5265 filter->list = g_slist_append(filter->list, (gpointer)node);
5270 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
5271 const char *property, const bool value)
5273 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5274 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5276 GSList *link = NULL;
5278 prop = _pminfo_appinfo_convert_to_prop_bool(property);
5279 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
5280 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
5281 _LOGE("Invalid Boolean Property\n");
5282 return PMINFO_R_EINVAL;
5284 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5285 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5287 _LOGE("Out of Memory!!!\n");
5288 return PMINFO_R_ERROR;
5291 val = strndup("('true','True')", 15);
5293 val = strndup("('false','False')", 17);
5295 _LOGE("Out of Memory\n");
5298 return PMINFO_R_ERROR;
5302 /*If API is called multiple times for same property, we should override the previous values.
5303 Last value set will be used for filtering.*/
5304 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5306 filter->list = g_slist_delete_link(filter->list, link);
5307 filter->list = g_slist_append(filter->list, (gpointer)node);
5312 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
5313 const char *property, const char *value)
5315 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5316 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5317 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5319 pkgmgrinfo_node_x *ptr = NULL;
5320 char prev[PKG_STRING_LEN_MAX] = {'\0'};
5321 char temp[PKG_STRING_LEN_MAX] = {'\0'};
5322 GSList *link = NULL;
5324 prop = _pminfo_appinfo_convert_to_prop_str(property);
5325 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
5326 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
5327 _LOGE("Invalid String Property\n");
5328 return PMINFO_R_EINVAL;
5330 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5331 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5333 _LOGE("Out of Memory!!!\n");
5334 return PMINFO_R_ERROR;
5338 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
5339 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
5340 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
5342 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
5344 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5346 filter->list = g_slist_delete_link(filter->list, link);
5347 filter->list = g_slist_append(filter->list, (gpointer)node);
5349 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
5350 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
5351 case E_PMINFO_APPINFO_PROP_APP_URI:
5352 case E_PMINFO_APPINFO_PROP_APP_MIME:
5353 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
5355 _LOGE("Out of Memory\n");
5358 return PMINFO_R_ERROR;
5360 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5362 ptr = (pkgmgrinfo_node_x *)link->data;
5363 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
5364 _LOGE("Previous value is %s\n", prev);
5365 filter->list = g_slist_delete_link(filter->list, link);
5366 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
5367 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5368 _LOGE("New value is %s\n", val);
5370 filter->list = g_slist_append(filter->list, (gpointer)node);
5371 memset(temp, '\0', PKG_STRING_LEN_MAX);
5373 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
5374 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5375 _LOGE("First value is %s\n", val);
5377 filter->list = g_slist_append(filter->list, (gpointer)node);
5378 memset(temp, '\0', PKG_STRING_LEN_MAX);
5382 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
5383 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5385 filter->list = g_slist_delete_link(filter->list, link);
5386 filter->list = g_slist_append(filter->list, (gpointer)node);
5392 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
5394 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5395 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5396 char *syslocale = NULL;
5397 char *locale = NULL;
5398 char *condition = NULL;
5399 char *error_message = NULL;
5400 char query[MAX_QUERY_LEN] = {'\0'};
5401 char where[MAX_QUERY_LEN] = {'\0'};
5405 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5406 /*Get current locale*/
5407 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5408 if (syslocale == NULL) {
5409 _LOGE("current locale is NULL\n");
5410 return PMINFO_R_ERROR;
5412 locale = __convert_system_locale_to_manifest_locale(syslocale);
5413 if (locale == NULL) {
5414 _LOGE("manifest locale is NULL\n");
5416 return PMINFO_R_ERROR;
5419 ret = __open_manifest_db();
5421 _LOGE("Fail to open manifest DB\n");
5422 ret = PMINFO_R_ERROR;
5426 /*Start constructing query*/
5427 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_APP, locale);
5429 /*Get where clause*/
5430 for (list = filter->list; list; list = g_slist_next(list)) {
5431 __get_filter_condition(list->data, &condition);
5433 strncat(where, condition, sizeof(where) - strlen(where) -1);
5434 where[sizeof(where) - 1] = '\0';
5438 if (g_slist_next(list)) {
5439 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5440 where[sizeof(where) - 1] = '\0';
5443 _LOGE("where = %s\n", where);
5444 if (strlen(where) > 0) {
5445 strncat(query, where, sizeof(query) - strlen(query) - 1);
5446 query[sizeof(query) - 1] = '\0';
5448 _LOGE("query = %s\n", query);
5452 sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
5453 _LOGE("Don't execute query = %s error message = %s\n", query,
5455 sqlite3_free(error_message);
5456 sqlite3_close(manifest_db);
5457 ret = PMINFO_R_ERROR;
5471 sqlite3_close(manifest_db);
5475 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
5476 pkgmgrinfo_app_list_cb app_cb, void * user_data)
5478 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5479 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5480 char *syslocale = NULL;
5481 char *locale = NULL;
5482 char *condition = NULL;
5483 char *error_message = NULL;
5484 char query[MAX_QUERY_LEN] = {'\0'};
5485 char where[MAX_QUERY_LEN] = {'\0'};
5488 uiapplication_x *ptr1 = NULL;
5489 serviceapplication_x *ptr2 = NULL;
5490 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5491 /*Get current locale*/
5492 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5493 if (syslocale == NULL) {
5494 _LOGE("current locale is NULL\n");
5495 return PMINFO_R_ERROR;
5497 locale = __convert_system_locale_to_manifest_locale(syslocale);
5498 if (locale == NULL) {
5499 _LOGE("manifest locale is NULL\n");
5501 return PMINFO_R_ERROR;
5504 ret = __open_manifest_db();
5506 _LOGE("Fail to open manifest DB\n");
5507 ret = PMINFO_R_ERROR;
5510 /*Start constructing query*/
5511 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
5512 /*Get where clause*/
5513 for (list = filter->list; list; list = g_slist_next(list)) {
5514 __get_filter_condition(list->data, &condition);
5516 strncat(where, condition, sizeof(where) - strlen(where) -1);
5517 where[sizeof(where) - 1] = '\0';
5521 if (g_slist_next(list)) {
5522 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5523 where[sizeof(where) - 1] = '\0';
5526 _LOGE("where = %s\n", where);
5527 if (strlen(where) > 0) {
5528 strncat(query, where, sizeof(query) - strlen(query) - 1);
5529 query[sizeof(query) - 1] = '\0';
5531 _LOGE("query = %s\n", query);
5532 /*To get filtered list*/
5533 pkgmgr_pkginfo_x *info = NULL;
5534 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5536 _LOGE("Out of Memory!!!\n");
5537 ret = PMINFO_R_ERROR;
5540 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5541 if (info->manifest_info == NULL) {
5542 _LOGE("Out of Memory!!!\n");
5543 ret = PMINFO_R_ERROR;
5546 /*To get detail app info for each member of filtered list*/
5547 pkgmgr_pkginfo_x *filtinfo = NULL;
5548 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5549 if (filtinfo == NULL) {
5550 _LOGE("Out of Memory!!!\n");
5551 ret = PMINFO_R_ERROR;
5554 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5555 if (filtinfo->manifest_info == NULL) {
5556 _LOGE("Out of Memory!!!\n");
5557 ret = PMINFO_R_ERROR;
5560 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5561 if (appinfo == NULL) {
5562 _LOGE("Out of Memory!!!\n");
5563 ret = PMINFO_R_ERROR;
5567 sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) {
5568 _LOGE("Don't execute query = %s error message = %s\n", query,
5570 sqlite3_free(error_message);
5571 sqlite3_close(manifest_db);
5572 ret = PMINFO_R_ERROR;
5575 memset(query, '\0', MAX_QUERY_LEN);
5576 if (info->manifest_info->uiapplication) {
5577 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5578 info->manifest_info->uiapplication = ptr1;
5580 if (info->manifest_info->serviceapplication) {
5581 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5582 info->manifest_info->serviceapplication = ptr2;
5584 /*Filtered UI Apps*/
5585 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5587 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5588 ptr1->appid, "uiapp");
5590 sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
5591 _LOGE("Don't execute query = %s error message = %s\n", query,
5593 sqlite3_free(error_message);
5594 sqlite3_close(manifest_db);
5595 ret = PMINFO_R_ERROR;
5599 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5601 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5602 ptr2->appid, "svcapp");
5604 sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
5605 _LOGE("Don't execute query = %s error message = %s\n", query,
5607 sqlite3_free(error_message);
5608 sqlite3_close(manifest_db);
5609 ret = PMINFO_R_ERROR;
5613 if (filtinfo->manifest_info->uiapplication) {
5614 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5615 filtinfo->manifest_info->uiapplication = ptr1;
5617 /*If the callback func return < 0 we break and no more call back is called*/
5620 appinfo->locale = strdup(locale);
5621 appinfo->uiapp_info = ptr1;
5622 appinfo->app_component = PMINFO_UI_APP;
5623 ret = app_cb((void *)appinfo, user_data);
5628 /*Filtered Service Apps*/
5629 if (filtinfo->manifest_info->serviceapplication) {
5630 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5631 filtinfo->manifest_info->serviceapplication = ptr2;
5633 /*If the callback func return < 0 we break and no more call back is called*/
5636 appinfo->locale = strdup(locale);
5637 appinfo->svcapp_info = ptr2;
5638 appinfo->app_component = PMINFO_SVC_APP;
5639 ret = app_cb((void *)appinfo, user_data);
5654 sqlite3_close(manifest_db);
5659 __cleanup_pkginfo(info);
5660 __cleanup_pkginfo(filtinfo);
5664 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
5666 return (pkgmgrinfo_pkginfo_filter_create(handle));
5669 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
5671 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5674 API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
5675 const char *key, const char *value)
5677 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
5678 retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
5679 /*value can be NULL. In that case all apps with specified key should be displayed*/
5683 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5684 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5685 retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
5687 tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5691 tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5694 /*If API is called multiple times, we should OR all conditions.*/
5695 filter->list = g_slist_append(filter->list, (gpointer)node);
5696 /*All memory will be freed in destroy API*/
5714 API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
5715 pkgmgrinfo_app_list_cb app_cb, void *user_data)
5717 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
5718 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
5719 char *syslocale = NULL;
5720 char *locale = NULL;
5721 char *condition = NULL;
5722 char *error_message = NULL;
5723 char query[MAX_QUERY_LEN] = {'\0'};
5724 char where[MAX_QUERY_LEN] = {'\0'};
5727 pkgmgr_pkginfo_x *info = NULL;
5728 pkgmgr_pkginfo_x *filtinfo = NULL;
5729 pkgmgr_appinfo_x *appinfo = NULL;
5730 uiapplication_x *ptr1 = NULL;
5731 serviceapplication_x *ptr2 = NULL;
5732 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5734 /*Get current locale*/
5735 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5736 retvm_if(syslocale == NULL, PMINFO_R_ERROR, "current locale is NULL\n");
5737 locale = __convert_system_locale_to_manifest_locale(syslocale);
5738 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
5740 ret = __open_manifest_db();
5741 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Fail to open manifest DB\n");
5743 /*Start constructing query*/
5744 memset(where, '\0', MAX_QUERY_LEN);
5745 memset(query, '\0', MAX_QUERY_LEN);
5746 snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
5747 /*Get where clause*/
5748 for (list = filter->list; list; list = g_slist_next(list)) {
5749 __get_metadata_filter_condition(list->data, &condition);
5751 strncat(where, condition, sizeof(where) - strlen(where) -1);
5755 if (g_slist_next(list)) {
5756 strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
5759 _LOGE("where = %s (%d)\n", where, strlen(where));
5760 if (strlen(where) > 0) {
5761 strncat(query, where, sizeof(query) - strlen(query) - 1);
5763 _LOGE("query = %s (%d)\n", query, strlen(query));
5764 /*To get filtered list*/
5765 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5766 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5768 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5769 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5771 /*To get detail app info for each member of filtered list*/
5772 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5773 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5775 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5776 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5778 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5779 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5781 ret = sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message);
5782 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5783 memset(query, '\0', MAX_QUERY_LEN);
5785 if (info->manifest_info->uiapplication) {
5786 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5787 info->manifest_info->uiapplication = ptr1;
5789 if (info->manifest_info->serviceapplication) {
5790 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5791 info->manifest_info->serviceapplication = ptr2;
5795 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5797 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5798 ptr1->appid, "uiapp");
5799 ret = sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message);
5800 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5801 memset(query, '\0', MAX_QUERY_LEN);
5804 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5806 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5807 ptr2->appid, "svcapp");
5808 ret = sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message);
5809 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
5810 memset(query, '\0', MAX_QUERY_LEN);
5812 /*Filtered UI Apps*/
5813 if (filtinfo->manifest_info->uiapplication) {
5814 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5815 filtinfo->manifest_info->uiapplication = ptr1;
5817 /*If the callback func return < 0 we break and no more call back is called*/
5820 appinfo->locale = strdup(locale);
5821 appinfo->uiapp_info = ptr1;
5822 appinfo->app_component = PMINFO_UI_APP;
5823 ret = app_cb((void *)appinfo, user_data);
5828 /*Filtered Service Apps*/
5829 if (filtinfo->manifest_info->serviceapplication) {
5830 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5831 filtinfo->manifest_info->serviceapplication = ptr2;
5833 /*If the callback func return < 0 we break and no more call back is called*/
5836 appinfo->locale = strdup(locale);
5837 appinfo->svcapp_info = ptr2;
5838 appinfo->app_component = PMINFO_SVC_APP;
5839 ret = app_cb((void *)appinfo, user_data);
5854 sqlite3_free(error_message);
5855 sqlite3_close(manifest_db);
5860 __cleanup_pkginfo(info);
5861 __cleanup_pkginfo(filtinfo);
5865 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
5867 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5868 pkgmgr_certinfo_x *certinfo = NULL;
5869 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
5870 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
5871 *handle = (void *)certinfo;
5875 API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
5877 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
5878 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
5879 pkgmgr_certinfo_x *certinfo = NULL;
5880 char *error_message = NULL;
5881 int ret = PMINFO_R_OK;
5882 char query[MAX_QUERY_LEN] = {'\0'};
5887 ret = db_util_open_with_options(CERT_DB, &cert_db,
5888 SQLITE_OPEN_READONLY, NULL);
5889 if (ret != SQLITE_OK) {
5890 _LOGE("connect db [%s] failed!\n", CERT_DB);
5891 return PMINFO_R_ERROR;
5894 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
5896 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
5897 _LOGE("Don't execute query = %s error message = %s\n", query,
5899 sqlite3_free(error_message);
5900 ret = PMINFO_R_ERROR;
5904 _LOGE("Package not found in DB\n");
5905 ret = PMINFO_R_ERROR;
5908 certinfo = (pkgmgr_certinfo_x *)handle;
5909 /*populate certinfo from DB*/
5910 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
5911 ret = __exec_certinfo_query(query, (void *)certinfo);
5913 _LOGE("Package Cert Info DB Information retrieval failed\n");
5914 ret = PMINFO_R_ERROR;
5917 for (i = 0; i < MAX_CERT_TYPE; i++) {
5918 memset(query, '\0', MAX_QUERY_LEN);
5919 snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
5920 ret = __exec_certinfo_query(query, (void *)certinfo);
5922 _LOGE("Cert Info DB Information retrieval failed\n");
5923 ret = PMINFO_R_ERROR;
5926 if (certinfo->cert_value) {
5927 (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
5928 free(certinfo->cert_value);
5929 certinfo->cert_value = NULL;
5933 sqlite3_close(cert_db);
5937 API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
5939 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5940 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5941 retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5942 retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5943 pkgmgr_certinfo_x *certinfo = NULL;
5944 certinfo = (pkgmgr_certinfo_x *)handle;
5945 if ((certinfo->cert_info)[cert_type])
5946 *cert_value = (certinfo->cert_info)[cert_type];
5952 API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
5954 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5956 pkgmgr_certinfo_x *certinfo = NULL;
5957 certinfo = (pkgmgr_certinfo_x *)handle;
5958 if (certinfo->pkgid) {
5959 free(certinfo->pkgid);
5960 certinfo->pkgid = NULL;
5962 for (i = 0; i < MAX_CERT_TYPE; i++) {
5963 if ((certinfo->cert_info)[i]) {
5964 free((certinfo->cert_info)[i]);
5965 (certinfo->cert_info)[i] = NULL;
5973 API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
5975 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5976 pkgmgr_instcertinfo_x *certinfo = NULL;
5977 certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
5978 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
5979 *handle = (void *)certinfo;
5983 API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
5985 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5986 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5987 retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5988 retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
5989 pkgmgr_instcertinfo_x *certinfo = NULL;
5990 certinfo = (pkgmgr_instcertinfo_x *)handle;
5991 (certinfo->cert_info)[cert_type] = strdup(cert_value);
5995 API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
5997 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
5998 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
5999 char *error_message = NULL;
6000 char query[MAX_QUERY_LEN] = {'\0'};
6001 char *vquery = NULL;
6006 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
6013 pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
6014 pkgmgr_certindexinfo_x *indexinfo = NULL;
6015 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
6016 if (indexinfo == NULL) {
6017 _LOGE("Out of Memory!!!");
6018 return PMINFO_R_ERROR;
6020 info->pkgid = strdup(pkgid);
6023 ret = db_util_open_with_options(CERT_DB, &cert_db,
6024 SQLITE_OPEN_READWRITE, NULL);
6025 if (ret != SQLITE_OK) {
6026 _LOGE("connect db [%s] failed!\n", CERT_DB);
6027 ret = PMINFO_R_ERROR;
6030 /*Begin Transaction*/
6031 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6032 if (ret != SQLITE_OK) {
6033 _LOGE("Failed to begin transaction\n");
6034 ret = PMINFO_R_ERROR;
6037 _LOGE("Transaction Begin\n");
6038 /*Check if request is to insert/update*/
6039 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6041 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6042 _LOGE("Don't execute query = %s error message = %s\n", query,
6044 sqlite3_free(error_message);
6045 ret = PMINFO_R_ERROR;
6050 We cant just issue update query directly. We need to manage index table also.
6051 Hence it is better to delete and insert again in case of update*/
6052 ret = __delete_certinfo(pkgid);
6054 _LOGE("Certificate Deletion Failed\n");
6056 for (i = 0; i < MAX_CERT_TYPE; i++) {
6057 if ((info->cert_info)[i]) {
6058 for (j = 0; j < i; j++) {
6059 if ( (info->cert_info)[j]) {
6060 if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
6061 (info->cert_id)[i] = (info->cert_id)[j];
6062 (info->is_new)[i] = 0;
6063 (info->ref_count)[i] = (info->ref_count)[j];
6070 memset(query, '\0', MAX_QUERY_LEN);
6071 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
6072 "where cert_info='%s'",(info->cert_info)[i]);
6073 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
6075 _LOGE("Cert Info DB Information retrieval failed\n");
6076 ret = PMINFO_R_ERROR;
6079 if (indexinfo->cert_id == 0) {
6080 /*New certificate. Get newid*/
6081 memset(query, '\0', MAX_QUERY_LEN);
6082 snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
6084 sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
6085 _LOGE("Don't execute query = %s error message = %s\n", query,
6087 sqlite3_free(error_message);
6088 ret = PMINFO_R_ERROR;
6096 indexinfo->cert_id = maxid;
6097 indexinfo->cert_ref_count = 1;
6101 (info->cert_id)[i] = indexinfo->cert_id;
6102 (info->is_new)[i] = is_new;
6103 (info->ref_count)[i] = indexinfo->cert_ref_count;
6104 _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
6105 indexinfo->cert_id = 0;
6106 indexinfo->cert_ref_count = 0;
6110 len = MAX_QUERY_LEN;
6111 for (i = 0; i < MAX_CERT_TYPE; i++) {
6112 if ((info->cert_info)[i])
6113 len+= strlen((info->cert_info)[i]);
6115 vquery = (char *)calloc(1, len);
6117 snprintf(vquery, len,
6118 "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
6119 "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
6120 "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
6121 info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
6122 (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
6123 (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
6124 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
6125 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
6127 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6128 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6130 sqlite3_free(error_message);
6131 ret = PMINFO_R_ERROR;
6134 /*Update index table info*/
6135 /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
6136 for (i = 0; i < MAX_CERT_TYPE; i++) {
6137 if ((info->cert_info)[i]) {
6138 memset(vquery, '\0', len);
6139 if ((info->is_new)[i]) {
6140 snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
6141 "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
6142 unique_id[c++] = (info->cert_id)[i];
6145 for (j = 0; j < MAX_CERT_TYPE; j++) {
6146 if ((info->cert_id)[i] == unique_id[j]) {
6147 /*Ref count has already been increased. Just continue*/
6151 if (j == MAX_CERT_TYPE)
6152 unique_id[c++] = (info->cert_id)[i];
6155 snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
6156 "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
6159 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6160 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6162 sqlite3_free(error_message);
6163 ret = PMINFO_R_ERROR;
6168 /*Commit transaction*/
6169 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6170 if (ret != SQLITE_OK) {
6171 _LOGE("Failed to commit transaction, Rollback now\n");
6172 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6173 ret = PMINFO_R_ERROR;
6176 _LOGE("Transaction Commit and End\n");
6179 sqlite3_close(cert_db);
6191 API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
6193 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6195 pkgmgr_instcertinfo_x *certinfo = NULL;
6196 certinfo = (pkgmgr_instcertinfo_x *)handle;
6197 if (certinfo->pkgid) {
6198 free(certinfo->pkgid);
6199 certinfo->pkgid = NULL;
6201 for (i = 0; i < MAX_CERT_TYPE; i++) {
6202 if ((certinfo->cert_info)[i]) {
6203 free((certinfo->cert_info)[i]);
6204 (certinfo->cert_info)[i] = NULL;
6212 API int pkgmgrinfo_delete_certinfo(const char *pkgid)
6214 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6217 ret = db_util_open_with_options(CERT_DB, &cert_db,
6218 SQLITE_OPEN_READWRITE, NULL);
6219 if (ret != SQLITE_OK) {
6220 _LOGE("connect db [%s] failed!\n", CERT_DB);
6221 ret = PMINFO_R_ERROR;
6224 /*Begin Transaction*/
6225 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6226 if (ret != SQLITE_OK) {
6227 _LOGE("Failed to begin transaction\n");
6228 ret = PMINFO_R_ERROR;
6231 _LOGE("Transaction Begin\n");
6232 ret = __delete_certinfo(pkgid);
6234 _LOGE("Certificate Deletion Failed\n");
6236 _LOGE("Certificate Deletion Success\n");
6238 /*Commit transaction*/
6239 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6240 if (ret != SQLITE_OK) {
6241 _LOGE("Failed to commit transaction, Rollback now\n");
6242 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6243 ret = PMINFO_R_ERROR;
6246 _LOGE("Transaction Commit and End\n");
6249 sqlite3_close(cert_db);
6253 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
6255 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
6256 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6258 char *manifest = NULL;
6259 manifest_x *mfx = NULL;
6261 manifest = pkgmgr_parser_get_manifest_file(pkgid);
6262 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
6264 mfx = pkgmgr_parser_process_manifest_xml(manifest);
6269 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
6271 *handle = (void *)mfx;
6276 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
6278 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
6279 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6281 int len = strlen(type);
6282 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6284 manifest_x *mfx = (manifest_x *)handle;
6286 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
6290 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
6292 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
6293 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6295 int len = strlen(version);
6296 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6298 manifest_x *mfx = (manifest_x *)handle;
6300 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
6304 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6306 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6307 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6309 manifest_x *mfx = (manifest_x *)handle;
6311 if (location == INSTALL_INTERNAL)
6312 strcpy(mfx->installlocation, "internal-only");
6313 else if (location == INSTALL_EXTERNAL)
6314 strcpy(mfx->installlocation, "prefer-external");
6319 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
6321 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6322 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6324 manifest_x *mfx = (manifest_x *)handle;
6326 mfx->package_size = strdup(size);
6331 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
6333 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6334 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6336 int len = strlen(label_txt);
6337 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6339 manifest_x *mfx = (manifest_x *)handle;
6341 label_x *label = calloc(1, sizeof(label_x));
6342 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6344 LISTADD(mfx->label, label);
6346 mfx->label->lang = strdup(locale);
6348 mfx->label->lang = strdup(DEFAULT_LOCALE);
6349 mfx->label->text = strdup(label_txt);
6354 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
6356 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6357 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6359 int len = strlen(icon_txt);
6360 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6362 manifest_x *mfx = (manifest_x *)handle;
6364 icon_x *icon = calloc(1, sizeof(icon_x));
6365 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6367 LISTADD(mfx->icon, icon);
6369 mfx->icon->lang = strdup(locale);
6371 mfx->icon->lang = strdup(DEFAULT_LOCALE);
6372 mfx->icon->text = strdup(icon_txt);
6377 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
6379 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6380 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6382 int len = strlen(desc_txt);
6383 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6385 manifest_x *mfx = (manifest_x *)handle;
6387 description_x *description = calloc(1, sizeof(description_x));
6388 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6390 LISTADD(mfx->description, description);
6392 mfx->description->lang = strdup(locale);
6394 mfx->description->lang = strdup(DEFAULT_LOCALE);
6395 mfx->description->text = strdup(desc_txt);
6400 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
6401 const char *author_email, const char *author_href, const char *locale)
6403 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6404 manifest_x *mfx = (manifest_x *)handle;
6405 author_x *author = calloc(1, sizeof(author_x));
6406 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6408 LISTADD(mfx->author, author);
6410 mfx->author->text = strdup(author_name);
6412 mfx->author->email = strdup(author_email);
6414 mfx->author->href = strdup(author_href);
6416 mfx->author->lang = strdup(locale);
6418 mfx->author->lang = strdup(DEFAULT_LOCALE);
6422 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
6424 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6425 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6427 manifest_x *mfx = (manifest_x *)handle;
6430 strcpy(mfx->removable, "false");
6431 else if (removable == 1)
6432 strcpy(mfx->removable, "true");
6437 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
6439 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6440 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6442 manifest_x *mfx = (manifest_x *)handle;
6445 strcpy(mfx->preload, "false");
6446 else if (preload == 1)
6447 strcpy(mfx->preload, "true");
6452 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6454 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6455 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6457 manifest_x *mfx = (manifest_x *)handle;
6459 if (location == INSTALL_INTERNAL)
6460 strcpy(mfx->installed_storage, "installed_internal");
6461 else if (location == INSTALL_EXTERNAL)
6462 strcpy(mfx->installed_storage, "installed_external");
6467 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6469 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6472 manifest_x *mfx = NULL;
6473 mfx = (manifest_x *)handle;
6475 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
6477 _LOGE("Successfully stored info in DB\n");
6480 _LOGE("Failed to store info in DB\n");
6481 return PMINFO_R_ERROR;
6485 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6487 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6489 manifest_x *mfx = NULL;
6490 mfx = (manifest_x *)handle;
6491 pkgmgr_parser_free_manifest_xml(mfx);
6495 API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
6497 /* Should be implemented later */
6501 API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
6503 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6505 char query[MAX_QUERY_LEN] = {'\0'};
6506 ret = __open_manifest_db();
6508 if (access(MANIFEST_DB, F_OK) == 0) {
6509 ret = db_util_open(MANIFEST_DB, &manifest_db,
6510 DB_UTIL_REGISTER_HOOK_METHOD);
6511 if (ret != SQLITE_OK) {
6512 _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
6513 return PMINFO_R_ERROR;
6517 /*Begin transaction*/
6518 ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6519 if (ret != SQLITE_OK) {
6520 _LOGE("Failed to begin transaction\n");
6521 sqlite3_close(manifest_db);
6522 return PMINFO_R_ERROR;
6524 _LOGD("Transaction Begin\n");
6526 memset(query, '\0', MAX_QUERY_LEN);
6527 snprintf(query, MAX_QUERY_LEN,
6528 "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
6530 char *error_message = NULL;
6532 sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
6533 _LOGE("Don't execute query = %s error message = %s\n", query,
6535 sqlite3_free(error_message);
6536 return PMINFO_R_ERROR;
6538 sqlite3_free(error_message);
6540 /*Commit transaction*/
6541 ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
6542 if (ret != SQLITE_OK) {
6543 _LOGE("Failed to commit transaction. Rollback now\n");
6544 sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
6545 sqlite3_close(manifest_db);
6546 return PMINFO_R_ERROR;
6548 _LOGD("Transaction Commit and End\n");
6549 sqlite3_close(manifest_db);
6555 API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
6557 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6558 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6559 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6560 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6561 int ret = PMINFO_R_OK;
6562 char query[MAX_QUERY_LEN] = {'\0'};
6563 char *error_message = NULL;
6564 pkgmgr_datacontrol_x *data = NULL;
6566 ret = __open_datacontrol_db();
6568 _LOGE("Fail to open datacontrol DB\n");
6569 return PMINFO_R_ERROR;
6572 data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x));
6574 _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
6575 sqlite3_close(datacontrol_db);
6576 return PMINFO_R_ERROR;
6579 snprintf(query, MAX_QUERY_LEN,
6580 "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",
6584 sqlite3_exec(datacontrol_db, query, __datacontrol_cb, (void *)data, &error_message)) {
6585 _LOGE("Don't execute query = %s error message = %s\n", query,
6587 sqlite3_free(error_message);
6588 sqlite3_close(datacontrol_db);
6589 return PMINFO_R_ERROR;
6592 *appid = (char *)data->appid;
6593 *access = (char *)data->access;
6595 sqlite3_close(datacontrol_db);
6600 API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
6602 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6604 char query[MAX_QUERY_LEN] = {'\0'};
6605 char *error_message = NULL;
6606 ret = __open_manifest_db();
6608 if (access(MANIFEST_DB, F_OK) == 0) {
6609 ret = db_util_open(MANIFEST_DB, &manifest_db,
6610 DB_UTIL_REGISTER_HOOK_METHOD);
6611 if (ret != SQLITE_OK) {
6612 _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
6613 return PMINFO_R_ERROR;
6617 /*Begin transaction*/
6618 ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6619 if (ret != SQLITE_OK) {
6620 _LOGE("Failed to begin transaction\n");
6621 sqlite3_close(manifest_db);
6622 return PMINFO_R_ERROR;
6624 _LOGD("Transaction Begin\n");
6626 memset(query, '\0', MAX_QUERY_LEN);
6627 snprintf(query, MAX_QUERY_LEN,
6628 "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid);
6631 sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
6632 _LOGE("Don't execute query = %s error message = %s\n", query,
6634 sqlite3_free(error_message);
6635 return PMINFO_R_ERROR;
6638 /*Commit transaction*/
6639 ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
6640 if (ret != SQLITE_OK) {
6641 _LOGE("Failed to commit transaction. Rollback now\n");
6642 sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
6643 sqlite3_close(manifest_db);
6644 return PMINFO_R_ERROR;
6646 _LOGD("Transaction Commit and End\n");
6647 sqlite3_close(manifest_db);
6652 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
6654 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6655 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6657 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6658 val = (char *)info->uiapp_info->guestmode_visibility;
6660 if (strcasecmp(val, "true") == 0){
6662 }else if (strcasecmp(val, "false") == 0){
6671 API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
6673 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6676 char *noti_string = NULL;
6678 char query[MAX_QUERY_LEN] = {'\0'};
6679 char *errmsg = NULL;
6680 sqlite3 *pkgmgr_parser_db;
6682 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6683 val = (char *)info->uiapp_info->guestmode_visibility;
6686 db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db,
6687 SQLITE_OPEN_READWRITE, NULL);
6689 if (ret != SQLITE_OK) {
6690 _LOGE("DB Open Failed\n");
6691 return PMINFO_R_ERROR;
6694 /*TODO: Write to DB here*/
6696 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
6698 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
6700 if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
6701 _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
6703 sqlite3_close(pkgmgr_parser_db);
6704 return PMINFO_R_ERROR;
6706 sqlite3_close(pkgmgr_parser_db);
6707 len = strlen((char *)info->uiapp_info->appid) + 8;
6708 noti_string = calloc(1, len);
6709 if (noti_string == NULL){
6710 return PMINFO_R_ERROR;
6712 snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
6713 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
6714 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed