From 9fd5b5f7dd83d56dcf2ec20219dc9bf3f11cd274 Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Mon, 9 Sep 2013 13:12:10 +0900 Subject: [PATCH 01/16] Sync to the latest code Change-Id: I5faef7bea943a194751f5df369fac38e4ab32ab2 Signed-off-by: junsuk77.oh --- CMakeLists.txt | 6 +- include/pkgmgr-info-debug.h | 2 - ...rser_list.txt.in => metadata_parser_list.txt.in | 0 packaging/pkgmgr-info.spec | 12 +- parser/CMakeLists.txt | 2 +- parser/manifest.xsd.in | 1 + parser/pkgmgr_parser.c | 984 ++++++++++++++------- parser/pkgmgr_parser.h | 1 + parser/pkgmgr_parser_db.c | 399 ++++++--- parser/pkgmgr_parser_internal.h | 24 - parser/pkgmgr_parser_signature.c | 734 +++++++++++++++ parser/pkgmgr_parser_signature.h | 130 +++ parser_path.conf.in | 2 +- src/pkgmgr-info.c | 14 +- tag_parser_list.txt.in | 7 + 15 files changed, 1832 insertions(+), 486 deletions(-) rename mdparser_list.txt.in => metadata_parser_list.txt.in (100%) create mode 100644 parser/pkgmgr_parser_signature.c create mode 100644 parser/pkgmgr_parser_signature.h create mode 100644 tag_parser_list.txt.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 17404ba..1e27766 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,12 +56,14 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/pkgmgr-info.pc.in ${CMAKE_BINARY_DIR}/pkgmgr- configure_file(parser_path.conf.in parser_path.conf @ONLY) configure_file(pkgmgr-info.manifest.in pkgmgr-info.manifest @ONLY) configure_file(pkgmgr-parser.manifest.in pkgmgr-parser.manifest @ONLY) -configure_file(mdparser_list.txt.in mdparser_list.txt @ONLY) +configure_file(metadata_parser_list.txt.in metadata_parser_list.txt @ONLY) configure_file(category_parser_list.txt.in category_parser_list.txt @ONLY) +configure_file(tag_parser_list.txt.in tag_parser_list.txt @ONLY) INSTALL(TARGETS pkgmgr-info DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-info.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/pkgmgr-info.h DESTINATION include) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/parser_path.conf DESTINATION ${PREFIX}/etc/package-manager/) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mdparser_list.txt DESTINATION ${PREFIX}/etc/package-manager/parserlib/metadata) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/metadata_parser_list.txt DESTINATION ${PREFIX}/etc/package-manager/parserlib/metadata) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/category_parser_list.txt DESTINATION ${PREFIX}/etc/package-manager/parserlib/category) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tag_parser_list.txt DESTINATION ${PREFIX}/etc/package-manager/parserlib) diff --git a/include/pkgmgr-info-debug.h b/include/pkgmgr-info-debug.h index 888a9b1..061fc50 100644 --- a/include/pkgmgr-info-debug.h +++ b/include/pkgmgr-info-debug.h @@ -24,8 +24,6 @@ #include -#undef LOG_TAG -#define LOG_TAG "PKGMGR_INFO" #define _LOGE(fmt, arg...) LOGE(fmt, ##arg) #define _LOGD(fmt, arg...) LOGD(fmt, ##arg) diff --git a/mdparser_list.txt.in b/metadata_parser_list.txt.in similarity index 100% rename from mdparser_list.txt.in rename to metadata_parser_list.txt.in diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index 39705f7..9678d10 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -1,6 +1,6 @@ Name: pkgmgr-info Summary: Packager Manager infomation api for package -Version: 0.0.135 +Version: 0.0.138 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 @@ -43,6 +43,13 @@ Dev package for libpkgmgr-parser %setup -q %build + +%if 0%{?tizen_build_binary_release_type_eng} +export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE" +export CXXFLAGS="$CXXFLAGS ?DTIZEN_ENGINEER_MODE" +export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE" +%endif + %cmake . make %{?jobs:-j%jobs} @@ -84,8 +91,9 @@ chsmack -a '_' /usr/etc/package-manager %{_prefix}/etc/package-manager/preload/manifest.xsd %{_prefix}/etc/package-manager/preload/xml.xsd %{_prefix}/etc/package-manager/parser_path.conf -%{_prefix}/etc/package-manager/parserlib/metadata/mdparser_list.txt +%{_prefix}/etc/package-manager/parserlib/metadata/metadata_parser_list.txt %{_prefix}/etc/package-manager/parserlib/category/category_parser_list.txt +%{_prefix}/etc/package-manager/parserlib/tag_parser_list.txt %files parser-devel %defattr(-,root,root,-) diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt index 870973d..6495d00 100755 --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -43,7 +43,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) ## pkgmgr_parser object (by sewook.park) # This library is for installer backend -add_library(pkgmgr_parser SHARED pkgmgr_parser.c pkgmgr_parser_db.c) +add_library(pkgmgr_parser SHARED pkgmgr_parser.c pkgmgr_parser_db.c pkgmgr_parser_signature.c) #add_library(pkgmgr_parser SHARED pkgmgr_parser.c) set_target_properties(pkgmgr_parser PROPERTIES SOVERSION ${VERSION_MAJOR}) set_target_properties(pkgmgr_parser PROPERTIES VERSION ${VERSION}) diff --git a/parser/manifest.xsd.in b/parser/manifest.xsd.in index 0f77a7a..cdf17f6 100755 --- a/parser/manifest.xsd.in +++ b/parser/manifest.xsd.in @@ -27,6 +27,7 @@ + diff --git a/parser/pkgmgr_parser.c b/parser/pkgmgr_parser.c index 986d8d6..5a6af7c 100755 --- a/parser/pkgmgr_parser.c +++ b/parser/pkgmgr_parser.c @@ -38,18 +38,28 @@ #include "pkgmgr_parser_internal.h" #include "pkgmgr_parser_db.h" #include "pkgmgr-info.h" +#include "pkgmgr_parser_signature.h" +#include "pkgmgr-info-debug.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "PKGMGR_PARSER" #define MANIFEST_RW_DIRECTORY "/opt/share/packages" #define MANIFEST_RO_DIRECTORY "/usr/share/packages" #define ASCII(s) (const char *)s #define XMLCHAR(s) (const xmlChar *)s -#define MDPARSER_LIST "/usr/etc/package-manager/parserlib/metadata/mdparser_list.txt" -#define MDPARSER_NAME "mdparser:" +#define METADATA_PARSER_LIST "/usr/etc/package-manager/parserlib/metadata/metadata_parser_list.txt" +#define METADATA_PARSER_NAME "metadataparser:" #define CATEGORY_PARSER_LIST "/usr/etc/package-manager/parserlib/category/category_parser_list.txt" #define CATEGORY_PARSER_NAME "categoryparser:" +#define TAG_PARSER_LIST "/usr/etc/package-manager/parserlib/tag_parser_list.txt" +#define TAG_PARSER_NAME "parserlib:" + #define PKG_TAG_LEN_MAX 128 /* operation_type */ @@ -57,6 +67,7 @@ typedef enum { ACTION_INSTALL = 0, ACTION_UPGRADE, ACTION_UNINSTALL, + ACTION_FOTA, ACTION_MAX } ACTION_TYPE; @@ -157,6 +168,25 @@ static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *con static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid); static int __validate_appid(const char *pkgid, const char *appid, char **newappid); +void *__open_lib_handle(char *tag) +{ + char *lib_path = NULL; + void *lib_handle = NULL; + + lib_path = __get_parser_plugin(tag); + retvm_if(!lib_path, NULL, "lib_path get fail"); + + lib_handle = dlopen(lib_path, RTLD_LAZY); + retvm_if(lib_handle == NULL, NULL, "dlopen is failed lib_path[%s]", lib_path); + + return lib_handle; +} + +void __close_lib_handle(void *lib_handle) +{ + dlclose(lib_handle); +} + static void __str_trim(char *input) { char *trim_str = input; @@ -179,7 +209,7 @@ static void __str_trim(char *input) static int __validate_appid(const char *pkgid, const char *appid, char **newappid) { if (!pkgid || !appid || !newappid) { - DBG("Arg supplied is NULL\n"); + _LOGD("Arg supplied is NULL\n"); return -1; } int pkglen = strlen(pkgid); @@ -191,17 +221,17 @@ static int __validate_appid(const char *pkgid, const char *appid, char **newappi len = pkglen + applen + 1; newapp = calloc(1,len); if (newapp == NULL) { - DBG("Malloc failed\n"); + _LOGD("Malloc failed\n"); return -1; } strncpy(newapp, pkgid, pkglen); strncat(newapp, appid, applen); - DBG("new appid is %s\n", newapp); + _LOGD("new appid is %s\n", newapp); *newappid = newapp; return 0; } if (applen < pkglen) { - DBG("app id is not proper\n"); + _LOGD("app id is not proper\n"); *newappid = NULL; #ifdef _VALIDATE_APPID_ return -1; @@ -210,7 +240,7 @@ static int __validate_appid(const char *pkgid, const char *appid, char **newappi #endif } if (!strcmp(appid, pkgid)) { - DBG("appid is proper\n"); + _LOGD("appid is proper\n"); *newappid = NULL; return 0; } @@ -218,12 +248,12 @@ static int __validate_appid(const char *pkgid, const char *appid, char **newappi ptr = strstr(appid, pkgid); ptr = ptr + pkglen; if (strncmp(ptr, ".", 1) == 0) { - DBG("appid is proper\n"); + _LOGD("appid is proper\n"); *newappid = NULL; return 0; } else { - DBG("appid is not proper\n"); + _LOGD("appid is not proper\n"); *newappid = NULL; #ifdef _VALIDATE_APPID_ return -1; @@ -232,7 +262,7 @@ static int __validate_appid(const char *pkgid, const char *appid, char **newappi #endif } } else { - DBG("appid is not proper\n"); + _LOGD("appid is not proper\n"); *newappid = NULL; #ifdef _VALIDATE_APPID_ return -1; @@ -248,7 +278,7 @@ static char * __get_tag_by_key(char *md_key) char *md_tag = NULL; if (md_key == NULL) { - DBG("md_key is NULL\n"); + _LOGD("md_key is NULL\n"); return NULL; } @@ -258,7 +288,7 @@ static char * __get_tag_by_key(char *md_key) return strdup(md_tag); } -static char *__get_mdparser_plugin(const char *type) +static char *__get_metadata_parser_plugin(const char *type) { FILE *fp = NULL; char buffer[1024] = { 0 }; @@ -266,13 +296,13 @@ static char *__get_mdparser_plugin(const char *type) char *path = NULL; if (type == NULL) { - DBGE("invalid argument\n"); + _LOGE("invalid argument\n"); return NULL; } fp = fopen(PKG_PARSER_CONF_PATH, "r"); if (fp == NULL) { - DBGE("no matching mdparser\n"); + _LOGE("no matching metadata parser\n"); return NULL; } @@ -282,8 +312,8 @@ static char *__get_mdparser_plugin(const char *type) __str_trim(buffer); - if ((path = strstr(buffer, MDPARSER_NAME)) != NULL) { - path = path + strlen(MDPARSER_NAME); + if ((path = strstr(buffer, METADATA_PARSER_NAME)) != NULL) { + path = path + strlen(METADATA_PARSER_NAME); break; } @@ -295,7 +325,7 @@ static char *__get_mdparser_plugin(const char *type) fclose(fp); if (path == NULL) { - DBGE("no matching [%s] [%s]\n", MDPARSER_NAME,type); + _LOGE("no matching [%s] [%s]\n", METADATA_PARSER_NAME,type); return NULL; } @@ -312,13 +342,13 @@ static char *__get_category_parser_plugin(const char *type) char *path = NULL; if (type == NULL) { - DBGE("invalid argument\n"); + _LOGE("invalid argument\n"); return NULL; } fp = fopen(PKG_PARSER_CONF_PATH, "r"); if (fp == NULL) { - DBGE("no matching mdparser\n"); + _LOGE("no matching metadata parser\n"); return NULL; } @@ -341,7 +371,7 @@ static char *__get_category_parser_plugin(const char *type) fclose(fp); if (path == NULL) { - DBGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME,type); + _LOGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME,type); return NULL; } @@ -358,13 +388,13 @@ static char *__get_parser_plugin(const char *type) char *path = NULL; if (type == NULL) { - DBGE("invalid argument\n"); + _LOGE("invalid argument\n"); return NULL; } fp = fopen(PKG_PARSER_CONF_PATH, "r"); if (fp == NULL) { - DBGE("no matching backendlib\n"); + _LOGE("no matching backendlib\n"); return NULL; } @@ -386,7 +416,7 @@ static char *__get_parser_plugin(const char *type) fclose(fp); if (path == NULL) { - DBGE("no matching backendlib\n"); + _LOGE("no matching backendlib\n"); return NULL; } @@ -395,12 +425,46 @@ static char *__get_parser_plugin(const char *type) return strdup(temp_path); } -static int __ps_run_mdparser(GList *md_list, const char *tag, +static int __ps_run_tag_parser(void *lib_handle, xmlDocPtr docPtr, const char *tag, + ACTION_TYPE action, const char *pkgid) +{ + int (*plugin_install) (xmlDocPtr, const char *); + int ret = -1; + char *ac = NULL; + + switch (action) { + case ACTION_INSTALL: + ac = "PKGMGR_PARSER_PLUGIN_INSTALL"; + break; + case ACTION_UPGRADE: + ac = "PKGMGR_PARSER_PLUGIN_UPGRADE"; + break; + case ACTION_UNINSTALL: + ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL"; + break; + default: + goto END; + } + + if ((plugin_install = + dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) { + _LOGE("can not find symbol[%s] \n", ac); + goto END; + } + + ret = plugin_install(docPtr, pkgid); + _LOGD("tag parser[%s, %s] ACTION_TYPE[%d] result[%d]\n", pkgid, tag, action, ret); + +END: + return ret; +} + +static int __ps_run_metadata_parser(GList *md_list, const char *tag, ACTION_TYPE action, const char *pkgid, const char *appid) { char *lib_path = NULL; void *lib_handle = NULL; - int (*mdparser_plugin) (const char *, const char *, GList *); + int (*metadata_parser_plugin) (const char *, const char *, GList *); int ret = -1; char *ac = NULL; @@ -418,28 +482,28 @@ static int __ps_run_mdparser(GList *md_list, const char *tag, goto END; } - lib_path = __get_mdparser_plugin(tag); + lib_path = __get_metadata_parser_plugin(tag); if (!lib_path) { - DBGE("get %s parser fail\n", tag); + _LOGE("get %s parser fail\n", tag); goto END; } if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) { - DBGE("dlopen is failed lib_path[%s]\n", lib_path); + _LOGE("dlopen is failed lib_path[%s]\n", lib_path); goto END; } - if ((mdparser_plugin = + if ((metadata_parser_plugin = dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) { - DBGE("can not find symbol[%s] \n",ac); + _LOGE("can not find symbol[%s] \n",ac); goto END; } - ret = mdparser_plugin(pkgid, appid, md_list); + ret = metadata_parser_plugin(pkgid, appid, md_list); if (ret < 0) - DBG("[appid = %s, libpath = %s plugin fail\n", appid, lib_path); + _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path); else - DBG("[appid = %s, libpath = %s plugin success\n", appid, lib_path); + _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path); END: if (lib_path) @@ -474,26 +538,26 @@ static int __ps_run_category_parser(GList *category_list, const char *tag, lib_path = __get_category_parser_plugin(tag); if (!lib_path) { - DBGE("get %s parser fail\n", tag); + _LOGE("get %s parser fail\n", tag); goto END; } if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) { - DBGE("dlopen is failed lib_path[%s]\n", lib_path); + _LOGE("dlopen is failed lib_path[%s]\n", lib_path); goto END; } if ((category_parser_plugin = dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) { - DBGE("can not find symbol[%s] \n",ac); + _LOGE("can not find symbol[%s] \n",ac); goto END; } ret = category_parser_plugin(pkgid, appid, category_list); if (ret < 0) - DBG("[appid = %s, libpath = %s plugin fail\n", appid, lib_path); + _LOGD("[appid = %s, libpath = %s plugin fail\n", appid, lib_path); else - DBG("[appid = %s, libpath = %s plugin success\n", appid, lib_path); + _LOGD("[appid = %s, libpath = %s plugin success\n", appid, lib_path); END: if (lib_path) @@ -532,20 +596,20 @@ static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, } if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) { - DBGE("dlopen is failed lib_path[%s]\n", lib_path); + _LOGE("dlopen is failed lib_path[%s]\n", lib_path); goto END; } if ((plugin_install = dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) { - DBGE("can not find symbol[%s] \n", ac); + _LOGE("can not find symbol[%s] \n", ac); goto END; } ret = plugin_install(docPtr, pkgid); if (ret < 0) - DBG("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path); + _LOGD("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path); else - DBG("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path); + _LOGD("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path); END: if (lib_path) @@ -561,14 +625,14 @@ static char *__pkgid_to_manifest(const char *pkgid) int size; if (pkgid == NULL) { - DBGE("pkgid is NULL"); + _LOGE("pkgid is NULL"); return NULL; } size = strlen(MANIFEST_RW_DIRECTORY) + strlen(pkgid) + 10; manifest = malloc(size); if (manifest == NULL) { - DBGE("No memory"); + _LOGE("No memory"); return NULL; } memset(manifest, '\0', size); @@ -581,7 +645,7 @@ static char *__pkgid_to_manifest(const char *pkgid) return manifest; } -static void __mdparser_clear_dir_list(GList* dir_list) +static void __metadata_parser_clear_dir_list(GList* dir_list) { GList *list = NULL; __metadata_t* detail = NULL; @@ -624,7 +688,88 @@ static void __category_parser_clear_dir_list(GList* dir_list) } } -static int __run_mdparser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action) +static int __run_tag_parser_prestep(void *lib_handle, xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid) +{ + int ret = -1; + const xmlChar *name; + + 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); + 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); + 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); + } + + ret = __ps_run_tag_parser(lib_handle, copyDocPtr, ASCII(name), action, pkgid); + END: + + return ret; +} + +static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action) { int ret = -1; int tag_exist = 0; @@ -638,7 +783,7 @@ static int __run_mdparser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE ac md_tag = __get_tag_by_key(md_key); if (md_tag == NULL) { - DBG("md_tag is NULL\n"); + _LOGD("md_tag is NULL\n"); return -1; } @@ -647,19 +792,19 @@ static int __run_mdparser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE ac md = up->metadata; while (md != NULL) { - //get glist of meatdata key and value combination + //get glist of metadata key and value combination memset(buffer, 0x00, 1024); snprintf(buffer, 1024, "%s/", md_key); if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) { md_detail = (__metadata_t*) calloc(1, sizeof(__metadata_t)); if (md_detail == NULL) { - DBG("Memory allocation failed\n"); + _LOGD("Memory allocation failed\n"); goto END; } md_detail->key = (char*) calloc(1, sizeof(char)*(strlen(md->key)+2)); if (md_detail->key == NULL) { - DBG("Memory allocation failed\n"); + _LOGD("Memory allocation failed\n"); free(md_detail); goto END; } @@ -667,7 +812,7 @@ static int __run_mdparser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE ac md_detail->value = (char*) calloc(1, sizeof(char)*(strlen(md->value)+2)); if (md_detail->value == NULL) { - DBG("Memory allocation failed\n"); + _LOGD("Memory allocation failed\n"); free(md_detail->key); free(md_detail); goto END; @@ -682,13 +827,13 @@ static int __run_mdparser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE ac //send glist to parser when tags for metadata plugin parser exist. if (tag_exist) { - ret = __ps_run_mdparser(md_list, md_tag, action, mfx->package, up->appid); + ret = __ps_run_metadata_parser(md_list, md_tag, action, mfx->package, up->appid); if (ret < 0) - DBG("mdparser failed[%d] for tag[%s]\n", ret, md_tag); + _LOGD("metadata_parser failed[%d] for tag[%s]\n", ret, md_tag); else - DBG("mdparser success for tag[%s]\n", md_tag); + _LOGD("metadata_parser success for tag[%s]\n", md_tag); } - __mdparser_clear_dir_list(md_list); + __metadata_parser_clear_dir_list(md_list); md_list = NULL; tag_exist = 0; up = up->next; @@ -696,7 +841,7 @@ static int __run_mdparser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE ac return 0; END: - __mdparser_clear_dir_list(md_list); + __metadata_parser_clear_dir_list(md_list); if (md_tag) free(md_tag); @@ -718,7 +863,7 @@ static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, A category_tag = __get_tag_by_key(category_key); if (category_tag == NULL) { - DBG("md_tag is NULL\n"); + _LOGD("md_tag is NULL\n"); return -1; } @@ -727,19 +872,19 @@ static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, A category = up->category; while (category != NULL) { - //get glist of meatdata key and value combination + //get glist of category key and value combination memset(buffer, 0x00, 1024); snprintf(buffer, 1024, "%s/", category_key); if ((category->name) && (strncmp(category->name, category_key, strlen(category_key)) == 0)) { category_detail = (__category_t*) calloc(1, sizeof(__category_t)); if (category_detail == NULL) { - DBG("Memory allocation failed\n"); + _LOGD("Memory allocation failed\n"); goto END; } category_detail->name = (char*) calloc(1, sizeof(char)*(strlen(category->name)+2)); if (category_detail->name == NULL) { - DBG("Memory allocation failed\n"); + _LOGD("Memory allocation failed\n"); free(category_detail); goto END; } @@ -755,9 +900,9 @@ static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, A if (tag_exist) { ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, up->appid); if (ret < 0) - DBG("category_parser failed[%d] for tag[%s]\n", ret, category_tag); + _LOGD("category_parser failed[%d] for tag[%s]\n", ret, category_tag); else - DBG("category_parser success for tag[%s]\n", category_tag); + _LOGD("category_parser success for tag[%s]\n", category_tag); } __category_parser_clear_dir_list(category_list); category_list = NULL; @@ -780,50 +925,48 @@ static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, con int ret = -1; const xmlChar *name; - DBG("__run_parser_prestep"); +// _LOGD("__run_parser_prestep"); if (xmlTextReaderDepth(reader) != 1) { - DBGE("Node depth is not 1"); + _LOGE("Node depth is not 1"); goto END; } if (xmlTextReaderNodeType(reader) != 1) { - DBGE("Node type is not 1"); + _LOGE("Node type is not 1"); goto END; } const xmlChar *value; name = xmlTextReaderConstName(reader); if (name == NULL) { - DBGE("TEST TEST TES\n"); + _LOGE("TEST TEST TES\n"); name = BAD_CAST "--"; } value = xmlTextReaderConstValue(reader); - DBG("%d %d %s %d %d", + _LOGD("%d %d %s %d %d", xmlTextReaderDepth(reader), xmlTextReaderNodeType(reader), name, xmlTextReaderIsEmptyElement(reader), xmlTextReaderHasValue(reader)); - if (value == NULL) { - DBG("ConstValue NULL"); - } else { + if (value != NULL) { if (xmlStrlen(value) > 40) { - DBG(" %.40s...", value); + _LOGD(" %.40s...", value); } else { - DBG(" %s", value); + _LOGD(" %s", value); } } name = xmlTextReaderConstName(reader); if (name == NULL) { - DBGE("TEST TEST TES\n"); + _LOGE("TEST TEST TES\n"); name = BAD_CAST "--"; } xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader); - DBG("docPtr->URL %s\n", (char *)docPtr->URL); + _LOGD("docPtr->URL %s\n", (char *)docPtr->URL); xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1); if (copyDocPtr == NULL) return -1; @@ -864,7 +1007,7 @@ static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, con #ifdef __DEBUG__ //#else - DBG("node type: %d, name: %s children->name: %s last->name: %s\n" + _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", @@ -894,7 +1037,7 @@ __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], c switch (xmlTextReaderNodeType(reader)) { case XML_READER_TYPE_END_ELEMENT: { - // DBG("XML_READER_TYPE_END_ELEMENT"); + // _LOGD("XML_READER_TYPE_END_ELEMENT"); break; } @@ -906,29 +1049,29 @@ __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], c const xmlChar *elementName = xmlTextReaderLocalName(reader); if (elementName == NULL) { -// DBG("elementName %s\n", (char *)elementName); +// _LOGD("elementName %s\n", (char *)elementName); break; } const xmlChar *nameSpace = xmlTextReaderConstNamespaceUri(reader); if (nameSpace) { -// DBG("nameSpace %s\n", (char *)nameSpace); +// _LOGD("nameSpace %s\n", (char *)nameSpace); } /* - DBG("XML_READER_TYPE_ELEMENT %s, %s\n", + _LOGD("XML_READER_TYPE_ELEMENT %s, %s\n", elementName ? elementName : "NULL", nameSpace ? nameSpace : "NULL"); */ if (tagv == NULL) { - DBG("__run_parser_prestep pkgid[%s]\n", pkgid); + _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) { - DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid); + _LOGD("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid); __run_parser_prestep(reader, action, pkgid); break; @@ -942,25 +1085,101 @@ __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], c { const xmlChar *value = xmlTextReaderConstValue(reader); if (value) { -// DBG("value %s\n", value); +// _LOGD("value %s\n", value); } const xmlChar *lang = xmlTextReaderConstXmlLang(reader); if (lang) { -// DBG("lang\n", lang); +// _LOGD("lang\n", lang); } -/* DBG("XML_READER_TYPE_TEXT %s, %s\n", +/* _LOGD("XML_READER_TYPE_TEXT %s, %s\n", value ? value : "NULL", lang ? lang : "NULL"); */ break; } default: -// DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader)); +// _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) +{ + switch (xmlTextReaderNodeType(reader)) { + case XML_READER_TYPE_END_ELEMENT: + { + break; + } + case XML_READER_TYPE_ELEMENT: + { + // Elements without closing tag don't receive + const xmlChar *elementName = + xmlTextReaderLocalName(reader); + if (elementName == NULL) { + break; + } + + if (strcmp(tag, ASCII(elementName)) == 0) { + _LOGD("find : tag[%s] ACTION_TYPE[%d] pkg[%s]\n", tag, action, pkgid); + __run_tag_parser_prestep(lib_handle, reader, action, pkgid); + break; + } + break; + } + + default: + break; + } +} + +static int __parser_send_tag(void *lib_handle, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid) +{ + 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: + return -1; + } + } 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: + return -1; + } + } else + return -1; + + if ((plugin_install = + dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) { + return -1; + } + + ret = plugin_install(pkgid); + return ret; +} + static void __plugin_send_tag(const char *tag, ACTION_TYPE action, PLUGIN_PROCESS_TYPE process, const char *pkgid) { char *lib_path = NULL; @@ -1006,20 +1225,20 @@ static void __plugin_send_tag(const char *tag, ACTION_TYPE action, PLUGIN_PROCES } if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) { - DBGE("dlopen is failed lib_path[%s] for tag[%s]\n", lib_path, tag); + _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) { - DBGE("can not find symbol[%s] for tag[%s] \n", ac, tag); +// _LOGE("can not find symbol[%s] for tag[%s] \n", ac, tag); goto END; } ret = plugin_install(pkgid); if (ret < 0) - DBG("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin fail\n", process, pkgid, tag); + _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin fail\n", process, pkgid, tag); else - DBG("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin success\n", process, pkgid, tag); + _LOGD("[PLUGIN_PROCESS_TYPE[%d] pkgid=%s, tag=%s plugin success\n", process, pkgid, tag); END: if (lib_path) @@ -1067,45 +1286,17 @@ __plugin_save_tag(xmlTextReaderPtr reader, char *const tagv[], char *tag_list[]) break; } default: -// DBG("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader)); +// _LOGD("Ignoring Node of Type: %d", xmlTextReaderNodeType(reader)); break; } } static void -__plugin_find_tag(const char *filename, char *const tagv[], char *tag_list[]) -{ - xmlTextReaderPtr reader; - xmlDocPtr docPtr; - int ret; - - docPtr = xmlReadFile(filename, NULL, 0); - reader = xmlReaderWalker(docPtr); - if (reader != NULL) { - ret = xmlTextReaderRead(reader); - while (ret == 1) { - __plugin_save_tag(reader, tagv, tag_list); - ret = xmlTextReaderRead(reader); - } - xmlFreeTextReader(reader); - - if (ret != 0) { - DBG("xmlReaderWalker fail"); - } - } else { - DBG("xmlReaderWalker fail"); - } -} - -static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid) { xmlTextReaderPtr reader; xmlDocPtr docPtr; int ret; - char *tag_list[PKG_TAG_LEN_MAX] = {'\0'}; - -// __plugin_find_tag(filename, tagv, tag_list); __plugin_process_tag(tagv, action, PLUGIN_PRE_PROCESS, pkgid); docPtr = xmlReadFile(filename, NULL, 0); @@ -1119,10 +1310,10 @@ __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const xmlFreeTextReader(reader); if (ret != 0) { - DBGE("%s : failed to parse", filename); + _LOGD("%s : failed to parse", filename); } } else { - DBGE("Unable to open %s", filename); + _LOGD("Unable to open %s", filename); } __plugin_process_tag(tagv, action, PLUGIN_POST_PROCESS, pkgid); @@ -1159,6 +1350,43 @@ static int __next_child_element(xmlTextReaderPtr reader, int depth) 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) @@ -2179,21 +2407,74 @@ static void __ps_free_ime(ime_x *ime) ime = NULL; } -int __ps_process_mdparser(manifest_x *mfx, ACTION_TYPE action) +int __ps_process_tag_parser(manifest_x *mfx, const char *filename, ACTION_TYPE action) +{ + xmlTextReaderPtr reader; + xmlDocPtr docPtr; + int ret = -1; + FILE *fp = NULL; + void *lib_handle = NULL; + char tag[PKG_STRING_LEN_MAX] = { 0 }; + + fp = fopen(TAG_PARSER_LIST, "r"); + retvm_if(fp == NULL, PMINFO_R_ERROR, "no preload list"); + + while (fgets(tag, sizeof(tag), fp) != NULL) { + __str_trim(tag); + + lib_handle = __open_lib_handle(tag); + if (lib_handle == NULL) + continue; + + ret = __parser_send_tag(lib_handle, action, PLUGIN_PRE_PROCESS, mfx->package); + _LOGD("PLUGIN_PRE_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret); + + docPtr = xmlReadFile(filename, NULL, 0); + reader = xmlReaderWalker(docPtr); + if (reader != NULL) { + ret = xmlTextReaderRead(reader); + while (ret == 1) { + __processTag(lib_handle, reader, action, tag, mfx->package); + ret = xmlTextReaderRead(reader); + } + xmlFreeTextReader(reader); + + if (ret != 0) { + _LOGD("%s : failed to parse", filename); + } + } else { + _LOGD("Unable to open %s", filename); + } + + ret = __parser_send_tag(lib_handle, action, PLUGIN_POST_PROCESS, mfx->package); + _LOGD("PLUGIN_POST_PROCESS[%s, %s] ACTION_TYPE[%d] result[%d]\n", mfx->package, tag, action, ret); + + __close_lib_handle(lib_handle); + + memset(tag, 0x00, sizeof(tag)); + } + + if (fp != NULL) + fclose(fp); + + return 0; +} + +int __ps_process_metadata_parser(manifest_x *mfx, ACTION_TYPE action) { int ret = -1; FILE *fp = NULL; char md_key[PKG_STRING_LEN_MAX] = { 0 }; - fp = fopen(MDPARSER_LIST, "r"); + fp = fopen(METADATA_PARSER_LIST, "r"); if (fp == NULL) { - DBG("no preload list\n"); + _LOGD("no preload list\n"); return -1; } while (fgets(md_key, sizeof(md_key), fp) != NULL) { __str_trim(md_key); - ret = __run_mdparser_prestep(mfx, md_key, action); + ret = __run_metadata_parser_prestep(mfx, md_key, action); memset(md_key, 0x00, sizeof(md_key)); } @@ -2212,7 +2493,7 @@ int __ps_process_category_parser(manifest_x *mfx, ACTION_TYPE action) fp = fopen(CATEGORY_PARSER_LIST, "r"); if (fp == NULL) { - DBG("no category parser list\n"); + _LOGD("no category parser list\n"); return -1; } @@ -2383,14 +2664,14 @@ static int __ps_process_define(xmlTextReaderPtr reader, define_x *define) while ((ret = __next_child_element(reader, depth))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } if (!strcmp(ASCII(node), "allowed")) { allowed_x *allowed= malloc(sizeof(allowed_x)); if (allowed == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(allowed, '\0', sizeof(allowed_x)); @@ -2399,7 +2680,7 @@ static int __ps_process_define(xmlTextReaderPtr reader, define_x *define) } else if (!strcmp(ASCII(node), "request")) { request_x *request = malloc(sizeof(request_x)); if (request == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(request, '\0', sizeof(request_x)); @@ -2408,7 +2689,7 @@ static int __ps_process_define(xmlTextReaderPtr reader, define_x *define) } else return -1; if (ret < 0) { - DBG("Processing define failed\n"); + _LOGD("Processing define failed\n"); return ret; } } @@ -2437,54 +2718,54 @@ static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcon while ((ret = __next_child_element(reader, depth))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } if (!strcmp(ASCII(node), "operation")) { operation_x *operation = malloc(sizeof(operation_x)); if (operation == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(operation, '\0', sizeof(operation_x)); LISTADD(appcontrol->operation, operation); ret = __ps_process_operation(reader, operation); - DBG("operation processing\n"); + _LOGD("operation processing\n"); } else if (!strcmp(ASCII(node), "uri")) { uri_x *uri= malloc(sizeof(uri_x)); if (uri == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(uri, '\0', sizeof(uri_x)); LISTADD(appcontrol->uri, uri); ret = __ps_process_uri(reader, uri); - DBG("uri processing\n"); + _LOGD("uri processing\n"); } else if (!strcmp(ASCII(node), "mime")) { mime_x *mime = malloc(sizeof(mime_x)); if (mime == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(mime, '\0', sizeof(mime_x)); LISTADD(appcontrol->mime, mime); ret = __ps_process_mime(reader, mime); - DBG("mime processing\n"); + _LOGD("mime processing\n"); } else if (!strcmp(ASCII(node), "subapp")) { subapp_x *subapp = malloc(sizeof(subapp_x)); if (subapp == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(subapp, '\0', sizeof(subapp_x)); LISTADD(appcontrol->subapp, subapp); ret = __ps_process_subapp(reader, subapp); - DBG("subapp processing\n"); + _LOGD("subapp processing\n"); } else return -1; if (ret < 0) { - DBG("Processing appcontrol failed\n"); + _LOGD("Processing appcontrol failed\n"); return ret; } } @@ -2526,54 +2807,54 @@ static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc) while ((ret = __next_child_element(reader, depth))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } if (!strcmp(ASCII(node), "operation")) { operation_x *operation = malloc(sizeof(operation_x)); if (operation == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(operation, '\0', sizeof(operation_x)); LISTADD(appsvc->operation, operation); ret = __ps_process_operation(reader, operation); - DBG("operation processing\n"); + _LOGD("operation processing\n"); } else if (!strcmp(ASCII(node), "uri")) { uri_x *uri= malloc(sizeof(uri_x)); if (uri == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(uri, '\0', sizeof(uri_x)); LISTADD(appsvc->uri, uri); ret = __ps_process_uri(reader, uri); - DBG("uri processing\n"); + _LOGD("uri processing\n"); } else if (!strcmp(ASCII(node), "mime")) { mime_x *mime = malloc(sizeof(mime_x)); if (mime == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(mime, '\0', sizeof(mime_x)); LISTADD(appsvc->mime, mime); ret = __ps_process_mime(reader, mime); - DBG("mime processing\n"); + _LOGD("mime processing\n"); } else if (!strcmp(ASCII(node), "subapp")) { subapp_x *subapp = malloc(sizeof(subapp_x)); if (subapp == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(subapp, '\0', sizeof(subapp_x)); LISTADD(appsvc->subapp, subapp); ret = __ps_process_subapp(reader, subapp); - DBG("subapp processing\n"); + _LOGD("subapp processing\n"); } else return -1; if (ret < 0) { - DBG("Processing appsvc failed\n"); + _LOGD("Processing appsvc failed\n"); return ret; } } @@ -2613,14 +2894,14 @@ static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privil while ((ret = __next_child_element(reader, depth))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } if (strcmp(ASCII(node), "privilege") == 0) { privilege_x *privilege = malloc(sizeof(privilege_x)); if (privilege == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(privilege, '\0', sizeof(privilege_x)); @@ -2629,7 +2910,7 @@ static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privil } else return -1; if (ret < 0) { - DBG("Processing privileges failed\n"); + _LOGD("Processing privileges failed\n"); return ret; } } @@ -2651,14 +2932,14 @@ static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditio while ((ret = __next_child_element(reader, depth))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } if (strcmp(ASCII(node), "condition") == 0) { condition_x *condition = malloc(sizeof(condition_x)); if (condition == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(condition, '\0', sizeof(condition_x)); @@ -2667,7 +2948,7 @@ static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditio } else return -1; if (ret < 0) { - DBG("Processing launchconditions failed\n"); + _LOGD("Processing launchconditions failed\n"); return ret; } } @@ -2694,14 +2975,14 @@ static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashar while ((ret = __next_child_element(reader, depth))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } if (!strcmp(ASCII(node), "define")) { define_x *define= malloc(sizeof(define_x)); if (define == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(define, '\0', sizeof(define_x)); @@ -2710,7 +2991,7 @@ static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashar } else if (!strcmp(ASCII(node), "request")) { request_x *request= malloc(sizeof(request_x)); if (request == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(request, '\0', sizeof(request_x)); @@ -2719,7 +3000,7 @@ static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashar } else return -1; if (ret < 0) { - DBG("Processing data-share failed\n"); + _LOGD("Processing data-share failed\n"); return ret; } } @@ -2748,6 +3029,8 @@ __get_icon_with_path(const char* icon) if (!package) return NULL; +/* "db/setting/theme" is not exist */ +#if 0 theme = vconf_get_str("db/setting/theme"); if (!theme) { theme = strdup("default"); @@ -2755,11 +3038,14 @@ __get_icon_with_path(const char* icon) return NULL; } } +#else + theme = strdup("default"); +#endif len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme); icon_with_path = malloc(len); if(icon_with_path == NULL) { - DBG("(icon_with_path == NULL) return\n"); + _LOGD("(icon_with_path == NULL) return\n"); free(theme); return NULL; } @@ -2771,19 +3057,19 @@ __get_icon_with_path(const char* icon) if (access(icon_with_path, R_OK) == 0) break; snprintf(icon_with_path, len, "/usr/share/icons/%s/small/%s", theme, icon); if (access(icon_with_path, R_OK) == 0) break; - DBG("cannot find icon %s", icon_with_path); + _LOGD("cannot find icon %s", icon_with_path); snprintf(icon_with_path, len,"/opt/share/icons/default/small/%s", icon); if (access(icon_with_path, R_OK) == 0) break; snprintf(icon_with_path, len, "/usr/share/icons/default/small/%s", icon); if (access(icon_with_path, R_OK) == 0) break; /* icon path is going to be moved intto the app directory */ - DBGE("icon file must be moved to %s", icon_with_path); + _LOGE("icon file must be moved to %s", icon_with_path); snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/%s/small/%s", package, theme, icon); if (access(icon_with_path, R_OK) == 0) break; snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/%s/small/%s", package, theme, icon); if (access(icon_with_path, R_OK) == 0) break; - DBG("cannot find icon %s", icon_with_path); + _LOGD("cannot find icon %s", icon_with_path); snprintf(icon_with_path, len, "/opt/apps/%s/res/icons/default/small/%s", package, icon); if (access(icon_with_path, R_OK) == 0) break; snprintf(icon_with_path, len, "/usr/apps/%s/res/icons/default/small/%s", package, icon); @@ -2794,7 +3080,7 @@ __get_icon_with_path(const char* icon) free(theme); - DBG("Icon path : %s ---> %s", icon, icon_with_path); + _LOGD("Icon path : %s ---> %s", icon, icon_with_path); return icon_with_path; } else { @@ -2842,7 +3128,7 @@ static void __ps_process_tag(manifest_x * mfx, char *const tagv[]) } /*check tag : not matched*/ } else - DBG("tag process [%s]is not defined\n", ret_result); + _LOGD("tag process [%s]is not defined\n", ret_result); free(tag); @@ -2850,7 +3136,7 @@ static void __ps_process_tag(manifest_x * mfx, char *const tagv[]) if (tagv[++i] != NULL) tag = strdup(tagv[i]); else { - DBG("tag process success...\n"); + _LOGD("tag process success...\n"); return; } } @@ -2920,9 +3206,9 @@ static int __ps_process_label(xmlTextReaderPtr reader, label_x *label) if (xmlTextReaderValue(reader)) label->text = ASCII(xmlTextReaderValue(reader)); -/* DBG("lable name %s\n", label->name); - DBG("lable lang %s\n", label->lang); - DBG("lable text %s\n", label->text); +/* _LOGD("lable name %s\n", label->name); + _LOGD("lable lang %s\n", label->lang); + _LOGD("lable text %s\n", label->text); */ return 0; @@ -3005,14 +3291,14 @@ static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capabi while ((ret = __next_child_element(reader, depth))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } if (!strcmp(ASCII(node), "resolution")) { resolution_x *resolution = malloc(sizeof(resolution_x)); if (resolution == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(resolution, '\0', sizeof(resolution_x)); @@ -3021,7 +3307,7 @@ static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capabi } else return -1; if (ret < 0) { - DBG("Processing capability failed\n"); + _LOGD("Processing capability failed\n"); return ret; } } @@ -3048,14 +3334,14 @@ static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *data while ((ret = __next_child_element(reader, depth))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } if (!strcmp(ASCII(node), "capability")) { capability_x *capability = malloc(sizeof(capability_x)); if (capability == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(capability, '\0', sizeof(capability_x)); @@ -3064,7 +3350,7 @@ static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *data } else return -1; if (ret < 0) { - DBG("Processing datacontrol failed\n"); + _LOGD("Processing datacontrol failed\n"); return ret; } } @@ -3098,17 +3384,17 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) { uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))); if (uiapplication->appid == NULL) { - DBG("appid cant be NULL\n"); + _LOGD("appid cant be NULL\n"); return -1; } } else { - DBG("appid is mandatory\n"); + _LOGD("appid is mandatory\n"); return -1; } /*check appid*/ ret = __validate_appid(package, uiapplication->appid, &newappid); if (ret == -1) { - DBG("appid is not proper\n"); + _LOGD("appid is not proper\n"); return -1; } else { if (newappid) { @@ -3235,13 +3521,13 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * while ((ret = __next_child_element(reader, depth))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } if (!strcmp(ASCII(node), "label")) { label_x *label = malloc(sizeof(label_x)); if (label == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(label, '\0', sizeof(label_x)); @@ -3250,7 +3536,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else if (!strcmp(ASCII(node), "icon")) { icon_x *icon = malloc(sizeof(icon_x)); if (icon == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(icon, '\0', sizeof(icon_x)); @@ -3259,7 +3545,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else if (!strcmp(ASCII(node), "image")) { image_x *image = malloc(sizeof(image_x)); if (image == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(image, '\0', sizeof(image_x)); @@ -3268,7 +3554,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else if (!strcmp(ASCII(node), "category")) { category_x *category = malloc(sizeof(category_x)); if (category == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(category, '\0', sizeof(category_x)); @@ -3277,7 +3563,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else if (!strcmp(ASCII(node), "metadata")) { metadata_x *metadata = malloc(sizeof(metadata_x)); if (metadata == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(metadata, '\0', sizeof(metadata_x)); @@ -3286,7 +3572,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else if (!strcmp(ASCII(node), "permission")) { permission_x *permission = malloc(sizeof(permission_x)); if (permission == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(permission, '\0', sizeof(permission_x)); @@ -3295,7 +3581,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else if (!strcmp(ASCII(node), "app-control")) { appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x)); if (appcontrol == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(appcontrol, '\0', sizeof(appcontrol_x)); @@ -3304,7 +3590,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else if (!strcmp(ASCII(node), "application-service")) { appsvc_x *appsvc = malloc(sizeof(appsvc_x)); if (appsvc == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(appsvc, '\0', sizeof(appsvc_x)); @@ -3313,7 +3599,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else if (!strcmp(ASCII(node), "data-share")) { datashare_x *datashare = malloc(sizeof(datashare_x)); if (datashare == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(datashare, '\0', sizeof(datashare_x)); @@ -3322,7 +3608,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else if (!strcmp(ASCII(node), "launch-conditions")) { launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x)); if (launchconditions == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(launchconditions, '\0', sizeof(launchconditions_x)); @@ -3331,7 +3617,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else if (!strcmp(ASCII(node), "notification")) { notification_x *notification = malloc(sizeof(notification_x)); if (notification == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(notification, '\0', sizeof(notification_x)); @@ -3340,7 +3626,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x * } else return -1; if (ret < 0) { - DBG("Processing uiapplication failed\n"); + _LOGD("Processing uiapplication failed\n"); return ret; } } @@ -3414,17 +3700,17 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) { serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))); if (serviceapplication->appid == NULL) { - DBG("appid cant be NULL\n"); + _LOGD("appid cant be NULL\n"); return -1; } } else { - DBG("appid is mandatory\n"); + _LOGD("appid is mandatory\n"); return -1; } /*check appid*/ ret = __validate_appid(package, serviceapplication->appid, &newappid); if (ret == -1) { - DBG("appid is not proper\n"); + _LOGD("appid is not proper\n"); return -1; } else { if (newappid) { @@ -3463,14 +3749,14 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli while ((ret = __next_child_element(reader, depth))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } if (!strcmp(ASCII(node), "label")) { label_x *label = malloc(sizeof(label_x)); if (label == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(label, '\0', sizeof(label_x)); @@ -3479,7 +3765,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli } else if (!strcmp(ASCII(node), "icon")) { icon_x *icon = malloc(sizeof(icon_x)); if (icon == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(icon, '\0', sizeof(icon_x)); @@ -3488,7 +3774,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli } else if (!strcmp(ASCII(node), "category")) { category_x *category = malloc(sizeof(category_x)); if (category == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(category, '\0', sizeof(category_x)); @@ -3497,7 +3783,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli } else if (!strcmp(ASCII(node), "metadata")) { metadata_x *metadata = malloc(sizeof(metadata_x)); if (metadata == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(metadata, '\0', sizeof(metadata_x)); @@ -3506,7 +3792,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli } else if (!strcmp(ASCII(node), "permission")) { permission_x *permission = malloc(sizeof(permission_x)); if (permission == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(permission, '\0', sizeof(permission_x)); @@ -3515,7 +3801,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli } else if (!strcmp(ASCII(node), "app-control")) { appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x)); if (appcontrol == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(appcontrol, '\0', sizeof(appcontrol_x)); @@ -3524,7 +3810,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli } else if (!strcmp(ASCII(node), "application-service")) { appsvc_x *appsvc = malloc(sizeof(appsvc_x)); if (appsvc == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(appsvc, '\0', sizeof(appsvc_x)); @@ -3533,7 +3819,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli } else if (!strcmp(ASCII(node), "data-share")) { datashare_x *datashare = malloc(sizeof(datashare_x)); if (datashare == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(datashare, '\0', sizeof(datashare_x)); @@ -3542,7 +3828,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli } else if (!strcmp(ASCII(node), "launch-conditions")) { launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x)); if (launchconditions == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(launchconditions, '\0', sizeof(launchconditions_x)); @@ -3551,7 +3837,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli } else if (!strcmp(ASCII(node), "notification")) { notification_x *notification = malloc(sizeof(notification_x)); if (notification == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(notification, '\0', sizeof(notification_x)); @@ -3560,7 +3846,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli } else if (!strcmp(ASCII(node), "data-control")) { datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x)); if (datacontrol == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(datacontrol, '\0', sizeof(datacontrol_x)); @@ -3569,7 +3855,7 @@ static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceappli } else return -1; if (ret < 0) { - DBG("Processing serviceapplication failed\n"); + _LOGD("Processing serviceapplication failed\n"); return ret; } } @@ -3654,7 +3940,7 @@ static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime) static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) { - DBG("__start_process\n"); + _LOGD("__start_process\n"); const xmlChar *node; int ret = -1; int depth = -1; @@ -3677,14 +3963,14 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) while ((ret = __next_child_element(reader, depth))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } if (!strcmp(ASCII(node), "label")) { label_x *label = malloc(sizeof(label_x)); if (label == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(label, '\0', sizeof(label_x)); @@ -3693,7 +3979,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "author")) { author_x *author = malloc(sizeof(author_x)); if (author == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(author, '\0', sizeof(author_x)); @@ -3702,7 +3988,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "description")) { description_x *description = malloc(sizeof(description_x)); if (description == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(description, '\0', sizeof(description_x)); @@ -3711,7 +3997,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "license")) { license_x *license = malloc(sizeof(license_x)); if (license == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(license, '\0', sizeof(license_x)); @@ -3720,7 +4006,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "privileges")) { privileges_x *privileges = malloc(sizeof(privileges_x)); if (privileges == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(privileges, '\0', sizeof(privileges_x)); @@ -3729,7 +4015,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "ui-application")) { uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x)); if (uiapplication == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(uiapplication, '\0', sizeof(uiapplication_x)); @@ -3738,7 +4024,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "service-application")) { serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x)); if (serviceapplication == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(serviceapplication, '\0', sizeof(serviceapplication_x)); @@ -3747,7 +4033,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "daemon")) { daemon_x *daemon = malloc(sizeof(daemon_x)); if (daemon == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(daemon, '\0', sizeof(daemon_x)); @@ -3756,7 +4042,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "theme")) { theme_x *theme = malloc(sizeof(theme_x)); if (theme == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(theme, '\0', sizeof(theme_x)); @@ -3765,7 +4051,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "font")) { font_x *font = malloc(sizeof(font_x)); if (font == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(font, '\0', sizeof(font_x)); @@ -3774,7 +4060,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "ime")) { ime_x *ime = malloc(sizeof(ime_x)); if (ime == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(ime, '\0', sizeof(ime_x)); @@ -3783,7 +4069,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "icon")) { icon_x *icon = malloc(sizeof(icon_x)); if (icon == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(icon, '\0', sizeof(icon_x)); @@ -3792,7 +4078,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "device-profile")) { deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x)); if (deviceprofile == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(deviceprofile, '\0', sizeof(deviceprofile_x)); @@ -3801,7 +4087,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) } else if (!strcmp(ASCII(node), "compatibility")) { compatibility_x *compatibility = malloc(sizeof(compatibility_x)); if (compatibility == NULL) { - DBG("Malloc Failed\n"); + _LOGD("Malloc Failed\n"); return -1; } memset(compatibility, '\0', sizeof(compatibility_x)); @@ -3821,7 +4107,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx) return -1; if (ret < 0) { - DBG("Processing manifest failed\n"); + _LOGD("Processing manifest failed\n"); return ret; } } @@ -3892,7 +4178,7 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx) if ((ret = __next_child_element(reader, -1))) { node = xmlTextReaderConstName(reader); if (!node) { - DBG("xmlTextReaderConstName value is NULL\n"); + _LOGD("xmlTextReaderConstName value is NULL\n"); return -1; } @@ -3902,11 +4188,11 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx) if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) { mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package"))); if (mfx->package == NULL) { - DBG("package cant be NULL\n"); + _LOGD("package cant be NULL\n"); return -1; } } else { - DBG("package field is mandatory\n"); + _LOGD("package field is mandatory\n"); return -1; } package = mfx->package; @@ -3923,6 +4209,8 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx) mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path"))); if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path"))) mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("main_package"))) + mfx->main_package = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("main_package"))); if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) { mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))); if (mfx->appsetting == NULL) @@ -3960,7 +4248,7 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx) ret = __start_process(reader, mfx); } else { - DBG("No Manifest element found\n"); + _LOGD("No Manifest element found\n"); return -1; } } @@ -3978,7 +4266,7 @@ static char* __convert_to_system_locale(const char *mlocale) char *locale = NULL; locale = (char *)calloc(1, 6); if (!locale) { - DBGE("Malloc Failed\n"); + _LOGE("Malloc Failed\n"); return NULL; } @@ -3997,6 +4285,7 @@ typedef enum { AIL_UPDATE, AIL_REMOVE, AIL_CLEAN, + AIL_FOTA, AIL_MAX } AIL_TYPE; @@ -4008,7 +4297,7 @@ static int __ail_change_info(int op, const char *appid) int ret = 0; if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) { - DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH); + _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH); goto END; } @@ -4026,6 +4315,9 @@ static int __ail_change_info(int op, const char *appid) case 3: aop = "ail_desktop_clean"; break; + case 4: + aop = "ail_desktop_fota"; + break; default: goto END; break; @@ -4033,7 +4325,7 @@ static int __ail_change_info(int op, const char *appid) if ((ail_desktop_operation = dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) { - DBGE("can not find symbol \n"); + _LOGE("can not find symbol \n"); goto END; } @@ -4050,7 +4342,7 @@ END: /* desktop shoud be generated automatically based on manifest */ /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/ #define BUFMAX 1024*128 -static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, bool is_update) +static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, ACTION_TYPE action) { FILE* file = NULL; int fd = 0; @@ -4061,18 +4353,18 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, b buf = (char *)calloc(1, BUFMAX); if (!buf) { - DBGE("Malloc Failed\n"); + _LOGE("Malloc Failed\n"); return -1; } buftemp = (char *)calloc(1, BUFMAX); if (!buftemp) { - DBGE("Malloc Failed\n"); + _LOGE("Malloc Failed\n"); free(buf); return -1; } - if (is_update) + if (action == ACTION_UPGRADE) __ail_change_info(AIL_CLEAN, mfx->package); for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) { @@ -4081,7 +4373,7 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, b /* skip making a deskfile and update ail, if preload app is updated */ if(strstr(manifest, MANIFEST_RO_PREFIX)) { __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid); - DBGE("preload app is update : skip and update ail : %s", manifest); + _LOGE("preload app is update : skip and update ail : %s", manifest); continue; } } @@ -4099,7 +4391,7 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, b file = fopen(filepath, "w"); if(file == NULL) { - DBGE("Can't open %s", filepath); + _LOGD("Can't open %s", filepath); free(buf); free(buftemp); return -1; @@ -4165,7 +4457,7 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, b while (mi) { mime_count++; mime = mi->name; - DBG("MIME type: %s\n", mime); + _LOGD("MIME type: %s\n", mime); strncat(buf, mime, BUFMAX-strlen(buf)-1); if(mi->next) { strncat(buf, mime_delim, BUFMAX-strlen(buf)-1); @@ -4176,8 +4468,8 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, b } asvc = asvc->next; } - DBG("MIME types: buf[%s]\n", buf); - DBG("MIME count: %d\n", mime_count); + _LOGD("MIME types: buf[%s]\n", buf); + _LOGD("MIME count: %d\n", mime_count); if(mime_count) fwrite(buf, 1, strlen(buf), file); } @@ -4232,6 +4524,13 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, b fwrite(buf, 1, strlen(buf), file); } + if(mfx->uiapplication->submode && !strcasecmp(mfx->uiapplication->submode, "True")) { + snprintf(buf, BUFMAX, "X-TIZEN-Submode=%s\n", mfx->uiapplication->submode); + fwrite(buf, 1, strlen(buf), file); + snprintf(buf, BUFMAX, "X-TIZEN-SubmodeMainid=%s\n", mfx->uiapplication->submode_mainid); + fwrite(buf, 1, strlen(buf), file); + } + snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package); fwrite(buf, 1, strlen(buf), file); @@ -4242,7 +4541,7 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, b if(mfx->uiapplication->appsvc) { snprintf(buf, BUFMAX, "X-TIZEN-Svc="); - DBG("buf[%s]\n", buf); + _LOGD("buf[%s]\n", buf); uiapplication_x *up = mfx->uiapplication; @@ -4289,7 +4588,7 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, b strncpy(buftemp, buf, BUFMAX); snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL"); - DBG("buf[%s]\n", buf); + _LOGD("buf[%s]\n", buf); if (ui) ui = ui->next; @@ -4320,7 +4619,7 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, b if(mfx->uiapplication->appcontrol) { snprintf(buf, BUFMAX, "X-TIZEN-Svc="); - DBG("buf[%s]\n", buf); + _LOGD("buf[%s]\n", buf); uiapplication_x *up = mfx->uiapplication; appcontrol_x *acontrol = NULL; @@ -4364,7 +4663,7 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, b strncpy(buftemp, buf, BUFMAX); snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL"); - DBG("buf[%s]\n", buf); + _LOGD("buf[%s]\n", buf); if (ui) ui = ui->next; @@ -4397,8 +4696,10 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, b fd = fileno(file); fsync(fd); fclose(file); - - __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid); + if (action == ACTION_FOTA) + __ail_change_info(AIL_FOTA, mfx->uiapplication->appid); + else + __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid); } free(buf); @@ -4436,20 +4737,20 @@ static int __ps_remove_appsvc_db(manifest_x *mfx) uiapplication_x *uiapplication = mfx->uiapplication; if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) { - DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH); + _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH); goto END; } if ((appsvc_operation = dlsym(lib_handle, "appsvc_unset_defapp")) == NULL || dlerror() != NULL) { - DBGE("can not find symbol \n"); + _LOGE("can not find symbol \n"); goto END; } for(; uiapplication; uiapplication=uiapplication->next) { ret = appsvc_operation(uiapplication->appid); if (ret <0) - DBGE("can not operation symbol \n"); + _LOGE("can not operation symbol \n"); } END: @@ -4484,7 +4785,7 @@ static int __add_preload_info(manifest_x * mfx, const char *manifest) fp = fopen(PRELOAD_PACKAGE_LIST, "r"); if (fp == NULL) { - DBGE("no preload list\n"); + _LOGE("no preload list\n"); return -1; } @@ -4553,14 +4854,14 @@ API int pkgmgr_parser_create_desktop_file(manifest_x *mfx) { int ret = 0; if (mfx == NULL) { - DBG("Manifest pointer is NULL\n"); + _LOGD("Manifest pointer is NULL\n"); return -1; } - ret = __ps_make_nativeapp_desktop(mfx, NULL, 0); + ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL); if (ret == -1) - DBG("Creating desktop file failed\n"); + _LOGD("Creating desktop file failed\n"); else - DBG("Creating desktop file Success\n"); + _LOGD("Creating desktop file Success\n"); return ret; } @@ -4648,6 +4949,10 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx) free((void *)mfx->nodisplay_setting); mfx->nodisplay_setting = NULL; } + if (mfx->main_package) { + free((void *)mfx->main_package); + mfx->main_package = NULL; + } /*Free Icon*/ if (mfx->icon) { @@ -4796,7 +5101,7 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx) API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest) { - DBG("parsing start\n"); + _LOGD("parsing start\n"); xmlTextReaderPtr reader; manifest_x *mfx = NULL; @@ -4806,17 +5111,17 @@ API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest) if (mfx) { memset(mfx, '\0', sizeof(manifest_x)); if (__process_manifest(reader, mfx) < 0) { - DBG("Parsing Failed\n"); + _LOGD("Parsing Failed\n"); pkgmgr_parser_free_manifest_xml(mfx); mfx = NULL; } else - DBG("Parsing Success\n"); + _LOGD("Parsing Success\n"); } else { - DBG("Memory allocation error\n"); + _LOGD("Memory allocation error\n"); } xmlFreeTextReader(reader); } else { - DBG("Unable to create xml reader\n"); + _LOGD("Unable to create xml reader\n"); } return mfx; } @@ -4825,50 +5130,52 @@ API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest) 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}; - if (manifest == NULL) { - DBG("argument supplied is NULL\n"); - return PMINFO_R_EINVAL; - } - DBG("parsing manifest for installation: %s\n", manifest); +// 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; int ret = -1; - char roxml_check[PKG_STRING_LEN_MAX] = {'\0'}; xmlInitParser(); mfx = pkgmgr_parser_process_manifest_xml(manifest); - DBG("Parsing Finished\n"); - if (mfx == NULL) - return PMINFO_R_ERROR; + retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL"); - __streamFile(manifest, ACTION_INSTALL, temp, mfx->package); + _LOGD("Parsing Finished\n"); + +// __streamFile(manifest, ACTION_INSTALL, temp, mfx->package); + __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL); __add_preload_info(mfx, manifest); - DBG("Added preload infomation\n"); + + _LOGD("Added preload infomation\n"); __ps_process_tag(mfx, tagv); ret = pkgmgr_parser_insert_manifest_info_in_db(mfx); - if (ret == -1) - DBG("DB Insert failed\n"); - else - DBG("DB Insert Success\n"); + retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed"); + + _LOGD("DB Insert Success\n"); - ret = __ps_process_mdparser(mfx, ACTION_INSTALL); + ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL); if (ret == -1) - DBG("Creating metadata parser failed\n"); + _LOGD("Creating metadata parser failed\n"); ret = __ps_process_category_parser(mfx, ACTION_INSTALL); if (ret == -1) - DBG("Creating category parser failed\n"); + _LOGD("Creating category parser failed\n"); + + if (__check_action_fota(tagv)) + ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA); + else + ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL); - ret = __ps_make_nativeapp_desktop(mfx, NULL, 0); if (ret == -1) - DBG("Creating desktop file failed\n"); + _LOGD("Creating desktop file failed\n"); else - DBG("Creating desktop file Success\n"); + _LOGD("Creating desktop file Success\n"); pkgmgr_parser_free_manifest_xml(mfx); - DBG("Free Done\n"); + _LOGD("Free Done\n"); xmlCleanupParser(); return PMINFO_R_OK; @@ -4876,12 +5183,10 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char 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}; - if (manifest == NULL) { - DBG("argument supplied is NULL\n"); - return PMINFO_R_EINVAL; - } - DBG("parsing manifest for upgradation: %s\n", manifest); +// 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 upgradation: %s\n", manifest); + manifest_x *mfx = NULL; int ret = -1; bool preload = false; @@ -4891,22 +5196,23 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con xmlInitParser(); mfx = pkgmgr_parser_process_manifest_xml(manifest); - DBG("Parsing Finished\n"); - if (mfx == NULL) - return PMINFO_R_ERROR; + retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL"); + + _LOGD("Parsing Finished\n"); - __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package); +// __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package); + __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE); __add_preload_info(mfx, manifest); - DBG("Added preload infomation\n"); + _LOGD("Added preload infomation\n"); __check_preload_updated(mfx, manifest); ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle); if (ret != PMINFO_R_OK) - DBG("pkgmgrinfo_pkginfo_get_pkginfo failed\n"); + _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n"); ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload); if (ret != PMINFO_R_OK) - DBG("pkgmgrinfo_pkginfo_is_preload failed\n"); + _LOGD("pkgmgrinfo_pkginfo_is_preload failed\n"); if (preload) { free((void *)mfx->preload); @@ -4915,7 +5221,7 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con ret = pkgmgrinfo_pkginfo_is_system(handle, &system); if (ret != PMINFO_R_OK) - DBG("pkgmgrinfo_pkginfo_is_system failed\n"); + _LOGD("pkgmgrinfo_pkginfo_is_system failed\n"); if (system) { free((void *)mfx->system); @@ -4924,7 +5230,7 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path); if (ret != PMINFO_R_OK) - DBG("pkgmgrinfo_pkginfo_get_csc_path failed\n"); + _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n"); if (csc_path != NULL) { if (mfx->csc_path) @@ -4933,28 +5239,26 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con } ret = pkgmgr_parser_update_manifest_info_in_db(mfx); - if (ret == -1) - DBG("DB Update failed\n"); - else - DBG("DB Update Success\n"); + retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed"); + _LOGD("DB Update Success\n"); - ret = __ps_process_mdparser(mfx, ACTION_UPGRADE); + ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE); if (ret == -1) - DBG("Upgrade metadata parser failed\n"); + _LOGD("Upgrade metadata parser failed\n"); ret = __ps_process_category_parser(mfx, ACTION_UPGRADE); if (ret == -1) - DBG("Creating category parser failed\n"); + _LOGD("Creating category parser failed\n"); - ret = __ps_make_nativeapp_desktop(mfx, manifest, 1); + ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE); if (ret == -1) - DBG("Creating desktop file failed\n"); + _LOGD("Creating desktop file failed\n"); else - DBG("Creating desktop file Success\n"); + _LOGD("Creating desktop file Success\n"); pkgmgrinfo_pkginfo_destroy_pkginfo(handle); pkgmgr_parser_free_manifest_xml(mfx); - DBG("Free Done\n"); + _LOGD("Free Done\n"); xmlCleanupParser(); return PMINFO_R_OK; @@ -4962,52 +5266,52 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con 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}; - if (manifest == NULL) { - DBG("argument supplied is NULL\n"); - return PMINFO_R_EINVAL; - } - DBG("parsing manifest for uninstallation: %s\n", manifest); +// 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); + manifest_x *mfx = NULL; int ret = -1; xmlInitParser(); mfx = pkgmgr_parser_process_manifest_xml(manifest); - DBG("Parsing Finished\n"); - if (mfx == NULL) - return PMINFO_R_ERROR; - - __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package); + retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL"); + + _LOGD("Parsing Finished\n"); + +// __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package); + __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL); + __add_preload_info(mfx, manifest); - DBG("Added preload infomation\n"); + _LOGD("Added preload infomation\n"); - ret = __ps_process_mdparser(mfx, ACTION_UNINSTALL); + ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL); if (ret == -1) - DBG("Removing metadata parser failed\n"); + _LOGD("Removing metadata parser failed\n"); ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL); if (ret == -1) - DBG("Creating category parser failed\n"); + _LOGD("Creating category parser failed\n"); ret = pkgmgr_parser_delete_manifest_info_from_db(mfx); if (ret == -1) - DBG("DB Delete failed\n"); + _LOGD("DB Delete failed\n"); else - DBG("DB Delete Success\n"); + _LOGD("DB Delete Success\n"); ret = __ps_remove_nativeapp_desktop(mfx); if (ret == -1) - DBG("Removing desktop file failed\n"); + _LOGD("Removing desktop file failed\n"); else - DBG("Removing desktop file Success\n"); + _LOGD("Removing desktop file Success\n"); ret = __ps_remove_appsvc_db(mfx); if (ret == -1) - DBG("Removing appsvc_db failed\n"); + _LOGD("Removing appsvc_db failed\n"); else - DBG("Removing appsvc_db Success\n"); + _LOGD("Removing appsvc_db Success\n"); pkgmgr_parser_free_manifest_xml(mfx); - DBG("Free Done\n"); + _LOGD("Free Done\n"); xmlCleanupParser(); return PMINFO_R_OK; @@ -5043,7 +5347,7 @@ API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char API int pkgmgr_parser_check_manifest_validation(const char *manifest) { if (manifest == NULL) { - DBGE("manifest file is NULL\n"); + _LOGE("manifest file is NULL\n"); return PMINFO_R_EINVAL; } int ret = -1; @@ -5052,29 +5356,29 @@ API int pkgmgr_parser_check_manifest_validation(const char *manifest) xmlSchemaPtr xschema; ctx = xmlSchemaNewParserCtxt(SCHEMA_FILE); if (ctx == NULL) { - DBGE("xmlSchemaNewParserCtxt() Failed\n"); + _LOGE("xmlSchemaNewParserCtxt() Failed\n"); return PMINFO_R_ERROR; } xschema = xmlSchemaParse(ctx); if (xschema == NULL) { - DBGE("xmlSchemaParse() Failed\n"); + _LOGE("xmlSchemaParse() Failed\n"); return PMINFO_R_ERROR; } vctx = xmlSchemaNewValidCtxt(xschema); if (vctx == NULL) { - DBGE("xmlSchemaNewValidCtxt() Failed\n"); + _LOGE("xmlSchemaNewValidCtxt() Failed\n"); return PMINFO_R_ERROR; } xmlSchemaSetValidErrors(vctx, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr); ret = xmlSchemaValidateFile(vctx, manifest, 0); if (ret == -1) { - DBGE("xmlSchemaValidateFile() failed\n"); + _LOGE("xmlSchemaValidateFile() failed\n"); return PMINFO_R_ERROR; } else if (ret == 0) { - DBGE("Manifest is Valid\n"); + _LOGE("Manifest is Valid\n"); return PMINFO_R_OK; } else { - DBGE("Manifest Validation Failed with error code %d\n", ret); + _LOGE("Manifest Validation Failed with error code %d\n", ret); return PMINFO_R_ERROR; } return PMINFO_R_OK; @@ -5091,7 +5395,7 @@ API int pkgmgr_parser_check_manifest_validation(const char *manifest) switch (pid) { case -1: - DBGE("fork failed\n"); + _LOGE("fork failed\n"); return -1; case 0: /* child */ @@ -5106,7 +5410,7 @@ API int pkgmgr_parser_check_manifest_validation(const char *manifest) if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema", SCHEMA_FILE, NULL) < 0) { - DBGE("execl error\n"); + _LOGE("execl error\n"); } _exit(100); @@ -5120,7 +5424,7 @@ API int pkgmgr_parser_check_manifest_validation(const char *manifest) if (err < 0) { if (errno == EINTR) continue; - DBGE("waitpid failed\n"); + _LOGE("waitpid failed\n"); return -1; } } diff --git a/parser/pkgmgr_parser.h b/parser/pkgmgr_parser.h index 85cb41c..60e6663 100755 --- a/parser/pkgmgr_parser.h +++ b/parser/pkgmgr_parser.h @@ -467,6 +467,7 @@ typedef struct manifest_x { const char *root_path; /**< package root path*/ const char *csc_path; /**< package csc path*/ const char *nodisplay_setting; /**< package no display setting menu*/ + const char *main_package; /**< main package id for sub-package(ug)*/ struct icon_x *icon; /**< package icon*/ struct label_x *label; /**< package label*/ struct author_x *author; /**< package author*/ diff --git a/parser/pkgmgr_parser_db.c b/parser/pkgmgr_parser_db.c index de46f96..a349f5c 100755 --- a/parser/pkgmgr_parser_db.c +++ b/parser/pkgmgr_parser_db.c @@ -32,9 +32,19 @@ #include "pkgmgr_parser_internal.h" #include "pkgmgr_parser_db.h" +#include "pkgmgr-info-debug.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "PKGMGR_PARSER" + #define PKGMGR_PARSER_DB_FILE "/opt/dbspace/.pkgmgr_parser.db" #define PKGMGR_CERT_DB_FILE "/opt/dbspace/.pkgmgr_cert.db" #define MAX_QUERY_LEN 4096 + +#define PKGMGR_PARSER_EMPTY_STR "" + sqlite3 *pkgmgr_parser_db; sqlite3 *pkgmgr_cert_db; @@ -247,6 +257,7 @@ static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata) static void __insert_pkglocale_info(gpointer data, gpointer userdata); static int __insert_manifest_info_in_db(manifest_x *mfx); static int __delete_manifest_info_from_db(manifest_x *mfx); +static int __delete_subpkg_info_from_db(char *appid); static int __delete_appinfo_from_db(char *db_table, const char *appid); static int __initialize_db(sqlite3 *db_handle, const char *db_query); static int __exec_query(char *query); @@ -258,6 +269,24 @@ static void __preserve_guestmode_visibility_value(manifest_x *mfx); static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname); static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path); +static int __delete_subpkg_list_cb(void *data, int ncols, char **coltxt, char **colname) +{ + if (coltxt[0]) + __delete_subpkg_info_from_db(coltxt[0]); + + return 0; +} + +static char *__get_str(const char *str) +{ + if (str == NULL) + { + return PKGMGR_PARSER_EMPTY_STR; + } + + return str; +} + static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path) { int ret = -1; @@ -267,21 +296,21 @@ static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path) db_util_open(db_path, &handle, DB_UTIL_REGISTER_HOOK_METHOD); if (ret != SQLITE_OK) { - DBG("connect db [%s] failed!\n", + _LOGD("connect db [%s] failed!\n", db_path); return -1; } *db_handle = handle; return 0; } - DBG("%s DB does not exists. Create one!!\n", db_path); + _LOGD("%s DB does not exists. Create one!!\n", db_path); ret = db_util_open(db_path, &handle, DB_UTIL_REGISTER_HOOK_METHOD); if (ret != SQLITE_OK) { - DBG("connect db [%s] failed!\n", db_path); + _LOGD("connect db [%s] failed!\n", db_path); return -1; } *db_handle = handle; @@ -307,7 +336,7 @@ static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char } } if (appid == NULL) { - DBG("app id is NULL\n"); + _LOGD("app id is NULL\n"); return -1; } /*update guest mode visibility*/ @@ -338,7 +367,7 @@ static void __preserve_guestmode_visibility_value(manifest_x *mfx) if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, __guestmode_visibility_cb, (void *)mfx, &error_message)) { - DBG("Don't execute query = %s error message = %s\n", + _LOGD("Don't execute query = %s error message = %s\n", query, error_message); sqlite3_free(error_message); } @@ -351,7 +380,7 @@ static int __initialize_db(sqlite3 *db_handle, const char *db_query) if (SQLITE_OK != sqlite3_exec(db_handle, db_query, NULL, NULL, &error_message)) { - DBG("Don't execute query = %s error message = %s\n", + _LOGD("Don't execute query = %s error message = %s\n", db_query, error_message); sqlite3_free(error_message); return -1; @@ -365,7 +394,7 @@ static int __exec_query(char *query) char *error_message = NULL; if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) { - DBG("Don't execute query = %s error message = %s\n", query, + _LOGD("Don't execute query = %s error message = %s\n", query, error_message); sqlite3_free(error_message); return -1; @@ -447,7 +476,7 @@ static GList *__create_image_list(GList *locale, image_x *image) static void __printfunc(gpointer data, gpointer userdata) { - DBG("%s ", (char*)data); + _LOGD("%s ", (char*)data); } static void __trimfunc(GList* trim_list) @@ -596,13 +625,21 @@ static void __insert_pkglocale_info(gpointer data, gpointer userdata) __extract_data(data, lbl, lcn, icn, dcn, ath, &label, &license, &icon, &description, &author); if (!label && !description && !icon && !license && !author) return; + sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_localized_info(package, package_locale, " \ "package_label, package_icon, package_description, package_license, package_author) values " \ - "('%q', '%q', '%q', '%q', '%q', '%q', '%q')", mfx->package, (char*)data, - label, icon, description, license, author); + "('%q', '%q', '%q', '%q', '%s', '%s', '%s')", + mfx->package, + (char*)data, + label, + icon, + __get_str(description), + __get_str(license), + __get_str(author)); + ret = __exec_query(query); if (ret == -1) - DBG("Package Localized Info DB Insert failed\n"); + _LOGD("Package Localized Info DB Insert failed\n"); } static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata) @@ -625,14 +662,21 @@ static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata) label, icon); ret = __exec_query(query); if (ret == -1) - DBG("Package UiApp Localized Info DB Insert failed\n"); + _LOGD("Package UiApp Localized Info DB Insert failed\n"); /*insert ui app locale info to pkg locale to get mainapp data */ if (strcasecmp(up->mainapp, "true")==0) { sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_localized_info(package, package_locale, " \ "package_label, package_icon, package_description, package_license, package_author) values " \ - "('%q', '%q', '%q', '%q', '%q', '%q', '%q')", up->package, (char*)data, - label, icon, NULL, NULL, NULL); + "('%q', '%q', '%q', '%q', '%q', '%q', '%q')", + up->package, + (char*)data, + label, + icon, + PKGMGR_PARSER_EMPTY_STR, + PKGMGR_PARSER_EMPTY_STR, + PKGMGR_PARSER_EMPTY_STR); + ret = __exec_query_no_msg(query); if (icon != NULL) { @@ -663,7 +707,7 @@ static void __insert_uiapplication_icon_section_info(gpointer data, gpointer use ret = __exec_query(query); if (ret == -1) - DBG("Package UiApp Localized Info DB Insert failed\n"); + _LOGD("Package UiApp Localized Info DB Insert failed\n"); } @@ -686,7 +730,7 @@ static void __insert_uiapplication_image_info(gpointer data, gpointer userdata) ret = __exec_query(query); if (ret == -1) - DBG("Package UiApp image Info DB Insert failed\n"); + _LOGD("Package UiApp image Info DB Insert failed\n"); } @@ -711,7 +755,7 @@ static void __insert_serviceapplication_locale_info(gpointer data, gpointer user label, icon); ret = __exec_query(query); if (ret == -1) - DBG("Package ServiceApp Localized Info DB Insert failed\n"); + _LOGD("Package ServiceApp Localized Info DB Insert failed\n"); } static int __insert_ui_mainapp_info(manifest_x *mfx) @@ -726,7 +770,7 @@ static int __insert_ui_mainapp_info(manifest_x *mfx) ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp Info DB Insert Failed\n"); + _LOGD("Package UiApp Info DB Insert Failed\n"); return -1; } if (strcasecmp(up->mainapp, "True")==0) @@ -740,13 +784,13 @@ static int __insert_ui_mainapp_info(manifest_x *mfx) if (mfx->uiapplication && mfx->uiapplication->appid) { snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_mainapp='true' where app_id='%s'", mfx->uiapplication->appid); } else { - DBG("Not valid appid\n"); + _LOGD("Not valid appid\n"); return -1; } ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp Info DB Insert Failed\n"); + _LOGD("Package UiApp Info DB Insert Failed\n"); return -1; } @@ -760,7 +804,7 @@ static int __insert_ui_mainapp_info(manifest_x *mfx) "update package_info set mainapp_id='%s' where package='%s'", mfx->mainapp_id, mfx->package); ret = __exec_query(query); if (ret == -1) { - DBG("Package Info DB update Failed\n"); + _LOGD("Package Info DB update Failed\n"); return -1; } @@ -782,13 +826,35 @@ static int __insert_uiapplication_info(manifest_x *mfx) "app_launchcondition, app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, "\ "app_preload, app_submode, app_submode_mainid, component_type, package) " \ "values('%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\ - up->appid, "uiapp", up->exec, up->nodisplay, up->type, "\0", up->multiple, - "\0", up->taskmanage, up->enabled, up->hwacceleration, up->screenreader, up->mainapp, up->recentimage, - up->launchcondition, up->indicatordisplay, up->portraitimg, up->landscapeimg, up->guestmode_visibility, up->permission_type, - mfx->preload, up->submode, up->submode_mainid, up->component_type, mfx->package); + up->appid, + "uiapp", + up->exec, + up->nodisplay, + up->type, + PKGMGR_PARSER_EMPTY_STR, + up->multiple, + PKGMGR_PARSER_EMPTY_STR, + up->taskmanage, + up->enabled, + up->hwacceleration, + up->screenreader, + up->mainapp, + __get_str(up->recentimage), + up->launchcondition, + up->indicatordisplay, + __get_str(up->portraitimg), + __get_str(up->landscapeimg), + up->guestmode_visibility, + up->permission_type, + mfx->preload, + up->submode, + __get_str(up->submode_mainid), + up->component_type, + mfx->package); + ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp Info DB Insert Failed\n"); + _LOGD("Package UiApp Info DB Insert Failed\n"); return -1; } up = up->next; @@ -814,7 +880,7 @@ static int __insert_uiapplication_appcategory_info(manifest_x *mfx) up->appid, ct->name); ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp Category Info DB Insert Failed\n"); + _LOGD("Package UiApp Category Info DB Insert Failed\n"); return -1; } ct = ct->next; @@ -843,7 +909,7 @@ static int __insert_uiapplication_appmetadata_info(manifest_x *mfx) up->appid, md->key, md->value); ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp Metadata Info DB Insert Failed\n"); + _LOGD("Package UiApp Metadata Info DB Insert Failed\n"); return -1; } } @@ -872,7 +938,7 @@ static int __insert_uiapplication_apppermission_info(manifest_x *mfx) up->appid, pm->type, pm->value); ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp permission Info DB Insert Failed\n"); + _LOGD("Package UiApp permission Info DB Insert Failed\n"); return -1; } pm = pm->next; @@ -930,7 +996,7 @@ static int __insert_uiapplication_appcontrol_info(manifest_x *mfx) ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp AppSvc DB Insert Failed\n"); + _LOGD("Package UiApp AppSvc DB Insert Failed\n"); return -1; } memset(query, '\0', MAX_QUERY_LEN); @@ -1000,11 +1066,15 @@ static int __insert_uiapplication_appsvc_info(manifest_x *mfx) snprintf(query, MAX_QUERY_LEN, "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type, subapp_name) " \ "values('%s', '%s', '%s', '%s', '%s')",\ - up->appid, operation, uri, mime, subapp); + up->appid, + operation, + __get_str(uri), + __get_str(mime), + __get_str(subapp)); ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp AppSvc DB Insert Failed\n"); + _LOGD("Package UiApp AppSvc DB Insert Failed\n"); return -1; } memset(query, '\0', MAX_QUERY_LEN); @@ -1052,7 +1122,7 @@ static int __insert_uiapplication_share_request_info(manifest_x *mfx) up->appid, rq->text); ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp Share Request DB Insert Failed\n"); + _LOGD("Package UiApp Share Request DB Insert Failed\n"); return -1; } memset(query, '\0', MAX_QUERY_LEN); @@ -1090,7 +1160,7 @@ static int __insert_uiapplication_share_allowed_info(manifest_x *mfx) up->appid, df->path, al->text); ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp Share Allowed DB Insert Failed\n"); + _LOGD("Package UiApp Share Allowed DB Insert Failed\n"); return -1; } memset(query, '\0', MAX_QUERY_LEN); @@ -1120,7 +1190,7 @@ static int __insert_serviceapplication_info(manifest_x *mfx) sp->autorestart, sp->enabled, sp->permission_type, mfx->package); ret = __exec_query(query); if (ret == -1) { - DBG("Package ServiceApp Info DB Insert Failed\n"); + _LOGD("Package ServiceApp Info DB Insert Failed\n"); return -1; } sp = sp->next; @@ -1146,7 +1216,7 @@ static int __insert_serviceapplication_appcategory_info(manifest_x *mfx) sp->appid, ct->name); ret = __exec_query(query); if (ret == -1) { - DBG("Package ServiceApp Category Info DB Insert Failed\n"); + _LOGD("Package ServiceApp Category Info DB Insert Failed\n"); return -1; } ct = ct->next; @@ -1175,7 +1245,7 @@ static int __insert_serviceapplication_appmetadata_info(manifest_x *mfx) sp->appid, md->key, md->value); ret = __exec_query(query); if (ret == -1) { - DBG("Package ServiceApp Metadata Info DB Insert Failed\n"); + _LOGD("Package ServiceApp Metadata Info DB Insert Failed\n"); return -1; } } @@ -1204,7 +1274,7 @@ static int __insert_serviceapplication_apppermission_info(manifest_x *mfx) sp->appid, pm->type, pm->value); ret = __exec_query(query); if (ret == -1) { - DBG("Package ServiceApp permission Info DB Insert Failed\n"); + _LOGD("Package ServiceApp permission Info DB Insert Failed\n"); return -1; } pm = pm->next; @@ -1260,7 +1330,7 @@ static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx) sp->appid, operation, uri, mime, subapp); ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp AppSvc DB Insert Failed\n"); + _LOGD("Package UiApp AppSvc DB Insert Failed\n"); return -1; } memset(query, '\0', MAX_QUERY_LEN); @@ -1329,10 +1399,14 @@ static int __insert_serviceapplication_appsvc_info(manifest_x *mfx) snprintf(query, MAX_QUERY_LEN, "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type, subapp_name) " \ "values('%s', '%s', '%s', '%s', '%s')",\ - sp->appid, operation, uri, mime, subapp); + sp->appid, + operation, + __get_str(uri), + __get_str(mime), + __get_str(subapp)); ret = __exec_query(query); if (ret == -1) { - DBG("Package UiApp AppSvc DB Insert Failed\n"); + _LOGD("Package UiApp AppSvc DB Insert Failed\n"); return -1; } memset(query, '\0', MAX_QUERY_LEN); @@ -1382,7 +1456,7 @@ static int __insert_serviceapplication_share_request_info(manifest_x *mfx) sp->appid, rq->text); ret = __exec_query(query); if (ret == -1) { - DBG("Package ServiceApp Share Request DB Insert Failed\n"); + _LOGD("Package ServiceApp Share Request DB Insert Failed\n"); return -1; } memset(query, '\0', MAX_QUERY_LEN); @@ -1422,7 +1496,7 @@ static int __insert_serviceapplication_share_allowed_info(manifest_x *mfx) sp->appid, df->path, al->text); ret = __exec_query(query); if (ret == -1) { - DBG("Package App Share Allowed DB Insert Failed\n"); + _LOGD("Package App Share Allowed DB Insert Failed\n"); return -1; } memset(query, '\0', MAX_QUERY_LEN); @@ -1494,21 +1568,56 @@ static int __insert_manifest_info_in_db(manifest_x *mfx) "package_removable, package_preload, package_readonly, package_update, package_appsetting, package_nodisplay, package_system," \ "author_name, author_email, author_href, installed_time, installed_storage, storeclient_id, mainapp_id, package_url, root_path, csc_path) " \ "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\ - mfx->package, type, mfx->version, mfx->installlocation, mfx->package_size, mfx->removable, mfx->preload, - mfx->readonly, mfx->update, mfx->appsetting, mfx->nodisplay_setting, mfx->system, - auth_name, auth_email, auth_href, mfx->installed_time, mfx->installed_storage, mfx->storeclient_id, mfx->mainapp_id, mfx->package_url, path, mfx->csc_path); - ret = __exec_query(query); - if (ret == -1) { - DBG("Package Info DB Insert Failed\n"); - if (type) { - free(type); - type = NULL; + mfx->package, + type, + mfx->version, + __get_str(mfx->installlocation), + __get_str(mfx->package_size), + mfx->removable, + mfx->preload, + mfx->readonly, + mfx->update, + mfx->appsetting, + mfx->nodisplay_setting, + mfx->system, + __get_str(auth_name), + __get_str(auth_email), + __get_str(auth_href), + mfx->installed_time, + mfx->installed_storage, + __get_str(mfx->storeclient_id), + mfx->mainapp_id, + __get_str(mfx->package_url), + path, + __get_str(mfx->csc_path)); + + /*If package dont have main_package tag, this package is main package.*/ + if (mfx->main_package == NULL) { + ret = __exec_query(query); + if (ret == -1) { + _LOGD("Package Info DB Insert Failed\n"); + if (type) { + free(type); + type = NULL; + } + if (path) { + free(path); + path = NULL; + } + return -1; } - if (path) { - free(path); - path = NULL; + } else { + /*If package has main_package tag, this package is sub package(ug, efl). + skip __exec_query for package_info and change pkgid with main_package*/ + memset(root, '\0', MAX_QUERY_LEN); + snprintf(root, MAX_QUERY_LEN - 1, "/usr/apps/%s", mfx->main_package); + if (access(root, F_OK) == 0) { + free((void *)mfx->package); + mfx->package = strdup(mfx->main_package); + } else { + _LOGE("main package[%s] is not installed\n", root); + return -1; } - return -1; } if (type) { free(type); @@ -1531,7 +1640,7 @@ static int __insert_manifest_info_in_db(manifest_x *mfx) mfx->package, pv->text); ret = __exec_query(query); if (ret == -1) { - DBG("Package Privilege Info DB Insert Failed\n"); + _LOGD("Package Privilege Info DB Insert Failed\n"); return -1; } pv = pv->next; @@ -1581,11 +1690,13 @@ static int __insert_manifest_info_in_db(manifest_x *mfx) __trimfunc(appimage); /*g_list_foreach(pkglocale, __printfunc, NULL);*/ - /*DBG("\n");*/ + /*_LOGD("\n");*/ /*g_list_foreach(applocale, __printfunc, NULL);*/ - /*package locale info*/ - g_list_foreach(pkglocale, __insert_pkglocale_info, (gpointer)mfx); + /*package locale info, it is only for main package.*/ + if (mfx->main_package == NULL) + g_list_foreach(pkglocale, __insert_pkglocale_info, (gpointer)mfx); + /*native app locale info*/ up = mfx->uiapplication; while(up != NULL) @@ -1704,9 +1815,69 @@ static int __delete_appinfo_from_db(char *db_table, const char *appid) "delete from %s where app_id='%s'", db_table, appid); ret = __exec_query(query); if (ret == -1) { - DBG("DB Deletion from table (%s) Failed\n", db_table); + _LOGD("DB Deletion from table (%s) Failed\n", db_table); + return -1; + } + return 0; +} + +static int __delete_subpkg_info_from_db(char *appid) +{ + int ret = -1; + + ret = __delete_appinfo_from_db("package_app_info", appid); + if (ret < 0) + return ret; + ret = __delete_appinfo_from_db("package_app_localized_info", appid); + if (ret < 0) + return ret; + ret = __delete_appinfo_from_db("package_app_icon_section_info", appid); + if (ret < 0) + return ret; + ret = __delete_appinfo_from_db("package_app_image_info", appid); + if (ret < 0) + return ret; + ret = __delete_appinfo_from_db("package_app_app_svc", appid); + if (ret < 0) + return ret; + ret = __delete_appinfo_from_db("package_app_app_control", appid); + if (ret < 0) + return ret; + ret = __delete_appinfo_from_db("package_app_app_category", appid); + if (ret < 0) + return ret; + ret = __delete_appinfo_from_db("package_app_app_metadata", appid); + if (ret < 0) + return ret; + ret = __delete_appinfo_from_db("package_app_app_permission", appid); + if (ret < 0) + return ret; + ret = __delete_appinfo_from_db("package_app_share_allowed", appid); + if (ret < 0) + return ret; + ret = __delete_appinfo_from_db("package_app_share_request", appid); + if (ret < 0) + return ret; + + return 0; +} + +static int __delete_subpkg_from_db(manifest_x *mfx) +{ + char query[MAX_QUERY_LEN] = { '\0' }; + int ret = -1; + char *error_message = NULL; + + snprintf(query, MAX_QUERY_LEN, "select app_id from package_app_info where package='%s'", mfx->package); + if (SQLITE_OK != + sqlite3_exec(pkgmgr_parser_db, query, __delete_subpkg_list_cb, NULL, &error_message)) { + _LOGE("Don't execute query = %s error message = %s\n", query, + error_message); + sqlite3_free(error_message); return -1; } + sqlite3_free(error_message); + return 0; } @@ -1719,7 +1890,7 @@ static int __delete_manifest_info_from_db(manifest_x *mfx) /*Delete from cert table*/ ret = pkgmgrinfo_delete_certinfo(mfx->package); if (ret) { - DBG("Cert Info DB Delete Failed\n"); + _LOGD("Cert Info DB Delete Failed\n"); return -1; } @@ -1728,7 +1899,7 @@ static int __delete_manifest_info_from_db(manifest_x *mfx) "delete from package_info where package='%s'", mfx->package); ret = __exec_query(query); if (ret == -1) { - DBG("Package Info DB Delete Failed\n"); + _LOGD("Package Info DB Delete Failed\n"); return -1; } memset(query, '\0', MAX_QUERY_LEN); @@ -1738,7 +1909,7 @@ static int __delete_manifest_info_from_db(manifest_x *mfx) "delete from package_localized_info where package='%s'", mfx->package); ret = __exec_query(query); if (ret == -1) { - DBG("Package Localized Info DB Delete Failed\n"); + _LOGD("Package Localized Info DB Delete Failed\n"); return -1; } @@ -1747,7 +1918,7 @@ static int __delete_manifest_info_from_db(manifest_x *mfx) "delete from package_privilege_info where package='%s'", mfx->package); ret = __exec_query(query); if (ret == -1) { - DBG("Package Privilege Info DB Delete Failed\n"); + _LOGD("Package Privilege Info DB Delete Failed\n"); return -1; } @@ -1824,6 +1995,10 @@ static int __delete_manifest_info_from_db(manifest_x *mfx) return ret; sp = sp->next; } + + /* if main package has sub pkg, delete sub pkg data*/ + __delete_subpkg_from_db(mfx); + return 0; } @@ -1836,7 +2011,7 @@ static int __update_preload_condition_in_db() ret = __exec_query(query); if (ret == -1) - DBG("Package preload_condition update failed\n"); + _LOGD("Package preload_condition update failed\n"); return ret; } @@ -1847,83 +2022,83 @@ int pkgmgr_parser_initialize_db() /*Manifest DB*/ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO); if (ret == -1) { - DBG("package info DB initialization failed\n"); + _LOGD("package info DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO); if (ret == -1) { - DBG("package localized info DB initialization failed\n"); + _LOGD("package localized info DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO); if (ret == -1) { - DBG("package app app privilege DB initialization failed\n"); + _LOGD("package app app privilege DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO); if (ret == -1) { - DBG("package app info DB initialization failed\n"); + _LOGD("package app info DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO); if (ret == -1) { - DBG("package app localized info DB initialization failed\n"); + _LOGD("package app localized info DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO); if (ret == -1) { - DBG("package app icon localized info DB initialization failed\n"); + _LOGD("package app icon localized info DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO); if (ret == -1) { - DBG("package app image info DB initialization failed\n"); + _LOGD("package app image info DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL); if (ret == -1) { - DBG("package app app control DB initialization failed\n"); + _LOGD("package app app control DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY); if (ret == -1) { - DBG("package app app category DB initialization failed\n"); + _LOGD("package app app category DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA); if (ret == -1) { - DBG("package app app category DB initialization failed\n"); + _LOGD("package app app category DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION); if (ret == -1) { - DBG("package app app permission DB initialization failed\n"); + _LOGD("package app app permission DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC); if (ret == -1) { - DBG("package app app svc DB initialization failed\n"); + _LOGD("package app app svc DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED); if (ret == -1) { - DBG("package app share allowed DB initialization failed\n"); + _LOGD("package app share allowed DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST); if (ret == -1) { - DBG("package app share request DB initialization failed\n"); + _LOGD("package app share request DB initialization failed\n"); return ret; } /*Cert DB*/ ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO); if (ret == -1) { - DBG("package cert info DB initialization failed\n"); + _LOGD("package cert info DB initialization failed\n"); return ret; } ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO); if (ret == -1) { - DBG("package cert index info DB initialization failed\n"); + _LOGD("package cert index info DB initialization failed\n"); return ret; } return 0; @@ -1935,13 +2110,13 @@ int pkgmgr_parser_check_and_create_db() /*Manifest DB*/ ret = __pkgmgr_parser_create_db(&pkgmgr_parser_db, PKGMGR_PARSER_DB_FILE); if (ret) { - DBG("Manifest DB creation Failed\n"); + _LOGD("Manifest DB creation Failed\n"); return -1; } /*Cert DB*/ ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, PKGMGR_CERT_DB_FILE); if (ret) { - DBG("Cert DB creation Failed\n"); + _LOGD("Cert DB creation Failed\n"); return -1; } return 0; @@ -1956,13 +2131,13 @@ void pkgmgr_parser_close_db() API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx) { if (mfx == NULL) { - DBG("manifest pointer is NULL\n"); + _LOGD("manifest pointer is NULL\n"); return -1; } int ret = 0; ret = pkgmgr_parser_check_and_create_db(); if (ret == -1) { - DBG("Failed to open DB\n"); + _LOGD("Failed to open DB\n"); return ret; } ret = pkgmgr_parser_initialize_db(); @@ -1971,26 +2146,26 @@ API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx) /*Begin transaction*/ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); if (ret != SQLITE_OK) { - DBG("Failed to begin transaction\n"); + _LOGD("Failed to begin transaction\n"); ret = -1; goto err; } - DBG("Transaction Begin\n"); + _LOGD("Transaction Begin\n"); ret = __insert_manifest_info_in_db(mfx); if (ret == -1) { - DBG("Insert into DB failed. Rollback now\n"); + _LOGD("Insert into DB failed. Rollback now\n"); sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); goto err; } /*Commit transaction*/ ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL); if (ret != SQLITE_OK) { - DBG("Failed to commit transaction. Rollback now\n"); + _LOGD("Failed to commit transaction. Rollback now\n"); sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); ret = -1; goto err; } - DBG("Transaction Commit and End\n"); + _LOGD("Transaction Commit and End\n"); err: pkgmgr_parser_close_db(); return ret; @@ -1999,13 +2174,13 @@ err: API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx) { if (mfx == NULL) { - DBG("manifest pointer is NULL\n"); + _LOGD("manifest pointer is NULL\n"); return -1; } int ret = 0; ret = pkgmgr_parser_check_and_create_db(); if (ret == -1) { - DBG("Failed to open DB\n"); + _LOGD("Failed to open DB\n"); return ret; } ret = pkgmgr_parser_initialize_db(); @@ -2016,20 +2191,20 @@ API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx) /*Begin transaction*/ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); if (ret != SQLITE_OK) { - DBG("Failed to begin transaction\n"); + _LOGD("Failed to begin transaction\n"); ret = -1; goto err; } - DBG("Transaction Begin\n"); + _LOGD("Transaction Begin\n"); ret = __delete_manifest_info_from_db(mfx); if (ret == -1) { - DBG("Delete from DB failed. Rollback now\n"); + _LOGD("Delete from DB failed. Rollback now\n"); sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); goto err; } ret = __insert_manifest_info_in_db(mfx); if (ret == -1) { - DBG("Insert into DB failed. Rollback now\n"); + _LOGD("Insert into DB failed. Rollback now\n"); sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); goto err; } @@ -2037,12 +2212,12 @@ API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx) /*Commit transaction*/ ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL); if (ret != SQLITE_OK) { - DBG("Failed to commit transaction. Rollback now\n"); + _LOGD("Failed to commit transaction. Rollback now\n"); sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); ret = -1; goto err; } - DBG("Transaction Commit and End\n"); + _LOGD("Transaction Commit and End\n"); err: pkgmgr_parser_close_db(); return ret; @@ -2051,38 +2226,38 @@ err: API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx) { if (mfx == NULL) { - DBG("manifest pointer is NULL\n"); + _LOGD("manifest pointer is NULL\n"); return -1; } int ret = 0; ret = pkgmgr_parser_check_and_create_db(); if (ret == -1) { - DBG("Failed to open DB\n"); + _LOGD("Failed to open DB\n"); return ret; } /*Begin transaction*/ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); if (ret != SQLITE_OK) { - DBG("Failed to begin transaction\n"); + _LOGD("Failed to begin transaction\n"); ret = -1; goto err; } - DBG("Transaction Begin\n"); + _LOGD("Transaction Begin\n"); ret = __delete_manifest_info_from_db(mfx); if (ret == -1) { - DBG("Delete from DB failed. Rollback now\n"); + _LOGD("Delete from DB failed. Rollback now\n"); sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); goto err; } /*Commit transaction*/ ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL); if (ret != SQLITE_OK) { - DBG("Failed to commit transaction, Rollback now\n"); + _LOGD("Failed to commit transaction, Rollback now\n"); sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); ret = -1; goto err; } - DBG("Transaction Commit and End\n"); + _LOGD("Transaction Commit and End\n"); err: pkgmgr_parser_close_db(); return ret; @@ -2093,32 +2268,32 @@ API int pkgmgr_parser_update_preload_info_in_db() int ret = 0; ret = pkgmgr_parser_check_and_create_db(); if (ret == -1) { - DBG("Failed to open DB\n"); + _LOGD("Failed to open DB\n"); return ret; } /*Begin transaction*/ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); if (ret != SQLITE_OK) { - DBG("Failed to begin transaction\n"); + _LOGD("Failed to begin transaction\n"); ret = -1; goto err; } - DBG("Transaction Begin\n"); + _LOGD("Transaction Begin\n"); ret = __update_preload_condition_in_db(); if (ret == -1) { - DBG("__update_preload_condition_in_db failed. Rollback now\n"); + _LOGD("__update_preload_condition_in_db failed. Rollback now\n"); sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); goto err; } /*Commit transaction*/ ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL); if (ret != SQLITE_OK) { - DBG("Failed to commit transaction, Rollback now\n"); + _LOGD("Failed to commit transaction, Rollback now\n"); sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL); ret = -1; goto err; } - DBG("Transaction Commit and End\n"); + _LOGD("Transaction Commit and End\n"); err: pkgmgr_parser_close_db(); return ret; diff --git a/parser/pkgmgr_parser_internal.h b/parser/pkgmgr_parser_internal.h index 7d422b3..a891b0b 100755 --- a/parser/pkgmgr_parser_internal.h +++ b/parser/pkgmgr_parser_internal.h @@ -27,30 +27,6 @@ #ifndef __PKGMGR_PARSER_INTERNAL_H__ #define __PKGMGR_PARSER_INTERNAL_H__ - -/* debug output */ -#if defined(NDEBUG) -#define DBG(fmt, args...) -#define __SET_DBG_OUTPUT(fp) -#elif defined(PRINT) -#include -FILE *___log = NULL; -#define DBG(fmt, args...) \ - {if (!___log) ___log = stderr; \ - fprintf(___log, "[DBG:PMS]%s:%d:%s(): " fmt "\n",\ - basename(__FILE__), __LINE__, __func__, ##args); fflush(___log); } -#define __SET_DBG_OUTPUT(fp) \ - (___log = fp) -#else -#include -#undef LOG_TAG -#define LOG_TAG "PKGMGR_PARSER" - -#define DBGE(fmt, arg...) LOGE(fmt,##arg) -#define DBG(fmt, arg...) LOGD(fmt,##arg) -#endif - - #ifndef API #define API __attribute__ ((visibility("default"))) #endif diff --git a/parser/pkgmgr_parser_signature.c b/parser/pkgmgr_parser_signature.c new file mode 100644 index 0000000..ede335d --- /dev/null +++ b/parser/pkgmgr_parser_signature.c @@ -0,0 +1,734 @@ +/* + * rpm-installer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jayoun Lee , Sewook Park , + * Jaeho Lee , Shobhit Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#include +#include "pkgmgr_parser_signature.h" + +#define ASCII(s) (const char *)s +#define XMLCHAR(s) (const xmlChar *)s + +static int _ri_next_child_element(xmlTextReaderPtr reader, int depth) +{ + int ret = xmlTextReaderRead(reader); + int cur = xmlTextReaderDepth(reader); + while (ret == 1) { + + switch (xmlTextReaderNodeType(reader)) { + case XML_READER_TYPE_ELEMENT: + if (cur == depth + 1) + return 1; + break; + case XML_READER_TYPE_TEXT: + if (cur == depth + 1) + return 0; + break; + case XML_READER_TYPE_END_ELEMENT: + if (cur == depth) + return 0; + break; + default: + if (cur <= depth) + return 0; + break; + } + ret = xmlTextReaderRead(reader); + cur = xmlTextReaderDepth(reader); + } + return ret; +} + +static void _ri_free_transform(transform_x *transform) +{ + if (transform == NULL) + return; + if (transform->algorithm) { + free((void *)transform->algorithm); + transform->algorithm = NULL; + } + free((void*)transform); + transform = NULL; +} + +static void _ri_free_cannonicalizationmethod(cannonicalizationmethod_x *cannonicalizationmethod) +{ + if (cannonicalizationmethod == NULL) + return; + if (cannonicalizationmethod->algorithm) { + free((void *)cannonicalizationmethod->algorithm); + cannonicalizationmethod->algorithm = NULL; + } + free((void*)cannonicalizationmethod); + cannonicalizationmethod = NULL; +} + +static void _ri_free_signaturemethod(signaturemethod_x *signaturemethod) +{ + if (signaturemethod == NULL) + return; + if (signaturemethod->algorithm) { + free((void *)signaturemethod->algorithm); + signaturemethod->algorithm = NULL; + } + free((void*)signaturemethod); + signaturemethod = NULL; +} + +static void _ri_free_digestmethod(digestmethod_x *digestmethod) +{ + if (digestmethod == NULL) + return; + if (digestmethod->algorithm) { + free((void *)digestmethod->algorithm); + digestmethod->algorithm = NULL; + } + free((void*)digestmethod); + digestmethod = NULL; +} + +static void _ri_free_digestvalue(digestvalue_x *digestvalue) +{ + if (digestvalue == NULL) + return; + if (digestvalue->text) { + free((void *)digestvalue->text); + digestvalue->text = NULL; + } + free((void*)digestvalue); + digestvalue = NULL; +} + +static void _ri_free_signaturevalue(signaturevalue_x *signaturevalue) +{ + if (signaturevalue == NULL) + return; + if (signaturevalue->text) { + free((void *)signaturevalue->text); + signaturevalue->text = NULL; + } + free((void*)signaturevalue); + signaturevalue = NULL; +} + +static void _ri_free_x509certificate(x509certificate_x *x509certificate) +{ + if (x509certificate == NULL) + return; + if (x509certificate->text) { + free((void *)x509certificate->text); + x509certificate->text = NULL; + } + free((void*)x509certificate); + x509certificate = NULL; +} + +static void _ri_free_x509data(x509data_x *x509data) +{ + if (x509data == NULL) + return; + if (x509data->x509certificate) { + x509certificate_x *x509certificate = x509data->x509certificate; + x509certificate_x *tmp = NULL; + while(x509certificate != NULL) { + tmp = x509certificate->next; + _ri_free_x509certificate(x509certificate); + x509certificate = tmp; + } + } + free((void*)x509data); + x509data = NULL; +} + +static void _ri_free_keyinfo(keyinfo_x *keyinfo) +{ + if (keyinfo == NULL) + return; + if (keyinfo->x509data) { + x509data_x *x509data = keyinfo->x509data; + x509data_x *tmp = NULL; + while(x509data != NULL) { + tmp = x509data->next; + _ri_free_x509data(x509data); + x509data = tmp; + } + } + free((void*)keyinfo); + keyinfo = NULL; +} + +static void _ri_free_transforms(transforms_x *transforms) +{ + if (transforms == NULL) + return; + if (transforms->transform) { + transform_x *transform = transforms->transform; + transform_x *tmp = NULL; + while(transform != NULL) { + tmp = transform->next; + _ri_free_transform(transform); + transform = tmp; + } + } + free((void*)transforms); + transforms = NULL; +} + +static void _ri_free_reference(reference_x *reference) +{ + if (reference == NULL) + return; + if (reference->digestmethod) { + digestmethod_x *digestmethod = reference->digestmethod; + digestmethod_x *tmp = NULL; + while(digestmethod != NULL) { + tmp = digestmethod->next; + _ri_free_digestmethod(digestmethod); + digestmethod = tmp; + } + } + if (reference->digestvalue) { + digestvalue_x *digestvalue = reference->digestvalue; + digestvalue_x *tmp = NULL; + while(digestvalue != NULL) { + tmp = digestvalue->next; + _ri_free_digestvalue(digestvalue); + digestvalue = tmp; + } + } + if (reference->transforms) { + transforms_x *transforms = reference->transforms; + transforms_x *tmp = NULL; + while(transforms != NULL) { + tmp = transforms->next; + _ri_free_transforms(transforms); + transforms = tmp; + } + } + free((void*)reference); + reference = NULL; +} + +static void _ri_free_signedinfo(signedinfo_x *signedinfo) +{ + if (signedinfo == NULL) + return; + if (signedinfo->cannonicalizationmethod) { + cannonicalizationmethod_x *cannonicalizationmethod = signedinfo->cannonicalizationmethod; + cannonicalizationmethod_x *tmp = NULL; + while(cannonicalizationmethod != NULL) { + tmp = cannonicalizationmethod->next; + _ri_free_cannonicalizationmethod(cannonicalizationmethod); + cannonicalizationmethod = tmp; + } + } + if (signedinfo->signaturemethod) { + signaturemethod_x *signaturemethod = signedinfo->signaturemethod; + signaturemethod_x *tmp = NULL; + while(signaturemethod != NULL) { + tmp = signaturemethod->next; + _ri_free_signaturemethod(signaturemethod); + signaturemethod = tmp; + } + } + if (signedinfo->reference) { + reference_x *reference = signedinfo->reference; + reference_x *tmp = NULL; + while(reference != NULL) { + tmp = reference->next; + _ri_free_reference(reference); + reference = tmp; + } + } + free((void*)signedinfo); + signedinfo = NULL; +} + +void _ri_free_signature_xml(signature_x *sigx) +{ + if (sigx == NULL) + return; + if (sigx->id) { + free((void *)sigx->id); + sigx->id = NULL; + } + if (sigx->xmlns) { + free((void *)sigx->xmlns); + sigx->xmlns = NULL; + } + if (sigx->signedinfo) { + signedinfo_x *signedinfo = sigx->signedinfo; + signedinfo_x *tmp = NULL; + while(signedinfo != NULL) { + tmp = signedinfo->next; + _ri_free_signedinfo(signedinfo); + signedinfo = tmp; + } + } + if (sigx->signaturevalue) { + signaturevalue_x *signaturevalue = sigx->signaturevalue; + signaturevalue_x *tmp = NULL; + while(signaturevalue != NULL) { + tmp = signaturevalue->next; + _ri_free_signaturevalue(signaturevalue); + signaturevalue = tmp; + } + } + if (sigx->keyinfo) { + keyinfo_x *keyinfo = sigx->keyinfo; + keyinfo_x *tmp = NULL; + while(keyinfo != NULL) { + tmp = keyinfo->next; + _ri_free_keyinfo(keyinfo); + keyinfo = tmp; + } + } + /*Object will be freed when it will be parsed in future*/ + free((void*)sigx); + sigx = NULL; +} + +static int _ri_process_digestmethod(xmlTextReaderPtr reader, digestmethod_x *digestmethod) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("Algorithm"))) + digestmethod->algorithm = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("Algorithm"))); + return 0; +} + +static int _ri_process_digestvalue(xmlTextReaderPtr reader, digestvalue_x *digestvalue) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) + digestvalue->text = ASCII(xmlTextReaderValue(reader)); + return 0; +} + +static int _ri_process_transform(xmlTextReaderPtr reader, transform_x *transform) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("Algorithm"))) + transform->algorithm = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("Algorithm"))); + return 0; +} + +static int _ri_process_transforms(xmlTextReaderPtr reader, transforms_x *transforms) +{ + const xmlChar *node = NULL; + int ret = 0; + int depth = 0; + transform_x *tmp1 = NULL; + + depth = xmlTextReaderDepth(reader); + while ((ret = _ri_next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + // _d_msg(DEBUG_ERR, "node is NULL\n"); + return -1; + } + if (strcmp(ASCII(node), "Transform") == 0) { + transform_x *transform = calloc(1, sizeof(transform_x)); + if (transform == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(transforms->transform, transform); + ret = _ri_process_transform(reader, transform); + } else { + // _d_msg(DEBUG_INFO, "Invalid tag %s", ASCII(node)); + return -1; + } + if (ret < 0) + return ret; + } + if (transforms->transform) { + LISTHEAD(transforms->transform, tmp1); + transforms->transform = tmp1; + } + return ret; +} + +static int _ri_process_cannonicalizationmethod(xmlTextReaderPtr reader, cannonicalizationmethod_x *cannonicalizationmethod) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("Algorithm"))) + cannonicalizationmethod->algorithm = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("Algorithm"))); + return 0; +} + +static int _ri_process_signaturemethod(xmlTextReaderPtr reader, signaturemethod_x *signaturemethod) +{ + if (xmlTextReaderGetAttribute(reader, XMLCHAR("Algorithm"))) + signaturemethod->algorithm = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("Algorithm"))); + return 0; +} + +static int _ri_process_reference(xmlTextReaderPtr reader, reference_x *reference) +{ + const xmlChar *node = NULL; + int ret = 0; + int depth = 0; + digestmethod_x *tmp1 = NULL; + digestvalue_x *tmp2 = NULL; + transforms_x *tmp3 = NULL; + + if (xmlTextReaderGetAttribute(reader, XMLCHAR("URI"))) + reference->uri = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("URI"))); + + depth = xmlTextReaderDepth(reader); + while ((ret = _ri_next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + // _d_msg(DEBUG_ERR, "node is NULL\n"); + return -1; + } + if (strcmp(ASCII(node), "DigestMethod") == 0) { + digestmethod_x *digestmethod = calloc(1, sizeof(digestmethod_x)); + if (digestmethod == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(reference->digestmethod, digestmethod); + ret = _ri_process_digestmethod(reader, digestmethod); + } else if (strcmp(ASCII(node), "DigestValue") == 0) { + digestvalue_x *digestvalue = calloc(1, sizeof(digestvalue_x)); + if (digestvalue == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(reference->digestvalue, digestvalue); + ret = _ri_process_digestvalue(reader, digestvalue); + } else if (strcmp(ASCII(node), "Transforms") == 0) { + transforms_x *transforms = calloc(1, sizeof(transforms_x)); + if (transforms == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(reference->transforms, transforms); + ret = _ri_process_transforms(reader, transforms); + } else { + // _d_msg(DEBUG_INFO, "Invalid tag %s", ASCII(node)); + return -1; + } + if (ret < 0) + return ret; + } + if (reference->digestmethod) { + LISTHEAD(reference->digestmethod, tmp1); + reference->digestmethod = tmp1; + } + if (reference->digestvalue) { + LISTHEAD(reference->digestvalue, tmp2); + reference->digestvalue = tmp2; + } + if (reference->transforms) { + LISTHEAD(reference->transforms, tmp3); + reference->transforms = tmp3; + } + return ret; +} + +static int _ri_process_x509certificate(xmlTextReaderPtr reader, x509certificate_x *x509certificate) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) { + x509certificate->text = ASCII(xmlTextReaderValue(reader)); + // _d_msg(DEBUG_INFO, "certlen=%d, x509certificate : %s", strlen(x509certificate->text), x509certificate->text); + } + return 0; +} + +static int _ri_process_x509data(xmlTextReaderPtr reader, x509data_x *x509data) +{ + const xmlChar *node = NULL; + int ret = 0; + int depth = 0; + x509certificate_x *tmp1 = NULL; + + depth = xmlTextReaderDepth(reader); + while ((ret = _ri_next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + // _d_msg(DEBUG_ERR, "node is NULL\n"); + return -1; + } + if (strcmp(ASCII(node), "X509Certificate") == 0) { + x509certificate_x *x509certificate = calloc(1, sizeof(x509certificate_x)); + if (x509certificate == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(x509data->x509certificate, x509certificate); + ret = _ri_process_x509certificate(reader, x509certificate); + } else { + // _d_msg(DEBUG_INFO, "Invalid tag %s", ASCII(node)); + return -1; + } + if (ret < 0) + return ret; + } + if (x509data->x509certificate) { + LISTHEAD(x509data->x509certificate, tmp1); + x509data->x509certificate = tmp1; + } + return ret; +} + +#if 0 +static int _ri_process_object(xmlTextReaderPtr reader, object_x *object) +{ + /*To be parsed later*/ + return 0; +} +#endif + +static int _ri_process_keyinfo(xmlTextReaderPtr reader, keyinfo_x *keyinfo) +{ + const xmlChar *node = NULL; + int ret = 0; + int depth = 0; + x509data_x *tmp1 = NULL; + + depth = xmlTextReaderDepth(reader); + while ((ret = _ri_next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + // _d_msg(DEBUG_ERR, "node is NULL\n"); + return -1; + } + if (strcmp(ASCII(node), "X509Data") == 0) { + x509data_x *x509data = calloc(1, sizeof(x509data_x)); + if (x509data == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(keyinfo->x509data, x509data); + ret = _ri_process_x509data(reader, x509data); + } else { + // _d_msg(DEBUG_INFO, "Invalid tag %s", ASCII(node)); + return -1; + } + if (ret < 0) + return ret; + } + if (keyinfo->x509data) { + LISTHEAD(keyinfo->x509data, tmp1); + keyinfo->x509data = tmp1; + } + return ret; +} + +static int _ri_process_signaturevalue(xmlTextReaderPtr reader, signaturevalue_x *signaturevalue) +{ + xmlTextReaderRead(reader); + if (xmlTextReaderValue(reader)) { + signaturevalue->text = ASCII(xmlTextReaderValue(reader)); + // _d_msg(DEBUG_INFO, "siglen=%d SignatureValue %s", strlen(signaturevalue->text), signaturevalue->text); + } + return 0; +} + +static int _ri_process_signedinfo(xmlTextReaderPtr reader, signedinfo_x *signedinfo) +{ + const xmlChar *node = NULL; + int ret = 0; + int depth = 0; + cannonicalizationmethod_x *tmp1 = NULL; + signaturemethod_x *tmp2 = NULL; + reference_x *tmp3 = NULL; + + depth = xmlTextReaderDepth(reader); + while ((ret = _ri_next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + // _d_msg(DEBUG_ERR, "node is NULL\n"); + return -1; + } + if (strcmp(ASCII(node), "CanonicalizationMethod") == 0) { + cannonicalizationmethod_x *cannonicalizationmethod = calloc(1, sizeof(cannonicalizationmethod_x)); + if (cannonicalizationmethod == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(signedinfo->cannonicalizationmethod, cannonicalizationmethod); + ret = _ri_process_cannonicalizationmethod(reader, cannonicalizationmethod); + } else if (strcmp(ASCII(node), "SignatureMethod") == 0) { + signaturemethod_x *signaturemethod = calloc(1, sizeof(signaturemethod_x)); + if (signaturemethod == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(signedinfo->signaturemethod, signaturemethod); + ret = _ri_process_signaturemethod(reader, signaturemethod); + } else if (strcmp(ASCII(node), "Reference") == 0) { + reference_x *reference = calloc(1, sizeof(reference_x)); + if (reference == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(signedinfo->reference, reference); + ret = _ri_process_reference(reader, reference); + } else { + // _d_msg(DEBUG_INFO, "Invalid tag %s", ASCII(node)); + return -1; + } + if (ret < 0) + return ret; + } + if (signedinfo->cannonicalizationmethod) { + LISTHEAD(signedinfo->cannonicalizationmethod, tmp1); + signedinfo->cannonicalizationmethod = tmp1; + } + if (signedinfo->signaturemethod) { + LISTHEAD(signedinfo->signaturemethod, tmp2); + signedinfo->signaturemethod = tmp2; + } + if (signedinfo->reference) { + LISTHEAD(signedinfo->reference, tmp3); + signedinfo->reference = tmp3; + } + return ret; +} + +static int _ri_process_sign(xmlTextReaderPtr reader, signature_x *sigx) +{ + const xmlChar *node = NULL; + int ret = 0; + int depth = 0; + signedinfo_x *tmp1 = NULL; + signaturevalue_x *tmp2 = NULL; + keyinfo_x *tmp3 = NULL; + object_x *tmp4 = NULL; + + depth = xmlTextReaderDepth(reader); + while ((ret = _ri_next_child_element(reader, depth))) { + node = xmlTextReaderConstName(reader); + if (!node) { + // _d_msg(DEBUG_ERR, "node is NULL\n"); + return -1; + } + if (strcmp(ASCII(node), "SignedInfo") == 0) { + signedinfo_x *signedinfo = calloc(1, sizeof(signedinfo_x)); + if (signedinfo == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(sigx->signedinfo, signedinfo); + ret = _ri_process_signedinfo(reader, signedinfo); + } else if (strcmp(ASCII(node), "SignatureValue") == 0) { + signaturevalue_x *signaturevalue = calloc(1, sizeof(signaturevalue_x)); + if (signaturevalue == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(sigx->signaturevalue, signaturevalue); + ret = _ri_process_signaturevalue(reader, signaturevalue); + } else if (strcmp(ASCII(node), "KeyInfo") == 0) { + keyinfo_x *keyinfo = calloc(1, sizeof(keyinfo_x)); + if (keyinfo == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(sigx->keyinfo, keyinfo); + ret = _ri_process_keyinfo(reader, keyinfo); + } else if (strcmp(ASCII(node), "Object") == 0) { + /* + object_x *object = calloc(1, sizeof(object_x)); + if (object == NULL) { + // _d_msg(DEBUG_ERR, "Calloc Failed\n"); + return -1; + } + LISTADD(sigx->object, object); + ret = _ri_process_object(reader, object); + */ + continue; + } else { + // _d_msg(DEBUG_INFO, "Invalid tag %s", ASCII(node)); + return -1; + } + if (ret < 0) + return ret; + } + if (sigx->signedinfo) { + LISTHEAD(sigx->signedinfo, tmp1); + sigx->signedinfo = tmp1; + } + if (sigx->signaturevalue) { + LISTHEAD(sigx->signaturevalue, tmp2); + sigx->signaturevalue = tmp2; + } + if (sigx->keyinfo) { + LISTHEAD(sigx->keyinfo, tmp3); + sigx->keyinfo = tmp3; + } + if (sigx->object) { + LISTHEAD(sigx->object, tmp4); + sigx->object = tmp4; + } + return ret; +} + +static int _ri_process_signature(xmlTextReaderPtr reader, signature_x *sigx) +{ + const xmlChar *node = NULL; + int ret = -1; + + if ((ret = _ri_next_child_element(reader, -1))) { + node = xmlTextReaderConstName(reader); + if (!node) { + // _d_msg(DEBUG_ERR, "Node is null"); + return -1; + } + if (!strcmp(ASCII(node), "Signature")) { + if (xmlTextReaderGetAttribute(reader, XMLCHAR("Id"))) + sigx->id = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("Id"))); + if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns"))) + sigx->xmlns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns"))); + ret = _ri_process_sign(reader, sigx); + } else { + // _d_msg(DEBUG_ERR, "No Signature element found\n"); + return -1; + } + } + return ret; +} + +signature_x *_ri_process_signature_xml(const char *signature_file) +{ + xmlTextReaderPtr reader; + signature_x *sigx = NULL; + + reader = xmlReaderForFile(signature_file, NULL, 0); + + if (reader) { + sigx = calloc(1, sizeof(signature_x)); + if (sigx) { + if (_ri_process_signature(reader, sigx) < 0) { + /* error in parsing. Let's display some hint where we failed */ + // _d_msg(DEBUG_ERR, "Syntax error in processing signature in the above line\n"); + _ri_free_signature_xml(sigx); + xmlFreeTextReader(reader); + return NULL; + } + } else { + // _d_msg(DEBUG_ERR, "Calloc failed\n"); + } + xmlFreeTextReader(reader); + } else { + // _d_msg(DEBUG_ERR, "Unable to create xml reader\n"); + } + return sigx; +} diff --git a/parser/pkgmgr_parser_signature.h b/parser/pkgmgr_parser_signature.h new file mode 100644 index 0000000..d1d8449 --- /dev/null +++ b/parser/pkgmgr_parser_signature.h @@ -0,0 +1,130 @@ +/* + * rpm-installer + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jayoun Lee , Sewook Park , + * Jaeho Lee , Shobhit Srivastava + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __PKGMGR_PARSER_SIGNATURE_H_ +#define __PKGMGR_PARSER_SIGNATURE_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct transform_x { + const char *algorithm; + struct transform_x *prev; + struct transform_x *next; +} transform_x; + +typedef struct digestmethod_x { + const char *algorithm; + struct digestmethod_x *prev; + struct digestmethod_x *next; +} digestmethod_x; + +typedef struct digestvalue_x { + const char *text; + struct digestvalue_x *prev; + struct digestvalue_x *next; +} digestvalue_x; + +typedef struct transforms_x { + struct transform_x *transform; + struct transforms_x *prev; + struct transforms_x *next; +} transforms_x; + +typedef struct x509certificate_x { + const char *text; + struct x509certificate_x *prev; + struct x509certificate_x *next; +} x509certificate_x; + +typedef struct reference_x { + const char *uri; + struct transforms_x *transforms; + struct digestmethod_x *digestmethod; + struct digestvalue_x *digestvalue; + struct reference_x *prev; + struct reference_x *next; +} reference_x; + +typedef struct cannonicalizationmethod_x { + const char *algorithm; + struct cannonicalizationmethod_x *prev; + struct cannonicalizationmethod_x *next; +} cannonicalizationmethod_x; + +typedef struct signaturemethod_x { + const char *algorithm; + struct signaturemethod_x *prev; + struct signaturemethod_x *next; +} signaturemethod_x; + +typedef struct x509data_x { + x509certificate_x *x509certificate; + struct x509data_x *prev; + struct x509data_x *next; +} x509data_x; + +typedef struct signedinfo_x { + struct cannonicalizationmethod_x *cannonicalizationmethod; + struct signaturemethod_x *signaturemethod; + struct reference_x *reference; + struct signedinfo_x *prev; + struct signedinfo_x *next; +} signedinfo_x; + +typedef struct signaturevalue_x { + const char *text; + struct signaturevalue_x *prev; + struct signaturevalue_x *next; +} signaturevalue_x; + +typedef struct keyinfo_x { + struct x509data_x *x509data; + struct keyinfo_x *prev; + struct keyinfo_x *next; +} keyinfo_x; + +/*This will be parsed later when requirement arises*/ +typedef struct object_x { + const char *id; + struct object_x *prev; + struct object_x *next; +} object_x; + +typedef struct signature_x { /*signature xml*/ + const char *id; /* distributor or author sign*/ + const char *xmlns; /* namespace*/ + struct signedinfo_x *signedinfo; /*signature data*/ + struct signaturevalue_x *signaturevalue; /* signature value*/ + struct keyinfo_x *keyinfo; /*cert info*/ + struct object_x *object; /*other parameters in object tag*/ +} signature_x; + + +signature_x *_ri_process_signature_xml(const char *signature_file); +void _ri_free_signature_xml(signature_x *sigx); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* __PKGMGR_PARSER_SIGNATURE_H_ */ diff --git a/parser_path.conf.in b/parser_path.conf.in index a54cc0a..0b946ca 100755 --- a/parser_path.conf.in +++ b/parser_path.conf.in @@ -2,5 +2,5 @@ # parserlib:directory_path parserlib:/usr/etc/package-manager/parserlib/ -mdparser:/usr/etc/package-manager/parserlib/metadata/ +metadataparser:/usr/etc/package-manager/parserlib/metadata/ categoryparser:/usr/etc/package-manager/parserlib/category/ diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index 08a38e7..c66c23c 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -43,6 +43,11 @@ #include #include +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "PKGMGR_INFO" + #define ASC_CHAR(s) (const char *)s #define XML_CHAR(s) (const xmlChar *)s @@ -1100,6 +1105,11 @@ static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname) info->manifest_info->mainapp_id = strdup(coltxt[i]); else info->manifest_info->mainapp_id = NULL; + } else if (strcmp(colname[i], "storeclient_id") == 0 ){ + if (coltxt[i]) + info->manifest_info->storeclient_id = strdup(coltxt[i]); + else + info->manifest_info->storeclient_id = NULL; } else if (strcmp(colname[i], "root_path") == 0 ){ if (coltxt[i]) info->manifest_info->root_path = strdup(coltxt[i]); @@ -2747,7 +2757,7 @@ API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **d if (ptr->lang) { if (strcmp(ptr->lang, locale) == 0) { *description = (char *)ptr->text; - if (strcasecmp(*description, "(null)") == 0) { + if (strcasecmp(*description, "(NULL)") == 0) { locale = DEFAULT_LOCALE; continue; } else @@ -2778,7 +2788,7 @@ API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **a if (ptr->lang) { if (strcmp(ptr->lang, locale) == 0) { *author_name = (char *)ptr->text; - if (strcasecmp(*author_name, "(null)") == 0) { + if (strcasecmp(*author_name, "(NULL)") == 0) { locale = DEFAULT_LOCALE; continue; } else diff --git a/tag_parser_list.txt.in b/tag_parser_list.txt.in new file mode 100644 index 0000000..df204e2 --- /dev/null +++ b/tag_parser_list.txt.in @@ -0,0 +1,7 @@ +shortcut-list +livebox +account +notifications +privileges +ime +font \ No newline at end of file -- 2.7.4 From ecc697a40fef42663b8e1b04edaa86275aeb3d84 Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Fri, 13 Sep 2013 16:37:27 +0900 Subject: [PATCH 02/16] TC fix : change null to empty str Change-Id: Icd468a89e0138faea9b1baf87dbaf28bfcacb50a Signed-off-by: junsuk77.oh --- packaging/pkgmgr-info.spec | 2 +- parser/pkgmgr_parser.h | 2 ++ parser/pkgmgr_parser_db.c | 2 -- src/pkgmgr-info.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index 9678d10..1aab8c5 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -1,6 +1,6 @@ Name: pkgmgr-info Summary: Packager Manager infomation api for package -Version: 0.0.138 +Version: 0.0.139 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 diff --git a/parser/pkgmgr_parser.h b/parser/pkgmgr_parser.h index 60e6663..6d7dbed 100755 --- a/parser/pkgmgr_parser.h +++ b/parser/pkgmgr_parser.h @@ -53,6 +53,8 @@ extern "C" { #define PKG_STRING_LEN_MAX 1024 +#define PKGMGR_PARSER_EMPTY_STR "" + /** * @brief List definitions. * All lists are doubly-linked, the last element is stored to list pointer, diff --git a/parser/pkgmgr_parser_db.c b/parser/pkgmgr_parser_db.c index a349f5c..3a65f26 100755 --- a/parser/pkgmgr_parser_db.c +++ b/parser/pkgmgr_parser_db.c @@ -43,8 +43,6 @@ #define PKGMGR_CERT_DB_FILE "/opt/dbspace/.pkgmgr_cert.db" #define MAX_QUERY_LEN 4096 -#define PKGMGR_PARSER_EMPTY_STR "" - sqlite3 *pkgmgr_parser_db; sqlite3 *pkgmgr_cert_db; diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index c66c23c..4691148 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -2757,7 +2757,7 @@ API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **d if (ptr->lang) { if (strcmp(ptr->lang, locale) == 0) { *description = (char *)ptr->text; - if (strcasecmp(*description, "(NULL)") == 0) { + if (strcasecmp(*description, PKGMGR_PARSER_EMPTY_STR) == 0) { locale = DEFAULT_LOCALE; continue; } else @@ -2788,7 +2788,7 @@ API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **a if (ptr->lang) { if (strcmp(ptr->lang, locale) == 0) { *author_name = (char *)ptr->text; - if (strcasecmp(*author_name, "(NULL)") == 0) { + if (strcasecmp(*author_name, PKGMGR_PARSER_EMPTY_STR) == 0) { locale = DEFAULT_LOCALE; continue; } else -- 2.7.4 From 43acdc295018e64e9cf1d4b47d147301c1cbca66 Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Mon, 30 Sep 2013 15:08:49 +0900 Subject: [PATCH 03/16] add git license file Change-Id: I85d4e8f1784a7a5cb14cf444dfffe29c017c7e98 Signed-off-by: junsuk77.oh --- packaging/pkgmgr-info.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index 1aab8c5..13e6f45 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -56,6 +56,9 @@ make %{?jobs:-j%jobs} %install %make_install +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} + %post mkdir -p /opt/usr/apps/tmp @@ -76,6 +79,7 @@ chsmack -a '_' /usr/etc/package-manager %manifest pkgmgr-info.manifest %defattr(-,root,root,-) %{_libdir}/libpkgmgr-info.so.* +/usr/share/license/%{name} %files devel %defattr(-,root,root,-) -- 2.7.4 From 08abc13a28a08d3775303932fedaba2b404c1c0d Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Mon, 7 Oct 2013 10:01:51 +0900 Subject: [PATCH 04/16] Sync to the latest code Change-Id: I26b62800f242721e18c7ff21881e64dc7af42d09 Signed-off-by: junsuk77.oh --- include/pkgmgr-info-debug.h | 10 +- packaging/pkgmgr-info.spec | 2 +- parser/pkgmgr_parser_db.c | 10 +- src/pkgmgr-info.c | 305 ++++++++++++++------------------------------ 4 files changed, 112 insertions(+), 215 deletions(-) diff --git a/include/pkgmgr-info-debug.h b/include/pkgmgr-info-debug.h index 061fc50..8bd898c 100644 --- a/include/pkgmgr-info-debug.h +++ b/include/pkgmgr-info-debug.h @@ -29,10 +29,6 @@ #define PKGMGR_INFO_ENABLE_DLOG -#define COLOR_RED "\033[0;31m" -#define COLOR_BLUE "\033[0;34m" -#define COLOR_END "\033[0;m" - #ifdef PKGMGR_INFO_ENABLE_DLOG #define PKGMGR_INFO_DEBUG(fmt, ...)\ do\ @@ -43,19 +39,19 @@ #define PKGMGR_INFO_DEBUG_ERR(fmt, ...)\ do\ {\ - LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__);\ + LOGE(fmt, ##__VA_ARGS__);\ }while (0) #define PKGMGR_INFO_BEGIN() \ do\ {\ - LOGD(COLOR_BLUE"BEGIN >>>>"COLOR_END);\ + LOGD("BEGIN >>>>");\ } while( 0 ) #define PKGMGR_INFO_END() \ do\ {\ - LOGD(COLOR_BLUE"END <<<<"COLOR_END);\ + LOGD("END <<<<");\ } \ while( 0 ) diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index 13e6f45..d273352 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -1,6 +1,6 @@ Name: pkgmgr-info Summary: Packager Manager infomation api for package -Version: 0.0.139 +Version: 0.0.140 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 diff --git a/parser/pkgmgr_parser_db.c b/parser/pkgmgr_parser_db.c index 3a65f26..0ee30c0 100755 --- a/parser/pkgmgr_parser_db.c +++ b/parser/pkgmgr_parser_db.c @@ -1614,6 +1614,14 @@ static int __insert_manifest_info_in_db(manifest_x *mfx) mfx->package = strdup(mfx->main_package); } else { _LOGE("main package[%s] is not installed\n", root); + if (type) { + free(type); + type = NULL; + } + if (path) { + free(path); + path = NULL; + } return -1; } } @@ -2144,7 +2152,7 @@ API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx) /*Begin transaction*/ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); if (ret != SQLITE_OK) { - _LOGD("Failed to begin transaction\n"); + _LOGD("Failed to begin transaction[%d]\n", ret); ret = -1; goto err; } diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index 4691148..197b148 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -2167,7 +2167,6 @@ err: API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data) { retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n"); - char *error_message = NULL; int ret = PMINFO_R_OK; char query[MAX_QUERY_LEN] = {'\0'}; char *syslocale = NULL; @@ -2178,40 +2177,27 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us description_x *tmp3 = NULL; author_x *tmp4 = NULL; privilege_x *tmp5 = NULL; + sqlite3 *pkginfo_db = NULL; + + /*open db*/ + ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); + retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); + /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - if (syslocale == NULL) { - _LOGE("current locale is NULL\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); + + /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); - if (locale == NULL) { - _LOGE("manifest locale is NULL\n"); - ret = PMINFO_R_EINVAL; - goto err; - } + tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); - ret = __open_manifest_db(); - if (ret == -1) { - _LOGE("Fail to open manifest DB\n"); - ret = PMINFO_R_ERROR; - goto err; - } pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x)); pkgmgr_pkginfo_x *node = NULL; pkgmgr_pkginfo_x *temp_node = NULL; snprintf(query, MAX_QUERY_LEN, "select * from package_info"); - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); - sqlite3_free(error_message); - sqlite3_close(manifest_db); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); LISTHEAD(tmphead, node); @@ -2219,47 +2205,32 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us pkginfo = node; pkginfo->locale = strdup(locale); pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x)); - if (pkginfo->manifest_info->privileges == NULL) { - _LOGE("Failed to allocate memory for privileges info\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info\n"); + /*populate manifest_info from DB*/ snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package); - ret = __exec_pkginfo_query(query, (void *)pkginfo); - if (ret == -1) { - _LOGE("Package Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + memset(query, '\0', MAX_QUERY_LEN); /*populate privilege_info from DB*/ snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package); - ret = __exec_pkginfo_query(query, (void *)pkginfo); - if (ret == -1) { - _LOGE("Package Privilege Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package privilege Info DB Information retrieval failed"); + memset(query, '\0', MAX_QUERY_LEN); snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \ " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale); - ret = __exec_pkginfo_query(query, (void *)pkginfo); - if (ret == -1) { - _LOGE("Package Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + /*Also store the values corresponding to default locales*/ memset(query, '\0', MAX_QUERY_LEN); snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \ " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE); - ret = __exec_pkginfo_query(query, (void *)pkginfo); - if (ret == -1) { - _LOGE("Package Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + if (pkginfo->manifest_info->label) { LISTHEAD(pkginfo->manifest_info->label, tmp1); pkginfo->manifest_info->label = tmp1; @@ -2293,8 +2264,8 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us ret = PMINFO_R_OK; -err: - sqlite3_close(manifest_db); +catch: + sqlite3_close(pkginfo_db); if (syslocale) { free(syslocale); syslocale = NULL; @@ -3656,7 +3627,6 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha char *syslocale = NULL; char *locale = NULL; char *condition = NULL; - char *error_message = NULL; char query[MAX_QUERY_LEN] = {'\0'}; char where[MAX_QUERY_LEN] = {'\0'}; GSList *list; @@ -3669,27 +3639,21 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha pkgmgr_pkginfo_x *node = NULL; pkgmgr_pkginfo_x *tmphead = NULL; pkgmgr_pkginfo_x *pkginfo = NULL; - pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle; - /*Get current locale*/ + sqlite3 *pkginfo_db = NULL; + + /*open db*/ + ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); + retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); + + /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - if (syslocale == NULL) { - _LOGE("current locale is NULL\n"); - return PMINFO_R_ERROR; - } + tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); + + /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); - if (locale == NULL) { - _LOGE("manifest locale is NULL\n"); - free(syslocale); - return PMINFO_R_ERROR; - } + tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); - ret = __open_manifest_db(); - if (ret == -1) { - _LOGE("Fail to open manifest DB\n"); - ret = PMINFO_R_ERROR; - goto err; - } /*Start constructing query*/ snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale); @@ -3713,61 +3677,38 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha query[sizeof(query) - 1] = '\0'; } _LOGE("query = %s\n", query); + tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x)); - if (tmphead == NULL) { - _LOGE("Out of Memory!!!\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(tmphead == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); - sqlite3_free(error_message); - sqlite3_close(manifest_db); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); LISTHEAD(tmphead, node); for(node = node->next ; node ; node = node->next) { pkginfo = node; pkginfo->locale = strdup(locale); pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x)); - if (pkginfo->manifest_info->privileges == NULL) { - _LOGE("Failed to allocate memory for privileges info\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info\n"); /*populate manifest_info from DB*/ snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package); - ret = __exec_pkginfo_query(query, (void *)pkginfo); - if (ret == -1) { - _LOGE("Package Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + memset(query, '\0', MAX_QUERY_LEN); snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \ " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale); - ret = __exec_pkginfo_query(query, (void *)pkginfo); - if (ret == -1) { - _LOGE("Package Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + /*Also store the values corresponding to default locales*/ memset(query, '\0', MAX_QUERY_LEN); snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \ " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE); - ret = __exec_pkginfo_query(query, (void *)pkginfo); - if (ret == -1) { - _LOGE("Package Info DB Information retrieval failed\n"); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + if (pkginfo->manifest_info->label) { LISTHEAD(pkginfo->manifest_info->label, tmp1); pkginfo->manifest_info->label = tmp1; @@ -3800,7 +3741,7 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha } ret = PMINFO_R_OK; -err: +catch: if (locale) { free(locale); locale = NULL; @@ -3809,7 +3750,7 @@ err: free(syslocale); syslocale = NULL; } - sqlite3_close(manifest_db); + sqlite3_close(pkginfo_db); __cleanup_pkginfo(tmphead); return ret; } @@ -5768,7 +5709,6 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha char *syslocale = NULL; char *locale = NULL; char *condition = NULL; - char *error_message = NULL; char query[MAX_QUERY_LEN] = {'\0'}; char where[MAX_QUERY_LEN] = {'\0'}; GSList *list; @@ -5776,25 +5716,20 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha uiapplication_x *ptr1 = NULL; serviceapplication_x *ptr2 = NULL; pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle; - /*Get current locale*/ + sqlite3 *pkginfo_db = NULL; + + /*open db*/ + ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); + retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); + + /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - if (syslocale == NULL) { - _LOGE("current locale is NULL\n"); - return PMINFO_R_ERROR; - } + tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); + + /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); - if (locale == NULL) { - _LOGE("manifest locale is NULL\n"); - free(syslocale); - return PMINFO_R_ERROR; - } + tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); - ret = __open_manifest_db(); - if (ret == -1) { - _LOGE("Fail to open manifest DB\n"); - ret = PMINFO_R_ERROR; - goto err; - } /*Start constructing query*/ snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale); /*Get where clause*/ @@ -5820,46 +5755,25 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha /*To get filtered list*/ pkgmgr_pkginfo_x *info = 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; - } + tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); + info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x)); - if (info->manifest_info == NULL) { - _LOGE("Out of Memory!!!\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); + /*To get detail app info for each member of filtered list*/ pkgmgr_pkginfo_x *filtinfo = NULL; filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x)); - if (filtinfo == NULL) { - _LOGE("Out of Memory!!!\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); + filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x)); - if (filtinfo->manifest_info == NULL) { - _LOGE("Out of Memory!!!\n"); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); + 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; - goto err; - } - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); - sqlite3_free(error_message); - sqlite3_close(manifest_db); - ret = PMINFO_R_ERROR; - goto err; - } + tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); + + ret = __exec_db_query(pkginfo_db, query, __app_list_cb, (void *)info); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + memset(query, '\0', MAX_QUERY_LEN); if (info->manifest_info->uiapplication) { LISTHEAD(info->manifest_info->uiapplication, ptr1); @@ -5874,29 +5788,15 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha { snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'", ptr1->appid, "uiapp"); - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); - sqlite3_free(error_message); - sqlite3_close(manifest_db); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); } for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next) { snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'", ptr2->appid, "svcapp"); - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); - sqlite3_free(error_message); - sqlite3_close(manifest_db); - ret = PMINFO_R_ERROR; - goto err; - } + ret = __exec_db_query(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); } if (filtinfo->manifest_info->uiapplication) { LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1); @@ -5930,7 +5830,7 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha ptr2 = ptr2->next; } ret = PMINFO_R_OK; -err: +catch: if (locale) { free(locale); locale = NULL; @@ -5939,7 +5839,7 @@ err: free(syslocale); syslocale = NULL; } - sqlite3_close(manifest_db); + sqlite3_close(pkginfo_db); if (appinfo) { free(appinfo); appinfo = NULL; @@ -6891,48 +6791,41 @@ API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *labe int ret = -1; char query[MAX_QUERY_LEN] = {'\0'}; char *error_message = NULL; - ret = __open_manifest_db(); + sqlite3 *pkginfo_db = NULL; - if (access(MANIFEST_DB, F_OK) == 0) { - ret = db_util_open(MANIFEST_DB, &manifest_db, - DB_UTIL_REGISTER_HOOK_METHOD); - if (ret != SQLITE_OK) { - _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB); - return PMINFO_R_ERROR; - } - } + /*open db*/ + ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0); + retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*Begin transaction*/ - ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); + ret = sqlite3_exec(pkginfo_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); if (ret != SQLITE_OK) { _LOGE("Failed to begin transaction\n"); - sqlite3_close(manifest_db); + sqlite3_close(pkginfo_db); return PMINFO_R_ERROR; } _LOGD("Transaction Begin\n"); memset(query, '\0', MAX_QUERY_LEN); - snprintf(query, MAX_QUERY_LEN, - "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid); + snprintf(query, MAX_QUERY_LEN, "update package_app_localized_info set app_label='%s' where app_id='%s'", label, appid); - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); + ret = sqlite3_exec(pkginfo_db, query, NULL, NULL, &error_message); + if (ret != SQLITE_OK) { + _LOGE("Don't execute query = %s error message = %s\n", query, error_message); sqlite3_free(error_message); return PMINFO_R_ERROR; } /*Commit transaction*/ - ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL); + ret = sqlite3_exec(pkginfo_db, "COMMIT", NULL, NULL, NULL); if (ret != SQLITE_OK) { _LOGE("Failed to commit transaction. Rollback now\n"); - sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL); - sqlite3_close(manifest_db); + sqlite3_exec(pkginfo_db, "ROLLBACK", NULL, NULL, NULL); + sqlite3_close(pkginfo_db); return PMINFO_R_ERROR; } _LOGD("Transaction Commit and End\n"); - sqlite3_close(manifest_db); + sqlite3_close(pkginfo_db); return PMINFO_R_OK; } -- 2.7.4 From 8411249480aa32c3490790576ef76867d9552b60 Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Tue, 8 Oct 2013 15:26:50 +0900 Subject: [PATCH 05/16] delete license path Change-Id: I5b272bf4ee98b890c9e29aa008670876bcbcd67c Signed-off-by: junsuk77.oh --- packaging/pkgmgr-info.spec | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index d273352..d1b930d 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -56,9 +56,6 @@ make %{?jobs:-j%jobs} %install %make_install -mkdir -p %{buildroot}/usr/share/license -cp LICENSE %{buildroot}/usr/share/license/%{name} - %post mkdir -p /opt/usr/apps/tmp @@ -79,7 +76,6 @@ chsmack -a '_' /usr/etc/package-manager %manifest pkgmgr-info.manifest %defattr(-,root,root,-) %{_libdir}/libpkgmgr-info.so.* -/usr/share/license/%{name} %files devel %defattr(-,root,root,-) -- 2.7.4 From dedec2a1aea5239b79a97da45b8d93fd05777676 Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Thu, 10 Oct 2013 14:40:50 +0900 Subject: [PATCH 06/16] sync with private master Change-Id: Id9c31e2b00f84097d066eb4c2fb3dd35568d59c8 Signed-off-by: junsuk77.oh --- include/pkgmgr-info.h | 37 +++ packaging/pkgmgr-info.spec | 2 +- parser/pkgmgr_parser.c | 22 +- parser/pkgmgr_parser.h | 3 + parser/pkgmgr_parser_db.c | 6 +- src/pkgmgr-info.c | 795 ++++++++++++++++++++++++++++++--------------- 6 files changed, 596 insertions(+), 269 deletions(-) diff --git a/include/pkgmgr-info.h b/include/pkgmgr-info.h index ddc9454..4415643 100755 --- a/include/pkgmgr-info.h +++ b/include/pkgmgr-info.h @@ -823,6 +823,43 @@ static int get_pkg_data_size(const char *pkgid) int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size); /** + * @fn int pkgmgrinfo_pkginfo_get_size_info(pkgmgrinfo_pkginfo_h handle, int *total_size, int *data_size) + * @brief This API gets the size information for given package on the target. + * + * @par This API is for package-manager client application + * @par Sync (or) Async : Synchronous API + * + * @param[in] handle pointer to package info handle + * @param[out] total_size pointer to hold package total size + * @param[out] data_size pointer to hold package data size + * @return 0 if success, error code(<0) if fail + * @retval PMINFO_R_OK success + * @retval PMINFO_R_EINVAL invalid argument + * @retval PMINFO_R_ERROR internal error + * @code +static int get_pkg_data_size(const char *pkgid) +{ + int ret = 0; + int total_size = 0; + int data_size = 0; + pkgmgrinfo_pkginfo_h handle; + ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle); + if (ret != PMINFO_R_OK) + return -1; + ret = pkgmgrinfo_pkginfo_get_size_info(handle, &total_size, &data_size); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return -1; + } + printf("pkg size: total=%d, data=%d\n", total_size, data_size); + pkgmgrinfo_pkginfo_destroy_pkginfo(handle); + return 0; +} + * @endcode + */ +int pkgmgrinfo_pkginfo_get_size_info(pkgmgrinfo_pkginfo_h handle, int *total_size, int *data_size); + +/** * @fn int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon) * @brief This API gets the package icon from the package ID * diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index d1b930d..09f0549 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -1,6 +1,6 @@ Name: pkgmgr-info Summary: Packager Manager infomation api for package -Version: 0.0.140 +Version: 0.0.141 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 diff --git a/parser/pkgmgr_parser.c b/parser/pkgmgr_parser.c index 5a6af7c..3233e36 100755 --- a/parser/pkgmgr_parser.c +++ b/parser/pkgmgr_parser.c @@ -2188,6 +2188,10 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication) free((void *)uiapplication->submode_mainid); uiapplication->submode_mainid = NULL; } + if (uiapplication->installed_storage) { + free((void *)uiapplication->installed_storage); + uiapplication->installed_storage = NULL; + } free((void*)uiapplication); uiapplication = NULL; @@ -4201,8 +4205,13 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx) /*app2ext needs package size for external installation*/ if (xmlTextReaderGetAttribute(reader, XMLCHAR("size"))) mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size"))); - if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location"))) + if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location"))) { mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location"))); + if (mfx->installlocation == NULL) + mfx->installlocation = strdup("internal-only"); + } else { + mfx->installlocation = strdup("internal-only"); + } if (xmlTextReaderGetAttribute(reader, XMLCHAR("type"))) mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type"))); if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path"))) @@ -4535,6 +4544,9 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, A fwrite(buf, 1, strlen(buf), file); + snprintf(buf, BUFMAX, "X-TIZEN-InstalledStorage=%s\n", mfx->installed_storage); + fwrite(buf, 1, strlen(buf), file); + // snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n"); // fwrite(buf, 1, strlen(buf), file); @@ -4913,6 +4925,14 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx) free((void *)mfx->package_size); mfx->package_size = NULL; } + if (mfx->package_total_size) { + free((void *)mfx->package_total_size); + mfx->package_total_size = NULL; + } + if (mfx->package_data_size) { + free((void *)mfx->package_data_size); + mfx->package_data_size = NULL; + } if (mfx->installed_time) { free((void *)mfx->installed_time); mfx->installed_time = NULL; diff --git a/parser/pkgmgr_parser.h b/parser/pkgmgr_parser.h index 6d7dbed..c04918f 100755 --- a/parser/pkgmgr_parser.h +++ b/parser/pkgmgr_parser.h @@ -381,6 +381,7 @@ typedef struct uiapplication_x { const char *preload; const char *submode; const char *submode_mainid; + const char *installed_storage; struct label_x *label; struct icon_x *icon; struct image_x *image; @@ -461,6 +462,8 @@ typedef struct manifest_x { const char *system; /**< package system flag*/ const char *type; /**< package type*/ const char *package_size; /**< package size for external installation*/ + const char *package_total_size; /**< package size for total*/ + const char *package_data_size; /**< package size for data*/ const char *installed_time; /**< installed time after finishing of installation*/ const char *installed_storage; /**< package currently installed storage*/ const char *storeclient_id; /**< id of store client for installed package*/ diff --git a/parser/pkgmgr_parser_db.c b/parser/pkgmgr_parser_db.c index 0ee30c0..db18b85 100755 --- a/parser/pkgmgr_parser_db.c +++ b/parser/pkgmgr_parser_db.c @@ -116,6 +116,7 @@ sqlite3 *pkgmgr_cert_db; "app_preload text DEFAULT 'false', " \ "app_submode text DEFAULT 'false', " \ "app_submode_mainid text, " \ + "app_installed_storage text, " \ "component_type text, " \ "package text not null, " \ "FOREIGN KEY(package) " \ @@ -822,8 +823,8 @@ static int __insert_uiapplication_info(manifest_x *mfx) "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \ "app_multiple, app_autorestart, app_taskmanage, app_enabled, app_hwacceleration, app_screenreader, app_mainapp , app_recentimage, " \ "app_launchcondition, app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, "\ - "app_preload, app_submode, app_submode_mainid, component_type, package) " \ - "values('%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\ + "app_preload, app_submode, app_submode_mainid, app_installed_storage, component_type, package) " \ + "values('%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\ up->appid, "uiapp", up->exec, @@ -847,6 +848,7 @@ static int __insert_uiapplication_info(manifest_x *mfx) mfx->preload, up->submode, __get_str(up->submode_mainid), + mfx->installed_storage, up->component_type, mfx->package); diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index 197b148..99a71d0 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -103,6 +104,7 @@ #define METADATA_FILTER_QUERY_UNION_CLAUSE " UNION "METADATA_FILTER_QUERY_SELECT_CLAUSE #define LANGUAGE_LENGTH 2 +#define LIBAIL_PATH "/usr/lib/libail.so.0" typedef struct _pkgmgr_instcertinfo_x { char *pkgid; @@ -189,6 +191,41 @@ typedef struct _pkgmgrinfo_appcontrol_x { typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname); +typedef int (*pkgmgr_handler)(int req_id, const char *pkg_type, + const char *pkgid, const char *key, + const char *val, const void *pmsg, void *data); + +typedef void pkgmgr_client; +typedef void pkgmgr_info; + +typedef enum { + PM_REQUEST_CSC = 0, + PM_REQUEST_MOVE = 1, + PM_REQUEST_GET_SIZE = 2, + PM_REQUEST_KILL_APP = 3, + PM_REQUEST_CHECK_APP = 4, + PM_REQUEST_MAX +}pkgmgr_request_service_type; + +typedef enum { + PM_GET_TOTAL_SIZE= 0, + PM_GET_DATA_SIZE = 1, + PM_GET_ALL_PKGS = 2, + PM_GET_SIZE_INFO = 3, + PM_GET_TOTAL_AND_DATA = 4, + PM_GET_MAX +}pkgmgr_getsize_type; + +typedef enum { + PC_REQUEST = 0, + PC_LISTENING, + PC_BROADCAST, +}client_type; + +#define PKG_SIZE_INFO_FILE "/tmp/pkgmgr_size_info.txt" +#define MAX_PKG_BUF_LEN 1024 +#define MAX_PKG_INFO_LEN 10 + char *pkgtype = "rpm"; __thread sqlite3 *manifest_db = NULL; __thread sqlite3 *datacontrol_db = NULL; @@ -692,6 +729,11 @@ static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname) info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[i]); else info->manifest_info->uiapplication->submode_mainid = NULL; + } else if (strcmp(colname[i], "app_installed_storage") == 0 ) { + if (coltxt[i]) + info->manifest_info->uiapplication->installed_storage = strdup(coltxt[i]); + else + info->manifest_info->uiapplication->installed_storage = NULL; } else continue; } @@ -1375,6 +1417,11 @@ static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colnam info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[j]); else info->manifest_info->uiapplication->submode_mainid = NULL; + } else if (strcmp(colname[j], "app_installed_storage") == 0 ) { + if (coltxt[j]) + info->manifest_info->uiapplication->installed_storage = strdup(coltxt[j]); + else + info->manifest_info->uiapplication->installed_storage = NULL; } else continue; } @@ -1624,6 +1671,11 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname) info->uiapp_info->submode_mainid = strdup(coltxt[i]); else info->uiapp_info->submode_mainid = NULL; + } else if (strcmp(colname[i], "app_installed_storage") == 0 ) { + if (coltxt[i]) + info->uiapp_info->installed_storage = strdup(coltxt[i]); + else + info->uiapp_info->installed_storage = NULL; } else continue; } @@ -1992,7 +2044,7 @@ static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const /* Exact found */ if (check_result == 1) { - _LOGD("%s find exact locale(%s)\n", appid, locale); +// _LOGD("%s find exact locale(%s)\n", appid, locale); return locale; } @@ -2011,61 +2063,6 @@ static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const return strdup(DEFAULT_LOCALE); } -long long _pkgmgr_calculate_dir_size(char *dirname) -{ - long long total = 0; - long long ret = 0; - int q = 0; /*quotient*/ - int r = 0; /*remainder*/ - DIR *dp = NULL; - struct dirent *ep = NULL; - struct stat fileinfo; - char abs_filename[FILENAME_MAX] = { 0, }; - retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL"); - - dp = opendir(dirname); - if (dp != NULL) { - while ((ep = readdir(dp)) != NULL) { - if (!strcmp(ep->d_name, ".") || - !strcmp(ep->d_name, "..")) { - continue; - } - snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname, - ep->d_name); - if (lstat(abs_filename, &fileinfo) < 0) - perror(abs_filename); - else { - if (S_ISDIR(fileinfo.st_mode)) { - total += fileinfo.st_size; - if (strcmp(ep->d_name, ".") - && strcmp(ep->d_name, "..")) { - ret = _pkgmgr_calculate_dir_size - (abs_filename); - total = total + ret; - } - } else if (S_ISLNK(fileinfo.st_mode)) { - continue; - } else { - /*It is a file. Calculate the actual - size occupied (in terms of 4096 blocks)*/ - q = (fileinfo.st_size / BLOCK_SIZE); - r = (fileinfo.st_size % BLOCK_SIZE); - if (r) { - q = q + 1; - } - total += q * BLOCK_SIZE; - } - } - } - (void)closedir(dp); - } else { - _LOGE("Couldn't open the directory\n"); - return -1; - } - return total; - -} - static int __delete_certinfo(const char *pkgid) { int ret = -1; @@ -2164,6 +2161,184 @@ err: return ret; } + +int __reqeust_get_size(const char *pkgid, int type) +{ + int ret = 0; + int size = 0; + char *errmsg = NULL; + void *pc = NULL; + void *handle = NULL; + FILE *fp = NULL; + pkgmgr_client *(*__pkgmgr_client_new)(client_type ctype) = NULL; + int (*__pkgmgr_client_get_size)(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data) = NULL; + int (*__pkgmgr_client_request_service)(pkgmgr_request_service_type service_type, int service_mode, + pkgmgr_client * pc, const char *pkg_type, const char *pkgid, + const char *custom_info, pkgmgr_handler event_cb, void *data) = NULL; + + retvm_if(pkgid == NULL, PMINFO_R_ERROR, "pkgid is NULL"); + + handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL); + retvm_if(!handle, PMINFO_R_ERROR, "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); + + __pkgmgr_client_request_service = dlsym(handle, "pkgmgr_client_request_service"); + errmsg = dlerror(); + tryvm_if((errmsg != NULL) || (__pkgmgr_client_request_service == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg); + + pc = __pkgmgr_client_new(PC_REQUEST); + tryvm_if(pc == NULL, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed."); + + size = __pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, type, pc, NULL, pkgid, NULL, NULL, NULL); + tryvm_if(size < 0, ret = PMINFO_R_ERROR, "get size failed."); + + ret = size; + +catch: + dlclose(handle); + return ret; +} + +void __get_package_size(const char *size_info, const char *pkgid, int *total_size, int *data_size) +{ + char *p = NULL; + p = strstr(size_info, pkgid); + if (p == NULL) + return; + + p += strlen(pkgid); + if (*p == '=') { + *total_size = atoi(p+1); + + while (*p) + { + if (*p == '/') { + *data_size = atoi(p+1); + break; + } else { + p++; + } + } + } else { + return; + } + + return; +} + +int __get_package_size_info(char **size_info) +{ + int ret = 0; + char *pInfo = NULL; + FILE *fp = NULL; + pInfo = (char *)malloc(MAX_PKG_BUF_LEN * MAX_PKG_INFO_LEN); + memset(pInfo, 0, MAX_PKG_BUF_LEN * MAX_PKG_INFO_LEN); + + fp = fopen(PKG_SIZE_INFO_FILE, "r"); + if (fp != NULL) { + fread(pInfo, 1, MAX_PKG_BUF_LEN * MAX_PKG_INFO_LEN, fp); + fclose(fp); + } + + *size_info = pInfo; + return PMINFO_R_OK; +} + +int __set_package_size_info(manifest_x *manifest, const char* size_info) +{ + int total_size = 0; + int data_size = 0; + int ret = 0; + char total_buf[PKG_TYPE_STRING_LEN_MAX] = {'\0'}; + char data_buf[PKG_TYPE_STRING_LEN_MAX] = {'\0'}; + + __get_package_size(size_info, manifest->package, &total_size, &data_size); + + manifest->package_size = strdup("true"); + + snprintf(total_buf, PKG_TYPE_STRING_LEN_MAX - 1, "%d", total_size); + manifest->package_total_size = strndup(total_buf, PKG_TYPE_STRING_LEN_MAX - 1); + + snprintf(data_buf, PKG_TYPE_STRING_LEN_MAX - 1, "%d", data_size); + manifest->package_data_size = strndup(data_buf, PKG_TYPE_STRING_LEN_MAX - 1); + + return 0; +} + +static int __pkginfo_check_installed_storage(pkgmgr_pkginfo_x *pkginfo) +{ + char buf[MAX_QUERY_LEN] = {'\0'}; + retvm_if(pkginfo->manifest_info->package == NULL, PMINFO_R_OK, "pkgid is NULL\n"); + + if (strcmp(pkginfo->manifest_info->installed_storage,"installed_external") == 0) { + snprintf(buf, MAX_QUERY_LEN - 1, "%s%s", PKG_SD_PATH, pkginfo->manifest_info->package); + if (access(buf, R_OK) != 0) { + _LOGE("can not access [%s]", buf); + return PMINFO_R_OK;//tmep, it will be fixed to :: return PMINFO_R_ERROR; + } + } + + return PMINFO_R_OK; +} + +static int __appinfo_check_installed_storage(pkgmgr_appinfo_x *appinfo) +{ + char buf[MAX_QUERY_LEN] = {'\0'}; + char *pkgid = NULL; + + pkgid = appinfo->package; + if(pkgid == NULL) + pkgid = appinfo->uiapp_info->package; + retvm_if(pkgid == NULL, PMINFO_R_OK, "pkgid is NULL\n"); + + if (strcmp(appinfo->uiapp_info->installed_storage,"installed_external") == 0) { + snprintf(buf, MAX_QUERY_LEN - 1, "%s%s", PKG_SD_PATH, pkgid); + if (access(buf, R_OK) != 0) { + _LOGE("can not access [%s]", buf); + return PMINFO_R_OK;//tmep, it will be fixed to :: return PMINFO_R_ERROR; + } + } + + return PMINFO_R_OK; +} + +static int __update_ail_appinfo(manifest_x * mfx) +{ + int ret = -1; + uiapplication_x *uiapplication = mfx->uiapplication; + void *lib_handle = NULL; + int (*ail_desktop_operation) (const char *appid, const char *property, const char *value, bool broadcast); + char *aop = NULL; + + if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) { + _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH); + goto END; + } + + aop = "ail_desktop_appinfo_modify_str"; + + if ((ail_desktop_operation = + dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) { + _LOGE("can not find symbol \n"); + goto END; + } + + for(; uiapplication; uiapplication=uiapplication->next) { + ret = ail_desktop_operation(uiapplication->appid, "AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR", mfx->installed_storage, FALSE); + if (ret != 0) + _LOGE("Failed to store info in DB\n"); + } + +END: + if (lib_handle) + dlclose(lib_handle); + + return ret; +} + API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data) { retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n"); @@ -2257,6 +2432,11 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us for(node = node->next; node ; node = node->next) { pkginfo = node; + + ret = __pkginfo_check_installed_storage(pkginfo); + if(ret < 0) + continue; + ret = pkg_list_cb( (void *)pkginfo, user_data); if(ret < 0) break; @@ -2379,6 +2559,9 @@ API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h * pkginfo->manifest_info->privileges->privilege = tmp5; } + ret = __pkginfo_check_installed_storage(pkginfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "[%s] is installed external, but is not in mmc", pkgid); + catch: if (ret == PMINFO_R_OK) *handle = (void*)pkginfo; @@ -2470,9 +2653,7 @@ API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *si retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); char *val = NULL; - char *location = NULL; pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; - location = (char *)info->manifest_info->installlocation; val = (char *)info->manifest_info->package_size; if (val) { *size = atoi(val); @@ -2489,159 +2670,85 @@ API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); - char *pkgid = NULL; - char device_path[PKG_STRING_LEN_MAX] = { '\0', }; - long long rw_size = 0; - long long ro_size= 0; - long long tmp_size= 0; - long long total_size= 0; - struct stat fileinfo; int ret = -1; + char *pkgid = NULL; + char *val = NULL; - ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid); - if(ret < 0) - return PMINFO_R_ERROR; - - /* RW area */ - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - rw_size += tmp_size; - } - } - - /* RO area */ - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } - } + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + val = (char *)info->manifest_info->package_size; + if (strcmp(val, "true") == 0) { + *size = atoi(info->manifest_info->package_total_size); + return 0; + } else { + ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid); + retvm_if(ret < 0, PMINFO_R_ERROR, "get pkgid fail"); - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } + *size = __reqeust_get_size(pkgid, PM_GET_TOTAL_SIZE); + return 0; } +} - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } - } +API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size) +{ + retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); + retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } - } + int ret = -1; + char *pkgid = NULL; + char *val = NULL; - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } - } + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + val = (char *)info->manifest_info->package_size; + if (strcmp(val, "true") == 0) { + *size = atoi(info->manifest_info->package_data_size); + return 0; + } else { + ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid); + retvm_if(ret < 0, PMINFO_R_ERROR, "get pkgid fail"); - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid); - if (lstat(device_path, &fileinfo) == 0) { - if (!S_ISLNK(fileinfo.st_mode)) { - tmp_size = _pkgmgr_calculate_dir_size(device_path); - if (tmp_size > 0) - ro_size += tmp_size; - } + *size = __reqeust_get_size(pkgid, PM_GET_DATA_SIZE); + return 0; } - - /* Total size */ - total_size = rw_size + ro_size; - *size = (int)total_size; - - return PMINFO_R_OK; } -API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size) +API int pkgmgrinfo_pkginfo_get_size_info(pkgmgrinfo_pkginfo_h handle, int *total_size, int *data_size) { retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); - retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); + retvm_if(total_size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); + retvm_if(data_size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); - char *pkgid = NULL; - char device_path[PKG_STRING_LEN_MAX] = { '\0', }; - long long total_size= 0; int ret = -1; + int total_tmp = 0; + int data_tmp = 0; + char *val = NULL; + char *pkgid = NULL; + char* package_size_info = NULL; - ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid); - if(ret < 0) - return PMINFO_R_ERROR; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; - snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid); - if (access(device_path, R_OK) == 0) - total_size = _pkgmgr_calculate_dir_size(device_path); - if (total_size < 0) - return PMINFO_R_ERROR; + val = (char *)info->manifest_info->package_size; + if (strcmp(val, "true") == 0) { + *total_size = atoi(info->manifest_info->package_total_size); + *data_size = atoi(info->manifest_info->package_data_size); + return 0; + } else { + ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid); + retvm_if(ret < 0, PMINFO_R_ERROR, "get pkgid fail"); - *size = (int)total_size; + ret = __reqeust_get_size(pkgid, PM_GET_TOTAL_AND_DATA); + retvm_if(ret < 0, PMINFO_R_ERROR, "fail reqeust size info"); - return PMINFO_R_OK; + ret = __get_package_size_info(&package_size_info); + retvm_if(ret != 0 || package_size_info == NULL, PMINFO_R_ERROR, "__get_package_size_info() failed"); + + __get_package_size(package_size_info, pkgid, &total_tmp, &data_tmp); + *total_size = total_tmp; + *data_size = data_tmp; + + free(package_size_info); + return 0; + } + return -1; } API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon) @@ -3399,6 +3506,13 @@ API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle) } free(filter); filter = NULL; + + if (access(PKG_SIZE_INFO_FILE, F_OK) == 0) { + char info_file[PKG_VALUE_STRING_LEN_MAX] = { 0, }; + snprintf(info_file, PKG_VALUE_STRING_LEN_MAX, "%s", PKG_SIZE_INFO_FILE); + remove(info_file); + } + return PMINFO_R_OK; } @@ -3543,35 +3657,31 @@ API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int char *syslocale = NULL; char *locale = NULL; char *condition = NULL; - char *error_message = NULL; char query[MAX_QUERY_LEN] = {'\0'}; char where[MAX_QUERY_LEN] = {'\0'}; GSList *list; int ret = 0; - + pkgmgr_pkginfo_x *node = NULL; + pkgmgr_pkginfo_x *tmphead = NULL; + pkgmgr_pkginfo_x *pkginfo = NULL; pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle; - /*Get current locale*/ + sqlite3 *pkginfo_db = NULL; + int filter_count = 0; + + /*open db*/ + ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); + retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); + + /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - if (syslocale == NULL) { - _LOGE("current locale is NULL\n"); - return PMINFO_R_ERROR; - } - locale = __convert_system_locale_to_manifest_locale(syslocale); - if (locale == NULL) { - _LOGE("manifest locale is NULL\n"); - free(syslocale); - return PMINFO_R_ERROR; - } + tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); - ret = __open_manifest_db(); - if (ret == -1) { - _LOGE("Fail to open manifest DB\n"); - ret = PMINFO_R_ERROR; - goto err; - } + /*get locale on db*/ + locale = __convert_system_locale_to_manifest_locale(syslocale); + tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); /*Start constructing query*/ - snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_PACKAGE, locale); + snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_PACKAGE, locale); /*Get where clause*/ for (list = filter->list; list; list = g_slist_next(list)) { @@ -3594,19 +3704,52 @@ API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int } _LOGE("query = %s\n", query); - /*Execute Query*/ - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); - sqlite3_free(error_message); - sqlite3_close(manifest_db); - ret = PMINFO_R_ERROR; - *count = 0; - goto err; + tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x)); + tryvm_if(tmphead == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); + + ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + + LISTHEAD(tmphead, node); + for(node = node->next ; node ; node = node->next) { + pkginfo = node; + pkginfo->locale = strdup(locale); + pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x)); + tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info\n"); + + /*populate manifest_info from DB*/ + snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package); + ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \ + " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale); + ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + + /*Also store the values corresponding to default locales*/ + memset(query, '\0', MAX_QUERY_LEN); + snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \ + " package='%s' and package_locale='%s'", pkginfo->manifest_info->package, DEFAULT_LOCALE); + ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); } + + LISTHEAD(tmphead, node); + + for(node = node->next ; node ; node = node->next) { + pkginfo = node; + ret = __pkginfo_check_installed_storage(pkginfo); + if(ret < 0) + continue; + filter_count++; + } + + *count = filter_count; ret = PMINFO_R_OK; -err: + +catch: if (locale) { free(locale); locale = NULL; @@ -3615,7 +3758,8 @@ err: free(syslocale); syslocale = NULL; } - sqlite3_close(manifest_db); + sqlite3_close(pkginfo_db); + __cleanup_pkginfo(tmphead); return ret; } @@ -3641,6 +3785,8 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha pkgmgr_pkginfo_x *pkginfo = NULL; pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle; sqlite3 *pkginfo_db = NULL; + const char* package_size_info = NULL; + bool is_setting = false; /*open db*/ ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); @@ -3663,6 +3809,10 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha if (condition) { strncat(where, condition, sizeof(where) - strlen(where) -1); where[sizeof(where) - 1] = '\0'; + + if (strstr(condition, "package_info.package_nodisplay")) + is_setting = true; + free(condition); condition = NULL; } @@ -3684,6 +3834,15 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha ret = __exec_db_query(pkginfo_db, query, __pkg_list_cb, (void *)tmphead); tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + if (is_setting) { + ret = __reqeust_get_size("size_info", PM_GET_SIZE_INFO); + tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "fail reqeust size info"); + + ret = __get_package_size_info(&package_size_info); + tryvm_if(ret != 0 || package_size_info == NULL, ret = PMINFO_R_ERROR, "__get_package_size_info() failed"); + _LOGD("is_setting is true, get package size info success!! "); + } + LISTHEAD(tmphead, node); for(node = node->next ; node ; node = node->next) { pkginfo = node; @@ -3729,12 +3888,20 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5); pkginfo->manifest_info->privileges->privilege = tmp5; } + if (is_setting) { + __set_package_size_info(pkginfo->manifest_info, package_size_info); + } } LISTHEAD(tmphead, node); for(node = node->next ; node ; node = node->next) { pkginfo = node; + + ret = __pkginfo_check_installed_storage(pkginfo); + if(ret < 0) + continue; + ret = pkg_cb( (void *)pkginfo, user_data); if(ret < 0) break; @@ -3750,6 +3917,10 @@ catch: free(syslocale); syslocale = NULL; } + if (package_size_info) { + free(package_size_info); + } + sqlite3_close(pkginfo_db); __cleanup_pkginfo(tmphead); return ret; @@ -3796,6 +3967,10 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ image_x *ptr6 = NULL; sqlite3 *appinfo_db = NULL; + /*check installed storage*/ + ret = __pkginfo_check_installed_storage(info); + retvm_if(ret < 0, PMINFO_R_EINVAL, "[%s] is installed external, but is not in mmc", info->manifest_info->package); + /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); retvm_if(syslocale == NULL, PMINFO_R_EINVAL, "current locale is NULL"); @@ -4161,6 +4336,10 @@ API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, voi appinfo->package = strdup(ptr1->package); appinfo->uiapp_info = ptr1; + ret = __appinfo_check_installed_storage(appinfo); + if(ret < 0) + continue; + ret = app_func((void *)appinfo, user_data); if (ret < 0) break; @@ -4323,6 +4502,11 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v LISTHEAD(appinfo->uiapp_info->image, tmp6); appinfo->uiapp_info->image = tmp6; } + + ret = __appinfo_check_installed_storage(appinfo); + if(ret < 0) + continue; + ret = app_func((void *)appinfo, user_data); if (ret < 0) break; @@ -4509,6 +4693,9 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h * ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo); tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed"); + ret = __appinfo_check_installed_storage(appinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "[%s] is installed external, but is not in mmc", appinfo->package); + switch (appinfo->app_component) { case PMINFO_UI_APP: if (appinfo->uiapp_info->label) { @@ -5625,36 +5812,30 @@ API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int char *syslocale = NULL; char *locale = NULL; char *condition = NULL; - char *error_message = NULL; 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; pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle; - /*Get current locale*/ + sqlite3 *pkginfo_db = NULL; + int filter_count = 0; + + /*open db*/ + ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); + retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); + + /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - if (syslocale == NULL) { - _LOGE("current locale is NULL\n"); - return PMINFO_R_ERROR; - } - locale = __convert_system_locale_to_manifest_locale(syslocale); - if (locale == NULL) { - _LOGE("manifest locale is NULL\n"); - free(syslocale); - return PMINFO_R_ERROR; - } + tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); - ret = __open_manifest_db(); - if (ret == -1) { - _LOGE("Fail to open manifest DB\n"); - ret = PMINFO_R_ERROR; - goto err; - } + /*get locale on db*/ + locale = __convert_system_locale_to_manifest_locale(syslocale); + tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); /*Start constructing query*/ - snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_APP, locale); - + snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, locale); /*Get where clause*/ for (list = filter->list; list; list = g_slist_next(list)) { __get_filter_condition(list->data, &condition); @@ -5674,21 +5855,92 @@ API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int strncat(query, where, sizeof(query) - strlen(query) - 1); query[sizeof(query) - 1] = '\0'; } - _LOGE("query = %s\n", query); + SECURE_LOGD("query = %s\n", query); + /*To get filtered list*/ + 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!!!\n"); - /*Execute Query*/ - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); - sqlite3_free(error_message); - sqlite3_close(manifest_db); - ret = PMINFO_R_ERROR; - *count = 0; - goto err; + info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x)); + tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); + + /*To get detail app info for each member of filtered list*/ + pkgmgr_pkginfo_x *filtinfo = NULL; + filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x)); + tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); + + filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x)); + tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); + + pkgmgr_appinfo_x *appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x)); + tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); + + ret = __exec_db_query(pkginfo_db, query, __app_list_cb, (void *)info); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + + memset(query, '\0', MAX_QUERY_LEN); + if (info->manifest_info->uiapplication) { + LISTHEAD(info->manifest_info->uiapplication, ptr1); + info->manifest_info->uiapplication = ptr1; + } + if (info->manifest_info->serviceapplication) { + LISTHEAD(info->manifest_info->serviceapplication, ptr2); + info->manifest_info->serviceapplication = ptr2; + } + /*Filtered UI Apps*/ + for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next) + { + snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'", + ptr1->appid, "uiapp"); + ret = __exec_db_query(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); } + for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next) + { + snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'", + ptr2->appid, "svcapp"); + ret = __exec_db_query(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo); + tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed"); + } + if (filtinfo->manifest_info->uiapplication) { + LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1); + filtinfo->manifest_info->uiapplication = ptr1; + } + /*If the callback func return < 0 we break and no more call back is called*/ + while(ptr1 != NULL) + { + appinfo->locale = strdup(locale); + appinfo->uiapp_info = ptr1; + appinfo->app_component = PMINFO_UI_APP; + + ret = __appinfo_check_installed_storage(appinfo); + if(ret < 0) { + ptr1 = ptr1->next; + continue; + } + + filter_count++; + + ptr1 = ptr1->next; + } + /*Filtered Service Apps*/ + if (filtinfo->manifest_info->serviceapplication) { + LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2); + filtinfo->manifest_info->serviceapplication = ptr2; + } + /*If the callback func return < 0 we break and no more call back is called*/ + while(ptr2 != NULL) + { + appinfo->locale = strdup(locale); + appinfo->svcapp_info = ptr2; + appinfo->app_component = PMINFO_SVC_APP; + filter_count++; + ptr2 = ptr2->next; + } + *count = filter_count; + ret = PMINFO_R_OK; -err: +catch: if (locale) { free(locale); locale = NULL; @@ -5697,7 +5949,13 @@ err: free(syslocale); syslocale = NULL; } - sqlite3_close(manifest_db); + sqlite3_close(pkginfo_db); + if (appinfo) { + free(appinfo); + appinfo = NULL; + } + __cleanup_pkginfo(info); + __cleanup_pkginfo(filtinfo); return ret; } @@ -5808,6 +6066,13 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha appinfo->locale = strdup(locale); appinfo->uiapp_info = ptr1; appinfo->app_component = PMINFO_UI_APP; + + ret = __appinfo_check_installed_storage(appinfo); + if(ret < 0) { + ptr1 = ptr1->next; + continue; + } + ret = app_cb((void *)appinfo, user_data); if (ret < 0) break; @@ -6661,13 +6926,13 @@ API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle) mfx = (manifest_x *)handle; ret = pkgmgr_parser_update_manifest_info_in_db(mfx); - if (ret == 0) { - _LOGE("Successfully stored info in DB\n"); - return PMINFO_R_OK; - } else { - _LOGE("Failed to store info in DB\n"); - return PMINFO_R_ERROR; - } + retvm_if(ret != 0, PMINFO_R_ERROR, "Failed to store info in DB\n"); + + ret = __update_ail_appinfo(mfx); + retvm_if(ret != 0, PMINFO_R_ERROR, "Failed to store info in DB\n"); + + _LOGE("Successfully stored info in DB\n"); + return PMINFO_R_OK; } API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle) -- 2.7.4 From 8b4bad89fe51011ca3e85c6aeea3cfe3788551a0 Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Fri, 11 Oct 2013 13:34:04 +0900 Subject: [PATCH 07/16] add pkgmgrinfo client apis Change-Id: I097cdda3a53c60e982ecfb2ba6691b423357f9af Signed-off-by: junsuk77.oh --- include/pkgmgr-info.h | 40 ++++++ packaging/pkgmgr-info.spec | 2 +- src/pkgmgr-info.c | 297 +++++++++++++++++++++++---------------------- 3 files changed, 193 insertions(+), 146 deletions(-) diff --git a/include/pkgmgr-info.h b/include/pkgmgr-info.h index 4415643..4e1cb18 100755 --- a/include/pkgmgr-info.h +++ b/include/pkgmgr-info.h @@ -5383,6 +5383,46 @@ static int set_app_guestmode_visibility(const char *appid, bool value) */ int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status); +/** + * @pkgmgrinfo client API +**/ + +/** + * @brief listening status type in pkgmgrinfo. + */ +#define PMINFO_CLIENT_STATUS_ALL 0x00 +#define PMINFO_CLIENT_STATUS_INSTALL 0x01 +#define PMINFO_CLIENT_STATUS_UNINSTALL 0x02 +#define PMINFO_CLIENT_STATUS_UPGRADE 0x04 +#define PMINFO_CLIENT_STATUS_MOVE 0x08 +#define PMINFO_CLIENT_STATUS_CLEAR_DATA 0x10 +#define PMINFO_CLIENT_STATUS_INSTALL_PROGRESS 0x20 + +/** + * @brief type definition. + */ +typedef void pkgmgrinfo_client; +typedef int (*pkgmgrinfo_handler)(int req_id, const char *pkg_type, + const char *pkgid, const char *key, + const char *val, const void *pmsg, void *data); + +typedef enum { + PMINFO_REQUEST = 0, + PMINFO_LISTENING, + PMINFO_BROADCAST, +}pkgmgrinfo_client_type; + +/** + * @brief This APIs provides pkgmgrinfo client listener + */ +pkgmgrinfo_client *pkgmgrinfo_client_new(pkgmgrinfo_client_type ctype); +int pkgmgrinfo_client_set_status_type(pkgmgrinfo_client *pc, int status_type); +int pkgmgrinfo_client_listen_status(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data); +int pkgmgrinfo_client_free(pkgmgrinfo_client *pc); +/** + * @pkgmgrinfo client API end +**/ + /** @} */ #ifdef __cplusplus diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index 09f0549..d18a763 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -1,6 +1,6 @@ Name: pkgmgr-info Summary: Packager Manager infomation api for package -Version: 0.0.141 +Version: 0.0.142 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index 99a71d0..328462b 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -227,12 +227,9 @@ typedef enum { #define MAX_PKG_INFO_LEN 10 char *pkgtype = "rpm"; -__thread sqlite3 *manifest_db = NULL; -__thread sqlite3 *datacontrol_db = NULL; + __thread sqlite3 *cert_db = NULL; -static int __open_manifest_db(); -static int __exec_pkginfo_query(char *query, void *data); static int __exec_certinfo_query(char *query, void *data); static int __exec_certindexinfo_query(char *query, void *data); static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname); @@ -477,34 +474,6 @@ static void __cleanup_appinfo(pkgmgr_appinfo_x *data) return; } -static int __open_manifest_db() -{ - int ret = -1; - if (access(MANIFEST_DB, F_OK) == 0) { - ret = - db_util_open_with_options(MANIFEST_DB, &manifest_db, - SQLITE_OPEN_READONLY, NULL); - retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", MANIFEST_DB); - return 0; - } - _LOGE("Manifest DB does not exists !!\n"); - return -1; -} - -static int __open_datacontrol_db() -{ - int ret = -1; - if (access(DATACONTROL_DB, F_OK) == 0) { - ret = - db_util_open_with_options(DATACONTROL_DB, &datacontrol_db, - SQLITE_OPEN_READONLY, NULL); - retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", DATACONTROL_DB); - return 0; - } - _LOGE("Datacontrol DB does not exists !!\n"); - return -1; -} - static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname) { pkgmgr_pkginfo_x *udata = (pkgmgr_pkginfo_x *)data; @@ -1863,20 +1832,6 @@ static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **col return 0; } -static int __exec_pkginfo_query(char *query, void *data) -{ - char *error_message = NULL; - if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __pkginfo_cb, data, &error_message)) { - _LOGE("Don't execute query = %s error message = %s\n", query, - error_message); - sqlite3_free(error_message); - return -1; - } - sqlite3_free(error_message); - return 0; -} - static int __exec_certinfo_query(char *query, void *data) { char *error_message = NULL; @@ -2355,14 +2310,11 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *us sqlite3 *pkginfo_db = NULL; /*open db*/ - ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0); retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); - - /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); @@ -2485,7 +2437,7 @@ API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h * sqlite3 *pkginfo_db = NULL; /*validate pkgid*/ - ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0); retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*check pkgid exist on db*/ @@ -2496,9 +2448,6 @@ API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h * /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); - - /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); @@ -3106,8 +3055,7 @@ API int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, con info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x)); retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!"); - ret = db_util_open_with_options(CERT_DB, &cert_db, - SQLITE_OPEN_READONLY, NULL); + ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READONLY, NULL); if (ret != SQLITE_OK) { _LOGE("connect db [%s] failed!\n", CERT_DB); ret = PMINFO_R_ERROR; @@ -3203,25 +3151,21 @@ API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const c int exist = -1; char *lpkgid = NULL; char *rpkgid = NULL; + sqlite3 *pkginfo_db = NULL; info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x)); retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!"); - ret = db_util_open_with_options(MANIFEST_DB, &manifest_db, - SQLITE_OPEN_READONLY, NULL); - if (ret != SQLITE_OK) { - _LOGE("connect db [%s] failed!\n", MANIFEST_DB); - ret = PMINFO_R_ERROR; - goto err; - } + ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0); + tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id); if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) { + sqlite3_exec(pkginfo_db, query, __validate_cb, (void *)&exist, &error_message)) { _LOGE("Don't execute query = %s error message = %s\n", query, error_message); ret = PMINFO_R_ERROR; - goto err; + goto catch; } if (exist == 0) { @@ -3229,17 +3173,17 @@ API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const c } else { snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id); if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) { + sqlite3_exec(pkginfo_db, query, __cert_cb, (void *)info, &error_message)) { _LOGE("Don't execute query = %s error message = %s\n", query, error_message); ret = PMINFO_R_ERROR; - goto err; + goto catch; } lpkgid = strdup(info->pkgid); if (lpkgid == NULL) { _LOGE("Out of Memory\n"); ret = PMINFO_R_ERROR; - goto err; + goto catch; } free(info->pkgid); info->pkgid = NULL; @@ -3247,11 +3191,11 @@ API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const c snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id); if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) { + sqlite3_exec(pkginfo_db, query, __validate_cb, (void *)&exist, &error_message)) { _LOGE("Don't execute query = %s error message = %s\n", query, error_message); ret = PMINFO_R_ERROR; - goto err; + goto catch; } if (exist == 0) { @@ -3259,25 +3203,26 @@ API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const c } else { snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id); if (SQLITE_OK != - sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) { + sqlite3_exec(pkginfo_db, query, __cert_cb, (void *)info, &error_message)) { _LOGE("Don't execute query = %s error message = %s\n", query, error_message); ret = PMINFO_R_ERROR; - goto err; + goto catch; } rpkgid = strdup(info->pkgid); if (rpkgid == NULL) { _LOGE("Out of Memory\n"); ret = PMINFO_R_ERROR; - goto err; + goto catch; } free(info->pkgid); info->pkgid = NULL; } ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result); - err: + + catch: sqlite3_free(error_message); - sqlite3_close(manifest_db); + sqlite3_close(pkginfo_db); if (info) { if (info->pkgid) { free(info->pkgid); @@ -3669,14 +3614,11 @@ API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int int filter_count = 0; /*open db*/ - ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0); retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); - - /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); @@ -3789,14 +3731,11 @@ API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h ha bool is_setting = false; /*open db*/ - ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0); retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); - - /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); @@ -3973,9 +3912,6 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - retvm_if(syslocale == NULL, PMINFO_R_EINVAL, "current locale is NULL"); - - /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL"); @@ -4000,7 +3936,7 @@ API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_ appinfo->app_component = PMINFO_ALL_APP; /*open db */ - ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open(MANIFEST_DB, &appinfo_db, 0); tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); appinfo->package = strdup(info->manifest_info->package); @@ -4300,7 +4236,7 @@ API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, voi sqlite3 *appinfo_db = NULL; /*open db*/ - ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open(MANIFEST_DB, &appinfo_db, 0); retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*calloc pkginfo*/ @@ -4393,14 +4329,11 @@ API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, v /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); - - /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); /*open db*/ - ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open(MANIFEST_DB, &appinfo_db, 0); retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*calloc pkginfo*/ @@ -4609,7 +4542,7 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h * sqlite3 *appinfo_db = NULL; /*open db*/ - ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open(MANIFEST_DB, &appinfo_db, 0); retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*check appid exist on db*/ @@ -4620,9 +4553,6 @@ API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h * /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); - - /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); @@ -5823,14 +5753,11 @@ API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int int filter_count = 0; /*open db*/ - ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0); retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); - - /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); @@ -5977,14 +5904,11 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha sqlite3 *pkginfo_db = NULL; /*open db*/ - ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL); + ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0); retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*get system locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL"); - - /*get locale on db*/ locale = __convert_system_locale_to_manifest_locale(syslocale); tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL"); @@ -6183,16 +6107,17 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f uiapplication_x *ptr1 = NULL; serviceapplication_x *ptr2 = NULL; pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle; + sqlite3 *pkginfo_db = NULL; + + /*open db*/ + ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0); + retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*Get current locale*/ syslocale = vconf_get_str(VCONFKEY_LANGSET); - retvm_if(syslocale == NULL, PMINFO_R_ERROR, "current locale is NULL\n"); locale = __convert_system_locale_to_manifest_locale(syslocale); tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n"); - ret = __open_manifest_db(); - tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Fail to open manifest DB\n"); - /*Start constructing query*/ memset(where, '\0', MAX_QUERY_LEN); memset(query, '\0', MAX_QUERY_LEN); @@ -6231,7 +6156,7 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x)); tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n"); - ret = sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message); + ret = sqlite3_exec(pkginfo_db, query, __app_list_cb, (void *)info, &error_message); tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message); memset(query, '\0', MAX_QUERY_LEN); @@ -6249,7 +6174,7 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f { snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'", ptr1->appid, "uiapp"); - ret = sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message); + ret = sqlite3_exec(pkginfo_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message); tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message); memset(query, '\0', MAX_QUERY_LEN); } @@ -6258,7 +6183,7 @@ API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_f { snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'", ptr2->appid, "svcapp"); - ret = sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message); + ret = sqlite3_exec(pkginfo_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message); tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message); memset(query, '\0', MAX_QUERY_LEN); } @@ -6305,7 +6230,7 @@ catch: syslocale = NULL; } sqlite3_free(error_message); - sqlite3_close(manifest_db); + sqlite3_close(pkginfo_db); if (appinfo) { free(appinfo); appinfo = NULL; @@ -6337,8 +6262,7 @@ API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_ int i = 0; /*Open db.*/ - ret = db_util_open_with_options(CERT_DB, &cert_db, - SQLITE_OPEN_READONLY, NULL); + ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READONLY, NULL); if (ret != SQLITE_OK) { _LOGE("connect db [%s] failed!\n", CERT_DB); return PMINFO_R_ERROR; @@ -6473,8 +6397,7 @@ API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h ha info->pkgid = strdup(pkgid); /*Open db.*/ - ret = db_util_open_with_options(CERT_DB, &cert_db, - SQLITE_OPEN_READWRITE, NULL); + ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL); if (ret != SQLITE_OK) { _LOGE("connect db [%s] failed!\n", CERT_DB); ret = PMINFO_R_ERROR; @@ -6667,8 +6590,7 @@ API int pkgmgrinfo_delete_certinfo(const char *pkgid) retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n"); int ret = -1; /*Open db.*/ - ret = db_util_open_with_options(CERT_DB, &cert_db, - SQLITE_OPEN_READWRITE, NULL); + ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL); if (ret != SQLITE_OK) { _LOGE("connect db [%s] failed!\n", CERT_DB); ret = PMINFO_R_ERROR; @@ -6956,22 +6878,16 @@ API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled) retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n"); int ret = -1; char query[MAX_QUERY_LEN] = {'\0'}; - ret = __open_manifest_db(); + sqlite3 *pkginfo_db = NULL; - if (access(MANIFEST_DB, F_OK) == 0) { - ret = db_util_open(MANIFEST_DB, &manifest_db, - DB_UTIL_REGISTER_HOOK_METHOD); - if (ret != SQLITE_OK) { - _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB); - return PMINFO_R_ERROR; - } - } + ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0); + retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); /*Begin transaction*/ - ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); + ret = sqlite3_exec(pkginfo_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL); if (ret != SQLITE_OK) { _LOGE("Failed to begin transaction\n"); - sqlite3_close(manifest_db); + sqlite3_close(pkginfo_db); return PMINFO_R_ERROR; } _LOGD("Transaction Begin\n"); @@ -6982,7 +6898,7 @@ API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled) char *error_message = NULL; if (SQLITE_OK != - sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) { + sqlite3_exec(pkginfo_db, query, NULL, NULL, &error_message)) { _LOGE("Don't execute query = %s error message = %s\n", query, error_message); sqlite3_free(error_message); @@ -6991,15 +6907,15 @@ API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled) sqlite3_free(error_message); /*Commit transaction*/ - ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL); + ret = sqlite3_exec(pkginfo_db, "COMMIT", NULL, NULL, NULL); if (ret != SQLITE_OK) { _LOGE("Failed to commit transaction. Rollback now\n"); - sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL); - sqlite3_close(manifest_db); + sqlite3_exec(pkginfo_db, "ROLLBACK", NULL, NULL, NULL); + sqlite3_close(pkginfo_db); return PMINFO_R_ERROR; } _LOGD("Transaction Commit and End\n"); - sqlite3_close(manifest_db); + sqlite3_close(pkginfo_db); return PMINFO_R_OK; } @@ -7016,16 +6932,16 @@ API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * typ char *error_message = NULL; pkgmgr_datacontrol_x *data = NULL; - ret = __open_datacontrol_db(); - if (ret == -1) { - _LOGE("Fail to open datacontrol DB\n"); - return PMINFO_R_ERROR; - } + sqlite3 *datacontrol_info_db = NULL; + + /*open db*/ + ret = db_util_open(MANIFEST_DB, &datacontrol_info_db, 0); + retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x)); if (data == NULL) { _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n"); - sqlite3_close(datacontrol_db); + sqlite3_close(datacontrol_info_db); return PMINFO_R_ERROR; } @@ -7034,18 +6950,18 @@ API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * typ providerid, type); if (SQLITE_OK != - sqlite3_exec(datacontrol_db, query, __datacontrol_cb, (void *)data, &error_message)) { + sqlite3_exec(datacontrol_info_db, query, __datacontrol_cb, (void *)data, &error_message)) { _LOGE("Don't execute query = %s error message = %s\n", query, error_message); sqlite3_free(error_message); - sqlite3_close(datacontrol_db); + sqlite3_close(datacontrol_info_db); return PMINFO_R_ERROR; } *appid = (char *)data->appid; *access = (char *)data->access; free(data); - sqlite3_close(datacontrol_db); + sqlite3_close(datacontrol_info_db); return PMINFO_R_OK; } @@ -7129,8 +7045,7 @@ API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, val = (char *)info->uiapp_info->guestmode_visibility; if (val ) { ret = - db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db, - SQLITE_OPEN_READWRITE, NULL); + db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db, SQLITE_OPEN_READWRITE, NULL); if (ret != SQLITE_OK) { _LOGE("DB Open Failed\n"); @@ -7163,3 +7078,95 @@ API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, } return PMINFO_R_OK; } + +/* pkgmgrinfo client start*/ +API pkgmgrinfo_client *pkgmgrinfo_client_new(pkgmgrinfo_client_type ctype) +{ + int ret = 0; + char *errmsg = NULL; + void *pc = NULL; + void *handle = NULL; + 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()); + + __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); + + pc = __pkgmgr_client_new(ctype); + tryvm_if(pc == NULL, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed."); + +catch: + dlclose(handle); + return (pkgmgrinfo_client *) pc; +} + +API int pkgmgrinfo_client_set_status_type(pkgmgrinfo_client *pc, int status_type) +{ + int ret = 0; + char *errmsg = NULL; + void *handle = NULL; + int (*__pkgmgr_client_set_status_type)(pkgmgrinfo_client *pc, int status_type) = NULL; + + handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL); + retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror()); + + __pkgmgr_client_set_status_type = dlsym(handle, "pkgmgr_client_set_status_type"); + errmsg = dlerror(); + tryvm_if((errmsg != NULL) || (__pkgmgr_client_set_status_type == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg); + + ret = __pkgmgr_client_set_status_type(pc, status_type); + tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed."); + +catch: + dlclose(handle); + return ret; +} + +API int pkgmgrinfo_client_listen_status(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data) +{ + int ret = 0; + char *errmsg = NULL; + void *handle = NULL; + int (*__pkgmgr_client_listen_status)(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data) = NULL; + + handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL); + retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror()); + + __pkgmgr_client_listen_status = dlsym(handle, "pkgmgr_client_listen_status"); + errmsg = dlerror(); + tryvm_if((errmsg != NULL) || (__pkgmgr_client_listen_status == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg); + + ret = __pkgmgr_client_listen_status(pc, event_cb, data); + tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed."); + +catch: + dlclose(handle); + return ret; +} + +API int pkgmgrinfo_client_free(pkgmgrinfo_client *pc) +{ + int ret = 0; + char *errmsg = NULL; + void *handle = NULL; + int (*__pkgmgr_client_free)(pkgmgrinfo_client *pc) = NULL; + + handle = dlopen("libpkgmgr-client.so.0", RTLD_LAZY | RTLD_GLOBAL); + retvm_if(!handle, PMINFO_R_ERROR, "dlopen() failed. [%s]", dlerror()); + + __pkgmgr_client_free = dlsym(handle, "pkgmgr_client_free"); + errmsg = dlerror(); + tryvm_if((errmsg != NULL) || (__pkgmgr_client_free == NULL), ret = PMINFO_R_ERROR, "dlsym() failed. [%s]", errmsg); + + ret = __pkgmgr_client_free(pc); + tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed."); + +catch: + dlclose(handle); + return ret; +} +/* pkgmgrinfo client end*/ + -- 2.7.4 From d883e54ea77c6542d95225239e7f968a8a386425 Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Fri, 11 Oct 2013 15:13:18 +0900 Subject: [PATCH 08/16] delete secure log Change-Id: I2efc0716709571e97ee2e9581c3c6f2084eee7fc Signed-off-by: junsuk77.oh --- src/pkgmgr-info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index 328462b..71e1802 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -5782,7 +5782,7 @@ API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int strncat(query, where, sizeof(query) - strlen(query) - 1); query[sizeof(query) - 1] = '\0'; } - SECURE_LOGD("query = %s\n", query); +// SECURE_LOGD("query = %s\n", query); /*To get filtered list*/ pkgmgr_pkginfo_x *info = NULL; info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x)); -- 2.7.4 From 84ff0610dac998341a50c933798b63f8055629af Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Fri, 11 Oct 2013 17:41:09 +0900 Subject: [PATCH 09/16] delete close handle Change-Id: I8abb4bb712efa6cd1b60f6d28a66b80efb071cc2 Signed-off-by: junsuk77.oh --- src/pkgmgr-info.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index 71e1802..793d014 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -7099,7 +7099,7 @@ API pkgmgrinfo_client *pkgmgrinfo_client_new(pkgmgrinfo_client_type ctype) tryvm_if(pc == NULL, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed."); catch: - dlclose(handle); +// dlclose(handle); return (pkgmgrinfo_client *) pc; } @@ -7121,7 +7121,7 @@ API int pkgmgrinfo_client_set_status_type(pkgmgrinfo_client *pc, int status_type tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed."); catch: - dlclose(handle); +// dlclose(handle); return ret; } @@ -7143,7 +7143,7 @@ API int pkgmgrinfo_client_listen_status(pkgmgrinfo_client *pc, pkgmgrinfo_handle tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed."); catch: - dlclose(handle); +// dlclose(handle); return ret; } @@ -7165,7 +7165,7 @@ API int pkgmgrinfo_client_free(pkgmgrinfo_client *pc) tryvm_if(ret < 0, ret = PMINFO_R_ERROR, "pkgmgr_client_new failed."); catch: - dlclose(handle); +// dlclose(handle); return ret; } /* pkgmgrinfo client end*/ -- 2.7.4 From 4d16466058fae8afb765194e2afd0f084dd1300e Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Tue, 15 Oct 2013 16:31:08 +0900 Subject: [PATCH 10/16] add license path Change-Id: I18ab9391c0c1b3e18651ccb692eeb3486aa8caa8 Signed-off-by: junsuk77.oh --- LICENSE | 204 +++++++++++++++++++++++++++++++++++++++++++++ packaging/pkgmgr-info.spec | 4 + 2 files changed, 208 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9c13a9b --- /dev/null +++ b/LICENSE @@ -0,0 +1,204 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index d18a763..d23528a 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -56,6 +56,9 @@ make %{?jobs:-j%jobs} %install %make_install +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} + %post mkdir -p /opt/usr/apps/tmp @@ -76,6 +79,7 @@ chsmack -a '_' /usr/etc/package-manager %manifest pkgmgr-info.manifest %defattr(-,root,root,-) %{_libdir}/libpkgmgr-info.so.* +/usr/share/license/%{name} %files devel %defattr(-,root,root,-) -- 2.7.4 From 51675475a03ebc20c27319c8675d84917da3597a Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Tue, 15 Oct 2013 17:07:06 +0900 Subject: [PATCH 11/16] fix datacontrol error Change-Id: I78e78630dce2f65d198bf015a02315a35e34da35 Signed-off-by: junsuk77.oh --- src/pkgmgr-info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index 793d014..c3abbd6 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -6935,7 +6935,7 @@ API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * typ sqlite3 *datacontrol_info_db = NULL; /*open db*/ - ret = db_util_open(MANIFEST_DB, &datacontrol_info_db, 0); + ret = db_util_open(DATACONTROL_DB, &datacontrol_info_db, 0); retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB); data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x)); -- 2.7.4 From 467e83c414065775e6f070c5bbc4a017fc149cdc Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Wed, 16 Oct 2013 16:31:33 +0900 Subject: [PATCH 12/16] sync with private master Change-Id: I50be8685359be1f5c7d4dc02a38af0e7a377874b Signed-off-by: junsuk77.oh --- CMakeLists.txt | 4 ++-- include/pkgmgr-info.h | 2 ++ packaging/pkgmgr-info.spec | 4 +++- src/pkgmgr-info.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e27766..d6d1aab 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,14 +17,14 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src ${CMAKE_ ### Required packages INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0) +pkg_check_modules(pkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -pkg_check_modules(libpkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0) +pkg_check_modules(libpkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1) FOREACH(flag ${libpkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/include/pkgmgr-info.h b/include/pkgmgr-info.h index 4e1cb18..13f3a66 100755 --- a/include/pkgmgr-info.h +++ b/include/pkgmgr-info.h @@ -5419,6 +5419,8 @@ pkgmgrinfo_client *pkgmgrinfo_client_new(pkgmgrinfo_client_type ctype); int pkgmgrinfo_client_set_status_type(pkgmgrinfo_client *pc, int status_type); int pkgmgrinfo_client_listen_status(pkgmgrinfo_client *pc, pkgmgrinfo_handler event_cb, void *data); int pkgmgrinfo_client_free(pkgmgrinfo_client *pc); +int pkgmgrinfo_client_request_enable_external_pkg(char *pkgid); + /** * @pkgmgrinfo client API end **/ diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index d23528a..c7ca35b 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -1,6 +1,6 @@ Name: pkgmgr-info Summary: Packager Manager infomation api for package -Version: 0.0.142 +Version: 0.0.143 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 @@ -11,6 +11,8 @@ BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(db-util) BuildRequires:pkgconfig(libxml-2.0) +BuildRequires: pkgconfig(dbus-1) +BuildRequires: pkgconfig(dbus-glib-1) %description Packager Manager infomation api for packaging diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index c3abbd6..adeb350 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -36,6 +36,9 @@ #include #include +#include +#include + #include "pkgmgr_parser.h" #include "pkgmgr-info-internal.h" #include "pkgmgr-info-debug.h" @@ -106,6 +109,11 @@ #define LANGUAGE_LENGTH 2 #define LIBAIL_PATH "/usr/lib/libail.so.0" +#define SERVICE_NAME "org.tizen.system.deviced" +#define PATH_NAME "/Org/Tizen/System/DeviceD/Mmc" +#define INTERFACE_NAME "org.tizen.system.deviced.Mmc" +#define METHOD_NAME "RequestMountApp2ext" + typedef struct _pkgmgr_instcertinfo_x { char *pkgid; char *cert_info[MAX_CERT_TYPE]; /*certificate data*/ @@ -2294,6 +2302,25 @@ END: return ret; } +static int __get_pkg_location(const char *pkgid) +{ + retvm_if(pkgid == NULL, PMINFO_R_OK, "pkginfo handle is NULL"); + + FILE *fp = NULL; + char pkg_mmc_path[FILENAME_MAX] = { 0, }; + snprintf(pkg_mmc_path, FILENAME_MAX, "%s%s", PKG_SD_PATH, pkgid); + + /*check whether application is in external memory or not */ + fp = fopen(pkg_mmc_path, "r"); + if (fp != NULL) { + fclose(fp); + fp = NULL; + return PMINFO_EXTERNAL_STORAGE; + } + + return PMINFO_INTERNAL_STORAGE; +} + API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data) { retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n"); @@ -7168,5 +7195,34 @@ catch: // dlclose(handle); return ret; } + +API int pkgmgrinfo_client_request_enable_external_pkg(char *pkgid) +{ + int ret = 0; + DBusConnection *bus; + DBusMessage *message; + + retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n"); + + if(__get_pkg_location(pkgid) != PMINFO_EXTERNAL_STORAGE) + return PMINFO_R_OK; + + bus = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); + 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."); + + 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"); + + dbus_connection_flush(bus); + dbus_message_unref(message); + + return PMINFO_R_OK; +} + /* pkgmgrinfo client end*/ -- 2.7.4 From ae696735dea156dab882dcb1034bf365c453c7a4 Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Thu, 17 Oct 2013 17:28:23 +0900 Subject: [PATCH 13/16] deprecated get-size api Change-Id: I312efc975a271a2e0ff40c01b8fc9bdf53d31794 Signed-off-by: junsuk77.oh --- include/pkgmgr-info.h | 9 ++++++--- src/pkgmgr-info.c | 25 ++++--------------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/include/pkgmgr-info.h b/include/pkgmgr-info.h index 13f3a66..6820824 100755 --- a/include/pkgmgr-info.h +++ b/include/pkgmgr-info.h @@ -53,6 +53,9 @@ extern "C" { #endif +#ifndef DEPRECATED +#define DEPRECATED __attribute__ ((__deprecated__)) +#endif /** * @mainpage @@ -785,7 +788,7 @@ static int get_pkg_total_size(const char *pkgid) } * @endcode */ - int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size); + int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size) DEPRECATED; /** * @fn int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size) @@ -820,7 +823,7 @@ static int get_pkg_data_size(const char *pkgid) } * @endcode */ - int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size); + int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size) DEPRECATED; /** * @fn int pkgmgrinfo_pkginfo_get_size_info(pkgmgrinfo_pkginfo_h handle, int *total_size, int *data_size) @@ -857,7 +860,7 @@ static int get_pkg_data_size(const char *pkgid) } * @endcode */ -int pkgmgrinfo_pkginfo_get_size_info(pkgmgrinfo_pkginfo_h handle, int *total_size, int *data_size); +int pkgmgrinfo_pkginfo_get_size_info(pkgmgrinfo_pkginfo_h handle, int *total_size, int *data_size) DEPRECATED; /** * @fn int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon) diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index adeb350..fe2a84c 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -2656,10 +2656,7 @@ API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size *size = atoi(info->manifest_info->package_total_size); return 0; } else { - ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid); - retvm_if(ret < 0, PMINFO_R_ERROR, "get pkgid fail"); - - *size = __reqeust_get_size(pkgid, PM_GET_TOTAL_SIZE); + *size = 0; return 0; } } @@ -2679,10 +2676,7 @@ API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size) *size = atoi(info->manifest_info->package_data_size); return 0; } else { - ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid); - retvm_if(ret < 0, PMINFO_R_ERROR, "get pkgid fail"); - - *size = __reqeust_get_size(pkgid, PM_GET_DATA_SIZE); + *size = 0; return 0; } } @@ -2708,20 +2702,9 @@ API int pkgmgrinfo_pkginfo_get_size_info(pkgmgrinfo_pkginfo_h handle, int *total *data_size = atoi(info->manifest_info->package_data_size); return 0; } else { - ret = pkgmgrinfo_pkginfo_get_pkgid(handle,&pkgid); - retvm_if(ret < 0, PMINFO_R_ERROR, "get pkgid fail"); - - ret = __reqeust_get_size(pkgid, PM_GET_TOTAL_AND_DATA); - retvm_if(ret < 0, PMINFO_R_ERROR, "fail reqeust size info"); + *total_size = 0; + *data_size = 0; - ret = __get_package_size_info(&package_size_info); - retvm_if(ret != 0 || package_size_info == NULL, PMINFO_R_ERROR, "__get_package_size_info() failed"); - - __get_package_size(package_size_info, pkgid, &total_tmp, &data_tmp); - *total_size = total_tmp; - *data_size = data_tmp; - - free(package_size_info); return 0; } return -1; -- 2.7.4 From d4fbc870cb8cb083158b465be8b7a2f26bb5155b Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Mon, 21 Oct 2013 13:55:45 +0900 Subject: [PATCH 14/16] add mdm server check api Change-Id: Ie2cfbe63606543ffa76fcf0eb01f69d8ebb1ea08 Signed-off-by: junsuk77.oh --- include/pkgmgr-info-debug.h | 1 + packaging/pkgmgr-info.spec | 2 +- parser/pkgmgr_parser.c | 33 +++++++++++++++++++++++++-------- parser/pkgmgr_parser.h | 6 ++++++ src/pkgmgr-info.c | 14 +++++++------- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/include/pkgmgr-info-debug.h b/include/pkgmgr-info-debug.h index 8bd898c..4588c82 100644 --- a/include/pkgmgr-info-debug.h +++ b/include/pkgmgr-info-debug.h @@ -26,6 +26,7 @@ #define _LOGE(fmt, arg...) LOGE(fmt, ##arg) #define _LOGD(fmt, arg...) LOGD(fmt, ##arg) +#define _LOGS(fmt, arg...) LOGD(fmt, ##arg) #define PKGMGR_INFO_ENABLE_DLOG diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index c7ca35b..db9f4df 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -1,6 +1,6 @@ Name: pkgmgr-info Summary: Packager Manager infomation api for package -Version: 0.0.143 +Version: 0.0.144 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 diff --git a/parser/pkgmgr_parser.c b/parser/pkgmgr_parser.c index 3233e36..9e94389 100755 --- a/parser/pkgmgr_parser.c +++ b/parser/pkgmgr_parser.c @@ -945,7 +945,7 @@ static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, con } value = xmlTextReaderConstValue(reader); - _LOGD("%d %d %s %d %d", + _LOGS("%d %d %s %d %d", xmlTextReaderDepth(reader), xmlTextReaderNodeType(reader), name, @@ -966,7 +966,7 @@ static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, con } xmlDocPtr docPtr = xmlTextReaderCurrentDoc(reader); - _LOGD("docPtr->URL %s\n", (char *)docPtr->URL); + _LOGS("docPtr->URL %s\n", (char *)docPtr->URL); xmlDocPtr copyDocPtr = xmlCopyDoc(docPtr, 1); if (copyDocPtr == NULL) return -1; @@ -1007,7 +1007,7 @@ static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, con #ifdef __DEBUG__ //#else - _LOGD("node type: %d, name: %s children->name: %s last->name: %s\n" + _LOGS("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", @@ -1310,10 +1310,10 @@ __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const xmlFreeTextReader(reader); if (ret != 0) { - _LOGD("%s : failed to parse", filename); + _LOGS("%s : failed to parse", filename); } } else { - _LOGD("Unable to open %s", filename); + _LOGS("Unable to open %s", filename); } __plugin_process_tag(tagv, action, PLUGIN_POST_PROCESS, pkgid); @@ -2444,10 +2444,10 @@ int __ps_process_tag_parser(manifest_x *mfx, const char *filename, ACTION_TYPE a xmlFreeTextReader(reader); if (ret != 0) { - _LOGD("%s : failed to parse", filename); + _LOGS("%s : failed to parse", filename); } } else { - _LOGD("Unable to open %s", filename); + _LOGS("Unable to open %s", filename); } ret = __parser_send_tag(lib_handle, action, PLUGIN_POST_PROCESS, mfx->package); @@ -4400,7 +4400,7 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, A file = fopen(filepath, "w"); if(file == NULL) { - _LOGD("Can't open %s", filepath); + _LOGS("Can't open %s", filepath); free(buf); free(buftemp); return -1; @@ -4861,6 +4861,17 @@ static int __check_preload_updated(manifest_x * mfx, const char *manifest) return 0; } +static int __ps_check_mdm_policy(manifest_x * mfx, ACTION_TYPE action) +{ + int ret = PMINFO_R_OK; + return ret; +} + +API int pkgmgr_parser_check_mdm_policy_for_uninstallation(const char *manifest) +{ + int ret = PMINFO_R_OK; + return ret; +} API int pkgmgr_parser_create_desktop_file(manifest_x *mfx) { @@ -5163,6 +5174,9 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char _LOGD("Parsing Finished\n"); + ret = __ps_check_mdm_policy(mfx, ACTION_INSTALL); + retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "pkg[%s] violate mdm policy.", mfx->package); + // __streamFile(manifest, ACTION_INSTALL, temp, mfx->package); __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL); __add_preload_info(mfx, manifest); @@ -5298,6 +5312,9 @@ API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, ch _LOGD("Parsing Finished\n"); + ret = __ps_check_mdm_policy(mfx, ACTION_UNINSTALL); + retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "pkg[%s] violate mdm policy.", mfx->package); + // __streamFile(manifest, ACTION_UNINSTALL, temp, mfx->package); __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL); diff --git a/parser/pkgmgr_parser.h b/parser/pkgmgr_parser.h index c04918f..7160ba3 100755 --- a/parser/pkgmgr_parser.h +++ b/parser/pkgmgr_parser.h @@ -490,6 +490,12 @@ typedef struct manifest_x { } manifest_x; /** + * @fn char int pkgmgr_parser_check_mdm_policy_for_uninstallation(manifest_x * mfx) + * @brief This API gets the mdm policy form mdm server + */ +int pkgmgr_parser_check_mdm_policy_for_uninstallation(const char *manifest); + +/** * @fn char *pkgmgr_parser_get_manifest_file(const char *pkgid) * @brief This API gets the manifest file of the package. * diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index fe2a84c..ba680fd 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -5717,18 +5717,18 @@ API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle, if (link) { ptr = (pkgmgrinfo_node_x *)link->data; strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1); - _LOGE("Previous value is %s\n", prev); + _LOGS("Previous value is %s\n", prev); filter->list = g_slist_delete_link(filter->list, link); snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value); strncpy(val, temp, PKG_STRING_LEN_MAX - 1); - _LOGE("New value is %s\n", val); + _LOGS("New value is %s\n", val); node->value = val; filter->list = g_slist_append(filter->list, (gpointer)node); memset(temp, '\0', PKG_STRING_LEN_MAX); } else { snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value); strncpy(val, temp, PKG_STRING_LEN_MAX - 1); - _LOGE("First value is %s\n", val); + _LOGS("First value is %s\n", val); node->value = val; filter->list = g_slist_append(filter->list, (gpointer)node); memset(temp, '\0', PKG_STRING_LEN_MAX); @@ -5787,12 +5787,12 @@ API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int where[sizeof(where) - 1] = '\0'; } } - _LOGE("where = %s\n", where); + _LOGS("where = %s\n", where); if (strlen(where) > 0) { strncat(query, where, sizeof(query) - strlen(query) - 1); query[sizeof(query) - 1] = '\0'; } -// SECURE_LOGD("query = %s\n", query); + _LOGS("query = %s\n", query); /*To get filtered list*/ pkgmgr_pkginfo_x *info = NULL; info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x)); @@ -5938,12 +5938,12 @@ API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h ha where[sizeof(where) - 1] = '\0'; } } - _LOGE("where = %s\n", where); + _LOGS("where = %s\n", where); if (strlen(where) > 0) { strncat(query, where, sizeof(query) - strlen(query) - 1); query[sizeof(query) - 1] = '\0'; } - _LOGE("query = %s\n", query); + _LOGS("query = %s\n", query); /*To get filtered list*/ pkgmgr_pkginfo_x *info = NULL; info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x)); -- 2.7.4 From 8da94e7d26af2f5a180a755da4e6aa1eea3f4df7 Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Tue, 22 Oct 2013 08:57:18 +0900 Subject: [PATCH 15/16] change enabel app2ext to use system server Change-Id: I25610e998259ec9dae631009885f12c05437a2e8 Signed-off-by: junsuk77.oh --- CMakeLists.txt | 4 ++-- packaging/pkgmgr-info.spec | 1 + src/pkgmgr-info.c | 27 +++------------------------ 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6d1aab..d49fb53 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,14 +17,14 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src ${CMAKE_ ### Required packages INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1) +pkg_check_modules(pkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1 deviced) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -pkg_check_modules(libpkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1) +pkg_check_modules(libpkgs REQUIRED glib-2.0 dlog vconf sqlite3 db-util libxml-2.0 dbus-1 dbus-glib-1 deviced) FOREACH(flag ${libpkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index db9f4df..f36ddbb 100755 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -13,6 +13,7 @@ BuildRequires: pkgconfig(db-util) BuildRequires:pkgconfig(libxml-2.0) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dbus-glib-1) +BuildRequires: pkgconfig(deviced) %description Packager Manager infomation api for packaging diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index ba680fd..89c1998 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -46,6 +46,7 @@ #include "pkgmgr_parser_db.h" #include #include +#include #ifdef LOG_TAG #undef LOG_TAG @@ -7181,30 +7182,8 @@ catch: API int pkgmgrinfo_client_request_enable_external_pkg(char *pkgid) { - int ret = 0; - DBusConnection *bus; - DBusMessage *message; - - retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n"); - - if(__get_pkg_location(pkgid) != PMINFO_EXTERNAL_STORAGE) - return PMINFO_R_OK; - - bus = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); - 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."); - - 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"); - - dbus_connection_flush(bus); - dbus_message_unref(message); - - return PMINFO_R_OK; + _LOGD("call system server to enable app2ext"); + return mmc_mount_app2ext(pkgid); } /* pkgmgrinfo client end*/ -- 2.7.4 From 15026d02f7736332b2516d4f62da409a08722d3d Mon Sep 17 00:00:00 2001 From: "junsuk77.oh" Date: Thu, 24 Oct 2013 11:13:36 +0900 Subject: [PATCH 16/16] add a routine to check external pkg Change-Id: I6ed5e19a0327567b9ddf9da6684a2b83c39d9f2d Signed-off-by: junsuk77.oh --- src/pkgmgr-info.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pkgmgr-info.c b/src/pkgmgr-info.c index 89c1998..663275d 100755 --- a/src/pkgmgr-info.c +++ b/src/pkgmgr-info.c @@ -7182,6 +7182,11 @@ catch: API int pkgmgrinfo_client_request_enable_external_pkg(char *pkgid) { + retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n"); + + if(__get_pkg_location(pkgid) != PMINFO_EXTERNAL_STORAGE) + return PMINFO_R_OK; + _LOGD("call system server to enable app2ext"); return mmc_mount_app2ext(pkgid); } -- 2.7.4