static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata);
static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission);
static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility);
-static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid);
static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
-static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability);
static int __ps_process_license(xmlTextReaderPtr reader, license_x *license);
static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol);
static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
static int __run_parser_prestep(xmlTextReaderPtr reader, ACTION_TYPE action, const char *pkgid);
static void __processNode(xmlTextReaderPtr reader, ACTION_TYPE action, char *const tagv[], const char *pkgid);
static void __streamFile(const char *filename, ACTION_TYPE action, char *const tagv[], const char *pkgid);
-static int __validate_appid(const char *pkgid, const char *appid, char **newappid);
API int __is_admin();
+static void __save_xml_attribute(xmlTextReaderPtr reader, char *attribute, const char **xml_attribute, char *default_value)
+{
+ xmlChar *attrib_val = xmlTextReaderGetAttribute(reader, XMLCHAR(attribute));
+ if (attrib_val) {
+ *xml_attribute = strdup((const char *)attrib_val);
+ xmlFree(attrib_val);
+ } else {
+ if (default_value != NULL) {
+ *xml_attribute = strdup(default_value);
+ }
+ }
+}
+
+static void __save_xml_lang(xmlTextReaderPtr reader, const char **xml_attribute)
+{
+ const xmlChar *attrib_val = xmlTextReaderConstXmlLang(reader);
+ if (attrib_val != NULL)
+ *xml_attribute = strdup(ASCII(attrib_val));
+ else
+ *xml_attribute = strdup(DEFAULT_LOCALE);
+}
+
+static void __save_xml_value(xmlTextReaderPtr reader, const char **xml_attribute)
+{
+ xmlTextReaderRead(reader);
+ const xmlChar *attrib_val = xmlTextReaderConstValue(reader);
+
+ if (attrib_val)
+ *xml_attribute = strdup((const char *)attrib_val);
+}
+
+static void __save_xml_installed_time(manifest_x *mfx)
+{
+ char buf[PKG_STRING_LEN_MAX] = {'\0'};
+ char *val = NULL;
+ time_t current_time;
+ time(¤t_time);
+ snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", (int)current_time);
+ val = strndup(buf, PKG_STRING_LEN_MAX - 1);
+ mfx->installed_time = val;
+}
+
+static void __save_xml_root_path(manifest_x *mfx, uid_t uid)
+{
+ char root[PKG_STRING_LEN_MAX] = { '\0' };
+ const char *path;
+
+ if (mfx->root_path)
+ return;
+
+ tzplatform_set_user(uid);
+ path = tzplatform_getenv((uid == OWNER_ROOT || uid == GLOBAL_USER) ? TZ_SYS_RO_APP : TZ_USER_APP);
+ snprintf(root, PKG_STRING_LEN_MAX - 1, "%s/%s", path, mfx->package);
+
+ mfx->root_path = strdup(root);
+
+ tzplatform_reset_user();
+}
+
+static void __save_xml_default_value(manifest_x * mfx)
+{
+ mfx->preload = strdup("False");
+ mfx->removable = strdup("True");
+ mfx->readonly = strdup("False");
+ mfx->update = strdup("False");
+ mfx->system = strdup("False");
+ mfx->installed_storage= strdup("installed_internal");
+ package = mfx->package;
+}
+
void *__open_lib_handle(char *tag)
{
char *lib_path = NULL;
-static int __validate_appid(const char *pkgid, const char *appid, char **newappid)
-{
- if (!pkgid || !appid || !newappid) {
- _LOGD("Arg supplied is NULL\n");
- return -1;
- }
- int pkglen = strlen(pkgid);
- int applen = strlen(appid);
- char *ptr = NULL;
- char *newapp = NULL;
- int len = 0;
- if (strncmp(appid, ".", 1) == 0) {
- len = pkglen + applen + 1;
- newapp = calloc(1,len);
- if (newapp == NULL) {
- _LOGD("Malloc failed\n");
- return -1;
- }
- strncpy(newapp, pkgid, pkglen);
- strncat(newapp, appid, applen);
- _LOGD("new appid is %s\n", newapp);
- *newappid = newapp;
- return 0;
- }
- if (applen < pkglen) {
- _LOGD("app id is not proper\n");
- *newappid = NULL;
-#ifdef _VALIDATE_APPID_
- return -1;
-#else
- return 0;
-#endif
- }
- if (!strcmp(appid, pkgid)) {
- _LOGD("appid is proper\n");
- *newappid = NULL;
- return 0;
- }
- else if (strncmp(appid, pkgid, pkglen) == 0) {
- ptr = strstr(appid, pkgid);
- ptr = ptr + pkglen;
- if (strncmp(ptr, ".", 1) == 0) {
- _LOGD("appid is proper\n");
- *newappid = NULL;
- return 0;
- }
- else {
- _LOGD("appid is not proper\n");
- *newappid = NULL;
-#ifdef _VALIDATE_APPID_
- return -1;
-#else
- return 0;
-#endif
- }
- } else {
- _LOGD("appid is not proper\n");
- *newappid = NULL;
-#ifdef _VALIDATE_APPID_
- return -1;
-#else
- return 0;
-#endif
- }
- return 0;
-}
-
static char * __get_tag_by_key(char *md_key)
{
char *md_tag = NULL;
{
if (appcontrol == NULL)
return;
- if (appcontrol->text) {
- free((void *)appcontrol->text);
- appcontrol->text = NULL;
- }
/*Free Operation*/
- if (appcontrol->operation) {
- operation_x *operation = appcontrol->operation;
- operation_x *tmp = NULL;
- while(operation != NULL) {
- tmp = operation->next;
- __ps_free_operation(operation);
- operation = tmp;
- }
- }
+ if (appcontrol->operation)
+ free(appcontrol->operation);
/*Free Uri*/
- if (appcontrol->uri) {
- uri_x *uri = appcontrol->uri;
- uri_x *tmp = NULL;
- while(uri != NULL) {
- tmp = uri->next;
- __ps_free_uri(uri);
- uri = tmp;
- }
- }
+ if (appcontrol->uri)
+ free(appcontrol->uri);
/*Free Mime*/
- if (appcontrol->mime) {
- mime_x *mime = appcontrol->mime;
- mime_x *tmp = NULL;
- while(mime != NULL) {
- tmp = mime->next;
- __ps_free_mime(mime);
- mime = tmp;
- }
- }
- /*Free subapp*/
- if (appcontrol->subapp) {
- subapp_x *subapp = appcontrol->subapp;
- subapp_x *tmp = NULL;
- while(subapp != NULL) {
- tmp = subapp->next;
- __ps_free_subapp(subapp);
- subapp = tmp;
- }
- }
+ if (appcontrol->mime)
+ free(appcontrol->mime);
free((void*)appcontrol);
appcontrol = NULL;
}
permission = tmp;
}
}
+ /*Free DataControl*/
+ if (uiapplication->datacontrol) {
+ datacontrol_x *datacontrol = uiapplication->datacontrol;
+ datacontrol_x *tmp = NULL;
+ while(datacontrol != NULL) {
+ tmp = datacontrol->next;
+ __ps_free_datacontrol(datacontrol);
+ datacontrol = tmp;
+ }
+ }
/* _PRODUCT_LAUNCHING_ENHANCED_ START */
if (uiapplication->indicatordisplay) {
free((void *)uiapplication->indicatordisplay);
static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed)
{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- allowed->text = ASCII(xmlTextReaderValue(reader));
+ __save_xml_value(reader, &allowed->text);
return 0;
}
static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- operation->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-/* Text does not exist. Only attribute exists
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- operation->text = ASCII(xmlTextReaderValue(reader));
-*/
+ __save_xml_attribute(reader, "name", &operation->name, NULL);
return 0;
}
static int __ps_process_uri(xmlTextReaderPtr reader, uri_x *uri)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- uri->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-/* Text does not exist. Only attribute exists
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- uri->text = ASCII(xmlTextReaderValue(reader));
-*/
+ __save_xml_attribute(reader, "name", &uri->name, NULL);
return 0;
}
static int __ps_process_mime(xmlTextReaderPtr reader, mime_x *mime)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- mime->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-/* Text does not exist. Only attribute exists
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- mime->text = ASCII(xmlTextReaderValue(reader));
-*/
+ __save_xml_attribute(reader, "name", &mime->name, NULL);
return 0;
}
static int __ps_process_subapp(xmlTextReaderPtr reader, subapp_x *subapp)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- subapp->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
-/* Text does not exist. Only attribute exists
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- mime->text = ASCII(xmlTextReaderValue(reader));
-*/
+ __save_xml_attribute(reader, "name", &subapp->name, NULL);
return 0;
}
static int __ps_process_condition(xmlTextReaderPtr reader, condition_x *condition)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- condition->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- condition->text = ASCII(xmlTextReaderValue(reader));
+ __save_xml_attribute(reader, "name", &condition->name, NULL);
return 0;
}
static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notification)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- notification->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- notification->text = ASCII(xmlTextReaderValue(reader));
+ __save_xml_attribute(reader, "name", ¬ification->name, NULL);
+ __save_xml_value(reader, ¬ification->text);
return 0;
}
static int __ps_process_category(xmlTextReaderPtr reader, category_x *category)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- category->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
+ __save_xml_attribute(reader, "name", &category->name, NULL);
return 0;
}
static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader)) {
- privilege->text = ASCII(xmlTextReaderValue(reader));
- }
+ __save_xml_value(reader, &privilege->text);
return 0;
}
static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
- metadata->key = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("key")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("value")))
- metadata->value = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("value")));
+ __save_xml_attribute(reader, "key", &metadata->key, NULL);
+ __save_xml_attribute(reader, "value", &metadata->value, NULL);
return 0;
}
static int __ps_process_permission(xmlTextReaderPtr reader, permission_x *permission)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
- permission->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
-
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- permission->value = ASCII(xmlTextReaderValue(reader));
+ __save_xml_attribute(reader, "type", &permission->type, NULL);
+ __save_xml_value(reader, &permission->value);
return 0;
}
static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- compatibility->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- compatibility->text = ASCII(xmlTextReaderValue(reader));
- return 0;
-}
-
-static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution)
-{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")))
- resolution->mimetype = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mime-type")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")))
- resolution->urischeme = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("uri-scheme")));
+ __save_xml_attribute(reader, "name", &compatibility->name, NULL);
+ __save_xml_value(reader, &compatibility->text);
return 0;
}
static int __ps_process_request(xmlTextReaderPtr reader, request_x *request)
{
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- request->text = ASCII(xmlTextReaderValue(reader));
+ __save_xml_value(reader, &request->text);
return 0;
}
allowed_x *tmp1 = NULL;
request_x *tmp2 = NULL;
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("path")))
- define->path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("path")));
+ __save_xml_attribute(reader, "path", &define->path, NULL);
depth = xmlTextReaderDepth(reader);
while ((ret = __next_child_element(reader, depth))) {
const xmlChar *node;
int ret = -1;
int depth = -1;
- operation_x *tmp1 = NULL;
- uri_x *tmp2 = NULL;
- mime_x *tmp3 = NULL;
- subapp_x *tmp4 = NULL;
depth = xmlTextReaderDepth(reader);
while ((ret = __next_child_element(reader, depth))) {
}
if (!strcmp(ASCII(node), "operation")) {
- operation_x *operation = malloc(sizeof(operation_x));
- if (operation == NULL) {
- _LOGD("Malloc Failed\n");
- return -1;
- }
- memset(operation, '\0', sizeof(operation_x));
- LISTADD(appcontrol->operation, operation);
- ret = __ps_process_operation(reader, operation);
+ __save_xml_attribute(reader, "name", &appcontrol->operation, NULL);
_LOGD("operation processing\n");
} else if (!strcmp(ASCII(node), "uri")) {
- uri_x *uri= malloc(sizeof(uri_x));
- if (uri == NULL) {
- _LOGD("Malloc Failed\n");
- return -1;
- }
- memset(uri, '\0', sizeof(uri_x));
- LISTADD(appcontrol->uri, uri);
- ret = __ps_process_uri(reader, uri);
+ __save_xml_attribute(reader, "name", &appcontrol->uri, NULL);
_LOGD("uri processing\n");
} else if (!strcmp(ASCII(node), "mime")) {
- mime_x *mime = malloc(sizeof(mime_x));
- if (mime == NULL) {
- _LOGD("Malloc Failed\n");
- return -1;
- }
- memset(mime, '\0', sizeof(mime_x));
- LISTADD(appcontrol->mime, mime);
- ret = __ps_process_mime(reader, mime);
+ __save_xml_attribute(reader, "name", &appcontrol->mime, NULL);
_LOGD("mime processing\n");
- } else if (!strcmp(ASCII(node), "subapp")) {
- subapp_x *subapp = malloc(sizeof(subapp_x));
- if (subapp == NULL) {
- _LOGD("Malloc Failed\n");
- return -1;
- }
- memset(subapp, '\0', sizeof(subapp_x));
- LISTADD(appcontrol->subapp, subapp);
- ret = __ps_process_subapp(reader, subapp);
- _LOGD("subapp processing\n");
} else
return -1;
if (ret < 0) {
return ret;
}
}
- if (appcontrol->operation) {
- LISTHEAD(appcontrol->operation, tmp1);
- appcontrol->operation = tmp1;
- }
- if (appcontrol->uri) {
- LISTHEAD(appcontrol->uri, tmp2);
- appcontrol->uri = tmp2;
- }
- if (appcontrol->mime) {
- LISTHEAD(appcontrol->mime, tmp3);
- appcontrol->mime = tmp3;
- }
- if (appcontrol->subapp) {
- LISTHEAD(appcontrol->subapp, tmp4);
- appcontrol->subapp = tmp4;
- }
-
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- appcontrol->text = ASCII(xmlTextReaderValue(reader));
return ret;
}
launchconditions->condition = tmp1;
}
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- launchconditions->text = ASCII(xmlTextReaderValue(reader));
+ __save_xml_value(reader, &launchconditions->text);
return ret;
}
static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- icon->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- if (xmlTextReaderConstXmlLang(reader)) {
- icon->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
- if (icon->lang == NULL)
- icon->lang = strdup(DEFAULT_LOCALE);
- } else {
- icon->lang = strdup(DEFAULT_LOCALE);
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
- icon->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
- icon->size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")))
- icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
+ __save_xml_attribute(reader, "name", &icon->name, NULL);
+ __save_xml_attribute(reader, "section", &icon->section, NULL);
+ __save_xml_attribute(reader, "size", &icon->size, NULL);
+ __save_xml_attribute(reader, "resolution", &icon->resolution, NULL);
+ __save_xml_lang(reader, &icon->lang);
+
xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader)) {
- const char *text = ASCII(xmlTextReaderValue(reader));
- if(text) {
- icon->text = (const char *)__get_icon_with_path(text, uid);
- free((void *)text);
- }
+ const char *text = ASCII(xmlTextReaderValue(reader));
+ if (text) {
+ icon->text = (const char *)__get_icon_with_path(text, uid);
+ free((void *)text);
}
return 0;
static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- image->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- if (xmlTextReaderConstXmlLang(reader)) {
- image->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
- if (image->lang == NULL)
- image->lang = strdup(DEFAULT_LOCALE);
- } else {
- image->lang = strdup(DEFAULT_LOCALE);
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("section")))
- image->section = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("section")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- image->text = ASCII(xmlTextReaderValue(reader));
-
+ __save_xml_attribute(reader, "name", &image->name, NULL);
+ __save_xml_attribute(reader, "section", &image->section, NULL);
+ __save_xml_lang(reader, &image->lang);
+ __save_xml_value(reader, &image->text);
return 0;
}
static int __ps_process_label(xmlTextReaderPtr reader, label_x *label)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("name")))
- label->name = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
- if (xmlTextReaderConstXmlLang(reader)) {
- label->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
- if (label->lang == NULL)
- label->lang = strdup(DEFAULT_LOCALE);
- } else
- label->lang = strdup(DEFAULT_LOCALE);
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- label->text = ASCII(xmlTextReaderValue(reader));
-
-
-/* _LOGD("lable name %s\n", label->name);
- _LOGD("lable lang %s\n", label->lang);
- _LOGD("lable text %s\n", label->text);
-*/
+ __save_xml_attribute(reader, "name", &label->name, NULL);
+ __save_xml_lang(reader, &label->lang);
+ __save_xml_value(reader, &label->text);
return 0;
}
static int __ps_process_author(xmlTextReaderPtr reader, author_x *author)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("email")))
- author->email = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("email")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("href")))
- author->href = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("href")));
- if (xmlTextReaderConstXmlLang(reader)) {
- author->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
- if (author->lang == NULL)
- author->lang = strdup(DEFAULT_LOCALE);
- } else {
- author->lang = strdup(DEFAULT_LOCALE);
- }
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader)) {
- const char *text = ASCII(xmlTextReaderValue(reader));
- if (*text == '\n') {
- author->text = NULL;
- free((void *)text);
- return 0;
- }
- author->text = ASCII(xmlTextReaderValue(reader));
- }
+ __save_xml_attribute(reader, "email", &author->email, NULL);
+ __save_xml_attribute(reader, "href", &author->href, NULL);
+ __save_xml_lang(reader, &author->lang);
+ __save_xml_value(reader, &author->text);
return 0;
}
static int __ps_process_description(xmlTextReaderPtr reader, description_x *description)
{
- if (xmlTextReaderConstXmlLang(reader)) {
- description->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
- if (description->lang == NULL)
- description->lang = strdup(DEFAULT_LOCALE);
- } else {
- description->lang = strdup(DEFAULT_LOCALE);
- }
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader)) {
- const char *text = ASCII(xmlTextReaderValue(reader));
- if (*text == '\n') {
- description->text = NULL;
- free((void *)text);
- return 0;
- }
- description->text = ASCII(xmlTextReaderValue(reader));
- }
+ __save_xml_lang(reader, &description->lang);
+ __save_xml_value(reader, &description->text);
return 0;
}
static int __ps_process_license(xmlTextReaderPtr reader, license_x *license)
{
- if (xmlTextReaderConstXmlLang(reader)) {
- license->lang = strdup(ASCII(xmlTextReaderConstXmlLang(reader)));
- if (license->lang == NULL)
- license->lang = strdup(DEFAULT_LOCALE);
- } else {
- license->lang = strdup(DEFAULT_LOCALE);
- }
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- license->text = ASCII(xmlTextReaderValue(reader));
+ __save_xml_lang(reader, &license->lang);
+ __save_xml_value(reader, &license->text);
return 0;
}
-static int __ps_process_capability(xmlTextReaderPtr reader, capability_x *capability)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- resolution_x *tmp1 = NULL;
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")))
- capability->operationid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("operation-id")));
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- _LOGD("xmlTextReaderConstName value is NULL\n");
- return -1;
- }
-
- if (!strcmp(ASCII(node), "resolution")) {
- resolution_x *resolution = malloc(sizeof(resolution_x));
- if (resolution == NULL) {
- _LOGD("Malloc Failed\n");
- return -1;
- }
- memset(resolution, '\0', sizeof(resolution_x));
- LISTADD(capability->resolution, resolution);
- ret = __ps_process_resolution(reader, resolution);
- } else
- return -1;
- if (ret < 0) {
- _LOGD("Processing capability failed\n");
- return ret;
- }
- }
-
- if (capability->resolution) {
- LISTHEAD(capability->resolution, tmp1);
- capability->resolution = tmp1;
- }
-
- return ret;
-}
-
static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol)
{
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("providerid")))
- datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("providerid")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("access")))
- datacontrol->access = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("access")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
- datacontrol->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
-
+ __save_xml_attribute(reader, "providerid", &datacontrol->providerid, NULL);
+ __save_xml_attribute(reader, "access", &datacontrol->access, NULL);
+ __save_xml_attribute(reader, "type", &datacontrol->type, NULL);
return 0;
}
const xmlChar *node;
int ret = -1;
int depth = -1;
- char *newappid = NULL;
label_x *tmp1 = NULL;
icon_x *tmp2 = NULL;
appsvc_x *tmp3 = NULL;
metadata_x *tmp9 = NULL;
image_x *tmp10 = NULL;
permission_x *tmp11 = NULL;
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
- uiapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
- if (uiapplication->appid == NULL) {
- _LOGD("appid cant be NULL\n");
- return -1;
- }
- } else {
- _LOGD("appid is mandatory\n");
- return -1;
- }
- /*check appid*/
- ret = __validate_appid(package, uiapplication->appid, &newappid);
- if (ret == -1) {
- _LOGD("appid is not proper\n");
- return -1;
- } else {
- if (newappid) {
- if (uiapplication->appid)
- free((void *)uiapplication->appid);
- uiapplication->appid = newappid;
- }
- uiapplication->package= strdup(package);
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
- uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay"))) {
- uiapplication->nodisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay")));
- if (uiapplication->nodisplay == NULL)
- uiapplication->nodisplay = strdup("false");
- } else {
- uiapplication->nodisplay = strdup("false");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("multiple"))) {
- uiapplication->multiple = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("multiple")));
- if (uiapplication->multiple == NULL)
- uiapplication->multiple = strdup("false");
- } else {
- uiapplication->multiple = strdup("false");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
- uiapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("categories")))
- uiapplication->categories = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("categories")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")))
- uiapplication->extraid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("extraid")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage"))) {
- uiapplication->taskmanage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("taskmanage")));
- if (uiapplication->taskmanage == NULL)
- uiapplication->taskmanage = strdup("true");
- } else {
- uiapplication->taskmanage = strdup("true");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("enabled"))) {
- uiapplication->enabled = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("enabled")));
- if (uiapplication->enabled == NULL)
- uiapplication->enabled = strdup("true");
- } else {
- uiapplication->enabled = strdup("true");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration"))) {
- uiapplication->hwacceleration = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("hw-acceleration")));
- if (uiapplication->hwacceleration == NULL)
- uiapplication->hwacceleration = strdup("use-system-setting");
- } else {
- uiapplication->hwacceleration = strdup("use-system-setting");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader"))) {
- uiapplication->screenreader = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("screen-reader")));
- if (uiapplication->screenreader == NULL)
- uiapplication->screenreader = strdup("use-system-setting");
- } else {
- uiapplication->screenreader = strdup("use-system-setting");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")))
- uiapplication->recentimage = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("recentimage")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp"))) {
- uiapplication->mainapp = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("mainapp")));
- if (uiapplication->mainapp == NULL)
- uiapplication->mainapp = strdup("false");
- } else {
- uiapplication->mainapp = strdup("false");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition"))) {
- uiapplication->launchcondition = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("launchcondition")));
- if (uiapplication->launchcondition == NULL)
- uiapplication->launchcondition = strdup("false");
- } else {
- uiapplication->launchcondition = strdup("false");
- }
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay"))) {
- uiapplication->indicatordisplay = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("indicatordisplay")));
- if (uiapplication->indicatordisplay == NULL)
- uiapplication->indicatordisplay = strdup("true");
- } else {
- uiapplication->indicatordisplay = strdup("true");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")))
- uiapplication->portraitimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("portrait-effectimage")));
- else
- uiapplication->portraitimg = NULL;
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")))
- uiapplication->landscapeimg = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("landscape-effectimage")));
- else
- uiapplication->landscapeimg = NULL;
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility"))) {
- uiapplication->guestmode_visibility = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("guestmode-visibility")));
- if (uiapplication->guestmode_visibility == NULL)
- uiapplication->guestmode_visibility = strdup("true");
- } else {
- uiapplication->guestmode_visibility = strdup("true");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
- uiapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
- if (uiapplication->permission_type == NULL)
- uiapplication->permission_type = strdup("normal");
- } else {
- uiapplication->permission_type = strdup("normal");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("component-type"))) {
- uiapplication->component_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("component-type")));
- if (uiapplication->component_type == NULL)
- uiapplication->component_type = strdup("uiapp");
- } else {
- uiapplication->component_type = strdup("uiapp");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode"))) {
- uiapplication->submode = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode")));
- if (uiapplication->submode == NULL)
- uiapplication->submode = strdup("false");
- } else {
- uiapplication->submode = strdup("false");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")))
- uiapplication->submode_mainid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("submode-mainid")));
+ datacontrol_x *tmp12 = NULL;
+
+ __save_xml_attribute(reader, "appid", &uiapplication->appid, NULL);
+ retvm_if(uiapplication->appid == NULL, PM_PARSER_R_ERROR, "appid cant be NULL, appid field is mandatory\n");
+ __save_xml_attribute(reader, "exec", &uiapplication->exec, NULL);
+ __save_xml_attribute(reader, "nodisplay", &uiapplication->nodisplay, "false");
+ __save_xml_attribute(reader, "multiple", &uiapplication->multiple, "false");
+ __save_xml_attribute(reader, "type", &uiapplication->type, NULL);
+ __save_xml_attribute(reader, "categories", &uiapplication->categories, NULL);
+ __save_xml_attribute(reader, "extraid", &uiapplication->extraid, NULL);
+ __save_xml_attribute(reader, "taskmanage", &uiapplication->taskmanage, "true");
+ __save_xml_attribute(reader, "enabled", &uiapplication->enabled, "true");
+ __save_xml_attribute(reader, "hw-acceleration", &uiapplication->hwacceleration, "default");
+ __save_xml_attribute(reader, "screen-reader", &uiapplication->screenreader, "use-system-setting");
+ __save_xml_attribute(reader, "mainapp", &uiapplication->mainapp, "false");
+ __save_xml_attribute(reader, "recentimage", &uiapplication->recentimage, "false");
+ __save_xml_attribute(reader, "launchcondition", &uiapplication->launchcondition, "false");
+ __save_xml_attribute(reader, "indicatordisplay", &uiapplication->indicatordisplay, "true");
+ __save_xml_attribute(reader, "portrait-effectimage", &uiapplication->portraitimg, NULL);
+ __save_xml_attribute(reader, "landscape-effectimage", &uiapplication->landscapeimg, NULL);
+ __save_xml_attribute(reader, "guestmode-visibility", &uiapplication->guestmode_visibility, "true");
+ __save_xml_attribute(reader, "permission-type", &uiapplication->permission_type, "normal");
+ __save_xml_attribute(reader, "component-type", &uiapplication->component_type, "uiapp");
+ /*component_type has "svcapp" or "uiapp", if it is not, parsing manifest is fail*/
+ retvm_if(((strcmp(uiapplication->component_type, "svcapp") != 0) && (strcmp(uiapplication->component_type, "uiapp") != 0) && (strcmp(uiapplication->component_type, "widgetapp") != 0)), PM_PARSER_R_ERROR, "invalid component_type[%s]\n", uiapplication->component_type);
+ __save_xml_attribute(reader, "submode", &uiapplication->submode, "false");
+ __save_xml_attribute(reader, "submode-mainid", &uiapplication->submode_mainid, NULL);
+ __save_xml_attribute(reader, "launch_mode", &uiapplication->launch_mode, "caller");
+
+ uiapplication->package= strdup(package);
depth = xmlTextReaderDepth(reader);
while ((ret = __next_child_element(reader, depth))) {
memset(notification, '\0', sizeof(notification_x));
LISTADD(uiapplication->notification, notification);
ret = __ps_process_notification(reader, notification);
+ } else if (!strcmp(ASCII(node), "datacontrol")) {
+ datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
+ if (datacontrol == NULL) {
+ _LOGD("Malloc Failed\n");
+ return -1;
+ }
+ memset(datacontrol, '\0', sizeof(datacontrol_x));
+ LISTADD(uiapplication->datacontrol, datacontrol);
+ ret = __ps_process_datacontrol(reader, datacontrol);
} else
return -1;
if (ret < 0) {
LISTHEAD(uiapplication->permission, tmp11);
uiapplication->permission = tmp11;
}
+ if (uiapplication->datacontrol) {
+ LISTHEAD(uiapplication->datacontrol, tmp12);
+ uiapplication->datacontrol = tmp12;
+ }
return ret;
}
const xmlChar *node;
int ret = -1;
int depth = -1;
- char *newappid = NULL;
label_x *tmp1 = NULL;
icon_x *tmp2 = NULL;
appsvc_x *tmp3 = NULL;
metadata_x *tmp10 = NULL;
permission_x *tmp11 = NULL;
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("appid"))) {
- serviceapplication->appid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appid")));
- if (serviceapplication->appid == NULL) {
- _LOGD("appid cant be NULL\n");
- return -1;
- }
- } else {
- _LOGD("appid is mandatory\n");
- return -1;
- }
- /*check appid*/
- ret = __validate_appid(package, serviceapplication->appid, &newappid);
- if (ret == -1) {
- _LOGD("appid is not proper\n");
- return -1;
- } else {
- if (newappid) {
- if (serviceapplication->appid)
- free((void *)serviceapplication->appid);
- serviceapplication->appid = newappid;
- }
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
- serviceapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
- serviceapplication->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot"))) {
- serviceapplication->onboot = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("on-boot")));
- if (serviceapplication->onboot == NULL)
- serviceapplication->onboot = strdup("false");
- } else {
- serviceapplication->onboot = strdup("false");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart"))) {
- serviceapplication->autorestart = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("auto-restart")));
- if (serviceapplication->autorestart == NULL)
- serviceapplication->autorestart = strdup("false");
- } else {
- serviceapplication->autorestart = strdup("false");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type"))) {
- serviceapplication->permission_type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("permission-type")));
- if (serviceapplication->permission_type == NULL)
- serviceapplication->permission_type = strdup("normal");
- } else {
- serviceapplication->permission_type = strdup("normal");
- }
+ __save_xml_attribute(reader, "appid", &serviceapplication->appid, NULL);
+ retvm_if(serviceapplication->appid == NULL, PM_PARSER_R_ERROR, "appid cant be NULL, appid field is mandatory\n");
+ __save_xml_attribute(reader, "exec", &serviceapplication->exec, NULL);
+ __save_xml_attribute(reader, "type", &serviceapplication->type, NULL);
+ __save_xml_attribute(reader, "enabled", &serviceapplication->enabled, "true");
+ __save_xml_attribute(reader, "permission-type", &serviceapplication->permission_type, "normal");
+ __save_xml_attribute(reader, "auto-restart", &serviceapplication->autorestart, "false");
+ __save_xml_attribute(reader, "on-boot", &serviceapplication->onboot, "false");
+
+ serviceapplication->package= strdup(package);
depth = xmlTextReaderDepth(reader);
while ((ret = __next_child_element(reader, depth))) {
continue;
} else if (!strcmp(ASCII(node), "ime")) {
continue;
- } else
+ } else if (!strcmp(ASCII(node), "feature")) {
+ continue;
+ } else {
+ _LOGE("Unknown element: %s", ASCII(node));
return -1;
+ }
if (ret < 0) {
_LOGD("Processing manifest failed\n");
return ret;
}
-static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
+static int __process_manifest(xmlTextReaderPtr reader, manifest_x *mfx, uid_t uid)
{
const xmlChar *node;
int ret = -1;
}
if (!strcmp(ASCII(node), "manifest")) {
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns"))){
- mfx->ns = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("xmlns")));
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("package"))) {
- mfx->package= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("package")));
- if (mfx->package == NULL) {
- _LOGD("package cant be NULL\n");
- return -1;
- }
- } else {
- _LOGD("package field is mandatory\n");
- return -1;
- }
- package = mfx->package;
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("version")))
- mfx->version= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("version")));
- /*app2ext needs package size for external installation*/
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("size")))
- mfx->package_size = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("size")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")))
- mfx->installlocation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("install-location")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("type")))
- mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
- 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)
- mfx->appsetting = strdup("false");
- } else {
- mfx->appsetting = strdup("false");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")))
- mfx->storeclient_id= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("storeclient-id")));
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting"))) {
- mfx->nodisplay_setting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("nodisplay-setting")));
- if (mfx->nodisplay_setting == NULL)
- mfx->nodisplay_setting = strdup("false");
- } else {
- mfx->nodisplay_setting = strdup("false");
- }
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("url")))
- mfx->package_url= ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("url")));
+ __save_xml_attribute(reader, "xmlns", &mfx->ns, NULL);
+ __save_xml_attribute(reader, "package", &mfx->package, NULL);
+ retvm_if(mfx->package == NULL, PM_PARSER_R_ERROR, "package cant be NULL, package field is mandatory\n");
+ __save_xml_attribute(reader, "version", &mfx->version, NULL);
+ __save_xml_attribute(reader, "size", &mfx->package_size, NULL);
+ __save_xml_attribute(reader, "install-location", &mfx->installlocation, "internal-only");
+ __save_xml_attribute(reader, "type", &mfx->type, "rpm");
+ __save_xml_attribute(reader, "root_path", &mfx->root_path, NULL);
+ __save_xml_attribute(reader, "csc_path", &mfx->csc_path, NULL);
+ __save_xml_attribute(reader, "appsetting", &mfx->appsetting, "false");
+ __save_xml_attribute(reader, "storeclient-id", &mfx->storeclient_id, NULL);
+ __save_xml_attribute(reader, "nodisplay-setting", &mfx->nodisplay_setting, "false");
+ __save_xml_attribute(reader, "url", &mfx->package_url, NULL);
+ __save_xml_attribute(reader, "api-version", &mfx->api_version, NULL);
+
+ __save_xml_installed_time(mfx);
+ __save_xml_root_path(mfx, uid);
/*Assign default values. If required it will be overwritten in __add_preload_info()*/
- mfx->preload = strdup("False");
- mfx->removable = strdup("True");
- mfx->readonly = strdup("False");
- mfx->update = strdup("False");
- mfx->system = strdup("False");
- char buf[PKG_STRING_LEN_MAX] = {'\0'};
- char *val = NULL;
- time_t current_time;
- time(¤t_time);
- snprintf(buf, PKG_STRING_LEN_MAX - 1, "%d", current_time);
- val = strndup(buf, PKG_STRING_LEN_MAX - 1);
- mfx->installed_time = val;
- mfx->installed_storage= strdup("installed_internal");
+ __save_xml_default_value(mfx);
ret = __start_process(reader, mfx, uid);
} else {
return locale;
}
-#define LIBAIL_PATH LIB_PATH "/libail.so.0"
-
-/* operation_type */
-typedef enum {
- AIL_INSTALL = 0,
- AIL_UPDATE,
- AIL_REMOVE,
- AIL_CLEAN,
- AIL_FOTA,
- AIL_MAX
-} AIL_TYPE;
-
-static int __ail_change_info(int op, const char *appid, uid_t uid)
-{
- void *lib_handle = NULL;
- char *aop = NULL;
- int ret = 0;
-
- if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
- _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
- goto END;
- }
-//is_admin
- if(uid != GLOBAL_USER)
- {
- int (*ail_desktop_operation) (const char *, uid_t uid);
- switch (op) {
- case 0:
- aop = "ail_usr_desktop_add";
- break;
- case 1:
- aop = "ail_usr_desktop_update";
- break;
- case 2:
- aop = "ail_usr_desktop_remove";
- break;
- case 3:
- aop = "ail_usr_desktop_clean";
- break;
- case 4:
- aop = "ail_usr_desktop_fota";
- break;
- default:
- goto END;
- break;
- }
-
- if ((ail_desktop_operation =
- dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
- _LOGE("can not find symbol \n");
- goto END;
- }
-
- ret = ail_desktop_operation(appid, uid);
- }else{
- int (*ail_desktop_operation) (const char *);
- switch (op) {
- case 0:
- aop = "ail_desktop_add";
- break;
- case 1:
- aop = "ail_desktop_update";
- break;
- case 2:
- aop = "ail_desktop_remove";
- break;
- 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) {
- _LOGE("can not find symbol \n");
- goto END;
- }
-
- ret = ail_desktop_operation(appid);
-
- }
-END:
- if (lib_handle)
- dlclose(lib_handle);
-
- return ret;
-}
-
-/* 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, ACTION_TYPE action, uid_t uid)
-{
- FILE* file = NULL;
- int fd = 0;
- char filepath[PKG_STRING_LEN_MAX] = "";
- char *buf = NULL;
- char *buftemp = NULL;
- char *locale = NULL;
-
- buf = (char *)calloc(1, BUFMAX);
- if (!buf) {
- _LOGE("Malloc Failed\n");
- return -1;
- }
-
- buftemp = (char *)calloc(1, BUFMAX);
- if (!buftemp) {
- _LOGE("Malloc Failed\n");
- free(buf);
- return -1;
- }
-
- if (action == ACTION_UPGRADE)
- __ail_change_info(AIL_CLEAN, mfx->package, uid);
-
- for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
-
- snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), mfx->uiapplication->appid);
-
- /* skip if desktop exists
- if (access(filepath, R_OK) == 0)
- continue;
- */
-
- file = fopen(filepath, "w");
- if(file == NULL)
- {
- _LOGD("Can't open %s", filepath);
- free(buf);
- free(buftemp);
- return -1;
- }
-
- snprintf(buf, BUFMAX, "[Desktop Entry]\n");
- fwrite(buf, 1, strlen(buf), file);
-
- for( ; mfx->uiapplication->label ; mfx->uiapplication->label = mfx->uiapplication->label->next) {
- if(!strcmp(mfx->uiapplication->label->lang, DEFAULT_LOCALE)) {
- snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
- } else {
- locale = __convert_to_system_locale(mfx->uiapplication->label->lang);
- snprintf(buf, BUFMAX, "Name[%s]=%s\n", locale,
- mfx->uiapplication->label->text);
- free(locale);
- }
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->label && mfx->uiapplication->label->text) {
- snprintf(buf, BUFMAX, "Name=%s\n", mfx->uiapplication->label->text);
- fwrite(buf, 1, strlen(buf), file);
- }
-/*
- else if(mfx->label && mfx->label->text) {
- snprintf(buf, BUFMAX, "Name=%s\n", mfx->label->text);
- fwrite(buf, 1, strlen(buf), file);
- } else {
- snprintf(buf, BUFMAX, "Name=%s\n", mfx->package);
- fwrite(buf, 1, strlen(buf), file);
- }
-*/
-
-
- snprintf(buf, BUFMAX, "Type=Application\n");
- fwrite(buf, 1, strlen(buf), file);
-
- if(mfx->uiapplication->exec) {
- snprintf(buf, BUFMAX, "Exec=%s\n", mfx->uiapplication->exec);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->icon && mfx->uiapplication->icon->text) {
- snprintf(buf, BUFMAX, "Icon=%s\n", mfx->uiapplication->icon->text);
- fwrite(buf, 1, strlen(buf), file);
- } else if(mfx->icon && mfx->icon->text) {
- snprintf(buf, BUFMAX, "Icon=%s\n", mfx->icon->text);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- // MIME types
- if(mfx->uiapplication && mfx->uiapplication->appsvc) {
- appsvc_x *asvc = mfx->uiapplication->appsvc;
- mime_x *mi = NULL;
- const char *mime = NULL;
- const char *mime_delim = "; ";
- int mime_count = 0;
-
- strncpy(buf, "MimeType=", BUFMAX-1);
- while (asvc) {
- mi = asvc->mime;
- while (mi) {
- mime_count++;
- mime = mi->name;
- _LOGD("MIME type: %s\n", mime);
- strncat(buf, mime, BUFMAX-strlen(buf)-1);
- if(mi->next) {
- strncat(buf, mime_delim, BUFMAX-strlen(buf)-1);
- }
-
- mi = mi->next;
- mime = NULL;
- }
- asvc = asvc->next;
- }
- _LOGD("MIME types: buf[%s]\n", buf);
- _LOGD("MIME count: %d\n", mime_count);
- if(mime_count)
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->version) {
- snprintf(buf, BUFMAX, "Version=%s\n", mfx->version);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->nodisplay) {
- snprintf(buf, BUFMAX, "NoDisplay=%s\n", mfx->uiapplication->nodisplay);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->categories) {
- snprintf(buf, BUFMAX, "Categories=%s\n", mfx->uiapplication->categories);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->taskmanage && !strcasecmp(mfx->uiapplication->taskmanage, "False")) {
- snprintf(buf, BUFMAX, "X-TIZEN-TaskManage=False\n");
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->enabled && !strcasecmp(mfx->uiapplication->enabled, "False")) {
- snprintf(buf, BUFMAX, "X-TIZEN-Enabled=False\n");
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->hwacceleration) {
- snprintf(buf, BUFMAX, "Hw-Acceleration=%s\n", mfx->uiapplication->hwacceleration);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->multiple && !strcasecmp(mfx->uiapplication->multiple, "True")) {
- snprintf(buf, BUFMAX, "X-TIZEN-Multiple=True\n");
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->extraid) {
- snprintf(buf, BUFMAX, "X-TIZEN-PackageID=%s\n", mfx->uiapplication->extraid);
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->removable && !strcasecmp(mfx->removable, "False")) {
- snprintf(buf, BUFMAX, "X-TIZEN-Removable=False\n");
- fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->type) {
- snprintf(buf, BUFMAX, "X-TIZEN-PackageType=%s\n", mfx->type);
- 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);
- }
-
- if(mfx->type) {
- snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
- fwrite(buf, 1, strlen(buf), file);
- }
- if(mfx->uiapplication->appid) {
- snprintf(buf, BUFMAX, "X-TIZEN-AppID=%s\n", mfx->uiapplication->appid);
- fwrite(buf, 1, strlen(buf), file);
- }
-
-
-
-// snprintf(buf, BUFMAX, "X-TIZEN-PackageType=rpm\n");
-// fwrite(buf, 1, strlen(buf), file);
-
-
- if(mfx->uiapplication->appsvc) {
- snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
- _LOGD("buf[%s]\n", buf);
-
-
- uiapplication_x *up = mfx->uiapplication;
- appsvc_x *asvc = NULL;
- operation_x *op = NULL;
- mime_x *mi = NULL;
- uri_x *ui = NULL;
- subapp_x *sub = NULL;
- const char *operation = NULL;
- const char *mime = NULL;
- const char *uri = NULL;
- const char *subapp = NULL;
- int i = 0;
-
-
- asvc = up->appsvc;
- while(asvc != NULL) {
- op = asvc->operation;
- while(op != NULL) {
- if (op)
- operation = op->name;
- mi = asvc->mime;
-
- do
- {
- if (mi)
- mime = mi->name;
- sub = asvc->subapp;
- do
- {
- if (sub)
- subapp = sub->name;
- ui = asvc->uri;
- do
- {
- if (ui)
- uri = ui->name;
-
- if(i++ > 0) {
- strncpy(buftemp, buf, BUFMAX);
- snprintf(buf, BUFMAX, "%s;", buftemp);
- }
-
-
- 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");
- _LOGD("buf[%s]\n", buf);
-
- if (ui)
- ui = ui->next;
- uri = NULL;
- } while(ui != NULL);
- if (sub)
- sub = sub->next;
- subapp = NULL;
- }while(sub != NULL);
- if (mi)
- mi = mi->next;
- mime = NULL;
- }while(mi != NULL);
- if (op)
- op = op->next;
- operation = NULL;
- }
- asvc = asvc->next;
- }
-
-
- fwrite(buf, 1, strlen(buf), file);
-
-// strncpy(buftemp, buf, BUFMAX);
-// snprintf(buf, BUFMAX, "%s\n", buftemp);
-// fwrite(buf, 1, strlen(buf), file);
- }
-
- if(mfx->uiapplication->appcontrol) {
- snprintf(buf, BUFMAX, "X-TIZEN-Svc=");
- _LOGD("buf[%s]\n", buf);
-
- uiapplication_x *up = mfx->uiapplication;
- appcontrol_x *acontrol = NULL;
- operation_x *op = NULL;
- mime_x *mi = NULL;
- uri_x *ui = NULL;
- subapp_x *sub = NULL;
- const char *operation = NULL;
- const char *mime = NULL;
- const char *uri = NULL;
- const char *subapp = NULL;
- int i = 0;
-
- acontrol = up->appcontrol;
- while(acontrol != NULL) {
- op = acontrol->operation;
- while(op != NULL) {
- if (op)
- operation = op->name;
- mi = acontrol->mime;
-
- do
- {
- if (mi)
- mime = mi->name;
- sub = acontrol->subapp;
- do
- {
- if (sub)
- subapp = sub->name;
- ui = acontrol->uri;
- do
- {
- if (ui)
- uri = ui->name;
-
- if(i++ > 0) {
- strncpy(buftemp, buf, BUFMAX);
- snprintf(buf, BUFMAX, "%s;", buftemp);
- }
-
- 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");
- _LOGD("buf[%s]\n", buf);
-
- if (ui)
- ui = ui->next;
- uri = NULL;
- } while(ui != NULL);
- if (sub)
- sub = sub->next;
- subapp = NULL;
- }while(sub != NULL);
- if (mi)
- mi = mi->next;
- mime = NULL;
- }while(mi != NULL);
- if (op)
- op = op->next;
- operation = NULL;
- }
- acontrol = acontrol->next;
- }
-
-
- fwrite(buf, 1, strlen(buf), file);
-
-// strncpy(buftemp, buf, BUFMAX);
-// snprintf(buf, BUFMAX, "%s\n", buftemp);
-// fwrite(buf, 1, strlen(buf), file);
- }
-
- fflush(file);
- fd = fileno(file);
- fsync(fd);
- fclose(file);
- if (action == ACTION_FOTA)
- __ail_change_info(AIL_FOTA, mfx->uiapplication->appid, uid);
- else
- __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid, uid);
- }
-
- free(buf);
- free(buftemp);
-
- return 0;
-}
-
-static int __ps_remove_nativeapp_desktop(manifest_x *mfx, uid_t uid)
-{
- char filepath[PKG_STRING_LEN_MAX] = "";
- int ret = 0;
- uiapplication_x *uiapplication = mfx->uiapplication;
-
- for(; uiapplication; uiapplication=uiapplication->next) {
- snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), uiapplication->appid);
-
- __ail_change_info(AIL_REMOVE, uiapplication->appid, uid);
-
- ret = remove(filepath);
- if (ret <0)
- return -1;
- }
-
- return 0;
-}
-
#define LIBAPPSVC_PATH LIB_PATH "/libappsvc.so.0"
static int __ps_remove_appsvc_db(manifest_x *mfx, uid_t uid)
uiapplication_x *uiapplication = mfx->uiapplication;
if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
- _LOGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAPPSVC_PATH);
+ _LOGE("dlopen is failed LIBAPPSVC_PATH[%s]\n", LIBAPPSVC_PATH);
goto END;
}
static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t uid)
{
- char filepath[PKG_STRING_LEN_MAX] = "";
- int ret = 0;
- uiapplication_x *uiapplication = mfx->uiapplication;
-
- if(strstr(manifest, getUserManifestPath(uid))) {
- /* if preload app is updated, then remove previous desktop file on RW*/
- for(; uiapplication; uiapplication=uiapplication->next) {
- snprintf(filepath, sizeof(filepath),"%s%s.desktop", getUserDesktopPath(uid), uiapplication->appid);
- ret = remove(filepath);
- if (ret <0)
- return -1;
- }
- } else {
+ if (!strstr(manifest, getUserManifestPath(uid))) {
/* if downloaded app is updated, then update tag set true*/
- free((void *)mfx->update);
+ if (mfx->update)
+ free((void *)mfx->update);
mfx->update = strdup("true");
}
API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
{
- int ret = 0;
- if (mfx == NULL) {
- _LOGD("Manifest pointer is NULL\n");
- return -1;
- }
- ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, GLOBAL_USER);
- if (ret == -1)
- _LOGD("Creating desktop file failed\n");
- else
- _LOGD("Creating desktop file Success\n");
- return ret;
+ /* desktop file is no longer used */
+ return 0;
}
API int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
{
- int ret = 0;
- if (mfx == NULL) {
- _LOGD("Manifest pointer is NULL\n");
- return -1;
- }
- ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, uid);
- if (ret == -1)
- _LOGD("Creating desktop file failed\n");
- else
- _LOGD("Creating desktop file Success\n");
- return ret;
+ /* desktop file is no longer used */
+ return 0;
}
free((void *)mfx->nodisplay_setting);
mfx->nodisplay_setting = NULL;
}
- if (mfx->main_package) {
- free((void *)mfx->main_package);
- mfx->main_package = NULL;
+ if (mfx->api_version) {
+ free((void *)mfx->api_version);
+ mfx->api_version = NULL;
}
/*Free Icon*/
_LOGD("Parsing Finished\n");
// __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
- __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
__add_preload_info(mfx, manifest, GLOBAL_USER);
_LOGD("Added preload infomation\n");
_LOGD("DB Insert Success\n");
+ __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
if (ret == -1)
_LOGD("Creating metadata parser failed\n");
if (ret == -1)
_LOGD("Creating category parser failed\n");
- if (__check_action_fota(tagv))
- ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA, GLOBAL_USER);
- else
- ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, GLOBAL_USER);
-
- if (ret == -1)
- _LOGD("Creating desktop file failed\n");
- else
- _LOGD("Creating desktop file Success\n");
-
pkgmgr_parser_free_manifest_xml(mfx);
_LOGD("Free Done\n");
xmlCleanupParser();
_LOGD("Parsing Finished\n");
// __streamFile(manifest, ACTION_INSTALL, temp, mfx->package);
- __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
__ps_process_tag(mfx, tagv);
retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
_LOGD("DB Insert Success\n");
+
+ __ps_process_tag_parser(mfx, manifest, ACTION_INSTALL);
ret = __ps_process_metadata_parser(mfx, ACTION_INSTALL);
if (ret == -1)
_LOGD("Creating metadata parser failed\n");
if (ret == -1)
_LOGD("Creating category parser failed\n");
- if (__check_action_fota(tagv))
- ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_FOTA, uid);
- else
- ret = __ps_make_nativeapp_desktop(mfx, NULL, ACTION_INSTALL, uid);
-
- if (ret == -1)
- _LOGD("Creating desktop file failed\n");
- else
- _LOGD("Creating desktop file Success\n");
pkgmgr_parser_free_manifest_xml(mfx);
_LOGD("Free Done\n");
xmlCleanupParser();
_LOGD("Parsing Finished\n");
// __streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
- __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
__add_preload_info(mfx, manifest, GLOBAL_USER);
_LOGD("Added preload infomation\n");
__check_preload_updated(mfx, manifest, GLOBAL_USER);
ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
+
_LOGD("DB Update Success\n");
+
+ __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
if (ret == -1){
_LOGD("Upgrade metadata parser failed\n");
ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
if (ret == -1)
_LOGD("Creating category parser failed\n");
- ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE, GLOBAL_USER);
- if (ret == -1)
- _LOGD("Creating desktop file failed\n");
- else
- _LOGD("Creating desktop file Success\n");
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
pkgmgr_parser_free_manifest_xml(mfx);
_LOGD("Free Done\n");
_LOGD("Parsing Finished\n");
//__streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
- __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
__check_preload_updated(mfx, manifest, uid);
ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(mfx->package, uid, &handle);
ret = pkgmgr_parser_update_manifest_info_in_usr_db(mfx, uid);
retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
_LOGD("DB Update Success\n");
- _LOGE("DB Update Success\n" );
+
+ __ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
if (ret == -1)
_LOGD("Upgrade metadata parser failed\n");
ret = __ps_process_category_parser(mfx, ACTION_UPGRADE);
if (ret == -1)
_LOGD("Creating category parser failed\n");
- ret = __ps_make_nativeapp_desktop(mfx, manifest, ACTION_UPGRADE, uid);
- if (ret == -1)
- _LOGD("Creating desktop file failed\n");
- else
- _LOGD("Creating desktop file Success\n");
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
pkgmgr_parser_free_manifest_xml(mfx);
_LOGD("Free Done\n");
else
_LOGD("DB Delete Success\n");
- ret = __ps_remove_nativeapp_desktop(mfx, GLOBAL_USER);
- if (ret == -1)
- _LOGD("Removing desktop file failed\n");
- else
- _LOGD("Removing desktop file Success\n");
-
pkgmgr_parser_free_manifest_xml(mfx);
_LOGD("Free Done\n");
xmlCleanupParser();
else
_LOGD("DB Delete Success\n");
- ret = __ps_remove_nativeapp_desktop(mfx, uid);
- if (ret == -1)
- _LOGD("Removing desktop file failed\n");
- else
- _LOGD("Removing desktop file Success\n");
-
ret = __ps_remove_appsvc_db(mfx, uid);
if (ret == -1)
_LOGD("Removing appsvc_db failed\n");