6 #include <tzplatform_config.h>
7 #include <pkgmgr-info.h>
9 #include "pkgmgr-server.h"
11 struct manifest_and_type {
16 struct manifest_and_type type_map[] = {
17 { "res/wgt/config.xml", "wgt" },
18 { "config.xml", "wgt" },
19 { "tizen-manifest.xml", "tpk" },
23 static const char legacy_content_path[] = "/opt/usr/media";
25 const char *_get_pkgtype_from_file(const char *file_path)
27 const char *type = NULL;
31 uf = unzOpen(file_path);
33 ERR("failed to open zip file %s", file_path);
37 for (i = 0; type_map[i].manifest != NULL; i++) {
38 if (unzLocateFile(uf, type_map[i].manifest, 0) == UNZ_OK) {
39 DBG("pkgtype of %s: [%s]", file_path, type_map[i].type);
40 type = type_map[i].type;
50 char *_get_pkgtype_from_pkgid(const char *pkgid, uid_t uid)
54 pkgmgrinfo_pkginfo_h info;
57 ret = pkgmgrinfo_pkginfo_get_usr_all_pkginfo(pkgid, uid, &info);
58 if (ret != PMINFO_R_OK)
61 ret = pkgmgrinfo_pkginfo_get_type(info, &pkgtype);
62 if (ret != PMINFO_R_OK) {
63 pkgmgrinfo_pkginfo_destroy_pkginfo(info);
67 DBG("pkgtype of %s: [%s]", pkgid, pkgtype);
69 type = strdup(pkgtype);
70 pkgmgrinfo_pkginfo_destroy_pkginfo(info);
75 const char *_get_adjusted_pkgpath(const char *org_file_path, uid_t caller_uid)
77 const char *file_path;
79 if (caller_uid >= REGULAR_USER &&
80 strstr(org_file_path, legacy_content_path) == org_file_path) {
81 DBG("legacy media path!");
82 tzplatform_set_user(caller_uid);
83 file_path = tzplatform_mkpath(TZ_USER_CONTENT,
84 org_file_path + strlen(legacy_content_path));
85 tzplatform_reset_user();
87 file_path = org_file_path;