- if (!strcmp(ASCII(node), "define")) {
- define_x *define= malloc(sizeof(define_x));
- if (define == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(define, '\0', sizeof(define_x));
- LISTADD(datashare->define, define);
- ret = __ps_process_define(reader, define);
- } else if (!strcmp(ASCII(node), "request")) {
- request_x *request= malloc(sizeof(request_x));
- if (request == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(request, '\0', sizeof(request_x));
- LISTADD(datashare->request, request);
- ret = __ps_process_request(reader, request);
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing data-share failed\n");
- return ret;
- }
- }
- if (datashare->define) {
- LISTHEAD(datashare->define, tmp1);
- datashare->define = tmp1;
- }
- if (datashare->request) {
- LISTHEAD(datashare->request, tmp2);
- datashare->request = tmp2;
- }
- return ret;
-}
-
-static char*
-__get_icon_with_path(const char* icon)
-{
- if (!icon)
- return NULL;
-
- if (index(icon, '/') == NULL) {
- char* theme = NULL;
- char* icon_with_path = NULL;
- int len;
-
- if (!package)
- return NULL;
-
- theme = vconf_get_str("db/setting/theme");
- if (!theme) {
- theme = strdup("default");
- if(!theme) {
- return NULL;
- }
- }
-
- 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");
- free(theme);
- return NULL;
- }
-
- memset(icon_with_path, 0, len);
-
- snprintf(icon_with_path, len, "/opt/share/icons/%s/small/%s", theme, icon);
- do {
- 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);
- 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);
- 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);
- 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);
- if (access(icon_with_path, R_OK) == 0) break;
- snprintf(icon_with_path, len, "/usr/ug/res/images/%s/%s", package, icon);
- if (access(icon_with_path, R_OK) == 0) break;
- } while (0);
-
- free(theme);
-
- DBG("Icon path : %s ---> %s", icon, icon_with_path);
-
- return icon_with_path;
- } else {
- char* confirmed_icon = NULL;
-
- confirmed_icon = strdup(icon);
- if (!confirmed_icon)
- return NULL;
- return confirmed_icon;
- }
-}
-
-static void __ps_process_tag(manifest_x * mfx, char *const tagv[])
-{
- int i = 0;
- char delims[] = "=";
- char *ret_result = NULL;
- char *tag = NULL;
-
- if (tagv == NULL)
- return;
-
- for (tag = strdup(tagv[0]); tag != NULL; ) {
- ret_result = strtok(tag, delims);
-
- /*check tag : preload */
- if (strcmp(ret_result, "preload") == 0) {
- ret_result = strtok(NULL, delims);
- if (strcmp(ret_result, "true") == 0) {
- free((void *)mfx->preload);
- mfx->preload = strdup("true");
- } else if (strcmp(ret_result, "false") == 0) {
- free((void *)mfx->preload);
- mfx->preload = strdup("false");
- }
- /*check tag : removable*/
- } else if (strcmp(ret_result, "removable") == 0) {
- ret_result = strtok(NULL, delims);
- if (strcmp(ret_result, "true") == 0){
- free((void *)mfx->removable);
- mfx->removable = strdup("true");
- } else if (strcmp(ret_result, "false") == 0) {
- free((void *)mfx->removable);
- mfx->removable = strdup("false");
- }
- /*check tag : not matched*/
- } else
- DBG("tag process [%s]is not defined\n", ret_result);
-
- free(tag);
-
- /*check next value*/
- if (tagv[++i] != NULL)
- tag = strdup(tagv[i]);
- else {
- DBG("tag process success...\n");
- return;
- }
- }
-}
-
-static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon)
-{
- 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")));
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader)) {
- const char *text = ASCII(xmlTextReaderValue(reader));
- if(text) {
- icon->text = (const char *)__get_icon_with_path(text);
- 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));
-
- 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));
-
-/* DBG("lable name %s\n", label->name);
- DBG("lable lang %s\n", label->lang);
- DBG("lable text %s\n", 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))
- author->text = ASCII(xmlTextReaderValue(reader));
- 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))
- description->text = ASCII(xmlTextReaderValue(reader));
- 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));
- 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) {
- DBG("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");
- return -1;
- }
- memset(resolution, '\0', sizeof(resolution_x));
- LISTADD(capability->resolution, resolution);
- ret = __ps_process_resolution(reader, resolution);
- } else
- return -1;
- if (ret < 0) {
- DBG("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)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- capability_x *tmp1 = NULL;
-
- if (xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")))
- datacontrol->providerid = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("provider-id")));
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("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");
- return -1;
- }
- memset(capability, '\0', sizeof(capability_x));
- LISTADD(datacontrol->capability, capability);
- ret = __ps_process_capability(reader, capability);
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing datacontrol failed\n");
- return ret;
- }
- }
-
- if (datacontrol->capability) {
- LISTHEAD(datacontrol->capability, tmp1);
- datacontrol->capability = tmp1;
- }
-
- return ret;
-}
-
-static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *uiapplication)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- char *newappid = NULL;
- label_x *tmp1 = NULL;
- icon_x *tmp2 = NULL;
- appsvc_x *tmp3 = NULL;
- appcontrol_x *tmp4 = NULL;
- launchconditions_x *tmp5 = NULL;
- notification_x *tmp6 = NULL;
- datashare_x *tmp7 = NULL;
- category_x *tmp8 = 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) {
- DBG("appid cant be NULL\n");
- return -1;
- }
- } else {
- DBG("appid is mandatory\n");
- return -1;
- }
- /*check appid*/
- ret = __validate_appid(package, uiapplication->appid, &newappid);
- if (ret == -1) {
- DBG("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("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")));
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("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");
- return -1;
- }
- memset(label, '\0', sizeof(label_x));
- LISTADD(uiapplication->label, label);
- ret = __ps_process_label(reader, label);
- } else if (!strcmp(ASCII(node), "icon")) {
- icon_x *icon = malloc(sizeof(icon_x));
- if (icon == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(icon, '\0', sizeof(icon_x));
- LISTADD(uiapplication->icon, icon);
- ret = __ps_process_icon(reader, icon);
- } else if (!strcmp(ASCII(node), "image")) {
- image_x *image = malloc(sizeof(image_x));
- if (image == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(image, '\0', sizeof(image_x));
- LISTADD(uiapplication->image, image);
- ret = __ps_process_image(reader, image);
- } else if (!strcmp(ASCII(node), "category")) {
- category_x *category = malloc(sizeof(category_x));
- if (category == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(category, '\0', sizeof(category_x));
- LISTADD(uiapplication->category, category);
- ret = __ps_process_category(reader, category);
- } else if (!strcmp(ASCII(node), "metadata")) {
- metadata_x *metadata = malloc(sizeof(metadata_x));
- if (metadata == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(metadata, '\0', sizeof(metadata_x));
- LISTADD(uiapplication->metadata, metadata);
- ret = __ps_process_metadata(reader, metadata);
- } else if (!strcmp(ASCII(node), "permission")) {
- permission_x *permission = malloc(sizeof(permission_x));
- if (permission == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(permission, '\0', sizeof(permission_x));
- LISTADD(uiapplication->permission, permission);
- ret = __ps_process_permission(reader, permission);
- } else if (!strcmp(ASCII(node), "app-control")) {
- appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
- if (appcontrol == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(appcontrol, '\0', sizeof(appcontrol_x));
- LISTADD(uiapplication->appcontrol, appcontrol);
- ret = __ps_process_appcontrol(reader, appcontrol);
- } else if (!strcmp(ASCII(node), "application-service")) {
- appsvc_x *appsvc = malloc(sizeof(appsvc_x));
- if (appsvc == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(appsvc, '\0', sizeof(appsvc_x));
- LISTADD(uiapplication->appsvc, appsvc);
- ret = __ps_process_appsvc(reader, appsvc);
- } else if (!strcmp(ASCII(node), "data-share")) {
- datashare_x *datashare = malloc(sizeof(datashare_x));
- if (datashare == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(datashare, '\0', sizeof(datashare_x));
- LISTADD(uiapplication->datashare, datashare);
- ret = __ps_process_datashare(reader, datashare);
- } else if (!strcmp(ASCII(node), "launch-conditions")) {
- launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
- if (launchconditions == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(launchconditions, '\0', sizeof(launchconditions_x));
- LISTADD(uiapplication->launchconditions, launchconditions);
- ret = __ps_process_launchconditions(reader, launchconditions);
- } else if (!strcmp(ASCII(node), "notification")) {
- notification_x *notification = malloc(sizeof(notification_x));
- if (notification == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(notification, '\0', sizeof(notification_x));
- LISTADD(uiapplication->notification, notification);
- ret = __ps_process_notification(reader, notification);
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing uiapplication failed\n");
- return ret;
- }
- }
-
- if (uiapplication->label) {
- LISTHEAD(uiapplication->label, tmp1);
- uiapplication->label = tmp1;
- }
- if (uiapplication->icon) {
- LISTHEAD(uiapplication->icon, tmp2);
- uiapplication->icon = tmp2;
- }
- if (uiapplication->appsvc) {
- LISTHEAD(uiapplication->appsvc, tmp3);
- uiapplication->appsvc = tmp3;
- }
- if (uiapplication->appcontrol) {
- LISTHEAD(uiapplication->appcontrol, tmp4);
- uiapplication->appcontrol = tmp4;
- }
- if (uiapplication->launchconditions) {
- LISTHEAD(uiapplication->launchconditions, tmp5);
- uiapplication->launchconditions = tmp5;
- }
- if (uiapplication->notification) {
- LISTHEAD(uiapplication->notification, tmp6);
- uiapplication->notification = tmp6;
- }
- if (uiapplication->datashare) {
- LISTHEAD(uiapplication->datashare, tmp7);
- uiapplication->datashare = tmp7;
- }
- if (uiapplication->category) {
- LISTHEAD(uiapplication->category, tmp8);
- uiapplication->category = tmp8;
- }
- if (uiapplication->metadata) {
- LISTHEAD(uiapplication->metadata, tmp9);
- uiapplication->metadata = tmp9;
- }
- if (uiapplication->image) {
- LISTHEAD(uiapplication->image, tmp10);
- uiapplication->image = tmp10;
- }
- if (uiapplication->permission) {
- LISTHEAD(uiapplication->permission, tmp11);
- uiapplication->permission = tmp11;
- }
-
- return ret;
-}
-
-static int __ps_process_serviceapplication(xmlTextReaderPtr reader, serviceapplication_x *serviceapplication)
-{
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- char *newappid = NULL;
- label_x *tmp1 = NULL;
- icon_x *tmp2 = NULL;
- appsvc_x *tmp3 = NULL;
- appcontrol_x *tmp4 = NULL;
- datacontrol_x *tmp5 = NULL;
- launchconditions_x *tmp6 = NULL;
- notification_x *tmp7 = NULL;
- datashare_x *tmp8 = NULL;
- category_x *tmp9 = 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) {
- DBG("appid cant be NULL\n");
- return -1;
- }
- } else {
- DBG("appid is mandatory\n");
- return -1;
- }
- /*check appid*/
- ret = __validate_appid(package, serviceapplication->appid, &newappid);
- if (ret == -1) {
- DBG("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");
- }
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("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");
- return -1;
- }
- memset(label, '\0', sizeof(label_x));
- LISTADD(serviceapplication->label, label);
- ret = __ps_process_label(reader, label);
- } else if (!strcmp(ASCII(node), "icon")) {
- icon_x *icon = malloc(sizeof(icon_x));
- if (icon == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(icon, '\0', sizeof(icon_x));
- LISTADD(serviceapplication->icon, icon);
- ret = __ps_process_icon(reader, icon);
- } else if (!strcmp(ASCII(node), "category")) {
- category_x *category = malloc(sizeof(category_x));
- if (category == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(category, '\0', sizeof(category_x));
- LISTADD(serviceapplication->category, category);
- ret = __ps_process_category(reader, category);
- } else if (!strcmp(ASCII(node), "metadata")) {
- metadata_x *metadata = malloc(sizeof(metadata_x));
- if (metadata == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(metadata, '\0', sizeof(metadata_x));
- LISTADD(serviceapplication->metadata, metadata);
- ret = __ps_process_metadata(reader, metadata);
- } else if (!strcmp(ASCII(node), "permission")) {
- permission_x *permission = malloc(sizeof(permission_x));
- if (permission == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(permission, '\0', sizeof(permission_x));
- LISTADD(serviceapplication->permission, permission);
- ret = __ps_process_permission(reader, permission);
- } else if (!strcmp(ASCII(node), "app-control")) {
- appcontrol_x *appcontrol = malloc(sizeof(appcontrol_x));
- if (appcontrol == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(appcontrol, '\0', sizeof(appcontrol_x));
- LISTADD(serviceapplication->appcontrol, appcontrol);
- ret = __ps_process_appcontrol(reader, appcontrol);
- } else if (!strcmp(ASCII(node), "application-service")) {
- appsvc_x *appsvc = malloc(sizeof(appsvc_x));
- if (appsvc == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(appsvc, '\0', sizeof(appsvc_x));
- LISTADD(serviceapplication->appsvc, appsvc);
- ret = __ps_process_appsvc(reader, appsvc);
- } else if (!strcmp(ASCII(node), "data-share")) {
- datashare_x *datashare = malloc(sizeof(datashare_x));
- if (datashare == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(datashare, '\0', sizeof(datashare_x));
- LISTADD(serviceapplication->datashare, datashare);
- ret = __ps_process_datashare(reader, datashare);
- } else if (!strcmp(ASCII(node), "launch-conditions")) {
- launchconditions_x *launchconditions = malloc(sizeof(launchconditions_x));
- if (launchconditions == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(launchconditions, '\0', sizeof(launchconditions_x));
- LISTADD(serviceapplication->launchconditions, launchconditions);
- ret = __ps_process_launchconditions(reader, launchconditions);
- } else if (!strcmp(ASCII(node), "notification")) {
- notification_x *notification = malloc(sizeof(notification_x));
- if (notification == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(notification, '\0', sizeof(notification_x));
- LISTADD(serviceapplication->notification, notification);
- ret = __ps_process_notification(reader, notification);
- } else if (!strcmp(ASCII(node), "data-control")) {
- datacontrol_x *datacontrol = malloc(sizeof(datacontrol_x));
- if (datacontrol == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(datacontrol, '\0', sizeof(datacontrol_x));
- LISTADD(serviceapplication->datacontrol, datacontrol);
- ret = __ps_process_datacontrol(reader, datacontrol);
- } else
- return -1;
- if (ret < 0) {
- DBG("Processing serviceapplication failed\n");
- return ret;
- }
- }
-
- if (serviceapplication->label) {
- LISTHEAD(serviceapplication->label, tmp1);
- serviceapplication->label = tmp1;
- }
- if (serviceapplication->icon) {
- LISTHEAD(serviceapplication->icon, tmp2);
- serviceapplication->icon = tmp2;
- }
- if (serviceapplication->appsvc) {
- LISTHEAD(serviceapplication->appsvc, tmp3);
- serviceapplication->appsvc = tmp3;
- }
- if (serviceapplication->appcontrol) {
- LISTHEAD(serviceapplication->appcontrol, tmp4);
- serviceapplication->appcontrol = tmp4;
- }
- if (serviceapplication->datacontrol) {
- LISTHEAD(serviceapplication->datacontrol, tmp5);
- serviceapplication->datacontrol = tmp5;
- }
- if (serviceapplication->launchconditions) {
- LISTHEAD(serviceapplication->launchconditions, tmp6);
- serviceapplication->launchconditions = tmp6;
- }
- if (serviceapplication->notification) {
- LISTHEAD(serviceapplication->notification, tmp7);
- serviceapplication->notification = tmp7;
- }
- if (serviceapplication->datashare) {
- LISTHEAD(serviceapplication->datashare, tmp8);
- serviceapplication->datashare = tmp8;
- }
- if (serviceapplication->category) {
- LISTHEAD(serviceapplication->category, tmp9);
- serviceapplication->category = tmp9;
- }
- if (serviceapplication->metadata) {
- LISTHEAD(serviceapplication->metadata, tmp10);
- serviceapplication->metadata = tmp10;
- }
- if (serviceapplication->permission) {
- LISTHEAD(serviceapplication->permission, tmp11);
- serviceapplication->permission = tmp11;
- }
-
- return ret;
-}
-
-static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_font(xmlTextReaderPtr reader, font_x *font)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_theme(xmlTextReaderPtr reader, theme_x *theme)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx)
-{
- DBG("__start_process\n");
- const xmlChar *node;
- int ret = -1;
- int depth = -1;
- label_x *tmp1 = NULL;
- author_x *tmp2 = NULL;
- description_x *tmp3 = NULL;
- license_x *tmp4 = NULL;
- uiapplication_x *tmp5 = NULL;
- serviceapplication_x *tmp6 = NULL;
- daemon_x *tmp7 = NULL;
- theme_x *tmp8 = NULL;
- font_x *tmp9 = NULL;
- ime_x *tmp10 = NULL;
- icon_x *tmp11 = NULL;
- compatibility_x *tmp12 = NULL;
- deviceprofile_x *tmp13 = NULL;
- privileges_x *tmp14 = NULL;
-
- depth = xmlTextReaderDepth(reader);
- while ((ret = __next_child_element(reader, depth))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("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");
- return -1;
- }
- memset(label, '\0', sizeof(label_x));
- LISTADD(mfx->label, label);
- ret = __ps_process_label(reader, label);
- } else if (!strcmp(ASCII(node), "author")) {
- author_x *author = malloc(sizeof(author_x));
- if (author == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(author, '\0', sizeof(author_x));
- LISTADD(mfx->author, author);
- ret = __ps_process_author(reader, author);
- } else if (!strcmp(ASCII(node), "description")) {
- description_x *description = malloc(sizeof(description_x));
- if (description == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(description, '\0', sizeof(description_x));
- LISTADD(mfx->description, description);
- ret = __ps_process_description(reader, description);
- } else if (!strcmp(ASCII(node), "license")) {
- license_x *license = malloc(sizeof(license_x));
- if (license == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(license, '\0', sizeof(license_x));
- LISTADD(mfx->license, license);
- ret = __ps_process_license(reader, license);
- } else if (!strcmp(ASCII(node), "privileges")) {
- privileges_x *privileges = malloc(sizeof(privileges_x));
- if (privileges == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(privileges, '\0', sizeof(privileges_x));
- LISTADD(mfx->privileges, privileges);
- ret = __ps_process_privileges(reader, privileges);
- } else if (!strcmp(ASCII(node), "ui-application")) {
- uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
- if (uiapplication == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(uiapplication, '\0', sizeof(uiapplication_x));
- LISTADD(mfx->uiapplication, uiapplication);
- ret = __ps_process_uiapplication(reader, uiapplication);
- } else if (!strcmp(ASCII(node), "service-application")) {
- serviceapplication_x *serviceapplication = malloc(sizeof(serviceapplication_x));
- if (serviceapplication == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(serviceapplication, '\0', sizeof(serviceapplication_x));
- LISTADD(mfx->serviceapplication, serviceapplication);
- ret = __ps_process_serviceapplication(reader, serviceapplication);
- } else if (!strcmp(ASCII(node), "daemon")) {
- daemon_x *daemon = malloc(sizeof(daemon_x));
- if (daemon == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(daemon, '\0', sizeof(daemon_x));
- LISTADD(mfx->daemon, daemon);
- ret = __ps_process_daemon(reader, daemon);
- } else if (!strcmp(ASCII(node), "theme")) {
- theme_x *theme = malloc(sizeof(theme_x));
- if (theme == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(theme, '\0', sizeof(theme_x));
- LISTADD(mfx->theme, theme);
- ret = __ps_process_theme(reader, theme);
- } else if (!strcmp(ASCII(node), "font")) {
- font_x *font = malloc(sizeof(font_x));
- if (font == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(font, '\0', sizeof(font_x));
- LISTADD(mfx->font, font);
- ret = __ps_process_font(reader, font);
- } else if (!strcmp(ASCII(node), "ime")) {
- ime_x *ime = malloc(sizeof(ime_x));
- if (ime == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(ime, '\0', sizeof(ime_x));
- LISTADD(mfx->ime, ime);
- ret = __ps_process_ime(reader, ime);
- } else if (!strcmp(ASCII(node), "icon")) {
- icon_x *icon = malloc(sizeof(icon_x));
- if (icon == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(icon, '\0', sizeof(icon_x));
- LISTADD(mfx->icon, icon);
- ret = __ps_process_icon(reader, icon);
- } else if (!strcmp(ASCII(node), "device-profile")) {
- deviceprofile_x *deviceprofile = malloc(sizeof(deviceprofile_x));
- if (deviceprofile == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(deviceprofile, '\0', sizeof(deviceprofile_x));
- LISTADD(mfx->deviceprofile, deviceprofile);
- ret = __ps_process_deviceprofile(reader, deviceprofile);
- } else if (!strcmp(ASCII(node), "compatibility")) {
- compatibility_x *compatibility = malloc(sizeof(compatibility_x));
- if (compatibility == NULL) {
- DBG("Malloc Failed\n");
- return -1;
- }
- memset(compatibility, '\0', sizeof(compatibility_x));
- LISTADD(mfx->compatibility, compatibility);
- ret = __ps_process_compatibility(reader, compatibility);
- } else if (!strcmp(ASCII(node), "shortcut-list")) {
- continue;
- } else if (!strcmp(ASCII(node), "livebox")) {
- continue;
- } else if (!strcmp(ASCII(node), "account")) {
- continue;
- } else if (!strcmp(ASCII(node), "notifications")) {
- continue;
- } else if (!strcmp(ASCII(node), "ime")) {
- continue;
- } else
- return -1;
-
- if (ret < 0) {
- DBG("Processing manifest failed\n");
- return ret;
- }
- }
- if (mfx->label) {
- LISTHEAD(mfx->label, tmp1);
- mfx->label = tmp1;
- }
- if (mfx->author) {
- LISTHEAD(mfx->author, tmp2);
- mfx->author = tmp2;
- }
- if (mfx->description) {
- LISTHEAD(mfx->description, tmp3);
- mfx->description= tmp3;
- }
- if (mfx->license) {
- LISTHEAD(mfx->license, tmp4);
- mfx->license= tmp4;
- }
- if (mfx->uiapplication) {
- LISTHEAD(mfx->uiapplication, tmp5);
- mfx->uiapplication = tmp5;
- }
- if (mfx->serviceapplication) {
- LISTHEAD(mfx->serviceapplication, tmp6);
- mfx->serviceapplication = tmp6;
- }
- if (mfx->daemon) {
- LISTHEAD(mfx->daemon, tmp7);
- mfx->daemon= tmp7;
- }
- if (mfx->theme) {
- LISTHEAD(mfx->theme, tmp8);
- mfx->theme= tmp8;
- }
- if (mfx->font) {
- LISTHEAD(mfx->font, tmp9);
- mfx->font= tmp9;
- }
- if (mfx->ime) {
- LISTHEAD(mfx->ime, tmp10);
- mfx->ime= tmp10;
- }
- if (mfx->icon) {
- LISTHEAD(mfx->icon, tmp11);
- mfx->icon= tmp11;
- }
- if (mfx->compatibility) {
- LISTHEAD(mfx->compatibility, tmp12);
- mfx->compatibility= tmp12;
- }
- if (mfx->deviceprofile) {
- LISTHEAD(mfx->deviceprofile, tmp13);
- mfx->deviceprofile= tmp13;
- }
- if (mfx->privileges) {
- LISTHEAD(mfx->privileges, tmp14);
- mfx->privileges = tmp14;
- }
- return ret;
-}
-
-static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
-{
- const xmlChar *node;
- int ret = -1;
-
- if ((ret = __next_child_element(reader, -1))) {
- node = xmlTextReaderConstName(reader);
- if (!node) {
- DBG("xmlTextReaderConstName value is NULL\n");
- return -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) {
- DBG("package cant be NULL\n");
- return -1;
- }
- } else {
- DBG("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("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")));
-
- /*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");
- 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");
-
- ret = __start_process(reader, mfx);
- } else {
- DBG("No Manifest element found\n");
- return -1;
- }
- }
- return ret;
-}
-
-#define DESKTOP_RW_PATH "/opt/share/applications/"
-#define DESKTOP_RO_PATH "/usr/share/applications/"
-#define MANIFEST_RO_PREFIX "/usr/share/packages/"
-
-static char* __convert_to_system_locale(const char *mlocale)
-{
- if (mlocale == NULL)
- return NULL;
- char *locale = NULL;
- locale = (char *)calloc(1, 6);
- if (!locale) {
- DBGE("Malloc Failed\n");
- return NULL;
- }
-
- strncpy(locale, mlocale, 2);
- strncat(locale, "_", 1);
- locale[3] = toupper(mlocale[3]);
- locale[4] = toupper(mlocale[4]);
- return locale;
-}
-
-#define LIBAIL_PATH "/usr/lib/libail.so.0"
-
-/* operation_type */
-typedef enum {
- AIL_INSTALL = 0,
- AIL_UPDATE,
- AIL_REMOVE,
- AIL_CLEAN,
- AIL_MAX
-} AIL_TYPE;
-
-static int __ail_change_info(int op, const char *appid)
-{
- void *lib_handle = NULL;
- int (*ail_desktop_operation) (const char *);
- char *aop = NULL;
- int ret = 0;
-
- if ((lib_handle = dlopen(LIBAIL_PATH, RTLD_LAZY)) == NULL) {
- DBGE("dlopen is failed LIBAIL_PATH[%s]\n", LIBAIL_PATH);
- goto END;
- }
-
-
- 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;
- default:
- goto END;
- break;
- }
-
- if ((ail_desktop_operation =
- dlsym(lib_handle, aop)) == NULL || dlerror() != NULL) {
- DBGE("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, bool is_update)
-{
- 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) {
- DBGE("Malloc Failed\n");
- return -1;
- }
-
- buftemp = (char *)calloc(1, BUFMAX);
- if (!buftemp) {
- DBGE("Malloc Failed\n");
- free(buf);
- return -1;
- }
-
- if (is_update)
- __ail_change_info(AIL_CLEAN, mfx->package);
-
- for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
-
- if (manifest != NULL) {
- /* 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);
- continue;
- }
- }
-
- if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
- snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
- else
- snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
-
- /* skip if desktop exists
- if (access(filepath, R_OK) == 0)
- continue;
- */
-
- file = fopen(filepath, "w");
- if(file == NULL)
- {
- DBGE("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;
- DBG("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;
- }
- DBG("MIME types: buf[%s]\n", buf);
- DBG("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);
- }
-
- snprintf(buf, BUFMAX, "X-TIZEN-PkgID=%s\n", mfx->package);
- 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=");
- DBG("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");
- DBG("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=");
- DBG("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");
- DBG("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);
-
- __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
- }
-
- free(buf);
- free(buftemp);
-
- return 0;
-}
-
-static int __ps_remove_nativeapp_desktop(manifest_x *mfx)
-{
- 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", DESKTOP_RW_PATH, uiapplication->appid);
-
- __ail_change_info(AIL_REMOVE, uiapplication->appid);
-
- ret = remove(filepath);
- if (ret <0)
- return -1;
- }
-
- return 0;
-}
-
-#define LIBAPPSVC_PATH "/usr/lib/libappsvc.so.0"
-
-static int __ps_remove_appsvc_db(manifest_x *mfx)
-{
- void *lib_handle = NULL;
- int (*appsvc_operation) (const char *);
- int ret = 0;
- uiapplication_x *uiapplication = mfx->uiapplication;
-
- if ((lib_handle = dlopen(LIBAPPSVC_PATH, RTLD_LAZY)) == NULL) {
- DBGE("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");
- goto END;
- }
-
- for(; uiapplication; uiapplication=uiapplication->next) {
- ret = appsvc_operation(uiapplication->appid);
- if (ret <0)
- DBGE("can not operation symbol \n");
- }
-
-END:
- if (lib_handle)
- dlclose(lib_handle);
-
- return ret;
-}
-
-#define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
-static int __add_preload_info(manifest_x * mfx, const char *manifest)
-{
- FILE *fp = NULL;
- char buffer[1024] = { 0 };
- int state = 0;
-
- if(strstr(manifest, MANIFEST_RO_PREFIX)) {
- free((void *)mfx->readonly);
- mfx->readonly = strdup("True");
-
- free((void *)mfx->preload);
- mfx->preload = strdup("True");
-
- free((void *)mfx->removable);
- mfx->removable = strdup("False");
-
- return 0;
- }
-
- fp = fopen(PRELOAD_PACKAGE_LIST, "r");
- if (fp == NULL) {
- DBGE("no preload list\n");
- return -1;
- }
-
- while (fgets(buffer, sizeof(buffer), fp) != NULL) {
- if (buffer[0] == '#') {
- if(strcasestr(buffer, "RW_NORM"))
- state = 2;
- else if(strcasestr(buffer, "RW_RM"))
- state = 3;
- else
- continue;
- }
-
- __str_trim(buffer);
-
- if(!strcmp(mfx->package, buffer)) {
- free((void *)mfx->preload);
- mfx->preload = strdup("True");
- if(state == 2){
- free((void *)mfx->readonly);
- mfx->readonly = strdup("False");
- free((void *)mfx->removable);
- mfx->removable = strdup("False");
- } else if(state == 3){
- free((void *)mfx->readonly);
- mfx->readonly = strdup("False");
- free((void *)mfx->removable);
- mfx->removable = strdup("True");
- }
- }
-
- memset(buffer, 0x00, sizeof(buffer));
- }
-
- if (fp != NULL)
- fclose(fp);
-
- return 0;
-}
-
-static int __check_preload_updated(manifest_x * mfx, const char *manifest)
-{
- char filepath[PKG_STRING_LEN_MAX] = "";
- int ret = 0;
- uiapplication_x *uiapplication = mfx->uiapplication;
-
- if(strstr(manifest, MANIFEST_RO_PREFIX)) {
- /* if preload app is updated, then remove previous desktop file on RW*/
- for(; uiapplication; uiapplication=uiapplication->next) {
- snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
- ret = remove(filepath);
- if (ret <0)
- return -1;
- }
- } else {
- /* if downloaded app is updated, then update tag set true*/
- free((void *)mfx->update);
- mfx->update = strdup("true");
- }
-
- return 0;
-}
-
-
-API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
-{
- int ret = 0;
- if (mfx == NULL) {
- DBG("Manifest pointer is NULL\n");
- return -1;
- }
- ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
- if (ret == -1)
- DBG("Creating desktop file failed\n");
- else
- DBG("Creating desktop file Success\n");
- return ret;
-}
-
-API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
-{
- if (mfx == NULL)
- return;
- if (mfx->ns) {
- free((void *)mfx->ns);
- mfx->ns = NULL;
- }
- if (mfx->package) {
- free((void *)mfx->package);
- mfx->package = NULL;
- }
- if (mfx->version) {
- free((void *)mfx->version);
- mfx->version = NULL;
- }
- if (mfx->installlocation) {
- free((void *)mfx->installlocation);
- mfx->installlocation = NULL;
- }
- if (mfx->preload) {
- free((void *)mfx->preload);
- mfx->preload = NULL;
- }
- if (mfx->readonly) {
- free((void *)mfx->readonly);
- mfx->readonly = NULL;
- }
- if (mfx->removable) {
- free((void *)mfx->removable);
- mfx->removable = NULL;
- }
- if (mfx->update) {
- free((void *)mfx->update);
- mfx->update = NULL;
- }
- if (mfx->type) {
- free((void *)mfx->type);
- mfx->type = NULL;
- }
- if (mfx->package_size) {
- free((void *)mfx->package_size);
- mfx->package_size = NULL;
- }
- if (mfx->installed_time) {
- free((void *)mfx->installed_time);
- mfx->installed_time = NULL;
- }
- if (mfx->installed_storage) {
- free((void *)mfx->installed_storage);
- mfx->installed_storage = NULL;
- }
- if (mfx->storeclient_id) {
- free((void *)mfx->storeclient_id);
- mfx->storeclient_id = NULL;
- }
- if (mfx->mainapp_id) {
- free((void *)mfx->mainapp_id);
- mfx->mainapp_id = NULL;
- }
- if (mfx->package_url) {
- free((void *)mfx->package_url);
- mfx->package_url = NULL;
- }
- if (mfx->root_path) {
- free((void *)mfx->root_path);
- mfx->root_path = NULL;
- }
- if (mfx->csc_path) {
- free((void *)mfx->csc_path);
- mfx->csc_path = NULL;
- }
- if (mfx->appsetting) {
- free((void *)mfx->appsetting);
- mfx->appsetting = NULL;
- }
- if (mfx->nodisplay_setting) {
- free((void *)mfx->nodisplay_setting);
- mfx->nodisplay_setting = NULL;
- }
-
- /*Free Icon*/
- if (mfx->icon) {
- icon_x *icon = mfx->icon;
- icon_x *tmp = NULL;
- while(icon != NULL) {
- tmp = icon->next;
- __ps_free_icon(icon);
- icon = tmp;
- }
- }
- /*Free Label*/
- if (mfx->label) {
- label_x *label = mfx->label;
- label_x *tmp = NULL;
- while(label != NULL) {
- tmp = label->next;
- __ps_free_label(label);
- label = tmp;
- }
- }
- /*Free Author*/
- if (mfx->author) {
- author_x *author = mfx->author;
- author_x *tmp = NULL;
- while(author != NULL) {
- tmp = author->next;
- __ps_free_author(author);
- author = tmp;
- }
- }
- /*Free Description*/
- if (mfx->description) {
- description_x *description = mfx->description;
- description_x *tmp = NULL;
- while(description != NULL) {
- tmp = description->next;
- __ps_free_description(description);
- description = tmp;
- }
- }
- /*Free License*/
- if (mfx->license) {
- license_x *license = mfx->license;
- license_x *tmp = NULL;
- while(license != NULL) {
- tmp = license->next;
- __ps_free_license(license);
- license = tmp;
- }
- }
- /*Free Privileges*/
- if (mfx->privileges) {
- privileges_x *privileges = mfx->privileges;
- privileges_x *tmp = NULL;
- while(privileges != NULL) {
- tmp = privileges->next;
- __ps_free_privileges(privileges);
- privileges = tmp;
- }
- }
- /*Free UiApplication*/
- if (mfx->uiapplication) {
- uiapplication_x *uiapplication = mfx->uiapplication;
- uiapplication_x *tmp = NULL;
- while(uiapplication != NULL) {
- tmp = uiapplication->next;
- __ps_free_uiapplication(uiapplication);
- uiapplication = tmp;
- }
- }
- /*Free ServiceApplication*/
- if (mfx->serviceapplication) {
- serviceapplication_x *serviceapplication = mfx->serviceapplication;
- serviceapplication_x *tmp = NULL;
- while(serviceapplication != NULL) {
- tmp = serviceapplication->next;
- __ps_free_serviceapplication(serviceapplication);
- serviceapplication = tmp;
- }
- }
- /*Free Daemon*/
- if (mfx->daemon) {
- daemon_x *daemon = mfx->daemon;
- daemon_x *tmp = NULL;
- while(daemon != NULL) {
- tmp = daemon->next;
- __ps_free_daemon(daemon);
- daemon = tmp;
- }
- }
- /*Free Theme*/
- if (mfx->theme) {
- theme_x *theme = mfx->theme;
- theme_x *tmp = NULL;
- while(theme != NULL) {
- tmp = theme->next;
- __ps_free_theme(theme);
- theme = tmp;
- }