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 bool _get_bool_value(const char *str)
58 else if (!strcasecmp(str, "true"))
64 static gint __compare_func(gconstpointer data1, gconstpointer data2)
66 pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1;
67 pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2;
68 if (node1->prop == node2->prop)
70 else if (node1->prop > node2->prop)
76 static void __destroy_each_node(gpointer data, gpointer user_data)
79 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
92 static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
96 free((void *)data->locale);
100 pkgmgrinfo_basic_free_package(data->pkg_info);
106 static int __child_element(xmlTextReaderPtr reader, int depth)
108 int ret = xmlTextReaderRead(reader);
109 int cur = xmlTextReaderDepth(reader);
112 switch (xmlTextReaderNodeType(reader)) {
113 case XML_READER_TYPE_ELEMENT:
114 if (cur == depth + 1)
117 case XML_READER_TYPE_TEXT:
118 /*text is handled by each function separately*/
119 if (cur == depth + 1)
122 case XML_READER_TYPE_END_ELEMENT:
131 ret = xmlTextReaderRead(reader);
132 cur = xmlTextReaderDepth(reader);
137 long long _pkgmgr_calculate_dir_size(char *dirname)
141 int q = 0; /*quotient*/
142 int r = 0; /*remainder*/
144 struct dirent *ep = NULL;
145 struct stat fileinfo;
146 char abs_filename[FILENAME_MAX] = { 0, };
147 retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL");
149 dp = opendir(dirname);
151 while ((ep = readdir(dp)) != NULL) {
152 if (!strcmp(ep->d_name, ".") ||
153 !strcmp(ep->d_name, "..")) {
156 snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
158 if (lstat(abs_filename, &fileinfo) < 0)
159 perror(abs_filename);
161 if (S_ISDIR(fileinfo.st_mode)) {
162 total += fileinfo.st_size;
163 if (strcmp(ep->d_name, ".")
164 && strcmp(ep->d_name, "..")) {
165 ret = _pkgmgr_calculate_dir_size
169 } else if (S_ISLNK(fileinfo.st_mode)) {
172 /*It is a file. Calculate the actual
173 size occupied (in terms of 4096 blocks)*/
174 q = (fileinfo.st_size / BLOCK_SIZE);
175 r = (fileinfo.st_size % BLOCK_SIZE);
179 total += q * BLOCK_SIZE;
185 _LOGE("Couldn't open the directory\n");
192 static gint __list_strcmp(gconstpointer a, gconstpointer b)
194 return strcmp((char *)a, (char *)b);
197 static int _pkginfo_get_list(sqlite3 *db, const char *locale,
198 pkgmgrinfo_filter_x *filter, GList **list)
200 static const char query_raw[] =
201 "SELECT DISTINCT package_info.package FROM package_info"
202 " LEFT OUTER JOIN package_localized_info"
203 " ON package_info.package=package_localized_info.package"
204 " AND package_localized_info.package_locale=%Q "
205 " LEFT OUTER JOIN package_privilege_info"
206 " ON package_info.package=package_privilege_info.package"
207 " WHERE package_info.package_disable='false'";
210 char *query_localized;
214 query = _get_filtered_query(query_raw, filter);
217 query_localized = sqlite3_mprintf(query, locale);
219 if (query_localized == NULL)
222 ret = sqlite3_prepare_v2(db, query_localized,
223 strlen(query_localized), &stmt, NULL);
224 sqlite3_free(query_localized);
225 if (ret != SQLITE_OK) {
226 LOGE("prepare failed: %s", sqlite3_errmsg(db));
230 while (sqlite3_step(stmt) == SQLITE_ROW) {
231 _save_column_str(stmt, 0, (const char **)&pkgid);
233 *list = g_list_insert_sorted(*list, pkgid,
237 sqlite3_finalize(stmt);
242 static int _pkginfo_get_filtered_list(pkgmgrinfo_filter_x *filter, uid_t uid,
252 locale = _get_system_locale();
254 return PMINFO_R_ERROR;
256 dbpath = getUserPkgParserDBPathUID(uid);
257 if (dbpath == NULL) {
259 return PMINFO_R_ERROR;
262 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
263 if (ret != SQLITE_OK) {
264 _LOGE("failed to open db: %d", ret);
266 return PMINFO_R_ERROR;
269 if (_pkginfo_get_list(db, locale, filter, list)) {
271 sqlite3_close_v2(db);
272 return PMINFO_R_ERROR;
274 sqlite3_close_v2(db);
276 if (uid == GLOBAL_USER) {
281 /* search again from global */
282 dbpath = getUserPkgParserDBPathUID(GLOBAL_USER);
283 if (dbpath == NULL) {
285 return PMINFO_R_ERROR;
288 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
289 if (ret != SQLITE_OK) {
290 _LOGE("failed to open db: %d", ret);
292 return PMINFO_R_ERROR;
295 if (_pkginfo_get_list(db, locale, filter, list)) {
297 sqlite3_close_v2(db);
298 return PMINFO_R_ERROR;
300 sqlite3_close_v2(db);
302 /* remove duplicate element:
303 * since the list is sorted, we can remove duplicates in linear time
305 for (tmp = *list, tmp2 = g_list_next(tmp); tmp;
306 tmp = tmp2, tmp2 = g_list_next(tmp)) {
307 if (tmp->prev == NULL || tmp->data == NULL)
309 if (strcmp((const char *)tmp->prev->data,
310 (const char *)tmp->data) == 0)
311 *list = g_list_delete_link(*list, tmp);
320 static int _pkginfo_get_filtered_foreach_pkginfo(pkgmgrinfo_filter_x *filter,
321 pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
324 pkgmgr_pkginfo_x *info;
330 ret = _pkginfo_get_filtered_list(filter, uid, &list);
331 if (ret != PMINFO_R_OK)
332 return PMINFO_R_ERROR;
334 for (tmp = list; tmp; tmp = tmp->next) {
335 pkgid = (char *)tmp->data;
337 ret = _pkginfo_get_pkginfo(pkgid, uid, &info);
338 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
339 ret = _pkginfo_get_pkginfo(pkgid, GLOBAL_USER,
341 if (ret != PMINFO_R_OK) {
345 if (pkg_list_cb(info, user_data) < 0)
347 pkgmgrinfo_pkginfo_destroy_pkginfo(info);
357 API int pkgmgrinfo_pkginfo_get_usr_list(pkgmgrinfo_pkg_list_cb pkg_list_cb,
358 void *user_data, uid_t uid)
360 if (pkg_list_cb == NULL) {
361 LOGE("invalid parameter");
362 return PMINFO_R_EINVAL;
365 return _pkginfo_get_filtered_foreach_pkginfo(NULL, pkg_list_cb,
369 API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
371 return pkgmgrinfo_pkginfo_get_usr_list(pkg_list_cb, user_data, GLOBAL_USER);
374 static int _pkginfo_get_author(sqlite3 *db, const char *pkgid,
377 static const char query_raw[] =
378 "SELECT author_name, author_email, author_href "
379 "FROM package_info WHERE package=%Q";
386 query = sqlite3_mprintf(query_raw, pkgid);
388 LOGE("out of memory");
389 return PMINFO_R_ERROR;
392 ret = sqlite3_prepare_v2(db, query, strlen(query),
395 if (ret != SQLITE_OK) {
396 LOGE("prepare failed: %s", sqlite3_errmsg(db));
397 return PMINFO_R_ERROR;
400 if (sqlite3_step(stmt) == SQLITE_ERROR) {
401 LOGE("step error: %s", sqlite3_errmsg(db));
402 sqlite3_finalize(stmt);
403 return PMINFO_R_ERROR;
406 /* one author per one package */
407 info = calloc(1, sizeof(author_x));
409 LOGE("out of memory");
410 sqlite3_finalize(stmt);
411 return PMINFO_R_ERROR;
414 _save_column_str(stmt, idx++, &info->text);
415 _save_column_str(stmt, idx++, &info->email);
416 _save_column_str(stmt, idx++, &info->href);
419 *author = g_list_append(*author, info);
421 sqlite3_finalize(stmt);
426 static int _pkginfo_get_label(sqlite3 *db, const char *pkgid,
427 const char *locale, GList **label)
429 static const char query_raw[] =
430 "SELECT package_label, package_locale "
431 "FROM package_localized_info "
432 "WHERE package=%Q AND package_locale IN (%Q, %Q)";
439 query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
441 LOGE("out of memory");
442 return PMINFO_R_ERROR;
445 ret = sqlite3_prepare_v2(db, query, strlen(query),
448 if (ret != SQLITE_OK) {
449 LOGE("prepare failed: %s", sqlite3_errmsg(db));
450 return PMINFO_R_ERROR;
453 while (sqlite3_step(stmt) == SQLITE_ROW) {
454 info = calloc(1, sizeof(label_x));
456 LOGE("out of memory");
457 sqlite3_finalize(stmt);
458 return PMINFO_R_ERROR;
461 _save_column_str(stmt, idx++, &info->text);
462 _save_column_str(stmt, idx++, &info->lang);
463 *label = g_list_append(*label, info);
466 sqlite3_finalize(stmt);
471 static int _pkginfo_get_icon(sqlite3 *db, const char *pkgid, const char *locale,
474 static const char query_raw[] =
475 "SELECT package_icon, package_locale "
476 "FROM package_localized_info "
477 "WHERE package=%Q AND package_locale IN (%Q, %Q)";
484 query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
486 LOGE("out of memory");
487 return PMINFO_R_ERROR;
490 ret = sqlite3_prepare_v2(db, query, strlen(query),
493 if (ret != SQLITE_OK) {
494 LOGE("prepare failed: %s", sqlite3_errmsg(db));
495 return PMINFO_R_ERROR;
498 while (sqlite3_step(stmt) == SQLITE_ROW) {
499 info = calloc(1, sizeof(icon_x));
501 LOGE("out of memory");
502 sqlite3_finalize(stmt);
503 return PMINFO_R_ERROR;
506 _save_column_str(stmt, idx++, &info->text);
507 _save_column_str(stmt, idx++, &info->lang);
508 *icon = g_list_append(*icon, info);
511 sqlite3_finalize(stmt);
516 static int _pkginfo_get_description(sqlite3 *db, const char *pkgid,
517 const char *locale, GList **description)
519 static const char query_raw[] =
520 "SELECT package_description, package_locale "
521 "FROM package_localized_info "
522 "WHERE package=%Q AND package_locale IN (%Q, %Q)";
529 query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE);
531 LOGE("out of memory");
532 return PMINFO_R_ERROR;
535 ret = sqlite3_prepare_v2(db, query, strlen(query),
538 if (ret != SQLITE_OK) {
539 LOGE("prepare failed: %s", sqlite3_errmsg(db));
540 return PMINFO_R_ERROR;
543 while (sqlite3_step(stmt) == SQLITE_ROW) {
544 info = calloc(1, sizeof(description_x));
546 LOGE("out of memory");
547 sqlite3_finalize(stmt);
548 return PMINFO_R_ERROR;
551 _save_column_str(stmt, idx++, &info->text);
552 _save_column_str(stmt, idx++, &info->lang);
553 *description = g_list_append(*description, info);
556 sqlite3_finalize(stmt);
561 static int _pkginfo_get_privilege(sqlite3 *db, const char *pkgid,
564 static const char query_raw[] =
565 "SELECT privilege FROM package_privilege_info WHERE package=%Q";
569 const char *privilege;
571 query = sqlite3_mprintf(query_raw, pkgid);
573 LOGE("out of memory");
574 return PMINFO_R_ERROR;
577 ret = sqlite3_prepare_v2(db, query, strlen(query),
580 if (ret != SQLITE_OK) {
581 LOGE("prepare failed: %s", sqlite3_errmsg(db));
582 return PMINFO_R_ERROR;
585 while (sqlite3_step(stmt) == SQLITE_ROW) {
587 _save_column_str(stmt, 0, &privilege);
589 *privileges = g_list_append(*privileges,
590 (gpointer)privilege);
593 sqlite3_finalize(stmt);
598 static char *_get_filtered_query(const char *query_raw,
599 pkgmgrinfo_filter_x *filter)
601 char buf[MAX_QUERY_LEN] = { 0, };
610 strncat(buf, query_raw, MAX_QUERY_LEN - 1);
612 for (list = head; list; list = list->next) {
613 /* TODO: revise condition getter function */
614 __get_filter_condition(list->data, &condition);
615 if (condition == NULL)
617 if (buf[strlen(query_raw)] == '\0') {
618 len += strlen(" WHERE ");
619 strncat(buf, " WHERE ", MAX_QUERY_LEN - len - 1);
621 len += strlen(" AND ");
622 strncat(buf, " AND ", MAX_QUERY_LEN -len - 1);
624 len += strlen(condition);
625 strncat(buf, condition, sizeof(buf) - len - 1);
633 static int _pkginfo_get_package(sqlite3 *db, const char *pkgid,
634 const char *locale, package_x **package)
636 static const char query_raw[] =
637 "SELECT package, package_version, "
638 "install_location, package_removable, package_preload, "
639 "package_readonly, package_update, package_appsetting, "
640 "package_system, package_type, package_size, installed_time, "
641 "installed_storage, storeclient_id, mainapp_id, package_url, "
642 "root_path, csc_path, package_nodisplay, package_api_version, "
643 "package_support_disable, package_tep_name "
644 "FROM package_info WHERE package=%Q AND package_disable='false'";
651 query = sqlite3_mprintf(query_raw, pkgid);
653 LOGE("out of memory");
654 return PMINFO_R_ERROR;
657 ret = sqlite3_prepare_v2(db, query, strlen(query),
660 if (ret != SQLITE_OK) {
661 LOGE("prepare failed: %s", sqlite3_errmsg(db));
662 return PMINFO_R_ERROR;
665 ret = sqlite3_step(stmt);
666 if (ret == SQLITE_DONE) {
667 sqlite3_finalize(stmt);
668 return PMINFO_R_ENOENT;
669 } else if (ret != SQLITE_ROW) {
670 LOGE("step failed: %s", sqlite3_errmsg(db));
671 sqlite3_finalize(stmt);
672 return PMINFO_R_ERROR;
675 info = calloc(1, sizeof(package_x));
677 LOGE("out of memory");
678 sqlite3_finalize(stmt);
679 return PMINFO_R_ERROR;
682 _save_column_str(stmt, idx++, &info->package);
683 _save_column_str(stmt, idx++, &info->version);
684 _save_column_str(stmt, idx++, &info->installlocation);
685 _save_column_str(stmt, idx++, &info->removable);
686 _save_column_str(stmt, idx++, &info->preload);
687 _save_column_str(stmt, idx++, &info->readonly);
688 _save_column_str(stmt, idx++, &info->update);
689 _save_column_str(stmt, idx++, &info->appsetting);
690 _save_column_str(stmt, idx++, &info->system);
691 _save_column_str(stmt, idx++, &info->type);
692 _save_column_str(stmt, idx++, &info->package_size);
693 _save_column_str(stmt, idx++, &info->installed_time);
694 _save_column_str(stmt, idx++, &info->installed_storage);
695 _save_column_str(stmt, idx++, &info->storeclient_id);
696 _save_column_str(stmt, idx++, &info->mainapp_id);
697 _save_column_str(stmt, idx++, &info->package_url);
698 _save_column_str(stmt, idx++, &info->root_path);
699 _save_column_str(stmt, idx++, &info->csc_path);
700 _save_column_str(stmt, idx++, &info->nodisplay_setting);
701 _save_column_str(stmt, idx++, &info->api_version);
702 _save_column_str(stmt, idx++, &info->support_disable);
703 _save_column_str(stmt, idx++, &info->tep_name);
705 if (_pkginfo_get_author(db, info->package, &info->author)) {
706 pkgmgrinfo_basic_free_package(info);
707 sqlite3_finalize(stmt);
708 return PMINFO_R_ERROR;
711 if (_pkginfo_get_label(db, info->package, locale, &info->label)) {
712 pkgmgrinfo_basic_free_package(info);
713 sqlite3_finalize(stmt);
714 return PMINFO_R_ERROR;
717 if (_pkginfo_get_icon(db, info->package, locale, &info->icon)) {
718 pkgmgrinfo_basic_free_package(info);
719 sqlite3_finalize(stmt);
720 return PMINFO_R_ERROR;
723 if (_pkginfo_get_description(db, info->package, locale,
724 &info->description)) {
725 pkgmgrinfo_basic_free_package(info);
726 sqlite3_finalize(stmt);
727 return PMINFO_R_ERROR;
730 if (_pkginfo_get_privilege(db, info->package, &info->privileges)) {
731 pkgmgrinfo_basic_free_package(info);
732 sqlite3_finalize(stmt);
733 return PMINFO_R_ERROR;
737 sqlite3_finalize(stmt);
742 static int _pkginfo_get_pkginfo(const char *pkgid, uid_t uid,
743 pkgmgr_pkginfo_x **pkginfo)
749 pkgmgr_pkginfo_x *info;
751 dbpath = getUserPkgParserDBPathUID(uid);
753 return PMINFO_R_ERROR;
755 locale = _get_system_locale();
757 return PMINFO_R_ERROR;
759 ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
760 if (ret != SQLITE_OK) {
761 _LOGE("failed to open db: %d", ret);
763 return PMINFO_R_ERROR;
766 info = calloc(1, sizeof(pkgmgr_pkginfo_x));
768 _LOGE("out of memory");
770 sqlite3_close_v2(db);
771 return PMINFO_R_ERROR;
774 ret = _pkginfo_get_package(db, pkgid, locale, &info->pkg_info);
775 if (ret != PMINFO_R_OK) {
778 sqlite3_close_v2(db);
782 info->locale = locale;
784 info->pkg_info->for_all_users = strdup(
785 uid != GLOBAL_USER ? "false" : "true");
789 sqlite3_close_v2(db);
794 API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid,
795 pkgmgrinfo_pkginfo_h *handle)
799 if (pkgid == NULL || handle == NULL) {
800 LOGE("invalid parameter");
801 return PMINFO_R_EINVAL;
804 ret = _pkginfo_get_pkginfo(pkgid, uid, (pkgmgr_pkginfo_x **)handle);
805 if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
806 ret = _pkginfo_get_pkginfo(pkgid, GLOBAL_USER,
807 (pkgmgr_pkginfo_x **)handle);
809 if (ret != PMINFO_R_OK)
810 _LOGE("failed to get pkginfo of %s for user %d", pkgid, uid);
815 API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
817 return pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, GLOBAL_USER, handle);
820 API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
822 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
824 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
825 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
827 if (info->pkg_info == NULL || info->pkg_info->package == NULL)
828 return PMINFO_R_ERROR;
830 *pkg_name = (char *)info->pkg_info->package;
835 API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
837 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
839 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
840 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
842 if (info->pkg_info == NULL || info->pkg_info->package == NULL)
843 return PMINFO_R_ERROR;
845 *pkgid = (char *)info->pkg_info->package;
850 API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
852 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
854 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
855 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
857 if (info->pkg_info == NULL || info->pkg_info->type == NULL)
858 return PMINFO_R_ERROR;
860 *type = (char *)info->pkg_info->type;
865 API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
867 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
869 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
870 retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
872 if (info->pkg_info == NULL || info->pkg_info->version == NULL)
873 return PMINFO_R_ERROR;
875 *version = (char *)info->pkg_info->version;
880 API int pkgmgrinfo_pkginfo_get_api_version(pkgmgrinfo_pkginfo_h handle, char **api_version)
882 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
884 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
885 retvm_if(api_version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
887 if (info->pkg_info == NULL || info->pkg_info->api_version == NULL)
888 return PMINFO_R_ERROR;
890 *api_version = (char *)info->pkg_info->api_version;
895 API int pkgmgrinfo_pkginfo_get_tep_name(pkgmgrinfo_pkginfo_h handle, char **tep_name)
897 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
899 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
900 retvm_if(tep_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
902 if (info->pkg_info == NULL || info->pkg_info->tep_name == NULL)
903 return PMINFO_R_ERROR;
905 if (strlen(info->pkg_info->tep_name) == 0)
906 return PMINFO_R_ERROR;
908 *tep_name = (char *)info->pkg_info->tep_name;
913 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
916 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
918 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
919 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
921 if (info->pkg_info == NULL || info->pkg_info->installlocation == NULL)
922 return PMINFO_R_ERROR;
924 val = (char *)info->pkg_info->installlocation;
925 if (strcmp(val, "internal-only") == 0)
926 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
927 else if (strcmp(val, "prefer-external") == 0)
928 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
930 *location = PMINFO_INSTALL_LOCATION_AUTO;
935 API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
937 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
939 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
940 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
942 if (info->pkg_info == NULL || info->pkg_info->package_size == NULL)
943 return PMINFO_R_ERROR;
945 *size = atoi((char *)info->pkg_info->package_size);
950 API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
953 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
954 long long rw_size = 0;
955 long long ro_size = 0;
956 long long tmp_size = 0;
957 long long total_size = 0;
958 struct stat fileinfo;
961 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
962 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
964 ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
966 return PMINFO_R_ERROR;
969 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid);
970 if (lstat(device_path, &fileinfo) == 0) {
971 if (!S_ISLNK(fileinfo.st_mode)) {
972 tmp_size = _pkgmgr_calculate_dir_size(device_path);
978 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid);
979 if (lstat(device_path, &fileinfo) == 0) {
980 if (!S_ISLNK(fileinfo.st_mode)) {
981 tmp_size = _pkgmgr_calculate_dir_size(device_path);
987 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid);
988 if (lstat(device_path, &fileinfo) == 0) {
989 if (!S_ISLNK(fileinfo.st_mode)) {
990 tmp_size = _pkgmgr_calculate_dir_size(device_path);
996 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
997 if (lstat(device_path, &fileinfo) == 0) {
998 if (!S_ISLNK(fileinfo.st_mode)) {
999 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1001 rw_size += tmp_size;
1005 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_PATH, pkgid);
1006 if (lstat(device_path, &fileinfo) == 0) {
1007 if (!S_ISLNK(fileinfo.st_mode)) {
1008 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1010 rw_size += tmp_size;
1014 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_PATH, pkgid);
1015 if (lstat(device_path, &fileinfo) == 0) {
1016 if (!S_ISLNK(fileinfo.st_mode)) {
1017 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1019 rw_size += tmp_size;
1024 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_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 ro_size += tmp_size;
1033 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid);
1034 if (lstat(device_path, &fileinfo) == 0) {
1035 if (!S_ISLNK(fileinfo.st_mode)) {
1036 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1038 ro_size += tmp_size;
1042 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid);
1043 if (lstat(device_path, &fileinfo) == 0) {
1044 if (!S_ISLNK(fileinfo.st_mode)) {
1045 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1047 ro_size += tmp_size;
1051 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid);
1052 if (lstat(device_path, &fileinfo) == 0) {
1053 if (!S_ISLNK(fileinfo.st_mode)) {
1054 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1056 ro_size += tmp_size;
1060 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid);
1061 if (lstat(device_path, &fileinfo) == 0) {
1062 if (!S_ISLNK(fileinfo.st_mode)) {
1063 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1065 ro_size += tmp_size;
1069 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid);
1070 if (lstat(device_path, &fileinfo) == 0) {
1071 if (!S_ISLNK(fileinfo.st_mode)) {
1072 tmp_size = _pkgmgr_calculate_dir_size(device_path);
1074 ro_size += tmp_size;
1079 total_size = rw_size + ro_size;
1080 *size = (int)total_size;
1085 API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
1088 char device_path[PKG_STRING_LEN_MAX] = { '\0', };
1089 long long total_size = 0;
1091 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1092 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1094 if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid) < 0)
1095 return PMINFO_R_ERROR;
1097 snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
1098 if (access(device_path, R_OK) == 0)
1099 total_size = _pkgmgr_calculate_dir_size(device_path);
1101 return PMINFO_R_ERROR;
1103 *size = (int)total_size;
1108 API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
1113 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1115 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
1116 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1118 locale = info->locale;
1119 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1121 if (info->pkg_info == NULL)
1122 return PMINFO_R_ERROR;
1124 for (tmp = info->pkg_info->icon; tmp; tmp = tmp->next) {
1125 ptr = (icon_x *)tmp->data;
1126 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1127 !strcasecmp(ptr->text, "(null)") ||
1128 strcmp(ptr->lang, locale))
1130 *icon = (char *)ptr->text;
1134 locale = DEFAULT_LOCALE;
1135 for (tmp = info->pkg_info->icon; tmp; tmp = tmp->next) {
1136 ptr = (icon_x *)tmp->data;
1137 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1138 strcmp(ptr->lang, locale))
1140 *icon = (char *)ptr->text;
1144 return PMINFO_R_ERROR;
1147 API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
1152 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1154 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
1155 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1157 locale = info->locale;
1158 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1160 for (tmp = info->pkg_info->label; tmp != NULL; tmp = tmp->next) {
1161 ptr = (label_x *)tmp->data;
1162 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1163 strcmp(ptr->lang, locale))
1165 *label = (char *)ptr->text;
1169 locale = DEFAULT_LOCALE;
1170 for (tmp = info->pkg_info->label; tmp != NULL; tmp = tmp->next) {
1171 ptr = (label_x *)tmp->data;
1172 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1173 strcmp(ptr->lang, locale))
1175 *label = (char *)ptr->text;
1179 return PMINFO_R_ERROR;
1182 API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
1187 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1189 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1190 retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1192 locale = info->locale;
1193 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1195 for (tmp = info->pkg_info->description; tmp; tmp = tmp->next) {
1196 ptr = (description_x *)tmp->data;
1197 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1198 strcmp(ptr->lang, locale))
1200 *description = (char *)ptr->text;
1204 locale = DEFAULT_LOCALE;
1205 for (tmp = info->pkg_info->description; tmp; tmp = tmp->next) {
1206 ptr = (description_x *)tmp->data;
1207 if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
1208 strcmp(ptr->lang, locale))
1210 *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;
1222 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1223 retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1225 if (info->pkg_info == NULL || info->pkg_info->author == NULL)
1226 return PMINFO_R_ERROR;
1228 author = (author_x *)info->pkg_info->author->data;
1229 if (author == NULL || author->text == NULL)
1230 return PMINFO_R_ERROR;
1232 *author_name = (char *)author->text;
1237 API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
1239 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1242 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1243 retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1245 if (info->pkg_info == NULL || info->pkg_info->author == NULL)
1246 return PMINFO_R_ERROR;
1248 author = (author_x *)info->pkg_info->author->data;
1249 if (author == NULL || author->email == NULL)
1250 return PMINFO_R_ERROR;
1252 *author_email = (char *)author->email;
1257 API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
1259 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1262 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1263 retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1265 if (info->pkg_info == NULL || info->pkg_info->author == NULL)
1266 return PMINFO_R_ERROR;
1268 author = (author_x *)info->pkg_info->author->data;
1269 if (author == NULL || author->href == NULL)
1270 return PMINFO_R_ERROR;
1272 *author_href = (char *)author->href;
1277 API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
1279 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1281 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1282 retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1284 if (info->pkg_info == NULL || info->pkg_info->installed_storage == NULL)
1285 return PMINFO_R_ERROR;
1287 if (strcmp(info->pkg_info->installed_storage,"installed_internal") == 0)
1288 *storage = PMINFO_INTERNAL_STORAGE;
1289 else if (strcmp(info->pkg_info->installed_storage,"installed_external") == 0)
1290 *storage = PMINFO_EXTERNAL_STORAGE;
1292 return PMINFO_R_ERROR;
1297 API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
1299 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1301 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1302 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1304 if (info->pkg_info == NULL || info->pkg_info->installed_time == NULL)
1305 return PMINFO_R_ERROR;
1307 *installed_time = atoi(info->pkg_info->installed_time);
1312 API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
1314 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1316 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1317 retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1319 if (info->pkg_info == NULL || info->pkg_info->storeclient_id == NULL)
1320 return PMINFO_R_ERROR;
1322 *storeclientid = (char *)info->pkg_info->storeclient_id;
1327 API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
1329 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1331 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1332 retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1334 if (info->pkg_info == NULL || info->pkg_info->mainapp_id == NULL)
1335 return PMINFO_R_ERROR;
1337 *mainappid = (char *)info->pkg_info->mainapp_id;
1342 API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
1344 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1346 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1347 retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1349 if (info->pkg_info == NULL || info->pkg_info->package_url == NULL)
1350 return PMINFO_R_ERROR;
1352 *url = (char *)info->pkg_info->package_url;
1357 API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
1359 const char *val = NULL;
1360 const xmlChar *node;
1361 xmlTextReaderPtr reader;
1362 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
1363 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1366 reader = xmlReaderForFile(manifest, NULL, 0);
1369 if (__child_element(reader, -1)) {
1370 node = xmlTextReaderConstName(reader);
1372 _LOGE("xmlTextReaderConstName value is NULL\n");
1373 xmlFreeTextReader(reader);
1375 return PMINFO_R_ERROR;
1378 if (!strcmp(ASC_CHAR(node), "manifest")) {
1379 if (xmlTextReaderGetAttribute(reader, XML_CHAR("size")))
1380 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("size")));
1386 _LOGE("package size is not specified\n");
1387 xmlFreeTextReader(reader);
1389 return PMINFO_R_ERROR;
1392 _LOGE("Unable to create xml reader\n");
1393 xmlFreeTextReader(reader);
1395 return PMINFO_R_ERROR;
1399 _LOGE("xmlReaderForFile value is NULL\n");
1401 return PMINFO_R_ERROR;
1404 xmlFreeTextReader(reader);
1410 API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
1412 const char *val = NULL;
1413 const xmlChar *node;
1414 xmlTextReaderPtr reader;
1415 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
1416 retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1419 reader = xmlReaderForFile(manifest, NULL, 0);
1422 if ( __child_element(reader, -1)) {
1423 node = xmlTextReaderConstName(reader);
1425 _LOGE("xmlTextReaderConstName value is NULL\n");
1426 xmlFreeTextReader(reader);
1428 return PMINFO_R_ERROR;
1431 if (!strcmp(ASC_CHAR(node), "manifest")) {
1432 if (xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")))
1433 val = ASC_CHAR(xmlTextReaderGetAttribute(reader, XML_CHAR("install-location")));
1436 if (strcmp(val, "internal-only") == 0)
1437 *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
1438 else if (strcmp(val, "prefer-external") == 0)
1439 *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
1441 *location = PMINFO_INSTALL_LOCATION_AUTO;
1444 _LOGE("Unable to create xml reader\n");
1445 xmlFreeTextReader(reader);
1447 return PMINFO_R_ERROR;
1451 _LOGE("xmlReaderForFile value is NULL\n");
1453 return PMINFO_R_ERROR;
1456 xmlFreeTextReader(reader);
1463 API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
1465 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1467 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1468 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1470 if (info->pkg_info == NULL || info->pkg_info->root_path == NULL)
1471 return PMINFO_R_ERROR;
1473 *path = (char *)info->pkg_info->root_path;
1478 API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
1480 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1482 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1483 retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1485 if (info->pkg_info == NULL || info->pkg_info->csc_path == NULL)
1486 return PMINFO_R_ERROR;
1488 *path = (char *)info->pkg_info->csc_path;
1494 API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
1496 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1497 retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1499 #if 0 //smack issue occured, check later
1501 pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
1503 _LOGD("invalid func parameters\n");
1504 return PMINFO_R_ERROR;
1506 _LOGD("pkgmgr_get_pkg_external_validation() called\n");
1509 char app_mmc_path[FILENAME_MAX] = { 0, };
1510 char app_dir_path[FILENAME_MAX] = { 0, };
1511 char app_mmc_internal_path[FILENAME_MAX] = { 0, };
1512 snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid);
1513 snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid);
1514 snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
1516 /*check whether application is in external memory or not */
1517 fp = fopen(app_mmc_path, "r");
1519 _LOGD(" app path in external memory not accesible\n");
1524 _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
1528 /*check whether application is in internal or not */
1529 fp = fopen(app_dir_path, "r");
1531 _LOGD(" app path in internal memory not accesible\n");
1533 return PMINFO_R_ERROR;
1536 /*check whether the application is installed in SD card
1537 but SD card is not present*/
1538 fp = fopen(app_mmc_internal_path, "r");
1541 _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
1546 _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
1551 _LOGD("pkgmgr_get_pkg_external_validation() end\n");
1558 API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
1560 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1562 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1563 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1565 if (info->pkg_info == NULL || info->pkg_info->removable == NULL)
1566 return PMINFO_R_ERROR;
1568 *removable = _get_bool_value(info->pkg_info->removable);
1573 API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
1576 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1578 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1579 retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1581 if (info->pkg_info == NULL || info->pkg_info->installlocation == NULL)
1582 return PMINFO_R_ERROR;
1584 val = (char *)info->pkg_info->installlocation;
1585 if (strcmp(val, "internal-only") == 0)
1587 else if (strcmp(val, "prefer-external") == 0)
1595 API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
1597 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1599 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1600 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1602 if (info->pkg_info == NULL || info->pkg_info->preload == NULL)
1603 return PMINFO_R_ERROR;
1605 *preload = _get_bool_value(info->pkg_info->preload);
1610 API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
1612 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1614 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1615 retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1617 if (info->pkg_info == NULL || info->pkg_info->system == NULL)
1618 return PMINFO_R_ERROR;
1620 *system = _get_bool_value(info->pkg_info->system);
1625 API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
1627 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1629 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1630 retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1632 if (info->pkg_info == NULL || info->pkg_info->readonly == NULL)
1633 return PMINFO_R_ERROR;
1635 *readonly = _get_bool_value(info->pkg_info->readonly);
1640 API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
1642 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1644 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1645 retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1647 if (info->pkg_info == NULL || info->pkg_info->update == NULL)
1648 return PMINFO_R_ERROR;
1650 *update = _get_bool_value(info->pkg_info->update);
1655 API int pkgmgrinfo_pkginfo_is_support_disable(pkgmgrinfo_pkginfo_h handle, bool *support_disable)
1657 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1659 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1660 retvm_if(support_disable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1662 if (info->pkg_info == NULL || info->pkg_info->support_disable == NULL)
1663 return PMINFO_R_ERROR;
1665 *support_disable = _get_bool_value(info->pkg_info->support_disable);
1670 API int pkgmgrinfo_pkginfo_is_global(pkgmgrinfo_pkginfo_h handle, bool *global)
1672 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1674 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1675 retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1677 if (info->pkg_info == NULL || info->pkg_info->for_all_users == NULL)
1678 return PMINFO_R_ERROR;
1680 *global = _get_bool_value(info->pkg_info->for_all_users);
1685 API int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users)
1687 return pkgmgrinfo_pkginfo_is_global(handle, for_all_users);
1690 API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
1692 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1694 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
1696 __cleanup_pkginfo(info);
1701 API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
1703 pkgmgrinfo_filter_x *filter;
1705 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
1707 filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
1708 if (filter == NULL) {
1709 _LOGE("Out of Memory!!!");
1710 return PMINFO_R_ERROR;
1718 API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
1720 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1722 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1725 g_slist_foreach(filter->list, __destroy_each_node, NULL);
1726 g_slist_free(filter->list);
1734 API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
1735 const char *property, const int value)
1737 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
1741 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1742 pkgmgrinfo_node_x *node;
1744 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1745 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1747 prop = _pminfo_pkginfo_convert_to_prop_int(property);
1748 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
1749 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
1750 _LOGE("Invalid Integer Property\n");
1751 return PMINFO_R_EINVAL;
1753 node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
1755 _LOGE("Out of Memory!!!\n");
1756 return PMINFO_R_ERROR;
1758 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
1759 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
1761 _LOGE("Out of Memory\n");
1763 return PMINFO_R_ERROR;
1767 /*If API is called multiple times for same property, we should override the previous values.
1768 Last value set will be used for filtering.*/
1769 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1771 filter->list = g_slist_delete_link(filter->list, link);
1772 filter->list = g_slist_append(filter->list, (gpointer)node);
1777 API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
1778 const char *property, const bool value)
1783 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1784 pkgmgrinfo_node_x *node;
1786 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1787 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1789 prop = _pminfo_pkginfo_convert_to_prop_bool(property);
1790 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
1791 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
1792 _LOGE("Invalid Boolean Property\n");
1793 return PMINFO_R_EINVAL;
1795 node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
1797 _LOGE("Out of Memory!!!\n");
1798 return PMINFO_R_ERROR;
1801 val = strndup("('true','True')", 15);
1803 val = strndup("('false','False')", 17);
1805 _LOGE("Out of Memory\n");
1807 return PMINFO_R_ERROR;
1811 /*If API is called multiple times for same property, we should override the previous values.
1812 Last value set will be used for filtering.*/
1813 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1815 filter->list = g_slist_delete_link(filter->list, link);
1816 filter->list = g_slist_append(filter->list, (gpointer)node);
1821 API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
1822 const char *property, const char *value)
1827 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
1828 pkgmgrinfo_node_x *node;
1830 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1831 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1832 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
1834 prop = _pminfo_pkginfo_convert_to_prop_str(property);
1835 if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
1836 prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
1837 _LOGE("Invalid String Property\n");
1838 return PMINFO_R_EINVAL;
1840 node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
1842 _LOGE("Out of Memory!!!\n");
1843 return PMINFO_R_ERROR;
1845 if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
1846 val = strndup("auto", PKG_STRING_LEN_MAX - 1);
1847 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
1848 val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
1849 else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
1850 val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
1851 else if (strcmp(value, "installed_internal") == 0)
1852 val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
1853 else if (strcmp(value, "installed_external") == 0)
1854 val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
1856 val = strndup(value, PKG_STRING_LEN_MAX - 1);
1858 _LOGE("Out of Memory\n");
1860 return PMINFO_R_ERROR;
1864 /*If API is called multiple times for same property, we should override the previous values.
1865 Last value set will be used for filtering.*/
1866 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
1868 filter->list = g_slist_delete_link(filter->list, link);
1869 filter->list = g_slist_append(filter->list, (gpointer)node);
1874 API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count, uid_t uid)
1879 if (handle == NULL || count == NULL) {
1880 _LOGE("invalid parameter");
1881 return PMINFO_R_EINVAL;
1884 ret = _pkginfo_get_filtered_list((pkgmgrinfo_filter_x *)handle, uid, &list);
1885 if (ret != PMINFO_R_OK)
1886 return PMINFO_R_ERROR;
1888 *count = g_list_length(list);
1890 g_list_free_full(list, free);
1895 API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
1897 return pkgmgrinfo_pkginfo_usr_filter_count(handle, count, GLOBAL_USER);
1900 API int pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(
1901 pkgmgrinfo_pkginfo_filter_h handle,
1902 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
1904 if (handle == NULL || pkg_cb == NULL) {
1905 LOGE("invalid parameter");
1906 return PMINFO_R_EINVAL;
1909 return _pkginfo_get_filtered_foreach_pkginfo(handle, pkg_cb, user_data,
1913 API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
1914 pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
1916 return pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, pkg_cb, user_data, GLOBAL_USER);
1919 API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
1920 pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
1922 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
1923 retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
1925 const char *privilege;
1927 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
1929 if (info->pkg_info == NULL)
1930 return PMINFO_R_ERROR;
1932 for (tmp = info->pkg_info->privileges; tmp; tmp = tmp->next) {
1933 privilege = (const char *)tmp->data;
1934 if (privilege == NULL)
1936 ret = privilege_func(privilege, user_data);
1943 API int pkgmgrinfo_create_pkgusrdbinfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkgdbinfo_h *handle)
1945 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
1946 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
1948 char *manifest = NULL;
1949 manifest_x *mfx = NULL;
1951 manifest = pkgmgr_parser_get_usr_manifest_file(pkgid, uid);
1952 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
1954 mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
1959 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
1961 *handle = (void *)mfx;
1966 API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
1968 retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
1969 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
1971 char *manifest = NULL;
1972 manifest_x *mfx = NULL;
1974 manifest = pkgmgr_parser_get_manifest_file(pkgid);
1975 retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
1977 mfx = pkgmgr_parser_process_manifest_xml(manifest);
1982 retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
1984 *handle = (void *)mfx;
1989 API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
1992 manifest_x *mfx = (manifest_x *)handle;
1994 retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
1995 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
1998 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2001 free((void *)mfx->type);
2003 mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
2008 API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
2011 manifest_x *mfx = (manifest_x *)handle;
2013 retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
2014 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2016 len = strlen(version);
2017 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2020 free((void *)mfx->version);
2022 mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
2026 API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
2028 manifest_x *mfx = (manifest_x *)handle;
2030 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2031 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2033 if (mfx->installlocation)
2034 free((void *)mfx->installlocation);
2036 if (location == INSTALL_INTERNAL)
2037 mfx->installlocation = strdup("internal-only");
2038 else if (location == INSTALL_EXTERNAL)
2039 mfx->installlocation = strdup("prefer-external");
2044 API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
2046 manifest_x *mfx = (manifest_x *)handle;
2048 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2049 retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
2051 if (mfx->package_size)
2052 free((void *)mfx->package_size);
2054 mfx->package_size = strdup(size);
2059 API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
2062 manifest_x *mfx = (manifest_x *)handle;
2065 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2066 retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
2068 len = strlen(label_txt);
2069 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2071 label = calloc(1, sizeof(label_x));
2072 retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
2075 label->lang = strdup(locale);
2077 label->lang = strdup(DEFAULT_LOCALE);
2078 label->text = strdup(label_txt);
2079 mfx->label = g_list_append(mfx->label, label);
2084 API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
2087 manifest_x *mfx = (manifest_x *)handle;
2090 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2091 retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
2093 len = strlen(icon_txt);
2094 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2096 icon = calloc(1, sizeof(icon_x));
2097 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
2100 icon->lang = strdup(locale);
2102 icon->lang = strdup(DEFAULT_LOCALE);
2103 icon->text = strdup(icon_txt);
2104 mfx->icon = g_list_append(mfx->icon, icon);
2109 API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
2111 int len = strlen(desc_txt);
2112 manifest_x *mfx = (manifest_x *)handle;
2113 description_x *description;
2115 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2116 retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
2118 len = strlen(desc_txt);
2119 retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
2121 description = calloc(1, sizeof(description_x));
2122 retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
2125 description->lang = strdup(locale);
2127 description->lang = strdup(DEFAULT_LOCALE);
2128 description->text = strdup(desc_txt);
2129 mfx->description = g_list_append(mfx->description, description);
2134 API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
2135 const char *author_email, const char *author_href, const char *locale)
2137 manifest_x *mfx = (manifest_x *)handle;
2140 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2142 author = calloc(1, sizeof(author_x));
2143 retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
2146 author->text = strdup(author_name);
2148 author->email = strdup(author_email);
2150 author->href = strdup(author_href);
2152 author->lang = strdup(locale);
2154 author->lang = strdup(DEFAULT_LOCALE);
2155 mfx->author = g_list_append(mfx->author, author);
2159 API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
2161 manifest_x *mfx = (manifest_x *)handle;
2163 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2164 retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2167 free((void *)mfx->removable);
2170 mfx->removable = strdup("false");
2171 else if (removable == 1)
2172 mfx->removable = strdup("true");
2177 API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
2179 manifest_x *mfx = (manifest_x *)handle;
2181 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2182 retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2185 free((void *)mfx->preload);
2188 mfx->preload = strdup("false");
2189 else if (preload == 1)
2190 mfx->preload = strdup("true");
2195 API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
2197 manifest_x *mfx = (manifest_x *)handle;
2199 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2200 retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
2202 if (mfx->installed_storage)
2203 free((void *)mfx->installed_storage);
2205 if (location == INSTALL_INTERNAL)
2206 mfx->installed_storage = strdup("installed_internal");
2207 else if (location == INSTALL_EXTERNAL)
2208 mfx->installed_storage = strdup("installed_external");
2213 API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
2216 manifest_x *mfx = (manifest_x *)handle;
2217 mfx = (manifest_x *)handle;
2219 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2221 ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
2223 _LOGE("Successfully stored info in DB\n");
2226 _LOGE("Failed to store info in DB\n");
2227 return PMINFO_R_ERROR;
2231 API int pkgmgrinfo_save_pkgusrdbinfo(pkgmgrinfo_pkgdbinfo_h handle, uid_t uid)
2234 manifest_x *mfx = (manifest_x *)handle;
2236 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2238 ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
2240 _LOGE("Successfully stored info in DB\n");
2243 _LOGE("Failed to store info in DB\n");
2244 return PMINFO_R_ERROR;
2248 API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
2250 manifest_x *mfx = (manifest_x *)handle;
2252 retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
2254 pkgmgrinfo_basic_free_package(mfx);