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 <sys/smack.h>
36 #include <linux/limits.h>
40 #include <libxml/parser.h>
41 #include <libxml/xmlreader.h>
42 #include <libxml/xmlschemas.h>
44 #include <dbus/dbus.h>
45 #include <dbus/dbus-glib-lowlevel.h>
47 /* For multi-user support */
48 #include <tzplatform_config.h>
50 #include "pkgmgr_parser.h"
51 #include "pkgmgr-info-internal.h"
52 #include "pkgmgr-info-debug.h"
53 #include "pkgmgr-info.h"
54 #include "pkgmgr_parser_db.h"
55 #include "pkgmgr_parser_internal.h"
62 #define LOG_TAG "PKGMGR_INFO"
64 #define ASC_CHAR(s) (const char *)s
65 #define XML_CHAR(s) (const xmlChar *)s
67 #define MANIFEST_DB tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
68 #define MAX_QUERY_LEN 4096
69 #define MAX_CERT_TYPE 9
70 #define CERT_DB tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db")
71 #define DATACONTROL_DB tzplatform_mkpath(TZ_USER_DB, ".app-package.db")
72 #define PKG_TYPE_STRING_LEN_MAX 128
73 #define PKG_VERSION_STRING_LEN_MAX 128
74 #define PKG_VALUE_STRING_LEN_MAX 512
75 #define PKG_LOCALE_STRING_LEN_MAX 8
76 #define PKG_RW_PATH tzplatform_mkpath(TZ_USER_APP, "")
77 #define PKG_RO_PATH tzplatform_mkpath(TZ_SYS_RO_APP, "")
78 #define BLOCK_SIZE 4096 /*in bytes*/
82 #define MMC_PATH tzplatform_mkpath(TZ_SYS_STORAGE, "sdcard")
83 #define PKG_SD_PATH tzplatform_mkpath3(TZ_SYS_STORAGE, "sdcard", "app2sd/")
84 #define PKG_INSTALLATION_PATH tzplatform_mkpath(TZ_USER_APP, "")
86 #define FILTER_QUERY_COUNT_PACKAGE "select count(DISTINCT package_info.package) " \
87 "from package_info LEFT OUTER JOIN package_localized_info " \
88 "ON package_info.package=package_localized_info.package " \
89 "and package_localized_info.package_locale='%s' where "
91 #define FILTER_QUERY_LIST_PACKAGE "select DISTINCT package_info.package " \
92 "from package_info LEFT OUTER JOIN package_localized_info " \
93 "ON package_info.package=package_localized_info.package " \
94 "and package_localized_info.package_locale='%s' where "
96 #define FILTER_QUERY_COUNT_APP "select count(DISTINCT package_app_info.app_id) " \
97 "from package_app_info LEFT OUTER JOIN package_app_localized_info " \
98 "ON package_app_info.app_id=package_app_localized_info.app_id " \
99 "and package_app_localized_info.app_locale='%s' " \
100 "LEFT OUTER JOIN package_app_app_svc " \
101 "ON package_app_info.app_id=package_app_app_svc.app_id " \
102 "LEFT OUTER JOIN package_app_app_category " \
103 "ON package_app_info.app_id=package_app_app_category.app_id where "
105 #define FILTER_QUERY_LIST_APP "select DISTINCT package_app_info.app_id, package_app_info.app_component " \
106 "from package_app_info LEFT OUTER JOIN package_app_localized_info " \
107 "ON package_app_info.app_id=package_app_localized_info.app_id " \
108 "and package_app_localized_info.app_locale='%s' " \
109 "LEFT OUTER JOIN package_app_app_svc " \
110 "ON package_app_info.app_id=package_app_app_svc.app_id " \
111 "LEFT OUTER JOIN package_app_app_category " \
112 "ON package_app_info.app_id=package_app_app_category.app_id where "
114 #define METADATA_FILTER_QUERY_SELECT_CLAUSE "select DISTINCT package_app_info.app_id, package_app_info.app_component " \
115 "from package_app_info LEFT OUTER JOIN package_app_app_metadata " \
116 "ON package_app_info.app_id=package_app_app_metadata.app_id where "
118 #define METADATA_FILTER_QUERY_UNION_CLAUSE " UNION "METADATA_FILTER_QUERY_SELECT_CLAUSE
120 #define LANGUAGE_LENGTH 2
122 #define SERVICE_NAME "org.tizen.system.deviced"
123 #define PATH_NAME "/Org/Tizen/System/DeviceD/Mmc"
124 #define INTERFACE_NAME "org.tizen.system.deviced.Mmc"
125 #define METHOD_NAME "RequestMountApp2ext"
129 typedef struct _pkgmgr_instcertinfo_x {
131 char *cert_info[MAX_CERT_TYPE]; /*certificate data*/
132 int is_new[MAX_CERT_TYPE]; /*whether already exist in table or not*/
133 int ref_count[MAX_CERT_TYPE]; /*reference count of certificate data*/
134 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
135 } pkgmgr_instcertinfo_x;
137 typedef struct _pkgmgr_certindexinfo_x {
140 } pkgmgr_certindexinfo_x;
142 typedef struct _pkgmgr_pkginfo_x {
144 manifest_x *manifest_info;
147 struct _pkgmgr_pkginfo_x *prev;
148 struct _pkgmgr_pkginfo_x *next;
151 typedef struct _pkgmgr_cert_x {
156 typedef struct _pkgmgr_datacontrol_x {
159 } pkgmgr_datacontrol_x;
161 typedef struct _pkgmgr_iconpath_x {
166 typedef struct _pkgmgr_image_x {
170 typedef struct _pkgmgr_locale_x {
174 typedef struct _pkgmgr_appinfo_x {
177 pkgmgrinfo_app_component app_component;
179 uiapplication_x *uiapp_info;
180 serviceapplication_x *svcapp_info;
184 typedef struct _pkgmgr_certinfo_x {
187 char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
188 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
192 typedef struct _pkgmgrinfo_filter_x {
195 } pkgmgrinfo_filter_x;
197 typedef struct _pkgmgrinfo_node_x {
203 typedef struct _pkgmgrinfo_appcontrol_x {
212 } pkgmgrinfo_appcontrol_x;
215 typedef struct _db_handle {
221 typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
223 typedef int (*pkgmgr_handler)(int req_id, const char *pkg_type,
224 const char *pkgid, const char *key,
225 const char *val, const void *pmsg, void *data);
227 typedef void pkgmgr_client;
228 typedef void pkgmgr_info;
233 PM_REQUEST_GET_SIZE = 2,
234 PM_REQUEST_KILL_APP = 3,
235 PM_REQUEST_CHECK_APP = 4,
237 }pkgmgr_request_service_type;
240 PM_GET_TOTAL_SIZE= 0,
241 PM_GET_DATA_SIZE = 1,
243 PM_GET_SIZE_INFO = 3,
244 PM_GET_TOTAL_AND_DATA = 4,
245 PM_GET_SIZE_FILE = 5,
247 }pkgmgr_getsize_type;
255 #define PKG_SIZE_INFO_FILE "/tmp/pkgmgr_size_info.txt"
256 #define MAX_PKG_BUF_LEN 1024
257 #define MAX_PKG_INFO_LEN 10
259 #define QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO "create table if not exists package_cert_index_info " \
260 "(cert_info text not null, " \
261 "cert_id integer, " \
262 "cert_ref_count integer, " \
263 "PRIMARY KEY(cert_id)) "
265 #define QUERY_CREATE_TABLE_PACKAGE_CERT_INFO "create table if not exists package_cert_info " \
266 "(package text not null, " \
267 "author_root_cert integer, " \
268 "author_im_cert integer, " \
269 "author_signer_cert integer, " \
270 "dist_root_cert integer, " \
271 "dist_im_cert integer, " \
272 "dist_signer_cert integer, " \
273 "dist2_root_cert integer, " \
274 "dist2_im_cert integer, " \
275 "dist2_signer_cert integer, " \
276 "PRIMARY KEY(package)) "
278 #define GET_DB(X) (X).dbHandle
279 char *pkgtype = "rpm";
280 __thread db_handle manifest_db;
281 __thread db_handle datacontrol_db;
282 __thread db_handle cert_db;
284 static int __open_manifest_db(uid_t uid);
285 static int __close_manifest_db(void);
286 static int __open_cert_db(uid_t uid, char* mode);
287 static int __close_cert_db(void);
288 static int __exec_pkginfo_query(char *query, void *data);
289 static int __exec_certinfo_query(char *query, void *data);
290 static int __exec_certindexinfo_query(char *query, void *data);
291 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname);
292 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname);
293 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname);
294 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname);
295 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname);
296 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname);
297 static int __count_cb(void *data, int ncols, char **coltxt, char **colname);
298 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
299 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
300 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname);
301 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname);
302 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data);
303 static void __cleanup_appinfo(pkgmgr_appinfo_x *data);
304 static char* __convert_system_locale_to_manifest_locale(char *syslocale);
305 static void __destroy_each_node(gpointer data, gpointer user_data);
306 static void __get_filter_condition(gpointer data, char **condition);
307 static void __get_metadata_filter_condition(gpointer data, char **condition);
308 static gint __compare_func(gconstpointer data1, gconstpointer data2);
309 static int __delete_certinfo(const char *pkgid, uid_t uid);
310 static int _check_create_Cert_db( sqlite3 *certdb);
311 static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data);
313 static int _mkdir_for_user(const char* dir, uid_t uid, gid_t gid)
319 fullpath = strdup(dir);
320 subpath = dirname(fullpath);
321 if (strlen(subpath) > 1 && strcmp(subpath, fullpath) != 0) {
322 ret = _mkdir_for_user(fullpath, uid, gid);
329 ret = mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
330 if (ret && errno != EEXIST) {
333 } else if (ret && errno == EEXIST) {
338 if (getuid() == ROOT_UID) {
339 ret = chown(dir, uid, gid);
341 _LOGE("FAIL : chown %s %d.%d, because %s", dir, uid,
342 gid, strerror(errno));
350 static const char *_get_db_path(uid_t uid) {
351 const char *db_path = NULL;
352 if (uid != GLOBAL_USER) {
353 tzplatform_set_user(uid);
354 db_path = tzplatform_getenv(TZ_USER_DB);
355 tzplatform_reset_user();
357 db_path = tzplatform_getenv(TZ_SYS_DB);
362 static int __attach_and_create_view(sqlite3 *handle, const char *db, const char *tables[], uid_t uid)
366 char query[MAX_QUERY_LEN];
368 if (uid == GLOBAL_USER)
371 snprintf(query, sizeof(query), "ATTACH DATABASE '%s' AS Global", db);
372 if (SQLITE_OK != sqlite3_exec(handle, query, NULL, NULL, &err)) {
373 _LOGD("Don't execute query = %s error message = %s\n", query, err);
378 for (i = 0; tables[i]; i++) {
379 snprintf(query, sizeof(query), "CREATE TEMP VIEW '%s' AS SELECT * \
380 FROM (SELECT *,0 AS for_all_users FROM main.'%s' UNION \
381 SELECT *,1 AS for_all_users FROM Global.'%s')",
382 tables[i], tables[i], tables[i]);
383 if (SQLITE_OK != sqlite3_exec(handle, query, NULL, NULL, &err)) {
384 _LOGD("Don't execute query = %s error message = %s\n", query, err);
392 static int _check_create_Cert_db( sqlite3 *certdb)
395 ret = __exec_db_query(certdb, QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO, NULL, NULL);
398 ret = __exec_db_query(certdb, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO, NULL, NULL);
402 static gid_t _get_gid(const char *name)
409 ret = getgrnam_r(name, &entry, buf, sizeof(buf), &ge);
410 if (ret || ge == NULL) {
411 _LOGE("fail to get gid of %s", name);
418 API char *getIconPath(uid_t uid)
420 const char *path = NULL;
421 uid_t uid_caller = getuid();
422 gid_t gid = ROOT_UID;
424 if (uid == ROOT_UID) {
425 _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
429 if (uid != GLOBAL_USER) {
430 tzplatform_set_user(uid);
431 path = tzplatform_mkpath(TZ_USER_ICONS, "/");
432 gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
433 tzplatform_reset_user();
435 path = tzplatform_mkpath(TZ_SYS_RW_ICONS, "/");
438 // just allow certain users to create the icon directory if needed.
439 if (uid_caller == ROOT_UID || uid_caller == uid)
440 _mkdir_for_user(path, uid, gid);
445 API char *getUserPkgParserDBPath(void)
447 return getUserPkgParserDBPathUID(GLOBAL_USER);
450 API char *getUserPkgParserDBPathUID(uid_t uid)
452 const char *pkgmgr_parser_db = NULL;
453 uid_t uid_caller = getuid();
454 gid_t gid = ROOT_UID;
456 if (uid == ROOT_UID) {
457 _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
461 if (uid != GLOBAL_USER) {
462 tzplatform_set_user(uid);
463 pkgmgr_parser_db = tzplatform_mkpath(TZ_USER_DB, ".pkgmgr_parser.db");
464 gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
465 tzplatform_reset_user();
467 pkgmgr_parser_db = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db");
470 // just allow certain users to create the dbspace directory if needed.
471 if (uid_caller == ROOT_UID || uid_caller == uid) {
472 const char *db_path = _get_db_path(uid);
473 _mkdir_for_user(db_path, uid, gid);
476 return pkgmgr_parser_db;
479 API char *getUserPkgCertDBPath(void)
481 return getUserPkgCertDBPathUID(GLOBAL_USER);
484 API char *getUserPkgCertDBPathUID(uid_t uid)
486 const char *pkgmgr_cert_db = NULL;
487 uid_t uid_caller = getuid();
488 gid_t gid = ROOT_UID;
490 if (uid == ROOT_UID) {
491 _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
495 if (uid != GLOBAL_USER) {
496 tzplatform_set_user(uid);
497 pkgmgr_cert_db = tzplatform_mkpath(TZ_USER_DB, ".pkgmgr_cert.db");
498 gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
499 tzplatform_reset_user();
501 pkgmgr_cert_db = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db");
504 // just allow certain users to create the dbspace directory if needed.
505 if (uid_caller == ROOT_UID || uid_caller == uid) {
506 const char *db_path = _get_db_path(uid);
507 _mkdir_for_user(db_path, uid, gid);
510 return pkgmgr_cert_db;
513 API const char* getUserDesktopPath(uid_t uid)
515 const char *path = NULL;
516 uid_t uid_caller = getuid();
517 gid_t gid = ROOT_UID;
519 if (uid == ROOT_UID) {
520 _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
524 if (uid != GLOBAL_USER) {
525 tzplatform_set_user(uid);
526 path = tzplatform_mkpath(TZ_USER_DESKTOP, "/");
527 gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
528 tzplatform_reset_user();
530 path = tzplatform_mkpath(TZ_SYS_RW_DESKTOP_APP, "/");
533 // just allow certain users to create the icon directory if needed.
534 if (uid_caller == ROOT_UID || uid_caller == uid)
535 _mkdir_for_user(path, uid, gid);
540 API const char* getUserManifestPath(uid_t uid)
542 const char *path = NULL;
543 uid_t uid_caller = getuid();
544 gid_t gid = ROOT_UID;
546 if (uid == ROOT_UID) {
547 _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
551 if (uid != GLOBAL_USER) {
552 tzplatform_set_user(uid);
553 path = tzplatform_mkpath(TZ_USER_PACKAGES, "/");
554 gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
555 tzplatform_reset_user();
557 path = tzplatform_mkpath(TZ_SYS_RW_PACKAGES, "/");
560 // just allow certain users to create the icon directory if needed.
561 if (uid_caller == ROOT_UID || uid_caller == uid)
562 _mkdir_for_user(path, uid, gid);
567 static gint __compare_func(gconstpointer data1, gconstpointer data2)
569 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
570 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
571 if (node1->prop == node2->prop)
573 else if (node1->prop > node2->prop)
579 static int __count_cb(void *data, int ncols, char **coltxt, char **colname)
582 *p = atoi(coltxt[0]);
583 _LOGE("count value is %d\n", *p);
587 static void __destroy_each_node(gpointer data, gpointer user_data)
589 ret_if(data == NULL);
590 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
603 static void __get_metadata_filter_condition(gpointer data, char **condition)
605 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
606 char key[MAX_QUERY_LEN] = {'\0'};
607 char value[MAX_QUERY_LEN] = {'\0'};
609 snprintf(key, MAX_QUERY_LEN, "(package_app_app_metadata.md_key='%s'", node->key);
612 snprintf(value, MAX_QUERY_LEN, " AND package_app_app_metadata.md_value='%s')", node->value);
617 *condition = strdup(key);
621 static void __get_filter_condition(gpointer data, char **condition)
623 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
624 char buf[MAX_QUERY_LEN + 1] = {'\0'};
625 char temp[PKG_STRING_LEN_MAX] = {'\0'};
626 switch (node->prop) {
627 case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
628 snprintf(buf, MAX_QUERY_LEN, "package_info.package='%s'", node->value);
630 case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
631 snprintf(buf, MAX_QUERY_LEN, "package_info.package_type='%s'", node->value);
633 case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
634 snprintf(buf, MAX_QUERY_LEN, "package_info.package_version='%s'", node->value);
636 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
637 snprintf(buf, MAX_QUERY_LEN, "package_info.install_location='%s'", node->value);
639 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
640 snprintf(buf, MAX_QUERY_LEN, "package_info.installed_storage='%s'", node->value);
642 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
643 snprintf(buf, MAX_QUERY_LEN, "package_info.author_name='%s'", node->value);
645 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
646 snprintf(buf, MAX_QUERY_LEN, "package_info.author_href='%s'", node->value);
648 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
649 snprintf(buf, MAX_QUERY_LEN, "package_info.author_email='%s'", node->value);
651 case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
652 snprintf(buf, MAX_QUERY_LEN, "package_info.package_size='%s'", node->value);
654 case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
655 snprintf(buf, MAX_QUERY_LEN, "package_info.package_removable IN %s", node->value);
657 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
658 snprintf(buf, MAX_QUERY_LEN, "package_info.package_preload IN %s", node->value);
660 case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
661 snprintf(buf, MAX_QUERY_LEN, "package_info.package_readonly IN %s", node->value);
663 case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
664 snprintf(buf, MAX_QUERY_LEN, "package_info.package_update IN %s", node->value);
666 case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
667 snprintf(buf, MAX_QUERY_LEN, "package_info.package_appsetting IN %s", node->value);
669 case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
670 snprintf(buf, MAX_QUERY_LEN, "package_info.package_nodisplay IN %s", node->value);
673 case E_PMINFO_APPINFO_PROP_APP_ID:
674 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_id='%s'", node->value);
676 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
677 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_component='%s'", node->value);
679 case E_PMINFO_APPINFO_PROP_APP_EXEC:
680 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_exec='%s'", node->value);
682 case E_PMINFO_APPINFO_PROP_APP_ICON:
683 snprintf(buf, MAX_QUERY_LEN, "package_app_localized_info.app_icon='%s'", node->value);
685 case E_PMINFO_APPINFO_PROP_APP_TYPE:
686 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_type='%s'", node->value);
688 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
689 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
690 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.operation IN %s", temp);
692 case E_PMINFO_APPINFO_PROP_APP_URI:
693 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
694 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.uri_scheme IN %s", temp);
696 case E_PMINFO_APPINFO_PROP_APP_MIME:
697 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
698 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.mime_type IN %s", temp);
700 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
701 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
702 snprintf(buf, MAX_QUERY_LEN, "package_app_app_category.category IN %s", temp);
704 case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
705 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_nodisplay IN %s", node->value);
707 case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
708 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_multiple IN %s", node->value);
710 case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
711 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_onboot IN %s", node->value);
713 case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
714 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_autorestart IN %s", node->value);
716 case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
717 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_taskmanage IN %s", node->value);
719 case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
720 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_hwacceleration='%s'", node->value);
722 case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
723 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_screenreader='%s'", node->value);
725 case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
726 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
729 _LOGE("Invalid Property Type\n");
733 *condition = strdup(buf);
737 static char* __convert_system_locale_to_manifest_locale(char *syslocale)
739 if (syslocale == NULL)
740 return strdup(DEFAULT_LOCALE);
742 locale = (char *)calloc(1, 6);
743 retvm_if(!locale, NULL, "Malloc Failed\n");
745 strncpy(locale, syslocale, 2);
746 strncat(locale, "-", 1);
747 locale[3] = syslocale[3] + 32;
748 locale[4] = syslocale[4] + 32;
752 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
754 ret_if(data == NULL);
756 free((void *)data->locale);
760 pkgmgr_parser_free_manifest_xml(data->manifest_info);
766 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
768 ret_if(data == NULL);
770 free((void *)data->package);
771 data->package = NULL;
774 free((void *)data->locale);
778 manifest_x *mfx = calloc(1, sizeof(manifest_x));
779 if (data->app_component == PMINFO_UI_APP)
780 mfx->uiapplication = data->uiapp_info;
781 else if (data->app_component == PMINFO_SVC_APP)
782 mfx->serviceapplication = data->svcapp_info;
783 pkgmgr_parser_free_manifest_xml(mfx);
789 static int __close_manifest_db(void)
791 if(manifest_db.ref) {
792 if(--manifest_db.ref == 0)
793 sqlite3_close(GET_DB(manifest_db));
799 static const char *parserdb_tables[] = {
800 "package_app_app_category",
802 "package_app_app_control",
803 "package_app_localized_info",
804 "package_app_app_metadata",
805 "package_app_share_allowed",
806 "package_app_app_permission",
807 "package_app_share_request",
808 "package_app_app_svc",
810 "package_app_data_control",
811 "package_localized_info",
812 "package_app_icon_section_info",
813 "package_privilege_info",
814 "package_app_image_info",
818 static int __open_manifest_db(uid_t uid)
821 if(manifest_db.ref) {
825 const char* user_pkg_parser = getUserPkgParserDBPathUID(uid);
826 if (access(user_pkg_parser, F_OK) != 0) {
827 _LOGE("Manifest DB does not exists !! try to create\n");
829 if (pkgmgr_parser_check_and_create_db(uid)) {
830 _LOGE("create db failed");
834 if (pkgmgr_parser_initialize_db()) {
835 _LOGE("initialize db failed");
840 ret = db_util_open_with_options(user_pkg_parser, &GET_DB(manifest_db),
841 SQLITE_OPEN_READONLY, NULL);
842 retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", user_pkg_parser);
844 ret = __attach_and_create_view(GET_DB(manifest_db), MANIFEST_DB, parserdb_tables, uid);
845 retvm_if(ret != SQLITE_OK, -1, "attach db [%s] failed!\n", user_pkg_parser);
850 static int __close_cert_db(void)
853 if(--cert_db.ref == 0)
854 sqlite3_close(GET_DB(cert_db));
857 _LOGE("Certificate DB is already closed !!\n");
861 static const char *certdb_tables[] = {
862 "package_cert_index_info",
867 static int __open_cert_db(uid_t uid, char* mode)
875 const char* user_cert_parser = getUserPkgCertDBPathUID(uid);
876 if (access(user_cert_parser, F_OK) == 0) {
877 ret = db_util_open_with_options(user_cert_parser, &GET_DB(cert_db),
878 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
879 retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", user_cert_parser);
881 if ((strcmp(mode, "w") != 0)) {
882 ret = __attach_and_create_view(GET_DB(cert_db), CERT_DB, certdb_tables, uid);
883 retvm_if(ret != SQLITE_OK, -1, "attach db [%s] failed!\n", user_cert_parser);
887 _LOGE("Cert DB does not exists !!\n");
891 static int __close_datacontrol_db(void)
893 if(datacontrol_db.ref) {
894 if(--datacontrol_db.ref == 0)
895 sqlite3_close(GET_DB(datacontrol_db));
898 _LOGE("Certificate DB is already closed !!\n");
902 static int __open_datacontrol_db()
905 if(datacontrol_db.ref) {
906 datacontrol_db.ref ++;
909 if (access(DATACONTROL_DB, F_OK) == 0) {
910 ret = db_util_open_with_options(DATACONTROL_DB, &GET_DB(datacontrol_db),
911 SQLITE_OPEN_READONLY, NULL);
912 retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", DATACONTROL_DB);
913 datacontrol_db.ref ++;
916 _LOGE("Datacontrol DB does not exists !!\n");
920 static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
922 pkgmgr_pkginfo_x *udata = (pkgmgr_pkginfo_x *)data;
924 pkgmgr_pkginfo_x *info = NULL;
925 info = calloc(1, sizeof(pkgmgr_pkginfo_x));
926 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
928 LISTADD(udata, info);
930 for(i = 0; i < ncols; i++)
932 if (strcmp(colname[i], "package") == 0) {
934 info->manifest_info->package = strdup(coltxt[i]);
936 info->manifest_info->package = NULL;
937 } else if (strcmp(colname[i], "for_all_users") == 0) {
939 info->manifest_info->for_all_users = strdup(coltxt[i]);
941 info->manifest_info->for_all_users = NULL;
946 //by default if views are not set , the column for_all_users doesn't exist,
947 // in this case we assume we retreive information about app avaible for all users
948 if (!info->manifest_info->for_all_users)
949 info->manifest_info->for_all_users = strdup("1");
954 static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname)
956 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
959 uiapplication_x *uiapp = NULL;
960 serviceapplication_x *svcapp = NULL;
961 for(i = 0; i < ncols; i++)
963 if ((strcmp(colname[i], "app_component") == 0) ||
964 (strcmp(colname[i], "package_app_info.app_component") == 0)) {
966 if (strcmp(coltxt[i], "uiapp") == 0) {
967 uiapp = calloc(1, sizeof(uiapplication_x));
969 _LOGE("Out of Memory!!!\n");
972 LISTADD(info->manifest_info->uiapplication, uiapp);
973 for(j = 0; j < ncols; j++)
975 if ((strcmp(colname[j], "app_id") == 0) ||
976 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
978 info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
979 } else if (strcmp(colname[j], "package") == 0) {
981 info->manifest_info->uiapplication->package = strdup(coltxt[j]);
986 svcapp = calloc(1, sizeof(serviceapplication_x));
987 if (svcapp == NULL) {
988 _LOGE("Out of Memory!!!\n");
991 LISTADD(info->manifest_info->serviceapplication, svcapp);
992 for(j = 0; j < ncols; j++)
994 if ((strcmp(colname[j], "app_id") == 0) ||
995 (strcmp(colname[j], "package_app_info.app_id") == 0)) {
997 info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
998 } else if (strcmp(colname[j], "package") == 0) {
1000 info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
1014 static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
1016 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
1018 uiapplication_x *uiapp = NULL;
1019 icon_x *icon = NULL;
1020 label_x *label = NULL;
1022 uiapp = calloc(1, sizeof(uiapplication_x));
1023 LISTADD(info->manifest_info->uiapplication, uiapp);
1024 icon = calloc(1, sizeof(icon_x));
1025 LISTADD(info->manifest_info->uiapplication->icon, icon);
1026 label = calloc(1, sizeof(label_x));
1027 LISTADD(info->manifest_info->uiapplication->label, label);
1029 for(i = 0; i < ncols; i++)
1031 if (strcmp(colname[i], "app_id") == 0) {
1033 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
1035 info->manifest_info->uiapplication->appid = NULL;
1036 } else if (strcmp(colname[i], "app_exec") == 0) {
1038 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
1040 info->manifest_info->uiapplication->exec = NULL;
1041 } else if (strcmp(colname[i], "app_type") == 0 ){
1043 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
1045 info->manifest_info->uiapplication->type = NULL;
1046 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
1048 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
1050 info->manifest_info->uiapplication->nodisplay = NULL;
1051 } else if (strcmp(colname[i], "app_multiple") == 0 ){
1053 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
1055 info->manifest_info->uiapplication->multiple = NULL;
1056 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
1058 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
1060 info->manifest_info->uiapplication->taskmanage = NULL;
1061 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
1063 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
1065 info->manifest_info->uiapplication->hwacceleration = NULL;
1066 } else if (strcmp(colname[i], "app_screenreader") == 0 ){
1068 info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
1070 info->manifest_info->uiapplication->screenreader = NULL;
1071 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
1073 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
1075 info->manifest_info->uiapplication->indicatordisplay = NULL;
1076 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
1078 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
1080 info->manifest_info->uiapplication->portraitimg = NULL;
1081 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
1083 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
1085 info->manifest_info->uiapplication->landscapeimg = NULL;
1086 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
1088 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
1090 info->manifest_info->uiapplication->guestmode_visibility = NULL;
1091 } else if (strcmp(colname[i], "package") == 0 ){
1093 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
1095 info->manifest_info->uiapplication->package = NULL;
1096 } else if (strcmp(colname[i], "app_icon") == 0) {
1098 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
1100 info->manifest_info->uiapplication->icon->text = NULL;
1101 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1103 info->manifest_info->uiapplication->enabled= strdup(coltxt[i]);
1105 info->manifest_info->uiapplication->enabled = NULL;
1106 } else if (strcmp(colname[i], "app_label") == 0 ) {
1108 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
1110 info->manifest_info->uiapplication->label->text = NULL;
1111 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1113 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
1115 info->manifest_info->uiapplication->recentimage = NULL;
1116 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1118 info->manifest_info->uiapplication->mainapp = strdup(coltxt[i]);
1120 info->manifest_info->uiapplication->mainapp = NULL;
1121 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1123 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
1124 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
1127 info->manifest_info->uiapplication->icon->lang = NULL;
1128 info->manifest_info->uiapplication->label->lang = NULL;
1130 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1132 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
1134 info->manifest_info->uiapplication->permission_type = NULL;
1135 } else if (strcmp(colname[i], "component_type") == 0 ) {
1137 info->manifest_info->uiapplication->component_type = strdup(coltxt[i]);
1139 info->manifest_info->uiapplication->component_type = NULL;
1140 } else if (strcmp(colname[i], "app_preload") == 0 ) {
1142 info->manifest_info->uiapplication->preload = strdup(coltxt[i]);
1144 info->manifest_info->uiapplication->preload = NULL;
1145 } else if (strcmp(colname[i], "app_submode") == 0 ) {
1147 info->manifest_info->uiapplication->submode = strdup(coltxt[i]);
1149 info->manifest_info->uiapplication->submode = NULL;
1150 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
1152 info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[i]);
1154 info->manifest_info->uiapplication->submode_mainid = NULL;
1155 } else if (strcmp(colname, "app_launch_mode") == 0 ) {
1157 info->manifest_info->uiapplication->launch_mode = strdup(coltxt[i]);
1159 info->manifest_info->uiapplication->launch_mode = NULL;
1166 static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
1168 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
1170 serviceapplication_x *svcapp = NULL;
1171 icon_x *icon = NULL;
1172 label_x *label = NULL;
1174 svcapp = calloc(1, sizeof(serviceapplication_x));
1175 LISTADD(info->manifest_info->serviceapplication, svcapp);
1176 icon = calloc(1, sizeof(icon_x));
1177 LISTADD(info->manifest_info->serviceapplication->icon, icon);
1178 label = calloc(1, sizeof(label_x));
1179 LISTADD(info->manifest_info->serviceapplication->label, label);
1180 for(i = 0; i < ncols; i++)
1182 if (strcmp(colname[i], "app_id") == 0) {
1184 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
1186 info->manifest_info->serviceapplication->appid = NULL;
1187 } else if (strcmp(colname[i], "app_exec") == 0) {
1189 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
1191 info->manifest_info->serviceapplication->exec = NULL;
1192 } else if (strcmp(colname[i], "app_type") == 0 ){
1194 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
1196 info->manifest_info->serviceapplication->type = NULL;
1197 } else if (strcmp(colname[i], "app_onboot") == 0 ){
1199 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
1201 info->manifest_info->serviceapplication->onboot = NULL;
1202 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
1204 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
1206 info->manifest_info->serviceapplication->autorestart = NULL;
1207 } else if (strcmp(colname[i], "package") == 0 ){
1209 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
1211 info->manifest_info->serviceapplication->package = NULL;
1212 } else if (strcmp(colname[i], "app_icon") == 0) {
1214 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
1216 info->manifest_info->serviceapplication->icon->text = NULL;
1217 } else if (strcmp(colname[i], "app_label") == 0 ) {
1219 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
1221 info->manifest_info->serviceapplication->label->text = NULL;
1222 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1224 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
1225 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
1228 info->manifest_info->serviceapplication->icon->lang = NULL;
1229 info->manifest_info->serviceapplication->label->lang = NULL;
1231 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1233 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
1235 info->manifest_info->serviceapplication->permission_type = NULL;
1242 static int __allapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
1244 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
1247 uiapplication_x *uiapp = NULL;
1248 serviceapplication_x *svcapp = NULL;
1249 for(j = 0; j < ncols; j++)
1251 if (strcmp(colname[j], "app_component") == 0) {
1253 if (strcmp(coltxt[j], "uiapp") == 0) {
1254 uiapp = calloc(1, sizeof(uiapplication_x));
1255 if (uiapp == NULL) {
1256 _LOGE("Out of Memory!!!\n");
1259 LISTADD(info->manifest_info->uiapplication, uiapp);
1260 for(i = 0; i < ncols; i++)
1262 if (strcmp(colname[i], "app_id") == 0) {
1264 info->manifest_info->uiapplication->appid = strdup(coltxt[i]);
1266 info->manifest_info->uiapplication->appid = NULL;
1267 } else if (strcmp(colname[i], "app_exec") == 0) {
1269 info->manifest_info->uiapplication->exec = strdup(coltxt[i]);
1271 info->manifest_info->uiapplication->exec = NULL;
1272 } else if (strcmp(colname[i], "app_type") == 0 ){
1274 info->manifest_info->uiapplication->type = strdup(coltxt[i]);
1276 info->manifest_info->uiapplication->type = NULL;
1277 } else if (strcmp(colname[i], "app_nodisplay") == 0 ){
1279 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[i]);
1281 info->manifest_info->uiapplication->nodisplay = NULL;
1282 } else if (strcmp(colname[i], "app_multiple") == 0 ){
1284 info->manifest_info->uiapplication->multiple = strdup(coltxt[i]);
1286 info->manifest_info->uiapplication->multiple = NULL;
1287 } else if (strcmp(colname[i], "app_taskmanage") == 0 ){
1289 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[i]);
1291 info->manifest_info->uiapplication->taskmanage = NULL;
1292 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ){
1294 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
1296 info->manifest_info->uiapplication->hwacceleration = NULL;
1297 } else if (strcmp(colname[i], "app_screenreader") == 0 ){
1299 info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
1301 info->manifest_info->uiapplication->screenreader = NULL;
1302 } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
1304 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
1306 info->manifest_info->uiapplication->indicatordisplay = NULL;
1307 } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
1309 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
1311 info->manifest_info->uiapplication->portraitimg = NULL;
1312 } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
1314 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
1316 info->manifest_info->uiapplication->landscapeimg = NULL;
1317 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
1319 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
1321 info->manifest_info->uiapplication->guestmode_visibility = NULL;
1322 } else if (strcmp(colname[i], "package") == 0 ){
1324 info->manifest_info->uiapplication->package = strdup(coltxt[i]);
1326 info->manifest_info->uiapplication->package = NULL;
1327 } else if (strcmp(colname[i], "app_icon") == 0) {
1329 info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
1331 info->manifest_info->uiapplication->icon->text = NULL;
1332 } else if (strcmp(colname[i], "app_label") == 0 ) {
1334 info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
1336 info->manifest_info->uiapplication->label->text = NULL;
1337 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
1339 info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
1341 info->manifest_info->uiapplication->recentimage = NULL;
1342 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
1344 info->manifest_info->uiapplication->mainapp= strdup(coltxt[i]);
1346 info->manifest_info->uiapplication->mainapp = NULL;
1347 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1349 info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
1350 info->manifest_info->uiapplication->label->lang = strdup(coltxt[i]);
1353 info->manifest_info->uiapplication->icon->lang = NULL;
1354 info->manifest_info->uiapplication->label->lang = NULL;
1356 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1358 info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
1360 info->manifest_info->uiapplication->permission_type = NULL;
1365 svcapp = calloc(1, sizeof(serviceapplication_x));
1366 if (svcapp == NULL) {
1367 _LOGE("Out of Memory!!!\n");
1370 LISTADD(info->manifest_info->serviceapplication, svcapp);
1371 for(i = 0; i < ncols; i++)
1373 if (strcmp(colname[i], "app_id") == 0) {
1375 info->manifest_info->serviceapplication->appid = strdup(coltxt[i]);
1377 info->manifest_info->serviceapplication->appid = NULL;
1378 } else if (strcmp(colname[i], "app_exec") == 0) {
1380 info->manifest_info->serviceapplication->exec = strdup(coltxt[i]);
1382 info->manifest_info->serviceapplication->exec = NULL;
1383 } else if (strcmp(colname[i], "app_type") == 0 ){
1385 info->manifest_info->serviceapplication->type = strdup(coltxt[i]);
1387 info->manifest_info->serviceapplication->type = NULL;
1388 } else if (strcmp(colname[i], "app_onboot") == 0 ){
1390 info->manifest_info->serviceapplication->onboot = strdup(coltxt[i]);
1392 info->manifest_info->serviceapplication->onboot = NULL;
1393 } else if (strcmp(colname[i], "app_autorestart") == 0 ){
1395 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[i]);
1397 info->manifest_info->serviceapplication->autorestart = NULL;
1398 } else if (strcmp(colname[i], "package") == 0 ){
1400 info->manifest_info->serviceapplication->package = strdup(coltxt[i]);
1402 info->manifest_info->serviceapplication->package = NULL;
1403 } else if (strcmp(colname[i], "app_icon") == 0) {
1405 info->manifest_info->serviceapplication->icon->text = strdup(coltxt[i]);
1407 info->manifest_info->serviceapplication->icon->text = NULL;
1408 } else if (strcmp(colname[i], "app_label") == 0 ) {
1410 info->manifest_info->serviceapplication->label->text = strdup(coltxt[i]);
1412 info->manifest_info->serviceapplication->label->text = NULL;
1413 } else if (strcmp(colname[i], "app_locale") == 0 ) {
1415 info->manifest_info->serviceapplication->icon->lang = strdup(coltxt[i]);
1416 info->manifest_info->serviceapplication->label->lang = strdup(coltxt[i]);
1419 info->manifest_info->serviceapplication->icon->lang = NULL;
1420 info->manifest_info->serviceapplication->label->lang = NULL;
1422 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
1424 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
1426 info->manifest_info->serviceapplication->permission_type = NULL;
1441 static int __validate_cb(void *data, int ncols, char **coltxt, char **colname)
1443 int *p = (int*)data;
1444 *p = atoi(coltxt[0]);
1448 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname)
1450 int *p = (int*)data;
1452 *p = atoi(coltxt[0]);
1456 static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
1458 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
1460 author_x *author = NULL;
1461 icon_x *icon = NULL;
1462 label_x *label = NULL;
1463 description_x *description = NULL;
1464 privilege_x *privilege = NULL;
1466 author = calloc(1, sizeof(author_x));
1467 LISTADD(info->manifest_info->author, author);
1468 icon = calloc(1, sizeof(icon_x));
1469 LISTADD(info->manifest_info->icon, icon);
1470 label = calloc(1, sizeof(label_x));
1471 LISTADD(info->manifest_info->label, label);
1472 description = calloc(1, sizeof(description_x));
1473 LISTADD(info->manifest_info->description, description);
1474 privilege = calloc(1, sizeof(privilege_x));
1475 LISTADD(info->manifest_info->privileges->privilege, privilege);
1476 for(i = 0; i < ncols; i++)
1478 if (strcmp(colname[i], "package_version") == 0) {
1480 info->manifest_info->version = strdup(coltxt[i]);
1482 info->manifest_info->version = NULL;
1483 } else if (strcmp(colname[i], "package_type") == 0) {
1485 info->manifest_info->type = strdup(coltxt[i]);
1487 info->manifest_info->type = NULL;
1488 } else if (strcmp(colname[i], "install_location") == 0) {
1490 info->manifest_info->installlocation = strdup(coltxt[i]);
1492 info->manifest_info->installlocation = NULL;
1493 } else if (strcmp(colname[i], "package_size") == 0) {
1495 info->manifest_info->package_size = strdup(coltxt[i]);
1497 info->manifest_info->package_size = NULL;
1498 } else if (strcmp(colname[i], "author_email") == 0 ){
1500 info->manifest_info->author->email = strdup(coltxt[i]);
1502 info->manifest_info->author->email = NULL;
1503 } else if (strcmp(colname[i], "author_href") == 0 ){
1505 info->manifest_info->author->href = strdup(coltxt[i]);
1507 info->manifest_info->author->href = NULL;
1508 } else if (strcmp(colname[i], "package_label") == 0 ){
1510 info->manifest_info->label->text = strdup(coltxt[i]);
1512 info->manifest_info->label->text = NULL;
1513 } else if (strcmp(colname[i], "package_icon") == 0 ){
1515 info->manifest_info->icon->text = strdup(coltxt[i]);
1517 info->manifest_info->icon->text = NULL;
1518 } else if (strcmp(colname[i], "package_description") == 0 ){
1520 info->manifest_info->description->text = strdup(coltxt[i]);
1522 info->manifest_info->description->text = NULL;
1523 } else if (strcmp(colname[i], "package_author") == 0 ){
1525 info->manifest_info->author->text = strdup(coltxt[i]);
1527 info->manifest_info->author->text = NULL;
1528 } else if (strcmp(colname[i], "package_removable") == 0 ){
1530 info->manifest_info->removable = strdup(coltxt[i]);
1532 info->manifest_info->removable = NULL;
1533 } else if (strcmp(colname[i], "package_preload") == 0 ){
1535 info->manifest_info->preload = strdup(coltxt[i]);
1537 info->manifest_info->preload = NULL;
1538 } else if (strcmp(colname[i], "package_readonly") == 0 ){
1540 info->manifest_info->readonly = strdup(coltxt[i]);
1542 info->manifest_info->readonly = NULL;
1543 } else if (strcmp(colname[i], "package_update") == 0 ){
1545 info->manifest_info->update= strdup(coltxt[i]);
1547 info->manifest_info->update = NULL;
1548 } else if (strcmp(colname[i], "package_system") == 0 ){
1550 info->manifest_info->system= strdup(coltxt[i]);
1552 info->manifest_info->system = NULL;
1553 } else if (strcmp(colname[i], "package_appsetting") == 0 ){
1555 info->manifest_info->appsetting = strdup(coltxt[i]);
1557 info->manifest_info->appsetting = NULL;
1558 } else if (strcmp(colname[i], "installed_time") == 0 ){
1560 info->manifest_info->installed_time = strdup(coltxt[i]);
1562 info->manifest_info->installed_time = NULL;
1563 } else if (strcmp(colname[i], "installed_storage") == 0 ){
1565 info->manifest_info->installed_storage = strdup(coltxt[i]);
1567 info->manifest_info->installed_storage = NULL;
1568 } else if (strcmp(colname[i], "mainapp_id") == 0 ){
1570 info->manifest_info->mainapp_id = strdup(coltxt[i]);
1572 info->manifest_info->mainapp_id = NULL;
1573 } else if (strcmp(colname[i], "storeclient_id") == 0 ){
1575 info->manifest_info->storeclient_id = strdup(coltxt[i]);
1577 info->manifest_info->storeclient_id = NULL;
1578 } else if (strcmp(colname[i], "root_path") == 0 ){
1580 info->manifest_info->root_path = strdup(coltxt[i]);
1582 info->manifest_info->root_path = NULL;
1583 } else if (strcmp(colname[i], "csc_path") == 0 ){
1585 info->manifest_info->csc_path = strdup(coltxt[i]);
1587 info->manifest_info->csc_path = NULL;
1588 } else if (strcmp(colname[i], "privilege") == 0 ){
1590 info->manifest_info->privileges->privilege->text = strdup(coltxt[i]);
1592 info->manifest_info->privileges->privilege->text = NULL;
1593 } else if (strcmp(colname[i], "package_locale") == 0 ){
1595 info->manifest_info->author->lang = strdup(coltxt[i]);
1596 info->manifest_info->icon->lang = strdup(coltxt[i]);
1597 info->manifest_info->label->lang = strdup(coltxt[i]);
1598 info->manifest_info->description->lang = strdup(coltxt[i]);
1601 info->manifest_info->author->lang = NULL;
1602 info->manifest_info->icon->lang = NULL;
1603 info->manifest_info->label->lang = NULL;
1604 info->manifest_info->description->lang = NULL;
1606 } else if (strcmp(colname[i], "package_url") == 0 ){
1608 info->manifest_info->package_url = strdup(coltxt[i]);
1610 info->manifest_info->package_url = NULL;
1618 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1620 if ( strcasecmp(comp, "uiapp") == 0)
1621 return PMINFO_UI_APP;
1622 else if ( strcasecmp(comp, "svcapp") == 0)
1623 return PMINFO_SVC_APP;
1628 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1630 pkgmgr_certindexinfo_x *info = (pkgmgr_certindexinfo_x *)data;
1632 for(i = 0; i < ncols; i++) {
1633 if (strcmp(colname[i], "cert_id") == 0) {
1635 info->cert_id = atoi(coltxt[i]);
1638 } else if (strcmp(colname[i], "cert_ref_count") == 0) {
1640 info->cert_ref_count = atoi(coltxt[i]);
1642 info->cert_ref_count = 0;
1648 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1650 pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)data;
1652 for(i = 0; i < ncols; i++)
1654 if (strcmp(colname[i], "package") == 0) {
1656 info->pkgid = strdup(coltxt[i]);
1659 } else if (strcmp(colname[i], "author_signer_cert") == 0) {
1661 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = atoi(coltxt[i]);
1663 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = 0;
1664 } else if (strcmp(colname[i], "author_im_cert") == 0) {
1666 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1668 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 0;
1669 } else if (strcmp(colname[i], "author_root_cert") == 0) {
1671 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = atoi(coltxt[i]);
1673 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = 0;
1674 } else if (strcmp(colname[i], "dist_signer_cert") == 0 ){
1676 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = atoi(coltxt[i]);
1678 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 0;
1679 } else if (strcmp(colname[i], "dist_im_cert") == 0 ){
1681 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1683 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 0;
1684 } else if (strcmp(colname[i], "dist_root_cert") == 0 ){
1686 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = atoi(coltxt[i]);
1688 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = 0;
1689 } else if (strcmp(colname[i], "dist2_signer_cert") == 0 ){
1691 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = atoi(coltxt[i]);
1693 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 0;
1694 } else if (strcmp(colname[i], "dist2_im_cert") == 0 ){
1696 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = atoi(coltxt[i]);
1698 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 0;
1699 } else if (strcmp(colname[i], "dist2_root_cert") == 0 ){
1701 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = atoi(coltxt[i]);
1703 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 0;
1704 } else if (strcmp(colname[i], "cert_info") == 0 ){
1706 info->cert_value = strdup(coltxt[i]);
1708 info->cert_value = NULL;
1715 static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1717 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
1720 uiapplication_x *uiapp = NULL;
1721 serviceapplication_x *svcapp = NULL;
1722 for(i = 0; i < ncols; i++)
1724 if (strcmp(colname[i], "app_component") == 0) {
1726 if (strcmp(coltxt[i], "uiapp") == 0) {
1727 uiapp = calloc(1, sizeof(uiapplication_x));
1728 if (uiapp == NULL) {
1729 _LOGE("Out of Memory!!!\n");
1732 LISTADD(info->manifest_info->uiapplication, uiapp);
1733 for(j = 0; j < ncols; j++)
1735 if (strcmp(colname[j], "app_id") == 0) {
1737 info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
1738 } else if (strcmp(colname[j], "app_exec") == 0) {
1740 info->manifest_info->uiapplication->exec = strdup(coltxt[j]);
1742 info->manifest_info->uiapplication->exec = NULL;
1743 } else if (strcmp(colname[j], "app_nodisplay") == 0) {
1745 info->manifest_info->uiapplication->nodisplay = strdup(coltxt[j]);
1747 info->manifest_info->uiapplication->nodisplay = NULL;
1748 } else if (strcmp(colname[j], "app_type") == 0 ) {
1750 info->manifest_info->uiapplication->type = strdup(coltxt[j]);
1752 info->manifest_info->uiapplication->type = NULL;
1753 } else if (strcmp(colname[j], "app_multiple") == 0 ) {
1755 info->manifest_info->uiapplication->multiple = strdup(coltxt[j]);
1757 info->manifest_info->uiapplication->multiple = NULL;
1758 } else if (strcmp(colname[j], "app_taskmanage") == 0 ) {
1760 info->manifest_info->uiapplication->taskmanage = strdup(coltxt[j]);
1762 info->manifest_info->uiapplication->taskmanage = NULL;
1763 } else if (strcmp(colname[j], "app_hwacceleration") == 0 ) {
1765 info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[j]);
1767 info->manifest_info->uiapplication->hwacceleration = NULL;
1768 } else if (strcmp(colname[j], "app_screenreader") == 0 ) {
1770 info->manifest_info->uiapplication->screenreader = strdup(coltxt[j]);
1772 info->manifest_info->uiapplication->screenreader = NULL;
1773 } else if (strcmp(colname[j], "app_enabled") == 0 ) {
1775 info->manifest_info->uiapplication->enabled= strdup(coltxt[j]);
1777 info->manifest_info->uiapplication->enabled = NULL;
1778 } else if (strcmp(colname[j], "app_indicatordisplay") == 0){
1780 info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[j]);
1782 info->manifest_info->uiapplication->indicatordisplay = NULL;
1783 } else if (strcmp(colname[j], "app_portraitimg") == 0){
1785 info->manifest_info->uiapplication->portraitimg = strdup(coltxt[j]);
1787 info->manifest_info->uiapplication->portraitimg = NULL;
1788 } else if (strcmp(colname[j], "app_landscapeimg") == 0){
1790 info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[j]);
1792 info->manifest_info->uiapplication->landscapeimg = NULL;
1793 } else if (strcmp(colname[j], "app_guestmodevisibility") == 0){
1795 info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[j]);
1797 info->manifest_info->uiapplication->guestmode_visibility = NULL;
1798 } else if (strcmp(colname[j], "app_recentimage") == 0 ) {
1800 info->manifest_info->uiapplication->recentimage = strdup(coltxt[j]);
1802 info->manifest_info->uiapplication->recentimage = NULL;
1803 } else if (strcmp(colname[j], "app_mainapp") == 0 ) {
1805 info->manifest_info->uiapplication->mainapp = strdup(coltxt[j]);
1807 info->manifest_info->uiapplication->mainapp = NULL;
1808 } else if (strcmp(colname[j], "package") == 0 ) {
1810 info->manifest_info->uiapplication->package = strdup(coltxt[j]);
1812 info->manifest_info->uiapplication->package = NULL;
1813 } else if (strcmp(colname[j], "app_component") == 0) {
1815 info->manifest_info->uiapplication->app_component = strdup(coltxt[j]);
1817 info->manifest_info->uiapplication->app_component = NULL;
1818 } else if (strcmp(colname[j], "app_permissiontype") == 0 ) {
1820 info->manifest_info->uiapplication->permission_type = strdup(coltxt[j]);
1822 info->manifest_info->uiapplication->permission_type = NULL;
1823 } else if (strcmp(colname[j], "component_type") == 0 ) {
1825 info->manifest_info->uiapplication->component_type = strdup(coltxt[j]);
1827 info->manifest_info->uiapplication->component_type = NULL;
1828 } else if (strcmp(colname[j], "app_preload") == 0 ) {
1830 info->manifest_info->uiapplication->preload = strdup(coltxt[j]);
1832 info->manifest_info->uiapplication->preload = NULL;
1833 } else if (strcmp(colname[j], "app_submode") == 0 ) {
1835 info->manifest_info->uiapplication->submode = strdup(coltxt[j]);
1837 info->manifest_info->uiapplication->submode = NULL;
1838 } else if (strcmp(colname[j], "app_submode_mainid") == 0 ) {
1840 info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[j]);
1842 info->manifest_info->uiapplication->submode_mainid = NULL;
1843 } else if (strcmp(colname[j], "app_launch_mode") == 0 ) {
1845 info->manifest_info->uiapplication->launch_mode = strdup(coltxt[j]);
1847 info->manifest_info->uiapplication->launch_mode = NULL;
1852 svcapp = calloc(1, sizeof(serviceapplication_x));
1853 if (svcapp == NULL) {
1854 _LOGE("Out of Memory!!!\n");
1857 LISTADD(info->manifest_info->serviceapplication, svcapp);
1858 for(j = 0; j < ncols; j++)
1860 if (strcmp(colname[j], "app_id") == 0) {
1862 info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
1863 } else if (strcmp(colname[j], "app_exec") == 0) {
1865 info->manifest_info->serviceapplication->exec = strdup(coltxt[j]);
1867 info->manifest_info->serviceapplication->exec = NULL;
1868 } else if (strcmp(colname[j], "app_type") == 0 ){
1870 info->manifest_info->serviceapplication->type = strdup(coltxt[j]);
1872 info->manifest_info->serviceapplication->type = NULL;
1873 } else if (strcmp(colname[j], "app_onboot") == 0 ){
1875 info->manifest_info->serviceapplication->onboot = strdup(coltxt[j]);
1877 info->manifest_info->serviceapplication->onboot = NULL;
1878 } else if (strcmp(colname[j], "app_autorestart") == 0 ){
1880 info->manifest_info->serviceapplication->autorestart = strdup(coltxt[j]);
1882 info->manifest_info->serviceapplication->autorestart = NULL;
1883 } else if (strcmp(colname[j], "package") == 0 ){
1885 info->manifest_info->serviceapplication->package = strdup(coltxt[j]);
1887 info->manifest_info->serviceapplication->package = NULL;
1888 } else if (strcmp(colname[j], "app_permissiontype") == 0 ) {
1890 info->manifest_info->serviceapplication->permission_type = strdup(coltxt[j]);
1892 info->manifest_info->serviceapplication->permission_type = NULL;
1905 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
1907 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
1909 icon_x *icon = NULL;
1910 label_x *label = NULL;
1911 category_x *category = NULL;
1912 metadata_x *metadata = NULL;
1913 permission_x *permission = NULL;
1914 image_x *image = NULL;
1916 switch (info->app_component) {
1918 icon = calloc(1, sizeof(icon_x));
1919 LISTADD(info->uiapp_info->icon, icon);
1920 label = calloc(1, sizeof(label_x));
1921 LISTADD(info->uiapp_info->label, label);
1922 category = calloc(1, sizeof(category_x));
1923 LISTADD(info->uiapp_info->category, category);
1924 metadata = calloc(1, sizeof(metadata_x));
1925 LISTADD(info->uiapp_info->metadata, metadata);
1926 permission = calloc(1, sizeof(permission_x));
1927 LISTADD(info->uiapp_info->permission, permission);
1928 image = calloc(1, sizeof(image_x));
1929 LISTADD(info->uiapp_info->image, image);
1931 for(i = 0; i < ncols; i++)
1933 if (strcmp(colname[i], "app_id") == 0) {
1934 /*appid being foreign key, is column in every table
1935 Hence appid gets strduped every time leading to memory leak.
1936 If appid is already set, just continue.*/
1937 if (info->uiapp_info->appid)
1940 info->uiapp_info->appid = strdup(coltxt[i]);
1942 info->uiapp_info->appid = NULL;
1943 } else if (strcmp(colname[i], "app_exec") == 0) {
1945 info->uiapp_info->exec = strdup(coltxt[i]);
1947 info->uiapp_info->exec = NULL;
1948 } else if (strcmp(colname[i], "app_nodisplay") == 0) {
1950 info->uiapp_info->nodisplay = strdup(coltxt[i]);
1952 info->uiapp_info->nodisplay = NULL;
1953 } else if (strcmp(colname[i], "app_type") == 0 ) {
1955 info->uiapp_info->type = strdup(coltxt[i]);
1957 info->uiapp_info->type = NULL;
1958 } else if (strcmp(colname[i], "app_icon_section") == 0 ) {
1960 info->uiapp_info->icon->section= strdup(coltxt[i]);
1962 info->uiapp_info->icon->section = NULL;
1963 } else if (strcmp(colname[i], "app_icon") == 0) {
1965 info->uiapp_info->icon->text = strdup(coltxt[i]);
1967 info->uiapp_info->icon->text = NULL;
1968 } else if (strcmp(colname[i], "app_label") == 0 ) {
1970 info->uiapp_info->label->text = strdup(coltxt[i]);
1972 info->uiapp_info->label->text = NULL;
1973 } else if (strcmp(colname[i], "app_multiple") == 0 ) {
1975 info->uiapp_info->multiple = strdup(coltxt[i]);
1977 info->uiapp_info->multiple = NULL;
1978 } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
1980 info->uiapp_info->taskmanage = strdup(coltxt[i]);
1982 info->uiapp_info->taskmanage = NULL;
1983 } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
1985 info->uiapp_info->hwacceleration = strdup(coltxt[i]);
1987 info->uiapp_info->hwacceleration = NULL;
1988 } else if (strcmp(colname[i], "app_screenreader") == 0 ) {
1990 info->uiapp_info->screenreader = strdup(coltxt[i]);
1992 info->uiapp_info->screenreader = NULL;
1993 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
1995 info->uiapp_info->enabled= strdup(coltxt[i]);
1997 info->uiapp_info->enabled = NULL;
1998 } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
2000 info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
2002 info->uiapp_info->indicatordisplay = NULL;
2003 } else if (strcmp(colname[i], "app_portraitimg") == 0){
2005 info->uiapp_info->portraitimg = strdup(coltxt[i]);
2007 info->uiapp_info->portraitimg = NULL;
2008 } else if (strcmp(colname[i], "app_landscapeimg") == 0){
2010 info->uiapp_info->landscapeimg = strdup(coltxt[i]);
2012 info->uiapp_info->landscapeimg = NULL;
2013 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
2015 info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
2017 info->uiapp_info->guestmode_visibility = NULL;
2018 } else if (strcmp(colname[i], "category") == 0 ) {
2020 info->uiapp_info->category->name = strdup(coltxt[i]);
2022 info->uiapp_info->category->name = NULL;
2023 } else if (strcmp(colname[i], "md_key") == 0 ) {
2025 info->uiapp_info->metadata->key = strdup(coltxt[i]);
2027 info->uiapp_info->metadata->key = NULL;
2028 } else if (strcmp(colname[i], "md_value") == 0 ) {
2030 info->uiapp_info->metadata->value = strdup(coltxt[i]);
2032 info->uiapp_info->metadata->value = NULL;
2033 } else if (strcmp(colname[i], "pm_type") == 0 ) {
2035 info->uiapp_info->permission->type= strdup(coltxt[i]);
2037 info->uiapp_info->permission->type = NULL;
2038 } else if (strcmp(colname[i], "pm_value") == 0 ) {
2040 info->uiapp_info->permission->value = strdup(coltxt[i]);
2042 info->uiapp_info->permission->value = NULL;
2043 } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
2045 info->uiapp_info->recentimage = strdup(coltxt[i]);
2047 info->uiapp_info->recentimage = NULL;
2048 } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
2050 info->uiapp_info->mainapp = strdup(coltxt[i]);
2052 info->uiapp_info->mainapp = NULL;
2053 } else if (strcmp(colname[i], "app_locale") == 0 ) {
2055 info->uiapp_info->icon->lang = strdup(coltxt[i]);
2056 info->uiapp_info->label->lang = strdup(coltxt[i]);
2059 info->uiapp_info->icon->lang = NULL;
2060 info->uiapp_info->label->lang = NULL;
2062 } else if (strcmp(colname[i], "app_image") == 0) {
2064 info->uiapp_info->image->text= strdup(coltxt[i]);
2066 info->uiapp_info->image->text = NULL;
2067 } else if (strcmp(colname[i], "app_image_section") == 0) {
2069 info->uiapp_info->image->section= strdup(coltxt[i]);
2071 info->uiapp_info->image->section = NULL;
2072 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
2074 info->uiapp_info->permission_type = strdup(coltxt[i]);
2076 info->uiapp_info->permission_type = NULL;
2077 } else if (strcmp(colname[i], "component_type") == 0 ) {
2079 info->uiapp_info->component_type = strdup(coltxt[i]);
2081 info->uiapp_info->component_type = NULL;
2082 } else if (strcmp(colname[i], "app_preload") == 0 ) {
2084 info->uiapp_info->preload = strdup(coltxt[i]);
2086 info->uiapp_info->preload = NULL;
2087 } else if (strcmp(colname[i], "app_submode") == 0 ) {
2089 info->uiapp_info->submode = strdup(coltxt[i]);
2091 info->uiapp_info->submode = NULL;
2092 } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
2094 info->uiapp_info->submode_mainid = strdup(coltxt[i]);
2096 info->uiapp_info->submode_mainid = NULL;
2097 } else if (strcmp(colname[i], "app_launch_mode") == 0 ) {
2099 info->uiapp_info->launch_mode = strdup(coltxt[i]);
2101 info->uiapp_info->launch_mode = NULL;
2106 case PMINFO_SVC_APP:
2107 icon = calloc(1, sizeof(icon_x));
2108 LISTADD(info->svcapp_info->icon, icon);
2109 label = calloc(1, sizeof(label_x));
2110 LISTADD(info->svcapp_info->label, label);
2111 category = calloc(1, sizeof(category_x));
2112 LISTADD(info->svcapp_info->category, category);
2113 metadata = calloc(1, sizeof(metadata_x));
2114 LISTADD(info->svcapp_info->metadata, metadata);
2115 permission = calloc(1, sizeof(permission_x));
2116 LISTADD(info->svcapp_info->permission, permission);
2117 for(i = 0; i < ncols; i++)
2119 if (strcmp(colname[i], "app_id") == 0) {
2120 /*appid being foreign key, is column in every table
2121 Hence appid gets strduped every time leading to memory leak.
2122 If appid is already set, just continue.*/
2123 if (info->svcapp_info->appid)
2126 info->svcapp_info->appid = strdup(coltxt[i]);
2128 info->svcapp_info->appid = NULL;
2129 } else if (strcmp(colname[i], "app_exec") == 0) {
2131 info->svcapp_info->exec = strdup(coltxt[i]);
2133 info->svcapp_info->exec = NULL;
2134 } else if (strcmp(colname[i], "app_icon") == 0) {
2136 info->svcapp_info->icon->text = strdup(coltxt[i]);
2138 info->svcapp_info->icon->text = NULL;
2139 } else if (strcmp(colname[i], "app_label") == 0 ) {
2141 info->svcapp_info->label->text = strdup(coltxt[i]);
2143 info->svcapp_info->label->text = NULL;
2144 } else if (strcmp(colname[i], "app_type") == 0 ) {
2146 info->svcapp_info->type = strdup(coltxt[i]);
2148 info->svcapp_info->type = NULL;
2149 } else if (strcmp(colname[i], "app_onboot") == 0 ) {
2151 info->svcapp_info->onboot = strdup(coltxt[i]);
2153 info->svcapp_info->onboot = NULL;
2154 } else if (strcmp(colname[i], "app_autorestart") == 0 ) {
2156 info->svcapp_info->autorestart = strdup(coltxt[i]);
2158 info->svcapp_info->autorestart = NULL;
2159 } else if (strcmp(colname[i], "app_enabled") == 0 ) {
2161 info->svcapp_info->enabled= strdup(coltxt[i]);
2163 info->svcapp_info->enabled = NULL;
2164 } else if (strcmp(colname[i], "category") == 0 ) {
2166 info->svcapp_info->category->name = strdup(coltxt[i]);
2168 info->svcapp_info->category->name = NULL;
2169 } else if (strcmp(colname[i], "md_key") == 0 ) {
2171 info->svcapp_info->metadata->key = strdup(coltxt[i]);
2173 info->svcapp_info->metadata->key = NULL;
2174 } else if (strcmp(colname[i], "md_value") == 0 ) {
2176 info->svcapp_info->metadata->value = strdup(coltxt[i]);
2178 info->svcapp_info->metadata->value = NULL;
2179 } else if (strcmp(colname[i], "pm_type") == 0 ) {
2181 info->svcapp_info->permission->type= strdup(coltxt[i]);
2183 info->svcapp_info->permission->type = NULL;
2184 } else if (strcmp(colname[i], "pm_value") == 0 ) {
2186 info->svcapp_info->permission->value = strdup(coltxt[i]);
2188 info->svcapp_info->permission->value = NULL;
2189 } else if (strcmp(colname[i], "app_locale") == 0 ) {
2191 info->svcapp_info->icon->lang = strdup(coltxt[i]);
2192 info->svcapp_info->label->lang = strdup(coltxt[i]);
2195 info->svcapp_info->icon->lang = NULL;
2196 info->svcapp_info->label->lang = NULL;
2198 } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
2200 info->svcapp_info->permission_type = strdup(coltxt[i]);
2202 info->svcapp_info->permission_type = NULL;
2215 static int __appcomponent_cb(void *data, int ncols, char **coltxt, char **colname)
2217 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
2219 for(i = 0; i < ncols; i++)
2221 if (strcmp(colname[i], "app_component") == 0) {
2222 info->app_component = __appcomponent_convert(coltxt[i]);
2223 } else if (strcmp(colname[i], "package") == 0) {
2224 info->package = strdup(coltxt[i]);
2231 static int __datacontrol_cb(void *data, int ncols, char **coltxt, char **colname)
2233 pkgmgr_datacontrol_x *info = (pkgmgr_datacontrol_x *)data;
2235 for(i = 0; i < ncols; i++)
2237 if (strcmp(colname[i], "PACKAGE_NAME") == 0) {
2239 info->appid = strdup(coltxt[i]);
2242 } else if (strcmp(colname[i], "ACCESS") == 0 ){
2244 info->access = strdup(coltxt[i]);
2246 info->access = NULL;
2253 static int __cert_cb(void *data, int ncols, char **coltxt, char **colname)
2255 pkgmgr_cert_x *info = (pkgmgr_cert_x *)data;
2258 for(i = 0; i < ncols; i++)
2260 if (strcmp(colname[i], "author_signer_cert") == 0) {
2262 info->cert_id = atoi(coltxt[i]);
2265 } else if (strcmp(colname[i], "package") == 0) {
2267 info->pkgid= strdup(coltxt[i]);
2276 /* get the first locale value*/
2277 static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
2279 pkgmgr_locale_x *info = (pkgmgr_locale_x *)data;
2282 info->locale = strdup(coltxt[0]);
2284 info->locale = NULL;
2289 static int __exec_pkginfo_query(char *query, void *data)
2291 char *error_message = NULL;
2293 sqlite3_exec(GET_DB(manifest_db), query, __pkginfo_cb, data, &error_message)) {
2294 _LOGE("Don't execute query = %s error message = %s\n", query,
2296 sqlite3_free(error_message);
2299 sqlite3_free(error_message);
2303 static int __exec_certinfo_query(char *query, void *data)
2305 char *error_message = NULL;
2307 sqlite3_exec(GET_DB(cert_db), query, __certinfo_cb, data, &error_message)) {
2308 _LOGE("Don't execute query = %s error message = %s\n", query,
2310 sqlite3_free(error_message);
2313 sqlite3_free(error_message);
2317 static int __exec_certindexinfo_query(char *query, void *data)
2319 char *error_message = NULL;
2321 sqlite3_exec(GET_DB(cert_db), query, __certindexinfo_cb, data, &error_message)) {
2322 _LOGE("Don't execute query = %s error message = %s\n", query,
2324 sqlite3_free(error_message);
2327 sqlite3_free(error_message);
2331 static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data)
2333 char *error_message = NULL;
2334 int ret = sqlite3_exec(db, query, callback, data, &error_message);
2335 if (SQLITE_OK != ret) {
2336 _LOGE("Don't execute query = %s error message = %s ret = %d\n", query,
2337 error_message, ret);
2338 sqlite3_free(error_message);
2341 sqlite3_free(error_message);
2346 static int __child_element(xmlTextReaderPtr reader, int depth)
2348 int ret = xmlTextReaderRead(reader);
2349 int cur = xmlTextReaderDepth(reader);
2352 switch (xmlTextReaderNodeType(reader)) {
2353 case XML_READER_TYPE_ELEMENT:
2354 if (cur == depth + 1)
2357 case XML_READER_TYPE_TEXT:
2358 /*text is handled by each function separately*/
2359 if (cur == depth + 1)
2362 case XML_READER_TYPE_END_ELEMENT:
2371 ret = xmlTextReaderRead(reader);
2372 cur = xmlTextReaderDepth(reader);
2377 static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, char **colname)
2379 int *p = (int*)data;
2380 *p = atoi(coltxt[0]);
2384 static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale)
2386 int result_query = -1;
2388 char query[MAX_QUERY_LEN];
2390 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);
2391 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
2392 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
2393 return result_query;
2396 static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
2398 int result_query = -1;
2400 char wildcard[2] = {'%','\0'};
2401 char query[MAX_QUERY_LEN];
2402 char lang[3] = {'\0'};
2403 strncpy(lang, locale, LANGUAGE_LENGTH);
2405 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);
2406 ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
2407 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
2408 return result_query;
2411 static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
2414 char wildcard[2] = {'%','\0'};
2415 char lang[3] = {'\0'};
2416 char query[MAX_QUERY_LEN];
2417 char *locale_new = NULL;
2418 pkgmgr_locale_x *info = NULL;
2420 info = (pkgmgr_locale_x *)malloc(sizeof(pkgmgr_locale_x));
2422 _LOGE("Out of Memory!!!\n");
2425 memset(info, '\0', sizeof(*info));
2427 strncpy(lang, locale, 2);
2428 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);
2429 ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
2430 tryvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
2431 locale_new = info->locale;
2442 static char* __convert_syslocale_to_manifest_locale(char *syslocale)
2444 char *locale = malloc(6);
2446 _LOGE("Malloc Failed\n");
2450 sprintf(locale, "%c%c-%c%c", syslocale[0], syslocale[1], tolower(syslocale[3]), tolower(syslocale[4]));
2454 static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const char *syslocale)
2459 char *locale = NULL;
2460 char *locale_new = NULL;
2461 int check_result = 0;
2463 locale = __convert_syslocale_to_manifest_locale((char *)syslocale);
2465 /*check exact matching */
2466 check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale);
2469 if (check_result == 1) {
2470 _LOGD("%s find exact locale(%s)\n", appid, locale);
2474 /* fallback matching */
2475 check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
2476 if(check_result == 1) {
2477 locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
2479 if (locale_new == NULL)
2480 locale_new = strdup(DEFAULT_LOCALE);
2484 /* default locale */
2486 return strdup(DEFAULT_LOCALE);
2489 long long _pkgmgr_calculate_dir_size(char *dirname)
2491 long long total = 0;
2493 int q = 0; /*quotient*/
2494 int r = 0; /*remainder*/
2496 struct dirent *ep = NULL;
2497 struct stat fileinfo;
2498 char abs_filename[FILENAME_MAX] = { 0, };
2499 retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL");
2501 dp = opendir(dirname);
2503 while ((ep = readdir(dp)) != NULL) {
2504 if (!strcmp(ep->d_name, ".") ||
2505 !strcmp(ep->d_name, "..")) {
2508 snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
2510 if (lstat(abs_filename, &fileinfo) < 0)
2511 perror(abs_filename);
2513 if (S_ISDIR(fileinfo.st_mode)) {
2514 total += fileinfo.st_size;
2515 if (strcmp(ep->d_name, ".")
2516 && strcmp(ep->d_name, "..")) {
2517 ret = _pkgmgr_calculate_dir_size
2519 total = total + ret;
2521 } else if (S_ISLNK(fileinfo.st_mode)) {
2524 /*It is a file. Calculate the actual
2525 size occupied (in terms of 4096 blocks)*/
2526 q = (fileinfo.st_size / BLOCK_SIZE);
2527 r = (fileinfo.st_size % BLOCK_SIZE);
2531 total += q * BLOCK_SIZE;
2537 _LOGE("Couldn't open the directory\n");
2544 static int __delete_certinfo(const char *pkgid, uid_t uid)
2550 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
2551 char *error_message = NULL;
2552 char query[MAX_QUERY_LEN] = {'\0'};
2553 pkgmgr_certinfo_x *certinfo = NULL;
2554 pkgmgr_certindexinfo_x *indexinfo = NULL;
2555 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
2556 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
2557 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
2558 if (indexinfo == NULL) {
2559 _LOGE("Out of Memory!!!");
2560 ret = PMINFO_R_ERROR;
2564 __open_cert_db(uid, "w");
2565 /*populate certinfo from DB*/
2566 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
2567 ret = __exec_certinfo_query(query, (void *)certinfo);
2569 _LOGE("Package Cert Info DB Information retrieval failed\n");
2570 ret = PMINFO_R_ERROR;
2573 /*Update cert index table*/
2574 for (i = 0; i < MAX_CERT_TYPE; i++) {
2575 if ((certinfo->cert_id)[i]) {
2576 for (j = 0; j < MAX_CERT_TYPE; j++) {
2577 if ((certinfo->cert_id)[i] == unique_id[j]) {
2578 /*Ref count has already been updated. Just continue*/
2582 if (j == MAX_CERT_TYPE)
2583 unique_id[c++] = (certinfo->cert_id)[i];
2586 memset(query, '\0', MAX_QUERY_LEN);
2587 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
2588 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
2590 _LOGE("Cert Info DB Information retrieval failed\n");
2591 ret = PMINFO_R_ERROR;
2594 memset(query, '\0', MAX_QUERY_LEN);
2595 if (indexinfo->cert_ref_count > 1) {
2596 /*decrease ref count*/
2597 snprintf(query, MAX_QUERY_LEN, "update package_cert_index_info set cert_ref_count=%d where cert_id=%d ",
2598 indexinfo->cert_ref_count - 1, (certinfo->cert_id)[i]);
2600 /*delete this certificate as ref count is 1 and it will become 0*/
2601 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
2604 sqlite3_exec(GET_DB(cert_db), query, NULL, NULL, &error_message)) {
2605 _LOGE("Don't execute query = %s error message = %s\n", query,
2607 sqlite3_free(error_message);
2608 ret = PMINFO_R_ERROR;
2613 /*Now delete the entry from db*/
2614 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
2616 sqlite3_exec(GET_DB(cert_db), query, NULL, NULL, &error_message)) {
2617 _LOGE("Don't execute query = %s error message = %s\n", query,
2619 sqlite3_free(error_message);
2620 ret = PMINFO_R_ERROR;
2629 if (certinfo->pkgid) {
2630 free(certinfo->pkgid);
2631 certinfo->pkgid = NULL;
2633 for (i = 0; i < MAX_CERT_TYPE; i++) {
2634 if ((certinfo->cert_info)[i]) {
2635 free((certinfo->cert_info)[i]);
2636 (certinfo->cert_info)[i] = NULL;
2645 static int __get_pkg_location(const char *pkgid)
2647 retvm_if(pkgid == NULL, PMINFO_R_OK, "pkginfo handle is NULL");
2650 char pkg_mmc_path[FILENAME_MAX] = { 0, };
2651 snprintf(pkg_mmc_path, FILENAME_MAX, "%s%s", PKG_SD_PATH, pkgid);
2653 /*check whether application is in external memory or not */
2654 fp = fopen(pkg_mmc_path, "r");
2658 return PMINFO_EXTERNAL_STORAGE;
2661 return PMINFO_INTERNAL_STORAGE;
2664 API int pkgmgrinfo_pkginfo_get_usr_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
2666 retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
2667 char *error_message = NULL;
2668 int ret = PMINFO_R_OK;
2671 char query[MAX_QUERY_LEN] = {'\0'};
2672 char *syslocale = NULL;
2673 char *locale = NULL;
2674 pkgmgr_pkginfo_x *pkginfo = NULL;
2675 label_x *tmp1 = NULL;
2676 icon_x *tmp2 = NULL;
2677 description_x *tmp3 = NULL;
2678 author_x *tmp4 = NULL;
2679 privilege_x *tmp5 = NULL;
2681 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2682 if (syslocale == NULL) {
2683 _LOGE("current locale is NULL\n");
2684 return PMINFO_R_ERROR;
2686 locale = __convert_system_locale_to_manifest_locale(syslocale);
2687 if (locale == NULL) {
2688 _LOGE("manifest locale is NULL\n");
2690 return PMINFO_R_ERROR;
2693 ret_db = __open_manifest_db(uid);
2695 _LOGE("Fail to open manifest DB\n");
2698 return PMINFO_R_ERROR;
2700 pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2701 pkgmgr_pkginfo_x *node = NULL;
2702 pkgmgr_pkginfo_x *temp_node = NULL;
2704 snprintf(query, MAX_QUERY_LEN, "select * from package_info");
2706 sqlite3_exec(GET_DB(manifest_db), query, __pkg_list_cb, (void *)tmphead, &error_message)) {
2707 _LOGE("Don't execute query = %s error message = %s\n", query,
2709 sqlite3_free(error_message);
2710 ret = PMINFO_R_ERROR;
2714 LISTHEAD(tmphead, node);
2716 for(node = node->next; node ; node = node->next) {
2718 pkginfo->locale = strdup(locale);
2719 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2720 if (pkginfo->manifest_info->privileges == NULL) {
2721 _LOGE("Failed to allocate memory for privileges info\n");
2722 ret = PMINFO_R_ERROR;
2725 /*populate manifest_info from DB*/
2726 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
2727 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2729 _LOGE("Package Info DB Information retrieval failed\n");
2730 ret = PMINFO_R_ERROR;
2733 memset(query, '\0', MAX_QUERY_LEN);
2734 /*populate privilege_info from DB*/
2735 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package);
2736 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2738 _LOGE("Package Privilege Info DB Information retrieval failed\n");
2739 ret = PMINFO_R_ERROR;
2742 memset(query, '\0', MAX_QUERY_LEN);
2743 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2744 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
2745 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2747 _LOGE("Package Info DB Information retrieval failed\n");
2748 ret = PMINFO_R_ERROR;
2751 /*Also store the values corresponding to default locales*/
2752 memset(query, '\0', MAX_QUERY_LEN);
2753 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2754 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
2755 ret = __exec_pkginfo_query(query, (void *)pkginfo);
2757 _LOGE("Package Info DB Information retrieval failed\n");
2758 ret = PMINFO_R_ERROR;
2761 if (pkginfo->manifest_info->label) {
2762 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2763 pkginfo->manifest_info->label = tmp1;
2765 if (pkginfo->manifest_info->icon) {
2766 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2767 pkginfo->manifest_info->icon = tmp2;
2769 if (pkginfo->manifest_info->description) {
2770 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2771 pkginfo->manifest_info->description = tmp3;
2773 if (pkginfo->manifest_info->author) {
2774 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2775 pkginfo->manifest_info->author = tmp4;
2777 if (pkginfo->manifest_info->privileges->privilege) {
2778 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2779 pkginfo->manifest_info->privileges->privilege = tmp5;
2783 LISTHEAD(tmphead, node);
2785 for(node = node->next; node ; node = node->next) {
2788 ret = pkg_list_cb( (void *)pkginfo, user_data);
2796 __close_manifest_db();
2805 LISTHEAD(tmphead, node);
2806 temp_node = node->next;
2809 temp_node = node->next;
2810 __cleanup_pkginfo(node);
2813 __cleanup_pkginfo(tmphead);
2817 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
2819 return pkgmgrinfo_pkginfo_get_usr_list(pkg_list_cb, user_data, GLOBAL_USER);
2822 API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkginfo_h *handle)
2824 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
2825 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2826 pkgmgr_pkginfo_x *pkginfo = NULL;
2827 int ret = PMINFO_R_OK;
2828 char query[MAX_QUERY_LEN] = {'\0'};
2829 char *syslocale = NULL;
2830 char *locale = NULL;
2832 label_x *tmp1 = NULL;
2833 icon_x *tmp2 = NULL;
2834 description_x *tmp3 = NULL;
2835 author_x *tmp4 = NULL;
2836 privilege_x *tmp5 = NULL;
2837 const char* user_pkg_parser = NULL;
2842 user_pkg_parser = getUserPkgParserDBPathUID(uid);
2843 ret = __open_manifest_db(uid);
2844 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
2846 /*check pkgid exist on db*/
2847 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
2848 ret = __exec_db_query(GET_DB(manifest_db), query, __validate_cb, (void *)&exist);
2849 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
2850 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] not found in DB", pkgid);
2852 /*get system locale*/
2853 syslocale = vconf_get_str(VCONFKEY_LANGSET);
2854 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
2856 /*get locale on db*/
2857 locale = __convert_system_locale_to_manifest_locale(syslocale);
2858 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
2860 pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
2861 tryvm_if(pkginfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for pkginfo");
2863 pkginfo->locale = strdup(locale);
2865 pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
2866 tryvm_if(pkginfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for manifest info");
2868 pkginfo->manifest_info->package = strdup(pkgid);
2869 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
2870 tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info");
2872 /*populate manifest_info from DB*/
2873 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
2874 ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
2875 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2877 memset(query, '\0', MAX_QUERY_LEN);
2878 /*populate privilege_info from DB*/
2879 snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
2880 ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
2881 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
2883 memset(query, '\0', MAX_QUERY_LEN);
2884 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2885 " package='%s' and package_locale='%s'", pkgid, locale);
2886 ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
2887 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2889 /*Also store the values corresponding to default locales*/
2890 memset(query, '\0', MAX_QUERY_LEN);
2891 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
2892 " package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
2893 ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
2894 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
2896 if (pkginfo->manifest_info->label) {
2897 LISTHEAD(pkginfo->manifest_info->label, tmp1);
2898 pkginfo->manifest_info->label = tmp1;
2900 if (pkginfo->manifest_info->icon) {
2901 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
2902 pkginfo->manifest_info->icon = tmp2;
2904 if (pkginfo->manifest_info->description) {
2905 LISTHEAD(pkginfo->manifest_info->description, tmp3);
2906 pkginfo->manifest_info->description = tmp3;
2908 if (pkginfo->manifest_info->author) {
2909 LISTHEAD(pkginfo->manifest_info->author, tmp4);
2910 pkginfo->manifest_info->author = tmp4;
2912 if (pkginfo->manifest_info->privileges->privilege) {
2913 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
2914 pkginfo->manifest_info->privileges->privilege = tmp5;
2918 if (ret == PMINFO_R_OK)
2919 *handle = (void*)pkginfo;
2922 __cleanup_pkginfo(pkginfo);
2924 __close_manifest_db();
2936 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
2938 return pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, GLOBAL_USER, handle);
2941 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
2943 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2944 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2945 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2946 if (info->manifest_info->package)
2947 *pkg_name = (char *)info->manifest_info->package;
2949 return PMINFO_R_ERROR;
2954 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
2956 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2957 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2958 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2959 if (info->manifest_info->package)
2960 *pkgid = (char *)info->manifest_info->package;
2962 return PMINFO_R_ERROR;
2967 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
2969 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2970 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2971 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2972 if (info->manifest_info->type)
2973 *type = (char *)info->manifest_info->type;
2979 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
2981 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2982 retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2983 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2984 *version = (char *)info->manifest_info->version;
2988 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
2990 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
2991 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2993 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2994 val = (char *)info->manifest_info->installlocation;
2996 if (strcmp(val, "internal-only") == 0)
2997 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
2998 else if (strcmp(val, "prefer-external") == 0)
2999 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
3001 *location = PMINFO_INSTALL_LOCATION_AUTO;
3006 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
3008 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3009 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3011 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3012 val = (char *)info->manifest_info->package_size;
3017 _LOGE("package size is not specified\n");
3018 return PMINFO_R_ERROR;
3023 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
3025 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3026 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3029 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
3030 long long rw_size = 0;
3031 long long ro_size= 0;
3032 long long tmp_size= 0;
3033 long long total_size= 0;
3034 struct stat fileinfo;
3037 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
3039 return PMINFO_R_ERROR;
3042 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid);
3043 if (lstat(device_path, &fileinfo) == 0) {
3044 if (!S_ISLNK(fileinfo.st_mode)) {
3045 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3047 rw_size += tmp_size;
3051 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid);
3052 if (lstat(device_path, &fileinfo) == 0) {
3053 if (!S_ISLNK(fileinfo.st_mode)) {
3054 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3056 rw_size += tmp_size;
3060 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid);
3061 if (lstat(device_path, &fileinfo) == 0) {
3062 if (!S_ISLNK(fileinfo.st_mode)) {
3063 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3065 rw_size += tmp_size;
3069 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
3070 if (lstat(device_path, &fileinfo) == 0) {
3071 if (!S_ISLNK(fileinfo.st_mode)) {
3072 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3074 rw_size += tmp_size;
3078 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_PATH, pkgid);
3079 if (lstat(device_path, &fileinfo) == 0) {
3080 if (!S_ISLNK(fileinfo.st_mode)) {
3081 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3083 rw_size += tmp_size;
3087 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_PATH, pkgid);
3088 if (lstat(device_path, &fileinfo) == 0) {
3089 if (!S_ISLNK(fileinfo.st_mode)) {
3090 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3092 rw_size += tmp_size;
3097 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_PATH, pkgid);
3098 if (lstat(device_path, &fileinfo) == 0) {
3099 if (!S_ISLNK(fileinfo.st_mode)) {
3100 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3102 ro_size += tmp_size;
3106 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid);
3107 if (lstat(device_path, &fileinfo) == 0) {
3108 if (!S_ISLNK(fileinfo.st_mode)) {
3109 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3111 ro_size += tmp_size;
3115 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid);
3116 if (lstat(device_path, &fileinfo) == 0) {
3117 if (!S_ISLNK(fileinfo.st_mode)) {
3118 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3120 ro_size += tmp_size;
3124 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid);
3125 if (lstat(device_path, &fileinfo) == 0) {
3126 if (!S_ISLNK(fileinfo.st_mode)) {
3127 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3129 ro_size += tmp_size;
3133 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid);
3134 if (lstat(device_path, &fileinfo) == 0) {
3135 if (!S_ISLNK(fileinfo.st_mode)) {
3136 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3138 ro_size += tmp_size;
3142 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid);
3143 if (lstat(device_path, &fileinfo) == 0) {
3144 if (!S_ISLNK(fileinfo.st_mode)) {
3145 tmp_size = _pkgmgr_calculate_dir_size(device_path);
3147 ro_size += tmp_size;
3152 total_size = rw_size + ro_size;
3153 *size = (int)total_size;
3158 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
3160 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3161 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3164 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
3165 long long total_size= 0;
3168 ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid);
3170 return PMINFO_R_ERROR;
3172 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
3173 if (access(device_path, R_OK) == 0)
3174 total_size = _pkgmgr_calculate_dir_size(device_path);
3176 return PMINFO_R_ERROR;
3178 *size = (int)total_size;
3183 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
3185 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3186 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3187 int ret = PMINFO_R_OK;
3188 char *locale = NULL;
3192 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3194 locale = info->locale;
3195 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
3197 for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next)
3200 if (strcmp(ptr->lang, locale) == 0) {
3201 *icon = (char *)ptr->text;
3202 if (strcasecmp(*icon, "(null)") == 0) {
3203 locale = DEFAULT_LOCALE;
3207 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
3208 *icon = (char *)ptr->text;
3217 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
3219 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
3220 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3221 int ret = PMINFO_R_OK;
3222 char *locale = NULL;
3223 label_x *ptr = NULL;
3226 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3227 locale = info->locale;
3228 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
3230 for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next)
3233 if (strcmp(ptr->lang, locale) == 0) {
3234 *label = (char *)ptr->text;
3235 if (strcasecmp(*label, "(null)") == 0) {
3236 locale = DEFAULT_LOCALE;
3240 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
3241 *label = (char *)ptr->text;
3250 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
3252 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3253 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3254 char *locale = NULL;
3255 description_x *ptr = NULL;
3256 *description = NULL;
3258 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3259 locale = info->locale;
3260 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
3262 for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next)
3265 if (strcmp(ptr->lang, locale) == 0) {
3266 *description = (char *)ptr->text;
3267 if (strcasecmp(*description, PKGMGR_PARSER_EMPTY_STR) == 0) {
3268 locale = DEFAULT_LOCALE;
3272 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
3273 *description = (char *)ptr->text;
3281 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
3283 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3284 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3285 char *locale = NULL;
3286 author_x *ptr = NULL;
3287 *author_name = NULL;
3289 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3290 locale = info->locale;
3291 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
3293 for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next)
3296 if (strcmp(ptr->lang, locale) == 0) {
3297 *author_name = (char *)ptr->text;
3298 if (strcasecmp(*author_name, PKGMGR_PARSER_EMPTY_STR) == 0) {
3299 locale = DEFAULT_LOCALE;
3303 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
3304 *author_name = (char *)ptr->text;
3312 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
3314 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3315 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3316 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3317 *author_email = (char *)info->manifest_info->author->email;
3321 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
3323 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3324 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3325 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3326 *author_href = (char *)info->manifest_info->author->href;
3330 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
3332 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3333 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3335 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3337 if (strcmp(info->manifest_info->installed_storage,"installed_internal") == 0)
3338 *storage = PMINFO_INTERNAL_STORAGE;
3339 else if (strcmp(info->manifest_info->installed_storage,"installed_external") == 0)
3340 *storage = PMINFO_EXTERNAL_STORAGE;
3342 return PMINFO_R_ERROR;
3347 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
3349 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3350 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3351 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3352 if (info->manifest_info->installed_time)
3353 *installed_time = atoi(info->manifest_info->installed_time);
3355 return PMINFO_R_ERROR;
3360 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
3362 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3363 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3364 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3365 *storeclientid = (char *)info->manifest_info->storeclient_id;
3369 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
3371 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3372 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3373 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3374 *mainappid = (char *)info->manifest_info->mainapp_id;
3378 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
3380 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3381 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3382 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3383 *url = (char *)info->manifest_info->package_url;
3387 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
3389 const char *val = NULL;
3390 const xmlChar *node;
3391 xmlTextReaderPtr reader;
3392 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
3393 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3396 reader = xmlReaderForFile(manifest, NULL, 0);
3399 if (__child_element(reader, -1)) {
3400 node = xmlTextReaderConstName(reader);
3402 _LOGE("xmlTextReaderConstName value is NULL\n");
3403 xmlFreeTextReader(reader);
3405 return PMINFO_R_ERROR;
3408 if (!strcmp(ASC_CHAR(node), "manifest")) {
3409 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
3410 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
3416 _LOGE("package size is not specified\n");
3417 xmlFreeTextReader(reader);
3419 return PMINFO_R_ERROR;
3422 _LOGE("Unable to create xml reader\n");
3423 xmlFreeTextReader(reader);
3425 return PMINFO_R_ERROR;
3429 _LOGE("xmlReaderForFile value is NULL\n");
3431 return PMINFO_R_ERROR;
3434 xmlFreeTextReader(reader);
3440 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
3442 const char *val = NULL;
3443 const xmlChar *node;
3444 xmlTextReaderPtr reader;
3445 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
3446 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3449 reader = xmlReaderForFile(manifest, NULL, 0);
3452 if ( __child_element(reader, -1)) {
3453 node = xmlTextReaderConstName(reader);
3455 _LOGE("xmlTextReaderConstName value is NULL\n");
3456 xmlFreeTextReader(reader);
3458 return PMINFO_R_ERROR;
3461 if (!strcmp(ASC_CHAR(node), "manifest")) {
3462 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
3463 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
3466 if (strcmp(val, "internal-only") == 0)
3467 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
3468 else if (strcmp(val, "prefer-external") == 0)
3469 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
3471 *location = PMINFO_INSTALL_LOCATION_AUTO;
3474 _LOGE("Unable to create xml reader\n");
3475 xmlFreeTextReader(reader);
3477 return PMINFO_R_ERROR;
3481 _LOGE("xmlReaderForFile value is NULL\n");
3483 return PMINFO_R_ERROR;
3486 xmlFreeTextReader(reader);
3493 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
3495 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3496 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3498 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3499 if (info->manifest_info->root_path)
3500 *path = (char *)info->manifest_info->root_path;
3502 return PMINFO_R_ERROR;
3507 API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
3509 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3510 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3512 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3513 if (info->manifest_info->csc_path)
3514 *path = (char *)info->manifest_info->csc_path;
3516 *path = (char *)info->manifest_info->csc_path;
3521 API int pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(const char *lhs_package_id, const char *rhs_package_id, uid_t uid, pkgmgrinfo_cert_compare_result_type_e *compare_result)
3523 retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
3524 retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
3525 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3527 int ret = PMINFO_R_OK;
3528 char query[MAX_QUERY_LEN] = {'\0'};
3529 char *error_message = NULL;
3530 pkgmgr_cert_x *info= NULL;
3534 *compare_result = PMINFO_CERT_COMPARE_ERROR;
3535 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3536 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3538 ret = __open_cert_db(uid, "r");
3540 ret = PMINFO_R_ERROR;
3543 _check_create_Cert_db(GET_DB(cert_db));
3544 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
3546 sqlite3_exec(GET_DB(cert_db), query, __validate_cb, (void *)&exist, &error_message)) {
3547 _LOGE("Don't execute query = %s error message = %s\n", query,
3549 ret = PMINFO_R_ERROR;
3556 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
3558 sqlite3_exec(GET_DB(cert_db), query, __cert_cb, (void *)info, &error_message)) {
3559 _LOGE("Don't execute query = %s error message = %s\n", query,
3561 ret = PMINFO_R_ERROR;
3564 lcert = info->cert_id;
3567 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
3569 sqlite3_exec(GET_DB(cert_db), query, __validate_cb, (void *)&exist, &error_message)) {
3570 _LOGE("Don't execute query = %s error message = %s\n", query,
3572 ret = PMINFO_R_ERROR;
3579 snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
3581 sqlite3_exec(GET_DB(cert_db), query, __cert_cb, (void *)info, &error_message)) {
3582 _LOGE("Don't execute query = %s error message = %s\n", query,
3584 ret = PMINFO_R_ERROR;
3587 rcert = info->cert_id;
3590 if ((lcert == 0) || (rcert == 0))
3592 if ((lcert == 0) && (rcert == 0))
3593 *compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
3594 else if (lcert == 0)
3595 *compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
3596 else if (rcert == 0)
3597 *compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
3600 *compare_result = PMINFO_CERT_COMPARE_MATCH;
3602 *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
3606 sqlite3_free(error_message);
3619 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)
3621 return pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lhs_package_id, rhs_package_id, GLOBAL_USER, compare_result);
3624 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)
3626 retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
3627 retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
3628 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3630 int ret = PMINFO_R_OK;
3631 char query[MAX_QUERY_LEN] = {'\0'};
3632 char *error_message = NULL;
3633 pkgmgr_cert_x *info= NULL;
3635 char *lpkgid = NULL;
3636 char *rpkgid = NULL;
3637 const char* user_pkg_parser = getUserPkgParserDBPath();
3639 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3640 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3642 ret = db_util_open_with_options(user_pkg_parser, &GET_DB(manifest_db),
3643 SQLITE_OPEN_READONLY, NULL);
3644 if (ret != SQLITE_OK) {
3645 _LOGE("connect db [%s] failed!\n", user_pkg_parser);
3646 ret = PMINFO_R_ERROR;
3650 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
3652 sqlite3_exec(GET_DB(manifest_db), query, __validate_cb, (void *)&exist, &error_message)) {
3653 _LOGE("Don't execute query = %s error message = %s\n", query,
3655 ret = PMINFO_R_ERROR;
3662 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
3664 sqlite3_exec(GET_DB(manifest_db), query, __cert_cb, (void *)info, &error_message)) {
3665 _LOGE("Don't execute query = %s error message = %s\n", query,
3667 ret = PMINFO_R_ERROR;
3670 lpkgid = strdup(info->pkgid);
3671 if (lpkgid == NULL) {
3672 _LOGE("Out of Memory\n");
3673 ret = PMINFO_R_ERROR;
3680 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
3682 sqlite3_exec(GET_DB(manifest_db), query, __validate_cb, (void *)&exist, &error_message)) {
3683 _LOGE("Don't execute query = %s error message = %s\n", query,
3685 ret = PMINFO_R_ERROR;
3692 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
3694 sqlite3_exec(GET_DB(manifest_db), query, __cert_cb, (void *)info, &error_message)) {
3695 _LOGE("Don't execute query = %s error message = %s\n", query,
3697 ret = PMINFO_R_ERROR;
3700 rpkgid = strdup(info->pkgid);
3701 if (rpkgid == NULL) {
3702 _LOGE("Out of Memory\n");
3703 ret = PMINFO_R_ERROR;
3709 ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
3711 sqlite3_free(error_message);
3712 __close_manifest_db();
3732 API int pkgmgrinfo_pkginfo_compare_usr_app_cert_info(const char *lhs_app_id, const char *rhs_app_id, uid_t uid, pkgmgrinfo_cert_compare_result_type_e *compare_result)
3734 retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
3735 retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
3736 retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
3738 int ret = PMINFO_R_OK;
3739 char query[MAX_QUERY_LEN] = {'\0'};
3740 char *error_message = NULL;
3741 pkgmgr_cert_x *info= NULL;
3743 char *lpkgid = NULL;
3744 char *rpkgid = NULL;
3746 info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
3747 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
3749 ret = __open_manifest_db(uid);
3750 if (ret != SQLITE_OK) {
3751 _LOGE("connect db [%s] failed!\n", getUserPkgParserDBPathUID(uid));
3752 ret = PMINFO_R_ERROR;
3756 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
3758 sqlite3_exec(GET_DB(manifest_db), query, __validate_cb, (void *)&exist, &error_message)) {
3759 _LOGE("Don't execute query = %s error message = %s\n", query,
3761 ret = PMINFO_R_ERROR;
3768 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
3770 sqlite3_exec(GET_DB(manifest_db), query, __cert_cb, (void *)info, &error_message)) {
3771 _LOGE("Don't execute query = %s error message = %s\n", query,
3773 ret = PMINFO_R_ERROR;
3776 lpkgid = strdup(info->pkgid);
3777 if (lpkgid == NULL) {
3778 _LOGE("Out of Memory\n");
3779 ret = PMINFO_R_ERROR;
3786 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
3788 sqlite3_exec(GET_DB(manifest_db), query, __validate_cb, (void *)&exist, &error_message)) {
3789 _LOGE("Don't execute query = %s error message = %s\n", query,
3791 ret = PMINFO_R_ERROR;
3798 snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
3800 sqlite3_exec(GET_DB(manifest_db), query, __cert_cb, (void *)info, &error_message)) {
3801 _LOGE("Don't execute query = %s error message = %s\n", query,
3803 ret = PMINFO_R_ERROR;
3806 rpkgid = strdup(info->pkgid);
3807 if (rpkgid == NULL) {
3808 _LOGE("Out of Memory\n");
3809 ret = PMINFO_R_ERROR;
3815 ret = pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lpkgid, rpkgid, uid, compare_result);
3817 sqlite3_free(error_message);
3818 __close_manifest_db();
3838 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
3840 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3841 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3843 #if 0 //smack issue occured, check later
3845 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
3847 _LOGD("invalid func parameters\n");
3848 return PMINFO_R_ERROR;
3850 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
3853 char app_mmc_path[FILENAME_MAX] = { 0, };
3854 char app_dir_path[FILENAME_MAX] = { 0, };
3855 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
3856 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
3857 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
3858 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
3860 /*check whether application is in external memory or not */
3861 fp = fopen(app_mmc_path, "r");
3863 _LOGD(" app path in external memory not accesible\n");
3868 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
3872 /*check whether application is in internal or not */
3873 fp = fopen(app_dir_path, "r");
3875 _LOGD(" app path in internal memory not accesible\n");
3877 return PMINFO_R_ERROR;
3880 /*check whether the application is installed in SD card
3881 but SD card is not present*/
3882 fp = fopen(app_mmc_internal_path, "r");
3885 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
3890 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
3895 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
3902 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
3904 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3905 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3907 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3908 val = (char *)info->manifest_info->removable;
3910 if (strcasecmp(val, "true") == 0)
3912 else if (strcasecmp(val, "false") == 0)
3920 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
3922 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3923 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3926 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3928 val = (char *)info->manifest_info->installlocation;
3930 if (strcmp(val, "internal-only") == 0)
3932 else if (strcmp(val, "prefer-external") == 0)
3941 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
3943 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3944 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3946 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3947 val = (char *)info->manifest_info->preload;
3949 if (strcasecmp(val, "true") == 0)
3951 else if (strcasecmp(val, "false") == 0)
3959 API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
3961 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3962 retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3965 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3966 val = (char *)info->manifest_info->system;
3968 if (strcasecmp(val, "true") == 0)
3970 else if (strcasecmp(val, "false") == 0)
3979 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
3981 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
3982 retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
3984 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
3985 val = (char *)info->manifest_info->readonly;
3987 if (strcasecmp(val, "true") == 0)
3989 else if (strcasecmp(val, "false") == 0)
3997 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
3999 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
4000 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4003 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
4004 val = (char *)info->manifest_info->update;
4006 if (strcasecmp(val, "true") == 0)
4008 else if (strcasecmp(val, "false") == 0)
4016 API int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users)
4018 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
4019 retvm_if(for_all_users == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
4022 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
4023 val = (char *)info->manifest_info->for_all_users;
4025 if (strcasecmp(val, "1") == 0)
4027 else if (strcasecmp(val, "0") == 0)
4036 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
4038 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
4039 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
4040 __cleanup_pkginfo(info);
4044 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
4046 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
4048 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
4049 if (filter == NULL) {
4050 _LOGE("Out of Memory!!!");
4051 return PMINFO_R_ERROR;
4057 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
4059 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4060 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
4062 g_slist_foreach(filter->list, __destroy_each_node, NULL);
4063 g_slist_free(filter->list);
4070 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
4071 const char *property, const int value)
4073 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4074 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4075 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
4077 GSList *link = NULL;
4079 prop = _pminfo_pkginfo_convert_to_prop_int(property);
4080 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
4081 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
4082 _LOGE("Invalid Integer Property\n");
4083 return PMINFO_R_EINVAL;
4085 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
4086 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
4088 _LOGE("Out of Memory!!!\n");
4089 return PMINFO_R_ERROR;
4091 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
4092 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
4094 _LOGE("Out of Memory\n");
4097 return PMINFO_R_ERROR;
4101 /*If API is called multiple times for same property, we should override the previous values.
4102 Last value set will be used for filtering.*/
4103 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
4105 filter->list = g_slist_delete_link(filter->list, link);
4106 filter->list = g_slist_append(filter->list, (gpointer)node);
4111 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
4112 const char *property, const bool value)
4114 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4115 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4117 GSList *link = NULL;
4119 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
4120 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
4121 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
4122 _LOGE("Invalid Boolean Property\n");
4123 return PMINFO_R_EINVAL;
4125 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
4126 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
4128 _LOGE("Out of Memory!!!\n");
4129 return PMINFO_R_ERROR;
4132 val = strndup("('true','True')", 15);
4134 val = strndup("('false','False')", 17);
4136 _LOGE("Out of Memory\n");
4139 return PMINFO_R_ERROR;
4143 /*If API is called multiple times for same property, we should override the previous values.
4144 Last value set will be used for filtering.*/
4145 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
4147 filter->list = g_slist_delete_link(filter->list, link);
4148 filter->list = g_slist_append(filter->list, (gpointer)node);
4153 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
4154 const char *property, const char *value)
4156 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4157 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4158 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4160 GSList *link = NULL;
4162 prop = _pminfo_pkginfo_convert_to_prop_str(property);
4163 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
4164 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
4165 _LOGE("Invalid String Property\n");
4166 return PMINFO_R_EINVAL;
4168 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
4169 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
4171 _LOGE("Out of Memory!!!\n");
4172 return PMINFO_R_ERROR;
4174 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
4175 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
4176 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
4177 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
4178 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
4179 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
4180 else if (strcmp(value, "installed_internal") == 0)
4181 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
4182 else if (strcmp(value, "installed_external") == 0)
4183 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
4185 val = strndup(value, PKG_STRING_LEN_MAX - 1);
4187 _LOGE("Out of Memory\n");
4190 return PMINFO_R_ERROR;
4194 /*If API is called multiple times for same property, we should override the previous values.
4195 Last value set will be used for filtering.*/
4196 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
4198 filter->list = g_slist_delete_link(filter->list, link);
4199 filter->list = g_slist_append(filter->list, (gpointer)node);
4204 API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count, uid_t uid)
4206 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4207 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4208 char *syslocale = NULL;
4209 char *locale = NULL;
4210 char *condition = NULL;
4211 char *error_message = NULL;
4212 char query[MAX_QUERY_LEN] = {'\0'};
4213 char where[MAX_QUERY_LEN] = {'\0'};
4217 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
4219 /*Get current locale*/
4220 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4221 if (syslocale == NULL) {
4222 _LOGE("current locale is NULL\n");
4223 return PMINFO_R_ERROR;
4225 locale = __convert_system_locale_to_manifest_locale(syslocale);
4226 if (locale == NULL) {
4227 _LOGE("manifest locale is NULL\n");
4229 return PMINFO_R_ERROR;
4232 ret = __open_manifest_db(uid);
4234 _LOGE("Fail to open manifest DB\n");
4237 return PMINFO_R_ERROR;
4240 /*Start constructing query*/
4241 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_PACKAGE, locale);
4243 /*Get where clause*/
4244 for (list = filter->list; list; list = g_slist_next(list)) {
4245 __get_filter_condition(list->data, &condition);
4247 strncat(where, condition, sizeof(where) - strlen(where) -1);
4248 where[sizeof(where) - 1] = '\0';
4252 if (g_slist_next(list)) {
4253 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
4254 where[sizeof(where) - 1] = '\0';
4257 _LOGE("where = %s\n", where);
4258 if (strlen(where) > 0) {
4259 strncat(query, where, sizeof(query) - strlen(query) - 1);
4260 query[sizeof(query) - 1] = '\0';
4262 _LOGE("query = %s\n", query);
4266 sqlite3_exec(GET_DB(manifest_db), query, __count_cb, (void *)count, &error_message)) {
4267 _LOGE("Don't execute query = %s error message = %s\n", query,
4269 sqlite3_free(error_message);
4270 ret = PMINFO_R_ERROR;
4284 __close_manifest_db();
4288 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
4290 return pkgmgrinfo_pkginfo_usr_filter_count(handle, count, GLOBAL_USER);
4293 API int pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
4294 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
4296 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4297 retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
4298 char *syslocale = NULL;
4299 char *locale = NULL;
4300 char *condition = NULL;
4301 char *error_message = NULL;
4302 char query[MAX_QUERY_LEN] = {'\0'};
4303 char where[MAX_QUERY_LEN] = {'\0'};
4306 label_x *tmp1 = NULL;
4307 icon_x *tmp2 = NULL;
4308 description_x *tmp3 = NULL;
4309 author_x *tmp4 = NULL;
4310 privilege_x *tmp5 = NULL;
4311 pkgmgr_pkginfo_x *node = NULL;
4312 pkgmgr_pkginfo_x *tmphead = NULL;
4313 pkgmgr_pkginfo_x *pkginfo = NULL;
4315 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
4316 /*Get current locale*/
4317 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4318 if (syslocale == NULL) {
4319 _LOGE("current locale is NULL\n");
4320 return PMINFO_R_ERROR;
4322 locale = __convert_system_locale_to_manifest_locale(syslocale);
4323 if (locale == NULL) {
4324 _LOGE("manifest locale is NULL\n");
4326 return PMINFO_R_ERROR;
4329 ret = __open_manifest_db(uid);
4331 _LOGE("Fail to open manifest DB\n");
4334 return PMINFO_R_ERROR;
4336 /*Start constructing query*/
4337 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale);
4339 /*Get where clause*/
4340 for (list = filter->list; list; list = g_slist_next(list)) {
4341 __get_filter_condition(list->data, &condition);
4343 strncat(where, condition, sizeof(where) - strlen(where) -1);
4344 where[sizeof(where) - 1] = '\0';
4348 if (g_slist_next(list)) {
4349 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
4350 where[sizeof(where) - 1] = '\0';
4353 _LOGE("where = %s\n", where);
4354 if (strlen(where) > 0) {
4355 strncat(query, where, sizeof(query) - strlen(query) - 1);
4356 query[sizeof(query) - 1] = '\0';
4358 _LOGE("query = %s\n", query);
4359 tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
4360 if (tmphead == NULL) {
4361 _LOGE("Out of Memory!!!\n");
4362 ret = PMINFO_R_ERROR;
4368 sqlite3_exec(GET_DB(manifest_db), query, __pkg_list_cb, (void *)tmphead, &error_message)) {
4369 _LOGE("Don't execute query = %s error message = %s\n", query,
4371 sqlite3_free(error_message);
4372 ret = PMINFO_R_ERROR;
4376 LISTHEAD(tmphead, node);
4377 for(node = node->next ; node ; node = node->next) {
4379 pkginfo->locale = strdup(locale);
4380 pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
4381 if (pkginfo->manifest_info->privileges == NULL) {
4382 _LOGE("Failed to allocate memory for privileges info\n");
4383 ret = PMINFO_R_ERROR;
4387 /*populate manifest_info from DB*/
4388 snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
4389 ret = __exec_pkginfo_query(query, (void *)pkginfo);
4391 _LOGE("Package Info DB Information retrieval failed\n");
4392 ret = PMINFO_R_ERROR;
4395 memset(query, '\0', MAX_QUERY_LEN);
4396 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
4397 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
4398 ret = __exec_pkginfo_query(query, (void *)pkginfo);
4400 _LOGE("Package Info DB Information retrieval failed\n");
4401 ret = PMINFO_R_ERROR;
4404 /*Also store the values corresponding to default locales*/
4405 memset(query, '\0', MAX_QUERY_LEN);
4406 snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
4407 " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE);
4408 ret = __exec_pkginfo_query(query, (void *)pkginfo);
4410 _LOGE("Package Info DB Information retrieval failed\n");
4411 ret = PMINFO_R_ERROR;
4414 if (pkginfo->manifest_info->label) {
4415 LISTHEAD(pkginfo->manifest_info->label, tmp1);
4416 pkginfo->manifest_info->label = tmp1;
4418 if (pkginfo->manifest_info->icon) {
4419 LISTHEAD(pkginfo->manifest_info->icon, tmp2);
4420 pkginfo->manifest_info->icon = tmp2;
4422 if (pkginfo->manifest_info->description) {
4423 LISTHEAD(pkginfo->manifest_info->description, tmp3);
4424 pkginfo->manifest_info->description = tmp3;
4426 if (pkginfo->manifest_info->author) {
4427 LISTHEAD(pkginfo->manifest_info->author, tmp4);
4428 pkginfo->manifest_info->author = tmp4;
4430 if (pkginfo->manifest_info->privileges->privilege) {
4431 LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
4432 pkginfo->manifest_info->privileges->privilege = tmp5;
4436 LISTHEAD(tmphead, node);
4438 for(node = node->next ; node ; node = node->next) {
4441 ret = pkg_cb( (void *)pkginfo, user_data);
4456 __close_manifest_db();
4457 __cleanup_pkginfo(tmphead);
4461 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
4462 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
4464 return pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, pkg_cb, user_data, GLOBAL_USER);
4467 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
4468 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
4470 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
4471 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
4473 privilege_x *ptr = NULL;
4474 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
4475 ptr = info->manifest_info->privileges->privilege;
4476 for (; ptr; ptr = ptr->next) {
4478 ret = privilege_func(ptr->text, user_data);
4486 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
4487 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
4489 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
4490 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
4491 retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
4493 char *syslocale = NULL;
4494 char *locale = NULL;
4496 char query[MAX_QUERY_LEN] = {'\0'};
4497 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
4498 pkgmgr_pkginfo_x *allinfo = NULL;
4499 pkgmgr_appinfo_x *appinfo = NULL;
4500 icon_x *ptr1 = NULL;
4501 label_x *ptr2 = NULL;
4502 category_x *ptr3 = NULL;
4503 metadata_x *ptr4 = NULL;
4504 permission_x *ptr5 = NULL;
4505 image_x *ptr6 = NULL;
4506 const char* user_pkg_parser = NULL;
4508 /*get system locale*/
4509 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4510 retvm_if(syslocale == NULL, PMINFO_R_EINVAL, "current locale is NULL");
4512 /*get locale on db*/
4513 locale = __convert_system_locale_to_manifest_locale(syslocale);
4514 tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
4517 allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4518 tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
4520 /*calloc manifest_info*/
4521 allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4522 tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4525 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4526 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
4528 /*set component type*/
4529 if (component == PMINFO_UI_APP)
4530 appinfo->app_component = PMINFO_UI_APP;
4531 if (component == PMINFO_SVC_APP)
4532 appinfo->app_component = PMINFO_SVC_APP;
4533 if (component == PMINFO_ALL_APP)
4534 appinfo->app_component = PMINFO_ALL_APP;
4537 user_pkg_parser = getUserPkgParserDBPathUID(uid);
4538 ret = __open_manifest_db(uid);
4539 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
4541 appinfo->package = strdup(info->manifest_info->package);
4542 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4543 "from package_app_info where " \
4544 "package='%s' and app_component='%s'",
4545 info->manifest_info->package,
4546 (appinfo->app_component==PMINFO_UI_APP ? "uiapp" : "svcapp"));
4550 /*Populate ui app info */
4551 ret = __exec_db_query(GET_DB(manifest_db), query, __uiapp_list_cb, (void *)info);
4552 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
4554 uiapplication_x *tmp = NULL;
4555 if (info->manifest_info->uiapplication) {
4556 LISTHEAD(info->manifest_info->uiapplication, tmp);
4557 info->manifest_info->uiapplication = tmp;
4559 /*Populate localized info for default locales and call callback*/
4560 /*If the callback func return < 0 we break and no more call back is called*/
4563 appinfo->locale = strdup(locale);
4564 appinfo->uiapp_info = tmp;
4565 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
4569 locale = __get_app_locale_by_fallback(GET_DB(manifest_db), appinfo->uiapp_info->appid, syslocale);
4572 memset(query, '\0', MAX_QUERY_LEN);
4573 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
4574 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4575 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4577 memset(query, '\0', MAX_QUERY_LEN);
4578 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);
4579 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4580 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4582 /*store setting notification icon section*/
4583 memset(query, '\0', MAX_QUERY_LEN);
4584 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
4585 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4586 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4588 /*store app preview image info*/
4589 memset(query, '\0', MAX_QUERY_LEN);
4590 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
4591 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4592 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4594 if (appinfo->uiapp_info->label) {
4595 LISTHEAD(appinfo->uiapp_info->label, ptr2);
4596 appinfo->uiapp_info->label = ptr2;
4598 if (appinfo->uiapp_info->icon) {
4599 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
4600 appinfo->uiapp_info->icon = ptr1;
4602 if (appinfo->uiapp_info->category) {
4603 LISTHEAD(appinfo->uiapp_info->category, ptr3);
4604 appinfo->uiapp_info->category = ptr3;
4606 if (appinfo->uiapp_info->metadata) {
4607 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
4608 appinfo->uiapp_info->metadata = ptr4;
4610 if (appinfo->uiapp_info->permission) {
4611 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
4612 appinfo->uiapp_info->permission = ptr5;
4614 if (appinfo->uiapp_info->image) {
4615 LISTHEAD(appinfo->uiapp_info->image, ptr6);
4616 appinfo->uiapp_info->image = ptr6;
4618 ret = app_func((void *)appinfo, user_data);
4624 case PMINFO_SVC_APP:
4625 /*Populate svc app info */
4626 ret = __exec_db_query(GET_DB(manifest_db), query, __svcapp_list_cb, (void *)info);
4627 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
4629 serviceapplication_x *tmp1 = NULL;
4630 if (info->manifest_info->serviceapplication) {
4631 LISTHEAD(info->manifest_info->serviceapplication, tmp1);
4632 info->manifest_info->serviceapplication = tmp1;
4634 /*Populate localized info for default locales and call callback*/
4635 /*If the callback func return < 0 we break and no more call back is called*/
4638 appinfo->locale = strdup(locale);
4639 appinfo->svcapp_info = tmp1;
4640 memset(query, '\0', MAX_QUERY_LEN);
4641 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
4642 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4643 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4645 memset(query, '\0', MAX_QUERY_LEN);
4646 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);
4647 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4648 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4650 if (appinfo->svcapp_info->label) {
4651 LISTHEAD(appinfo->svcapp_info->label, ptr2);
4652 appinfo->svcapp_info->label = ptr2;
4654 if (appinfo->svcapp_info->icon) {
4655 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
4656 appinfo->svcapp_info->icon = ptr1;
4658 if (appinfo->svcapp_info->category) {
4659 LISTHEAD(appinfo->svcapp_info->category, ptr3);
4660 appinfo->svcapp_info->category = ptr3;
4662 if (appinfo->svcapp_info->metadata) {
4663 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
4664 appinfo->svcapp_info->metadata = ptr4;
4666 if (appinfo->svcapp_info->permission) {
4667 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
4668 appinfo->svcapp_info->permission = ptr5;
4670 ret = app_func((void *)appinfo, user_data);
4676 case PMINFO_ALL_APP:
4677 memset(query, '\0', MAX_QUERY_LEN);
4678 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
4680 /*Populate all app info */
4681 ret = __exec_db_query(GET_DB(manifest_db), query, __allapp_list_cb, (void *)allinfo);
4682 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
4685 appinfo->app_component = PMINFO_UI_APP;
4686 uiapplication_x *tmp2 = NULL;
4687 if (allinfo->manifest_info->uiapplication) {
4688 LISTHEAD(allinfo->manifest_info->uiapplication, tmp2);
4689 allinfo->manifest_info->uiapplication = tmp2;
4691 /*Populate localized info for default locales and call callback*/
4692 /*If the callback func return < 0 we break and no more call back is called*/
4695 appinfo->locale = strdup(locale);
4696 appinfo->uiapp_info = tmp2;
4697 memset(query, '\0', MAX_QUERY_LEN);
4698 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
4699 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4700 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4702 memset(query, '\0', MAX_QUERY_LEN);
4703 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);
4704 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4705 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4707 /*store setting notification icon section*/
4708 memset(query, '\0', MAX_QUERY_LEN);
4709 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
4710 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4711 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
4713 /*store app preview image info*/
4714 memset(query, '\0', MAX_QUERY_LEN);
4715 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
4716 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4717 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
4719 if (appinfo->uiapp_info->label) {
4720 LISTHEAD(appinfo->uiapp_info->label, ptr2);
4721 appinfo->uiapp_info->label = ptr2;
4723 if (appinfo->uiapp_info->icon) {
4724 LISTHEAD(appinfo->uiapp_info->icon, ptr1);
4725 appinfo->uiapp_info->icon = ptr1;
4727 if (appinfo->uiapp_info->category) {
4728 LISTHEAD(appinfo->uiapp_info->category, ptr3);
4729 appinfo->uiapp_info->category = ptr3;
4731 if (appinfo->uiapp_info->metadata) {
4732 LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
4733 appinfo->uiapp_info->metadata = ptr4;
4735 if (appinfo->uiapp_info->permission) {
4736 LISTHEAD(appinfo->uiapp_info->permission, ptr5);
4737 appinfo->uiapp_info->permission = ptr5;
4739 if (appinfo->uiapp_info->image) {
4740 LISTHEAD(appinfo->uiapp_info->image, ptr6);
4741 appinfo->uiapp_info->image = ptr6;
4743 ret = app_func((void *)appinfo, user_data);
4750 appinfo->app_component = PMINFO_SVC_APP;
4751 serviceapplication_x *tmp3 = NULL;
4752 if (allinfo->manifest_info->serviceapplication) {
4753 LISTHEAD(allinfo->manifest_info->serviceapplication, tmp3);
4754 allinfo->manifest_info->serviceapplication = tmp3;
4756 /*Populate localized info for default locales and call callback*/
4757 /*If the callback func return < 0 we break and no more call back is called*/
4760 appinfo->locale = strdup(locale);
4761 appinfo->svcapp_info = tmp3;
4762 memset(query, '\0', MAX_QUERY_LEN);
4763 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
4764 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4765 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4767 memset(query, '\0', MAX_QUERY_LEN);
4768 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);
4769 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4770 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
4772 if (appinfo->svcapp_info->label) {
4773 LISTHEAD(appinfo->svcapp_info->label, ptr2);
4774 appinfo->svcapp_info->label = ptr2;
4776 if (appinfo->svcapp_info->icon) {
4777 LISTHEAD(appinfo->svcapp_info->icon, ptr1);
4778 appinfo->svcapp_info->icon = ptr1;
4780 if (appinfo->svcapp_info->category) {
4781 LISTHEAD(appinfo->svcapp_info->category, ptr3);
4782 appinfo->svcapp_info->category = ptr3;
4784 if (appinfo->svcapp_info->metadata) {
4785 LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
4786 appinfo->svcapp_info->metadata = ptr4;
4788 if (appinfo->svcapp_info->permission) {
4789 LISTHEAD(appinfo->svcapp_info->permission, ptr5);
4790 appinfo->svcapp_info->permission = ptr5;
4792 ret = app_func((void *)appinfo, user_data);
4797 appinfo->app_component = PMINFO_ALL_APP;
4813 if (appinfo->package) {
4814 free((void *)appinfo->package);
4815 appinfo->package = NULL;
4820 __cleanup_pkginfo(allinfo);
4822 __close_manifest_db();
4826 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
4827 pkgmgrinfo_app_list_cb app_func, void *user_data)
4829 return pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, GLOBAL_USER);
4832 API int pkgmgrinfo_appinfo_get_usr_install_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
4834 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4836 int ret = PMINFO_R_OK;
4837 char query[MAX_QUERY_LEN] = {'\0'};
4838 pkgmgr_appinfo_x *appinfo = NULL;
4839 uiapplication_x *ptr1 = NULL;
4840 serviceapplication_x *ptr2 = NULL;
4841 const char* user_pkg_parser = NULL;
4844 user_pkg_parser = getUserPkgParserDBPathUID(uid);
4845 ret = __open_manifest_db(uid);
4846 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
4849 pkgmgr_pkginfo_x *info = NULL;
4850 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4851 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4853 /*calloc manifest_info*/
4854 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4855 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4858 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4859 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4861 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4862 ret = __exec_db_query(GET_DB(manifest_db), query, __mini_appinfo_cb, (void *)info);
4863 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4865 if (info->manifest_info->uiapplication) {
4866 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4867 info->manifest_info->uiapplication = ptr1;
4869 if (info->manifest_info->serviceapplication) {
4870 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4871 info->manifest_info->serviceapplication = ptr2;
4875 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4877 appinfo->app_component = PMINFO_UI_APP;
4878 appinfo->package = strdup(ptr1->package);
4879 appinfo->uiapp_info = ptr1;
4881 ret = app_func((void *)appinfo, user_data);
4884 free((void *)appinfo->package);
4885 appinfo->package = NULL;
4888 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
4890 appinfo->app_component = PMINFO_SVC_APP;
4891 appinfo->package = strdup(ptr2->package);
4892 appinfo->svcapp_info = ptr2;
4894 ret = app_func((void *)appinfo, user_data);
4897 free((void *)appinfo->package);
4898 appinfo->package = NULL;
4903 __close_manifest_db();
4908 __cleanup_pkginfo(info);
4912 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
4914 return pkgmgrinfo_appinfo_get_usr_install_list(app_func, GLOBAL_USER, user_data);
4917 API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
4919 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
4921 int ret = PMINFO_R_OK;
4922 char query[MAX_QUERY_LEN] = {'\0'};
4923 char *syslocale = NULL;
4924 char *locale = NULL;
4925 pkgmgr_appinfo_x *appinfo = NULL;
4926 uiapplication_x *ptr1 = NULL;
4927 serviceapplication_x *ptr2 = NULL;
4928 label_x *tmp1 = NULL;
4929 icon_x *tmp2 = NULL;
4930 category_x *tmp3 = NULL;
4931 metadata_x *tmp4 = NULL;
4932 permission_x *tmp5 = NULL;
4933 image_x *tmp6 = NULL;
4934 const char *user_pkg_parser = NULL;
4936 /*get system locale*/
4937 syslocale = vconf_get_str(VCONFKEY_LANGSET);
4938 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
4940 /*get locale on db*/
4941 locale = __convert_system_locale_to_manifest_locale(syslocale);
4942 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
4945 user_pkg_parser = getUserPkgParserDBPathUID(uid);
4946 ret = __open_manifest_db(uid);
4947 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
4950 pkgmgr_pkginfo_x *info = NULL;
4951 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
4952 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4954 /*calloc manifest_info*/
4955 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
4956 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4959 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
4960 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
4962 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
4963 ret = __exec_db_query(GET_DB(manifest_db), query, __app_list_cb, (void *)info);
4964 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4966 if (info->manifest_info->uiapplication) {
4967 LISTHEAD(info->manifest_info->uiapplication, ptr1);
4968 info->manifest_info->uiapplication = ptr1;
4970 if (info->manifest_info->serviceapplication) {
4971 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
4972 info->manifest_info->serviceapplication = ptr2;
4976 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
4978 appinfo->locale = strdup(locale);
4979 appinfo->app_component = PMINFO_UI_APP;
4980 appinfo->package = strdup(ptr1->package);
4981 appinfo->uiapp_info = ptr1;
4982 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4983 "from package_app_info where " \
4984 "app_id='%s'", ptr1->appid);
4985 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
4986 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
4988 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
4992 locale = __get_app_locale_by_fallback(GET_DB(manifest_db), ptr1->appid, syslocale);
4995 memset(query, '\0', MAX_QUERY_LEN);
4996 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
4997 "from package_app_localized_info where " \
4998 "app_id='%s' and app_locale='%s'",
4999 ptr1->appid, locale);
5000 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5001 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
5003 memset(query, '\0', MAX_QUERY_LEN);
5004 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
5005 "from package_app_localized_info where " \
5006 "app_id='%s' and app_locale='%s'",
5007 ptr1->appid, DEFAULT_LOCALE);
5009 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5010 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
5012 /*store setting notification icon section*/
5013 memset(query, '\0', MAX_QUERY_LEN);
5014 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
5015 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5016 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
5018 /*store app preview image info*/
5019 memset(query, '\0', MAX_QUERY_LEN);
5020 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
5021 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5022 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
5024 if (appinfo->uiapp_info->label) {
5025 LISTHEAD(appinfo->uiapp_info->label, tmp1);
5026 appinfo->uiapp_info->label = tmp1;
5028 if (appinfo->uiapp_info->icon) {
5029 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
5030 appinfo->uiapp_info->icon= tmp2;
5032 if (appinfo->uiapp_info->category) {
5033 LISTHEAD(appinfo->uiapp_info->category, tmp3);
5034 appinfo->uiapp_info->category = tmp3;
5036 if (appinfo->uiapp_info->metadata) {
5037 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
5038 appinfo->uiapp_info->metadata = tmp4;
5040 if (appinfo->uiapp_info->permission) {
5041 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
5042 appinfo->uiapp_info->permission = tmp5;
5044 if (appinfo->uiapp_info->image) {
5045 LISTHEAD(appinfo->uiapp_info->image, tmp6);
5046 appinfo->uiapp_info->image = tmp6;
5048 ret = app_func((void *)appinfo, user_data);
5051 free((void *)appinfo->package);
5052 appinfo->package = NULL;
5055 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
5057 appinfo->locale = strdup(locale);
5058 appinfo->app_component = PMINFO_SVC_APP;
5059 appinfo->package = strdup(ptr2->package);
5060 appinfo->svcapp_info = ptr2;
5061 memset(query, '\0', MAX_QUERY_LEN);
5062 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
5063 "from package_app_info where " \
5064 "app_id='%s'", ptr2->appid);
5065 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5066 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
5068 memset(query, '\0', MAX_QUERY_LEN);
5069 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
5070 "from package_app_localized_info where " \
5071 "app_id='%s' and app_locale='%s'",
5072 ptr2->appid, locale);
5073 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5074 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
5076 memset(query, '\0', MAX_QUERY_LEN);
5077 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
5078 "from package_app_localized_info where " \
5079 "app_id='%s' and app_locale='%s'",
5080 ptr2->appid, DEFAULT_LOCALE);
5081 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5082 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
5084 if (appinfo->svcapp_info->label) {
5085 LISTHEAD(appinfo->svcapp_info->label, tmp1);
5086 appinfo->svcapp_info->label = tmp1;
5088 if (appinfo->svcapp_info->icon) {
5089 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
5090 appinfo->svcapp_info->icon= tmp2;
5092 if (appinfo->svcapp_info->category) {
5093 LISTHEAD(appinfo->svcapp_info->category, tmp3);
5094 appinfo->svcapp_info->category = tmp3;
5096 if (appinfo->svcapp_info->metadata) {
5097 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
5098 appinfo->svcapp_info->metadata = tmp4;
5100 if (appinfo->svcapp_info->permission) {
5101 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
5102 appinfo->svcapp_info->permission = tmp5;
5104 ret = app_func((void *)appinfo, user_data);
5107 free((void *)appinfo->package);
5108 appinfo->package = NULL;
5121 __close_manifest_db();
5126 __cleanup_pkginfo(info);
5130 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
5132 return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, GLOBAL_USER, user_data);
5135 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
5137 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
5138 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5140 pkgmgr_appinfo_x *appinfo = NULL;
5141 char *syslocale = NULL;
5142 char *locale = NULL;
5145 label_x *tmp1 = NULL;
5146 icon_x *tmp2 = NULL;
5147 category_x *tmp3 = NULL;
5148 metadata_x *tmp4 = NULL;
5149 permission_x *tmp5 = NULL;
5150 image_x *tmp6 = NULL;
5151 char query[MAX_QUERY_LEN] = {'\0'};
5152 const char* user_pkg_parser = NULL;
5157 user_pkg_parser = getUserPkgParserDBPathUID(uid);
5158 ret = __open_manifest_db(uid);
5159 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
5161 /*check appid exist on db*/
5162 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
5163 ret = __exec_db_query(GET_DB(manifest_db), query, __validate_cb, (void *)&exist);
5164 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
5165 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
5167 /*get system locale*/
5168 syslocale = vconf_get_str(VCONFKEY_LANGSET);
5169 tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
5171 /*get locale on db*/
5172 locale = __convert_system_locale_to_manifest_locale(syslocale);
5173 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
5176 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
5177 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
5179 /*check app_component from DB*/
5180 memset(query, '\0', MAX_QUERY_LEN);
5181 snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
5182 ret = __exec_db_query(GET_DB(manifest_db), query, __appcomponent_cb, (void *)appinfo);
5183 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
5185 /*calloc app_component*/
5186 if (appinfo->app_component == PMINFO_UI_APP) {
5187 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
5188 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
5190 appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
5191 tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
5193 appinfo->locale = strdup(locale);
5195 /*populate app_info from DB*/
5196 memset(query, '\0', MAX_QUERY_LEN);
5197 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
5198 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5199 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
5201 memset(query, '\0', MAX_QUERY_LEN);
5202 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
5203 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5204 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
5206 /*Also store the values corresponding to default locales*/
5207 memset(query, '\0', MAX_QUERY_LEN);
5208 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
5209 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5210 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
5212 /*Populate app category*/
5213 memset(query, '\0', MAX_QUERY_LEN);
5214 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
5215 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5216 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
5218 /*Populate app metadata*/
5219 memset(query, '\0', MAX_QUERY_LEN);
5220 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
5221 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5222 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
5224 /*Populate app permission*/
5225 memset(query, '\0', MAX_QUERY_LEN);
5226 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
5227 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5228 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
5230 /*store setting notification icon section*/
5231 memset(query, '\0', MAX_QUERY_LEN);
5232 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
5233 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5234 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
5236 /*store app preview image info*/
5237 memset(query, '\0', MAX_QUERY_LEN);
5238 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
5239 ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
5240 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
5242 switch (appinfo->app_component) {
5244 if (appinfo->uiapp_info->label) {
5245 LISTHEAD(appinfo->uiapp_info->label, tmp1);
5246 appinfo->uiapp_info->label = tmp1;
5248 if (appinfo->uiapp_info->icon) {
5249 LISTHEAD(appinfo->uiapp_info->icon, tmp2);
5250 appinfo->uiapp_info->icon = tmp2;
5252 if (appinfo->uiapp_info->category) {
5253 LISTHEAD(appinfo->uiapp_info->category, tmp3);
5254 appinfo->uiapp_info->category = tmp3;
5256 if (appinfo->uiapp_info->metadata) {
5257 LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
5258 appinfo->uiapp_info->metadata = tmp4;
5260 if (appinfo->uiapp_info->permission) {
5261 LISTHEAD(appinfo->uiapp_info->permission, tmp5);
5262 appinfo->uiapp_info->permission = tmp5;
5264 if (appinfo->uiapp_info->image) {
5265 LISTHEAD(appinfo->uiapp_info->image, tmp6);
5266 appinfo->uiapp_info->image = tmp6;
5269 case PMINFO_SVC_APP:
5270 if (appinfo->svcapp_info->label) {
5271 LISTHEAD(appinfo->svcapp_info->label, tmp1);
5272 appinfo->svcapp_info->label = tmp1;
5274 if (appinfo->svcapp_info->icon) {
5275 LISTHEAD(appinfo->svcapp_info->icon, tmp2);
5276 appinfo->svcapp_info->icon = tmp2;
5278 if (appinfo->svcapp_info->category) {
5279 LISTHEAD(appinfo->svcapp_info->category, tmp3);
5280 appinfo->svcapp_info->category = tmp3;
5282 if (appinfo->svcapp_info->metadata) {
5283 LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
5284 appinfo->svcapp_info->metadata = tmp4;
5286 if (appinfo->svcapp_info->permission) {
5287 LISTHEAD(appinfo->svcapp_info->permission, tmp5);
5288 appinfo->svcapp_info->permission = tmp5;
5298 if (ret == PMINFO_R_OK)
5299 *handle = (void*)appinfo;
5302 __cleanup_appinfo(appinfo);
5305 __close_manifest_db();
5317 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
5319 return pkgmgrinfo_appinfo_get_usr_appinfo(appid, GLOBAL_USER, handle);
5322 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
5324 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5325 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5326 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5328 if (info->app_component == PMINFO_UI_APP)
5329 *appid = (char *)info->uiapp_info->appid;
5330 else if (info->app_component == PMINFO_SVC_APP)
5331 *appid = (char *)info->svcapp_info->appid;
5336 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
5338 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5339 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5340 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5342 *pkg_name = (char *)info->package;
5347 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
5349 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5350 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5351 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5353 *pkgid = (char *)info->package;
5358 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
5360 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5361 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5362 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5364 if (info->app_component == PMINFO_UI_APP)
5365 *exec = (char *)info->uiapp_info->exec;
5366 if (info->app_component == PMINFO_SVC_APP)
5367 *exec = (char *)info->svcapp_info->exec;
5373 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
5375 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5376 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5377 char *locale = NULL;
5379 icon_x *start = NULL;
5382 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5383 locale = info->locale;
5384 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
5386 if (info->app_component == PMINFO_UI_APP)
5387 start = info->uiapp_info->icon;
5388 if (info->app_component == PMINFO_SVC_APP)
5389 start = info->svcapp_info->icon;
5390 for(ptr = start; ptr != NULL; ptr = ptr->next)
5393 if (strcmp(ptr->lang, locale) == 0) {
5394 *icon = (char *)ptr->text;
5395 if (strcasecmp(*icon, "(null)") == 0) {
5396 locale = DEFAULT_LOCALE;
5400 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
5401 *icon = (char *)ptr->text;
5410 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
5412 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5413 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5414 char *locale = NULL;
5415 label_x *ptr = NULL;
5416 label_x *start = NULL;
5419 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5420 locale = info->locale;
5421 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
5423 if (info->app_component == PMINFO_UI_APP)
5424 start = info->uiapp_info->label;
5425 if (info->app_component == PMINFO_SVC_APP)
5426 start = info->svcapp_info->label;
5427 for(ptr = start; ptr != NULL; ptr = ptr->next)
5430 if (strcmp(ptr->lang, locale) == 0) {
5431 *label = (char *)ptr->text;
5432 if (strcasecmp(*label, "(null)") == 0) {
5433 locale = DEFAULT_LOCALE;
5437 } else if (strncasecmp(ptr->lang, locale, 2) == 0) {
5438 *label = (char *)ptr->text;
5439 if (strcasecmp(*label, "(null)") == 0) {
5440 locale = DEFAULT_LOCALE;
5444 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
5445 *label = (char *)ptr->text;
5453 static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
5455 char *result = NULL;
5457 sqlite3_stmt *stmt = NULL;
5462 manifest_db = getUserPkgParserDBPathUID(uid);
5463 if (manifest_db == NULL) {
5464 _LOGE("Failed to get manifest db path");
5468 if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
5469 _LOGE("DB open fail\n");
5473 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
5474 if (query == NULL) {
5475 _LOGE("Out of memory");
5479 if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
5480 _LOGE("prepare_v2 fail\n");
5484 if (sqlite3_step(stmt) == SQLITE_ROW) {
5485 val = (char *)sqlite3_column_text(stmt, 0);
5487 result = strdup(val);
5491 sqlite3_finalize(stmt);
5492 sqlite3_free(query);
5498 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
5503 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
5505 val = _get_localed_label(appid, locale, uid);
5507 val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
5510 ret = PMINFO_R_ERROR;
5519 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
5521 return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, GLOBAL_USER, label);
5524 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
5526 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5527 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5528 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5530 if (info->app_component == PMINFO_UI_APP)
5531 *component = PMINFO_UI_APP;
5532 else if (info->app_component == PMINFO_SVC_APP)
5533 *component = PMINFO_SVC_APP;
5535 return PMINFO_R_ERROR;
5540 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
5542 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5543 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5544 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5546 if (info->app_component == PMINFO_UI_APP)
5547 *app_type = (char *)info->uiapp_info->type;
5548 if (info->app_component == PMINFO_SVC_APP)
5549 *app_type = (char *)info->svcapp_info->type;
5554 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
5555 int *operation_count, char ***operation)
5557 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5558 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5559 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5560 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
5561 *operation_count = data->operation_count;
5562 *operation = data->operation;
5566 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
5567 int *uri_count, char ***uri)
5569 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5570 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5571 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5572 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
5573 *uri_count = data->uri_count;
5578 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
5579 int *mime_count, char ***mime)
5581 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5582 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5583 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5584 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
5585 *mime_count = data->mime_count;
5590 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
5591 int *subapp_count, char ***subapp)
5593 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5594 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5595 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5596 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
5597 *subapp_count = data->subapp_count;
5598 *subapp = data->subapp;
5602 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
5604 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5605 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5609 icon_x *start = NULL;
5610 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5612 start = info->uiapp_info->icon;
5614 for(ptr = start; ptr != NULL; ptr = ptr->next)
5617 val = (char *)ptr->section;
5618 if (strcmp(val, "setting") == 0){
5619 *icon = (char *)ptr->text;
5628 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
5630 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5631 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5635 icon_x *start = NULL;
5636 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5638 start = info->uiapp_info->icon;
5640 for(ptr = start; ptr != NULL; ptr = ptr->next)
5643 val = (char *)ptr->section;
5645 if (strcmp(val, "notification") == 0){
5646 *icon = (char *)ptr->text;
5655 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
5657 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5658 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5660 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5661 val = (char *)info->uiapp_info->recentimage;
5663 if (strcasecmp(val, "capture") == 0)
5664 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
5665 else if (strcasecmp(val, "icon") == 0)
5666 *type = PMINFO_RECENTIMAGE_USE_ICON;
5668 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
5674 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
5676 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5677 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5680 image_x *ptr = NULL;
5681 image_x *start = NULL;
5682 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5684 start = info->uiapp_info->image;
5686 for(ptr = start; ptr != NULL; ptr = ptr->next)
5689 val = (char *)ptr->section;
5691 if (strcmp(val, "preview") == 0)
5692 *preview_img = (char *)ptr->text;
5700 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
5702 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5703 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5706 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5708 if (info->app_component == PMINFO_UI_APP)
5709 val = info->uiapp_info->permission_type;
5710 else if (info->app_component == PMINFO_SVC_APP)
5711 val = info->svcapp_info->permission_type;
5713 return PMINFO_R_ERROR;
5715 if (strcmp(val, "signature") == 0)
5716 *permission = PMINFO_PERMISSION_SIGNATURE;
5717 else if (strcmp(val, "privilege") == 0)
5718 *permission = PMINFO_PERMISSION_PRIVILEGE;
5720 *permission = PMINFO_PERMISSION_NORMAL;
5725 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
5727 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5728 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5729 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5731 *component_type = (char *)info->uiapp_info->component_type;
5736 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
5738 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5739 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5741 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5742 val = (char *)info->uiapp_info->hwacceleration;
5744 if (strcasecmp(val, "not-use-GL") == 0)
5745 *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
5746 else if (strcasecmp(val, "use-GL") == 0)
5747 *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
5749 *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
5754 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
5756 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5757 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5759 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5760 val = (char *)info->uiapp_info->screenreader;
5762 if (strcasecmp(val, "screenreader-off") == 0)
5763 *screenreader = PMINFO_SCREENREADER_OFF;
5764 else if (strcasecmp(val, "screenreader-on") == 0)
5765 *screenreader = PMINFO_SCREENREADER_ON;
5767 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
5772 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
5774 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5775 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5776 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5777 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5779 if (info->app_component == PMINFO_UI_APP){
5780 *portrait_img = (char *)info->uiapp_info->portraitimg;
5781 *landscape_img = (char *)info->uiapp_info->landscapeimg;
5787 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
5789 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
5790 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
5791 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5793 *submode_mainid = (char *)info->uiapp_info->submode_mainid;
5798 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
5800 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
5801 retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5802 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
5803 if (info->uiapp_info->launch_mode)
5804 *mode = (char *)(info->uiapp_info->launch_mode);
5806 return PMINFO_R_ERROR;
5811 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
5813 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5814 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5815 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5816 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5818 int ret = PMINFO_R_OK;
5820 sqlite3_stmt *stmt = NULL;
5823 ret = __open_manifest_db(uid);
5824 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
5826 /*Start constructing query*/
5827 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
5830 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
5831 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
5834 ret = sqlite3_step(stmt);
5835 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
5837 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
5838 *access = strdup((char *)sqlite3_column_text(stmt, 2));
5843 sqlite3_free(query);
5844 sqlite3_finalize(stmt);
5845 __close_manifest_db();
5849 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
5851 return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, GLOBAL_USER, appid, access);
5854 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
5856 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
5857 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
5859 int ret = PMINFO_R_OK;
5861 sqlite3_stmt *stmt = NULL;
5864 ret = __open_manifest_db(uid);
5865 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
5867 /*Start constructing query*/
5868 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
5871 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
5872 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
5875 ret = sqlite3_step(stmt);
5876 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
5878 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
5883 sqlite3_free(query);
5884 sqlite3_finalize(stmt);
5885 __close_manifest_db();
5889 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
5891 return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
5894 #define OPERATION_LAUNCH_ON_EVENT "http://tizen.org/appcontrol/operation/launch_on_event"
5896 API int pkgmgrinfo_appinfo_get_event_launch_list(GList **es_info)
5898 pkgmgrinfo_appinfo_get_usr_event_launch_list(es_info, GLOBAL_USER);
5901 API int pkgmgrinfo_appinfo_get_usr_event_launch_list(GList **es_info, uid_t uid)
5903 int ret = PMINFO_R_OK;
5905 sqlite3_stmt *stmt = NULL;
5906 const char* user_pkg_parser = NULL;
5909 user_pkg_parser = getUserPkgParserDBPathUID(uid);
5910 ret = __open_manifest_db(uid);
5911 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR,
5912 "connect db [%s] failed!", user_pkg_parser);
5914 /*Start constructing query*/
5915 query = sqlite3_mprintf("select * from package_app_app_control");
5918 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
5919 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR,
5920 "sqlite3_prepare_v2 failed[%s] : %s\n", query, sqlite3_errmsg(GET_DB(manifest_db)));
5923 while (sqlite3_step(stmt) == SQLITE_ROW) {
5925 app_ctrl = (char *)sqlite3_column_text(stmt, 1);
5926 if (app_ctrl == NULL) {
5931 int len_acv, cnt_acv;
5932 appctrlv = g_strsplit(app_ctrl, ";", 0);
5933 for (len_acv = 0; appctrlv[len_acv] != NULL; len_acv++);
5934 for (cnt_acv = 0; cnt_acv < len_acv; cnt_acv++) {
5935 if (strncmp(OPERATION_LAUNCH_ON_EVENT,
5936 (char *)appctrlv[cnt_acv],
5937 strlen(OPERATION_LAUNCH_ON_EVENT)) != 0) {
5941 gchar **launch_onevt;
5943 launch_onevt = g_strsplit(appctrlv[cnt_acv], "|", 3);
5944 for (len_lo = 0; launch_onevt[len_lo] != NULL; len_lo++);
5945 if (len_lo > 2 && g_str_has_prefix(launch_onevt[1], "event://") &&
5946 strlen(launch_onevt[1]) > 8) {
5947 eventsystem_info_s *esi =
5948 (eventsystem_info_s *)calloc(1,
5949 sizeof(eventsystem_info_s));
5951 strdup((const char *)sqlite3_column_text(stmt, 0));
5952 esi->event_name = strdup((const char*)&launch_onevt[1][8]);
5953 *es_info = g_list_append(*es_info, esi);
5955 g_strfreev(launch_onevt);
5957 g_strfreev(appctrlv);
5962 sqlite3_free(query);
5963 sqlite3_finalize(stmt);
5964 __close_manifest_db();
5968 API int pkgmgrinfo_appinfo_get_event_launch_list_by_appid(const char *appid, GList **es_info)
5970 pkgmgrinfo_appinfo_get_usr_event_launch_list_by_appid(appid,
5971 es_info, GLOBAL_USER);
5974 API int pkgmgrinfo_appinfo_get_usr_event_launch_list_by_appid(const char *appid, GList **es_info, uid_t uid)
5976 int ret = PMINFO_R_OK;
5978 sqlite3_stmt *stmt = NULL;
5979 const char* user_pkg_parser = NULL;
5982 user_pkg_parser = getUserPkgParserDBPathUID(uid);
5983 ret = __open_manifest_db(uid);
5984 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR,
5985 "connect db [%s] failed!", user_pkg_parser);
5987 /*Start constructing query*/
5988 query = sqlite3_mprintf("select * from package_app_app_control where app_id=%Q",
5992 ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
5993 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR,
5994 "sqlite3_prepare_v2 failed[%s] : %s\n", query, sqlite3_errmsg(GET_DB(manifest_db)));
5997 while (sqlite3_step(stmt) == SQLITE_ROW) {
5999 app_ctrl = (char *)sqlite3_column_text(stmt, 1);
6000 if (app_ctrl == NULL) {
6005 int len_acv, cnt_acv;
6006 appctrlv = g_strsplit(app_ctrl, ";", 0);
6007 for (len_acv = 0; appctrlv[len_acv] != NULL; len_acv++);
6008 for (cnt_acv = 0; cnt_acv < len_acv; cnt_acv++) {
6009 if (strncmp(OPERATION_LAUNCH_ON_EVENT,
6010 (char *)appctrlv[cnt_acv],
6011 strlen(OPERATION_LAUNCH_ON_EVENT)) != 0) {
6015 gchar **launch_onevt;
6017 launch_onevt = g_strsplit(appctrlv[cnt_acv], "|", 3);
6018 for (len_lo = 0; launch_onevt[len_lo] != NULL; len_lo++);
6019 if (len_lo > 2 && g_str_has_prefix(launch_onevt[1], "event://") &&
6020 strlen(launch_onevt[1]) > 8) {
6021 eventsystem_info_s *esi =
6022 (eventsystem_info_s *)calloc(1,
6023 sizeof(eventsystem_info_s));
6024 esi->appid = strdup(appid);
6025 esi->event_name = strdup((const char*)&launch_onevt[1][8]);
6026 *es_info = g_list_append(*es_info, esi);
6028 g_strfreev(launch_onevt);
6030 g_strfreev(appctrlv);
6035 sqlite3_free(query);
6036 sqlite3_finalize(stmt);
6037 __close_manifest_db();
6041 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
6042 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
6044 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6045 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
6047 permission_x *ptr = NULL;
6048 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6049 if (info->app_component == PMINFO_UI_APP)
6050 ptr = info->uiapp_info->permission;
6051 else if (info->app_component == PMINFO_SVC_APP)
6052 ptr = info->svcapp_info->permission;
6054 return PMINFO_R_EINVAL;
6055 for (; ptr; ptr = ptr->next) {
6057 ret = permission_func(ptr->value, user_data);
6065 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
6066 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
6068 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6069 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
6071 category_x *ptr = NULL;
6072 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6073 if (info->app_component == PMINFO_UI_APP)
6074 ptr = info->uiapp_info->category;
6075 else if (info->app_component == PMINFO_SVC_APP)
6076 ptr = info->svcapp_info->category;
6078 return PMINFO_R_EINVAL;
6079 for (; ptr; ptr = ptr->next) {
6081 ret = category_func(ptr->name, user_data);
6089 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
6090 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
6092 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6093 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
6095 metadata_x *ptr = NULL;
6096 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6097 if (info->app_component == PMINFO_UI_APP)
6098 ptr = info->uiapp_info->metadata;
6099 else if (info->app_component == PMINFO_SVC_APP)
6100 ptr = info->svcapp_info->metadata;
6102 return PMINFO_R_EINVAL;
6103 for (; ptr; ptr = ptr->next) {
6105 ret = metadata_func(ptr->key, ptr->value, user_data);
6113 API int pkgmgrinfo_usr_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
6114 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data, uid_t uid)
6116 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6117 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
6125 char *manifest = NULL;
6126 char **operation = NULL;
6129 char **subapp = NULL;
6130 appcontrol_x *appcontrol = NULL;
6131 manifest_x *mfx = NULL;
6132 operation_x *op = NULL;
6135 subapp_x *sa = NULL;
6136 pkgmgrinfo_app_component component;
6137 pkgmgrinfo_appcontrol_x *ptr = NULL;
6138 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
6140 _LOGE("Failed to get package name\n");
6141 return PMINFO_R_ERROR;
6143 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
6145 _LOGE("Failed to get app component name\n");
6146 return PMINFO_R_ERROR;
6148 manifest = pkgmgr_parser_get_usr_manifest_file(pkgid, uid);
6149 if (manifest == NULL) {
6150 _LOGE("Failed to fetch package manifest file\n");
6151 return PMINFO_R_ERROR;
6153 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
6155 _LOGE("Failed to parse package manifest file\n");
6158 return PMINFO_R_ERROR;
6161 ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
6163 _LOGE("Out of Memory!!!\n");
6164 pkgmgr_parser_free_manifest_xml(mfx);
6165 return PMINFO_R_ERROR;
6167 /*Get Operation, Uri, Mime*/
6168 switch (component) {
6170 if (mfx->uiapplication) {
6171 if (mfx->uiapplication->appsvc) {
6172 appcontrol = mfx->uiapplication->appsvc;
6176 case PMINFO_SVC_APP:
6177 if (mfx->serviceapplication) {
6178 if (mfx->serviceapplication->appsvc) {
6179 appcontrol = mfx->serviceapplication->appsvc;
6186 for (; appcontrol; appcontrol = appcontrol->next) {
6187 op = appcontrol->operation;
6188 for (; op; op = op->next)
6190 op = appcontrol->operation;
6192 ui = appcontrol->uri;
6193 for (; ui; ui = ui->next)
6195 ui = appcontrol->uri;
6197 mi = appcontrol->mime;
6198 for (; mi; mi = mi->next)
6200 mi = appcontrol->mime;
6202 sa = appcontrol->subapp;
6203 for (; sa; sa = sa->next)
6205 sa = appcontrol->subapp;
6207 operation = (char **)calloc(oc, sizeof(char *));
6208 for (i = 0; i < oc; i++) {
6209 operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
6213 uri = (char **)calloc(uc, sizeof(char *));
6214 for (i = 0; i < uc; i++) {
6215 uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
6219 mime = (char **)calloc(mc, sizeof(char *));
6220 for (i = 0; i < mc; i++) {
6221 mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
6225 subapp = (char **)calloc(sc, sizeof(char *));
6226 for (i = 0; i < sc; i++) {
6227 subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
6231 /*populate appcontrol handle*/
6232 ptr->operation_count = oc;
6233 ptr->uri_count = uc;
6234 ptr->mime_count = mc;
6235 ptr->subapp_count = sc;
6236 ptr->operation = operation;
6239 ptr->subapp = subapp;
6241 ret = appcontrol_func((void *)ptr, user_data);
6242 for (i = 0; i < oc; i++) {
6245 operation[i] = NULL;
6252 for (i = 0; i < uc; i++) {
6262 for (i = 0; i < mc; i++) {
6272 for (i = 0; i < sc; i++) {
6289 pkgmgr_parser_free_manifest_xml(mfx);
6297 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
6298 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
6300 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6301 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
6309 char *manifest = NULL;
6310 char **operation = NULL;
6313 char **subapp = NULL;
6314 appcontrol_x *appcontrol = NULL;
6315 manifest_x *mfx = NULL;
6316 operation_x *op = NULL;
6319 subapp_x *sa = NULL;
6320 pkgmgrinfo_app_component component;
6321 pkgmgrinfo_appcontrol_x *ptr = NULL;
6322 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
6324 _LOGE("Failed to get package name\n");
6325 return PMINFO_R_ERROR;
6327 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
6329 _LOGE("Failed to get app component name\n");
6330 return PMINFO_R_ERROR;
6332 manifest = pkgmgr_parser_get_manifest_file(pkgid);
6333 if (manifest == NULL) {
6334 _LOGE("Failed to fetch package manifest file\n");
6335 return PMINFO_R_ERROR;
6337 mfx = pkgmgr_parser_process_manifest_xml(manifest);
6339 _LOGE("Failed to parse package manifest file\n");
6342 return PMINFO_R_ERROR;
6345 ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
6347 _LOGE("Out of Memory!!!\n");
6348 pkgmgr_parser_free_manifest_xml(mfx);
6349 return PMINFO_R_ERROR;
6351 /*Get Operation, Uri, Mime*/
6352 switch (component) {
6354 if (mfx->uiapplication) {
6355 if (mfx->uiapplication->appsvc) {
6356 appcontrol = mfx->uiapplication->appsvc;
6360 case PMINFO_SVC_APP:
6361 if (mfx->serviceapplication) {
6362 if (mfx->serviceapplication->appsvc) {
6363 appcontrol = mfx->serviceapplication->appsvc;
6370 for (; appcontrol; appcontrol = appcontrol->next) {
6371 op = appcontrol->operation;
6372 for (; op; op = op->next)
6374 op = appcontrol->operation;
6376 ui = appcontrol->uri;
6377 for (; ui; ui = ui->next)
6379 ui = appcontrol->uri;
6381 mi = appcontrol->mime;
6382 for (; mi; mi = mi->next)
6384 mi = appcontrol->mime;
6386 sa = appcontrol->subapp;
6387 for (; sa; sa = sa->next)
6389 sa = appcontrol->subapp;
6391 operation = (char **)calloc(oc, sizeof(char *));
6392 for (i = 0; i < oc; i++) {
6393 operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
6397 uri = (char **)calloc(uc, sizeof(char *));
6398 for (i = 0; i < uc; i++) {
6399 uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
6403 mime = (char **)calloc(mc, sizeof(char *));
6404 for (i = 0; i < mc; i++) {
6405 mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
6409 subapp = (char **)calloc(sc, sizeof(char *));
6410 for (i = 0; i < sc; i++) {
6411 subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
6415 /*populate appcontrol handle*/
6416 ptr->operation_count = oc;
6417 ptr->uri_count = uc;
6418 ptr->mime_count = mc;
6419 ptr->subapp_count = sc;
6420 ptr->operation = operation;
6423 ptr->subapp = subapp;
6425 ret = appcontrol_func((void *)ptr, user_data);
6426 for (i = 0; i < oc; i++) {
6429 operation[i] = NULL;
6436 for (i = 0; i < uc; i++) {
6446 for (i = 0; i < mc; i++) {
6456 for (i = 0; i < sc; i++) {
6473 pkgmgr_parser_free_manifest_xml(mfx);
6481 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
6483 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6484 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
6486 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6487 val = (char *)info->uiapp_info->nodisplay;
6489 if (strcasecmp(val, "true") == 0)
6491 else if (strcasecmp(val, "false") == 0)
6499 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
6501 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6502 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
6504 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6505 val = (char *)info->uiapp_info->multiple;
6507 if (strcasecmp(val, "true") == 0)
6509 else if (strcasecmp(val, "false") == 0)
6517 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
6519 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6520 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
6522 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6523 val = (char *)info->uiapp_info->indicatordisplay;
6525 if (strcasecmp(val, "true") == 0){
6526 *indicator_disp = 1;
6527 }else if (strcasecmp(val, "false") == 0){
6528 *indicator_disp = 0;
6530 *indicator_disp = 0;
6536 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
6538 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6539 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
6541 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6542 val = (char *)info->uiapp_info->taskmanage;
6544 if (strcasecmp(val, "true") == 0)
6546 else if (strcasecmp(val, "false") == 0)
6554 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
6556 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6557 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
6559 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6560 if (info->app_component == PMINFO_UI_APP)
6561 val = (char *)info->uiapp_info->enabled;
6562 else if (info->app_component == PMINFO_SVC_APP)
6563 val = (char *)info->uiapp_info->enabled;
6565 _LOGE("invalid component type\n");
6566 return PMINFO_R_EINVAL;
6570 if (strcasecmp(val, "true") == 0)
6572 else if (strcasecmp(val, "false") == 0)
6581 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
6583 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6584 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
6586 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6587 val = (char *)info->svcapp_info->onboot;
6589 if (strcasecmp(val, "true") == 0)
6591 else if (strcasecmp(val, "false") == 0)
6599 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
6601 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6602 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
6604 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6605 val = (char *)info->svcapp_info->autorestart;
6607 if (strcasecmp(val, "true") == 0)
6609 else if (strcasecmp(val, "false") == 0)
6617 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
6619 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6620 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
6622 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6623 val = (char *)info->uiapp_info->mainapp;
6625 if (strcasecmp(val, "true") == 0)
6627 else if (strcasecmp(val, "false") == 0)
6635 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
6637 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6638 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6640 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6641 val = (char *)info->uiapp_info->preload;
6643 if (strcasecmp(val, "true") == 0)
6645 else if (strcasecmp(val, "false") == 0)
6653 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
6655 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
6656 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
6658 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6659 val = (char *)info->uiapp_info->submode;
6661 if (strcasecmp(val, "true") == 0)
6663 else if (strcasecmp(val, "false") == 0)
6671 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
6673 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6674 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
6675 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
6677 category_x *ptr = NULL;
6678 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6682 ptr = info->uiapp_info->category;
6684 for (; ptr; ptr = ptr->next) {
6686 if (strcasecmp(ptr->name, category) == 0)
6697 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
6699 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
6700 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
6701 __cleanup_appinfo(info);
6705 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
6707 return (pkgmgrinfo_pkginfo_filter_create(handle));
6710 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
6712 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
6715 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
6716 const char *property, const int value)
6718 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
6719 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
6720 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
6722 GSList *link = NULL;
6724 prop = _pminfo_appinfo_convert_to_prop_int(property);
6725 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
6726 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
6727 _LOGE("Invalid Integer Property\n");
6728 return PMINFO_R_EINVAL;
6730 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
6731 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
6733 _LOGE("Out of Memory!!!\n");
6734 return PMINFO_R_ERROR;
6736 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
6737 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
6739 _LOGE("Out of Memory\n");
6742 return PMINFO_R_ERROR;
6746 /*If API is called multiple times for same property, we should override the previous values.
6747 Last value set will be used for filtering.*/
6748 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
6750 filter->list = g_slist_delete_link(filter->list, link);
6751 filter->list = g_slist_append(filter->list, (gpointer)node);
6756 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
6757 const char *property, const bool value)
6759 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
6760 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
6762 GSList *link = NULL;
6764 prop = _pminfo_appinfo_convert_to_prop_bool(property);
6765 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
6766 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
6767 _LOGE("Invalid Boolean Property\n");
6768 return PMINFO_R_EINVAL;
6770 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
6771 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
6773 _LOGE("Out of Memory!!!\n");
6774 return PMINFO_R_ERROR;
6777 val = strndup("('true','True')", 15);
6779 val = strndup("('false','False')", 17);
6781 _LOGE("Out of Memory\n");
6784 return PMINFO_R_ERROR;
6788 /*If API is called multiple times for same property, we should override the previous values.
6789 Last value set will be used for filtering.*/
6790 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
6792 filter->list = g_slist_delete_link(filter->list, link);
6793 filter->list = g_slist_append(filter->list, (gpointer)node);
6798 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
6799 const char *property, const char *value)
6801 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
6802 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
6803 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
6805 pkgmgrinfo_node_x *ptr = NULL;
6806 char prev[PKG_STRING_LEN_MAX] = {'\0'};
6807 char temp[PKG_STRING_LEN_MAX] = {'\0'};
6808 GSList *link = NULL;
6810 prop = _pminfo_appinfo_convert_to_prop_str(property);
6811 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
6812 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
6813 _LOGE("Invalid String Property\n");
6814 return PMINFO_R_EINVAL;
6816 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
6817 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
6819 _LOGE("Out of Memory!!!\n");
6820 return PMINFO_R_ERROR;
6824 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
6825 if (strcmp(value, PMINFO_APPINFO_UI_APP) == 0)
6826 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
6828 val = strndup("svcapp", PKG_STRING_LEN_MAX - 1);
6830 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
6832 filter->list = g_slist_delete_link(filter->list, link);
6833 filter->list = g_slist_append(filter->list, (gpointer)node);
6835 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
6836 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
6837 case E_PMINFO_APPINFO_PROP_APP_URI:
6838 case E_PMINFO_APPINFO_PROP_APP_MIME:
6839 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
6841 _LOGE("Out of Memory\n");
6844 return PMINFO_R_ERROR;
6846 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
6848 ptr = (pkgmgrinfo_node_x *)link->data;
6849 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
6850 _LOGE("Previous value is %s\n", prev);
6851 filter->list = g_slist_delete_link(filter->list, link);
6852 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
6853 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
6854 _LOGE("New value is %s\n", val);
6856 filter->list = g_slist_append(filter->list, (gpointer)node);
6857 memset(temp, '\0', PKG_STRING_LEN_MAX);
6859 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
6860 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
6861 _LOGE("First value is %s\n", val);
6863 filter->list = g_slist_append(filter->list, (gpointer)node);
6864 memset(temp, '\0', PKG_STRING_LEN_MAX);
6868 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
6869 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
6871 filter->list = g_slist_delete_link(filter->list, link);
6872 filter->list = g_slist_append(filter->list, (gpointer)node);
6878 API int pkgmgrinfo_appinfo_usr_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
6880 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
6881 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
6882 char *syslocale = NULL;
6883 char *locale = NULL;
6884 char *condition = NULL;
6885 char *error_message = NULL;
6886 char query[MAX_QUERY_LEN] = {'\0'};
6887 char where[MAX_QUERY_LEN] = {'\0'};
6891 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
6892 /*Get current locale*/
6893 syslocale = vconf_get_str(VCONFKEY_LANGSET);
6894 if (syslocale == NULL) {
6895 _LOGE("current locale is NULL\n");
6896 return PMINFO_R_ERROR;
6898 locale = __convert_system_locale_to_manifest_locale(syslocale);
6899 if (locale == NULL) {
6900 _LOGE("manifest locale is NULL\n");
6902 return PMINFO_R_ERROR;
6905 ret = __open_manifest_db(uid);
6907 _LOGE("Fail to open manifest DB\n");
6910 return PMINFO_R_ERROR;
6913 /*Start constructing query*/
6914 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_APP, locale);
6916 /*Get where clause*/
6917 for (list = filter->list; list; list = g_slist_next(list)) {
6918 __get_filter_condition(list->data, &condition);
6920 strncat(where, condition, sizeof(where) - strlen(where) -1);
6921 where[sizeof(where) - 1] = '\0';
6925 if (g_slist_next(list)) {
6926 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
6927 where[sizeof(where) - 1] = '\0';
6930 _LOGE("where = %s\n", where);
6931 if (strlen(where) > 0) {
6932 strncat(query, where, sizeof(query) - strlen(query) - 1);
6933 query[sizeof(query) - 1] = '\0';
6935 _LOGE("query = %s\n", query);
6939 sqlite3_exec(GET_DB(manifest_db), query, __count_cb, (void *)count, &error_message)) {
6940 _LOGE("Don't execute query = %s error message = %s\n", query,
6942 sqlite3_free(error_message);
6943 ret = PMINFO_R_ERROR;
6957 __close_manifest_db();
6961 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
6963 return pkgmgrinfo_appinfo_usr_filter_count(handle, count, GLOBAL_USER);
6966 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
6967 pkgmgrinfo_app_list_cb app_cb, void * user_data, uid_t uid)
6969 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
6970 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
6971 char *syslocale = NULL;
6972 char *locale = NULL;
6973 char *condition = NULL;
6974 char *error_message = NULL;
6975 char query[MAX_QUERY_LEN] = {'\0'};
6976 char where[MAX_QUERY_LEN] = {'\0'};
6979 uiapplication_x *ptr1 = NULL;
6980 serviceapplication_x *ptr2 = NULL;
6981 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
6982 /*Get current locale*/
6983 syslocale = vconf_get_str(VCONFKEY_LANGSET);
6984 if (syslocale == NULL) {
6985 _LOGE("current locale is NULL\n");
6986 return PMINFO_R_ERROR;
6988 locale = __convert_system_locale_to_manifest_locale(syslocale);
6989 if (locale == NULL) {
6990 _LOGE("manifest locale is NULL\n");
6992 return PMINFO_R_ERROR;
6995 ret = __open_manifest_db(uid);
6997 _LOGE("Fail to open manifest DB\n");
7000 return PMINFO_R_ERROR;
7002 /*Start constructing query*/
7003 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale);
7004 /*Get where clause*/
7005 for (list = filter->list; list; list = g_slist_next(list)) {
7006 __get_filter_condition(list->data, &condition);
7008 strncat(where, condition, sizeof(where) - strlen(where) -1);
7009 where[sizeof(where) - 1] = '\0';
7013 if (g_slist_next(list)) {
7014 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
7015 where[sizeof(where) - 1] = '\0';
7018 _LOGE("where = %s\n", where);
7019 if (strlen(where) > 0) {
7020 strncat(query, where, sizeof(query) - strlen(query) - 1);
7021 query[sizeof(query) - 1] = '\0';
7023 _LOGE("query = %s\n", query);
7024 /*To get filtered list*/
7025 pkgmgr_pkginfo_x *info = NULL;
7026 pkgmgr_pkginfo_x *filtinfo = NULL;
7027 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
7029 _LOGE("Out of Memory!!!\n");
7030 ret = PMINFO_R_ERROR;
7033 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
7034 if (info->manifest_info == NULL) {
7035 _LOGE("Out of Memory!!!\n");
7036 ret = PMINFO_R_ERROR;
7039 /*To get detail app info for each member of filtered list*/
7040 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
7041 if (filtinfo == NULL) {
7042 _LOGE("Out of Memory!!!\n");
7043 ret = PMINFO_R_ERROR;
7046 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
7047 if (filtinfo->manifest_info == NULL) {
7048 _LOGE("Out of Memory!!!\n");
7049 ret = PMINFO_R_ERROR;
7052 pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
7053 if (appinfo == NULL) {
7054 _LOGE("Out of Memory!!!\n");
7055 ret = PMINFO_R_ERROR;
7059 sqlite3_exec(GET_DB(manifest_db), query, __app_list_cb, (void *)info, &error_message)) {
7060 _LOGE("Don't execute query = %s error message = %s\n", query,
7062 sqlite3_free(error_message);
7063 ret = PMINFO_R_ERROR;
7066 memset(query, '\0', MAX_QUERY_LEN);
7067 if (info->manifest_info->uiapplication) {
7068 LISTHEAD(info->manifest_info->uiapplication, ptr1);
7069 info->manifest_info->uiapplication = ptr1;
7071 if (info->manifest_info->serviceapplication) {
7072 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
7073 info->manifest_info->serviceapplication = ptr2;
7075 /*Filtered UI Apps*/
7076 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
7078 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
7079 ptr1->appid, "uiapp");
7081 sqlite3_exec(GET_DB(manifest_db), query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
7082 _LOGE("Don't execute query = %s error message = %s\n", query,
7084 sqlite3_free(error_message);
7085 ret = PMINFO_R_ERROR;
7089 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
7091 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
7092 ptr2->appid, "svcapp");
7094 sqlite3_exec(GET_DB(manifest_db), query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
7095 _LOGE("Don't execute query = %s error message = %s\n", query,
7097 sqlite3_free(error_message);
7098 ret = PMINFO_R_ERROR;
7102 if (filtinfo->manifest_info->uiapplication) {
7103 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
7104 filtinfo->manifest_info->uiapplication = ptr1;
7106 /*If the callback func return < 0 we break and no more call back is called*/
7109 appinfo->locale = strdup(locale);
7110 appinfo->uiapp_info = ptr1;
7111 appinfo->app_component = PMINFO_UI_APP;
7112 ret = app_cb((void *)appinfo, user_data);
7117 /*Filtered Service Apps*/
7118 if (filtinfo->manifest_info->serviceapplication) {
7119 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
7120 filtinfo->manifest_info->serviceapplication = ptr2;
7122 /*If the callback func return < 0 we break and no more call back is called*/
7125 appinfo->locale = strdup(locale);
7126 appinfo->svcapp_info = ptr2;
7127 appinfo->app_component = PMINFO_SVC_APP;
7128 ret = app_cb((void *)appinfo, user_data);
7143 __close_manifest_db();
7148 __cleanup_pkginfo(info);
7149 __cleanup_pkginfo(filtinfo);
7153 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
7154 pkgmgrinfo_app_list_cb app_cb, void * user_data)
7156 return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle, app_cb, user_data, GLOBAL_USER);
7159 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
7161 return (pkgmgrinfo_pkginfo_filter_create(handle));
7164 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
7166 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
7169 API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
7170 const char *key, const char *value)
7172 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
7173 retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
7174 /*value can be NULL. In that case all apps with specified key should be displayed*/
7178 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
7179 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
7180 retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
7182 tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
7186 tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
7189 /*If API is called multiple times, we should OR all conditions.*/
7190 filter->list = g_slist_append(filter->list, (gpointer)node);
7191 /*All memory will be freed in destroy API*/
7209 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
7210 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
7212 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
7213 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
7214 char *syslocale = NULL;
7215 char *locale = NULL;
7216 char *condition = NULL;
7217 char *error_message = NULL;
7218 char query[MAX_QUERY_LEN] = {'\0'};
7219 char where[MAX_QUERY_LEN] = {'\0'};
7222 pkgmgr_pkginfo_x *info = NULL;
7223 pkgmgr_pkginfo_x *filtinfo = NULL;
7224 pkgmgr_appinfo_x *appinfo = NULL;
7225 uiapplication_x *ptr1 = NULL;
7226 serviceapplication_x *ptr2 = NULL;
7227 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
7229 /*Get current locale*/
7230 syslocale = vconf_get_str(VCONFKEY_LANGSET);
7231 retvm_if(syslocale == NULL, PMINFO_R_ERROR, "current locale is NULL\n");
7232 locale = __convert_system_locale_to_manifest_locale(syslocale);
7233 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
7235 ret = __open_manifest_db(uid);
7237 _LOGE("Fail to open manifest DB\n");
7240 return PMINFO_R_ERROR;
7242 /*Start constructing query*/
7243 memset(where, '\0', MAX_QUERY_LEN);
7244 memset(query, '\0', MAX_QUERY_LEN);
7245 snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
7246 /*Get where clause*/
7247 for (list = filter->list; list; list = g_slist_next(list)) {
7248 __get_metadata_filter_condition(list->data, &condition);
7250 strncat(where, condition, sizeof(where) - strlen(where) -1);
7254 if (g_slist_next(list)) {
7255 strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
7258 _LOGE("where = %s (%d)\n", where, strlen(where));
7259 if (strlen(where) > 0) {
7260 strncat(query, where, sizeof(query) - strlen(query) - 1);
7262 _LOGE("query = %s (%d)\n", query, strlen(query));
7263 /*To get filtered list*/
7264 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
7265 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
7267 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
7268 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
7270 /*To get detail app info for each member of filtered list*/
7271 filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
7272 tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
7274 filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
7275 tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
7277 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
7278 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
7280 ret = sqlite3_exec(GET_DB(manifest_db), query, __app_list_cb, (void *)info, &error_message);
7281 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
7282 memset(query, '\0', MAX_QUERY_LEN);
7284 if (info->manifest_info->uiapplication) {
7285 LISTHEAD(info->manifest_info->uiapplication, ptr1);
7286 info->manifest_info->uiapplication = ptr1;
7288 if (info->manifest_info->serviceapplication) {
7289 LISTHEAD(info->manifest_info->serviceapplication, ptr2);
7290 info->manifest_info->serviceapplication = ptr2;
7294 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
7296 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
7297 ptr1->appid, "uiapp");
7298 ret = sqlite3_exec(GET_DB(manifest_db), query, __uiapp_list_cb, (void *)filtinfo, &error_message);
7299 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
7300 memset(query, '\0', MAX_QUERY_LEN);
7303 for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
7305 snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
7306 ptr2->appid, "svcapp");
7307 ret = sqlite3_exec(GET_DB(manifest_db), query, __svcapp_list_cb, (void *)filtinfo, &error_message);
7308 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
7309 memset(query, '\0', MAX_QUERY_LEN);
7311 /*Filtered UI Apps*/
7312 if (filtinfo->manifest_info->uiapplication) {
7313 LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
7314 filtinfo->manifest_info->uiapplication = ptr1;
7316 /*If the callback func return < 0 we break and no more call back is called*/
7319 appinfo->locale = strdup(locale);
7320 appinfo->uiapp_info = ptr1;
7321 appinfo->app_component = PMINFO_UI_APP;
7322 ret = app_cb((void *)appinfo, user_data);
7327 /*Filtered Service Apps*/
7328 if (filtinfo->manifest_info->serviceapplication) {
7329 LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
7330 filtinfo->manifest_info->serviceapplication = ptr2;
7332 /*If the callback func return < 0 we break and no more call back is called*/
7335 appinfo->locale = strdup(locale);
7336 appinfo->svcapp_info = ptr2;
7337 appinfo->app_component = PMINFO_SVC_APP;
7338 ret = app_cb((void *)appinfo, user_data);
7353 sqlite3_free(error_message);
7354 __close_manifest_db();
7359 __cleanup_pkginfo(info);
7360 __cleanup_pkginfo(filtinfo);
7364 API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
7365 pkgmgrinfo_app_list_cb app_cb, void *user_data)
7367 return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb, user_data, GLOBAL_USER);
7370 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
7372 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
7373 pkgmgr_certinfo_x *certinfo = NULL;
7374 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
7376 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
7377 *handle = (void *)certinfo;
7381 API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle, uid_t uid)
7383 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
7384 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
7385 pkgmgr_certinfo_x *certinfo = NULL;
7386 char *error_message = NULL;
7387 int ret = PMINFO_R_OK;
7388 char query[MAX_QUERY_LEN] = {'\0'};
7393 ret = __open_cert_db(uid,"r");
7394 if (ret != SQLITE_OK) {
7395 _LOGE("connect db [%s] failed!\n");
7396 ret = PMINFO_R_ERROR;
7399 _check_create_Cert_db(GET_DB(cert_db));
7401 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
7403 sqlite3_exec(GET_DB(cert_db), query, __validate_cb, (void *)&exist, &error_message)) {
7404 _LOGE("Don't execute query = %s error message = %s\n", query,
7406 sqlite3_free(error_message);
7407 ret = PMINFO_R_ERROR;
7411 _LOGE("Package not found in DB\n");
7412 ret = PMINFO_R_ERROR;
7415 certinfo = (pkgmgr_certinfo_x *)handle;
7416 /*populate certinfo from DB*/
7417 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
7418 ret = __exec_certinfo_query(query, (void *)certinfo);
7420 _LOGE("Package Cert Info DB Information retrieval failed\n");
7421 ret = PMINFO_R_ERROR;
7424 for (i = 0; i < MAX_CERT_TYPE; i++) {
7425 memset(query, '\0', MAX_QUERY_LEN);
7426 snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
7427 ret = __exec_certinfo_query(query, (void *)certinfo);
7429 _LOGE("Cert Info DB Information retrieval failed\n");
7430 ret = PMINFO_R_ERROR;
7433 if (certinfo->cert_value) {
7434 (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
7435 free(certinfo->cert_value);
7436 certinfo->cert_value = NULL;
7444 API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
7446 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
7447 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
7448 retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
7449 retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
7450 pkgmgr_certinfo_x *certinfo = NULL;
7451 certinfo = (pkgmgr_certinfo_x *)handle;
7452 if ((certinfo->cert_info)[cert_type])
7453 *cert_value = (certinfo->cert_info)[cert_type];
7459 API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
7461 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
7463 pkgmgr_certinfo_x *certinfo = NULL;
7464 certinfo = (pkgmgr_certinfo_x *)handle;
7465 if (certinfo->pkgid) {
7466 free(certinfo->pkgid);
7467 certinfo->pkgid = NULL;
7469 for (i = 0; i < MAX_CERT_TYPE; i++) {
7470 if ((certinfo->cert_info)[i]) {
7471 free((certinfo->cert_info)[i]);
7472 (certinfo->cert_info)[i] = NULL;
7480 API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
7482 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
7483 pkgmgr_instcertinfo_x *certinfo = NULL;
7485 certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
7486 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
7487 *handle = (void *)certinfo;
7491 API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
7493 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
7494 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
7495 retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
7496 retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
7497 pkgmgr_instcertinfo_x *certinfo = NULL;
7498 certinfo = (pkgmgr_instcertinfo_x *)handle;
7499 (certinfo->cert_info)[cert_type] = strdup(cert_value);
7503 API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle, uid_t uid)
7505 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
7506 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
7507 char *error_message = NULL;
7508 char query[MAX_QUERY_LEN] = {'\0'};
7509 char *vquery = NULL;
7514 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
7521 pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
7522 pkgmgr_certindexinfo_x *indexinfo = NULL;
7523 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
7524 if (indexinfo == NULL) {
7525 _LOGE("Out of Memory!!!");
7526 return PMINFO_R_ERROR;
7528 info->pkgid = strdup(pkgid);
7531 ret =__open_cert_db(uid, "w");
7533 ret = PMINFO_R_ERROR;
7534 _LOGE("Failed to open cert db \n");
7537 _check_create_Cert_db(GET_DB(cert_db));
7538 /*Begin Transaction*/
7539 ret = sqlite3_exec(GET_DB(cert_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
7541 _LOGE("Failed to begin transaction %s\n");
7542 ret = PMINFO_R_ERROR;
7546 /*Check if request is to insert/update*/
7547 snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
7549 sqlite3_exec(GET_DB(cert_db), query, __validate_cb, (void *)&exist, &error_message)) {
7550 _LOGE("Don't execute query = %s error message = %s\n", query,
7552 sqlite3_free(error_message);
7553 ret = PMINFO_R_ERROR;
7558 We cant just issue update query directly. We need to manage index table also.
7559 Hence it is better to delete and insert again in case of update*/
7560 ret = __delete_certinfo(pkgid, uid);
7562 _LOGE("Certificate Deletion Failed\n");
7564 for (i = 0; i < MAX_CERT_TYPE; i++) {
7565 if ((info->cert_info)[i]) {
7566 for (j = 0; j < i; j++) {
7567 if ( (info->cert_info)[j]) {
7568 if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
7569 (info->cert_id)[i] = (info->cert_id)[j];
7570 (info->is_new)[i] = 0;
7571 (info->ref_count)[i] = (info->ref_count)[j];
7578 memset(query, '\0', MAX_QUERY_LEN);
7579 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
7580 "where cert_info='%s'",(info->cert_info)[i]);
7581 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
7583 _LOGE("Cert Info DB Information retrieval failed\n");
7584 ret = PMINFO_R_ERROR;
7587 if (indexinfo->cert_id == 0) {
7588 /*New certificate. Get newid*/
7589 memset(query, '\0', MAX_QUERY_LEN);
7590 snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
7592 sqlite3_exec(GET_DB(cert_db), query, __maxid_cb, (void *)&newid, &error_message)) {
7593 _LOGE("Don't execute query = %s error message = %s\n", query,
7595 sqlite3_free(error_message);
7596 ret = PMINFO_R_ERROR;
7604 indexinfo->cert_id = maxid;
7605 indexinfo->cert_ref_count = 1;
7609 (info->cert_id)[i] = indexinfo->cert_id;
7610 (info->is_new)[i] = is_new;
7611 (info->ref_count)[i] = indexinfo->cert_ref_count;
7612 indexinfo->cert_id = 0;
7613 indexinfo->cert_ref_count = 0;
7617 len = MAX_QUERY_LEN;
7618 for (i = 0; i < MAX_CERT_TYPE; i++) {
7619 if ((info->cert_info)[i])
7620 len+= strlen((info->cert_info)[i]);
7622 vquery = (char *)calloc(1, len);
7624 snprintf(vquery, len,
7625 "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
7626 "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
7627 "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
7628 info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
7629 (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
7630 (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
7631 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
7632 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
7634 sqlite3_exec(GET_DB(cert_db), vquery, NULL, NULL, &error_message)) {
7635 _LOGE("Don't execute query = %s error message = %s\n", vquery,
7637 sqlite3_free(error_message);
7638 ret = PMINFO_R_ERROR;
7641 /*Update index table info*/
7642 /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
7643 for (i = 0; i < MAX_CERT_TYPE; i++) {
7644 if ((info->cert_info)[i]) {
7645 memset(vquery, '\0', len);
7646 if ((info->is_new)[i]) {
7647 snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
7648 "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
7649 unique_id[c++] = (info->cert_id)[i];
7652 for (j = 0; j < MAX_CERT_TYPE; j++) {
7653 if ((info->cert_id)[i] == unique_id[j]) {
7654 /*Ref count has already been increased. Just continue*/
7658 if (j == MAX_CERT_TYPE)
7659 unique_id[c++] = (info->cert_id)[i];
7662 snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
7663 "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
7666 sqlite3_exec(GET_DB(cert_db), vquery, NULL, NULL, &error_message)) {
7667 _LOGE("Don't execute query = %s error message = %s\n", vquery,
7669 sqlite3_free(error_message);
7670 ret = PMINFO_R_ERROR;
7675 /*Commit transaction*/
7676 ret = sqlite3_exec(GET_DB(cert_db), "COMMIT", NULL, NULL, NULL);
7677 if (ret != SQLITE_OK) {
7678 _LOGE("Failed to commit transaction, Rollback now\n");
7679 sqlite3_exec(GET_DB(cert_db), "ROLLBACK", NULL, NULL, NULL);
7680 ret = PMINFO_R_ERROR;
7698 API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
7700 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
7702 pkgmgr_instcertinfo_x *certinfo = NULL;
7703 certinfo = (pkgmgr_instcertinfo_x *)handle;
7704 if (certinfo->pkgid) {
7705 free(certinfo->pkgid);
7706 certinfo->pkgid = NULL;
7708 for (i = 0; i < MAX_CERT_TYPE; i++) {
7709 if ((certinfo->cert_info)[i]) {
7710 free((certinfo->cert_info)[i]);
7711 (certinfo->cert_info)[i] = NULL;
7719 API int pkgmgrinfo_delete_usr_certinfo(const char *pkgid, uid_t uid)
7721 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
7724 ret = __open_cert_db(uid, "w");
7726 _LOGE("connect db [%s] failed!\n", getUserPkgCertDBPathUID(uid));
7727 ret = PMINFO_R_ERROR;
7730 _check_create_Cert_db(GET_DB(cert_db));
7731 /*Begin Transaction*/
7732 ret = sqlite3_exec(GET_DB(cert_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
7733 if (ret != SQLITE_OK) {
7734 _LOGE("Failed to begin transaction\n");
7735 ret = PMINFO_R_ERROR;
7738 _LOGE("Transaction Begin\n");
7739 ret = __delete_certinfo(pkgid, uid);
7741 _LOGE("Certificate Deletion Failed\n");
7743 _LOGE("Certificate Deletion Success\n");
7745 /*Commit transaction*/
7746 ret = sqlite3_exec(GET_DB(cert_db), "COMMIT", NULL, NULL, NULL);
7747 if (ret != SQLITE_OK) {
7748 _LOGE("Failed to commit transaction, Rollback now\n");
7749 sqlite3_exec(GET_DB(cert_db), "ROLLBACK", NULL, NULL, NULL);
7750 ret = PMINFO_R_ERROR;
7753 _LOGE("Transaction Commit and End\n");
7761 API int pkgmgrinfo_delete_certinfo(const char *pkgid)
7763 return pkgmgrinfo_delete_usr_certinfo(pkgid, GLOBAL_USER);
7766 API int pkgmgrinfo_create_pkgusrdbinfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkgdbinfo_h *handle)
7768 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
7769 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7771 char *manifest = NULL;
7772 manifest_x *mfx = NULL;
7774 manifest = pkgmgr_parser_get_usr_manifest_file(pkgid, uid);
7775 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
7777 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
7782 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
7784 *handle = (void *)mfx;
7789 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
7791 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
7792 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7794 char *manifest = NULL;
7795 manifest_x *mfx = NULL;
7797 manifest = pkgmgr_parser_get_manifest_file(pkgid);
7798 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
7800 mfx = pkgmgr_parser_process_manifest_xml(manifest);
7805 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
7807 *handle = (void *)mfx;
7812 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
7814 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
7815 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7817 int len = strlen(type);
7818 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
7820 manifest_x *mfx = (manifest_x *)handle;
7822 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
7826 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
7828 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
7829 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7831 int len = strlen(version);
7832 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
7834 manifest_x *mfx = (manifest_x *)handle;
7836 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
7840 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
7842 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7843 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
7845 manifest_x *mfx = (manifest_x *)handle;
7847 if (location == INSTALL_INTERNAL)
7848 strcpy(mfx->installlocation, "internal-only");
7849 else if (location == INSTALL_EXTERNAL)
7850 strcpy(mfx->installlocation, "prefer-external");
7855 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
7857 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7858 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
7860 manifest_x *mfx = (manifest_x *)handle;
7862 mfx->package_size = strdup(size);
7867 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
7869 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7870 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
7872 int len = strlen(label_txt);
7873 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
7875 manifest_x *mfx = (manifest_x *)handle;
7877 label_x *label = calloc(1, sizeof(label_x));
7878 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
7880 LISTADD(mfx->label, label);
7882 mfx->label->lang = strdup(locale);
7884 mfx->label->lang = strdup(DEFAULT_LOCALE);
7885 mfx->label->text = strdup(label_txt);
7890 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
7892 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7893 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
7895 int len = strlen(icon_txt);
7896 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
7898 manifest_x *mfx = (manifest_x *)handle;
7900 icon_x *icon = calloc(1, sizeof(icon_x));
7901 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
7903 LISTADD(mfx->icon, icon);
7905 mfx->icon->lang = strdup(locale);
7907 mfx->icon->lang = strdup(DEFAULT_LOCALE);
7908 mfx->icon->text = strdup(icon_txt);
7913 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
7915 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7916 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
7918 int len = strlen(desc_txt);
7919 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
7921 manifest_x *mfx = (manifest_x *)handle;
7923 description_x *description = calloc(1, sizeof(description_x));
7924 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
7926 LISTADD(mfx->description, description);
7928 mfx->description->lang = strdup(locale);
7930 mfx->description->lang = strdup(DEFAULT_LOCALE);
7931 mfx->description->text = strdup(desc_txt);
7936 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
7937 const char *author_email, const char *author_href, const char *locale)
7939 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7940 manifest_x *mfx = (manifest_x *)handle;
7941 author_x *author = calloc(1, sizeof(author_x));
7942 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
7944 LISTADD(mfx->author, author);
7946 mfx->author->text = strdup(author_name);
7948 mfx->author->email = strdup(author_email);
7950 mfx->author->href = strdup(author_href);
7952 mfx->author->lang = strdup(locale);
7954 mfx->author->lang = strdup(DEFAULT_LOCALE);
7958 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
7960 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7961 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
7963 manifest_x *mfx = (manifest_x *)handle;
7966 strcpy(mfx->removable, "false");
7967 else if (removable == 1)
7968 strcpy(mfx->removable, "true");
7973 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
7975 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7976 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
7978 manifest_x *mfx = (manifest_x *)handle;
7981 strcpy(mfx->preload, "false");
7982 else if (preload == 1)
7983 strcpy(mfx->preload, "true");
7988 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
7990 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
7991 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
7993 manifest_x *mfx = (manifest_x *)handle;
7995 if (location == INSTALL_INTERNAL)
7996 strcpy(mfx->installed_storage, "installed_internal");
7997 else if (location == INSTALL_EXTERNAL)
7998 strcpy(mfx->installed_storage, "installed_external");
8003 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
8005 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
8008 manifest_x *mfx = NULL;
8009 mfx = (manifest_x *)handle;
8011 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
8013 _LOGE("Successfully stored info in DB\n");
8016 _LOGE("Failed to store info in DB\n");
8017 return PMINFO_R_ERROR;
8021 API int pkgmgrinfo_save_pkgusrdbinfo(pkgmgrinfo_pkgdbinfo_h handle, uid_t uid)
8023 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
8026 manifest_x *mfx = NULL;
8027 mfx = (manifest_x *)handle;
8029 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
8031 _LOGE("Successfully stored info in DB\n");
8034 _LOGE("Failed to store info in DB\n");
8035 return PMINFO_R_ERROR;
8039 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
8041 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
8043 manifest_x *mfx = NULL;
8044 mfx = (manifest_x *)handle;
8045 pkgmgr_parser_free_manifest_xml(mfx);
8049 API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
8051 /* Should be implemented later */
8055 API int pkgmgrinfo_appinfo_set_usr_state_enabled(const char *appid, bool enabled, uid_t uid)
8057 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
8059 char query[MAX_QUERY_LEN] = {'\0'};
8062 ret = __open_manifest_db(uid);
8063 if (ret != SQLITE_OK) {
8064 _LOGE("connect db [%s] failed!\n", getUserPkgParserDBPathUID(uid));
8065 return PMINFO_R_ERROR;
8068 /*Begin transaction*/
8069 ret = sqlite3_exec(GET_DB(manifest_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
8070 if (ret != SQLITE_OK) {
8071 _LOGE("Failed to begin transaction\n");
8072 __close_manifest_db();
8073 return PMINFO_R_ERROR;
8075 _LOGD("Transaction Begin\n");
8077 memset(query, '\0', MAX_QUERY_LEN);
8078 snprintf(query, MAX_QUERY_LEN,
8079 "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
8081 char *error_message = NULL;
8083 sqlite3_exec(GET_DB(manifest_db), query, NULL, NULL, &error_message)) {
8084 _LOGE("Don't execute query = %s error message = %s\n", query,
8086 sqlite3_free(error_message);
8087 return PMINFO_R_ERROR;
8089 sqlite3_free(error_message);
8091 /*Commit transaction*/
8092 ret = sqlite3_exec(GET_DB(manifest_db), "COMMIT", NULL, NULL, NULL);
8093 if (ret != SQLITE_OK) {
8094 _LOGE("Failed to commit transaction. Rollback now\n");
8095 sqlite3_exec(GET_DB(manifest_db), "ROLLBACK", NULL, NULL, NULL);
8096 __close_manifest_db();
8097 return PMINFO_R_ERROR;
8099 _LOGD("Transaction Commit and End\n");
8100 __close_manifest_db();
8104 API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
8106 return pkgmgrinfo_appinfo_set_usr_state_enabled(appid, enabled, GLOBAL_USER);
8109 API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
8111 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
8112 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
8113 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
8114 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
8115 int ret = PMINFO_R_OK;
8116 char query[MAX_QUERY_LEN] = {'\0'};
8117 char *error_message = NULL;
8118 pkgmgr_datacontrol_x *data = NULL;
8120 ret = __open_datacontrol_db();
8122 _LOGE("Fail to open datacontrol DB\n");
8123 return PMINFO_R_ERROR;
8126 data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x));
8128 _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
8129 __close_datacontrol_db();
8130 return PMINFO_R_ERROR;
8133 snprintf(query, MAX_QUERY_LEN,
8134 "select appinfo.package_name, datacontrol.access from appinfo, datacontrol where datacontrol.id=appinfo.unique_id and datacontrol.providerid = '%s' and datacontrol.type='%s' COLLATE NOCASE",
8138 sqlite3_exec(GET_DB(datacontrol_db), query, __datacontrol_cb, (void *)data, &error_message)) {
8139 _LOGE("Don't execute query = %s error message = %s\n", query,
8141 sqlite3_free(error_message);
8142 __close_datacontrol_db();
8143 return PMINFO_R_ERROR;
8146 *appid = (char *)data->appid;
8147 *access = (char *)data->access;
8149 __close_datacontrol_db();
8154 API int pkgmgrinfo_appinfo_set_usr_default_label(const char *appid, const char *label, uid_t uid)
8156 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
8158 char query[MAX_QUERY_LEN] = {'\0'};
8159 char *error_message = NULL;
8160 ret = __open_manifest_db(uid);
8163 /*Begin transaction*/
8164 ret = sqlite3_exec(GET_DB(manifest_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
8165 if (ret != SQLITE_OK) {
8166 _LOGE("Failed to begin transaction\n");
8167 __close_manifest_db();
8168 return PMINFO_R_ERROR;
8170 _LOGD("Transaction Begin\n");
8172 memset(query, '\0', MAX_QUERY_LEN);
8173 snprintf(query, MAX_QUERY_LEN,
8174 "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid);
8177 sqlite3_exec(GET_DB(manifest_db), query, NULL, NULL, &error_message)) {
8178 _LOGE("Don't execute query = %s error message = %s\n", query,
8180 sqlite3_free(error_message);
8181 return PMINFO_R_ERROR;
8184 /*Commit transaction*/
8185 ret = sqlite3_exec(GET_DB(manifest_db), "COMMIT", NULL, NULL, NULL);
8186 if (ret != SQLITE_OK) {
8187 _LOGE("Failed to commit transaction. Rollback now\n");
8188 sqlite3_exec(GET_DB(manifest_db), "ROLLBACK", NULL, NULL, NULL);
8189 __close_manifest_db();
8190 return PMINFO_R_ERROR;
8192 _LOGD("Transaction Commit and End\n");
8193 __close_manifest_db();
8197 API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
8199 return pkgmgrinfo_appinfo_set_usr_default_label(appid, label, GLOBAL_USER);
8202 API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
8204 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
8205 retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
8207 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
8208 val = (char *)info->uiapp_info->guestmode_visibility;
8210 if (strcasecmp(val, "true") == 0){
8212 }else if (strcasecmp(val, "false") == 0){
8221 API int pkgmgrinfo_appinfo_set_usr_guestmode_visibility(pkgmgrinfo_appinfo_h handle, uid_t uid, bool status)
8223 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
8226 char *noti_string = NULL;
8228 char query[MAX_QUERY_LEN] = {'\0'};
8229 char *errmsg = NULL;
8230 sqlite3 *pkgmgr_parser_db;
8232 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
8233 val = (char *)info->uiapp_info->guestmode_visibility;
8236 db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkgmgr_parser_db,
8237 SQLITE_OPEN_READWRITE, NULL);
8239 if (ret != SQLITE_OK) {
8240 _LOGE("DB Open Failed\n");
8241 return PMINFO_R_ERROR;
8244 /*TODO: Write to DB here*/
8246 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
8248 snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
8250 if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
8251 _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
8253 sqlite3_close(pkgmgr_parser_db);
8254 return PMINFO_R_ERROR;
8256 sqlite3_close(pkgmgr_parser_db);
8257 len = strlen((char *)info->uiapp_info->appid) + 8;
8258 noti_string = calloc(1, len);
8259 if (noti_string == NULL){
8260 return PMINFO_R_ERROR;
8262 snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
8263 vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
8264 vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
8271 API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
8273 return pkgmgrinfo_appinfo_set_usr_guestmode_visibility(handle, GLOBAL_USER, status);
8276 /* pkgmgrinfo client start*/
8277 API pkgmgrinfo_client *pkgmgrinfo_client_new(pkgmgrinfo_client_type ctype)
8280 char *errmsg = NULL;
8282 void *handle = NULL;
8283 pkgmgrinfo_client *(*__pkgmgr_client_new)(pkgmgrinfo_client_type ctype) = NULL;
8285 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
8286 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
8288 __pkgmgr_client_new = dlsym(handle, "pkgmgr_client_new");
8290 tryvm_if((errmsg != NULL) || (__pkgmgr_client_new == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
8292 pc = __pkgmgr_client_new(ctype);
8293 tryvm_if(pc == NULL, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
8297 return (pkgmgrinfo_client *) pc;
8300 API int pkgmgrinfo_client_set_status_type(pkgmgrinfo_client *pc, int status_type)
8303 char *errmsg = NULL;
8304 void *handle = NULL;
8305 int (*__pkgmgr_client_set_status_type)(pkgmgrinfo_client *pc, int status_type) = NULL;
8307 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
8308 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
8310 __pkgmgr_client_set_status_type = dlsym(handle, "pkgmgr_client_set_status_type");
8312 tryvm_if((errmsg != NULL) || (__pkgmgr_client_set_status_type == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
8314 ret = __pkgmgr_client_set_status_type(pc, status_type);
8315 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
8319 * Do not close libpkgmgr-client.so.0 to avoid munmap registered callback
8321 * The lib dependency chain like below
8322 * amd --> pkgmgr-info -- dlopen --> libpkgmgr-client --> libpkgmgr-installer-client
8324 * And there is a function in libpkgmgr-installer-client named _on_signal_handle_filter()
8325 * which will registered to dbus callback in amd though in fact amd doesn't direct depends
8326 * on libpkgmgr-installer-client.
8328 * So when the dlcose happen, then libpkgmgr-installer-client been closed too since no one
8331 * However, when the libdbus call into the callback function, it suddenly fond that the
8332 * function address is gone (unmapped), then we receive a SIGSEGV.
8334 * I'm not sure why we're using dlopen/dlclose in this case, I think it's much simple and
8335 * robust if we just link to the well-known lib.
8337 * See https://bugs.tizen.org/jira/browse/PTREL-591
8343 API int pkgmgrinfo_client_listen_status(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data)
8346 char *errmsg = NULL;
8347 void *handle = NULL;
8348 int (*__pkgmgr_client_listen_status)(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data) = NULL;
8350 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
8351 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
8353 __pkgmgr_client_listen_status = dlsym(handle, "pkgmgr_client_listen_status");
8355 tryvm_if((errmsg != NULL) || (__pkgmgr_client_listen_status == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
8357 ret = __pkgmgr_client_listen_status(pc, event_cb, data);
8358 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
8361 /* same as pkgmgrinfo_client_new */
8365 API int pkgmgrinfo_client_free(pkgmgrinfo_client *pc)
8368 char *errmsg = NULL;
8369 void *handle = NULL;
8370 int (*__pkgmgr_client_free)(pkgmgrinfo_client *pc) = NULL;
8372 handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
8373 retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
8375 __pkgmgr_client_free = dlsym(handle, "pkgmgr_client_free");
8377 tryvm_if((errmsg != NULL) || (__pkgmgr_client_free == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
8379 ret = __pkgmgr_client_free(pc);
8380 tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
8383 /* same as pkgmgrinfo_client_new */
8387 API int pkgmgrinfo_client_request_enable_external_pkg(char *pkgid)
8390 DBusConnection *bus;
8391 DBusMessage *message;
8393 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
8395 if(__get_pkg_location(pkgid) != PMINFO_EXTERNAL_STORAGE)
8398 bus = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
8399 retvm_if(bus == NULL, PMINFO_R_EINVAL, "dbus_bus_get() failed.");
8401 message = dbus_message_new_method_call (SERVICE_NAME, PATH_NAME, INTERFACE_NAME, METHOD_NAME);
8402 retvm_if(message == NULL, PMINFO_R_EINVAL, "dbus_message_new_method_call() failed.");
8404 dbus_message_append_args(message, DBUS_TYPE_STRING, &pkgid, DBUS_TYPE_INVALID);
8406 ret = dbus_connection_send_with_reply_and_block(bus, message, -1, NULL);
8407 retvm_if(!ret, ret = PMINFO_R_EINVAL, "connection_send dbus fail");
8409 dbus_connection_flush(bus);
8410 dbus_message_unref(message);
8415 /* pkgmgrinfo client end*/