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 static int _pkginfo_get_pkginfo(const char *pkgid, uid_t uid,
50 pkgmgr_pkginfo_x **pkginfo);
51 static char *_get_filtered_query(const char *query_raw,
52 pkgmgrinfo_filter_x *filter);
54 static gint __compare_func(gconstpointer data1, gconstpointer data2)
56 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
57 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
58 if (node1->prop == node2->prop)
60 else if (node1->prop > node2->prop)
66 static void __destroy_each_node(gpointer data, gpointer user_data)
69 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
82 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
86 free((void *)data->locale);
90 pkgmgrinfo_basic_free_package(data->pkg_info);
96 static int __child_element(xmlTextReaderPtr reader, int depth)
98 int ret = xmlTextReaderRead(reader);
99 int cur = xmlTextReaderDepth(reader);
102 switch (xmlTextReaderNodeType(reader)) {
103 case XML_READER_TYPE_ELEMENT:
104 if (cur == depth + 1)
107 case XML_READER_TYPE_TEXT:
108 /*text is handled by each function separately*/
109 if (cur == depth + 1)
112 case XML_READER_TYPE_END_ELEMENT:
121 ret = xmlTextReaderRead(reader);
122 cur = xmlTextReaderDepth(reader);
127 long long _pkgmgr_calculate_dir_size(char *dirname)
131 int q = 0; /*quotient*/
132 int r = 0; /*remainder*/
134 struct dirent *ep = NULL;
135 struct stat fileinfo;
136 char abs_filename[FILENAME_MAX] = { 0, };
137 retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL");
139 dp = opendir(dirname);
141 while ((ep = readdir(dp)) != NULL) {
142 if (!strcmp(ep->d_name, ".") ||
143 !strcmp(ep->d_name, "..")) {
146 snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
148 if (lstat(abs_filename, &fileinfo) < 0)
149 perror(abs_filename);
151 if (S_ISDIR(fileinfo.st_mode)) {
152 total += fileinfo.st_size;
153 if (strcmp(ep->d_name, ".")
154 && strcmp(ep->d_name, "..")) {
155 ret = _pkgmgr_calculate_dir_size
159 } else if (S_ISLNK(fileinfo.st_mode)) {
162 /*It is a file. Calculate the actual
163 size occupied (in terms of 4096 blocks)*/
164 q = (fileinfo.st_size / BLOCK_SIZE);
165 r = (fileinfo.st_size % BLOCK_SIZE);
169 total += q * BLOCK_SIZE;
175 _LOGE("Couldn't open the directory\n");
182 static gint __list_strcmp(gconstpointer a, gconstpointer b)
184 return strcmp((char *)a, (char *)b);
187 static int _pkginfo_get_list(sqlite3 *db, const char *locale,
188 pkgmgrinfo_filter_x *filter, GList **list)
190 static const char query_raw[] =
191 "SELECT DISTINCT package_info.package FROM package_info"
192 " LEFT OUTER JOIN package_localized_info"
193 " ON package_info.package=package_localized_info.package"
194 " AND package_localized_info.package_locale=%Q "
195 " LEFT OUTER JOIN package_privilege_info"
196 " ON package_info.package=package_privilege_info.package";
199 char *query_localized;
203 query = _get_filtered_query(query_raw, filter);
206 query_localized = sqlite3_mprintf(query, locale);
208 if (query_localized == NULL)
211 ret = sqlite3_prepare_v2(db, query_localized,
212 strlen(query_localized), &stmt, NULL);
213 sqlite3_free(query_localized);
214 if (ret != SQLITE_OK) {
215 LOGE("prepare failed: %s", sqlite3_errmsg(db));
219 while (sqlite3_step(stmt) == SQLITE_ROW) {
220 _save_column_str(stmt, 0, (const char **)&pkgid);
222 *list = g_list_insert_sorted(*list, pkgid,
226 sqlite3_finalize(stmt);
231 static int _pkginfo_get_filtered_list(pkgmgrinfo_filter_x *filter, uid_t uid,
241 locale = _get_system_locale();
243 return PMINFO_R_ERROR;
245 dbpath = getUserPkgParserDBPathUID(uid);
246 if (dbpath == NULL) {
248 return PMINFO_R_ERROR;
251 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
252 if (ret != SQLITE_OK) {
253 _LOGE("failed to open db: %d", ret);
255 return PMINFO_R_ERROR;
258 if (_pkginfo_get_list(db, locale, filter, list)) {
260 sqlite3_close_v2(db);
261 return PMINFO_R_ERROR;
263 sqlite3_close_v2(db);
265 if (uid == GLOBAL_USER) {
270 /* search again from global */
271 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
272 if (dbpath == NULL) {
274 return PMINFO_R_ERROR;
277 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
278 if (ret != SQLITE_OK) {
279 _LOGE("failed to open db: %d", ret);
281 return PMINFO_R_ERROR;
284 if (_pkginfo_get_list(db, locale, filter, list)) {
286 sqlite3_close_v2(db);
287 return PMINFO_R_ERROR;
289 sqlite3_close_v2(db);
291 /* remove duplicate element:
292 * since the list is sorted, we can remove duplicates in linear time
294 for (tmp = *list, tmp2 = g_list_next(tmp); tmp;
295 tmp = tmp2, tmp2 = g_list_next(tmp)) {
296 if (tmp->prev == NULL || tmp->data == NULL)
298 if (strcmp((const char *)tmp->prev->data,
299 (const char *)tmp->data) == 0)
300 *list = g_list_delete_link(*list, tmp);
307 static int _pkginfo_get_filtered_foreach_pkginfo(pkgmgrinfo_filter_x *filter,
308 pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
311 pkgmgr_pkginfo_x *info;
317 ret = _pkginfo_get_filtered_list(filter, uid, &list);
318 if (ret != PMINFO_R_OK)
319 return PMINFO_R_ERROR;
321 for (tmp = list; tmp; tmp = tmp->next) {
322 pkgid = (char *)tmp->data;
324 ret = _pkginfo_get_pkginfo(pkgid, uid, &info);
325 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
326 ret = _pkginfo_get_pkginfo(pkgid, GLOBAL_USER,
328 if (ret != PMINFO_R_OK) {
332 if (pkg_list_cb(info, user_data) < 0)
334 pkgmgrinfo_pkginfo_destroy_pkginfo(info);
344 API int pkgmgrinfo_pkginfo_get_usr_list(pkgmgrinfo_pkg_list_cb pkg_list_cb,
345 void *user_data, uid_t uid)
347 if (pkg_list_cb == NULL) {
348 LOGE("invalid parameter");
349 return PMINFO_R_EINVAL;
352 return _pkginfo_get_filtered_foreach_pkginfo(NULL, pkg_list_cb,
356 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
358 return pkgmgrinfo_pkginfo_get_usr_list(pkg_list_cb, user_data, GLOBAL_USER);
361 static int _pkginfo_get_author(sqlite3 *db, const char *pkgid,
364 static const char query_raw[] =
365 "SELECT author_name, author_email, author_href "
366 "FROM package_info WHERE package=%Q";
373 query = sqlite3_mprintf(query_raw, pkgid);
375 LOGE("out of memory");
376 return PMINFO_R_ERROR;
379 ret = sqlite3_prepare_v2(db, query, strlen(query),
382 if (ret != SQLITE_OK) {
383 LOGE("prepare failed: %s", sqlite3_errmsg(db));
384 return PMINFO_R_ERROR;
387 if (sqlite3_step(stmt) == SQLITE_ERROR) {
388 LOGE("step error: %s", sqlite3_errmsg(db));
389 sqlite3_finalize(stmt);
390 return PMINFO_R_ERROR;
393 /* one author per one package */
394 info = calloc(1, sizeof(author_x));
396 LOGE("out of memory");
397 sqlite3_finalize(stmt);
398 return PMINFO_R_ERROR;
401 _save_column_str(stmt, idx++, &info->text);
402 _save_column_str(stmt, idx++, &info->email);
403 _save_column_str(stmt, idx++, &info->href);
407 sqlite3_finalize(stmt);
412 static int _pkginfo_get_label(sqlite3 *db, const char *pkgid,
413 const char *locale, label_x **label)
415 static const char query_raw[] =
416 "SELECT package_label, package_locale "
417 "FROM package_localized_info "
418 "WHERE package=%Q AND package_locale IN (%Q, %Q)";
425 query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
427 LOGE("out of memory");
428 return PMINFO_R_ERROR;
431 ret = sqlite3_prepare_v2(db, query, strlen(query),
434 if (ret != SQLITE_OK) {
435 LOGE("prepare failed: %s", sqlite3_errmsg(db));
436 return PMINFO_R_ERROR;
439 while (sqlite3_step(stmt) == SQLITE_ROW) {
440 info = calloc(1, sizeof(label_x));
442 LOGE("out of memory");
443 sqlite3_finalize(stmt);
445 LISTHEAD(*label, info);
448 return PMINFO_R_ERROR;
451 _save_column_str(stmt, idx++, &info->text);
452 _save_column_str(stmt, idx++, &info->lang);
453 LISTADD(*label, info);
457 LISTHEAD(*label, info);
461 sqlite3_finalize(stmt);
466 static int _pkginfo_get_icon(sqlite3 *db, const char *pkgid, const char *locale,
469 static const char query_raw[] =
470 "SELECT package_icon, package_locale "
471 "FROM package_localized_info "
472 "WHERE package=%Q AND package_locale IN (%Q, %Q)";
479 query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
481 LOGE("out of memory");
482 return PMINFO_R_ERROR;
485 ret = sqlite3_prepare_v2(db, query, strlen(query),
488 if (ret != SQLITE_OK) {
489 LOGE("prepare failed: %s", sqlite3_errmsg(db));
490 return PMINFO_R_ERROR;
493 while (sqlite3_step(stmt) == SQLITE_ROW) {
494 info = calloc(1, sizeof(icon_x));
496 LOGE("out of memory");
497 sqlite3_finalize(stmt);
499 LISTHEAD(*icon, info);
502 return PMINFO_R_ERROR;
505 _save_column_str(stmt, idx++, &info->text);
506 _save_column_str(stmt, idx++, &info->lang);
507 LISTADD(*icon, info);
511 LISTHEAD(*icon, info);
515 sqlite3_finalize(stmt);
520 static int _pkginfo_get_description(sqlite3 *db, const char *pkgid,
521 const char *locale, description_x **description)
523 static const char query_raw[] =
524 "SELECT package_description, package_locale "
525 "FROM package_localized_info "
526 "WHERE package=%Q AND package_locale IN (%Q, %Q)";
533 query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
535 LOGE("out of memory");
536 return PMINFO_R_ERROR;
539 ret = sqlite3_prepare_v2(db, query, strlen(query),
542 if (ret != SQLITE_OK) {
543 LOGE("prepare failed: %s", sqlite3_errmsg(db));
544 return PMINFO_R_ERROR;
547 while (sqlite3_step(stmt) == SQLITE_ROW) {
548 info = calloc(1, sizeof(description_x));
550 LOGE("out of memory");
551 sqlite3_finalize(stmt);
553 LISTHEAD(*description, info);
556 return PMINFO_R_ERROR;
559 _save_column_str(stmt, idx++, &info->text);
560 _save_column_str(stmt, idx++, &info->lang);
561 LISTADD(*description, info);
565 LISTHEAD(*description, info);
569 sqlite3_finalize(stmt);
574 static int _pkginfo_get_privilege(sqlite3 *db, const char *pkgid,
575 privileges_x **privileges)
577 static const char query_raw[] =
578 "SELECT privilege FROM package_privilege_info WHERE package=%Q";
585 /* privilege list should stored in privileges_x... */
586 p = calloc(1, sizeof(privileges_x));
588 LOGE("out of memory");
589 return PMINFO_R_ERROR;
593 query = sqlite3_mprintf(query_raw, pkgid);
595 LOGE("out of memory");
597 return PMINFO_R_ERROR;
600 ret = sqlite3_prepare_v2(db, query, strlen(query),
603 if (ret != SQLITE_OK) {
604 LOGE("prepare failed: %s", sqlite3_errmsg(db));
606 return PMINFO_R_ERROR;
609 while (sqlite3_step(stmt) == SQLITE_ROW) {
610 info = calloc(1, sizeof(privilege_x));
612 LOGE("out of memory");
613 sqlite3_finalize(stmt);
615 LISTHEAD(p->privilege, info);
618 return PMINFO_R_ERROR;
620 _save_column_str(stmt, 0, &info->text);
621 LISTADD(p->privilege, info);
625 LISTHEAD(p->privilege, info);
629 sqlite3_finalize(stmt);
634 static char *_get_filtered_query(const char *query_raw,
635 pkgmgrinfo_filter_x *filter)
637 char buf[MAX_QUERY_LEN] = { 0, };
646 strncat(buf, query_raw, MAX_QUERY_LEN - 1);
648 for (list = head; list; list = list->next) {
649 /* TODO: revise condition getter function */
650 __get_filter_condition(list->data, &condition);
651 if (condition == NULL)
653 if (buf[strlen(query_raw)] == '\0') {
654 len += strlen(" WHERE ");
655 strncat(buf, " WHERE ", MAX_QUERY_LEN - len - 1);
657 len += strlen(" AND ");
658 strncat(buf, " AND ", MAX_QUERY_LEN -len - 1);
660 len += strlen(condition);
661 strncat(buf, condition, sizeof(buf) - len - 1);
669 static int _pkginfo_get_package(sqlite3 *db, const char *pkgid,
670 const char *locale, package_x **package)
672 static const char query_raw[] =
673 "SELECT package, package_version, "
674 "install_location, package_removable, package_preload, "
675 "package_readonly, package_update, package_appsetting, "
676 "package_system, package_type, package_size, installed_time, "
677 "installed_storage, storeclient_id, mainapp_id, package_url, "
678 "root_path, csc_path, package_nodisplay, package_api_version, "
679 "package_support_disable "
680 "FROM package_info WHERE package=%Q";
687 query = sqlite3_mprintf(query_raw, pkgid);
689 LOGE("out of memory");
690 return PMINFO_R_ERROR;
693 ret = sqlite3_prepare_v2(db, query, strlen(query),
696 if (ret != SQLITE_OK) {
697 LOGE("prepare failed: %s", sqlite3_errmsg(db));
698 return PMINFO_R_ERROR;
701 ret = sqlite3_step(stmt);
702 if (ret == SQLITE_DONE) {
703 sqlite3_finalize(stmt);
704 return PMINFO_R_ENOENT;
705 } else if (ret != SQLITE_ROW) {
706 LOGE("step failed: %s", sqlite3_errmsg(db));
707 sqlite3_finalize(stmt);
708 return PMINFO_R_ERROR;
711 info = calloc(1, sizeof(package_x));
713 LOGE("out of memory");
714 sqlite3_finalize(stmt);
715 return PMINFO_R_ERROR;
718 _save_column_str(stmt, idx++, &info->package);
719 _save_column_str(stmt, idx++, &info->version);
720 _save_column_str(stmt, idx++, &info->installlocation);
721 _save_column_str(stmt, idx++, &info->removable);
722 _save_column_str(stmt, idx++, &info->preload);
723 _save_column_str(stmt, idx++, &info->readonly);
724 _save_column_str(stmt, idx++, &info->update);
725 _save_column_str(stmt, idx++, &info->appsetting);
726 _save_column_str(stmt, idx++, &info->system);
727 _save_column_str(stmt, idx++, &info->type);
728 _save_column_str(stmt, idx++, &info->package_size);
729 _save_column_str(stmt, idx++, &info->installed_time);
730 _save_column_str(stmt, idx++, &info->installed_storage);
731 _save_column_str(stmt, idx++, &info->storeclient_id);
732 _save_column_str(stmt, idx++, &info->mainapp_id);
733 _save_column_str(stmt, idx++, &info->package_url);
734 _save_column_str(stmt, idx++, &info->root_path);
735 _save_column_str(stmt, idx++, &info->csc_path);
736 _save_column_str(stmt, idx++, &info->nodisplay_setting);
737 _save_column_str(stmt, idx++, &info->api_version);
738 _save_column_str(stmt, idx++, &info->support_disable);
740 if (_pkginfo_get_author(db, info->package, &info->author)) {
741 pkgmgrinfo_basic_free_package(info);
742 sqlite3_finalize(stmt);
743 return PMINFO_R_ERROR;
746 if (_pkginfo_get_label(db, info->package, locale, &info->label)) {
747 pkgmgrinfo_basic_free_package(info);
748 sqlite3_finalize(stmt);
749 return PMINFO_R_ERROR;
752 if (_pkginfo_get_icon(db, info->package, locale, &info->icon)) {
753 pkgmgrinfo_basic_free_package(info);
754 sqlite3_finalize(stmt);
755 return PMINFO_R_ERROR;
758 if (_pkginfo_get_description(db, info->package, locale,
759 &info->description)) {
760 pkgmgrinfo_basic_free_package(info);
761 sqlite3_finalize(stmt);
762 return PMINFO_R_ERROR;
765 if (_pkginfo_get_privilege(db, info->package, &info->privileges)) {
766 pkgmgrinfo_basic_free_package(info);
767 sqlite3_finalize(stmt);
768 return PMINFO_R_ERROR;
772 sqlite3_finalize(stmt);
777 static int _pkginfo_get_pkginfo(const char *pkgid, uid_t uid,
778 pkgmgr_pkginfo_x **pkginfo)
784 pkgmgr_pkginfo_x *info;
786 dbpath = getUserPkgParserDBPathUID(uid);
788 return PMINFO_R_ERROR;
790 locale = _get_system_locale();
792 return PMINFO_R_ERROR;
794 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
795 if (ret != SQLITE_OK) {
796 _LOGE("failed to open db: %d", ret);
798 return PMINFO_R_ERROR;
801 info = calloc(1, sizeof(pkgmgr_pkginfo_x));
803 _LOGE("out of memory");
805 sqlite3_close_v2(db);
806 return PMINFO_R_ERROR;
809 ret = _pkginfo_get_package(db, pkgid, locale, &info->pkg_info);
810 if (ret == PMINFO_R_OK) {
811 info->locale = strdup(locale);
813 info->pkg_info->for_all_users = strdup(
814 uid != GLOBAL_USER ? "false" : "true");
820 sqlite3_close_v2(db);
825 API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid,
826 pkgmgrinfo_pkginfo_h *handle)
830 if (pkgid == NULL || handle == NULL) {
831 LOGE("invalid parameter");
832 return PMINFO_R_EINVAL;
835 ret = _pkginfo_get_pkginfo(pkgid, uid, (pkgmgr_pkginfo_x **)handle);
836 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
837 ret = _pkginfo_get_pkginfo(pkgid, GLOBAL_USER,
838 (pkgmgr_pkginfo_x **)handle);
840 if (ret != PMINFO_R_OK)
841 _LOGE("failed to get pkginfo of %s for user %d", pkgid, uid);
846 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
848 return pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, GLOBAL_USER, handle);
851 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
853 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
855 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
856 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
858 if (info->pkg_info == NULL || info->pkg_info->package == NULL)
859 return PMINFO_R_ERROR;
861 *pkg_name = (char *)info->pkg_info->package;
866 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
868 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
870 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
871 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
873 if (info->pkg_info == NULL || info->pkg_info->package == NULL)
874 return PMINFO_R_ERROR;
876 *pkgid = (char *)info->pkg_info->package;
881 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
883 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
885 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
886 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
888 if (info->pkg_info == NULL || info->pkg_info->type == NULL)
889 return PMINFO_R_ERROR;
891 *type = (char *)info->pkg_info->type;
896 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
898 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
900 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
901 retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
903 if (info->pkg_info == NULL || info->pkg_info->version == NULL)
904 return PMINFO_R_ERROR;
906 *version = (char *)info->pkg_info->version;
911 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
914 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
916 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
917 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
919 if (info->pkg_info == NULL || info->pkg_info->installlocation == NULL)
920 return PMINFO_R_ERROR;
922 val = (char *)info->pkg_info->installlocation;
923 if (strcmp(val, "internal-only") == 0)
924 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
925 else if (strcmp(val, "prefer-external") == 0)
926 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
928 *location = PMINFO_INSTALL_LOCATION_AUTO;
933 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
935 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
937 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
938 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
940 if (info->pkg_info == NULL || info->pkg_info->package_size == NULL)
941 return PMINFO_R_ERROR;
943 *size = atoi((char *)info->pkg_info->package_size);
948 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
951 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
952 long long rw_size = 0;
953 long long ro_size = 0;
954 long long tmp_size = 0;
955 long long total_size = 0;
956 struct stat fileinfo;
959 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
960 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
962 ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
964 return PMINFO_R_ERROR;
967 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid);
968 if (lstat(device_path, &fileinfo) == 0) {
969 if (!S_ISLNK(fileinfo.st_mode)) {
970 tmp_size = _pkgmgr_calculate_dir_size(device_path);
976 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid);
977 if (lstat(device_path, &fileinfo) == 0) {
978 if (!S_ISLNK(fileinfo.st_mode)) {
979 tmp_size = _pkgmgr_calculate_dir_size(device_path);
985 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid);
986 if (lstat(device_path, &fileinfo) == 0) {
987 if (!S_ISLNK(fileinfo.st_mode)) {
988 tmp_size = _pkgmgr_calculate_dir_size(device_path);
994 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
995 if (lstat(device_path, &fileinfo) == 0) {
996 if (!S_ISLNK(fileinfo.st_mode)) {
997 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1003 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_PATH, pkgid);
1004 if (lstat(device_path, &fileinfo) == 0) {
1005 if (!S_ISLNK(fileinfo.st_mode)) {
1006 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1008 rw_size += tmp_size;
1012 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_PATH, pkgid);
1013 if (lstat(device_path, &fileinfo) == 0) {
1014 if (!S_ISLNK(fileinfo.st_mode)) {
1015 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1017 rw_size += tmp_size;
1022 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_PATH, pkgid);
1023 if (lstat(device_path, &fileinfo) == 0) {
1024 if (!S_ISLNK(fileinfo.st_mode)) {
1025 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1027 ro_size += tmp_size;
1031 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid);
1032 if (lstat(device_path, &fileinfo) == 0) {
1033 if (!S_ISLNK(fileinfo.st_mode)) {
1034 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1036 ro_size += tmp_size;
1040 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid);
1041 if (lstat(device_path, &fileinfo) == 0) {
1042 if (!S_ISLNK(fileinfo.st_mode)) {
1043 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1045 ro_size += tmp_size;
1049 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid);
1050 if (lstat(device_path, &fileinfo) == 0) {
1051 if (!S_ISLNK(fileinfo.st_mode)) {
1052 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1054 ro_size += tmp_size;
1058 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid);
1059 if (lstat(device_path, &fileinfo) == 0) {
1060 if (!S_ISLNK(fileinfo.st_mode)) {
1061 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1063 ro_size += tmp_size;
1067 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid);
1068 if (lstat(device_path, &fileinfo) == 0) {
1069 if (!S_ISLNK(fileinfo.st_mode)) {
1070 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1072 ro_size += tmp_size;
1077 total_size = rw_size + ro_size;
1078 *size = (int)total_size;
1083 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
1086 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
1087 long long total_size = 0;
1089 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1090 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1092 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid) < 0)
1093 return PMINFO_R_ERROR;
1095 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
1096 if (access(device_path, R_OK) == 0)
1097 total_size = _pkgmgr_calculate_dir_size(device_path);
1099 return PMINFO_R_ERROR;
1101 *size = (int)total_size;
1106 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
1110 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1112 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
1113 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1115 locale = info->locale;
1116 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1118 for (ptr = info->pkg_info->icon; ptr != NULL; ptr = ptr->next) {
1119 if (ptr->lang == NULL)
1122 if (strcmp(ptr->lang, locale) == 0) {
1123 *icon = (char *)ptr->text;
1124 if (strcasecmp(*icon, "(null)") == 0) {
1125 locale = DEFAULT_LOCALE;
1130 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
1131 *icon = (char *)ptr->text;
1136 return PMINFO_R_ERROR;
1139 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
1143 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1145 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
1146 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1148 locale = info->locale;
1149 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1151 for (ptr = info->pkg_info->label; ptr != NULL; ptr = ptr->next) {
1152 if (ptr->lang == NULL)
1155 if (strcmp(ptr->lang, locale) == 0) {
1156 *label = (char *)ptr->text;
1157 if (strcasecmp(*label, "(null)") == 0) {
1158 locale = DEFAULT_LOCALE;
1163 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
1164 *label = (char *)ptr->text;
1169 return PMINFO_R_ERROR;
1172 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
1176 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1178 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1179 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1181 locale = info->locale;
1182 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1184 for (ptr = info->pkg_info->description; ptr != NULL; ptr = ptr->next) {
1185 if (ptr->lang == NULL)
1188 if (strcmp(ptr->lang, locale) == 0) {
1189 *description = (char *)ptr->text;
1190 if (strcasecmp(*description, PKGMGR_PARSER_EMPTY_STR) == 0) {
1191 locale = DEFAULT_LOCALE;
1196 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
1197 *description = (char *)ptr->text;
1202 return PMINFO_R_ERROR;
1205 API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
1207 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1209 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1210 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1212 if (info->pkg_info == NULL || info->pkg_info->author == NULL ||
1213 info->pkg_info->author->text == NULL)
1214 return PMINFO_R_ERROR;
1216 *author_name = (char *)info->pkg_info->author->text;
1221 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
1223 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1225 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1226 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1228 if (info->pkg_info == NULL || info->pkg_info->author == NULL ||
1229 info->pkg_info->author->email == NULL)
1230 return PMINFO_R_ERROR;
1232 *author_email = (char *)info->pkg_info->author->email;
1237 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
1239 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1241 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1242 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1244 if (info->pkg_info == NULL || info->pkg_info->author == NULL ||
1245 info->pkg_info->author->href == NULL)
1246 return PMINFO_R_ERROR;
1248 *author_href = (char *)info->pkg_info->author->href;
1253 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
1255 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1257 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1258 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1260 if (info->pkg_info == NULL || info->pkg_info->installed_storage == NULL)
1261 return PMINFO_R_ERROR;
1263 if (strcmp(info->pkg_info->installed_storage,"installed_internal") == 0)
1264 *storage = PMINFO_INTERNAL_STORAGE;
1265 else if (strcmp(info->pkg_info->installed_storage,"installed_external") == 0)
1266 *storage = PMINFO_EXTERNAL_STORAGE;
1268 return PMINFO_R_ERROR;
1273 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
1275 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1277 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1278 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1280 if (info->pkg_info == NULL || info->pkg_info->installed_time == NULL)
1281 return PMINFO_R_ERROR;
1283 *installed_time = atoi(info->pkg_info->installed_time);
1288 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
1290 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1292 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1293 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1295 if (info->pkg_info == NULL || info->pkg_info->storeclient_id == NULL)
1296 return PMINFO_R_ERROR;
1298 *storeclientid = (char *)info->pkg_info->storeclient_id;
1303 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
1305 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1307 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1308 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1310 if (info->pkg_info == NULL || info->pkg_info->mainapp_id == NULL)
1311 return PMINFO_R_ERROR;
1313 *mainappid = (char *)info->pkg_info->mainapp_id;
1318 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
1320 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1322 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1323 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1325 if (info->pkg_info == NULL || info->pkg_info->package_url == NULL)
1326 return PMINFO_R_ERROR;
1328 *url = (char *)info->pkg_info->package_url;
1333 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
1335 const char *val = NULL;
1336 const xmlChar *node;
1337 xmlTextReaderPtr reader;
1338 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
1339 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1342 reader = xmlReaderForFile(manifest, NULL, 0);
1345 if (__child_element(reader, -1)) {
1346 node = xmlTextReaderConstName(reader);
1348 _LOGE("xmlTextReaderConstName value is NULL\n");
1349 xmlFreeTextReader(reader);
1351 return PMINFO_R_ERROR;
1354 if (!strcmp(ASC_CHAR(node), "manifest")) {
1355 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
1356 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
1362 _LOGE("package size is not specified\n");
1363 xmlFreeTextReader(reader);
1365 return PMINFO_R_ERROR;
1368 _LOGE("Unable to create xml reader\n");
1369 xmlFreeTextReader(reader);
1371 return PMINFO_R_ERROR;
1375 _LOGE("xmlReaderForFile value is NULL\n");
1377 return PMINFO_R_ERROR;
1380 xmlFreeTextReader(reader);
1386 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
1388 const char *val = NULL;
1389 const xmlChar *node;
1390 xmlTextReaderPtr reader;
1391 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
1392 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1395 reader = xmlReaderForFile(manifest, NULL, 0);
1398 if ( __child_element(reader, -1)) {
1399 node = xmlTextReaderConstName(reader);
1401 _LOGE("xmlTextReaderConstName value is NULL\n");
1402 xmlFreeTextReader(reader);
1404 return PMINFO_R_ERROR;
1407 if (!strcmp(ASC_CHAR(node), "manifest")) {
1408 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
1409 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
1412 if (strcmp(val, "internal-only") == 0)
1413 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
1414 else if (strcmp(val, "prefer-external") == 0)
1415 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
1417 *location = PMINFO_INSTALL_LOCATION_AUTO;
1420 _LOGE("Unable to create xml reader\n");
1421 xmlFreeTextReader(reader);
1423 return PMINFO_R_ERROR;
1427 _LOGE("xmlReaderForFile value is NULL\n");
1429 return PMINFO_R_ERROR;
1432 xmlFreeTextReader(reader);
1439 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
1441 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1443 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1444 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1446 if (info->pkg_info == NULL || info->pkg_info->root_path == NULL)
1447 return PMINFO_R_ERROR;
1449 *path = (char *)info->pkg_info->root_path;
1454 API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
1456 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1458 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1459 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1461 if (info->pkg_info == NULL || info->pkg_info->csc_path == NULL)
1462 return PMINFO_R_ERROR;
1464 *path = (char *)info->pkg_info->csc_path;
1470 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
1472 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1473 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1475 #if 0 //smack issue occured, check later
1477 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
1479 _LOGD("invalid func parameters\n");
1480 return PMINFO_R_ERROR;
1482 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
1485 char app_mmc_path[FILENAME_MAX] = { 0, };
1486 char app_dir_path[FILENAME_MAX] = { 0, };
1487 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
1488 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
1489 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
1490 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
1492 /*check whether application is in external memory or not */
1493 fp = fopen(app_mmc_path, "r");
1495 _LOGD(" app path in external memory not accesible\n");
1500 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
1504 /*check whether application is in internal or not */
1505 fp = fopen(app_dir_path, "r");
1507 _LOGD(" app path in internal memory not accesible\n");
1509 return PMINFO_R_ERROR;
1512 /*check whether the application is installed in SD card
1513 but SD card is not present*/
1514 fp = fopen(app_mmc_internal_path, "r");
1517 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
1522 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
1527 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
1534 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
1537 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1539 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1540 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1542 if (info->pkg_info == NULL || info->pkg_info->removable == NULL)
1543 return PMINFO_R_ERROR;
1545 val = (char *)info->pkg_info->removable;
1546 if (strcasecmp(val, "true") == 0)
1548 else if (strcasecmp(val, "false") == 0)
1556 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
1559 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1561 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1562 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1564 if (info->pkg_info == NULL || info->pkg_info->installlocation == NULL)
1565 return PMINFO_R_ERROR;
1567 val = (char *)info->pkg_info->installlocation;
1568 if (strcmp(val, "internal-only") == 0)
1570 else if (strcmp(val, "prefer-external") == 0)
1578 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
1581 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1583 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1584 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1586 if (info->pkg_info == NULL || info->pkg_info->preload == NULL)
1587 return PMINFO_R_ERROR;
1589 val = (char *)info->pkg_info->preload;
1590 if (strcasecmp(val, "true") == 0)
1592 else if (strcasecmp(val, "false") == 0)
1600 API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
1603 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1605 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1606 retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1608 if (info->pkg_info == NULL || info->pkg_info->system == NULL)
1609 return PMINFO_R_ERROR;
1611 val = (char *)info->pkg_info->system;
1612 if (strcasecmp(val, "true") == 0)
1614 else if (strcasecmp(val, "false") == 0)
1622 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
1625 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1627 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1628 retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1630 if (info->pkg_info == NULL || info->pkg_info->readonly == NULL)
1631 return PMINFO_R_ERROR;
1633 val = (char *)info->pkg_info->readonly;
1634 if (strcasecmp(val, "true") == 0)
1636 else if (strcasecmp(val, "false") == 0)
1644 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
1647 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1649 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1650 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1652 if (info->pkg_info == NULL || info->pkg_info->update == NULL)
1653 return PMINFO_R_ERROR;
1655 val = (char *)info->pkg_info->update;
1656 if (strcasecmp(val, "true") == 0)
1658 else if (strcasecmp(val, "false") == 0)
1666 API int pkgmgrinfo_pkginfo_is_support_disable(pkgmgrinfo_pkginfo_h handle, bool *support_disable)
1669 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1671 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1672 retvm_if(support_disable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1674 if (info->pkg_info == NULL || info->pkg_info->support_disable == NULL)
1675 return PMINFO_R_ERROR;
1677 val = (char *)info->pkg_info->support_disable;
1678 if (strcasecmp(val, "true") == 0)
1679 *support_disable = 1;
1680 else if (strcasecmp(val, "false") == 0)
1681 *support_disable = 0;
1683 *support_disable = 1;
1688 API int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users)
1691 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1693 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1694 retvm_if(for_all_users == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1696 if (info->pkg_info == NULL || info->pkg_info->for_all_users == NULL)
1697 return PMINFO_R_ERROR;
1699 val = (char *)info->pkg_info->for_all_users;
1700 if (strcasecmp(val, "true") == 0)
1702 else if (strcasecmp(val, "false") == 0)
1710 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
1712 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1714 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1716 __cleanup_pkginfo(info);
1721 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
1723 pkgmgrinfo_filter_x *filter;
1725 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
1727 filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
1728 if (filter == NULL) {
1729 _LOGE("Out of Memory!!!");
1730 return PMINFO_R_ERROR;
1738 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
1740 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1742 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1745 g_slist_foreach(filter->list, __destroy_each_node, NULL);
1746 g_slist_free(filter->list);
1754 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
1755 const char *property, const int value)
1757 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
1761 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1762 pkgmgrinfo_node_x *node;
1764 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1765 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1767 prop = _pminfo_pkginfo_convert_to_prop_int(property);
1768 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
1769 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
1770 _LOGE("Invalid Integer Property\n");
1771 return PMINFO_R_EINVAL;
1773 node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
1775 _LOGE("Out of Memory!!!\n");
1776 return PMINFO_R_ERROR;
1778 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
1779 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
1781 _LOGE("Out of Memory\n");
1783 return PMINFO_R_ERROR;
1787 /*If API is called multiple times for same property, we should override the previous values.
1788 Last value set will be used for filtering.*/
1789 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1791 filter->list = g_slist_delete_link(filter->list, link);
1792 filter->list = g_slist_append(filter->list, (gpointer)node);
1797 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
1798 const char *property, const bool value)
1803 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1804 pkgmgrinfo_node_x *node;
1806 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1807 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1809 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
1810 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
1811 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
1812 _LOGE("Invalid Boolean Property\n");
1813 return PMINFO_R_EINVAL;
1815 node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
1817 _LOGE("Out of Memory!!!\n");
1818 return PMINFO_R_ERROR;
1821 val = strndup("('true','True')", 15);
1823 val = strndup("('false','False')", 17);
1825 _LOGE("Out of Memory\n");
1827 return PMINFO_R_ERROR;
1831 /*If API is called multiple times for same property, we should override the previous values.
1832 Last value set will be used for filtering.*/
1833 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1835 filter->list = g_slist_delete_link(filter->list, link);
1836 filter->list = g_slist_append(filter->list, (gpointer)node);
1841 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
1842 const char *property, const char *value)
1847 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1848 pkgmgrinfo_node_x *node;
1850 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1851 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1852 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1854 prop = _pminfo_pkginfo_convert_to_prop_str(property);
1855 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
1856 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
1857 _LOGE("Invalid String Property\n");
1858 return PMINFO_R_EINVAL;
1860 node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
1862 _LOGE("Out of Memory!!!\n");
1863 return PMINFO_R_ERROR;
1865 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
1866 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
1867 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
1868 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
1869 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
1870 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
1871 else if (strcmp(value, "installed_internal") == 0)
1872 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
1873 else if (strcmp(value, "installed_external") == 0)
1874 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
1876 val = strndup(value, PKG_STRING_LEN_MAX - 1);
1878 _LOGE("Out of Memory\n");
1880 return PMINFO_R_ERROR;
1884 /*If API is called multiple times for same property, we should override the previous values.
1885 Last value set will be used for filtering.*/
1886 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1888 filter->list = g_slist_delete_link(filter->list, link);
1889 filter->list = g_slist_append(filter->list, (gpointer)node);
1894 API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count, uid_t uid)
1899 if (handle == NULL || count == NULL) {
1900 _LOGE("invalid parameter");
1901 return PMINFO_R_EINVAL;
1904 ret = _pkginfo_get_filtered_list((pkgmgrinfo_filter_x *)handle, uid, &list);
1905 if (ret != PMINFO_R_OK)
1906 return PMINFO_R_ERROR;
1908 *count = g_list_length(list);
1910 g_list_free_full(list, free);
1915 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
1917 return pkgmgrinfo_pkginfo_usr_filter_count(handle, count, GLOBAL_USER);
1920 API int pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(
1921 pkgmgrinfo_pkginfo_filter_h handle,
1922 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
1924 if (handle == NULL || pkg_cb == NULL) {
1925 LOGE("invalid parameter");
1926 return PMINFO_R_EINVAL;
1929 return _pkginfo_get_filtered_foreach_pkginfo(handle, pkg_cb, user_data,
1933 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
1934 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
1936 return pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, pkg_cb, user_data, GLOBAL_USER);
1939 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
1940 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
1942 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
1943 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1945 privilege_x *ptr = NULL;
1946 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1947 ptr = info->pkg_info->privileges->privilege;
1948 for (; ptr; ptr = ptr->next) {
1950 ret = privilege_func(ptr->text, user_data);
1958 API int pkgmgrinfo_create_pkgusrdbinfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkgdbinfo_h *handle)
1960 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
1961 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
1963 char *manifest = NULL;
1964 manifest_x *mfx = NULL;
1966 manifest = pkgmgr_parser_get_usr_manifest_file(pkgid, uid);
1967 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
1969 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
1974 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
1976 *handle = (void *)mfx;
1981 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
1983 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
1984 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
1986 char *manifest = NULL;
1987 manifest_x *mfx = NULL;
1989 manifest = pkgmgr_parser_get_manifest_file(pkgid);
1990 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
1992 mfx = pkgmgr_parser_process_manifest_xml(manifest);
1997 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
1999 *handle = (void *)mfx;
2004 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
2007 manifest_x *mfx = (manifest_x *)handle;
2009 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
2010 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2013 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2016 free((void *)mfx->type);
2018 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
2023 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
2026 manifest_x *mfx = (manifest_x *)handle;
2028 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
2029 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2031 len = strlen(version);
2032 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2035 free((void *)mfx->version);
2037 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
2041 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
2043 manifest_x *mfx = (manifest_x *)handle;
2045 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2046 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2048 if (mfx->installlocation)
2049 free((void *)mfx->installlocation);
2051 if (location == INSTALL_INTERNAL)
2052 mfx->installlocation = strdup("internal-only");
2053 else if (location == INSTALL_EXTERNAL)
2054 mfx->installlocation = strdup("prefer-external");
2059 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
2061 manifest_x *mfx = (manifest_x *)handle;
2063 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2064 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
2066 if (mfx->package_size)
2067 free((void *)mfx->package_size);
2069 mfx->package_size = strdup(size);
2074 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
2077 manifest_x *mfx = (manifest_x *)handle;
2080 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2081 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
2083 len = strlen(label_txt);
2084 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2086 label = calloc(1, sizeof(label_x));
2087 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
2089 LISTADD(mfx->label, label);
2091 mfx->label->lang = strdup(locale);
2093 mfx->label->lang = strdup(DEFAULT_LOCALE);
2094 mfx->label->text = strdup(label_txt);
2099 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
2102 manifest_x *mfx = (manifest_x *)handle;
2105 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2106 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
2108 len = strlen(icon_txt);
2109 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2111 icon = calloc(1, sizeof(icon_x));
2112 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
2114 LISTADD(mfx->icon, icon);
2116 mfx->icon->lang = strdup(locale);
2118 mfx->icon->lang = strdup(DEFAULT_LOCALE);
2119 mfx->icon->text = strdup(icon_txt);
2124 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
2126 int len = strlen(desc_txt);
2127 manifest_x *mfx = (manifest_x *)handle;
2128 description_x *description;
2130 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2131 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
2133 len = strlen(desc_txt);
2134 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2136 description = calloc(1, sizeof(description_x));
2137 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
2139 LISTADD(mfx->description, description);
2141 mfx->description->lang = strdup(locale);
2143 mfx->description->lang = strdup(DEFAULT_LOCALE);
2144 mfx->description->text = strdup(desc_txt);
2149 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
2150 const char *author_email, const char *author_href, const char *locale)
2152 manifest_x *mfx = (manifest_x *)handle;
2155 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2157 author = calloc(1, sizeof(author_x));
2158 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
2160 LISTADD(mfx->author, author);
2162 mfx->author->text = strdup(author_name);
2164 mfx->author->email = strdup(author_email);
2166 mfx->author->href = strdup(author_href);
2168 mfx->author->lang = strdup(locale);
2170 mfx->author->lang = strdup(DEFAULT_LOCALE);
2174 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
2176 manifest_x *mfx = (manifest_x *)handle;
2178 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2179 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2182 free((void *)mfx->removable);
2185 mfx->removable = strdup("false");
2186 else if (removable == 1)
2187 mfx->removable = strdup("true");
2192 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
2194 manifest_x *mfx = (manifest_x *)handle;
2196 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2197 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2200 free((void *)mfx->preload);
2203 mfx->preload = strdup("false");
2204 else if (preload == 1)
2205 mfx->preload = strdup("true");
2210 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
2212 manifest_x *mfx = (manifest_x *)handle;
2214 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2215 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2217 if (mfx->installed_storage)
2218 free((void *)mfx->installed_storage);
2220 if (location == INSTALL_INTERNAL)
2221 mfx->installed_storage = strdup("installed_internal");
2222 else if (location == INSTALL_EXTERNAL)
2223 mfx->installed_storage = strdup("installed_external");
2228 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
2231 manifest_x *mfx = (manifest_x *)handle;
2232 mfx = (manifest_x *)handle;
2234 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2236 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
2238 _LOGE("Successfully stored info in DB\n");
2241 _LOGE("Failed to store info in DB\n");
2242 return PMINFO_R_ERROR;
2246 API int pkgmgrinfo_save_pkgusrdbinfo(pkgmgrinfo_pkgdbinfo_h handle, uid_t uid)
2249 manifest_x *mfx = (manifest_x *)handle;
2251 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2253 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
2255 _LOGE("Successfully stored info in DB\n");
2258 _LOGE("Failed to store info in DB\n");
2259 return PMINFO_R_ERROR;
2263 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
2265 manifest_x *mfx = (manifest_x *)handle;
2267 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2269 pkgmgrinfo_basic_free_package(mfx);