#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 SYSCONFDIR "/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_LIST SYSCONFDIR "/package-manager/parserlib/category/category_parser_list.txt"
#define CATEGORY_PARSER_NAME "categoryparser:"
+#define TAG_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/tag_parser_list.txt"
+#define TAG_PARSER_NAME "parserlib:"
+
#define PKG_TAG_LEN_MAX 128
/* operation_type */
ACTION_INSTALL = 0,
ACTION_UPGRADE,
ACTION_UNINSTALL,
+ ACTION_FOTA,
ACTION_MAX
} ACTION_TYPE;
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;
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);
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;
#endif
}
if (!strcmp(appid, pkgid)) {
- DBG("appid is proper\n");
+ _LOGD("appid is proper\n");
*newappid = NULL;
return 0;
}
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;
#endif
}
} else {
- DBG("appid is not proper\n");
+ _LOGD("appid is not proper\n");
*newappid = NULL;
#ifdef _VALIDATE_APPID_
return -1;
char *md_tag = NULL;
if (md_key == NULL) {
- DBG("md_key is NULL\n");
+ _LOGD("md_key is NULL\n");
return NULL;
}
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 };
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;
}
__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;
}
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;
}
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;
}
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;
}
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;
}
fclose(fp);
if (path == NULL) {
- DBGE("no matching backendlib\n");
+ _LOGE("no matching backendlib\n");
return NULL;
}
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;
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)
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)
}
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)
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);
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;
}
}
-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;
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;
}
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;
}
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;
//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;
return 0;
END:
- __mdparser_clear_dir_list(md_list);
+ __metadata_parser_clear_dir_list(md_list);
if (md_tag)
free(md_tag);
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;
}
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;
}
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;
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;
#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",
switch (xmlTextReaderNodeType(reader)) {
case XML_READER_TYPE_END_ELEMENT:
{
- // DBG("XML_READER_TYPE_END_ELEMENT");
+ // _LOGD("XML_READER_TYPE_END_ELEMENT");
break;
}
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;
{
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;
}
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)
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(tag_list, action, PLUGIN_PRE_PROCESS, pkgid);
+ __plugin_process_tag(tagv, action, PLUGIN_PRE_PROCESS, pkgid);
docPtr = xmlReadFile(filename, NULL, 0);
reader = xmlReaderWalker(docPtr);
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(tag_list, action, PLUGIN_POST_PROCESS, pkgid);
+ __plugin_process_tag(tagv, action, PLUGIN_POST_PROCESS, pkgid);
}
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)
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));
}
fp = fopen(CATEGORY_PARSER_LIST, "r");
if (fp == NULL) {
- DBG("no category parser list\n");
+ _LOGD("no category parser list\n");
return -1;
}
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));
} 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));
} else
return -1;
if (ret < 0) {
- DBG("Processing define failed\n");
+ _LOGD("Processing define failed\n");
return ret;
}
}
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;
}
}
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;
}
}
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));
} else
return -1;
if (ret < 0) {
- DBG("Processing privileges failed\n");
+ _LOGD("Processing privileges failed\n");
return ret;
}
}
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));
} else
return -1;
if (ret < 0) {
- DBG("Processing launchconditions failed\n");
+ _LOGD("Processing launchconditions failed\n");
return ret;
}
}
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));
} 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));
} else
return -1;
if (ret < 0) {
- DBG("Processing data-share failed\n");
+ _LOGD("Processing data-share failed\n");
return ret;
}
}
if (!package)
return NULL;
+/* "db/setting/theme" is not exist */
+#if 0
theme = vconf_get_str("db/setting/theme");
if (!theme) {
theme = strdup("default");
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;
}
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);
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 {
}
/*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);
if (tagv[++i] != NULL)
tag = strdup(tagv[i]);
else {
- DBG("tag process success...\n");
+ _LOGD("tag process success...\n");
return;
}
}
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;
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));
} else
return -1;
if (ret < 0) {
- DBG("Processing capability failed\n");
+ _LOGD("Processing capability failed\n");
return ret;
}
}
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));
} else
return -1;
if (ret < 0) {
- DBG("Processing datacontrol failed\n");
+ _LOGD("Processing datacontrol failed\n");
return ret;
}
}
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) {
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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} else
return -1;
if (ret < 0) {
- DBG("Processing uiapplication failed\n");
+ _LOGD("Processing uiapplication failed\n");
return ret;
}
}
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) {
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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} else
return -1;
if (ret < 0) {
- DBG("Processing serviceapplication failed\n");
+ _LOGD("Processing serviceapplication failed\n");
return ret;
}
}
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;
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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
} 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));
return -1;
if (ret < 0) {
- DBG("Processing manifest failed\n");
+ _LOGD("Processing manifest failed\n");
return ret;
}
}
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;
}
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;
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)
ret = __start_process(reader, mfx);
} else {
- DBG("No Manifest element found\n");
+ _LOGD("No Manifest element found\n");
return -1;
}
}
char *locale = NULL;
locale = (char *)calloc(1, 6);
if (!locale) {
- DBGE("Malloc Failed\n");
+ _LOGE("Malloc Failed\n");
return NULL;
}
AIL_UPDATE,
AIL_REMOVE,
AIL_CLEAN,
+ AIL_FOTA,
AIL_MAX
} AIL_TYPE;
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;
}
case 3:
aop = "ail_desktop_clean";
break;
+ case 4:
+ aop = "ail_desktop_fota";
+ break;
default:
goto END;
break;
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;
}
/* 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;
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) {
/* 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;
}
}
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;
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);
}
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);
}
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);
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;
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;
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;
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;
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);
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:
fp = fopen(PRELOAD_PACKAGE_LIST, "r");
if (fp == NULL) {
- DBGE("no preload list\n");
+ _LOGE("no preload list\n");
return -1;
}
{
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;
}
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) {
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;
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;
}
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;
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;
xmlInitParser();
mfx = pkgmgr_parser_process_manifest_xml(manifest);
- DBG("Parsing Finished\n");
- if (mfx == NULL)
- return PMINFO_R_ERROR;
-
- __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
+ retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
+
+ _LOGD("Parsing Finished\n");
+
+// __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);
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);
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)
}
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;
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;
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;
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;
switch (pid) {
case -1:
- DBGE("fork failed\n");
+ _LOGE("fork failed\n");
return -1;
case 0:
/* child */
if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
SCHEMA_FILE, NULL) < 0) {
- DBGE("execl error\n");
+ _LOGE("execl error\n");
}
_exit(100);
if (err < 0) {
if (errno == EINTR)
continue;
- DBGE("waitpid failed\n");
+ _LOGE("waitpid failed\n");
return -1;
}
}
#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
+
sqlite3 *pkgmgr_parser_db;
sqlite3 *pkgmgr_cert_db;
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);
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;
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;
}
}
if (appid == NULL) {
- DBG("app id is NULL\n");
+ _LOGD("app id is NULL\n");
return -1;
}
/*update guest mode visibility*/
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);
}
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;
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;
static void __printfunc(gpointer data, gpointer userdata)
{
- DBG("%s ", (char*)data);
+ _LOGD("%s ", (char*)data);
}
static void __trimfunc(GList* trim_list)
__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)
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) {
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");
}
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");
}
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)
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)
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;
}
"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;
}
"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;
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;
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;
}
}
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;
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);
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);
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);
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);
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;
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;
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;
}
}
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;
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);
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);
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);
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);
"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);
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;
__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)
"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;
+}
+
static int __delete_manifest_info_from_db(manifest_x *mfx)
{
char query[MAX_QUERY_LEN] = { '\0' };
/*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;
}
"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);
"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;
}
"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;
}
return ret;
sp = sp->next;
}
+
+ /* if main package has sub pkg, delete sub pkg data*/
+ __delete_subpkg_from_db(mfx);
+
return 0;
}
ret = __exec_query(query);
if (ret == -1)
- DBG("Package preload_condition update failed\n");
+ _LOGD("Package preload_condition update failed\n");
return ret;
}
/*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;
/*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;
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();
/*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;
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();
/*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;
}
/*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;
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;
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;
--- /dev/null
+/*
+ * rpm-installer
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * 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 <pkgmgr_parser.h>
+#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;
+}