} while (0)
#define retm_if(expr, fmt, arg...) do { \
- if (expr) { \
- PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
- return; \
- } \
- } while (0)
+ if (expr) { \
+ PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+ return; \
+ } \
+} while (0)
#define retv_if(expr, val) do { \
- if (expr) { \
- PKGMGR_INFO_DEBUG_ERR("(%s) ", #expr); \
- return (val); \
- } \
- } while (0)
+ if (expr) { \
+ PKGMGR_INFO_DEBUG_ERR("(%s) ", #expr); \
+ return (val); \
+ } \
+} while (0)
#define retvm_if(expr, val, fmt, arg...) do { \
if (expr) { \
} \
} while (0)
+#define trym_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
+ goto catch; \
+ } \
+} while (0)
+
#define tryvm_if(expr, val, fmt, arg...) do { \
if (expr) { \
PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
#define PMINFO_PKGINFO_PROP_RANGE_BASIC "PMINFO_PKGINFO_PROP_RANGE_BASIC"
/* For multiuser support */
-char *getIconPath(uid_t uid);
-char *getUserPkgParserDBPath(void);
-char *getUserPkgParserDBPathUID(uid_t uid);
-char *getUserPkgCertDBPath(void);
-char *getUserPkgCertDBPathUID(uid_t uid);
-const char* getUserDesktopPath(uid_t uid);
-const char* getUserManifestPath(uid_t uid);
+const char *getIconPath(uid_t uid);
+const char *getUserPkgParserDBPath(void);
+const char *getUserPkgParserDBPathUID(uid_t uid);
+const char *getUserPkgCertDBPath(void);
+const char *getUserPkgCertDBPathUID(uid_t uid);
+const char *getUserDesktopPath(uid_t uid);
+const char *getUserManifestPath(uid_t uid);
/**
* @fn int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
static void __ps_free_metadata(metadata_x *metadata);
static void __ps_free_permission(permission_x *permission);
static void __ps_free_compatibility(compatibility_x *compatibility);
-static void __ps_free_resolution(resolution_x *resolution);
static void __ps_free_request(request_x *request);
static void __ps_free_define(define_x *define);
static void __ps_free_appsvc(appsvc_x *appsvc);
static void __ps_free_icon(icon_x *icon);
static void __ps_free_author(author_x *author);
static void __ps_free_description(description_x *description);
-static void __ps_free_capability(capability_x *capability);
static void __ps_free_license(license_x *license);
static void __ps_free_appcontrol(appcontrol_x *appcontrol);
static void __ps_free_datacontrol(datacontrol_x *datacontrol);
static void __str_trim(char *input);
static char *__get_parser_plugin(const char *type);
static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
-static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
-static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
-static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
API int __is_admin();
static void __save_xml_attribute(xmlTextReaderPtr reader, char *attribute, const char **xml_attribute, char *default_value)
detail = (__metadata_t *)list->data;
if (detail) {
if (detail->key)
- free(detail->key);
+ free((void *)detail->key);
if (detail->value)
- free(detail->value);
+ free((void *)detail->value);
free(detail);
}
list = g_list_next(list);
detail = (__category_t *)list->data;
if (detail) {
if (detail->name)
- free(detail->name);
+ free((void *)detail->name);
free(detail);
}
return -1;
}
- while(up != NULL)
- {
+ while(up != NULL) {
md = up->metadata;
- while (md != NULL)
- {
+ while (md != NULL) {
//get glist of metadata key and value combination
memset(buffer, 0x00, 1024);
snprintf(buffer, 1024, "%s/", md_key);
goto END;
}
- md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2));
+ md_detail->key = strdup(md->key);
if (md_detail->key == NULL) {
_LOGD("Memory allocation failed\n");
free(md_detail);
goto END;
}
- snprintf(md_detail->key, (strlen(md->key)+1), "%s", md->key);
- md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2));
+ md_detail->value = strdup(md->value);
if (md_detail->value == NULL) {
_LOGD("Memory allocation failed\n");
- free(md_detail->key);
+ free((void *)md_detail->key);
free(md_detail);
goto END;
}
- snprintf(md_detail->value, (strlen(md->value)+1), "%s", md->value);
md_list = g_list_append(md_list, (gpointer)md_detail);
tag_exist = 1;
return -1;
}
- while(up != NULL)
- {
+ while(up != NULL) {
category = up->category;
- while (category != NULL)
- {
+ while (category != NULL) {
//get glist of category key and value combination
memset(buffer, 0x00, 1024);
snprintf(buffer, 1024, "%s/", category_key);
goto END;
}
- category_detail->name = (char*) calloc(1, sizeof(char)*(strlen(category->name)+2));
+ category_detail->name = strdup(category->name);
if (category_detail->name == NULL) {
_LOGD("Memory allocation failed\n");
free(category_detail);
goto END;
}
- snprintf(category_detail->name, (strlen(category->name)+1), "%s", category->name);
category_list = g_list_append(category_list, (gpointer)category_detail);
tag_exist = 1;
return ret;
}
-static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid)
-{
- int ret = -1;
- const xmlChar *name;
-
-// _LOGD("__run_parser_prestep");
-
- if (xmlTextReaderDepth(reader) != 1) {
- _LOGE("Node depth is not 1");
- goto END;
- }
-
- if (xmlTextReaderNodeType(reader) != 1) {
- _LOGE("Node type is not 1");
- goto END;
- }
-
- const xmlChar *value;
- name = xmlTextReaderConstName(reader);
- if (name == NULL) {
- _LOGE("TEST TEST TES\n");
- name = BAD_CAST "--";
- }
-
- value = xmlTextReaderConstValue(reader);
- _LOGD("%d %d %s %d %d",
- xmlTextReaderDepth(reader),
- xmlTextReaderNodeType(reader),
- name,
- xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader));
-
- if (value != NULL) {
- if (xmlStrlen(value) > 40) {
- _LOGD(" %.40s...", value);
- } else {
- _LOGD(" %s", value);
- }
- }
-
- name = xmlTextReaderConstName(reader);
- if (name == NULL) {
- _LOGE("TEST TEST TES\n");
- name = BAD_CAST "--";
- }
-
- xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader);
- _LOGD("docPtr->URL %s\n", (char *)docPtr->URL);
- xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1);
- if (copyDocPtr == NULL)
- return -1;
- xmlNode *rootElement = xmlDocGetRootElement(copyDocPtr);
- if (rootElement == NULL)
- return -1;
- xmlNode *cur_node = xmlFirstElementChild(rootElement);
- if (cur_node == NULL)
- return -1;
- xmlNode *temp = xmlTextReaderExpand(reader);
- if (temp == NULL)
- return -1;
- xmlNode *next_node = NULL;
- while(cur_node != NULL) {
- if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
- (temp->line == cur_node->line) ) {
- break;
- }
- else {
- next_node = xmlNextElementSibling(cur_node);
- xmlUnlinkNode(cur_node);
- xmlFreeNode(cur_node);
- cur_node = next_node;
- }
- }
- if (cur_node == NULL)
- return -1;
- next_node = xmlNextElementSibling(cur_node);
- if (next_node) {
- cur_node->next = NULL;
- next_node->prev = NULL;
- xmlFreeNodeList(next_node);
- xmlSetTreeDoc(cur_node, copyDocPtr);
- } else {
- xmlSetTreeDoc(cur_node, copyDocPtr);
- }
-
-#ifdef __DEBUG__
-
-//#else
- _LOGD("node type: %d, name: %s children->name: %s last->name: %s\n"
- "parent->name: %s next->name: %s prev->name: %s\n",
- cur_node->type, cur_node->name,
- cur_node->children ? cur_node->children->name : "NULL",
- cur_node->last ? cur_node->last->name : "NULL",
- cur_node->parent ? cur_node->parent->name : "NULL",
- cur_node->next ? cur_node->next->name : "NULL",
- cur_node->prev ? cur_node->prev->name : "NULL");
-
- FILE *fp = fopen(tzplatform_mkpath(TZ_SYS_SHARE, "test.xml"), "a");
- xmlDocDump(fp, copyDocPtr);
- fclose(fp);
-#endif
-
- ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
- END:
-
- return ret;
-}
-
-static void
-__processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid)
-{
- char *tag = NULL;
- int i = 0;
-
- switch (xmlTextReaderNodeType(reader)) {
- case XML_READER_TYPE_END_ELEMENT:
- {
- // _LOGD("XML_READER_TYPE_END_ELEMENT");
- break;
- }
-
- case XML_READER_TYPE_ELEMENT:
- {
- // Elements without closing tag don't receive
- // XML_READER_TYPE_END_ELEMENT event.
-
- const xmlChar *elementName =
- xmlTextReaderLocalName(reader);
- if (elementName == NULL) {
-// _LOGD("elementName %s\n", (char *)elementName);
- break;
- }
-
- const xmlChar *nameSpace =
- xmlTextReaderConstNamespaceUri(reader);
- if (nameSpace) {
-// _LOGD("nameSpace %s\n", (char *)nameSpace);
- }
-/*
- _LOGD("XML_READER_TYPE_ELEMENT %s, %s\n",
- elementName ? elementName : "NULL",
- nameSpace ? nameSpace : "NULL");
-*/
- if (tagv == NULL) {
- _LOGD("__run_parser_prestep pkgid[%s]\n", pkgid);
- __run_parser_prestep(reader, action, pkgid);
- }
- else {
- i = 0;
- for (tag = tagv[0]; tag; tag = tagv[++i])
- if (strcmp(tag, ASCII(elementName)) == 0) {
- _LOGD("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
- __run_parser_prestep(reader,
- action, pkgid);
- break;
- }
- }
-
- break;
- }
- case XML_READER_TYPE_TEXT:
- case XML_READER_TYPE_CDATA:
- {
- const xmlChar *value = xmlTextReaderConstValue(reader);
- if (value) {
-// _LOGD("value %s\n", value);
- }
-
- const xmlChar *lang = xmlTextReaderConstXmlLang(reader);
- if (lang) {
-// _LOGD("lang\n", lang);
- }
-
-/* _LOGD("XML_READER_TYPE_TEXT %s, %s\n",
- value ? value : "NULL", lang ? lang : "NULL");
-*/
- break;
- }
- default:
-// _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
- break;
- }
-}
-
-static void
-__processTag(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, char *tag, const char *pkgid)
+static void __process_tag(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, char *tag, const char *pkgid)
{
switch (xmlTextReaderNodeType(reader)) {
case XML_READER_TYPE_END_ELEMENT:
return ret;
}
-static void __plugin_send_tag(const char *tag, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
-{
- char *lib_path = NULL;
- void *lib_handle = NULL;
- int (*plugin_install) (const char *);
- int ret = -1;
- char *ac = NULL;
-
- if (process == PLUGIN_PRE_PROCESS) {
- switch (action) {
- case ACTION_INSTALL:
- ac = "PKGMGR_PARSER_PLUGIN_PRE_INSTALL";
- break;
- case ACTION_UPGRADE:
- ac = "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE";
- break;
- case ACTION_UNINSTALL:
- ac = "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL";
- break;
- default:
- goto END;
- }
- } else if (process == PLUGIN_POST_PROCESS) {
- switch (action) {
- case ACTION_INSTALL:
- ac = "PKGMGR_PARSER_PLUGIN_POST_INSTALL";
- break;
- case ACTION_UPGRADE:
- ac = "PKGMGR_PARSER_PLUGIN_POST_UPGRADE";
- break;
- case ACTION_UNINSTALL:
- ac = "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL";
- break;
- default:
- goto END;
- }
- } else
- goto END;
-
- lib_path = __get_parser_plugin(tag);
- if (!lib_path) {
- goto END;
- }
-
- if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
- _LOGE("dlopen is failed lib_path[%s] for tag[%s]\n", lib_path, tag);
- goto END;
- }
- if ((plugin_install =
- dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
-// _LOGE("can not find symbol[%s] for tag[%s] \n", ac, tag);
- goto END;
- }
-
- ret = plugin_install(pkgid);
- if (ret < 0)
- _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin fail\n", process, pkgid, tag);
- else
- _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin success\n", process, pkgid, tag);
-
-END:
- if (lib_path)
- free(lib_path);
- if (lib_handle)
- dlclose(lib_handle);
-}
-
-static void
-__plugin_process_tag(char *const tag_list[], ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid)
-{
- char *tag = NULL;
- int i = 0;
-
- for (tag = tag_list[0]; tag; tag = tag_list[++i])
- __plugin_send_tag(tag, action, process, pkgid);
-
-}
-
-static void
-__plugin_save_tag(xmlTextReaderPtr reader, char *const tagv[], char *tag_list[])
-{
- char *tag = NULL;
- int i = 0;
- static int pre_cnt=0;
-
- switch (xmlTextReaderNodeType(reader)) {
- case XML_READER_TYPE_ELEMENT:
- {
- const xmlChar *elementName = xmlTextReaderLocalName(reader);
- if (elementName == NULL) {
- break;
- }
- i = 0;
- for (tag = tag_list[0]; tag; tag = tag_list[++i])
- if (strcmp(ASCII(elementName), tag) == 0) {
- return;
- }
- i = 0;
- for (tag = tagv[0]; tag; tag = tagv[++i])
- if (strcmp(tag, ASCII(elementName)) == 0) {
- tag_list[pre_cnt++] = tag;
- break;
- }
- break;
- }
- default:
-// _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader));
- break;
- }
-}
-
-static void
-__streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid)
-{
- xmlTextReaderPtr reader;
- xmlDocPtr docPtr;
- int ret;
- __plugin_process_tag(tagv, action, PLUGIN_PRE_PROCESS, pkgid);
-
- docPtr = xmlReadFile(filename, NULL, 0);
- reader = xmlReaderWalker(docPtr);
- if (reader != NULL) {
- ret = xmlTextReaderRead(reader);
- while (ret == 1) {
- __processNode(reader, action, tagv, pkgid);
- ret = xmlTextReaderRead(reader);
- }
- xmlFreeTextReader(reader);
-
- if (ret != 0) {
- _LOGD("%s : failed to parse", filename);
- }
- } else {
- _LOGD("Unable to open %s", filename);
- }
-
- __plugin_process_tag(tagv, action, PLUGIN_POST_PROCESS, pkgid);
-}
-
static int __next_child_element(xmlTextReaderPtr reader, int depth)
{
int ret = xmlTextReaderRead(reader);
return ret;
}
-static bool __check_action_fota(char *const tagv[])
-{
- int i = 0;
- char delims[] = "=";
- char *ret_result = NULL;
- char *tag = NULL;
- int ret = false;
-
- if (tagv == NULL)
- return ret;
-
- for (tag = strdup(tagv[0]); tag != NULL; ) {
- ret_result = strtok(tag, delims);
-
- /*check tag : fota is true */
- if (strcmp(ret_result, "fota") == 0) {
- ret_result = strtok(NULL, delims);
- if (strcmp(ret_result, "true") == 0) {
- ret = true;
- }
- } else
- _LOGD("tag process [%s]is not defined\n", ret_result);
-
- free(tag);
-
- /*check next value*/
- if (tagv[++i] != NULL)
- tag = strdup(tagv[i]);
- else {
- _LOGD("tag process success...%d\n" , ret);
- return ret;
- }
- }
-
- return ret;
-}
-
static void __ps_free_category(category_x *category)
{
if (category == NULL)
compatibility = NULL;
}
-static void __ps_free_resolution(resolution_x *resolution)
-{
- if (resolution == NULL)
- return;
- if (resolution->mimetype) {
- free((void *)resolution->mimetype);
- resolution->mimetype = NULL;
- }
- if (resolution->urischeme) {
- free((void *)resolution->urischeme);
- resolution->urischeme = NULL;
- }
- free((void*)resolution);
- resolution = NULL;
-}
-
-static void __ps_free_capability(capability_x *capability)
-{
- if (capability == NULL)
- return;
- if (capability->operationid) {
- free((void *)capability->operationid);
- capability->operationid = NULL;
- }
- /*Free Resolution*/
- if (capability->resolution) {
- resolution_x *resolution = capability->resolution;
- resolution_x *tmp = NULL;
- while(resolution != NULL) {
- tmp = resolution->next;
- __ps_free_resolution(resolution);
- resolution = tmp;
- }
- }
- free((void*)capability);
- capability = NULL;
-}
-
static void __ps_free_allowed(allowed_x *allowed)
{
if (allowed == NULL)
return;
/*Free Operation*/
if (appcontrol->operation)
- free(appcontrol->operation);
+ free((void *)appcontrol->operation);
/*Free Uri*/
if (appcontrol->uri)
- free(appcontrol->uri);
+ free((void *)appcontrol->uri);
/*Free Mime*/
if (appcontrol->mime)
- free(appcontrol->mime);
+ free((void *)appcontrol->mime);
free((void*)appcontrol);
appcontrol = NULL;
}
if (reader != NULL) {
ret = xmlTextReaderRead(reader);
while (ret == 1) {
- __processTag(lib_handle, reader, action, tag, mfx->package);
+ __process_tag(lib_handle, reader, action, tag, mfx->package);
ret = xmlTextReaderRead(reader);
}
xmlFreeTextReader(reader);
int __ps_process_metadata_parser(manifest_x *mfx, ACTION_TYPE action)
{
fprintf(stdout,"__ps_process_metadata_parser\n");
- int ret = -1;
+ int ret = 0;
FILE *fp = NULL;
char md_key[PKG_STRING_LEN_MAX] = { 0 };
_LOGD("no preload list\n");
return -1;
}
-
+
while (fgets(md_key, sizeof(md_key), fp) != NULL) {
__str_trim(md_key);
ret = __run_metadata_parser_prestep(mfx, md_key, action);
-
- memset(md_key, 0x00, sizeof(md_key));
+ if (ret < 0)
+ break;
}
if (fp != NULL)
fclose(fp);
- return 0;
+ return ret;
}
int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action)
{
- int ret = -1;
+ int ret = 0;
FILE *fp = NULL;
char category_key[PKG_STRING_LEN_MAX] = { 0 };
while (fgets(category_key, sizeof(category_key), fp) != NULL) {
__str_trim(category_key);
ret = __run_category_parser_prestep(mfx, category_key, action);
-
- memset(category_key, 0x00, sizeof(category_key));
+ if (ret < 0)
+ break;
}
if (fp != NULL)
fclose(fp);
- return 0;
+ return ret;
}
static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
return ret;
}
-static char*
-__get_icon_with_path(const char* icon, uid_t uid)
+static char *__get_icon_with_path(const char * icon, uid_t uid)
{
- if (!icon)
+ char *theme;
+ char *icon_with_path;
+ char *confirmed_icon;
+ const char *app_path;
+ int len;
+
+ if (!icon || !package)
return NULL;
if (index(icon, '/') == NULL) {
- char* theme = NULL;
- char* icon_with_path = NULL;
- char *app_path = NULL;
- int len;
-
- if (!package)
- return NULL;
-
/* "db/setting/theme" is not exist */
#if 0
theme = vconf_get_str("db/setting/theme");
if (access (icon_with_path, F_OK)) { //If doesn't exist in case of Global app, try to get icon directly into app's directory
app_path = tzplatform_getenv(TZ_SYS_RW_APP);
if (app_path)
- snprintf(icon_with_path, len, "%s/%q/res/icons/%q/small/%q", app_path, package, theme, icon);
- if (access (icon_with_path, F_OK))
+ snprintf(icon_with_path, len, "%s/%s/res/icons/%s/small/%s", app_path, package, theme, icon);
+ if (access(icon_with_path, F_OK))
_LOGE("Cannot find icon path");
}
}
_LOGD("Icon path : %s ---> %s", icon, icon_with_path);
return icon_with_path;
} else {
- char* confirmed_icon = NULL;
-
confirmed_icon = strdup(icon);
if (!confirmed_icon)
return NULL;
return ret;
}
-static char* __convert_to_system_locale(const char *mlocale)
-{
- if (mlocale == NULL)
- return NULL;
- char *locale = NULL;
- locale = (char *)calloc(1, 6);
- if (!locale) {
- _LOGE("Malloc Failed\n");
- return NULL;
- }
-
- strncpy(locale, mlocale, 2);
- strncat(locale, "_", 1);
- locale[3] = toupper(mlocale[3]);
- locale[4] = toupper(mlocale[4]);
- return locale;
-}
-
#define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
static int __ps_remove_appsvc_db(manifest_x *mfx, uid_t uid)
API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
{
-// char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("parsing manifest for installation: %s\n", manifest);
_LOGD("Parsing Finished\n");
-// __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
__add_preload_info(mfx, manifest, GLOBAL_USER);
_LOGD("Added preload infomation\n");
}
API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
{
-// char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("parsing manifest for installation: %s\n", manifest);
manifest_x *mfx = NULL;
retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("Parsing Finished\n");
-// __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
__ps_process_tag(mfx, tagv);
API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
{
-// char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("pkgmgr_parser_parse_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
manifest_x *mfx = NULL;
retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("Parsing Finished\n");
-// __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
__add_preload_info(mfx, manifest, GLOBAL_USER);
_LOGD("Added preload infomation\n");
__check_preload_updated(mfx, manifest, GLOBAL_USER);
ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
if (ret != PMINFO_R_OK)
_LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
-
+
if (csc_path != NULL) {
if (mfx->csc_path)
free((void *)mfx->csc_path);
API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
{
-// char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD(" pkgmgr_parser_parse_usr_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
manifest_x *mfx = NULL;
retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("Parsing Finished\n");
- //__streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
__check_preload_updated(mfx, manifest, uid);
ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(mfx->package, uid, &handle);
API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
{
-// char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("parsing manifest for uninstallation: %s\n", manifest);
_LOGD("Parsing Finished\n");
-// __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
__ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
__add_preload_info(mfx, manifest, GLOBAL_USER);
API int pkgmgr_parser_parse_usr_manifest_for_uninstallation(const char *manifest, uid_t uid, char *const tagv[])
{
-// char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("parsing manifest for uninstallation: %s\n", manifest);
_LOGD("Parsing Finished\n");
-// __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package);
__ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
struct deviceprofile_x *next;
}deviceprofile_x;
-typedef struct resolution_x {
- const char *mimetype;
- const char *urischeme;
- struct resolution_x *prev;
- struct resolution_x *next;
-} resolution_x;
-
-typedef struct capability_x {
- const char *operationid;
- const char *access;
- struct resolution_x *resolution;
- struct capability_x *prev;
- struct capability_x *next;
-} capability_x;
-
typedef struct datacontrol_x {
const char *providerid;
const char *access;
return 0;
}
-static char *__get_str(const char *str)
+static const char *__get_str(const char *str)
{
if (str == NULL)
{
return locale;
}
-static void __printfunc(gpointer data, gpointer userdata)
-{
- _LOGD("%s ", (char*)data);
-}
-
static void __trimfunc(GList* trim_list)
{
char *trim_data = NULL;
privileges_x *pvs = NULL;
privilege_x *pv = NULL;
char query[MAX_QUERY_LEN] = { '\0' };
- char root[MAX_QUERY_LEN] = { '\0' };
int ret = -1;
const char *auth_name = NULL;
const char *auth_email = NULL;
const char *auth_href = NULL;
- const char *apps_path = NULL;
GList *pkglocale = NULL;
GList *applocale = NULL;
/*remove duplicated data in appimage*/
__trimfunc(appimage);
- /*g_list_foreach(pkglocale, __printfunc, NULL);*/
- /*_LOGD("\n");*/
- /*g_list_foreach(applocale, __printfunc, NULL);*/
-
g_list_foreach(pkglocale, __insert_pkglocale_info, (gpointer)mfx);
/*native app locale info*/
return 0;
}
-void pkgmgr_parser_close_db()
+void pkgmgr_parser_close_db(void)
{
sqlite3_close(pkgmgr_parser_db);
sqlite3_close(pkgmgr_cert_db);
int pkgmgr_parser_check_and_create_db(uid_t uid);
int pkgmgr_parser_initialize_db(uid_t uid);
+void pkgmgr_parser_close_db(void);
#endif /* __PKGMGR_PARSER_INTERNAL_H__ */
* limitations under the License.
*
*/
-#include <pkgmgr_parser.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+#include "pkgmgr_parser.h"
#include "pkgmgr_parser_signature.h"
#define ASCII(s) (const char *)s
return entry.gr_gid;
}
-API char *getIconPath(uid_t uid)
+API const char *getIconPath(uid_t uid)
{
const char *path = NULL;
uid_t uid_caller = getuid();
return path;
}
-API char *getUserPkgParserDBPath(void)
+API const char *getUserPkgParserDBPath(void)
{
return getUserPkgParserDBPathUID(GLOBAL_USER);
}
-API char *getUserPkgParserDBPathUID(uid_t uid)
+API const char *getUserPkgParserDBPathUID(uid_t uid)
{
const char *pkgmgr_parser_db = NULL;
uid_t uid_caller = getuid();
return pkgmgr_parser_db;
}
-API char *getUserPkgCertDBPath(void)
+API const char *getUserPkgCertDBPath(void)
{
return getUserPkgCertDBPathUID(GLOBAL_USER);
}
-API char *getUserPkgCertDBPathUID(uid_t uid)
+API const char *getUserPkgCertDBPathUID(uid_t uid)
{
const char *pkgmgr_cert_db = NULL;
uid_t uid_caller = getuid();
return pkgmgr_cert_db;
}
-API const char* getUserDesktopPath(uid_t uid)
+API const char *getUserDesktopPath(uid_t uid)
{
const char *path = NULL;
uid_t uid_caller = getuid();
return path;
}
-API const char* getUserManifestPath(uid_t uid)
+API const char *getUserManifestPath(uid_t uid)
{
const char *path = NULL;
uid_t uid_caller = getuid();
info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[i]);
else
info->manifest_info->uiapplication->submode_mainid = NULL;
- } else if (strcmp(colname, "app_launch_mode") == 0 ) {
+ } else if (strcmp(colname[i], "app_launch_mode") == 0 ) {
if (coltxt[i])
info->manifest_info->uiapplication->launch_mode = strdup(coltxt[i]);
else
{
char *dup;
char *token;
- char *ptr;
+ char *ptr = NULL;
appcontrol_x *ac;
if (appcontrol_str == NULL)
if (strcmp(token, "NULL"))
ac->mime = strdup(token);
LISTADD(*appcontrol, ac);
- } while (token = strtok_r(NULL, ";", &ptr));
+ } while ((token = strtok_r(NULL, ";", &ptr)));
free(dup);
}
metadata_x *metadata = NULL;
permission_x *permission = NULL;
image_x *image = NULL;
- appcontrol_x *appcontrol = NULL;
switch (info->app_component) {
case PMINFO_UI_APP:
strncpy(lang, locale, 2);
snprintf(query, MAX_QUERY_LEN, "select app_locale from package_app_localized_info where app_id='%s' and app_locale like '%s%s'", appid, lang, wildcard);
ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
- tryvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
+ trym_if(ret == -1, "Exec DB query failed");
locale_new = info->locale;
free(info);
return locale_new;
image_x *tmp6 = NULL;
appcontrol_x *tmp7 = NULL;
const char *user_pkg_parser = NULL;
+ pkgmgr_pkginfo_x *info = NULL;
/*get system locale*/
syslocale = vconf_get_str(VCONFKEY_LANGSET);
retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
/*calloc pkginfo*/
- pkgmgr_pkginfo_x *info = NULL;
info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
if (info->app_component == PMINFO_UI_APP)
start = info->uiapp_info->icon;
- if (info->app_component == PMINFO_SVC_APP)
+ else if (info->app_component == PMINFO_SVC_APP)
start = info->svcapp_info->icon;
+ else
+ return PMINFO_R_EINVAL;
for (ptr = start; ptr != NULL; ptr = ptr->next) {
if (ptr->lang == NULL)
if (info->app_component == PMINFO_UI_APP)
start = info->uiapp_info->label;
- if (info->app_component == PMINFO_SVC_APP)
+ else if (info->app_component == PMINFO_SVC_APP)
start = info->svcapp_info->label;
+ else
+ return PMINFO_R_EINVAL;
for (ptr = start; ptr != NULL; ptr = ptr->next) {
if (ptr->lang == NULL)
sqlite3_stmt *stmt = NULL;
sqlite3 *db = NULL;
char *val;
- char *manifest_db;
+ const char *manifest_db;
manifest_db = getUserPkgParserDBPathUID(uid);
if (manifest_db == NULL) {
API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
{
char *val;
- int ret;
retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
{
- char *val;
+ const char *val;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
appcontrol = info->svcapp_info->appcontrol;
break;
default:
- break;
+ return PMINFO_R_EINVAL;
}
for (; appcontrol; appcontrol = appcontrol->next) {
ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
pkgmgrinfo_app_list_cb app_cb, void * user_data, uid_t uid)
{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
- retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
- char *syslocale = NULL;
- char *locale = NULL;
- char *condition = NULL;
- char *error_message = NULL;
+ char *syslocale;
+ char *locale;
+ char *condition;
+ char *error_message;
char query[MAX_QUERY_LEN] = {'\0'};
char where[MAX_QUERY_LEN] = {'\0'};
GSList *list;
- int ret = 0;
- uiapplication_x *ptr1 = NULL;
- serviceapplication_x *ptr2 = NULL;
+ int ret;
+ uiapplication_x *ptr1;
+ serviceapplication_x *ptr2;
pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
+ pkgmgr_pkginfo_x *info;
+ pkgmgr_pkginfo_x *filtinfo = NULL;
+ pkgmgr_appinfo_x *appinfo = NULL;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+
/*Get current locale*/
syslocale = vconf_get_str(VCONFKEY_LANGSET);
if (syslocale == NULL) {
query[sizeof(query) - 1] = '\0';
}
/*To get filtered list*/
- pkgmgr_pkginfo_x *info = NULL;
- pkgmgr_pkginfo_x *filtinfo = NULL;
info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
if (info == NULL) {
_LOGE("Out of Memory!!!\n");
ret = PMINFO_R_ERROR;
goto err;
}
- pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
+ appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
if (appinfo == NULL) {
_LOGE("Out of Memory!!!\n");
ret = PMINFO_R_ERROR;
API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
{
+ int len;
+ manifest_x *mfx = (manifest_x *)handle;
+
retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
- int len = strlen(type);
+ len = strlen(type);
retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
- manifest_x *mfx = (manifest_x *)handle;
+ if (mfx->type)
+ free((void *)mfx->type);
mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
+
return PMINFO_R_OK;
}
API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
{
+ int len;
+ manifest_x *mfx = (manifest_x *)handle;
+
retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
- int len = strlen(version);
+ len = strlen(version);
retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
- manifest_x *mfx = (manifest_x *)handle;
+ if (mfx->version)
+ free((void *)mfx->version);
mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
return PMINFO_R_OK;
API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
{
+ manifest_x *mfx = (manifest_x *)handle;
+
retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
- manifest_x *mfx = (manifest_x *)handle;
+ if (mfx->installlocation)
+ free((void *)mfx->installlocation);
if (location == INSTALL_INTERNAL)
- strcpy(mfx->installlocation, "internal-only");
+ mfx->installlocation = strdup("internal-only");
else if (location == INSTALL_EXTERNAL)
- strcpy(mfx->installlocation, "prefer-external");
+ mfx->installlocation = strdup("prefer-external");
return PMINFO_R_OK;
}
API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
{
+ manifest_x *mfx = (manifest_x *)handle;
+
retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
- manifest_x *mfx = (manifest_x *)handle;
+ if (mfx->package_size)
+ free((void *)mfx->package_size);
mfx->package_size = strdup(size);
API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
{
+ int len;
+ manifest_x *mfx = (manifest_x *)handle;
+ label_x *label;
+
retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
- int len = strlen(label_txt);
+ len = strlen(label_txt);
retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
- manifest_x *mfx = (manifest_x *)handle;
-
- label_x *label = calloc(1, sizeof(label_x));
+ label = calloc(1, sizeof(label_x));
retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
LISTADD(mfx->label, label);
API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
{
+ int len;
+ manifest_x *mfx = (manifest_x *)handle;
+ icon_x *icon;
+
retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
- int len = strlen(icon_txt);
+ len = strlen(icon_txt);
retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
- manifest_x *mfx = (manifest_x *)handle;
-
- icon_x *icon = calloc(1, sizeof(icon_x));
+ icon = calloc(1, sizeof(icon_x));
retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
LISTADD(mfx->icon, icon);
API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
{
+ int len = strlen(desc_txt);
+ manifest_x *mfx = (manifest_x *)handle;
+ description_x *description;
+
retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
- int len = strlen(desc_txt);
+ len = strlen(desc_txt);
retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
- manifest_x *mfx = (manifest_x *)handle;
-
- description_x *description = calloc(1, sizeof(description_x));
+ description = calloc(1, sizeof(description_x));
retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
LISTADD(mfx->description, description);
API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
const char *author_email, const char *author_href, const char *locale)
{
- retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
manifest_x *mfx = (manifest_x *)handle;
- author_x *author = calloc(1, sizeof(author_x));
+ author_x *author;
+
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
+ author = calloc(1, sizeof(author_x));
retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
LISTADD(mfx->author, author);
API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
{
+ manifest_x *mfx = (manifest_x *)handle;
+
retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
- manifest_x *mfx = (manifest_x *)handle;
+ if (mfx->removable)
+ free((void *)mfx->removable);
if (removable == 0)
- strcpy(mfx->removable, "false");
+ mfx->removable = strdup("false");
else if (removable == 1)
- strcpy(mfx->removable, "true");
+ mfx->removable = strdup("true");
return PMINFO_R_OK;
}
API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
{
+ manifest_x *mfx = (manifest_x *)handle;
+
retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
- manifest_x *mfx = (manifest_x *)handle;
+ if (mfx->preload)
+ free((void *)mfx->preload);
if (preload == 0)
- strcpy(mfx->preload, "false");
+ mfx->preload = strdup("false");
else if (preload == 1)
- strcpy(mfx->preload, "true");
+ mfx->preload = strdup("true");
return PMINFO_R_OK;
}
API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
{
+ manifest_x *mfx = (manifest_x *)handle;
+
retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
- manifest_x *mfx = (manifest_x *)handle;
+ if (mfx->installed_storage)
+ free((void *)mfx->installed_storage);
if (location == INSTALL_INTERNAL)
- strcpy(mfx->installed_storage, "installed_internal");
+ mfx->installed_storage = strdup("installed_internal");
else if (location == INSTALL_EXTERNAL)
- strcpy(mfx->installed_storage, "installed_external");
+ mfx->installed_storage = strdup("installed_external");
return PMINFO_R_OK;
}
API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
{
- retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
-
- int ret = 0;
- manifest_x *mfx = NULL;
+ int ret;
+ manifest_x *mfx = (manifest_x *)handle;
mfx = (manifest_x *)handle;
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
if (ret == 0) {
_LOGE("Successfully stored info in DB\n");
API int pkgmgrinfo_save_pkgusrdbinfo(pkgmgrinfo_pkgdbinfo_h handle, uid_t uid)
{
- retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+ int ret;
+ manifest_x *mfx = (manifest_x *)handle;
- int ret = 0;
- manifest_x *mfx = NULL;
- mfx = (manifest_x *)handle;
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
if (ret == 0) {
API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
{
+ manifest_x *mfx = (manifest_x *)handle;
+
retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
- manifest_x *mfx = NULL;
- mfx = (manifest_x *)handle;
pkgmgr_parser_free_manifest_xml(mfx);
+
return PMINFO_R_OK;
}
API int pkgmgrinfo_appinfo_set_usr_state_enabled(const char *appid, bool enabled, uid_t uid)
{
- retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
- int ret = -1;
+ int ret;
char query[MAX_QUERY_LEN] = {'\0'};
+ char *error_message;
+
+ retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
/* Open db.*/
ret = __open_manifest_db(uid);
snprintf(query, MAX_QUERY_LEN,
"update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
- char *error_message = NULL;
if (SQLITE_OK !=
sqlite3_exec(GET_DB(manifest_db), query, NULL, NULL, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
{
+ int ret;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ char *error_message;
+ pkgmgr_datacontrol_x *data;
+
retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
- int ret = PMINFO_R_OK;
- char query[MAX_QUERY_LEN] = {'\0'};
- char *error_message = NULL;
- pkgmgr_datacontrol_x *data = NULL;
ret = __open_datacontrol_db();
if (ret == -1) {
*appid = (char *)data->appid;
*access = (char *)data->access;
free(data);
- __close_datacontrol_db();
+ __close_datacontrol_db();
return PMINFO_R_OK;
}
API int pkgmgrinfo_appinfo_set_usr_default_label(const char *appid, const char *label, uid_t uid)
{
- retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
- int ret = -1;
+ int ret;
char query[MAX_QUERY_LEN] = {'\0'};
- char *error_message = NULL;
- ret = __open_manifest_db(uid);
+ char *error_message;
+ retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
+
+ ret = __open_manifest_db(uid);
+ if (ret == -1) {
+ _LOGE("Fail to open manifest DB\n");
+ return PMINFO_R_ERROR;
+ }
/*Begin transaction*/
ret = sqlite3_exec(GET_DB(manifest_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
{
+ const char *val;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
- char *val = NULL;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- val = (char *)info->uiapp_info->guestmode_visibility;
+
+ val = info->uiapp_info->guestmode_visibility;
if (val) {
if (strcasecmp(val, "true") == 0){
*status = 1;
API int pkgmgrinfo_appinfo_set_usr_guestmode_visibility(pkgmgrinfo_appinfo_h handle, uid_t uid, bool status)
{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
- char *val = NULL;
- int ret = 0;
- int len = 0;
+ const char *val;
+ int ret;
char query[MAX_QUERY_LEN] = {'\0'};
- char *errmsg = NULL;
+ char *errmsg;
sqlite3 *pkgmgr_parser_db;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- val = (char *)info->uiapp_info->guestmode_visibility;
- if (val ) {
- ret =
- db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkgmgr_parser_db,
+ val = info->uiapp_info->guestmode_visibility;
+ if (val) {
+ ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkgmgr_parser_db,
SQLITE_OPEN_READWRITE, NULL);
-
if (ret != SQLITE_OK) {
_LOGE("DB Open Failed\n");
return PMINFO_R_ERROR;
/* pkgmgrinfo client start*/
API pkgmgrinfo_client *pkgmgrinfo_client_new(pkgmgrinfo_client_type ctype)
{
- int ret = 0;
- char *errmsg = NULL;
+ char *errmsg;
void *pc = NULL;
- void *handle = NULL;
+ void *handle;
pkgmgrinfo_client *(*__pkgmgr_client_new)(pkgmgrinfo_client_type ctype) = NULL;
handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
- retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror());
+ retvm_if(!handle, NULL, "dlopen() failed. [%s]", dlerror());
__pkgmgr_client_new = dlsym(handle, "pkgmgr_client_new");
errmsg = dlerror();
- tryvm_if((errmsg != NULL) || (__pkgmgr_client_new == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg);
+ trym_if((errmsg != NULL) || (__pkgmgr_client_new == NULL), "dlsym() failed. [%s]", errmsg);
pc = __pkgmgr_client_new(ctype);
- tryvm_if(pc == NULL, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed.");
+ trym_if(pc == NULL, "pkgmgr_client_new failed.");
catch:
dlclose(handle);
API int pkgmgrinfo_client_set_status_type(pkgmgrinfo_client *pc, int status_type)
{
- int ret = 0;
- char *errmsg = NULL;
- void *handle = NULL;
+ int ret;
+ char *errmsg;
+ void *handle;
int (*__pkgmgr_client_set_status_type)(pkgmgrinfo_client *pc, int status_type) = NULL;
handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL);
API int pkgmgrinfo_client_request_enable_external_pkg(char *pkgid)
{
- int ret = 0;
DBusConnection *bus;
- DBusMessage *message;
+ DBusMessage *message = NULL;
+ DBusMessage *reply = NULL;
retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
retvm_if(bus == NULL, PMINFO_R_EINVAL, "dbus_bus_get() failed.");
message = dbus_message_new_method_call (SERVICE_NAME, PATH_NAME, INTERFACE_NAME, METHOD_NAME);
- retvm_if(message == NULL, PMINFO_R_EINVAL, "dbus_message_new_method_call() failed.");
+ trym_if(message == NULL, "dbus_message_new_method_call() failed.");
dbus_message_append_args(message, DBUS_TYPE_STRING, &pkgid, DBUS_TYPE_INVALID);
- ret = dbus_connection_send_with_reply_and_block(bus, message, -1, NULL);
- retvm_if(!ret, ret = PMINFO_R_EINVAL, "connection_send dbus fail");
+ reply = dbus_connection_send_with_reply_and_block(bus, message, -1, NULL);
+ trym_if(reply == NULL, "connection_send dbus fail");
+catch:
dbus_connection_flush(bus);
- dbus_message_unref(message);
+ if (message)
+ dbus_message_unref(message);
+ if (reply)
+ dbus_message_unref(reply);
return PMINFO_R_OK;
}