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.
35 #include <libxml/parser.h>
36 #include <libxml/xmlreader.h>
37 #include <libxml/xmlschemas.h>
39 #include <dbus/dbus.h>
40 #include <dbus/dbus-glib-lowlevel.h>
42 #include "pkgmgr_parser.h"
43 #include "pkgmgr-info-internal.h"
44 #include "pkgmgr-info-debug.h"
45 #include "pkgmgr-info.h"
46 #include "pkgmgr_parser_db.h"
54 #define LOG_TAG "PKGMGR_INFO"
56 #define ASC_CHAR(s) (const char *)s
57 #define XML_CHAR(s) (const xmlChar *)s
59 #define MANIFEST_DB "/opt/dbspace/.pkgmgr_parser.db"
60 #define MAX_QUERY_LEN 4096
61 #define MAX_CERT_TYPE 9
62 #define CERT_DB "/opt/dbspace/.pkgmgr_cert.db"
63 #define DATACONTROL_DB "/opt/usr/dbspace/.app-package.db"
64 #define PKG_TYPE_STRING_LEN_MAX 128
65 #define PKG_VERSION_STRING_LEN_MAX 128
66 #define PKG_VALUE_STRING_LEN_MAX 512
67 #define PKG_LOCALE_STRING_LEN_MAX 8
68 #define PKG_RW_PATH "/opt/usr/apps/"
69 #define PKG_RO_PATH "/usr/apps/"
70 #define BLOCK_SIZE 4096 /*in bytes*/
72 #define MMC_PATH "/opt/storage/sdcard"
73 #define PKG_SD_PATH MMC_PATH"/app2sd/"
74 #define PKG_INSTALLATION_PATH "/opt/usr/apps/"
76 #define FILTER_QUERY_COUNT_PACKAGE "select count(DISTINCT package_info.package) " \
77 "from package_info LEFT OUTER JOIN package_localized_info " \
78 "ON package_info.package=package_localized_info.package " \
79 "and package_localized_info.package_locale='%s' where "
81 #define FILTER_QUERY_LIST_PACKAGE "select DISTINCT package_info.package " \
82 "from package_info LEFT OUTER JOIN package_localized_info " \
83 "ON package_info.package=package_localized_info.package " \
84 "and package_localized_info.package_locale='%s' where "
86 #define FILTER_QUERY_COUNT_APP "select count(DISTINCT package_app_info.app_id) " \
87 "from package_app_info LEFT OUTER JOIN package_app_localized_info " \
88 "ON package_app_info.app_id=package_app_localized_info.app_id " \
89 "and package_app_localized_info.app_locale='%s' " \
90 "LEFT OUTER JOIN package_app_app_svc " \
91 "ON package_app_info.app_id=package_app_app_svc.app_id " \
92 "LEFT OUTER JOIN package_app_app_category " \
93 "ON package_app_info.app_id=package_app_app_category.app_id where "
95 #define FILTER_QUERY_LIST_APP "select DISTINCT package_app_info.app_id, package_app_info.app_component " \
96 "from package_app_info LEFT OUTER JOIN package_app_localized_info " \
97 "ON package_app_info.app_id=package_app_localized_info.app_id " \
98 "and package_app_localized_info.app_locale='%s' " \
99 "LEFT OUTER JOIN package_app_app_svc " \
100 "ON package_app_info.app_id=package_app_app_svc.app_id " \
101 "LEFT OUTER JOIN package_app_app_category " \
102 "ON package_app_info.app_id=package_app_app_category.app_id where "
104 #define METADATA_FILTER_QUERY_SELECT_CLAUSE "select DISTINCT package_app_info.app_id, package_app_info.app_component " \
105 "from package_app_info LEFT OUTER JOIN package_app_app_metadata " \
106 "ON package_app_info.app_id=package_app_app_metadata.app_id where "
108 #define METADATA_FILTER_QUERY_UNION_CLAUSE " UNION "METADATA_FILTER_QUERY_SELECT_CLAUSE
110 #define LANGUAGE_LENGTH 2
111 #define LIBAIL_PATH "/usr/lib/libail.so.0"
113 #define SERVICE_NAME "org.tizen.system.deviced"
114 #define PATH_NAME "/Org/Tizen/System/DeviceD/Mmc"
115 #define INTERFACE_NAME "org.tizen.system.deviced.Mmc"
116 #define METHOD_NAME "RequestMountApp2ext"
118 typedef struct _pkgmgr_instcertinfo_x {
120 char *cert_info[MAX_CERT_TYPE]; /*certificate data*/
121 int is_new[MAX_CERT_TYPE]; /*whether already exist in table or not*/
122 int ref_count[MAX_CERT_TYPE]; /*reference count of certificate data*/
123 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
124 } pkgmgr_instcertinfo_x;
126 typedef struct _pkgmgr_certindexinfo_x {
129 } pkgmgr_certindexinfo_x;
131 typedef struct _pkgmgr_pkginfo_x {
132 manifest_x *manifest_info;
135 struct _pkgmgr_pkginfo_x *prev;
136 struct _pkgmgr_pkginfo_x *next;
139 typedef struct _pkgmgr_cert_x {
144 typedef struct _pkgmgr_datacontrol_x {
147 } pkgmgr_datacontrol_x;
149 typedef struct _pkgmgr_iconpath_x {
154 typedef struct _pkgmgr_image_x {
158 typedef struct _pkgmgr_locale_x {
162 typedef struct _pkgmgr_appinfo_x {
165 pkgmgrinfo_app_component app_component;
167 uiapplication_x *uiapp_info;
168 serviceapplication_x *svcapp_info;
172 typedef struct _pkgmgr_certinfo_x {
175 char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
176 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
180 typedef struct _pkgmgrinfo_filter_x {
182 } pkgmgrinfo_filter_x;
184 typedef struct _pkgmgrinfo_node_x {
190 typedef struct _pkgmgrinfo_appcontrol_x {
199 } pkgmgrinfo_appcontrol_x;
201 typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
203 typedef int (*pkgmgr_handler)(int req_id, const char *pkg_type,
204 const char *pkgid, const char *key,
205 const char *val, const void *pmsg, void *data);
207 typedef void pkgmgr_client;
208 typedef void pkgmgr_info;
213 PM_REQUEST_GET_SIZE = 2,
214 PM_REQUEST_KILL_APP = 3,
215 PM_REQUEST_CHECK_APP = 4,
217 }pkgmgr_request_service_type;
220 PM_GET_TOTAL_SIZE= 0,
221 PM_GET_DATA_SIZE = 1,
223 PM_GET_SIZE_INFO = 3,
224 PM_GET_TOTAL_AND_DATA = 4,
226 }pkgmgr_getsize_type;
234 #define PKG_SIZE_INFO_FILE "/tmp/pkgmgr_size_info.txt"
235 #define MAX_PKG_BUF_LEN 1024
236 #define MAX_PKG_INFO_LEN 10
238 char *pkgtype = "rpm";
240 __thread sqlite3 *cert_db = NULL;
242 static int __exec_certinfo_query(char *query, void *data);
243 static int __exec_certindexinfo_query(char *query, void *data);
244 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname);
245 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname);
246 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname);
247 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname);
248 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname);
249 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname);
250 static int __count_cb(void *data, int ncols, char **coltxt, char **colname);
251 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
252 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
253 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname);
254 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname);
255 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data);
256 static void __cleanup_appinfo(pkgmgr_appinfo_x *data);
257 static char* __convert_system_locale_to_manifest_locale(char *syslocale);
258 static void __destroy_each_node(gpointer data, gpointer user_data);
259 static void __get_filter_condition(gpointer data, char **condition);
260 static void __get_metadata_filter_condition(gpointer data, char **condition);
261 static gint __compare_func(gconstpointer data1, gconstpointer data2);
262 static int __delete_certinfo(const char *pkgid);
264 static gint __compare_func(gconstpointer data1, gconstpointer data2)
266 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
267 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
268 if (node1->prop == node2->prop)
270 else if (node1->prop > node2->prop)
276 static int __count_cb(void *data, int ncols, char **coltxt, char **colname)
279 *p = atoi(coltxt[0]);
280 _LOGE("count value is %d\n", *p);
284 static void __destroy_each_node(gpointer data, gpointer user_data)
286 ret_if(data == NULL);
287 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
300 static void __get_metadata_filter_condition(gpointer data, char **condition)
302 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
303 char key[MAX_QUERY_LEN] = {'\0'};
304 char value[MAX_QUERY_LEN] = {'\0'};
306 snprintf(key, MAX_QUERY_LEN, "(package_app_app_metadata.md_key='%s'", node->key);
309 snprintf(value, MAX_QUERY_LEN, " AND package_app_app_metadata.md_value='%s')", node->value);
314 *condition = strdup(key);
318 static void __get_filter_condition(gpointer data, char **condition)
320 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
321 char buf[MAX_QUERY_LEN + 1] = {'\0'};
322 char temp[PKG_STRING_LEN_MAX] = {'\0'};
323 switch (node->prop) {
324 case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
325 snprintf(buf, MAX_QUERY_LEN, "package_info.package='%s'", node->value);
327 case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
328 snprintf(buf, MAX_QUERY_LEN, "package_info.package_type='%s'", node->value);
330 case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
331 snprintf(buf, MAX_QUERY_LEN, "package_info.package_version='%s'", node->value);
333 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
334 snprintf(buf, MAX_QUERY_LEN, "package_info.install_location='%s'", node->value);
336 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
337 snprintf(buf, MAX_QUERY_LEN, "package_info.installed_storage='%s'", node->value);
339 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
340 snprintf(buf, MAX_QUERY_LEN, "package_info.author_name='%s'", node->value);
342 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
343 snprintf(buf, MAX_QUERY_LEN, "package_info.author_href='%s'", node->value);
345 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
346 snprintf(buf, MAX_QUERY_LEN, "package_info.author_email='%s'", node->value);
348 case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
349 snprintf(buf, MAX_QUERY_LEN, "package_info.package_size='%s'", node->value);
351 case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
352 snprintf(buf, MAX_QUERY_LEN, "package_info.package_removable IN %s", node->value);
354 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
355 snprintf(buf, MAX_QUERY_LEN, "package_info.package_preload IN %s", node->value);
357 case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
358 snprintf(buf, MAX_QUERY_LEN, "package_info.package_readonly IN %s", node->value);
360 case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
361 snprintf(buf, MAX_QUERY_LEN, "package_info.package_update IN %s", node->value);
363 case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
364 snprintf(buf, MAX_QUERY_LEN, "package_info.package_appsetting IN %s", node->value);
366 case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
367 snprintf(buf, MAX_QUERY_LEN, "package_info.package_nodisplay IN %s", node->value);
370 case E_PMINFO_APPINFO_PROP_APP_ID:
371 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_id='%s'", node->value);
373 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
374 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_component='%s'", node->value);
376 case E_PMINFO_APPINFO_PROP_APP_EXEC:
377 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_exec='%s'", node->value);
379 case E_PMINFO_APPINFO_PROP_APP_ICON:
380 snprintf(buf, MAX_QUERY_LEN, "package_app_localized_info.app_icon='%s'", node->value);
382 case E_PMINFO_APPINFO_PROP_APP_TYPE:
383 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_type='%s'", node->value);
385 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
386 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
387 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.operation IN %s", temp);
389 case E_PMINFO_APPINFO_PROP_APP_URI:
390 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
391 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.uri_scheme IN %s", temp);
393 case E_PMINFO_APPINFO_PROP_APP_MIME:
394 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
395 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.mime_type IN %s", temp);
397 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
398 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
399 snprintf(buf, MAX_QUERY_LEN, "package_app_app_category.category IN %s", temp);
401 case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
402 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_nodisplay IN %s", node->value);
404 case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
405 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_multiple IN %s", node->value);
407 case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
408 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_onboot IN %s", node->value);
410 case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
411 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_autorestart IN %s", node->value);
413 case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
414 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_taskmanage IN %s", node->value);
416 case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
417 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_hwacceleration='%s'", node->value);
419 case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
420 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_screenreader='%s'", node->value);
422 case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
423 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
426 _LOGE("Invalid Property Type\n");
430 *condition = strdup(buf);
434 static char* __convert_system_locale_to_manifest_locale(char *syslocale)
436 if (syslocale == NULL)
437 return strdup(DEFAULT_LOCALE);
439 locale = (char *)calloc(1, 6);
440 retvm_if(!locale, NULL, "Malloc Failed\n");
442 strncpy(locale, syslocale, 2);
443 strncat(locale, "-", 1);
444 locale[3] = syslocale[3] + 32;
445 locale[4] = syslocale[4] + 32;
449 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
451 ret_if(data == NULL);
453 free((void *)data->locale);
457 pkgmgr_parser_free_manifest_xml(data->manifest_info);
463 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
465 ret_if(data == NULL);
467 free((void *)data->package);
468 data->package = NULL;
471 free((void *)data->locale);
475 manifest_x *mfx = calloc(1, sizeof(manifest_x));
476 if (data->app_component == PMINFO_UI_APP)
477 mfx->uiapplication = data->uiapp_info;
478 else if (data->app_component == PMINFO_SVC_APP)
479 mfx->serviceapplication = data->svcapp_info;
480 pkgmgr_parser_free_manifest_xml(mfx);
486 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
488 pkgmgr_pkginfo_x *udata = (pkgmgr_pkginfo_x *)data;
490 pkgmgr_pkginfo_x *info = NULL;
491 info = calloc(1, sizeof(pkgmgr_pkginfo_x));
492 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
494 LISTADD(udata, info);
495 for(i = 0; i < ncols; i++)
497 if (strcmp(colname[i], "package") == 0) {
499 info->manifest_info->package = strdup(coltxt[i]);
501 info->manifest_info->package = NULL;
509 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname)
511 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
514 uiapplication_x *uiapp = NULL;
515 serviceapplication_x *svcapp = NULL;
516 for(i = 0; i < ncols; i++)
518 if ((strcmp(colname[i], "app_component") == 0) ||
519 (strcmp(colname[i], "package_app_info.app_component") == 0)) {
521 if (strcmp(coltxt[i], "uiapp") == 0) {
522 uiapp = calloc(1, sizeof(uiapplication_x));
524 _LOGE("Out of Memory!!!\n");
527 LISTADD(info->manifest_info->uiapplication, uiapp);
528 for(j = 0; j < ncols; j++)
530 if ((strcmp(colname[j], "app_id") == 0) ||
531 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
533 info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
534 } else if (strcmp(colname[j], "package") == 0) {
536 info->manifest_info->uiapplication->package = strdup(coltxt[j]);
541 svcapp = calloc(1, sizeof(serviceapplication_x));
542 if (svcapp == NULL) {
543 _LOGE("Out of Memory!!!\n");
546 LISTADD(info->manifest_info->serviceapplication, svcapp);
547 for(j = 0; j < ncols; j++)
549 if ((strcmp(colname[j], "app_id") == 0) ||
550 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
552 info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
553 } else if (strcmp(colname[j], "package") == 0) {
555 info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
569 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
571 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
573 uiapplication_x *uiapp = NULL;
575 label_x *label = NULL;
577 uiapp = calloc(1, sizeof(uiapplication_x));
578 LISTADD(info->manifest_info->uiapplication, uiapp);
579 icon = calloc(1, sizeof(icon_x));
580 LISTADD(info->manifest_info->uiapplication->icon, icon);
581 label = calloc(1, sizeof(label_x));
582 LISTADD(info->manifest_info->uiapplication->label, label);
584 for(i = 0; i < ncols; i++)
586 if (strcmp(colname[i], "app_id") == 0) {
588 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
590 info->manifest_info->uiapplication->appid = NULL;
591 } else if (strcmp(colname[i], "app_exec") == 0) {
593 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
595 info->manifest_info->uiapplication->exec = NULL;
596 } else if (strcmp(colname[i], "app_type") == 0 ){
598 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
600 info->manifest_info->uiapplication->type = NULL;
601 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
603 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
605 info->manifest_info->uiapplication->nodisplay = NULL;
606 } else if (strcmp(colname[i], "app_multiple") == 0 ){
608 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
610 info->manifest_info->uiapplication->multiple = NULL;
611 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
613 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
615 info->manifest_info->uiapplication->taskmanage = NULL;
616 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
618 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
620 info->manifest_info->uiapplication->hwacceleration = NULL;
621 } else if (strcmp(colname[i], "app_screenreader") == 0 ){
623 info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
625 info->manifest_info->uiapplication->screenreader = NULL;
626 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
628 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
630 info->manifest_info->uiapplication->indicatordisplay = NULL;
631 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
633 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
635 info->manifest_info->uiapplication->portraitimg = NULL;
636 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
638 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
640 info->manifest_info->uiapplication->landscapeimg = NULL;
641 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
643 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
645 info->manifest_info->uiapplication->guestmode_visibility = NULL;
646 } else if (strcmp(colname[i], "package") == 0 ){
648 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
650 info->manifest_info->uiapplication->package = NULL;
651 } else if (strcmp(colname[i], "app_icon") == 0) {
653 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
655 info->manifest_info->uiapplication->icon->text = NULL;
656 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
658 info->manifest_info->uiapplication->enabled= strdup(coltxt[i]);
660 info->manifest_info->uiapplication->enabled = NULL;
661 } else if (strcmp(colname[i], "app_label") == 0 ) {
663 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
665 info->manifest_info->uiapplication->label->text = NULL;
666 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
668 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
670 info->manifest_info->uiapplication->recentimage = NULL;
671 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
673 info->manifest_info->uiapplication->mainapp = strdup(coltxt[i]);
675 info->manifest_info->uiapplication->mainapp = NULL;
676 } else if (strcmp(colname[i], "app_locale") == 0 ) {
678 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
679 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
682 info->manifest_info->uiapplication->icon->lang = NULL;
683 info->manifest_info->uiapplication->label->lang = NULL;
685 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
687 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
689 info->manifest_info->uiapplication->permission_type = NULL;
690 } else if (strcmp(colname[i], "component_type") == 0 ) {
692 info->manifest_info->uiapplication->component_type = strdup(coltxt[i]);
694 info->manifest_info->uiapplication->component_type = NULL;
695 } else if (strcmp(colname[i], "app_preload") == 0 ) {
697 info->manifest_info->uiapplication->preload = strdup(coltxt[i]);
699 info->manifest_info->uiapplication->preload = NULL;
700 } else if (strcmp(colname[i], "app_submode") == 0 ) {
702 info->manifest_info->uiapplication->submode = strdup(coltxt[i]);
704 info->manifest_info->uiapplication->submode = NULL;
705 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
707 info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[i]);
709 info->manifest_info->uiapplication->submode_mainid = NULL;
710 } else if (strcmp(colname[i], "app_installed_storage") == 0 ) {
712 info->manifest_info->uiapplication->installed_storage = strdup(coltxt[i]);
714 info->manifest_info->uiapplication->installed_storage = NULL;
721 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
723 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
725 serviceapplication_x *svcapp = NULL;
727 label_x *label = NULL;
729 svcapp = calloc(1, sizeof(serviceapplication_x));
730 LISTADD(info->manifest_info->serviceapplication, svcapp);
731 icon = calloc(1, sizeof(icon_x));
732 LISTADD(info->manifest_info->serviceapplication->icon, icon);
733 label = calloc(1, sizeof(label_x));
734 LISTADD(info->manifest_info->serviceapplication->label, label);
735 for(i = 0; i < ncols; i++)
737 if (strcmp(colname[i], "app_id") == 0) {
739 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
741 info->manifest_info->serviceapplication->appid = NULL;
742 } else if (strcmp(colname[i], "app_exec") == 0) {
744 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
746 info->manifest_info->serviceapplication->exec = NULL;
747 } else if (strcmp(colname[i], "app_type") == 0 ){
749 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
751 info->manifest_info->serviceapplication->type = NULL;
752 } else if (strcmp(colname[i], "app_onboot") == 0 ){
754 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
756 info->manifest_info->serviceapplication->onboot = NULL;
757 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
759 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
761 info->manifest_info->serviceapplication->autorestart = NULL;
762 } else if (strcmp(colname[i], "package") == 0 ){
764 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
766 info->manifest_info->serviceapplication->package = NULL;
767 } else if (strcmp(colname[i], "app_icon") == 0) {
769 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
771 info->manifest_info->serviceapplication->icon->text = NULL;
772 } else if (strcmp(colname[i], "app_label") == 0 ) {
774 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
776 info->manifest_info->serviceapplication->label->text = NULL;
777 } else if (strcmp(colname[i], "app_locale") == 0 ) {
779 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
780 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
783 info->manifest_info->serviceapplication->icon->lang = NULL;
784 info->manifest_info->serviceapplication->label->lang = NULL;
786 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
788 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
790 info->manifest_info->serviceapplication->permission_type = NULL;
797 static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
799 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
802 uiapplication_x *uiapp = NULL;
803 serviceapplication_x *svcapp = NULL;
804 for(j = 0; j < ncols; j++)
806 if (strcmp(colname[j], "app_component") == 0) {
808 if (strcmp(coltxt[j], "uiapp") == 0) {
809 uiapp = calloc(1, sizeof(uiapplication_x));
811 _LOGE("Out of Memory!!!\n");
814 LISTADD(info->manifest_info->uiapplication, uiapp);
815 for(i = 0; i < ncols; i++)
817 if (strcmp(colname[i], "app_id") == 0) {
819 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
821 info->manifest_info->uiapplication->appid = NULL;
822 } else if (strcmp(colname[i], "app_exec") == 0) {
824 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
826 info->manifest_info->uiapplication->exec = NULL;
827 } else if (strcmp(colname[i], "app_type") == 0 ){
829 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
831 info->manifest_info->uiapplication->type = NULL;
832 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
834 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
836 info->manifest_info->uiapplication->nodisplay = NULL;
837 } else if (strcmp(colname[i], "app_multiple") == 0 ){
839 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
841 info->manifest_info->uiapplication->multiple = NULL;
842 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
844 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
846 info->manifest_info->uiapplication->taskmanage = NULL;
847 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
849 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
851 info->manifest_info->uiapplication->hwacceleration = NULL;
852 } else if (strcmp(colname[i], "app_screenreader") == 0 ){
854 info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
856 info->manifest_info->uiapplication->screenreader = NULL;
857 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
859 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
861 info->manifest_info->uiapplication->indicatordisplay = NULL;
862 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
864 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
866 info->manifest_info->uiapplication->portraitimg = NULL;
867 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
869 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
871 info->manifest_info->uiapplication->landscapeimg = NULL;
872 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
874 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
876 info->manifest_info->uiapplication->guestmode_visibility = NULL;
877 } else if (strcmp(colname[i], "package") == 0 ){
879 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
881 info->manifest_info->uiapplication->package = NULL;
882 } else if (strcmp(colname[i], "app_icon") == 0) {
884 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
886 info->manifest_info->uiapplication->icon->text = NULL;
887 } else if (strcmp(colname[i], "app_label") == 0 ) {
889 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
891 info->manifest_info->uiapplication->label->text = NULL;
892 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
894 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
896 info->manifest_info->uiapplication->recentimage = NULL;
897 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
899 info->manifest_info->uiapplication->mainapp= strdup(coltxt[i]);
901 info->manifest_info->uiapplication->mainapp = NULL;
902 } else if (strcmp(colname[i], "app_locale") == 0 ) {
904 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
905 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
908 info->manifest_info->uiapplication->icon->lang = NULL;
909 info->manifest_info->uiapplication->label->lang = NULL;
911 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
913 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
915 info->manifest_info->uiapplication->permission_type = NULL;
920 svcapp = calloc(1, sizeof(serviceapplication_x));
921 if (svcapp == NULL) {
922 _LOGE("Out of Memory!!!\n");
925 LISTADD(info->manifest_info->serviceapplication, svcapp);
926 for(i = 0; i < ncols; i++)
928 if (strcmp(colname[i], "app_id") == 0) {
930 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
932 info->manifest_info->serviceapplication->appid = NULL;
933 } else if (strcmp(colname[i], "app_exec") == 0) {
935 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
937 info->manifest_info->serviceapplication->exec = NULL;
938 } else if (strcmp(colname[i], "app_type") == 0 ){
940 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
942 info->manifest_info->serviceapplication->type = NULL;
943 } else if (strcmp(colname[i], "app_onboot") == 0 ){
945 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
947 info->manifest_info->serviceapplication->onboot = NULL;
948 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
950 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
952 info->manifest_info->serviceapplication->autorestart = NULL;
953 } else if (strcmp(colname[i], "package") == 0 ){
955 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
957 info->manifest_info->serviceapplication->package = NULL;
958 } else if (strcmp(colname[i], "app_icon") == 0) {
960 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
962 info->manifest_info->serviceapplication->icon->text = NULL;
963 } else if (strcmp(colname[i], "app_label") == 0 ) {
965 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
967 info->manifest_info->serviceapplication->label->text = NULL;
968 } else if (strcmp(colname[i], "app_locale") == 0 ) {
970 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
971 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
974 info->manifest_info->serviceapplication->icon->lang = NULL;
975 info->manifest_info->serviceapplication->label->lang = NULL;
977 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
979 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
981 info->manifest_info->serviceapplication->permission_type = NULL;
996 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname)
999 *p = atoi(coltxt[0]);
1003 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname)
1005 int *p = (int*)data;
1007 *p = atoi(coltxt[0]);
1011 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
1013 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
1015 author_x *author = NULL;
1016 icon_x *icon = NULL;
1017 label_x *label = NULL;
1018 description_x *description = NULL;
1019 privilege_x *privilege = NULL;
1021 author = calloc(1, sizeof(author_x));
1022 LISTADD(info->manifest_info->author, author);
1023 icon = calloc(1, sizeof(icon_x));
1024 LISTADD(info->manifest_info->icon, icon);
1025 label = calloc(1, sizeof(label_x));
1026 LISTADD(info->manifest_info->label, label);
1027 description = calloc(1, sizeof(description_x));
1028 LISTADD(info->manifest_info->description, description);
1029 privilege = calloc(1, sizeof(privilege_x));
1030 LISTADD(info->manifest_info->privileges->privilege, privilege);
1031 for(i = 0; i < ncols; i++)
1033 if (strcmp(colname[i], "package_version") == 0) {
1035 info->manifest_info->version = strdup(coltxt[i]);
1037 info->manifest_info->version = NULL;
1038 } else if (strcmp(colname[i], "package_type") == 0) {
1040 info->manifest_info->type = strdup(coltxt[i]);
1042 info->manifest_info->type = NULL;
1043 } else if (strcmp(colname[i], "install_location") == 0) {
1045 info->manifest_info->installlocation = strdup(coltxt[i]);
1047 info->manifest_info->installlocation = NULL;
1048 } else if (strcmp(colname[i], "package_size") == 0) {
1050 info->manifest_info->package_size = strdup(coltxt[i]);
1052 info->manifest_info->package_size = NULL;
1053 } else if (strcmp(colname[i], "author_email") == 0 ){
1055 info->manifest_info->author->email = strdup(coltxt[i]);
1057 info->manifest_info->author->email = NULL;
1058 } else if (strcmp(colname[i], "author_href") == 0 ){
1060 info->manifest_info->author->href = strdup(coltxt[i]);
1062 info->manifest_info->author->href = NULL;
1063 } else if (strcmp(colname[i], "package_label") == 0 ){
1065 info->manifest_info->label->text = strdup(coltxt[i]);
1067 info->manifest_info->label->text = NULL;
1068 } else if (strcmp(colname[i], "package_icon") == 0 ){
1070 info->manifest_info->icon->text = strdup(coltxt[i]);
1072 info->manifest_info->icon->text = NULL;
1073 } else if (strcmp(colname[i], "package_description") == 0 ){
1075 info->manifest_info->description->text = strdup(coltxt[i]);
1077 info->manifest_info->description->text = NULL;
1078 } else if (strcmp(colname[i], "package_author") == 0 ){
1080 info->manifest_info->author->text = strdup(coltxt[i]);
1082 info->manifest_info->author->text = NULL;
1083 } else if (strcmp(colname[i], "package_removable") == 0 ){
1085 info->manifest_info->removable = strdup(coltxt[i]);
1087 info->manifest_info->removable = NULL;
1088 } else if (strcmp(colname[i], "package_preload") == 0 ){
1090 info->manifest_info->preload = strdup(coltxt[i]);
1092 info->manifest_info->preload = NULL;
1093 } else if (strcmp(colname[i], "package_readonly") == 0 ){
1095 info->manifest_info->readonly = strdup(coltxt[i]);
1097 info->manifest_info->readonly = NULL;
1098 } else if (strcmp(colname[i], "package_update") == 0 ){
1100 info->manifest_info->update= strdup(coltxt[i]);
1102 info->manifest_info->update = NULL;
1103 } else if (strcmp(colname[i], "package_system") == 0 ){
1105 info->manifest_info->system= strdup(coltxt[i]);
1107 info->manifest_info->system = NULL;
1108 } else if (strcmp(colname[i], "package_appsetting") == 0 ){
1110 info->manifest_info->appsetting = strdup(coltxt[i]);
1112 info->manifest_info->appsetting = NULL;
1113 } else if (strcmp(colname[i], "installed_time") == 0 ){
1115 info->manifest_info->installed_time = strdup(coltxt[i]);
1117 info->manifest_info->installed_time = NULL;
1118 } else if (strcmp(colname[i], "installed_storage") == 0 ){
1120 info->manifest_info->installed_storage = strdup(coltxt[i]);
1122 info->manifest_info->installed_storage = NULL;
1123 } else if (strcmp(colname[i], "mainapp_id") == 0 ){
1125 info->manifest_info->mainapp_id = strdup(coltxt[i]);
1127 info->manifest_info->mainapp_id = NULL;
1128 } else if (strcmp(colname[i], "storeclient_id") == 0 ){
1130 info->manifest_info->storeclient_id = strdup(coltxt[i]);
1132 info->manifest_info->storeclient_id = NULL;
1133 } else if (strcmp(colname[i], "root_path") == 0 ){
1135 info->manifest_info->root_path = strdup(coltxt[i]);
1137 info->manifest_info->root_path = NULL;
1138 } else if (strcmp(colname[i], "csc_path") == 0 ){
1140 info->manifest_info->csc_path = strdup(coltxt[i]);
1142 info->manifest_info->csc_path = NULL;
1143 } else if (strcmp(colname[i], "privilege") == 0 ){
1145 info->manifest_info->privileges->privilege->text = strdup(coltxt[i]);
1147 info->manifest_info->privileges->privilege->text = NULL;
1148 } else if (strcmp(colname[i], "package_locale") == 0 ){
1150 info->manifest_info->author->lang = strdup(coltxt[i]);
1151 info->manifest_info->icon->lang = strdup(coltxt[i]);
1152 info->manifest_info->label->lang = strdup(coltxt[i]);
1153 info->manifest_info->description->lang = strdup(coltxt[i]);
1156 info->manifest_info->author->lang = NULL;
1157 info->manifest_info->icon->lang = NULL;
1158 info->manifest_info->label->lang = NULL;
1159 info->manifest_info->description->lang = NULL;
1161 } else if (strcmp(colname[i], "package_url") == 0 ){
1163 info->manifest_info->package_url = strdup(coltxt[i]);
1165 info->manifest_info->package_url = NULL;
1173 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1175 if ( strcasecmp(comp, "uiapp") == 0)
1176 return PMINFO_UI_APP;
1177 else if ( strcasecmp(comp, "svcapp") == 0)
1178 return PMINFO_SVC_APP;
1183 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1185 pkgmgr_certindexinfo_x *info = (pkgmgr_certindexinfo_x *)data;
1187 for(i = 0; i < ncols; i++) {
1188 if (strcmp(colname[i], "cert_id") == 0) {
1190 info->cert_id = atoi(coltxt[i]);
1193 } else if (strcmp(colname[i], "cert_ref_count") == 0) {
1195 info->cert_ref_count = atoi(coltxt[i]);
1197 info->cert_ref_count = 0;
1203 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1205 pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)data;
1207 for(i = 0; i < ncols; i++)
1209 if (strcmp(colname[i], "package") == 0) {
1211 info->pkgid = strdup(coltxt[i]);
1214 } else if (strcmp(colname[i], "author_signer_cert") == 0) {
1216 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = atoi(coltxt[i]);
1218 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = 0;
1219 } else if (strcmp(colname[i], "author_im_cert") == 0) {
1221 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1223 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 0;
1224 } else if (strcmp(colname[i], "author_root_cert") == 0) {
1226 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = atoi(coltxt[i]);
1228 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = 0;
1229 } else if (strcmp(colname[i], "dist_signer_cert") == 0 ){
1231 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = atoi(coltxt[i]);
1233 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 0;
1234 } else if (strcmp(colname[i], "dist_im_cert") == 0 ){
1236 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1238 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 0;
1239 } else if (strcmp(colname[i], "dist_root_cert") == 0 ){
1241 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = atoi(coltxt[i]);
1243 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = 0;
1244 } else if (strcmp(colname[i], "dist2_signer_cert") == 0 ){
1246 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = atoi(coltxt[i]);
1248 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 0;
1249 } else if (strcmp(colname[i], "dist2_im_cert") == 0 ){
1251 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1253 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 0;
1254 } else if (strcmp(colname[i], "dist2_root_cert") == 0 ){
1256 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = atoi(coltxt[i]);
1258 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 0;
1259 } else if (strcmp(colname[i], "cert_info") == 0 ){
1261 info->cert_value = strdup(coltxt[i]);
1263 info->cert_value = NULL;
1270 static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1272 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
1275 uiapplication_x *uiapp = NULL;
1276 serviceapplication_x *svcapp = NULL;
1277 for(i = 0; i < ncols; i++)
1279 if (strcmp(colname[i], "app_component") == 0) {
1281 if (strcmp(coltxt[i], "uiapp") == 0) {
1282 uiapp = calloc(1, sizeof(uiapplication_x));
1283 if (uiapp == NULL) {
1284 _LOGE("Out of Memory!!!\n");
1287 LISTADD(info->manifest_info->uiapplication, uiapp);
1288 for(j = 0; j < ncols; j++)
1290 if (strcmp(colname[j], "app_id") == 0) {
1292 info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
1293 } else if (strcmp(colname[j], "app_exec") == 0) {
1295 info->manifest_info->uiapplication->exec = strdup(coltxt[j]);
1297 info->manifest_info->uiapplication->exec = NULL;
1298 } else if (strcmp(colname[j], "app_nodisplay") == 0) {
1300 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[j]);
1302 info->manifest_info->uiapplication->nodisplay = NULL;
1303 } else if (strcmp(colname[j], "app_type") == 0 ) {
1305 info->manifest_info->uiapplication->type = strdup(coltxt[j]);
1307 info->manifest_info->uiapplication->type = NULL;
1308 } else if (strcmp(colname[j], "app_multiple") == 0 ) {
1310 info->manifest_info->uiapplication->multiple = strdup(coltxt[j]);
1312 info->manifest_info->uiapplication->multiple = NULL;
1313 } else if (strcmp(colname[j], "app_taskmanage") == 0 ) {
1315 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[j]);
1317 info->manifest_info->uiapplication->taskmanage = NULL;
1318 } else if (strcmp(colname[j], "app_hwacceleration") == 0 ) {
1320 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[j]);
1322 info->manifest_info->uiapplication->hwacceleration = NULL;
1323 } else if (strcmp(colname[j], "app_screenreader") == 0 ) {
1325 info->manifest_info->uiapplication->screenreader = strdup(coltxt[j]);
1327 info->manifest_info->uiapplication->screenreader = NULL;
1328 } else if (strcmp(colname[j], "app_enabled") == 0 ) {
1330 info->manifest_info->uiapplication->enabled= strdup(coltxt[j]);
1332 info->manifest_info->uiapplication->enabled = NULL;
1333 } else if (strcmp(colname[j], "app_indicatordisplay") == 0){
1335 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[j]);
1337 info->manifest_info->uiapplication->indicatordisplay = NULL;
1338 } else if (strcmp(colname[j], "app_portraitimg") == 0){
1340 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[j]);
1342 info->manifest_info->uiapplication->portraitimg = NULL;
1343 } else if (strcmp(colname[j], "app_landscapeimg") == 0){
1345 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[j]);
1347 info->manifest_info->uiapplication->landscapeimg = NULL;
1348 } else if (strcmp(colname[j], "app_guestmodevisibility") == 0){
1350 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[j]);
1352 info->manifest_info->uiapplication->guestmode_visibility = NULL;
1353 } else if (strcmp(colname[j], "app_recentimage") == 0 ) {
1355 info->manifest_info->uiapplication->recentimage = strdup(coltxt[j]);
1357 info->manifest_info->uiapplication->recentimage = NULL;
1358 } else if (strcmp(colname[j], "app_mainapp") == 0 ) {
1360 info->manifest_info->uiapplication->mainapp = strdup(coltxt[j]);
1362 info->manifest_info->uiapplication->mainapp = NULL;
1363 } else if (strcmp(colname[j], "package") == 0 ) {
1365 info->manifest_info->uiapplication->package = strdup(coltxt[j]);
1367 info->manifest_info->uiapplication->package = NULL;
1368 } else if (strcmp(colname[j], "app_component") == 0) {
1370 info->manifest_info->uiapplication->app_component = strdup(coltxt[j]);
1372 info->manifest_info->uiapplication->app_component = NULL;
1373 } else if (strcmp(colname[j], "app_permissiontype") == 0 ) {
1375 info->manifest_info->uiapplication->permission_type = strdup(coltxt[j]);
1377 info->manifest_info->uiapplication->permission_type = NULL;
1378 } else if (strcmp(colname[j], "component_type") == 0 ) {
1380 info->manifest_info->uiapplication->component_type = strdup(coltxt[j]);
1382 info->manifest_info->uiapplication->component_type = NULL;
1383 } else if (strcmp(colname[j], "app_preload") == 0 ) {
1385 info->manifest_info->uiapplication->preload = strdup(coltxt[j]);
1387 info->manifest_info->uiapplication->preload = NULL;
1388 } else if (strcmp(colname[j], "app_submode") == 0 ) {
1390 info->manifest_info->uiapplication->submode = strdup(coltxt[j]);
1392 info->manifest_info->uiapplication->submode = NULL;
1393 } else if (strcmp(colname[j], "app_submode_mainid") == 0 ) {
1395 info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[j]);
1397 info->manifest_info->uiapplication->submode_mainid = NULL;
1398 } else if (strcmp(colname[j], "app_installed_storage") == 0 ) {
1400 info->manifest_info->uiapplication->installed_storage = strdup(coltxt[j]);
1402 info->manifest_info->uiapplication->installed_storage = NULL;
1407 svcapp = calloc(1, sizeof(serviceapplication_x));
1408 if (svcapp == NULL) {
1409 _LOGE("Out of Memory!!!\n");
1412 LISTADD(info->manifest_info->serviceapplication, svcapp);
1413 for(j = 0; j < ncols; j++)
1415 if (strcmp(colname[j], "app_id") == 0) {
1417 info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
1418 } else if (strcmp(colname[j], "app_exec") == 0) {
1420 info->manifest_info->serviceapplication->exec = strdup(coltxt[j]);
1422 info->manifest_info->serviceapplication->exec = NULL;
1423 } else if (strcmp(colname[j], "app_type") == 0 ){
1425 info->manifest_info->serviceapplication->type = strdup(coltxt[j]);
1427 info->manifest_info->serviceapplication->type = NULL;
1428 } else if (strcmp(colname[j], "app_onboot") == 0 ){
1430 info->manifest_info->serviceapplication->onboot = strdup(coltxt[j]);
1432 info->manifest_info->serviceapplication->onboot = NULL;
1433 } else if (strcmp(colname[j], "app_autorestart") == 0 ){
1435 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[j]);
1437 info->manifest_info->serviceapplication->autorestart = NULL;
1438 } else if (strcmp(colname[j], "package") == 0 ){
1440 info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
1442 info->manifest_info->serviceapplication->package = NULL;
1443 } else if (strcmp(colname[j], "app_permissiontype") == 0 ) {
1445 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[j]);
1447 info->manifest_info->serviceapplication->permission_type = NULL;
1460 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1462 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1464 icon_x *icon = NULL;
1465 label_x *label = NULL;
1466 category_x *category = NULL;
1467 metadata_x *metadata = NULL;
1468 permission_x *permission = NULL;
1469 image_x *image = NULL;
1471 switch (info->app_component) {
1473 icon = calloc(1, sizeof(icon_x));
1474 LISTADD(info->uiapp_info->icon, icon);
1475 label = calloc(1, sizeof(label_x));
1476 LISTADD(info->uiapp_info->label, label);
1477 category = calloc(1, sizeof(category_x));
1478 LISTADD(info->uiapp_info->category, category);
1479 metadata = calloc(1, sizeof(metadata_x));
1480 LISTADD(info->uiapp_info->metadata, metadata);
1481 permission = calloc(1, sizeof(permission_x));
1482 LISTADD(info->uiapp_info->permission, permission);
1483 image = calloc(1, sizeof(image_x));
1484 LISTADD(info->uiapp_info->image, image);
1486 for(i = 0; i < ncols; i++)
1488 if (strcmp(colname[i], "app_id") == 0) {
1489 /*appid being foreign key, is column in every table
1490 Hence appid gets strduped every time leading to memory leak.
1491 If appid is already set, just continue.*/
1492 if (info->uiapp_info->appid)
1495 info->uiapp_info->appid = strdup(coltxt[i]);
1497 info->uiapp_info->appid = NULL;
1498 } else if (strcmp(colname[i], "app_exec") == 0) {
1500 info->uiapp_info->exec = strdup(coltxt[i]);
1502 info->uiapp_info->exec = NULL;
1503 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1505 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1507 info->uiapp_info->nodisplay = NULL;
1508 } else if (strcmp(colname[i], "app_type") == 0 ) {
1510 info->uiapp_info->type = strdup(coltxt[i]);
1512 info->uiapp_info->type = NULL;
1513 } else if (strcmp(colname[i], "app_icon_section") == 0 ) {
1515 info->uiapp_info->icon->section= strdup(coltxt[i]);
1517 info->uiapp_info->icon->section = NULL;
1518 } else if (strcmp(colname[i], "app_icon") == 0) {
1520 info->uiapp_info->icon->text = strdup(coltxt[i]);
1522 info->uiapp_info->icon->text = NULL;
1523 } else if (strcmp(colname[i], "app_label") == 0 ) {
1525 info->uiapp_info->label->text = strdup(coltxt[i]);
1527 info->uiapp_info->label->text = NULL;
1528 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1530 info->uiapp_info->multiple = strdup(coltxt[i]);
1532 info->uiapp_info->multiple = NULL;
1533 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1535 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1537 info->uiapp_info->taskmanage = NULL;
1538 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1540 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1542 info->uiapp_info->hwacceleration = NULL;
1543 } else if (strcmp(colname[i], "app_screenreader") == 0 ) {
1545 info->uiapp_info->screenreader = strdup(coltxt[i]);
1547 info->uiapp_info->screenreader = NULL;
1548 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1550 info->uiapp_info->enabled= strdup(coltxt[i]);
1552 info->uiapp_info->enabled = NULL;
1553 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
1555 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
1557 info->uiapp_info->indicatordisplay = NULL;
1558 } else if (strcmp(colname[i], "app_portraitimg") == 0){
1560 info->uiapp_info->portraitimg = strdup(coltxt[i]);
1562 info->uiapp_info->portraitimg = NULL;
1563 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
1565 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
1567 info->uiapp_info->landscapeimg = NULL;
1568 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
1570 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
1572 info->uiapp_info->guestmode_visibility = NULL;
1573 } else if (strcmp(colname[i], "category") == 0 ) {
1575 info->uiapp_info->category->name = strdup(coltxt[i]);
1577 info->uiapp_info->category->name = NULL;
1578 } else if (strcmp(colname[i], "md_key") == 0 ) {
1580 info->uiapp_info->metadata->key = strdup(coltxt[i]);
1582 info->uiapp_info->metadata->key = NULL;
1583 } else if (strcmp(colname[i], "md_value") == 0 ) {
1585 info->uiapp_info->metadata->value = strdup(coltxt[i]);
1587 info->uiapp_info->metadata->value = NULL;
1588 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1590 info->uiapp_info->permission->type= strdup(coltxt[i]);
1592 info->uiapp_info->permission->type = NULL;
1593 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1595 info->uiapp_info->permission->value = strdup(coltxt[i]);
1597 info->uiapp_info->permission->value = NULL;
1598 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1600 info->uiapp_info->recentimage = strdup(coltxt[i]);
1602 info->uiapp_info->recentimage = NULL;
1603 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1605 info->uiapp_info->mainapp = strdup(coltxt[i]);
1607 info->uiapp_info->mainapp = NULL;
1608 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1610 info->uiapp_info->icon->lang = strdup(coltxt[i]);
1611 info->uiapp_info->label->lang = strdup(coltxt[i]);
1614 info->uiapp_info->icon->lang = NULL;
1615 info->uiapp_info->label->lang = NULL;
1617 } else if (strcmp(colname[i], "app_image") == 0) {
1619 info->uiapp_info->image->text= strdup(coltxt[i]);
1621 info->uiapp_info->image->text = NULL;
1622 } else if (strcmp(colname[i], "app_image_section") == 0) {
1624 info->uiapp_info->image->section= strdup(coltxt[i]);
1626 info->uiapp_info->image->section = NULL;
1627 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1629 info->uiapp_info->permission_type = strdup(coltxt[i]);
1631 info->uiapp_info->permission_type = NULL;
1632 } else if (strcmp(colname[i], "component_type") == 0 ) {
1634 info->uiapp_info->component_type = strdup(coltxt[i]);
1636 info->uiapp_info->component_type = NULL;
1637 } else if (strcmp(colname[i], "app_preload") == 0 ) {
1639 info->uiapp_info->preload = strdup(coltxt[i]);
1641 info->uiapp_info->preload = NULL;
1642 } else if (strcmp(colname[i], "app_submode") == 0 ) {
1644 info->uiapp_info->submode = strdup(coltxt[i]);
1646 info->uiapp_info->submode = NULL;
1647 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
1649 info->uiapp_info->submode_mainid = strdup(coltxt[i]);
1651 info->uiapp_info->submode_mainid = NULL;
1652 } else if (strcmp(colname[i], "app_installed_storage") == 0 ) {
1654 info->uiapp_info->installed_storage = strdup(coltxt[i]);
1656 info->uiapp_info->installed_storage = NULL;
1661 case PMINFO_SVC_APP:
1662 icon = calloc(1, sizeof(icon_x));
1663 LISTADD(info->svcapp_info->icon, icon);
1664 label = calloc(1, sizeof(label_x));
1665 LISTADD(info->svcapp_info->label, label);
1666 category = calloc(1, sizeof(category_x));
1667 LISTADD(info->svcapp_info->category, category);
1668 metadata = calloc(1, sizeof(metadata_x));
1669 LISTADD(info->svcapp_info->metadata, metadata);
1670 permission = calloc(1, sizeof(permission_x));
1671 LISTADD(info->svcapp_info->permission, permission);
1672 for(i = 0; i < ncols; i++)
1674 if (strcmp(colname[i], "app_id") == 0) {
1675 /*appid being foreign key, is column in every table
1676 Hence appid gets strduped every time leading to memory leak.
1677 If appid is already set, just continue.*/
1678 if (info->svcapp_info->appid)
1681 info->svcapp_info->appid = strdup(coltxt[i]);
1683 info->svcapp_info->appid = NULL;
1684 } else if (strcmp(colname[i], "app_exec") == 0) {
1686 info->svcapp_info->exec = strdup(coltxt[i]);
1688 info->svcapp_info->exec = NULL;
1689 } else if (strcmp(colname[i], "app_icon") == 0) {
1691 info->svcapp_info->icon->text = strdup(coltxt[i]);
1693 info->svcapp_info->icon->text = NULL;
1694 } else if (strcmp(colname[i], "app_label") == 0 ) {
1696 info->svcapp_info->label->text = strdup(coltxt[i]);
1698 info->svcapp_info->label->text = NULL;
1699 } else if (strcmp(colname[i], "app_type") == 0 ) {
1701 info->svcapp_info->type = strdup(coltxt[i]);
1703 info->svcapp_info->type = NULL;
1704 } else if (strcmp(colname[i], "app_onboot") == 0 ) {
1706 info->svcapp_info->onboot = strdup(coltxt[i]);
1708 info->svcapp_info->onboot = NULL;
1709 } else if (strcmp(colname[i], "app_autorestart") == 0 ) {
1711 info->svcapp_info->autorestart = strdup(coltxt[i]);
1713 info->svcapp_info->autorestart = NULL;
1714 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1716 info->svcapp_info->enabled= strdup(coltxt[i]);
1718 info->svcapp_info->enabled = NULL;
1719 } else if (strcmp(colname[i], "category") == 0 ) {
1721 info->svcapp_info->category->name = strdup(coltxt[i]);
1723 info->svcapp_info->category->name = NULL;
1724 } else if (strcmp(colname[i], "md_key") == 0 ) {
1726 info->svcapp_info->metadata->key = strdup(coltxt[i]);
1728 info->svcapp_info->metadata->key = NULL;
1729 } else if (strcmp(colname[i], "md_value") == 0 ) {
1731 info->svcapp_info->metadata->value = strdup(coltxt[i]);
1733 info->svcapp_info->metadata->value = NULL;
1734 } else if (strcmp(colname[i], "pm_type") == 0 ) {
1736 info->svcapp_info->permission->type= strdup(coltxt[i]);
1738 info->svcapp_info->permission->type = NULL;
1739 } else if (strcmp(colname[i], "pm_value") == 0 ) {
1741 info->svcapp_info->permission->value = strdup(coltxt[i]);
1743 info->svcapp_info->permission->value = NULL;
1744 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1746 info->svcapp_info->icon->lang = strdup(coltxt[i]);
1747 info->svcapp_info->label->lang = strdup(coltxt[i]);
1750 info->svcapp_info->icon->lang = NULL;
1751 info->svcapp_info->label->lang = NULL;
1753 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1755 info->svcapp_info->permission_type = strdup(coltxt[i]);
1757 info->svcapp_info->permission_type = NULL;
1770 static int __appcomponent_cb(void *data, int ncols, char **coltxt, char **colname)
1772 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1774 for(i = 0; i < ncols; i++)
1776 if (strcmp(colname[i], "app_component") == 0) {
1777 info->app_component = __appcomponent_convert(coltxt[i]);
1778 } else if (strcmp(colname[i], "package") == 0) {
1779 info->package = strdup(coltxt[i]);
1786 static int __datacontrol_cb(void *data, int ncols, char **coltxt, char **colname)
1788 pkgmgr_datacontrol_x *info = (pkgmgr_datacontrol_x *)data;
1790 for(i = 0; i < ncols; i++)
1792 if (strcmp(colname[i], "PACKAGE_NAME") == 0) {
1794 info->appid = strdup(coltxt[i]);
1797 } else if (strcmp(colname[i], "ACCESS") == 0 ){
1799 info->access = strdup(coltxt[i]);
1801 info->access = NULL;
1808 static int __cert_cb(void *data, int ncols, char **coltxt, char **colname)
1810 pkgmgr_cert_x *info = (pkgmgr_cert_x *)data;
1813 for(i = 0; i < ncols; i++)
1815 if (strcmp(colname[i], "author_signer_cert") == 0) {
1817 info->cert_id = atoi(coltxt[i]);
1820 } else if (strcmp(colname[i], "package") == 0) {
1822 info->pkgid= strdup(coltxt[i]);
1831 /* get the first locale value*/
1832 static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
1834 pkgmgr_locale_x *info = (pkgmgr_locale_x *)data;
1837 info->locale = strdup(coltxt[0]);
1839 info->locale = NULL;
1844 static int __exec_certinfo_query(char *query, void *data)
1846 char *error_message = NULL;
1848 sqlite3_exec(cert_db, query, __certinfo_cb, data, &error_message)) {
1849 _LOGE("Don't execute query = %s error message = %s\n", query,
1851 sqlite3_free(error_message);
1854 sqlite3_free(error_message);
1858 static int __exec_certindexinfo_query(char *query, void *data)
1860 char *error_message = NULL;
1862 sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
1863 _LOGE("Don't execute query = %s error message = %s\n", query,
1865 sqlite3_free(error_message);
1868 sqlite3_free(error_message);
1872 static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data)
1874 char *error_message = NULL;
1876 sqlite3_exec(db, query, callback, data, &error_message)) {
1877 _LOGE("Don't execute query = %s error message = %s\n", query,
1879 sqlite3_free(error_message);
1882 sqlite3_free(error_message);
1887 static int __child_element(xmlTextReaderPtr reader, int depth)
1889 int ret = xmlTextReaderRead(reader);
1890 int cur = xmlTextReaderDepth(reader);
1893 switch (xmlTextReaderNodeType(reader)) {
1894 case XML_READER_TYPE_ELEMENT:
1895 if (cur == depth + 1)
1898 case XML_READER_TYPE_TEXT:
1899 /*text is handled by each function separately*/
1900 if (cur == depth + 1)
1903 case XML_READER_TYPE_END_ELEMENT:
1912 ret = xmlTextReaderRead(reader);
1913 cur = xmlTextReaderDepth(reader);
1918 static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, char **colname)
1920 int *p = (int*)data;
1921 *p = atoi(coltxt[0]);
1925 static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale)
1927 int result_query = -1;
1929 char query[MAX_QUERY_LEN];
1931 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);
1932 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1933 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1934 return result_query;
1937 static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1939 int result_query = -1;
1941 char wildcard[2] = {'%','\0'};
1942 char query[MAX_QUERY_LEN];
1943 char lang[3] = {'\0'};
1944 strncpy(lang, locale, LANGUAGE_LENGTH);
1946 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);
1947 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
1948 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1949 return result_query;
1952 static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
1955 char wildcard[2] = {'%','\0'};
1956 char lang[3] = {'\0'};
1957 char query[MAX_QUERY_LEN];
1958 char *locale_new = NULL;
1959 pkgmgr_locale_x *info = NULL;
1961 info = (pkgmgr_locale_x *)malloc(sizeof(pkgmgr_locale_x));
1963 _LOGE("Out of Memory!!!\n");
1966 memset(info, '\0', sizeof(*info));
1968 strncpy(lang, locale, 2);
1969 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);
1970 ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
1971 tryvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
1972 locale_new = info->locale;
1983 static char* __convert_syslocale_to_manifest_locale(char *syslocale)
1985 char *locale = malloc(6);
1987 _LOGE("Malloc Failed\n");
1991 sprintf(locale, "%c%c-%c%c", syslocale[0], syslocale[1], tolower(syslocale[3]), tolower(syslocale[4]));
1995 static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const char *syslocale)
2000 char *locale = NULL;
2001 char *locale_new = NULL;
2002 int check_result = 0;
2004 locale = __convert_syslocale_to_manifest_locale((char *)syslocale);
2006 /*check exact matching */
2007 check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale);
2010 if (check_result == 1) {
2011 // _LOGD("%s find exact locale(%s)\n", appid, locale);
2015 /* fallback matching */
2016 check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
2017 if(check_result == 1) {
2018 locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
2020 if (locale_new == NULL)
2021 locale_new = strdup(DEFAULT_LOCALE);
2025 /* default locale */
2027 return strdup(DEFAULT_LOCALE);
2030 static int __delete_certinfo(const char *pkgid)
2036 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
2037 char *error_message = NULL;
2038 char query[MAX_QUERY_LEN] = {'\0'};
2039 pkgmgr_certinfo_x *certinfo = NULL;
2040 pkgmgr_certindexinfo_x *indexinfo = NULL;
2041 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
2042 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
2043 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
2044 if (indexinfo == NULL) {
2045 _LOGE("Out of Memory!!!");
2046 ret = PMINFO_R_ERROR;
2049 /*populate certinfo from DB*/
2050 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
2051 ret = __exec_certinfo_query(query, (void *)certinfo);
2053 _LOGE("Package Cert Info DB Information retrieval failed\n");
2054 ret = PMINFO_R_ERROR;
2057 /*Update cert index table*/
2058 for (i = 0; i < MAX_CERT_TYPE; i++) {
2059 if ((certinfo->cert_id)[i]) {
2060 for (j = 0; j < MAX_CERT_TYPE; j++) {
2061 if ((certinfo->cert_id)[i] == unique_id[j]) {
2062 /*Ref count has already been updated. Just continue*/
2066 if (j == MAX_CERT_TYPE)
2067 unique_id[c++] = (certinfo->cert_id)[i];
2070 memset(query, '\0', MAX_QUERY_LEN);
2071 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
2072 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
2074 _LOGE("Cert Info DB Information retrieval failed\n");
2075 ret = PMINFO_R_ERROR;
2078 memset(query, '\0', MAX_QUERY_LEN);
2079 if (indexinfo->cert_ref_count > 1) {
2080 /*decrease ref count*/
2081 snprintf(query, MAX_QUERY_LEN, "update package_cert_index_info set cert_ref_count=%d where cert_id=%d ",
2082 indexinfo->cert_ref_count - 1, (certinfo->cert_id)[i]);
2084 /*delete this certificate as ref count is 1 and it will become 0*/
2085 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
2088 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
2089 _LOGE("Don't execute query = %s error message = %s\n", query,
2091 sqlite3_free(error_message);
2092 ret = PMINFO_R_ERROR;
2097 /*Now delete the entry from db*/
2098 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
2100 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
2101 _LOGE("Don't execute query = %s error message = %s\n", query,
2103 sqlite3_free(error_message);
2104 ret = PMINFO_R_ERROR;
2113 if (certinfo->pkgid) {
2114 free(certinfo->pkgid);
2115 certinfo->pkgid = NULL;
2117 for (i = 0; i < MAX_CERT_TYPE; i++) {
2118 if ((certinfo->cert_info)[i]) {
2119 free((certinfo->cert_info)[i]);
2120 (certinfo->cert_info)[i] = NULL;
2129 int __reqeust_get_size(const char *pkgid, int type)
2133 char *errmsg = NULL;
2135 void *handle = NULL;
2137 pkgmgr_client *(*__pkgmgr_client_new)(client_type ctype) = NULL;
2138 int (*__pkgmgr_client_get_size)(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data) = NULL;
2139 int (*__pkgmgr_client_request_service)(pkgmgr_request_service_type service_type, int service_mode,
2140 pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
2141 const char *custom_info, pkgmgr_handler event_cb, void *data) = NULL;
2143 retvm_if(pkgid == NULL, PMINFO_R_ERROR, "pkgid is NULL");
2145 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
2146 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
2148 __pkgmgr_client_new = dlsym(handle, "pkgmgr_client_new");
2150 tryvm_if((errmsg != NULL) || (__pkgmgr_client_new == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
2152 __pkgmgr_client_request_service = dlsym(handle, "pkgmgr_client_request_service");
2154 tryvm_if((errmsg != NULL) || (__pkgmgr_client_request_service == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
2156 pc = __pkgmgr_client_new(PC_REQUEST);
2157 tryvm_if(pc == NULL, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
2159 size = __pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, type, pc, NULL, pkgid, NULL, NULL, NULL);
2160 tryvm_if(size < 0, ret = PMINFO_R_ERROR, "get size failed.");
2169 void __get_package_size(const char *size_info, const char *pkgid, int *total_size, int *data_size)
2172 p = strstr(size_info, pkgid);
2178 *total_size = atoi(p+1);
2183 *data_size = atoi(p+1);
2196 int __get_package_size_info(char **size_info)
2201 pInfo = (char *)malloc(MAX_PKG_BUF_LEN * MAX_PKG_INFO_LEN);
2202 memset(pInfo, 0, MAX_PKG_BUF_LEN * MAX_PKG_INFO_LEN);
2204 fp = fopen(PKG_SIZE_INFO_FILE, "r");
2206 fread(pInfo, 1, MAX_PKG_BUF_LEN * MAX_PKG_INFO_LEN, fp);
2214 int __set_package_size_info(manifest_x *manifest, const char* size_info)
2219 char total_buf[PKG_TYPE_STRING_LEN_MAX] = {'\0'};
2220 char data_buf[PKG_TYPE_STRING_LEN_MAX] = {'\0'};
2222 __get_package_size(size_info, manifest->package, &total_size, &data_size);
2224 manifest->package_size = strdup("true");
2226 snprintf(total_buf, PKG_TYPE_STRING_LEN_MAX - 1, "%d", total_size);
2227 manifest->package_total_size = strndup(total_buf, PKG_TYPE_STRING_LEN_MAX - 1);
2229 snprintf(data_buf, PKG_TYPE_STRING_LEN_MAX - 1, "%d", data_size);
2230 manifest->package_data_size = strndup(data_buf, PKG_TYPE_STRING_LEN_MAX - 1);
2235 static int __pkginfo_check_installed_storage(pkgmgr_pkginfo_x *pkginfo)
2237 char buf[MAX_QUERY_LEN] = {'\0'};
2238 retvm_if(pkginfo->manifest_info->package == NULL, PMINFO_R_OK, "pkgid is NULL\n");
2240 if (strcmp(pkginfo->manifest_info->installed_storage,"installed_external") == 0) {
2241 snprintf(buf, MAX_QUERY_LEN - 1, "%s%s", PKG_SD_PATH, pkginfo->manifest_info->package);
2242 if (access(buf, R_OK) != 0) {
2243 _LOGE("can not access [%s]", buf);
2244 return PMINFO_R_OK;//tmep, it will be fixed to :: return PMINFO_R_ERROR;
2251 static int __appinfo_check_installed_storage(pkgmgr_appinfo_x *appinfo)
2253 char buf[MAX_QUERY_LEN] = {'\0'};
2256 pkgid = appinfo->package;
2258 pkgid = appinfo->uiapp_info->package;
2259 retvm_if(pkgid == NULL, PMINFO_R_OK, "pkgid is NULL\n");
2261 if (strcmp(appinfo->uiapp_info->installed_storage,"installed_external") == 0) {
2262 snprintf(buf, MAX_QUERY_LEN - 1, "%s%s", PKG_SD_PATH, pkgid);
2263 if (access(buf, R_OK) != 0) {
2264 _LOGE("can not access [%s]", buf);
2265 return PMINFO_R_OK;//tmep, it will be fixed to :: return PMINFO_R_ERROR;
2272 static int __update_ail_appinfo(manifest_x * mfx)
2275 uiapplication_x *uiapplication = mfx->uiapplication;
2276 void *lib_handle = NULL;
2277 int (*ail_desktop_operation) (const char *appid, const char *property, const char *value, bool broadcast);
2280 if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
2281 _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
2285 aop = "ail_desktop_appinfo_modify_str";
2287 if ((ail_desktop_operation =
2288 dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
2289 _LOGE("can not find symbol \n");
2293 for(; uiapplication; uiapplication=uiapplication->next) {
2294 ret = ail_desktop_operation(uiapplication->appid, "AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR", mfx->installed_storage, FALSE);
2296 _LOGE("Failed to store info in DB\n");
2301 dlclose(lib_handle);
2306 static int __get_pkg_location(const char *pkgid)
2308 retvm_if(pkgid == NULL, PMINFO_R_OK, "pkginfo handle is NULL");
2311 char pkg_mmc_path[FILENAME_MAX] = { 0, };
2312 snprintf(pkg_mmc_path, FILENAME_MAX, "%s%s", PKG_SD_PATH, pkgid);
2314 /*check whether application is in external memory or not */
2315 fp = fopen(pkg_mmc_path, "r");
2319 return PMINFO_EXTERNAL_STORAGE;
2322 return PMINFO_INTERNAL_STORAGE;
2325 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
2327 retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
2328 int ret = PMINFO_R_OK;
2329 char query[MAX_QUERY_LEN] = {'\0'};
2330 char *syslocale = NULL;
2331 char *locale = NULL;
2332 pkgmgr_pkginfo_x *pkginfo = NULL;
2333 label_x *tmp1 = NULL;
2334 icon_x *tmp2 = NULL;
2335 description_x *tmp3 = NULL;
2336 author_x *tmp4 = NULL;
2337 privilege_x *tmp5 = NULL;
2338 sqlite3 *pkginfo_db = NULL;
2341 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
2342 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2344 /*get system locale*/
2345 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2346 locale = __convert_system_locale_to_manifest_locale(syslocale);
2347 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
2349 pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2350 pkgmgr_pkginfo_x *node = NULL;
2351 pkgmgr_pkginfo_x *temp_node = NULL;
2353 snprintf(query, MAX_QUERY_LEN, "select * from package_info");
2354 ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead);
2355 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2357 LISTHEAD(tmphead, node);
2359 for(node = node->next; node ; node = node->next) {
2361 pkginfo->locale = strdup(locale);
2362 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2363 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info\n");
2365 /*populate manifest_info from DB*/
2366 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
2367 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2368 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2370 memset(query, '\0', MAX_QUERY_LEN);
2371 /*populate privilege_info from DB*/
2372 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package);
2373 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2374 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package privilege Info DB Information retrieval failed");
2376 memset(query, '\0', MAX_QUERY_LEN);
2377 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2378 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
2379 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2380 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2382 /*Also store the values corresponding to default locales*/
2383 memset(query, '\0', MAX_QUERY_LEN);
2384 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2385 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
2386 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2387 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2389 if (pkginfo->manifest_info->label) {
2390 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2391 pkginfo->manifest_info->label = tmp1;
2393 if (pkginfo->manifest_info->icon) {
2394 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2395 pkginfo->manifest_info->icon = tmp2;
2397 if (pkginfo->manifest_info->description) {
2398 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2399 pkginfo->manifest_info->description = tmp3;
2401 if (pkginfo->manifest_info->author) {
2402 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2403 pkginfo->manifest_info->author = tmp4;
2405 if (pkginfo->manifest_info->privileges->privilege) {
2406 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2407 pkginfo->manifest_info->privileges->privilege = tmp5;
2411 LISTHEAD(tmphead, node);
2413 for(node = node->next; node ; node = node->next) {
2416 ret = __pkginfo_check_installed_storage(pkginfo);
2420 ret = pkg_list_cb( (void *)pkginfo, user_data);
2428 sqlite3_close(pkginfo_db);
2437 LISTHEAD(tmphead, node);
2438 temp_node = node->next;
2441 temp_node = node->next;
2442 __cleanup_pkginfo(node);
2445 __cleanup_pkginfo(tmphead);
2450 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
2452 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
2453 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2454 pkgmgr_pkginfo_x *pkginfo = NULL;
2455 int ret = PMINFO_R_OK;
2456 char query[MAX_QUERY_LEN] = {'\0'};
2457 char *syslocale = NULL;
2458 char *locale = NULL;
2460 label_x *tmp1 = NULL;
2461 icon_x *tmp2 = NULL;
2462 description_x *tmp3 = NULL;
2463 author_x *tmp4 = NULL;
2464 privilege_x *tmp5 = NULL;
2465 sqlite3 *pkginfo_db = NULL;
2468 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
2469 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2471 /*check pkgid exist on db*/
2472 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
2473 ret = __exec_db_query(pkginfo_db, query, __validate_cb, (void *)&exist);
2474 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
2475 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] not found in DB", pkgid);
2477 /*get system locale*/
2478 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2479 locale = __convert_system_locale_to_manifest_locale(syslocale);
2480 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
2482 pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2483 tryvm_if(pkginfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for pkginfo");
2485 pkginfo->locale = strdup(locale);
2487 pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
2488 tryvm_if(pkginfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for manifest info");
2490 pkginfo->manifest_info->package = strdup(pkgid);
2491 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2492 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info");
2494 /*populate manifest_info from DB*/
2495 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
2496 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2497 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2499 memset(query, '\0', MAX_QUERY_LEN);
2500 /*populate privilege_info from DB*/
2501 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
2502 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2503 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
2505 memset(query, '\0', MAX_QUERY_LEN);
2506 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2507 " package='%s' and package_locale='%s'", pkgid, locale);
2508 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2509 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2511 /*Also store the values corresponding to default locales*/
2512 memset(query, '\0', MAX_QUERY_LEN);
2513 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2514 " package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
2515 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
2516 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2518 if (pkginfo->manifest_info->label) {
2519 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2520 pkginfo->manifest_info->label = tmp1;
2522 if (pkginfo->manifest_info->icon) {
2523 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2524 pkginfo->manifest_info->icon = tmp2;
2526 if (pkginfo->manifest_info->description) {
2527 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2528 pkginfo->manifest_info->description = tmp3;
2530 if (pkginfo->manifest_info->author) {
2531 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2532 pkginfo->manifest_info->author = tmp4;
2534 if (pkginfo->manifest_info->privileges->privilege) {
2535 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2536 pkginfo->manifest_info->privileges->privilege = tmp5;
2539 ret = __pkginfo_check_installed_storage(pkginfo);
2540 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "[%s] is installed external, but is not in mmc", pkgid);
2543 if (ret == PMINFO_R_OK)
2544 *handle = (void*)pkginfo;
2547 __cleanup_pkginfo(pkginfo);
2549 sqlite3_close(pkginfo_db);
2563 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
2565 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2566 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2567 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2568 if (info->manifest_info->package)
2569 *pkg_name = (char *)info->manifest_info->package;
2571 return PMINFO_R_ERROR;
2576 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
2578 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2579 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2580 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2581 if (info->manifest_info->package)
2582 *pkgid = (char *)info->manifest_info->package;
2584 return PMINFO_R_ERROR;
2589 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
2591 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2592 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2593 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2594 if (info->manifest_info->type)
2595 *type = (char *)info->manifest_info->type;
2601 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
2603 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2604 retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2605 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2606 *version = (char *)info->manifest_info->version;
2610 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
2612 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2613 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2615 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2616 val = (char *)info->manifest_info->installlocation;
2618 if (strcmp(val, "internal-only") == 0)
2619 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2620 else if (strcmp(val, "prefer-external") == 0)
2621 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
2623 *location = PMINFO_INSTALL_LOCATION_AUTO;
2628 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
2630 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2631 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2633 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2634 val = (char *)info->manifest_info->package_size;
2639 _LOGE("package size is not specified\n");
2640 return PMINFO_R_ERROR;
2645 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
2647 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2648 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2654 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2655 val = (char *)info->manifest_info->package_size;
2656 if (strcmp(val, "true") == 0) {
2657 *size = atoi(info->manifest_info->package_total_size);
2665 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
2667 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2668 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2674 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2675 val = (char *)info->manifest_info->package_size;
2676 if (strcmp(val, "true") == 0) {
2677 *size = atoi(info->manifest_info->package_data_size);
2685 API int pkgmgrinfo_pkginfo_get_size_info(pkgmgrinfo_pkginfo_h handle, int *total_size, int *data_size)
2687 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2688 retvm_if(total_size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2689 retvm_if(data_size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2696 char* package_size_info = NULL;
2698 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2700 val = (char *)info->manifest_info->package_size;
2701 if (strcmp(val, "true") == 0) {
2702 *total_size = atoi(info->manifest_info->package_total_size);
2703 *data_size = atoi(info->manifest_info->package_data_size);
2714 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
2716 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2717 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2718 int ret = PMINFO_R_OK;
2719 char *locale = NULL;
2723 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2725 locale = info->locale;
2726 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2728 for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next)
2731 if (strcmp(ptr->lang, locale) == 0) {
2732 *icon = (char *)ptr->text;
2733 if (strcasecmp(*icon, "(null)") == 0) {
2734 locale = DEFAULT_LOCALE;
2738 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2739 *icon = (char *)ptr->text;
2748 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
2750 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2751 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2752 int ret = PMINFO_R_OK;
2753 char *locale = NULL;
2754 label_x *ptr = NULL;
2757 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2758 locale = info->locale;
2759 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2761 for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next)
2764 if (strcmp(ptr->lang, locale) == 0) {
2765 *label = (char *)ptr->text;
2766 if (strcasecmp(*label, "(null)") == 0) {
2767 locale = DEFAULT_LOCALE;
2771 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2772 *label = (char *)ptr->text;
2781 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
2783 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2784 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2785 char *locale = NULL;
2786 description_x *ptr = NULL;
2787 *description = NULL;
2789 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2790 locale = info->locale;
2791 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2793 for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next)
2796 if (strcmp(ptr->lang, locale) == 0) {
2797 *description = (char *)ptr->text;
2798 if (strcasecmp(*description, PKGMGR_PARSER_EMPTY_STR) == 0) {
2799 locale = DEFAULT_LOCALE;
2803 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2804 *description = (char *)ptr->text;
2812 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
2814 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2815 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2816 char *locale = NULL;
2817 author_x *ptr = NULL;
2818 *author_name = NULL;
2820 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2821 locale = info->locale;
2822 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
2824 for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next)
2827 if (strcmp(ptr->lang, locale) == 0) {
2828 *author_name = (char *)ptr->text;
2829 if (strcasecmp(*author_name, PKGMGR_PARSER_EMPTY_STR) == 0) {
2830 locale = DEFAULT_LOCALE;
2834 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
2835 *author_name = (char *)ptr->text;
2843 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
2845 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2846 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2847 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2848 *author_email = (char *)info->manifest_info->author->email;
2852 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
2854 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2855 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2856 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2857 *author_href = (char *)info->manifest_info->author->href;
2861 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
2863 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2864 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2866 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2868 if (strcmp(info->manifest_info->installed_storage,"installed_internal") == 0)
2869 *storage = PMINFO_INTERNAL_STORAGE;
2870 else if (strcmp(info->manifest_info->installed_storage,"installed_external") == 0)
2871 *storage = PMINFO_EXTERNAL_STORAGE;
2873 return PMINFO_R_ERROR;
2878 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
2880 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2881 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2882 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2883 if (info->manifest_info->installed_time)
2884 *installed_time = atoi(info->manifest_info->installed_time);
2886 return PMINFO_R_ERROR;
2891 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
2893 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2894 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2895 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2896 *storeclientid = (char *)info->manifest_info->storeclient_id;
2900 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
2902 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2903 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2904 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2905 *mainappid = (char *)info->manifest_info->mainapp_id;
2909 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
2911 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2912 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2913 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2914 *url = (char *)info->manifest_info->package_url;
2918 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
2920 const char *val = NULL;
2921 const xmlChar *node;
2922 xmlTextReaderPtr reader;
2923 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2924 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2927 reader = xmlReaderForFile(manifest, NULL, 0);
2930 if (__child_element(reader, -1)) {
2931 node = xmlTextReaderConstName(reader);
2933 _LOGE("xmlTextReaderConstName value is NULL\n");
2934 xmlFreeTextReader(reader);
2936 return PMINFO_R_ERROR;
2939 if (!strcmp(ASC_CHAR(node), "manifest")) {
2940 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
2941 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
2947 _LOGE("package size is not specified\n");
2948 xmlFreeTextReader(reader);
2950 return PMINFO_R_ERROR;
2953 _LOGE("Unable to create xml reader\n");
2954 xmlFreeTextReader(reader);
2956 return PMINFO_R_ERROR;
2960 _LOGE("xmlReaderForFile value is NULL\n");
2962 return PMINFO_R_ERROR;
2965 xmlFreeTextReader(reader);
2971 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
2973 const char *val = NULL;
2974 const xmlChar *node;
2975 xmlTextReaderPtr reader;
2976 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
2977 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2980 reader = xmlReaderForFile(manifest, NULL, 0);
2983 if ( __child_element(reader, -1)) {
2984 node = xmlTextReaderConstName(reader);
2986 _LOGE("xmlTextReaderConstName value is NULL\n");
2987 xmlFreeTextReader(reader);
2989 return PMINFO_R_ERROR;
2992 if (!strcmp(ASC_CHAR(node), "manifest")) {
2993 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
2994 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
2997 if (strcmp(val, "internal-only") == 0)
2998 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2999 else if (strcmp(val, "prefer-external") == 0)
3000 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
3002 *location = PMINFO_INSTALL_LOCATION_AUTO;
3005 _LOGE("Unable to create xml reader\n");
3006 xmlFreeTextReader(reader);
3008 return PMINFO_R_ERROR;
3012 _LOGE("xmlReaderForFile value is NULL\n");
3014 return PMINFO_R_ERROR;
3017 xmlFreeTextReader(reader);
3024 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
3026 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3027 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3029 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3030 if (info->manifest_info->root_path)
3031 *path = (char *)info->manifest_info->root_path;
3033 return PMINFO_R_ERROR;
3038 API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
3040 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3041 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3043 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3044 if (info->manifest_info->csc_path)
3045 *path = (char *)info->manifest_info->csc_path;
3047 *path = (char *)info->manifest_info->csc_path;
3052 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)
3054 retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
3055 retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
3056 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3058 int ret = PMINFO_R_OK;
3059 char query[MAX_QUERY_LEN] = {'\0'};
3060 char *error_message = NULL;
3061 pkgmgr_cert_x *info= NULL;
3065 *compare_result = PMINFO_CERT_COMPARE_ERROR;
3066 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3067 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3069 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READONLY, NULL);
3070 if (ret != SQLITE_OK) {
3071 _LOGE("connect db [%s] failed!\n", CERT_DB);
3072 ret = PMINFO_R_ERROR;
3076 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
3078 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
3079 _LOGE("Don't execute query = %s error message = %s\n", query,
3081 ret = PMINFO_R_ERROR;
3088 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
3090 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
3091 _LOGE("Don't execute query = %s error message = %s\n", query,
3093 ret = PMINFO_R_ERROR;
3096 lcert = info->cert_id;
3099 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
3101 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
3102 _LOGE("Don't execute query = %s error message = %s\n", query,
3104 ret = PMINFO_R_ERROR;
3111 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
3113 sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
3114 _LOGE("Don't execute query = %s error message = %s\n", query,
3116 ret = PMINFO_R_ERROR;
3119 rcert = info->cert_id;
3122 if ((lcert == 0) || (rcert == 0))
3124 if ((lcert == 0) && (rcert == 0))
3125 *compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
3126 else if (lcert == 0)
3127 *compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
3128 else if (rcert == 0)
3129 *compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
3132 *compare_result = PMINFO_CERT_COMPARE_MATCH;
3134 *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
3138 sqlite3_free(error_message);
3139 sqlite3_close(cert_db);
3152 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)
3154 retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
3155 retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
3156 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3158 int ret = PMINFO_R_OK;
3159 char query[MAX_QUERY_LEN] = {'\0'};
3160 char *error_message = NULL;
3161 pkgmgr_cert_x *info= NULL;
3163 char *lpkgid = NULL;
3164 char *rpkgid = NULL;
3165 sqlite3 *pkginfo_db = NULL;
3167 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3168 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3170 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3171 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3173 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
3175 sqlite3_exec(pkginfo_db, query, __validate_cb, (void *)&exist, &error_message)) {
3176 _LOGE("Don't execute query = %s error message = %s\n", query,
3178 ret = PMINFO_R_ERROR;
3185 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
3187 sqlite3_exec(pkginfo_db, query, __cert_cb, (void *)info, &error_message)) {
3188 _LOGE("Don't execute query = %s error message = %s\n", query,
3190 ret = PMINFO_R_ERROR;
3193 lpkgid = strdup(info->pkgid);
3194 if (lpkgid == NULL) {
3195 _LOGE("Out of Memory\n");
3196 ret = PMINFO_R_ERROR;
3203 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
3205 sqlite3_exec(pkginfo_db, query, __validate_cb, (void *)&exist, &error_message)) {
3206 _LOGE("Don't execute query = %s error message = %s\n", query,
3208 ret = PMINFO_R_ERROR;
3215 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
3217 sqlite3_exec(pkginfo_db, query, __cert_cb, (void *)info, &error_message)) {
3218 _LOGE("Don't execute query = %s error message = %s\n", query,
3220 ret = PMINFO_R_ERROR;
3223 rpkgid = strdup(info->pkgid);
3224 if (rpkgid == NULL) {
3225 _LOGE("Out of Memory\n");
3226 ret = PMINFO_R_ERROR;
3232 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
3235 sqlite3_free(error_message);
3236 sqlite3_close(pkginfo_db);
3256 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
3258 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3259 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3261 #if 0 //smack issue occured, check later
3263 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
3265 _LOGD("invalid func parameters\n");
3266 return PMINFO_R_ERROR;
3268 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
3271 char app_mmc_path[FILENAME_MAX] = { 0, };
3272 char app_dir_path[FILENAME_MAX] = { 0, };
3273 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
3274 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
3275 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
3276 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
3278 /*check whether application is in external memory or not */
3279 fp = fopen(app_mmc_path, "r");
3281 _LOGD(" app path in external memory not accesible\n");
3286 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
3290 /*check whether application is in internal or not */
3291 fp = fopen(app_dir_path, "r");
3293 _LOGD(" app path in internal memory not accesible\n");
3295 return PMINFO_R_ERROR;
3298 /*check whether the application is installed in SD card
3299 but SD card is not present*/
3300 fp = fopen(app_mmc_internal_path, "r");
3303 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
3308 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
3313 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
3320 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
3322 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3323 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3325 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3326 val = (char *)info->manifest_info->removable;
3328 if (strcasecmp(val, "true") == 0)
3330 else if (strcasecmp(val, "false") == 0)
3338 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
3340 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3341 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3344 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3346 val = (char *)info->manifest_info->installlocation;
3348 if (strcmp(val, "internal-only") == 0)
3350 else if (strcmp(val, "prefer-external") == 0)
3359 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
3361 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3362 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3364 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3365 val = (char *)info->manifest_info->preload;
3367 if (strcasecmp(val, "true") == 0)
3369 else if (strcasecmp(val, "false") == 0)
3377 API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
3379 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3380 retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3383 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3384 val = (char *)info->manifest_info->system;
3386 if (strcasecmp(val, "true") == 0)
3388 else if (strcasecmp(val, "false") == 0)
3397 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
3399 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3400 retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3402 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3403 val = (char *)info->manifest_info->readonly;
3405 if (strcasecmp(val, "true") == 0)
3407 else if (strcasecmp(val, "false") == 0)
3415 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
3417 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3418 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3421 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3422 val = (char *)info->manifest_info->update;
3424 if (strcasecmp(val, "true") == 0)
3426 else if (strcasecmp(val, "false") == 0)
3434 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
3436 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3437 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3438 __cleanup_pkginfo(info);
3442 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
3444 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
3446 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
3447 if (filter == NULL) {
3448 _LOGE("Out of Memory!!!");
3449 return PMINFO_R_ERROR;
3455 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
3457 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3458 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3460 g_slist_foreach(filter->list, __destroy_each_node, NULL);
3461 g_slist_free(filter->list);
3466 if (access(PKG_SIZE_INFO_FILE, F_OK) == 0) {
3467 char info_file[PKG_VALUE_STRING_LEN_MAX] = { 0, };
3468 snprintf(info_file, PKG_VALUE_STRING_LEN_MAX, "%s", PKG_SIZE_INFO_FILE);
3475 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
3476 const char *property, const int value)
3478 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3479 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3480 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
3482 GSList *link = NULL;
3484 prop = _pminfo_pkginfo_convert_to_prop_int(property);
3485 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
3486 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
3487 _LOGE("Invalid Integer Property\n");
3488 return PMINFO_R_EINVAL;
3490 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3491 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3493 _LOGE("Out of Memory!!!\n");
3494 return PMINFO_R_ERROR;
3496 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
3497 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
3499 _LOGE("Out of Memory\n");
3502 return PMINFO_R_ERROR;
3506 /*If API is called multiple times for same property, we should override the previous values.
3507 Last value set will be used for filtering.*/
3508 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3510 filter->list = g_slist_delete_link(filter->list, link);
3511 filter->list = g_slist_append(filter->list, (gpointer)node);
3516 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
3517 const char *property, const bool value)
3519 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3520 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3522 GSList *link = NULL;
3524 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
3525 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
3526 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
3527 _LOGE("Invalid Boolean Property\n");
3528 return PMINFO_R_EINVAL;
3530 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3531 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3533 _LOGE("Out of Memory!!!\n");
3534 return PMINFO_R_ERROR;
3537 val = strndup("('true','True')", 15);
3539 val = strndup("('false','False')", 17);
3541 _LOGE("Out of Memory\n");
3544 return PMINFO_R_ERROR;
3548 /*If API is called multiple times for same property, we should override the previous values.
3549 Last value set will be used for filtering.*/
3550 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3552 filter->list = g_slist_delete_link(filter->list, link);
3553 filter->list = g_slist_append(filter->list, (gpointer)node);
3558 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
3559 const char *property, const char *value)
3561 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3562 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3563 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3565 GSList *link = NULL;
3567 prop = _pminfo_pkginfo_convert_to_prop_str(property);
3568 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
3569 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
3570 _LOGE("Invalid String Property\n");
3571 return PMINFO_R_EINVAL;
3573 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3574 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3576 _LOGE("Out of Memory!!!\n");
3577 return PMINFO_R_ERROR;
3579 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
3580 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
3581 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
3582 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
3583 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
3584 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
3585 else if (strcmp(value, "installed_internal") == 0)
3586 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
3587 else if (strcmp(value, "installed_external") == 0)
3588 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
3590 val = strndup(value, PKG_STRING_LEN_MAX - 1);
3592 _LOGE("Out of Memory\n");
3595 return PMINFO_R_ERROR;
3599 /*If API is called multiple times for same property, we should override the previous values.
3600 Last value set will be used for filtering.*/
3601 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3603 filter->list = g_slist_delete_link(filter->list, link);
3604 filter->list = g_slist_append(filter->list, (gpointer)node);
3609 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
3611 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3612 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3613 char *syslocale = NULL;
3614 char *locale = NULL;
3615 char *condition = NULL;
3616 char query[MAX_QUERY_LEN] = {'\0'};
3617 char where[MAX_QUERY_LEN] = {'\0'};
3620 pkgmgr_pkginfo_x *node = NULL;
3621 pkgmgr_pkginfo_x *tmphead = NULL;
3622 pkgmgr_pkginfo_x *pkginfo = NULL;
3623 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3624 sqlite3 *pkginfo_db = NULL;
3625 int filter_count = 0;
3628 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3629 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3631 /*get system locale*/
3632 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3633 locale = __convert_system_locale_to_manifest_locale(syslocale);
3634 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
3636 /*Start constructing query*/
3637 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
3639 /*Get where clause*/
3640 for (list = filter->list; list; list = g_slist_next(list)) {
3641 __get_filter_condition(list->data, &condition);
3643 strncat(where, condition, sizeof(where) - strlen(where) -1);
3644 where[sizeof(where) - 1] = '\0';
3648 if (g_slist_next(list)) {
3649 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3650 where[sizeof(where) - 1] = '\0';
3653 _LOGE("where = %s\n", where);
3654 if (strlen(where) > 0) {
3655 strncat(query, where, sizeof(query) - strlen(query) - 1);
3656 query[sizeof(query) - 1] = '\0';
3658 _LOGE("query = %s\n", query);
3660 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
3661 tryvm_if(tmphead == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3663 ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead);
3664 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3666 LISTHEAD(tmphead, node);
3667 for(node = node->next ; node ; node = node->next) {
3669 pkginfo->locale = strdup(locale);
3670 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
3671 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info\n");
3673 /*populate manifest_info from DB*/
3674 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
3675 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3676 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3678 memset(query, '\0', MAX_QUERY_LEN);
3679 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3680 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
3681 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3682 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3684 /*Also store the values corresponding to default locales*/
3685 memset(query, '\0', MAX_QUERY_LEN);
3686 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3687 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
3688 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3689 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3692 LISTHEAD(tmphead, node);
3694 for(node = node->next ; node ; node = node->next) {
3696 ret = __pkginfo_check_installed_storage(pkginfo);
3702 *count = filter_count;
3714 sqlite3_close(pkginfo_db);
3715 __cleanup_pkginfo(tmphead);
3719 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
3720 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
3722 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3723 retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3724 char *syslocale = NULL;
3725 char *locale = NULL;
3726 char *condition = NULL;
3727 char query[MAX_QUERY_LEN] = {'\0'};
3728 char where[MAX_QUERY_LEN] = {'\0'};
3731 label_x *tmp1 = NULL;
3732 icon_x *tmp2 = NULL;
3733 description_x *tmp3 = NULL;
3734 author_x *tmp4 = NULL;
3735 privilege_x *tmp5 = NULL;
3736 pkgmgr_pkginfo_x *node = NULL;
3737 pkgmgr_pkginfo_x *tmphead = NULL;
3738 pkgmgr_pkginfo_x *pkginfo = NULL;
3739 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3740 sqlite3 *pkginfo_db = NULL;
3741 const char* package_size_info = NULL;
3742 bool is_setting = false;
3745 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3746 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3748 /*get system locale*/
3749 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3750 locale = __convert_system_locale_to_manifest_locale(syslocale);
3751 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
3753 /*Start constructing query*/
3754 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
3756 /*Get where clause*/
3757 for (list = filter->list; list; list = g_slist_next(list)) {
3758 __get_filter_condition(list->data, &condition);
3760 strncat(where, condition, sizeof(where) - strlen(where) -1);
3761 where[sizeof(where) - 1] = '\0';
3763 if (strstr(condition, "package_info.package_nodisplay"))
3769 if (g_slist_next(list)) {
3770 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3771 where[sizeof(where) - 1] = '\0';
3774 _LOGE("where = %s\n", where);
3775 if (strlen(where) > 0) {
3776 strncat(query, where, sizeof(query) - strlen(query) - 1);
3777 query[sizeof(query) - 1] = '\0';
3779 _LOGE("query = %s\n", query);
3781 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
3782 tryvm_if(tmphead == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3784 ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead);
3785 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3788 ret = __reqeust_get_size("size_info", PM_GET_SIZE_INFO);
3789 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "fail reqeust size info");
3791 ret = __get_package_size_info(&package_size_info);
3792 tryvm_if(ret != 0 || package_size_info == NULL, ret = PMINFO_R_ERROR, "__get_package_size_info() failed");
3793 _LOGD("is_setting is true, get package size info success!! ");
3796 LISTHEAD(tmphead, node);
3797 for(node = node->next ; node ; node = node->next) {
3799 pkginfo->locale = strdup(locale);
3800 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
3801 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info\n");
3803 /*populate manifest_info from DB*/
3804 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
3805 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3806 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3808 memset(query, '\0', MAX_QUERY_LEN);
3809 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3810 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
3811 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3812 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3814 /*Also store the values corresponding to default locales*/
3815 memset(query, '\0', MAX_QUERY_LEN);
3816 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
3817 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
3818 ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
3819 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
3821 if (pkginfo->manifest_info->label) {
3822 LISTHEAD(pkginfo->manifest_info->label, tmp1);
3823 pkginfo->manifest_info->label = tmp1;
3825 if (pkginfo->manifest_info->icon) {
3826 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
3827 pkginfo->manifest_info->icon = tmp2;
3829 if (pkginfo->manifest_info->description) {
3830 LISTHEAD(pkginfo->manifest_info->description, tmp3);
3831 pkginfo->manifest_info->description = tmp3;
3833 if (pkginfo->manifest_info->author) {
3834 LISTHEAD(pkginfo->manifest_info->author, tmp4);
3835 pkginfo->manifest_info->author = tmp4;
3837 if (pkginfo->manifest_info->privileges->privilege) {
3838 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
3839 pkginfo->manifest_info->privileges->privilege = tmp5;
3842 __set_package_size_info(pkginfo->manifest_info, package_size_info);
3846 LISTHEAD(tmphead, node);
3848 for(node = node->next ; node ; node = node->next) {
3851 ret = __pkginfo_check_installed_storage(pkginfo);
3855 ret = pkg_cb( (void *)pkginfo, user_data);
3870 if (package_size_info) {
3871 free(package_size_info);
3874 sqlite3_close(pkginfo_db);
3875 __cleanup_pkginfo(tmphead);
3879 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
3880 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
3882 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3883 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
3885 privilege_x *ptr = NULL;
3886 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3887 ptr = info->manifest_info->privileges->privilege;
3888 for (; ptr; ptr = ptr->next) {
3890 ret = privilege_func(ptr->text, user_data);
3898 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
3899 pkgmgrinfo_app_list_cb app_func, void *user_data)
3901 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3902 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
3903 retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
3905 char *syslocale = NULL;
3906 char *locale = NULL;
3908 char query[MAX_QUERY_LEN] = {'\0'};
3909 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3910 pkgmgr_pkginfo_x *allinfo = NULL;
3911 pkgmgr_appinfo_x *appinfo = NULL;
3912 icon_x *ptr1 = NULL;
3913 label_x *ptr2 = NULL;
3914 category_x *ptr3 = NULL;
3915 metadata_x *ptr4 = NULL;
3916 permission_x *ptr5 = NULL;
3917 image_x *ptr6 = NULL;
3918 sqlite3 *appinfo_db = NULL;
3920 /*check installed storage*/
3921 ret = __pkginfo_check_installed_storage(info);
3922 retvm_if(ret < 0, PMINFO_R_EINVAL, "[%s] is installed external, but is not in mmc", info->manifest_info->package);
3924 /*get system locale*/
3925 syslocale = vconf_get_str(VCONFKEY_LANGSET);
3926 locale = __convert_system_locale_to_manifest_locale(syslocale);
3927 tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
3930 allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
3931 tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3933 /*calloc manifest_info*/
3934 allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
3935 tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
3938 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
3939 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
3941 /*set component type*/
3942 if (component == PMINFO_UI_APP)
3943 appinfo->app_component = PMINFO_UI_APP;
3944 if (component == PMINFO_SVC_APP)
3945 appinfo->app_component = PMINFO_SVC_APP;
3946 if (component == PMINFO_ALL_APP)
3947 appinfo->app_component = PMINFO_ALL_APP;
3950 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
3951 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3953 appinfo->package = strdup(info->manifest_info->package);
3954 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
3955 "from package_app_info where " \
3956 "package='%s' and app_component='%s'",
3957 info->manifest_info->package,
3958 (appinfo->app_component==PMINFO_UI_APP ? "uiapp" : "svcapp"));
3962 /*Populate ui app info */
3963 ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
3964 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
3966 uiapplication_x *tmp = NULL;
3967 if (info->manifest_info->uiapplication) {
3968 LISTHEAD(info->manifest_info->uiapplication, tmp);
3969 info->manifest_info->uiapplication = tmp;
3971 /*Populate localized info for default locales and call callback*/
3972 /*If the callback func return < 0 we break and no more call back is called*/
3975 appinfo->locale = strdup(locale);
3976 appinfo->uiapp_info = tmp;
3977 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
3981 locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
3984 memset(query, '\0', MAX_QUERY_LEN);
3985 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
3986 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3987 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3989 memset(query, '\0', MAX_QUERY_LEN);
3990 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);
3991 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3992 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
3994 /*store setting notification icon section*/
3995 memset(query, '\0', MAX_QUERY_LEN);
3996 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
3997 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
3998 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4000 /*store app preview image info*/
4001 memset(query, '\0', MAX_QUERY_LEN);
4002 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
4003 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4004 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4006 if (appinfo->uiapp_info->label) {
4007 LISTHEAD(appinfo->uiapp_info->label, ptr2);
4008 appinfo->uiapp_info->label = ptr2;
4010 if (appinfo->uiapp_info->icon) {
4011 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
4012 appinfo->uiapp_info->icon = ptr1;
4014 if (appinfo->uiapp_info->category) {
4015 LISTHEAD(appinfo->uiapp_info->category, ptr3);
4016 appinfo->uiapp_info->category = ptr3;
4018 if (appinfo->uiapp_info->metadata) {
4019 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
4020 appinfo->uiapp_info->metadata = ptr4;
4022 if (appinfo->uiapp_info->permission) {
4023 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
4024 appinfo->uiapp_info->permission = ptr5;
4026 if (appinfo->uiapp_info->image) {
4027 LISTHEAD(appinfo->uiapp_info->image, ptr6);
4028 appinfo->uiapp_info->image = ptr6;
4030 ret = app_func((void *)appinfo, user_data);
4036 case PMINFO_SVC_APP:
4037 /*Populate svc app info */
4038 ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
4039 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
4041 serviceapplication_x *tmp1 = NULL;
4042 if (info->manifest_info->serviceapplication) {
4043 LISTHEAD(info->manifest_info->serviceapplication, tmp1);
4044 info->manifest_info->serviceapplication = tmp1;
4046 /*Populate localized info for default locales and call callback*/
4047 /*If the callback func return < 0 we break and no more call back is called*/
4050 appinfo->locale = strdup(locale);
4051 appinfo->svcapp_info = tmp1;
4052 memset(query, '\0', MAX_QUERY_LEN);
4053 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
4054 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4055 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4057 memset(query, '\0', MAX_QUERY_LEN);
4058 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);
4059 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4060 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4062 if (appinfo->svcapp_info->label) {
4063 LISTHEAD(appinfo->svcapp_info->label, ptr2);
4064 appinfo->svcapp_info->label = ptr2;
4066 if (appinfo->svcapp_info->icon) {
4067 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
4068 appinfo->svcapp_info->icon = ptr1;
4070 if (appinfo->svcapp_info->category) {
4071 LISTHEAD(appinfo->svcapp_info->category, ptr3);
4072 appinfo->svcapp_info->category = ptr3;
4074 if (appinfo->svcapp_info->metadata) {
4075 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
4076 appinfo->svcapp_info->metadata = ptr4;
4078 if (appinfo->svcapp_info->permission) {
4079 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
4080 appinfo->svcapp_info->permission = ptr5;
4082 ret = app_func((void *)appinfo, user_data);
4088 case PMINFO_ALL_APP:
4089 memset(query, '\0', MAX_QUERY_LEN);
4090 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
4092 /*Populate all app info */
4093 ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo);
4094 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
4097 appinfo->app_component = PMINFO_UI_APP;
4098 uiapplication_x *tmp2 = NULL;
4099 if (allinfo->manifest_info->uiapplication) {
4100 LISTHEAD(allinfo->manifest_info->uiapplication, tmp2);
4101 allinfo->manifest_info->uiapplication = tmp2;
4103 /*Populate localized info for default locales and call callback*/
4104 /*If the callback func return < 0 we break and no more call back is called*/
4107 appinfo->locale = strdup(locale);
4108 appinfo->uiapp_info = tmp2;
4109 memset(query, '\0', MAX_QUERY_LEN);
4110 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
4111 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4112 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4114 memset(query, '\0', MAX_QUERY_LEN);
4115 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);
4116 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4117 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4119 /*store setting notification icon section*/
4120 memset(query, '\0', MAX_QUERY_LEN);
4121 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
4122 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4123 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4125 /*store app preview image info*/
4126 memset(query, '\0', MAX_QUERY_LEN);
4127 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
4128 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4129 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4131 if (appinfo->uiapp_info->label) {
4132 LISTHEAD(appinfo->uiapp_info->label, ptr2);
4133 appinfo->uiapp_info->label = ptr2;
4135 if (appinfo->uiapp_info->icon) {
4136 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
4137 appinfo->uiapp_info->icon = ptr1;
4139 if (appinfo->uiapp_info->category) {
4140 LISTHEAD(appinfo->uiapp_info->category, ptr3);
4141 appinfo->uiapp_info->category = ptr3;
4143 if (appinfo->uiapp_info->metadata) {
4144 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
4145 appinfo->uiapp_info->metadata = ptr4;
4147 if (appinfo->uiapp_info->permission) {
4148 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
4149 appinfo->uiapp_info->permission = ptr5;
4151 if (appinfo->uiapp_info->image) {
4152 LISTHEAD(appinfo->uiapp_info->image, ptr6);
4153 appinfo->uiapp_info->image = ptr6;
4155 ret = app_func((void *)appinfo, user_data);
4162 appinfo->app_component = PMINFO_SVC_APP;
4163 serviceapplication_x *tmp3 = NULL;
4164 if (allinfo->manifest_info->serviceapplication) {
4165 LISTHEAD(allinfo->manifest_info->serviceapplication, tmp3);
4166 allinfo->manifest_info->serviceapplication = tmp3;
4168 /*Populate localized info for default locales and call callback*/
4169 /*If the callback func return < 0 we break and no more call back is called*/
4172 appinfo->locale = strdup(locale);
4173 appinfo->svcapp_info = tmp3;
4174 memset(query, '\0', MAX_QUERY_LEN);
4175 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->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 * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
4181 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4182 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4184 if (appinfo->svcapp_info->label) {
4185 LISTHEAD(appinfo->svcapp_info->label, ptr2);
4186 appinfo->svcapp_info->label = ptr2;
4188 if (appinfo->svcapp_info->icon) {
4189 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
4190 appinfo->svcapp_info->icon = ptr1;
4192 if (appinfo->svcapp_info->category) {
4193 LISTHEAD(appinfo->svcapp_info->category, ptr3);
4194 appinfo->svcapp_info->category = ptr3;
4196 if (appinfo->svcapp_info->metadata) {
4197 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
4198 appinfo->svcapp_info->metadata = ptr4;
4200 if (appinfo->svcapp_info->permission) {
4201 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
4202 appinfo->svcapp_info->permission = ptr5;
4204 ret = app_func((void *)appinfo, user_data);
4209 appinfo->app_component = PMINFO_ALL_APP;
4225 if (appinfo->package) {
4226 free((void *)appinfo->package);
4227 appinfo->package = NULL;
4232 __cleanup_pkginfo(allinfo);
4234 sqlite3_close(appinfo_db);
4238 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4240 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4242 int ret = PMINFO_R_OK;
4243 char query[MAX_QUERY_LEN] = {'\0'};
4244 pkgmgr_appinfo_x *appinfo = NULL;
4245 uiapplication_x *ptr1 = NULL;
4246 serviceapplication_x *ptr2 = NULL;
4247 sqlite3 *appinfo_db = NULL;
4250 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
4251 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4254 pkgmgr_pkginfo_x *info = NULL;
4255 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4256 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4258 /*calloc manifest_info*/
4259 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4260 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4263 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4264 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4266 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4267 ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
4268 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4270 if (info->manifest_info->uiapplication) {
4271 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4272 info->manifest_info->uiapplication = ptr1;
4274 if (info->manifest_info->serviceapplication) {
4275 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4276 info->manifest_info->serviceapplication = ptr2;
4280 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4282 appinfo->app_component = PMINFO_UI_APP;
4283 appinfo->package = strdup(ptr1->package);
4284 appinfo->uiapp_info = ptr1;
4286 ret = __appinfo_check_installed_storage(appinfo);
4290 ret = app_func((void *)appinfo, user_data);
4293 free((void *)appinfo->package);
4294 appinfo->package = NULL;
4297 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4299 appinfo->app_component = PMINFO_SVC_APP;
4300 appinfo->package = strdup(ptr2->package);
4301 appinfo->svcapp_info = ptr2;
4303 ret = app_func((void *)appinfo, user_data);
4306 free((void *)appinfo->package);
4307 appinfo->package = NULL;
4312 sqlite3_close(appinfo_db);
4318 __cleanup_pkginfo(info);
4322 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4324 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4326 int ret = PMINFO_R_OK;
4327 char query[MAX_QUERY_LEN] = {'\0'};
4328 char *syslocale = NULL;
4329 char *locale = NULL;
4330 pkgmgr_appinfo_x *appinfo = NULL;
4331 uiapplication_x *ptr1 = NULL;
4332 serviceapplication_x *ptr2 = NULL;
4333 label_x *tmp1 = NULL;
4334 icon_x *tmp2 = NULL;
4335 category_x *tmp3 = NULL;
4336 metadata_x *tmp4 = NULL;
4337 permission_x *tmp5 = NULL;
4338 image_x *tmp6 = NULL;
4339 sqlite3 *appinfo_db = NULL;
4341 /*get system locale*/
4342 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4343 locale = __convert_system_locale_to_manifest_locale(syslocale);
4344 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4347 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
4348 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4351 pkgmgr_pkginfo_x *info = NULL;
4352 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4353 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4355 /*calloc manifest_info*/
4356 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4357 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4360 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4361 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4363 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4364 ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
4365 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4367 if (info->manifest_info->uiapplication) {
4368 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4369 info->manifest_info->uiapplication = ptr1;
4371 if (info->manifest_info->serviceapplication) {
4372 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4373 info->manifest_info->serviceapplication = ptr2;
4377 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4379 appinfo->locale = strdup(locale);
4380 appinfo->app_component = PMINFO_UI_APP;
4381 appinfo->package = strdup(ptr1->package);
4382 appinfo->uiapp_info = ptr1;
4383 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4384 "from package_app_info where " \
4385 "app_id='%s'", ptr1->appid);
4386 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4387 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4389 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
4393 locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
4396 memset(query, '\0', MAX_QUERY_LEN);
4397 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4398 "from package_app_localized_info where " \
4399 "app_id='%s' and app_locale='%s'",
4400 ptr1->appid, locale);
4401 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4402 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4404 memset(query, '\0', MAX_QUERY_LEN);
4405 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4406 "from package_app_localized_info where " \
4407 "app_id='%s' and app_locale='%s'",
4408 ptr1->appid, DEFAULT_LOCALE);
4410 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4411 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4413 /*store setting notification icon section*/
4414 memset(query, '\0', MAX_QUERY_LEN);
4415 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
4416 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4417 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4419 /*store app preview image info*/
4420 memset(query, '\0', MAX_QUERY_LEN);
4421 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
4422 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4423 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4425 if (appinfo->uiapp_info->label) {
4426 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4427 appinfo->uiapp_info->label = tmp1;
4429 if (appinfo->uiapp_info->icon) {
4430 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4431 appinfo->uiapp_info->icon= tmp2;
4433 if (appinfo->uiapp_info->category) {
4434 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4435 appinfo->uiapp_info->category = tmp3;
4437 if (appinfo->uiapp_info->metadata) {
4438 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4439 appinfo->uiapp_info->metadata = tmp4;
4441 if (appinfo->uiapp_info->permission) {
4442 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4443 appinfo->uiapp_info->permission = tmp5;
4445 if (appinfo->uiapp_info->image) {
4446 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4447 appinfo->uiapp_info->image = tmp6;
4450 ret = __appinfo_check_installed_storage(appinfo);
4454 ret = app_func((void *)appinfo, user_data);
4457 free((void *)appinfo->package);
4458 appinfo->package = NULL;
4461 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4463 appinfo->locale = strdup(locale);
4464 appinfo->app_component = PMINFO_SVC_APP;
4465 appinfo->package = strdup(ptr2->package);
4466 appinfo->svcapp_info = ptr2;
4467 memset(query, '\0', MAX_QUERY_LEN);
4468 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4469 "from package_app_info where " \
4470 "app_id='%s'", ptr2->appid);
4471 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4472 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4474 memset(query, '\0', MAX_QUERY_LEN);
4475 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4476 "from package_app_localized_info where " \
4477 "app_id='%s' and app_locale='%s'",
4478 ptr2->appid, locale);
4479 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4480 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4482 memset(query, '\0', MAX_QUERY_LEN);
4483 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4484 "from package_app_localized_info where " \
4485 "app_id='%s' and app_locale='%s'",
4486 ptr2->appid, DEFAULT_LOCALE);
4487 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4488 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4490 if (appinfo->svcapp_info->label) {
4491 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4492 appinfo->svcapp_info->label = tmp1;
4494 if (appinfo->svcapp_info->icon) {
4495 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4496 appinfo->svcapp_info->icon= tmp2;
4498 if (appinfo->svcapp_info->category) {
4499 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4500 appinfo->svcapp_info->category = tmp3;
4502 if (appinfo->svcapp_info->metadata) {
4503 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4504 appinfo->svcapp_info->metadata = tmp4;
4506 if (appinfo->svcapp_info->permission) {
4507 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4508 appinfo->svcapp_info->permission = tmp5;
4510 ret = app_func((void *)appinfo, user_data);
4513 free((void *)appinfo->package);
4514 appinfo->package = NULL;
4527 sqlite3_close(appinfo_db);
4532 __cleanup_pkginfo(info);
4536 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
4538 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
4539 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4541 pkgmgr_appinfo_x *appinfo = NULL;
4542 char *syslocale = NULL;
4543 char *locale = NULL;
4546 label_x *tmp1 = NULL;
4547 icon_x *tmp2 = NULL;
4548 category_x *tmp3 = NULL;
4549 metadata_x *tmp4 = NULL;
4550 permission_x *tmp5 = NULL;
4551 image_x *tmp6 = NULL;
4552 char query[MAX_QUERY_LEN] = {'\0'};
4553 sqlite3 *appinfo_db = NULL;
4556 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
4557 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
4559 /*check appid exist on db*/
4560 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
4561 ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
4562 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
4563 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
4565 /*get system locale*/
4566 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4567 locale = __convert_system_locale_to_manifest_locale(syslocale);
4568 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4571 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4572 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
4574 /*check app_component from DB*/
4575 memset(query, '\0', MAX_QUERY_LEN);
4576 snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
4577 ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
4578 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4580 /*calloc app_component*/
4581 if (appinfo->app_component == PMINFO_UI_APP) {
4582 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
4583 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
4585 appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
4586 tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
4588 appinfo->locale = strdup(locale);
4590 /*populate app_info from DB*/
4591 memset(query, '\0', MAX_QUERY_LEN);
4592 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
4593 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4594 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4596 memset(query, '\0', MAX_QUERY_LEN);
4597 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
4598 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4599 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4601 /*Also store the values corresponding to default locales*/
4602 memset(query, '\0', MAX_QUERY_LEN);
4603 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
4604 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4605 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4607 /*Populate app category*/
4608 memset(query, '\0', MAX_QUERY_LEN);
4609 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
4610 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4611 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
4613 /*Populate app metadata*/
4614 memset(query, '\0', MAX_QUERY_LEN);
4615 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
4616 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4617 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
4619 /*Populate app permission*/
4620 memset(query, '\0', MAX_QUERY_LEN);
4621 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
4622 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4623 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
4625 /*store setting notification icon section*/
4626 memset(query, '\0', MAX_QUERY_LEN);
4627 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
4628 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4629 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4631 /*store app preview image info*/
4632 memset(query, '\0', MAX_QUERY_LEN);
4633 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
4634 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
4635 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4637 ret = __appinfo_check_installed_storage(appinfo);
4638 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "[%s] is installed external, but is not in mmc", appinfo->package);
4640 switch (appinfo->app_component) {
4642 if (appinfo->uiapp_info->label) {
4643 LISTHEAD(appinfo->uiapp_info->label, tmp1);
4644 appinfo->uiapp_info->label = tmp1;
4646 if (appinfo->uiapp_info->icon) {
4647 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
4648 appinfo->uiapp_info->icon = tmp2;
4650 if (appinfo->uiapp_info->category) {
4651 LISTHEAD(appinfo->uiapp_info->category, tmp3);
4652 appinfo->uiapp_info->category = tmp3;
4654 if (appinfo->uiapp_info->metadata) {
4655 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
4656 appinfo->uiapp_info->metadata = tmp4;
4658 if (appinfo->uiapp_info->permission) {
4659 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
4660 appinfo->uiapp_info->permission = tmp5;
4662 if (appinfo->uiapp_info->image) {
4663 LISTHEAD(appinfo->uiapp_info->image, tmp6);
4664 appinfo->uiapp_info->image = tmp6;
4667 case PMINFO_SVC_APP:
4668 if (appinfo->svcapp_info->label) {
4669 LISTHEAD(appinfo->svcapp_info->label, tmp1);
4670 appinfo->svcapp_info->label = tmp1;
4672 if (appinfo->svcapp_info->icon) {
4673 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
4674 appinfo->svcapp_info->icon = tmp2;
4676 if (appinfo->svcapp_info->category) {
4677 LISTHEAD(appinfo->svcapp_info->category, tmp3);
4678 appinfo->svcapp_info->category = tmp3;
4680 if (appinfo->svcapp_info->metadata) {
4681 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
4682 appinfo->svcapp_info->metadata = tmp4;
4684 if (appinfo->svcapp_info->permission) {
4685 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
4686 appinfo->svcapp_info->permission = tmp5;
4696 if (ret == PMINFO_R_OK)
4697 *handle = (void*)appinfo;
4700 __cleanup_appinfo(appinfo);
4703 sqlite3_close(appinfo_db);
4716 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
4718 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4719 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4720 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4722 if (info->app_component == PMINFO_UI_APP)
4723 *appid = (char *)info->uiapp_info->appid;
4724 else if (info->app_component == PMINFO_SVC_APP)
4725 *appid = (char *)info->svcapp_info->appid;
4730 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
4732 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4733 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4734 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4736 *pkg_name = (char *)info->package;
4741 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
4743 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4744 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4745 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4747 *pkgid = (char *)info->package;
4752 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
4754 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4755 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4756 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4758 if (info->app_component == PMINFO_UI_APP)
4759 *exec = (char *)info->uiapp_info->exec;
4760 if (info->app_component == PMINFO_SVC_APP)
4761 *exec = (char *)info->svcapp_info->exec;
4767 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4769 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4770 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4771 char *locale = NULL;
4773 icon_x *start = NULL;
4776 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4777 locale = info->locale;
4778 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4780 if (info->app_component == PMINFO_UI_APP)
4781 start = info->uiapp_info->icon;
4782 if (info->app_component == PMINFO_SVC_APP)
4783 start = info->svcapp_info->icon;
4784 for(ptr = start; ptr != NULL; ptr = ptr->next)
4787 if (strcmp(ptr->lang, locale) == 0) {
4788 *icon = (char *)ptr->text;
4789 if (strcasecmp(*icon, "(null)") == 0) {
4790 locale = DEFAULT_LOCALE;
4794 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4795 *icon = (char *)ptr->text;
4804 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
4806 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4807 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4808 char *locale = NULL;
4809 label_x *ptr = NULL;
4810 label_x *start = NULL;
4813 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4814 locale = info->locale;
4815 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
4817 if (info->app_component == PMINFO_UI_APP)
4818 start = info->uiapp_info->label;
4819 if (info->app_component == PMINFO_SVC_APP)
4820 start = info->svcapp_info->label;
4821 for(ptr = start; ptr != NULL; ptr = ptr->next)
4824 if (strcmp(ptr->lang, locale) == 0) {
4825 *label = (char *)ptr->text;
4826 if (strcasecmp(*label, "(null)") == 0) {
4827 locale = DEFAULT_LOCALE;
4831 } else if (strncasecmp(ptr->lang, locale, 2) == 0) {
4832 *label = (char *)ptr->text;
4833 if (strcasecmp(*label, "(null)") == 0) {
4834 locale = DEFAULT_LOCALE;
4838 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
4839 *label = (char *)ptr->text;
4848 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
4850 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4851 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4852 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4854 if (info->app_component == PMINFO_UI_APP)
4855 *component = PMINFO_UI_APP;
4856 else if (info->app_component == PMINFO_SVC_APP)
4857 *component = PMINFO_SVC_APP;
4859 return PMINFO_R_ERROR;
4864 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
4866 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4867 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4868 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4870 if (info->app_component == PMINFO_UI_APP)
4871 *app_type = (char *)info->uiapp_info->type;
4872 if (info->app_component == PMINFO_SVC_APP)
4873 *app_type = (char *)info->svcapp_info->type;
4878 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
4879 int *operation_count, char ***operation)
4881 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4882 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4883 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4884 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4885 *operation_count = data->operation_count;
4886 *operation = data->operation;
4890 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
4891 int *uri_count, char ***uri)
4893 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4894 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4895 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4896 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4897 *uri_count = data->uri_count;
4902 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
4903 int *mime_count, char ***mime)
4905 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4906 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4907 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4908 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4909 *mime_count = data->mime_count;
4914 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
4915 int *subapp_count, char ***subapp)
4917 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4918 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4919 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4920 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
4921 *subapp_count = data->subapp_count;
4922 *subapp = data->subapp;
4926 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4928 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4929 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4933 icon_x *start = NULL;
4934 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4936 start = info->uiapp_info->icon;
4938 for(ptr = start; ptr != NULL; ptr = ptr->next)
4941 val = (char *)ptr->section;
4942 if (strcmp(val, "setting") == 0){
4943 *icon = (char *)ptr->text;
4952 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
4954 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
4955 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4959 icon_x *start = NULL;
4960 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4962 start = info->uiapp_info->icon;
4964 for(ptr = start; ptr != NULL; ptr = ptr->next)
4967 val = (char *)ptr->section;
4969 if (strcmp(val, "notification") == 0){
4970 *icon = (char *)ptr->text;
4979 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
4981 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
4982 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
4984 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
4985 val = (char *)info->uiapp_info->recentimage;
4987 if (strcasecmp(val, "capture") == 0)
4988 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
4989 else if (strcasecmp(val, "icon") == 0)
4990 *type = PMINFO_RECENTIMAGE_USE_ICON;
4992 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
4998 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
5000 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5001 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5004 image_x *ptr = NULL;
5005 image_x *start = NULL;
5006 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5008 start = info->uiapp_info->image;
5010 for(ptr = start; ptr != NULL; ptr = ptr->next)
5013 val = (char *)ptr->section;
5015 if (strcmp(val, "preview") == 0)
5016 *preview_img = (char *)ptr->text;
5024 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
5026 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5027 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5030 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5032 if (info->app_component == PMINFO_UI_APP)
5033 val = info->uiapp_info->permission_type;
5034 else if (info->app_component == PMINFO_SVC_APP)
5035 val = info->svcapp_info->permission_type;
5037 return PMINFO_R_ERROR;
5039 if (strcmp(val, "signature") == 0)
5040 *permission = PMINFO_PERMISSION_SIGNATURE;
5041 else if (strcmp(val, "privilege") == 0)
5042 *permission = PMINFO_PERMISSION_PRIVILEGE;
5044 *permission = PMINFO_PERMISSION_NORMAL;
5049 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
5051 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5052 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5053 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5055 *component_type = (char *)info->uiapp_info->component_type;
5060 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
5062 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5063 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5065 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5066 val = (char *)info->uiapp_info->hwacceleration;
5068 if (strcasecmp(val, "not-use-GL") == 0)
5069 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
5070 else if (strcasecmp(val, "use-GL") == 0)
5071 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
5073 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
5078 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
5080 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5081 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5083 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5084 val = (char *)info->uiapp_info->screenreader;
5086 if (strcasecmp(val, "screenreader-off") == 0)
5087 *screenreader = PMINFO_SCREENREADER_OFF;
5088 else if (strcasecmp(val, "screenreader-on") == 0)
5089 *screenreader = PMINFO_SCREENREADER_ON;
5091 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
5096 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
5098 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5099 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5100 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5101 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5103 if (info->app_component == PMINFO_UI_APP){
5104 *portrait_img = (char *)info->uiapp_info->portraitimg;
5105 *landscape_img = (char *)info->uiapp_info->landscapeimg;
5111 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
5113 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5114 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5115 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5117 *submode_mainid = (char *)info->uiapp_info->submode_mainid;
5122 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
5123 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
5125 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5126 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5128 permission_x *ptr = NULL;
5129 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5130 if (info->app_component == PMINFO_UI_APP)
5131 ptr = info->uiapp_info->permission;
5132 else if (info->app_component == PMINFO_SVC_APP)
5133 ptr = info->svcapp_info->permission;
5135 return PMINFO_R_EINVAL;
5136 for (; ptr; ptr = ptr->next) {
5138 ret = permission_func(ptr->value, user_data);
5146 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
5147 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
5149 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5150 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5152 category_x *ptr = NULL;
5153 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5154 if (info->app_component == PMINFO_UI_APP)
5155 ptr = info->uiapp_info->category;
5156 else if (info->app_component == PMINFO_SVC_APP)
5157 ptr = info->svcapp_info->category;
5159 return PMINFO_R_EINVAL;
5160 for (; ptr; ptr = ptr->next) {
5162 ret = category_func(ptr->name, user_data);
5170 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
5171 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
5173 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5174 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5176 metadata_x *ptr = NULL;
5177 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5178 if (info->app_component == PMINFO_UI_APP)
5179 ptr = info->uiapp_info->metadata;
5180 else if (info->app_component == PMINFO_SVC_APP)
5181 ptr = info->svcapp_info->metadata;
5183 return PMINFO_R_EINVAL;
5184 for (; ptr; ptr = ptr->next) {
5186 ret = metadata_func(ptr->key, ptr->value, user_data);
5194 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
5195 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
5197 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5198 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
5206 char *manifest = NULL;
5207 char **operation = NULL;
5210 char **subapp = NULL;
5211 appcontrol_x *appcontrol = NULL;
5212 manifest_x *mfx = NULL;
5213 operation_x *op = NULL;
5216 subapp_x *sa = NULL;
5217 pkgmgrinfo_app_component component;
5218 pkgmgrinfo_appcontrol_x *ptr = NULL;
5219 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
5221 _LOGE("Failed to get package name\n");
5222 return PMINFO_R_ERROR;
5224 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
5226 _LOGE("Failed to get app component name\n");
5227 return PMINFO_R_ERROR;
5229 manifest = pkgmgr_parser_get_manifest_file(pkgid);
5230 if (manifest == NULL) {
5231 _LOGE("Failed to fetch package manifest file\n");
5232 return PMINFO_R_ERROR;
5234 mfx = pkgmgr_parser_process_manifest_xml(manifest);
5236 _LOGE("Failed to parse package manifest file\n");
5239 return PMINFO_R_ERROR;
5242 ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
5244 _LOGE("Out of Memory!!!\n");
5245 pkgmgr_parser_free_manifest_xml(mfx);
5246 return PMINFO_R_ERROR;
5248 /*Get Operation, Uri, Mime*/
5249 switch (component) {
5251 if (mfx->uiapplication) {
5252 if (mfx->uiapplication->appsvc) {
5253 appcontrol = mfx->uiapplication->appsvc;
5257 case PMINFO_SVC_APP:
5258 if (mfx->serviceapplication) {
5259 if (mfx->serviceapplication->appsvc) {
5260 appcontrol = mfx->serviceapplication->appsvc;
5267 for (; appcontrol; appcontrol = appcontrol->next) {
5268 op = appcontrol->operation;
5269 for (; op; op = op->next)
5271 op = appcontrol->operation;
5273 ui = appcontrol->uri;
5274 for (; ui; ui = ui->next)
5276 ui = appcontrol->uri;
5278 mi = appcontrol->mime;
5279 for (; mi; mi = mi->next)
5281 mi = appcontrol->mime;
5283 sa = appcontrol->subapp;
5284 for (; sa; sa = sa->next)
5286 sa = appcontrol->subapp;
5288 operation = (char **)calloc(oc, sizeof(char *));
5289 for (i = 0; i < oc; i++) {
5290 operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
5294 uri = (char **)calloc(uc, sizeof(char *));
5295 for (i = 0; i < uc; i++) {
5296 uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
5300 mime = (char **)calloc(mc, sizeof(char *));
5301 for (i = 0; i < mc; i++) {
5302 mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
5306 subapp = (char **)calloc(sc, sizeof(char *));
5307 for (i = 0; i < sc; i++) {
5308 subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
5312 /*populate appcontrol handle*/
5313 ptr->operation_count = oc;
5314 ptr->uri_count = uc;
5315 ptr->mime_count = mc;
5316 ptr->subapp_count = sc;
5317 ptr->operation = operation;
5320 ptr->subapp = subapp;
5322 ret = appcontrol_func((void *)ptr, user_data);
5323 for (i = 0; i < oc; i++) {
5326 operation[i] = NULL;
5333 for (i = 0; i < uc; i++) {
5343 for (i = 0; i < mc; i++) {
5353 for (i = 0; i < sc; i++) {
5370 pkgmgr_parser_free_manifest_xml(mfx);
5378 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
5380 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5381 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5383 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5384 val = (char *)info->uiapp_info->nodisplay;
5386 if (strcasecmp(val, "true") == 0)
5388 else if (strcasecmp(val, "false") == 0)
5396 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
5398 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5399 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5401 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5402 val = (char *)info->uiapp_info->multiple;
5404 if (strcasecmp(val, "true") == 0)
5406 else if (strcasecmp(val, "false") == 0)
5414 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
5416 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5417 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5419 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5420 val = (char *)info->uiapp_info->indicatordisplay;
5422 if (strcasecmp(val, "true") == 0){
5423 *indicator_disp = 1;
5424 }else if (strcasecmp(val, "false") == 0){
5425 *indicator_disp = 0;
5427 *indicator_disp = 0;
5433 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
5435 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5436 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5438 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5439 val = (char *)info->uiapp_info->taskmanage;
5441 if (strcasecmp(val, "true") == 0)
5443 else if (strcasecmp(val, "false") == 0)
5451 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
5453 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5454 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5456 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5457 if (info->app_component == PMINFO_UI_APP)
5458 val = (char *)info->uiapp_info->enabled;
5459 else if (info->app_component == PMINFO_SVC_APP)
5460 val = (char *)info->uiapp_info->enabled;
5462 _LOGE("invalid component type\n");
5463 return PMINFO_R_EINVAL;
5467 if (strcasecmp(val, "true") == 0)
5469 else if (strcasecmp(val, "false") == 0)
5478 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
5480 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5481 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5483 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5484 val = (char *)info->svcapp_info->onboot;
5486 if (strcasecmp(val, "true") == 0)
5488 else if (strcasecmp(val, "false") == 0)
5496 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
5498 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5499 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5501 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5502 val = (char *)info->svcapp_info->autorestart;
5504 if (strcasecmp(val, "true") == 0)
5506 else if (strcasecmp(val, "false") == 0)
5514 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
5516 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5517 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5519 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5520 val = (char *)info->uiapp_info->mainapp;
5522 if (strcasecmp(val, "true") == 0)
5524 else if (strcasecmp(val, "false") == 0)
5532 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
5534 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5535 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5537 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5538 val = (char *)info->uiapp_info->preload;
5540 if (strcasecmp(val, "true") == 0)
5542 else if (strcasecmp(val, "false") == 0)
5550 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
5552 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5553 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5555 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5556 val = (char *)info->uiapp_info->submode;
5558 if (strcasecmp(val, "true") == 0)
5560 else if (strcasecmp(val, "false") == 0)
5568 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
5570 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5571 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5572 __cleanup_appinfo(info);
5576 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
5578 return (pkgmgrinfo_pkginfo_filter_create(handle));
5581 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
5583 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
5586 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
5587 const char *property, const int value)
5589 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5590 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5591 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
5593 GSList *link = NULL;
5595 prop = _pminfo_appinfo_convert_to_prop_int(property);
5596 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
5597 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
5598 _LOGE("Invalid Integer Property\n");
5599 return PMINFO_R_EINVAL;
5601 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5602 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5604 _LOGE("Out of Memory!!!\n");
5605 return PMINFO_R_ERROR;
5607 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
5608 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
5610 _LOGE("Out of Memory\n");
5613 return PMINFO_R_ERROR;
5617 /*If API is called multiple times for same property, we should override the previous values.
5618 Last value set will be used for filtering.*/
5619 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5621 filter->list = g_slist_delete_link(filter->list, link);
5622 filter->list = g_slist_append(filter->list, (gpointer)node);
5627 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
5628 const char *property, const bool value)
5630 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5631 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5633 GSList *link = NULL;
5635 prop = _pminfo_appinfo_convert_to_prop_bool(property);
5636 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
5637 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
5638 _LOGE("Invalid Boolean Property\n");
5639 return PMINFO_R_EINVAL;
5641 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5642 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5644 _LOGE("Out of Memory!!!\n");
5645 return PMINFO_R_ERROR;
5648 val = strndup("('true','True')", 15);
5650 val = strndup("('false','False')", 17);
5652 _LOGE("Out of Memory\n");
5655 return PMINFO_R_ERROR;
5659 /*If API is called multiple times for same property, we should override the previous values.
5660 Last value set will be used for filtering.*/
5661 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5663 filter->list = g_slist_delete_link(filter->list, link);
5664 filter->list = g_slist_append(filter->list, (gpointer)node);
5669 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
5670 const char *property, const char *value)
5672 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5673 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5674 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5676 pkgmgrinfo_node_x *ptr = NULL;
5677 char prev[PKG_STRING_LEN_MAX] = {'\0'};
5678 char temp[PKG_STRING_LEN_MAX] = {'\0'};
5679 GSList *link = NULL;
5681 prop = _pminfo_appinfo_convert_to_prop_str(property);
5682 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
5683 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
5684 _LOGE("Invalid String Property\n");
5685 return PMINFO_R_EINVAL;
5687 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5688 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
5690 _LOGE("Out of Memory!!!\n");
5691 return PMINFO_R_ERROR;
5695 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
5696 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
5697 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
5699 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
5701 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5703 filter->list = g_slist_delete_link(filter->list, link);
5704 filter->list = g_slist_append(filter->list, (gpointer)node);
5706 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
5707 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
5708 case E_PMINFO_APPINFO_PROP_APP_URI:
5709 case E_PMINFO_APPINFO_PROP_APP_MIME:
5710 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
5712 _LOGE("Out of Memory\n");
5715 return PMINFO_R_ERROR;
5717 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5719 ptr = (pkgmgrinfo_node_x *)link->data;
5720 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
5721 _LOGS("Previous value is %s\n", prev);
5722 filter->list = g_slist_delete_link(filter->list, link);
5723 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
5724 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5725 _LOGS("New value is %s\n", val);
5727 filter->list = g_slist_append(filter->list, (gpointer)node);
5728 memset(temp, '\0', PKG_STRING_LEN_MAX);
5730 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
5731 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
5732 _LOGS("First value is %s\n", val);
5734 filter->list = g_slist_append(filter->list, (gpointer)node);
5735 memset(temp, '\0', PKG_STRING_LEN_MAX);
5739 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
5740 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
5742 filter->list = g_slist_delete_link(filter->list, link);
5743 filter->list = g_slist_append(filter->list, (gpointer)node);
5749 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
5751 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5752 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5753 char *syslocale = NULL;
5754 char *locale = NULL;
5755 char *condition = NULL;
5756 char query[MAX_QUERY_LEN] = {'\0'};
5757 char where[MAX_QUERY_LEN] = {'\0'};
5760 uiapplication_x *ptr1 = NULL;
5761 serviceapplication_x *ptr2 = NULL;
5762 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5763 sqlite3 *pkginfo_db = NULL;
5764 int filter_count = 0;
5767 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
5768 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
5770 /*get system locale*/
5771 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5772 locale = __convert_system_locale_to_manifest_locale(syslocale);
5773 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
5775 /*Start constructing query*/
5776 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
5777 /*Get where clause*/
5778 for (list = filter->list; list; list = g_slist_next(list)) {
5779 __get_filter_condition(list->data, &condition);
5781 strncat(where, condition, sizeof(where) - strlen(where) -1);
5782 where[sizeof(where) - 1] = '\0';
5786 if (g_slist_next(list)) {
5787 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5788 where[sizeof(where) - 1] = '\0';
5791 _LOGS("where = %s\n", where);
5792 if (strlen(where) > 0) {
5793 strncat(query, where, sizeof(query) - strlen(query) - 1);
5794 query[sizeof(query) - 1] = '\0';
5796 _LOGS("query = %s\n", query);
5797 /*To get filtered list*/
5798 pkgmgr_pkginfo_x *info = NULL;
5799 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5800 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5802 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5803 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5805 /*To get detail app info for each member of filtered list*/
5806 pkgmgr_pkginfo_x *filtinfo = NULL;
5807 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5808 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5810 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5811 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5813 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5814 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5816 ret = __exec_db_query(pkginfo_db, query, __app_list_cb, (void *)info);
5817 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5819 memset(query, '\0', MAX_QUERY_LEN);
5820 if (info->manifest_info->uiapplication) {
5821 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5822 info->manifest_info->uiapplication = ptr1;
5824 if (info->manifest_info->serviceapplication) {
5825 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5826 info->manifest_info->serviceapplication = ptr2;
5828 /*Filtered UI Apps*/
5829 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5831 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5832 ptr1->appid, "uiapp");
5833 ret = __exec_db_query(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo);
5834 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5836 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5838 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5839 ptr2->appid, "svcapp");
5840 ret = __exec_db_query(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo);
5841 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5843 if (filtinfo->manifest_info->uiapplication) {
5844 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5845 filtinfo->manifest_info->uiapplication = ptr1;
5847 /*If the callback func return < 0 we break and no more call back is called*/
5850 appinfo->locale = strdup(locale);
5851 appinfo->uiapp_info = ptr1;
5852 appinfo->app_component = PMINFO_UI_APP;
5854 ret = __appinfo_check_installed_storage(appinfo);
5864 /*Filtered Service Apps*/
5865 if (filtinfo->manifest_info->serviceapplication) {
5866 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
5867 filtinfo->manifest_info->serviceapplication = ptr2;
5869 /*If the callback func return < 0 we break and no more call back is called*/
5872 appinfo->locale = strdup(locale);
5873 appinfo->svcapp_info = ptr2;
5874 appinfo->app_component = PMINFO_SVC_APP;
5878 *count = filter_count;
5890 sqlite3_close(pkginfo_db);
5895 __cleanup_pkginfo(info);
5896 __cleanup_pkginfo(filtinfo);
5900 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
5901 pkgmgrinfo_app_list_cb app_cb, void * user_data)
5903 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5904 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
5905 char *syslocale = NULL;
5906 char *locale = NULL;
5907 char *condition = NULL;
5908 char query[MAX_QUERY_LEN] = {'\0'};
5909 char where[MAX_QUERY_LEN] = {'\0'};
5912 uiapplication_x *ptr1 = NULL;
5913 serviceapplication_x *ptr2 = NULL;
5914 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
5915 sqlite3 *pkginfo_db = NULL;
5918 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
5919 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
5921 /*get system locale*/
5922 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5923 locale = __convert_system_locale_to_manifest_locale(syslocale);
5924 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
5926 /*Start constructing query*/
5927 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
5928 /*Get where clause*/
5929 for (list = filter->list; list; list = g_slist_next(list)) {
5930 __get_filter_condition(list->data, &condition);
5932 strncat(where, condition, sizeof(where) - strlen(where) -1);
5933 where[sizeof(where) - 1] = '\0';
5937 if (g_slist_next(list)) {
5938 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
5939 where[sizeof(where) - 1] = '\0';
5942 _LOGS("where = %s\n", where);
5943 if (strlen(where) > 0) {
5944 strncat(query, where, sizeof(query) - strlen(query) - 1);
5945 query[sizeof(query) - 1] = '\0';
5947 _LOGS("query = %s\n", query);
5948 /*To get filtered list*/
5949 pkgmgr_pkginfo_x *info = NULL;
5950 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5951 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5953 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5954 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5956 /*To get detail app info for each member of filtered list*/
5957 pkgmgr_pkginfo_x *filtinfo = NULL;
5958 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
5959 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5961 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
5962 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5964 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5965 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
5967 ret = __exec_db_query(pkginfo_db, query, __app_list_cb, (void *)info);
5968 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5970 memset(query, '\0', MAX_QUERY_LEN);
5971 if (info->manifest_info->uiapplication) {
5972 LISTHEAD(info->manifest_info->uiapplication, ptr1);
5973 info->manifest_info->uiapplication = ptr1;
5975 if (info->manifest_info->serviceapplication) {
5976 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
5977 info->manifest_info->serviceapplication = ptr2;
5979 /*Filtered UI Apps*/
5980 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
5982 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5983 ptr1->appid, "uiapp");
5984 ret = __exec_db_query(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo);
5985 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5987 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5989 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
5990 ptr2->appid, "svcapp");
5991 ret = __exec_db_query(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo);
5992 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
5994 if (filtinfo->manifest_info->uiapplication) {
5995 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
5996 filtinfo->manifest_info->uiapplication = ptr1;
5998 /*If the callback func return < 0 we break and no more call back is called*/
6001 appinfo->locale = strdup(locale);
6002 appinfo->uiapp_info = ptr1;
6003 appinfo->app_component = PMINFO_UI_APP;
6005 ret = __appinfo_check_installed_storage(appinfo);
6011 ret = app_cb((void *)appinfo, user_data);
6016 /*Filtered Service Apps*/
6017 if (filtinfo->manifest_info->serviceapplication) {
6018 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
6019 filtinfo->manifest_info->serviceapplication = ptr2;
6021 /*If the callback func return < 0 we break and no more call back is called*/
6024 appinfo->locale = strdup(locale);
6025 appinfo->svcapp_info = ptr2;
6026 appinfo->app_component = PMINFO_SVC_APP;
6027 ret = app_cb((void *)appinfo, user_data);
6042 sqlite3_close(pkginfo_db);
6047 __cleanup_pkginfo(info);
6048 __cleanup_pkginfo(filtinfo);
6052 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
6054 return (pkgmgrinfo_pkginfo_filter_create(handle));
6057 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
6059 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
6062 API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
6063 const char *key, const char *value)
6065 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
6066 retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
6067 /*value can be NULL. In that case all apps with specified key should be displayed*/
6071 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
6072 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
6073 retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
6075 tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6079 tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6082 /*If API is called multiple times, we should OR all conditions.*/
6083 filter->list = g_slist_append(filter->list, (gpointer)node);
6084 /*All memory will be freed in destroy API*/
6102 API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
6103 pkgmgrinfo_app_list_cb app_cb, void *user_data)
6105 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
6106 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
6107 char *syslocale = NULL;
6108 char *locale = NULL;
6109 char *condition = NULL;
6110 char *error_message = NULL;
6111 char query[MAX_QUERY_LEN] = {'\0'};
6112 char where[MAX_QUERY_LEN] = {'\0'};
6115 pkgmgr_pkginfo_x *info = NULL;
6116 pkgmgr_pkginfo_x *filtinfo = NULL;
6117 pkgmgr_appinfo_x *appinfo = NULL;
6118 uiapplication_x *ptr1 = NULL;
6119 serviceapplication_x *ptr2 = NULL;
6120 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
6121 sqlite3 *pkginfo_db = NULL;
6124 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
6125 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
6127 /*Get current locale*/
6128 syslocale = vconf_get_str(VCONFKEY_LANGSET);
6129 locale = __convert_system_locale_to_manifest_locale(syslocale);
6130 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
6132 /*Start constructing query*/
6133 memset(where, '\0', MAX_QUERY_LEN);
6134 memset(query, '\0', MAX_QUERY_LEN);
6135 snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
6136 /*Get where clause*/
6137 for (list = filter->list; list; list = g_slist_next(list)) {
6138 __get_metadata_filter_condition(list->data, &condition);
6140 strncat(where, condition, sizeof(where) - strlen(where) -1);
6144 if (g_slist_next(list)) {
6145 strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
6148 _LOGE("where = %s (%d)\n", where, strlen(where));
6149 if (strlen(where) > 0) {
6150 strncat(query, where, sizeof(query) - strlen(query) - 1);
6152 _LOGE("query = %s (%d)\n", query, strlen(query));
6153 /*To get filtered list*/
6154 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
6155 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6157 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
6158 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6160 /*To get detail app info for each member of filtered list*/
6161 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
6162 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6164 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
6165 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6167 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
6168 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
6170 ret = sqlite3_exec(pkginfo_db, query, __app_list_cb, (void *)info, &error_message);
6171 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
6172 memset(query, '\0', MAX_QUERY_LEN);
6174 if (info->manifest_info->uiapplication) {
6175 LISTHEAD(info->manifest_info->uiapplication, ptr1);
6176 info->manifest_info->uiapplication = ptr1;
6178 if (info->manifest_info->serviceapplication) {
6179 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
6180 info->manifest_info->serviceapplication = ptr2;
6184 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
6186 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
6187 ptr1->appid, "uiapp");
6188 ret = sqlite3_exec(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message);
6189 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
6190 memset(query, '\0', MAX_QUERY_LEN);
6193 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
6195 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
6196 ptr2->appid, "svcapp");
6197 ret = sqlite3_exec(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message);
6198 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
6199 memset(query, '\0', MAX_QUERY_LEN);
6201 /*Filtered UI Apps*/
6202 if (filtinfo->manifest_info->uiapplication) {
6203 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
6204 filtinfo->manifest_info->uiapplication = ptr1;
6206 /*If the callback func return < 0 we break and no more call back is called*/
6209 appinfo->locale = strdup(locale);
6210 appinfo->uiapp_info = ptr1;
6211 appinfo->app_component = PMINFO_UI_APP;
6212 ret = app_cb((void *)appinfo, user_data);
6217 /*Filtered Service Apps*/
6218 if (filtinfo->manifest_info->serviceapplication) {
6219 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
6220 filtinfo->manifest_info->serviceapplication = ptr2;
6222 /*If the callback func return < 0 we break and no more call back is called*/
6225 appinfo->locale = strdup(locale);
6226 appinfo->svcapp_info = ptr2;
6227 appinfo->app_component = PMINFO_SVC_APP;
6228 ret = app_cb((void *)appinfo, user_data);
6243 sqlite3_free(error_message);
6244 sqlite3_close(pkginfo_db);
6249 __cleanup_pkginfo(info);
6250 __cleanup_pkginfo(filtinfo);
6254 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
6256 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6257 pkgmgr_certinfo_x *certinfo = NULL;
6258 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
6259 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
6260 *handle = (void *)certinfo;
6264 API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
6266 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
6267 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
6268 pkgmgr_certinfo_x *certinfo = NULL;
6269 char *error_message = NULL;
6270 int ret = PMINFO_R_OK;
6271 char query[MAX_QUERY_LEN] = {'\0'};
6276 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READONLY, NULL);
6277 if (ret != SQLITE_OK) {
6278 _LOGE("connect db [%s] failed!\n", CERT_DB);
6279 return PMINFO_R_ERROR;
6282 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6284 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6285 _LOGE("Don't execute query = %s error message = %s\n", query,
6287 sqlite3_free(error_message);
6288 ret = PMINFO_R_ERROR;
6292 _LOGE("Package not found in DB\n");
6293 ret = PMINFO_R_ERROR;
6296 certinfo = (pkgmgr_certinfo_x *)handle;
6297 /*populate certinfo from DB*/
6298 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
6299 ret = __exec_certinfo_query(query, (void *)certinfo);
6301 _LOGE("Package Cert Info DB Information retrieval failed\n");
6302 ret = PMINFO_R_ERROR;
6305 for (i = 0; i < MAX_CERT_TYPE; i++) {
6306 memset(query, '\0', MAX_QUERY_LEN);
6307 snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
6308 ret = __exec_certinfo_query(query, (void *)certinfo);
6310 _LOGE("Cert Info DB Information retrieval failed\n");
6311 ret = PMINFO_R_ERROR;
6314 if (certinfo->cert_value) {
6315 (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
6316 free(certinfo->cert_value);
6317 certinfo->cert_value = NULL;
6321 sqlite3_close(cert_db);
6325 API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
6327 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6328 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6329 retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6330 retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6331 pkgmgr_certinfo_x *certinfo = NULL;
6332 certinfo = (pkgmgr_certinfo_x *)handle;
6333 if ((certinfo->cert_info)[cert_type])
6334 *cert_value = (certinfo->cert_info)[cert_type];
6340 API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
6342 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6344 pkgmgr_certinfo_x *certinfo = NULL;
6345 certinfo = (pkgmgr_certinfo_x *)handle;
6346 if (certinfo->pkgid) {
6347 free(certinfo->pkgid);
6348 certinfo->pkgid = NULL;
6350 for (i = 0; i < MAX_CERT_TYPE; i++) {
6351 if ((certinfo->cert_info)[i]) {
6352 free((certinfo->cert_info)[i]);
6353 (certinfo->cert_info)[i] = NULL;
6361 API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
6363 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6364 pkgmgr_instcertinfo_x *certinfo = NULL;
6365 certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
6366 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
6367 *handle = (void *)certinfo;
6371 API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
6373 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6374 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6375 retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6376 retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
6377 pkgmgr_instcertinfo_x *certinfo = NULL;
6378 certinfo = (pkgmgr_instcertinfo_x *)handle;
6379 (certinfo->cert_info)[cert_type] = strdup(cert_value);
6383 API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
6385 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
6386 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
6387 char *error_message = NULL;
6388 char query[MAX_QUERY_LEN] = {'\0'};
6389 char *vquery = NULL;
6394 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
6401 pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
6402 pkgmgr_certindexinfo_x *indexinfo = NULL;
6403 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
6404 if (indexinfo == NULL) {
6405 _LOGE("Out of Memory!!!");
6406 return PMINFO_R_ERROR;
6408 info->pkgid = strdup(pkgid);
6411 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL);
6412 if (ret != SQLITE_OK) {
6413 _LOGE("connect db [%s] failed!\n", CERT_DB);
6414 ret = PMINFO_R_ERROR;
6417 /*Begin Transaction*/
6418 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6419 if (ret != SQLITE_OK) {
6420 _LOGE("Failed to begin transaction\n");
6421 ret = PMINFO_R_ERROR;
6424 _LOGE("Transaction Begin\n");
6425 /*Check if request is to insert/update*/
6426 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
6428 sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
6429 _LOGE("Don't execute query = %s error message = %s\n", query,
6431 sqlite3_free(error_message);
6432 ret = PMINFO_R_ERROR;
6437 We cant just issue update query directly. We need to manage index table also.
6438 Hence it is better to delete and insert again in case of update*/
6439 ret = __delete_certinfo(pkgid);
6441 _LOGE("Certificate Deletion Failed\n");
6443 for (i = 0; i < MAX_CERT_TYPE; i++) {
6444 if ((info->cert_info)[i]) {
6445 for (j = 0; j < i; j++) {
6446 if ( (info->cert_info)[j]) {
6447 if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
6448 (info->cert_id)[i] = (info->cert_id)[j];
6449 (info->is_new)[i] = 0;
6450 (info->ref_count)[i] = (info->ref_count)[j];
6457 memset(query, '\0', MAX_QUERY_LEN);
6458 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
6459 "where cert_info='%s'",(info->cert_info)[i]);
6460 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
6462 _LOGE("Cert Info DB Information retrieval failed\n");
6463 ret = PMINFO_R_ERROR;
6466 if (indexinfo->cert_id == 0) {
6467 /*New certificate. Get newid*/
6468 memset(query, '\0', MAX_QUERY_LEN);
6469 snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
6471 sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
6472 _LOGE("Don't execute query = %s error message = %s\n", query,
6474 sqlite3_free(error_message);
6475 ret = PMINFO_R_ERROR;
6483 indexinfo->cert_id = maxid;
6484 indexinfo->cert_ref_count = 1;
6488 (info->cert_id)[i] = indexinfo->cert_id;
6489 (info->is_new)[i] = is_new;
6490 (info->ref_count)[i] = indexinfo->cert_ref_count;
6491 _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
6492 indexinfo->cert_id = 0;
6493 indexinfo->cert_ref_count = 0;
6497 len = MAX_QUERY_LEN;
6498 for (i = 0; i < MAX_CERT_TYPE; i++) {
6499 if ((info->cert_info)[i])
6500 len+= strlen((info->cert_info)[i]);
6502 vquery = (char *)calloc(1, len);
6504 snprintf(vquery, len,
6505 "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
6506 "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
6507 "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
6508 info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
6509 (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
6510 (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
6511 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
6512 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
6514 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6515 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6517 sqlite3_free(error_message);
6518 ret = PMINFO_R_ERROR;
6521 /*Update index table info*/
6522 /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
6523 for (i = 0; i < MAX_CERT_TYPE; i++) {
6524 if ((info->cert_info)[i]) {
6525 memset(vquery, '\0', len);
6526 if ((info->is_new)[i]) {
6527 snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
6528 "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
6529 unique_id[c++] = (info->cert_id)[i];
6532 for (j = 0; j < MAX_CERT_TYPE; j++) {
6533 if ((info->cert_id)[i] == unique_id[j]) {
6534 /*Ref count has already been increased. Just continue*/
6538 if (j == MAX_CERT_TYPE)
6539 unique_id[c++] = (info->cert_id)[i];
6542 snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
6543 "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
6546 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
6547 _LOGE("Don't execute query = %s error message = %s\n", vquery,
6549 sqlite3_free(error_message);
6550 ret = PMINFO_R_ERROR;
6555 /*Commit transaction*/
6556 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6557 if (ret != SQLITE_OK) {
6558 _LOGE("Failed to commit transaction, Rollback now\n");
6559 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6560 ret = PMINFO_R_ERROR;
6563 _LOGE("Transaction Commit and End\n");
6566 sqlite3_close(cert_db);
6578 API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
6580 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6582 pkgmgr_instcertinfo_x *certinfo = NULL;
6583 certinfo = (pkgmgr_instcertinfo_x *)handle;
6584 if (certinfo->pkgid) {
6585 free(certinfo->pkgid);
6586 certinfo->pkgid = NULL;
6588 for (i = 0; i < MAX_CERT_TYPE; i++) {
6589 if ((certinfo->cert_info)[i]) {
6590 free((certinfo->cert_info)[i]);
6591 (certinfo->cert_info)[i] = NULL;
6599 API int pkgmgrinfo_delete_certinfo(const char *pkgid)
6601 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6604 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL);
6605 if (ret != SQLITE_OK) {
6606 _LOGE("connect db [%s] failed!\n", CERT_DB);
6607 ret = PMINFO_R_ERROR;
6610 /*Begin Transaction*/
6611 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6612 if (ret != SQLITE_OK) {
6613 _LOGE("Failed to begin transaction\n");
6614 ret = PMINFO_R_ERROR;
6617 _LOGE("Transaction Begin\n");
6618 ret = __delete_certinfo(pkgid);
6620 _LOGE("Certificate Deletion Failed\n");
6622 _LOGE("Certificate Deletion Success\n");
6624 /*Commit transaction*/
6625 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
6626 if (ret != SQLITE_OK) {
6627 _LOGE("Failed to commit transaction, Rollback now\n");
6628 sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
6629 ret = PMINFO_R_ERROR;
6632 _LOGE("Transaction Commit and End\n");
6635 sqlite3_close(cert_db);
6639 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
6641 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
6642 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6644 char *manifest = NULL;
6645 manifest_x *mfx = NULL;
6647 manifest = pkgmgr_parser_get_manifest_file(pkgid);
6648 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
6650 mfx = pkgmgr_parser_process_manifest_xml(manifest);
6655 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
6657 *handle = (void *)mfx;
6662 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
6664 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
6665 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6667 int len = strlen(type);
6668 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6670 manifest_x *mfx = (manifest_x *)handle;
6672 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
6676 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
6678 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
6679 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6681 int len = strlen(version);
6682 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6684 manifest_x *mfx = (manifest_x *)handle;
6686 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
6690 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6692 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6693 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6695 manifest_x *mfx = (manifest_x *)handle;
6697 if (location == INSTALL_INTERNAL)
6698 strcpy(mfx->installlocation, "internal-only");
6699 else if (location == INSTALL_EXTERNAL)
6700 strcpy(mfx->installlocation, "prefer-external");
6705 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
6707 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6708 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6710 manifest_x *mfx = (manifest_x *)handle;
6712 mfx->package_size = strdup(size);
6717 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
6719 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6720 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6722 int len = strlen(label_txt);
6723 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6725 manifest_x *mfx = (manifest_x *)handle;
6727 label_x *label = calloc(1, sizeof(label_x));
6728 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6730 LISTADD(mfx->label, label);
6732 mfx->label->lang = strdup(locale);
6734 mfx->label->lang = strdup(DEFAULT_LOCALE);
6735 mfx->label->text = strdup(label_txt);
6740 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
6742 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6743 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6745 int len = strlen(icon_txt);
6746 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6748 manifest_x *mfx = (manifest_x *)handle;
6750 icon_x *icon = calloc(1, sizeof(icon_x));
6751 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6753 LISTADD(mfx->icon, icon);
6755 mfx->icon->lang = strdup(locale);
6757 mfx->icon->lang = strdup(DEFAULT_LOCALE);
6758 mfx->icon->text = strdup(icon_txt);
6763 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
6765 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6766 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
6768 int len = strlen(desc_txt);
6769 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
6771 manifest_x *mfx = (manifest_x *)handle;
6773 description_x *description = calloc(1, sizeof(description_x));
6774 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
6776 LISTADD(mfx->description, description);
6778 mfx->description->lang = strdup(locale);
6780 mfx->description->lang = strdup(DEFAULT_LOCALE);
6781 mfx->description->text = strdup(desc_txt);
6786 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
6787 const char *author_email, const char *author_href, const char *locale)
6789 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6790 manifest_x *mfx = (manifest_x *)handle;
6791 author_x *author = calloc(1, sizeof(author_x));
6792 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
6794 LISTADD(mfx->author, author);
6796 mfx->author->text = strdup(author_name);
6798 mfx->author->email = strdup(author_email);
6800 mfx->author->href = strdup(author_href);
6802 mfx->author->lang = strdup(locale);
6804 mfx->author->lang = strdup(DEFAULT_LOCALE);
6808 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
6810 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6811 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6813 manifest_x *mfx = (manifest_x *)handle;
6816 strcpy(mfx->removable, "false");
6817 else if (removable == 1)
6818 strcpy(mfx->removable, "true");
6823 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
6825 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6826 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6828 manifest_x *mfx = (manifest_x *)handle;
6831 strcpy(mfx->preload, "false");
6832 else if (preload == 1)
6833 strcpy(mfx->preload, "true");
6838 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
6840 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6841 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
6843 manifest_x *mfx = (manifest_x *)handle;
6845 if (location == INSTALL_INTERNAL)
6846 strcpy(mfx->installed_storage, "installed_internal");
6847 else if (location == INSTALL_EXTERNAL)
6848 strcpy(mfx->installed_storage, "installed_external");
6853 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6855 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6858 manifest_x *mfx = NULL;
6859 mfx = (manifest_x *)handle;
6861 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
6862 retvm_if(ret != 0, PMINFO_R_ERROR, "Failed to store info in DB\n");
6864 ret = __update_ail_appinfo(mfx);
6865 retvm_if(ret != 0, PMINFO_R_ERROR, "Failed to store info in DB\n");
6867 _LOGE("Successfully stored info in DB\n");
6871 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
6873 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
6875 manifest_x *mfx = NULL;
6876 mfx = (manifest_x *)handle;
6877 pkgmgr_parser_free_manifest_xml(mfx);
6881 API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
6883 /* Should be implemented later */
6887 API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
6889 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6891 char query[MAX_QUERY_LEN] = {'\0'};
6892 sqlite3 *pkginfo_db = NULL;
6894 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
6895 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
6897 /*Begin transaction*/
6898 ret = sqlite3_exec(pkginfo_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6899 if (ret != SQLITE_OK) {
6900 _LOGE("Failed to begin transaction\n");
6901 sqlite3_close(pkginfo_db);
6902 return PMINFO_R_ERROR;
6904 _LOGD("Transaction Begin\n");
6906 memset(query, '\0', MAX_QUERY_LEN);
6907 snprintf(query, MAX_QUERY_LEN,
6908 "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
6910 char *error_message = NULL;
6912 sqlite3_exec(pkginfo_db, query, NULL, NULL, &error_message)) {
6913 _LOGE("Don't execute query = %s error message = %s\n", query,
6915 sqlite3_free(error_message);
6916 return PMINFO_R_ERROR;
6918 sqlite3_free(error_message);
6920 /*Commit transaction*/
6921 ret = sqlite3_exec(pkginfo_db, "COMMIT", NULL, NULL, NULL);
6922 if (ret != SQLITE_OK) {
6923 _LOGE("Failed to commit transaction. Rollback now\n");
6924 sqlite3_exec(pkginfo_db, "ROLLBACK", NULL, NULL, NULL);
6925 sqlite3_close(pkginfo_db);
6926 return PMINFO_R_ERROR;
6928 _LOGD("Transaction Commit and End\n");
6929 sqlite3_close(pkginfo_db);
6935 API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
6937 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6938 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
6939 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6940 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6941 int ret = PMINFO_R_OK;
6942 char query[MAX_QUERY_LEN] = {'\0'};
6943 char *error_message = NULL;
6944 pkgmgr_datacontrol_x *data = NULL;
6946 sqlite3 *datacontrol_info_db = NULL;
6949 ret = db_util_open(DATACONTROL_DB, &datacontrol_info_db, 0);
6950 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
6952 data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x));
6954 _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
6955 sqlite3_close(datacontrol_info_db);
6956 return PMINFO_R_ERROR;
6959 snprintf(query, MAX_QUERY_LEN,
6960 "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",
6964 sqlite3_exec(datacontrol_info_db, query, __datacontrol_cb, (void *)data, &error_message)) {
6965 _LOGE("Don't execute query = %s error message = %s\n", query,
6967 sqlite3_free(error_message);
6968 sqlite3_close(datacontrol_info_db);
6969 return PMINFO_R_ERROR;
6972 *appid = (char *)data->appid;
6973 *access = (char *)data->access;
6975 sqlite3_close(datacontrol_info_db);
6980 API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
6982 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
6984 char query[MAX_QUERY_LEN] = {'\0'};
6985 char *error_message = NULL;
6986 sqlite3 *pkginfo_db = NULL;
6989 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
6990 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
6992 /*Begin transaction*/
6993 ret = sqlite3_exec(pkginfo_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
6994 if (ret != SQLITE_OK) {
6995 _LOGE("Failed to begin transaction\n");
6996 sqlite3_close(pkginfo_db);
6997 return PMINFO_R_ERROR;
6999 _LOGD("Transaction Begin\n");
7001 memset(query, '\0', MAX_QUERY_LEN);
7002 snprintf(query, MAX_QUERY_LEN, "update package_app_localized_info set app_label='%s' where app_id='%s'", label, appid);
7004 ret = sqlite3_exec(pkginfo_db, query, NULL, NULL, &error_message);
7005 if (ret != SQLITE_OK) {
7006 _LOGE("Don't execute query = %s error message = %s\n", query, error_message);
7007 sqlite3_free(error_message);
7008 return PMINFO_R_ERROR;
7011 /*Commit transaction*/
7012 ret = sqlite3_exec(pkginfo_db, "COMMIT", NULL, NULL, NULL);
7013 if (ret != SQLITE_OK) {
7014 _LOGE("Failed to commit transaction. Rollback now\n");
7015 sqlite3_exec(pkginfo_db, "ROLLBACK", NULL, NULL, NULL);
7016 sqlite3_close(pkginfo_db);
7017 return PMINFO_R_ERROR;
7019 _LOGD("Transaction Commit and End\n");
7020 sqlite3_close(pkginfo_db);
7025 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
7027 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
7028 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
7030 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
7031 val = (char *)info->uiapp_info->guestmode_visibility;
7033 if (strcasecmp(val, "true") == 0){
7035 }else if (strcasecmp(val, "false") == 0){
7044 API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
7046 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
7049 char *noti_string = NULL;
7051 char query[MAX_QUERY_LEN] = {'\0'};
7052 char *errmsg = NULL;
7053 sqlite3 *pkgmgr_parser_db;
7055 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
7056 val = (char *)info->uiapp_info->guestmode_visibility;
7059 db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db, SQLITE_OPEN_READWRITE, NULL);
7061 if (ret != SQLITE_OK) {
7062 _LOGE("DB Open Failed\n");
7063 return PMINFO_R_ERROR;
7066 /*TODO: Write to DB here*/
7068 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
7070 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
7072 if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
7073 _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
7075 sqlite3_close(pkgmgr_parser_db);
7076 return PMINFO_R_ERROR;
7078 sqlite3_close(pkgmgr_parser_db);
7079 len = strlen((char *)info->uiapp_info->appid) + 8;
7080 noti_string = calloc(1, len);
7081 if (noti_string == NULL){
7082 return PMINFO_R_ERROR;
7084 snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
7085 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
7086 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
7093 /* pkgmgrinfo client start*/
7094 API pkgmgrinfo_client *pkgmgrinfo_client_new(pkgmgrinfo_client_type ctype)
7097 char *errmsg = NULL;
7099 void *handle = NULL;
7100 pkgmgrinfo_client *(*__pkgmgr_client_new)(pkgmgrinfo_client_type ctype) = NULL;
7102 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7103 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7105 __pkgmgr_client_new = dlsym(handle, "pkgmgr_client_new");
7107 tryvm_if((errmsg != NULL) || (__pkgmgr_client_new == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7109 pc = __pkgmgr_client_new(ctype);
7110 tryvm_if(pc == NULL, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7114 return (pkgmgrinfo_client *) pc;
7117 API int pkgmgrinfo_client_set_status_type(pkgmgrinfo_client *pc, int status_type)
7120 char *errmsg = NULL;
7121 void *handle = NULL;
7122 int (*__pkgmgr_client_set_status_type)(pkgmgrinfo_client *pc, int status_type) = NULL;
7124 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7125 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7127 __pkgmgr_client_set_status_type = dlsym(handle, "pkgmgr_client_set_status_type");
7129 tryvm_if((errmsg != NULL) || (__pkgmgr_client_set_status_type == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7131 ret = __pkgmgr_client_set_status_type(pc, status_type);
7132 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7139 API int pkgmgrinfo_client_listen_status(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data)
7142 char *errmsg = NULL;
7143 void *handle = NULL;
7144 int (*__pkgmgr_client_listen_status)(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data) = NULL;
7146 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7147 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7149 __pkgmgr_client_listen_status = dlsym(handle, "pkgmgr_client_listen_status");
7151 tryvm_if((errmsg != NULL) || (__pkgmgr_client_listen_status == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7153 ret = __pkgmgr_client_listen_status(pc, event_cb, data);
7154 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7161 API int pkgmgrinfo_client_free(pkgmgrinfo_client *pc)
7164 char *errmsg = NULL;
7165 void *handle = NULL;
7166 int (*__pkgmgr_client_free)(pkgmgrinfo_client *pc) = NULL;
7168 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
7169 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
7171 __pkgmgr_client_free = dlsym(handle, "pkgmgr_client_free");
7173 tryvm_if((errmsg != NULL) || (__pkgmgr_client_free == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
7175 ret = __pkgmgr_client_free(pc);
7176 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
7183 API int pkgmgrinfo_client_request_enable_external_pkg(char *pkgid)
7185 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
7187 if(__get_pkg_location(pkgid) != PMINFO_EXTERNAL_STORAGE)
7190 _LOGD("call system server to enable app2ext");
7191 return mmc_mount_app2ext(pkgid);
7194 /* pkgmgrinfo client end*/