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.
30 #include <sys/smack.h>
31 #include <linux/limits.h>
35 #include <libxml/parser.h>
36 #include <libxml/xmlreader.h>
37 #include <libxml/xmlschemas.h>
41 #include "pkgmgr_parser.h"
42 #include "pkgmgrinfo_basic.h"
43 #include "pkgmgrinfo_private.h"
44 #include "pkgmgrinfo_debug.h"
45 #include "pkgmgr-info.h"
46 #include "pkgmgr_parser_db.h"
47 #include "pkgmgr_parser_internal.h"
49 #define FILTER_QUERY_COUNT_PACKAGE "select count(DISTINCT package_info.package) " \
50 "from package_info LEFT OUTER JOIN package_localized_info " \
51 "ON package_info.package=package_localized_info.package " \
52 "and package_localized_info.package_locale='%s' where "
55 static int _pkginfo_get_pkginfo(const char *pkgid, uid_t uid,
56 pkgmgr_pkginfo_x **pkginfo);
57 static char *_get_filtered_query(const char *query_raw,
58 pkgmgrinfo_filter_x *filter);
60 static gint __compare_func(gconstpointer data1, gconstpointer data2)
62 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
63 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
64 if (node1->prop == node2->prop)
66 else if (node1->prop > node2->prop)
72 static int __count_cb(void *data, int ncols, char **coltxt, char **colname)
76 _LOGE("count value is %d\n", *p);
80 static void __destroy_each_node(gpointer data, gpointer user_data)
83 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
96 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
100 free((void *)data->locale);
104 pkgmgrinfo_basic_free_package(data->pkg_info);
110 static int __child_element(xmlTextReaderPtr reader, int depth)
112 int ret = xmlTextReaderRead(reader);
113 int cur = xmlTextReaderDepth(reader);
116 switch (xmlTextReaderNodeType(reader)) {
117 case XML_READER_TYPE_ELEMENT:
118 if (cur == depth + 1)
121 case XML_READER_TYPE_TEXT:
122 /*text is handled by each function separately*/
123 if (cur == depth + 1)
126 case XML_READER_TYPE_END_ELEMENT:
135 ret = xmlTextReaderRead(reader);
136 cur = xmlTextReaderDepth(reader);
141 long long _pkgmgr_calculate_dir_size(char *dirname)
145 int q = 0; /*quotient*/
146 int r = 0; /*remainder*/
148 struct dirent *ep = NULL;
149 struct stat fileinfo;
150 char abs_filename[FILENAME_MAX] = { 0, };
151 retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL");
153 dp = opendir(dirname);
155 while ((ep = readdir(dp)) != NULL) {
156 if (!strcmp(ep->d_name, ".") ||
157 !strcmp(ep->d_name, "..")) {
160 snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
162 if (lstat(abs_filename, &fileinfo) < 0)
163 perror(abs_filename);
165 if (S_ISDIR(fileinfo.st_mode)) {
166 total += fileinfo.st_size;
167 if (strcmp(ep->d_name, ".")
168 && strcmp(ep->d_name, "..")) {
169 ret = _pkgmgr_calculate_dir_size
173 } else if (S_ISLNK(fileinfo.st_mode)) {
176 /*It is a file. Calculate the actual
177 size occupied (in terms of 4096 blocks)*/
178 q = (fileinfo.st_size / BLOCK_SIZE);
179 r = (fileinfo.st_size % BLOCK_SIZE);
183 total += q * BLOCK_SIZE;
189 _LOGE("Couldn't open the directory\n");
196 static gint __list_strcmp(gconstpointer a, gconstpointer b)
198 return strcmp((char *)a, (char *)b);
201 static int _pkginfo_get_list(sqlite3 *db, const char *locale,
202 pkgmgrinfo_filter_x *filter, GList **list)
204 static const char query_raw[] =
205 "SELECT DISTINCT package_info.package FROM package_info"
206 " LEFT OUTER JOIN package_localized_info"
207 " ON package_info.package=package_localized_info.package"
208 " AND package_localized_info.package_locale=%Q "
209 " LEFT OUTER JOIN package_privilege_info"
210 " ON package_info.package=package_privilege_info.package";
213 char *query_localized;
217 query = _get_filtered_query(query_raw, filter);
220 query_localized = sqlite3_mprintf(query, locale);
222 if (query_localized == NULL)
225 ret = sqlite3_prepare_v2(db, query_localized,
226 strlen(query_localized), &stmt, NULL);
227 sqlite3_free(query_localized);
228 if (ret != SQLITE_OK) {
229 LOGE("prepare failed: %s", sqlite3_errmsg(db));
233 while (sqlite3_step(stmt) == SQLITE_ROW) {
234 _save_column_str(stmt, 0, (const char **)&pkgid);
236 *list = g_list_insert_sorted(*list, pkgid,
240 sqlite3_finalize(stmt);
245 static int _pkginfo_get_filtered_list(pkgmgrinfo_filter_x *filter, uid_t uid,
254 locale = _get_system_locale();
256 return PMINFO_R_ERROR;
258 dbpath = getUserPkgParserDBPathUID(uid);
259 if (dbpath == NULL) {
261 return PMINFO_R_ERROR;
264 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
265 if (ret != SQLITE_OK) {
266 _LOGE("failed to open db: %d", ret);
268 return PMINFO_R_ERROR;
271 if (_pkginfo_get_list(db, locale, filter, list)) {
273 sqlite3_close_v2(db);
274 return PMINFO_R_ERROR;
276 sqlite3_close_v2(db);
278 if (uid == GLOBAL_USER) {
283 /* search again from global */
284 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
285 if (dbpath == NULL) {
287 return PMINFO_R_ERROR;
290 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
291 if (ret != SQLITE_OK) {
292 _LOGE("failed to open db: %d", ret);
294 return PMINFO_R_ERROR;
297 if (_pkginfo_get_list(db, locale, filter, list)) {
299 sqlite3_close_v2(db);
300 return PMINFO_R_ERROR;
302 sqlite3_close_v2(db);
304 /* remove duplicate element:
305 * since the list is sorted, we can remove duplicates in linear time
307 for (tmp = *list; tmp; tmp = tmp->next) {
308 if (tmp->prev == NULL || tmp->data == NULL)
310 if (strcmp((const char *)tmp->prev->data,
311 (const char *)tmp->data) == 0)
312 *list = g_list_delete_link(*list, tmp);
319 static int _pkginfo_get_filtered_foreach_pkginfo(pkgmgrinfo_filter_x *filter,
320 pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
323 pkgmgr_pkginfo_x *info;
329 ret = _pkginfo_get_filtered_list(filter, uid, &list);
330 if (ret != PMINFO_R_OK)
331 return PMINFO_R_ERROR;
333 for (tmp = list; tmp; tmp = tmp->next) {
334 pkgid = (char *)tmp->data;
336 ret = _pkginfo_get_pkginfo(pkgid, uid, &info);
337 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
338 ret = _pkginfo_get_pkginfo(pkgid, GLOBAL_USER,
340 if (ret != PMINFO_R_OK) {
344 if (pkg_list_cb(info, user_data) < 0)
346 pkgmgrinfo_pkginfo_destroy_pkginfo(info);
356 API int pkgmgrinfo_pkginfo_get_usr_list(pkgmgrinfo_pkg_list_cb pkg_list_cb,
357 void *user_data, uid_t uid)
359 if (pkg_list_cb == NULL) {
360 LOGE("invalid parameter");
361 return PMINFO_R_EINVAL;
364 return _pkginfo_get_filtered_foreach_pkginfo(NULL, pkg_list_cb,
368 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
370 return pkgmgrinfo_pkginfo_get_usr_list(pkg_list_cb, user_data, GLOBAL_USER);
373 static int _pkginfo_get_author(sqlite3 *db, const char *pkgid,
376 static const char query_raw[] =
377 "SELECT author_name, author_email, author_href "
378 "FROM package_info WHERE package=%Q";
385 query = sqlite3_mprintf(query_raw, pkgid);
387 LOGE("out of memory");
388 return PMINFO_R_ERROR;
391 ret = sqlite3_prepare_v2(db, query, strlen(query),
394 if (ret != SQLITE_OK) {
395 LOGE("prepare failed: %s", sqlite3_errmsg(db));
396 return PMINFO_R_ERROR;
399 if (sqlite3_step(stmt) == SQLITE_ERROR) {
400 LOGE("step error: %s", sqlite3_errmsg(db));
401 sqlite3_finalize(stmt);
402 return PMINFO_R_ERROR;
405 /* one author per one package */
406 info = calloc(1, sizeof(author_x));
408 LOGE("out of memory");
409 sqlite3_finalize(stmt);
410 return PMINFO_R_ERROR;
413 _save_column_str(stmt, idx++, &info->text);
414 _save_column_str(stmt, idx++, &info->email);
415 _save_column_str(stmt, idx++, &info->href);
419 sqlite3_finalize(stmt);
424 static int _pkginfo_get_label(sqlite3 *db, const char *pkgid,
425 const char *locale, label_x **label)
427 static const char query_raw[] =
428 "SELECT package_label, package_locale "
429 "FROM package_localized_info "
430 "WHERE package=%Q AND package_locale IN (%Q, %Q)";
437 query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
439 LOGE("out of memory");
440 return PMINFO_R_ERROR;
443 ret = sqlite3_prepare_v2(db, query, strlen(query),
446 if (ret != SQLITE_OK) {
447 LOGE("prepare failed: %s", sqlite3_errmsg(db));
448 return PMINFO_R_ERROR;
451 while (sqlite3_step(stmt) == SQLITE_ROW) {
452 info = calloc(1, sizeof(label_x));
454 LOGE("out of memory");
455 sqlite3_finalize(stmt);
457 LISTHEAD(*label, info);
460 return PMINFO_R_ERROR;
463 _save_column_str(stmt, idx++, &info->text);
464 _save_column_str(stmt, idx++, &info->lang);
465 LISTADD(*label, info);
469 LISTHEAD(*label, info);
473 sqlite3_finalize(stmt);
478 static int _pkginfo_get_icon(sqlite3 *db, const char *pkgid, const char *locale,
481 static const char query_raw[] =
482 "SELECT package_icon, package_locale "
483 "FROM package_localized_info "
484 "WHERE package=%Q AND package_locale IN (%Q, %Q)";
491 query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
493 LOGE("out of memory");
494 return PMINFO_R_ERROR;
497 ret = sqlite3_prepare_v2(db, query, strlen(query),
500 if (ret != SQLITE_OK) {
501 LOGE("prepare failed: %s", sqlite3_errmsg(db));
502 return PMINFO_R_ERROR;
505 while (sqlite3_step(stmt) == SQLITE_ROW) {
506 info = calloc(1, sizeof(icon_x));
508 LOGE("out of memory");
509 sqlite3_finalize(stmt);
511 LISTHEAD(*icon, info);
514 return PMINFO_R_ERROR;
517 _save_column_str(stmt, idx++, &info->text);
518 _save_column_str(stmt, idx++, &info->lang);
519 LISTADD(*icon, info);
523 LISTHEAD(*icon, info);
527 sqlite3_finalize(stmt);
532 static int _pkginfo_get_description(sqlite3 *db, const char *pkgid,
533 const char *locale, description_x **description)
535 static const char query_raw[] =
536 "SELECT package_description, package_locale "
537 "FROM package_localized_info "
538 "WHERE package=%Q AND package_locale IN (%Q, %Q)";
545 query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
547 LOGE("out of memory");
548 return PMINFO_R_ERROR;
551 ret = sqlite3_prepare_v2(db, query, strlen(query),
554 if (ret != SQLITE_OK) {
555 LOGE("prepare failed: %s", sqlite3_errmsg(db));
556 return PMINFO_R_ERROR;
559 while (sqlite3_step(stmt) == SQLITE_ROW) {
560 info = calloc(1, sizeof(description_x));
562 LOGE("out of memory");
563 sqlite3_finalize(stmt);
565 LISTHEAD(*description, info);
568 return PMINFO_R_ERROR;
571 _save_column_str(stmt, idx++, &info->text);
572 _save_column_str(stmt, idx++, &info->lang);
573 LISTADD(*description, info);
577 LISTHEAD(*description, info);
581 sqlite3_finalize(stmt);
586 static int _pkginfo_get_privilege(sqlite3 *db, const char *pkgid,
587 privileges_x **privileges)
589 static const char query_raw[] =
590 "SELECT privilege FROM package_privilege_info WHERE package=%Q";
597 /* privilege list should stored in privileges_x... */
598 p = calloc(1, sizeof(privileges_x));
600 LOGE("out of memory");
601 return PMINFO_R_ERROR;
605 query = sqlite3_mprintf(query_raw, pkgid);
607 LOGE("out of memory");
609 return PMINFO_R_ERROR;
612 ret = sqlite3_prepare_v2(db, query, strlen(query),
615 if (ret != SQLITE_OK) {
616 LOGE("prepare failed: %s", sqlite3_errmsg(db));
618 return PMINFO_R_ERROR;
621 while (sqlite3_step(stmt) == SQLITE_ROW) {
622 info = calloc(1, sizeof(privilege_x));
624 LOGE("out of memory");
625 sqlite3_finalize(stmt);
627 LISTHEAD(p->privilege, info);
630 return PMINFO_R_ERROR;
632 _save_column_str(stmt, 0, &info->text);
633 LISTADD(p->privilege, info);
637 LISTHEAD(p->privilege, info);
641 sqlite3_finalize(stmt);
646 static char *_get_filtered_query(const char *query_raw,
647 pkgmgrinfo_filter_x *filter)
649 char buf[MAX_QUERY_LEN] = { 0, };
658 strncat(buf, query_raw, MAX_QUERY_LEN - 1);
660 for (list = head; list; list = list->next) {
661 /* TODO: revise condition getter function */
662 __get_filter_condition(list->data, &condition);
663 if (condition == NULL)
665 if (buf[strlen(query_raw)] == '\0') {
666 len += strlen(" WHERE ");
667 strncat(buf, " WHERE ", MAX_QUERY_LEN - len - 1);
669 len += strlen(" AND ");
670 strncat(buf, " AND ", MAX_QUERY_LEN -len - 1);
672 len += strlen(condition);
673 strncat(buf, condition, sizeof(buf) - len - 1);
681 static int _pkginfo_get_package(sqlite3 *db, const char *pkgid,
682 const char *locale, package_x **package)
684 static const char query_raw[] =
685 "SELECT package, package_version, "
686 "install_location, package_removable, package_preload, "
687 "package_readonly, package_update, package_appsetting, "
688 "package_system, package_type, package_size, installed_time, "
689 "installed_storage, storeclient_id, mainapp_id, package_url, "
690 "root_path, csc_path, package_nodisplay, package_api_version, "
691 "package_support_disable "
692 "FROM package_info WHERE package=%Q";
699 query = sqlite3_mprintf(query_raw, pkgid);
701 LOGE("out of memory");
702 return PMINFO_R_ERROR;
705 ret = sqlite3_prepare_v2(db, query, strlen(query),
708 if (ret != SQLITE_OK) {
709 LOGE("prepare failed: %s", sqlite3_errmsg(db));
710 return PMINFO_R_ERROR;
713 ret = sqlite3_step(stmt);
714 if (ret == SQLITE_DONE) {
715 sqlite3_finalize(stmt);
716 return PMINFO_R_ENOENT;
717 } else if (ret != SQLITE_ROW) {
718 LOGE("step failed: %s", sqlite3_errmsg(db));
719 sqlite3_finalize(stmt);
720 return PMINFO_R_ERROR;
723 info = calloc(1, sizeof(package_x));
725 LOGE("out of memory");
726 sqlite3_finalize(stmt);
727 return PMINFO_R_ERROR;
730 _save_column_str(stmt, idx++, &info->package);
731 _save_column_str(stmt, idx++, &info->version);
732 _save_column_str(stmt, idx++, &info->installlocation);
733 _save_column_str(stmt, idx++, &info->removable);
734 _save_column_str(stmt, idx++, &info->preload);
735 _save_column_str(stmt, idx++, &info->readonly);
736 _save_column_str(stmt, idx++, &info->update);
737 _save_column_str(stmt, idx++, &info->appsetting);
738 _save_column_str(stmt, idx++, &info->system);
739 _save_column_str(stmt, idx++, &info->type);
740 _save_column_str(stmt, idx++, &info->package_size);
741 _save_column_str(stmt, idx++, &info->installed_time);
742 _save_column_str(stmt, idx++, &info->installed_storage);
743 _save_column_str(stmt, idx++, &info->storeclient_id);
744 _save_column_str(stmt, idx++, &info->mainapp_id);
745 _save_column_str(stmt, idx++, &info->package_url);
746 _save_column_str(stmt, idx++, &info->root_path);
747 _save_column_str(stmt, idx++, &info->csc_path);
748 _save_column_str(stmt, idx++, &info->nodisplay_setting);
749 _save_column_str(stmt, idx++, &info->api_version);
750 _save_column_str(stmt, idx++, &info->support_disable);
752 if (_pkginfo_get_author(db, info->package, &info->author)) {
753 pkgmgrinfo_basic_free_package(info);
754 sqlite3_finalize(stmt);
755 return PMINFO_R_ERROR;
758 if (_pkginfo_get_label(db, info->package, locale, &info->label)) {
759 pkgmgrinfo_basic_free_package(info);
760 sqlite3_finalize(stmt);
761 return PMINFO_R_ERROR;
764 if (_pkginfo_get_icon(db, info->package, locale, &info->icon)) {
765 pkgmgrinfo_basic_free_package(info);
766 sqlite3_finalize(stmt);
767 return PMINFO_R_ERROR;
770 if (_pkginfo_get_description(db, info->package, locale,
771 &info->description)) {
772 pkgmgrinfo_basic_free_package(info);
773 sqlite3_finalize(stmt);
774 return PMINFO_R_ERROR;
777 if (_pkginfo_get_privilege(db, info->package, &info->privileges)) {
778 pkgmgrinfo_basic_free_package(info);
779 sqlite3_finalize(stmt);
780 return PMINFO_R_ERROR;
784 sqlite3_finalize(stmt);
789 static int _pkginfo_get_pkginfo(const char *pkgid, uid_t uid,
790 pkgmgr_pkginfo_x **pkginfo)
796 pkgmgr_pkginfo_x *info;
798 dbpath = getUserPkgParserDBPathUID(uid);
800 return PMINFO_R_ERROR;
802 locale = _get_system_locale();
804 return PMINFO_R_ERROR;
806 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
807 if (ret != SQLITE_OK) {
808 _LOGE("failed to open db: %d", ret);
810 return PMINFO_R_ERROR;
813 info = calloc(1, sizeof(pkgmgr_pkginfo_x));
815 _LOGE("out of memory");
817 sqlite3_close_v2(db);
818 return PMINFO_R_ERROR;
821 ret = _pkginfo_get_package(db, pkgid, locale, &info->pkg_info);
822 if (ret == PMINFO_R_OK) {
823 info->locale = strdup(locale);
825 info->pkg_info->for_all_users = strdup(
826 uid != GLOBAL_USER ? "false" : "true");
832 sqlite3_close_v2(db);
837 API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid,
838 pkgmgrinfo_pkginfo_h *handle)
842 if (pkgid == NULL || handle == NULL) {
843 LOGE("invalid parameter");
844 return PMINFO_R_EINVAL;
847 ret = _pkginfo_get_pkginfo(pkgid, uid, (pkgmgr_pkginfo_x **)handle);
848 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
849 ret = _pkginfo_get_pkginfo(pkgid, GLOBAL_USER,
850 (pkgmgr_pkginfo_x **)handle);
852 if (ret != PMINFO_R_OK)
853 _LOGE("failed to get pkginfo of %s for user %d", pkgid, uid);
858 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
860 return pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, GLOBAL_USER, handle);
863 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
865 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
867 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
868 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
870 if (info->pkg_info == NULL || info->pkg_info->package == NULL)
871 return PMINFO_R_ERROR;
873 *pkg_name = (char *)info->pkg_info->package;
878 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
880 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
882 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
883 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
885 if (info->pkg_info == NULL || info->pkg_info->package == NULL)
886 return PMINFO_R_ERROR;
888 *pkgid = (char *)info->pkg_info->package;
893 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
895 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
897 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
898 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
900 if (info->pkg_info == NULL || info->pkg_info->type == NULL)
901 return PMINFO_R_ERROR;
903 *type = (char *)info->pkg_info->type;
908 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
910 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
912 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
913 retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
915 if (info->pkg_info == NULL || info->pkg_info->version == NULL)
916 return PMINFO_R_ERROR;
918 *version = (char *)info->pkg_info->version;
923 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
926 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
928 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
929 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
931 if (info->pkg_info == NULL || info->pkg_info->installlocation == NULL)
932 return PMINFO_R_ERROR;
934 val = (char *)info->pkg_info->installlocation;
935 if (strcmp(val, "internal-only") == 0)
936 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
937 else if (strcmp(val, "prefer-external") == 0)
938 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
940 *location = PMINFO_INSTALL_LOCATION_AUTO;
945 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
947 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
949 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
950 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
952 if (info->pkg_info == NULL || info->pkg_info->package_size == NULL)
953 return PMINFO_R_ERROR;
955 *size = atoi((char *)info->pkg_info->package_size);
960 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
963 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
964 long long rw_size = 0;
965 long long ro_size = 0;
966 long long tmp_size = 0;
967 long long total_size = 0;
968 struct stat fileinfo;
971 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
972 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
974 ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
976 return PMINFO_R_ERROR;
979 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid);
980 if (lstat(device_path, &fileinfo) == 0) {
981 if (!S_ISLNK(fileinfo.st_mode)) {
982 tmp_size = _pkgmgr_calculate_dir_size(device_path);
988 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid);
989 if (lstat(device_path, &fileinfo) == 0) {
990 if (!S_ISLNK(fileinfo.st_mode)) {
991 tmp_size = _pkgmgr_calculate_dir_size(device_path);
997 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid);
998 if (lstat(device_path, &fileinfo) == 0) {
999 if (!S_ISLNK(fileinfo.st_mode)) {
1000 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1002 rw_size += tmp_size;
1006 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
1007 if (lstat(device_path, &fileinfo) == 0) {
1008 if (!S_ISLNK(fileinfo.st_mode)) {
1009 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1011 rw_size += tmp_size;
1015 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_PATH, pkgid);
1016 if (lstat(device_path, &fileinfo) == 0) {
1017 if (!S_ISLNK(fileinfo.st_mode)) {
1018 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1020 rw_size += tmp_size;
1024 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_PATH, pkgid);
1025 if (lstat(device_path, &fileinfo) == 0) {
1026 if (!S_ISLNK(fileinfo.st_mode)) {
1027 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1029 rw_size += tmp_size;
1034 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_PATH, pkgid);
1035 if (lstat(device_path, &fileinfo) == 0) {
1036 if (!S_ISLNK(fileinfo.st_mode)) {
1037 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1039 ro_size += tmp_size;
1043 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid);
1044 if (lstat(device_path, &fileinfo) == 0) {
1045 if (!S_ISLNK(fileinfo.st_mode)) {
1046 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1048 ro_size += tmp_size;
1052 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid);
1053 if (lstat(device_path, &fileinfo) == 0) {
1054 if (!S_ISLNK(fileinfo.st_mode)) {
1055 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1057 ro_size += tmp_size;
1061 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid);
1062 if (lstat(device_path, &fileinfo) == 0) {
1063 if (!S_ISLNK(fileinfo.st_mode)) {
1064 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1066 ro_size += tmp_size;
1070 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid);
1071 if (lstat(device_path, &fileinfo) == 0) {
1072 if (!S_ISLNK(fileinfo.st_mode)) {
1073 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1075 ro_size += tmp_size;
1079 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid);
1080 if (lstat(device_path, &fileinfo) == 0) {
1081 if (!S_ISLNK(fileinfo.st_mode)) {
1082 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1084 ro_size += tmp_size;
1089 total_size = rw_size + ro_size;
1090 *size = (int)total_size;
1095 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
1098 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
1099 long long total_size = 0;
1101 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1102 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1104 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid) < 0)
1105 return PMINFO_R_ERROR;
1107 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
1108 if (access(device_path, R_OK) == 0)
1109 total_size = _pkgmgr_calculate_dir_size(device_path);
1111 return PMINFO_R_ERROR;
1113 *size = (int)total_size;
1118 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
1122 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1124 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
1125 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1127 locale = info->locale;
1128 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1130 for (ptr = info->pkg_info->icon; ptr != NULL; ptr = ptr->next) {
1131 if (ptr->lang == NULL)
1134 if (strcmp(ptr->lang, locale) == 0) {
1135 *icon = (char *)ptr->text;
1136 if (strcasecmp(*icon, "(null)") == 0) {
1137 locale = DEFAULT_LOCALE;
1142 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
1143 *icon = (char *)ptr->text;
1148 return PMINFO_R_ERROR;
1151 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
1155 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1157 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
1158 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1160 locale = info->locale;
1161 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1163 for (ptr = info->pkg_info->label; ptr != NULL; ptr = ptr->next) {
1164 if (ptr->lang == NULL)
1167 if (strcmp(ptr->lang, locale) == 0) {
1168 *label = (char *)ptr->text;
1169 if (strcasecmp(*label, "(null)") == 0) {
1170 locale = DEFAULT_LOCALE;
1175 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
1176 *label = (char *)ptr->text;
1181 return PMINFO_R_ERROR;
1184 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
1188 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1190 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1191 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1193 locale = info->locale;
1194 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1196 for (ptr = info->pkg_info->description; ptr != NULL; ptr = ptr->next) {
1197 if (ptr->lang == NULL)
1200 if (strcmp(ptr->lang, locale) == 0) {
1201 *description = (char *)ptr->text;
1202 if (strcasecmp(*description, PKGMGR_PARSER_EMPTY_STR) == 0) {
1203 locale = DEFAULT_LOCALE;
1208 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
1209 *description = (char *)ptr->text;
1214 return PMINFO_R_ERROR;
1217 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
1219 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1221 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1222 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1224 if (info->pkg_info == NULL || info->pkg_info->author == NULL ||
1225 info->pkg_info->author->text == NULL)
1226 return PMINFO_R_ERROR;
1228 *author_name = (char *)info->pkg_info->author->text;
1233 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
1235 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1237 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1238 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1240 if (info->pkg_info == NULL || info->pkg_info->author == NULL ||
1241 info->pkg_info->author->email == NULL)
1242 return PMINFO_R_ERROR;
1244 *author_email = (char *)info->pkg_info->author->email;
1249 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
1251 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1253 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1254 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1256 if (info->pkg_info == NULL || info->pkg_info->author == NULL ||
1257 info->pkg_info->author->href == NULL)
1258 return PMINFO_R_ERROR;
1260 *author_href = (char *)info->pkg_info->author->href;
1265 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
1267 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1269 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1270 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1272 if (info->pkg_info == NULL || info->pkg_info->installed_storage == NULL)
1273 return PMINFO_R_ERROR;
1275 if (strcmp(info->pkg_info->installed_storage,"installed_internal") == 0)
1276 *storage = PMINFO_INTERNAL_STORAGE;
1277 else if (strcmp(info->pkg_info->installed_storage,"installed_external") == 0)
1278 *storage = PMINFO_EXTERNAL_STORAGE;
1280 return PMINFO_R_ERROR;
1285 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
1287 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1289 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1290 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1292 if (info->pkg_info == NULL || info->pkg_info->installed_time == NULL)
1293 return PMINFO_R_ERROR;
1295 *installed_time = atoi(info->pkg_info->installed_time);
1300 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
1302 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1304 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1305 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1307 if (info->pkg_info == NULL || info->pkg_info->storeclient_id == NULL)
1308 return PMINFO_R_ERROR;
1310 *storeclientid = (char *)info->pkg_info->storeclient_id;
1315 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
1317 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1319 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1320 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1322 if (info->pkg_info == NULL || info->pkg_info->mainapp_id == NULL)
1323 return PMINFO_R_ERROR;
1325 *mainappid = (char *)info->pkg_info->mainapp_id;
1330 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
1332 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1334 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1335 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1337 if (info->pkg_info == NULL || info->pkg_info->package_url == NULL)
1338 return PMINFO_R_ERROR;
1340 *url = (char *)info->pkg_info->package_url;
1345 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
1347 const char *val = NULL;
1348 const xmlChar *node;
1349 xmlTextReaderPtr reader;
1350 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
1351 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1354 reader = xmlReaderForFile(manifest, NULL, 0);
1357 if (__child_element(reader, -1)) {
1358 node = xmlTextReaderConstName(reader);
1360 _LOGE("xmlTextReaderConstName value is NULL\n");
1361 xmlFreeTextReader(reader);
1363 return PMINFO_R_ERROR;
1366 if (!strcmp(ASC_CHAR(node), "manifest")) {
1367 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
1368 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
1374 _LOGE("package size is not specified\n");
1375 xmlFreeTextReader(reader);
1377 return PMINFO_R_ERROR;
1380 _LOGE("Unable to create xml reader\n");
1381 xmlFreeTextReader(reader);
1383 return PMINFO_R_ERROR;
1387 _LOGE("xmlReaderForFile value is NULL\n");
1389 return PMINFO_R_ERROR;
1392 xmlFreeTextReader(reader);
1398 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
1400 const char *val = NULL;
1401 const xmlChar *node;
1402 xmlTextReaderPtr reader;
1403 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
1404 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1407 reader = xmlReaderForFile(manifest, NULL, 0);
1410 if ( __child_element(reader, -1)) {
1411 node = xmlTextReaderConstName(reader);
1413 _LOGE("xmlTextReaderConstName value is NULL\n");
1414 xmlFreeTextReader(reader);
1416 return PMINFO_R_ERROR;
1419 if (!strcmp(ASC_CHAR(node), "manifest")) {
1420 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
1421 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
1424 if (strcmp(val, "internal-only") == 0)
1425 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
1426 else if (strcmp(val, "prefer-external") == 0)
1427 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
1429 *location = PMINFO_INSTALL_LOCATION_AUTO;
1432 _LOGE("Unable to create xml reader\n");
1433 xmlFreeTextReader(reader);
1435 return PMINFO_R_ERROR;
1439 _LOGE("xmlReaderForFile value is NULL\n");
1441 return PMINFO_R_ERROR;
1444 xmlFreeTextReader(reader);
1451 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
1453 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1455 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1456 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1458 if (info->pkg_info == NULL || info->pkg_info->root_path == NULL)
1459 return PMINFO_R_ERROR;
1461 *path = (char *)info->pkg_info->root_path;
1466 API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
1468 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1470 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1471 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1473 if (info->pkg_info == NULL || info->pkg_info->csc_path == NULL)
1474 return PMINFO_R_ERROR;
1476 *path = (char *)info->pkg_info->csc_path;
1482 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
1484 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1485 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1487 #if 0 //smack issue occured, check later
1489 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
1491 _LOGD("invalid func parameters\n");
1492 return PMINFO_R_ERROR;
1494 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
1497 char app_mmc_path[FILENAME_MAX] = { 0, };
1498 char app_dir_path[FILENAME_MAX] = { 0, };
1499 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
1500 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
1501 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
1502 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
1504 /*check whether application is in external memory or not */
1505 fp = fopen(app_mmc_path, "r");
1507 _LOGD(" app path in external memory not accesible\n");
1512 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
1516 /*check whether application is in internal or not */
1517 fp = fopen(app_dir_path, "r");
1519 _LOGD(" app path in internal memory not accesible\n");
1521 return PMINFO_R_ERROR;
1524 /*check whether the application is installed in SD card
1525 but SD card is not present*/
1526 fp = fopen(app_mmc_internal_path, "r");
1529 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
1534 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
1539 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
1546 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
1549 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1551 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1552 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1554 if (info->pkg_info == NULL || info->pkg_info->removable == NULL)
1555 return PMINFO_R_ERROR;
1557 val = (char *)info->pkg_info->removable;
1558 if (strcasecmp(val, "true") == 0)
1560 else if (strcasecmp(val, "false") == 0)
1568 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
1571 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1573 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1574 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1576 if (info->pkg_info == NULL || info->pkg_info->installlocation == NULL)
1577 return PMINFO_R_ERROR;
1579 val = (char *)info->pkg_info->installlocation;
1580 if (strcmp(val, "internal-only") == 0)
1582 else if (strcmp(val, "prefer-external") == 0)
1590 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
1593 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1595 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1596 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1598 if (info->pkg_info == NULL || info->pkg_info->preload == NULL)
1599 return PMINFO_R_ERROR;
1601 val = (char *)info->pkg_info->preload;
1602 if (strcasecmp(val, "true") == 0)
1604 else if (strcasecmp(val, "false") == 0)
1612 API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
1615 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1617 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1618 retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1620 if (info->pkg_info == NULL || info->pkg_info->system == NULL)
1621 return PMINFO_R_ERROR;
1623 val = (char *)info->pkg_info->system;
1624 if (strcasecmp(val, "true") == 0)
1626 else if (strcasecmp(val, "false") == 0)
1634 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
1637 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1639 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1640 retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1642 if (info->pkg_info == NULL || info->pkg_info->readonly == NULL)
1643 return PMINFO_R_ERROR;
1645 val = (char *)info->pkg_info->readonly;
1646 if (strcasecmp(val, "true") == 0)
1648 else if (strcasecmp(val, "false") == 0)
1656 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
1659 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1661 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1662 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1664 if (info->pkg_info == NULL || info->pkg_info->update == NULL)
1665 return PMINFO_R_ERROR;
1667 val = (char *)info->pkg_info->update;
1668 if (strcasecmp(val, "true") == 0)
1670 else if (strcasecmp(val, "false") == 0)
1678 API int pkgmgrinfo_pkginfo_is_support_disable(pkgmgrinfo_pkginfo_h handle, bool *support_disable)
1681 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1683 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1684 retvm_if(support_disable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1686 if (info->pkg_info == NULL || info->pkg_info->support_disable == NULL)
1687 return PMINFO_R_ERROR;
1689 val = (char *)info->pkg_info->support_disable;
1690 if (strcasecmp(val, "true") == 0)
1691 *support_disable = 1;
1692 else if (strcasecmp(val, "false") == 0)
1693 *support_disable = 0;
1695 *support_disable = 1;
1700 API int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users)
1703 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1705 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1706 retvm_if(for_all_users == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1708 if (info->pkg_info == NULL || info->pkg_info->for_all_users == NULL)
1709 return PMINFO_R_ERROR;
1711 val = (char *)info->pkg_info->for_all_users;
1712 if (strcasecmp(val, "true") == 0)
1714 else if (strcasecmp(val, "false") == 0)
1722 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
1724 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1726 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1728 __cleanup_pkginfo(info);
1733 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
1735 pkgmgrinfo_filter_x *filter;
1737 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
1739 filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
1740 if (filter == NULL) {
1741 _LOGE("Out of Memory!!!");
1742 return PMINFO_R_ERROR;
1750 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
1752 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1754 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1757 g_slist_foreach(filter->list, __destroy_each_node, NULL);
1758 g_slist_free(filter->list);
1766 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
1767 const char *property, const int value)
1769 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
1773 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1774 pkgmgrinfo_node_x *node;
1776 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1777 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1779 prop = _pminfo_pkginfo_convert_to_prop_int(property);
1780 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
1781 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
1782 _LOGE("Invalid Integer Property\n");
1783 return PMINFO_R_EINVAL;
1785 node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
1787 _LOGE("Out of Memory!!!\n");
1788 return PMINFO_R_ERROR;
1790 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
1791 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
1793 _LOGE("Out of Memory\n");
1795 return PMINFO_R_ERROR;
1799 /*If API is called multiple times for same property, we should override the previous values.
1800 Last value set will be used for filtering.*/
1801 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1803 filter->list = g_slist_delete_link(filter->list, link);
1804 filter->list = g_slist_append(filter->list, (gpointer)node);
1809 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
1810 const char *property, const bool value)
1815 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1816 pkgmgrinfo_node_x *node;
1818 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1819 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1821 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
1822 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
1823 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
1824 _LOGE("Invalid Boolean Property\n");
1825 return PMINFO_R_EINVAL;
1827 node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
1829 _LOGE("Out of Memory!!!\n");
1830 return PMINFO_R_ERROR;
1833 val = strndup("('true','True')", 15);
1835 val = strndup("('false','False')", 17);
1837 _LOGE("Out of Memory\n");
1839 return PMINFO_R_ERROR;
1843 /*If API is called multiple times for same property, we should override the previous values.
1844 Last value set will be used for filtering.*/
1845 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1847 filter->list = g_slist_delete_link(filter->list, link);
1848 filter->list = g_slist_append(filter->list, (gpointer)node);
1853 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
1854 const char *property, const char *value)
1859 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1860 pkgmgrinfo_node_x *node;
1862 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1863 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1864 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1866 prop = _pminfo_pkginfo_convert_to_prop_str(property);
1867 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
1868 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
1869 _LOGE("Invalid String Property\n");
1870 return PMINFO_R_EINVAL;
1872 node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
1874 _LOGE("Out of Memory!!!\n");
1875 return PMINFO_R_ERROR;
1877 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
1878 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
1879 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
1880 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
1881 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
1882 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
1883 else if (strcmp(value, "installed_internal") == 0)
1884 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
1885 else if (strcmp(value, "installed_external") == 0)
1886 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
1888 val = strndup(value, PKG_STRING_LEN_MAX - 1);
1890 _LOGE("Out of Memory\n");
1892 return PMINFO_R_ERROR;
1896 /*If API is called multiple times for same property, we should override the previous values.
1897 Last value set will be used for filtering.*/
1898 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1900 filter->list = g_slist_delete_link(filter->list, link);
1901 filter->list = g_slist_append(filter->list, (gpointer)node);
1906 API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count, uid_t uid)
1908 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1909 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1910 char *locale = NULL;
1911 char *condition = NULL;
1912 char *error_message = NULL;
1913 char query[MAX_QUERY_LEN] = {'\0'};
1914 char where[MAX_QUERY_LEN] = {'\0'};
1918 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
1920 /*Get current locale*/
1921 locale = _get_system_locale();
1922 if (locale == NULL) {
1923 _LOGE("manifest locale is NULL\n");
1924 return PMINFO_R_ERROR;
1927 ret = __open_manifest_db(uid, true);
1929 _LOGE("Fail to open manifest DB\n");
1931 return PMINFO_R_ERROR;
1934 /*Start constructing query*/
1935 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_PACKAGE, locale);
1937 /*Get where clause*/
1938 for (list = filter->list; list; list = g_slist_next(list)) {
1939 __get_filter_condition(list->data, &condition);
1941 strncat(where, condition, sizeof(where) - strlen(where) -1);
1942 where[sizeof(where) - 1] = '\0';
1946 if (g_slist_next(list)) {
1947 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
1948 where[sizeof(where) - 1] = '\0';
1951 if (strlen(where) > 0) {
1952 strncat(query, where, sizeof(query) - strlen(query) - 1);
1953 query[sizeof(query) - 1] = '\0';
1958 sqlite3_exec(GET_DB(manifest_db), query, __count_cb, (void *)count, &error_message)) {
1959 _LOGE("Don't execute query = %s error message = %s\n", query,
1961 sqlite3_free(error_message);
1962 ret = PMINFO_R_ERROR;
1972 __close_manifest_db();
1976 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
1978 return pkgmgrinfo_pkginfo_usr_filter_count(handle, count, GLOBAL_USER);
1981 API int pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(
1982 pkgmgrinfo_pkginfo_filter_h handle,
1983 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
1985 if (handle == NULL || pkg_cb == NULL) {
1986 LOGE("invalid parameter");
1987 return PMINFO_R_EINVAL;
1990 return _pkginfo_get_filtered_foreach_pkginfo(handle, pkg_cb, user_data,
1994 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
1995 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
1997 return pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, pkg_cb, user_data, GLOBAL_USER);
2000 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
2001 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
2003 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
2004 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2006 privilege_x *ptr = NULL;
2007 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
2008 ptr = info->pkg_info->privileges->privilege;
2009 for (; ptr; ptr = ptr->next) {
2011 ret = privilege_func(ptr->text, user_data);
2019 API int pkgmgrinfo_create_pkgusrdbinfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkgdbinfo_h *handle)
2021 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
2022 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2024 char *manifest = NULL;
2025 manifest_x *mfx = NULL;
2027 manifest = pkgmgr_parser_get_usr_manifest_file(pkgid, uid);
2028 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
2030 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
2035 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
2037 *handle = (void *)mfx;
2042 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
2044 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
2045 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2047 char *manifest = NULL;
2048 manifest_x *mfx = NULL;
2050 manifest = pkgmgr_parser_get_manifest_file(pkgid);
2051 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
2053 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2058 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
2060 *handle = (void *)mfx;
2065 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
2068 manifest_x *mfx = (manifest_x *)handle;
2070 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
2071 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2074 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2077 free((void *)mfx->type);
2079 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
2084 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
2087 manifest_x *mfx = (manifest_x *)handle;
2089 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
2090 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2092 len = strlen(version);
2093 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2096 free((void *)mfx->version);
2098 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
2102 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
2104 manifest_x *mfx = (manifest_x *)handle;
2106 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2107 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2109 if (mfx->installlocation)
2110 free((void *)mfx->installlocation);
2112 if (location == INSTALL_INTERNAL)
2113 mfx->installlocation = strdup("internal-only");
2114 else if (location == INSTALL_EXTERNAL)
2115 mfx->installlocation = strdup("prefer-external");
2120 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
2122 manifest_x *mfx = (manifest_x *)handle;
2124 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2125 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
2127 if (mfx->package_size)
2128 free((void *)mfx->package_size);
2130 mfx->package_size = strdup(size);
2135 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
2138 manifest_x *mfx = (manifest_x *)handle;
2141 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2142 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
2144 len = strlen(label_txt);
2145 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2147 label = calloc(1, sizeof(label_x));
2148 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
2150 LISTADD(mfx->label, label);
2152 mfx->label->lang = strdup(locale);
2154 mfx->label->lang = strdup(DEFAULT_LOCALE);
2155 mfx->label->text = strdup(label_txt);
2160 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
2163 manifest_x *mfx = (manifest_x *)handle;
2166 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2167 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
2169 len = strlen(icon_txt);
2170 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2172 icon = calloc(1, sizeof(icon_x));
2173 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
2175 LISTADD(mfx->icon, icon);
2177 mfx->icon->lang = strdup(locale);
2179 mfx->icon->lang = strdup(DEFAULT_LOCALE);
2180 mfx->icon->text = strdup(icon_txt);
2185 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
2187 int len = strlen(desc_txt);
2188 manifest_x *mfx = (manifest_x *)handle;
2189 description_x *description;
2191 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2192 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
2194 len = strlen(desc_txt);
2195 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2197 description = calloc(1, sizeof(description_x));
2198 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
2200 LISTADD(mfx->description, description);
2202 mfx->description->lang = strdup(locale);
2204 mfx->description->lang = strdup(DEFAULT_LOCALE);
2205 mfx->description->text = strdup(desc_txt);
2210 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
2211 const char *author_email, const char *author_href, const char *locale)
2213 manifest_x *mfx = (manifest_x *)handle;
2216 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2218 author = calloc(1, sizeof(author_x));
2219 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
2221 LISTADD(mfx->author, author);
2223 mfx->author->text = strdup(author_name);
2225 mfx->author->email = strdup(author_email);
2227 mfx->author->href = strdup(author_href);
2229 mfx->author->lang = strdup(locale);
2231 mfx->author->lang = strdup(DEFAULT_LOCALE);
2235 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
2237 manifest_x *mfx = (manifest_x *)handle;
2239 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2240 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2243 free((void *)mfx->removable);
2246 mfx->removable = strdup("false");
2247 else if (removable == 1)
2248 mfx->removable = strdup("true");
2253 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
2255 manifest_x *mfx = (manifest_x *)handle;
2257 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2258 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2261 free((void *)mfx->preload);
2264 mfx->preload = strdup("false");
2265 else if (preload == 1)
2266 mfx->preload = strdup("true");
2271 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
2273 manifest_x *mfx = (manifest_x *)handle;
2275 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2276 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2278 if (mfx->installed_storage)
2279 free((void *)mfx->installed_storage);
2281 if (location == INSTALL_INTERNAL)
2282 mfx->installed_storage = strdup("installed_internal");
2283 else if (location == INSTALL_EXTERNAL)
2284 mfx->installed_storage = strdup("installed_external");
2289 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
2292 manifest_x *mfx = (manifest_x *)handle;
2293 mfx = (manifest_x *)handle;
2295 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2297 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
2299 _LOGE("Successfully stored info in DB\n");
2302 _LOGE("Failed to store info in DB\n");
2303 return PMINFO_R_ERROR;
2307 API int pkgmgrinfo_save_pkgusrdbinfo(pkgmgrinfo_pkgdbinfo_h handle, uid_t uid)
2310 manifest_x *mfx = (manifest_x *)handle;
2312 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2314 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
2316 _LOGE("Successfully stored info in DB\n");
2319 _LOGE("Failed to store info in DB\n");
2320 return PMINFO_R_ERROR;
2324 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
2326 manifest_x *mfx = (manifest_x *)handle;
2328 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2330 pkgmgrinfo_basic_free_package(mfx);