Fix the exception about getting effectimage
[platform/core/appfw/pkgmgr-info.git] / parser / pkgmgr_parser.c
index 64c0e84..b672cf3 100644 (file)
@@ -1644,7 +1644,7 @@ static int __ps_process_application(xmlTextReaderPtr reader, application_x *appl
        __save_xml_attribute(reader, "landscape-effectimage", &application->landscapeimg, NULL);
        __save_xml_attribute(reader, "guestmode-visibility", &application->guestmode_visibility, "true");
        __save_xml_attribute(reader, "permission-type", &application->permission_type, "normal");
-       __save_xml_attribute(reader, "component-type", &application->component_type, type == PMINFO_UI_APP ? "uiapp" : "svcapp");
+       __save_xml_attribute(reader, "component-type", &application->component_type, type == PMINFO_UI_APP ? "uiapp" : type == PMINFO_SVC_APP ? "svcapp" : "widgetapp");
        /*component_type has "svcapp" or "uiapp", if it is not, parsing manifest is fail*/
        retvm_if(((strcmp(application->component_type, "svcapp") != 0) && (strcmp(application->component_type, "uiapp") != 0) && (strcmp(application->component_type, "widgetapp") != 0)), PM_PARSER_R_ERROR, "invalid component_type[%s]", application->component_type);
        __save_xml_attribute(reader, "submode", &application->submode, "false");
@@ -1656,6 +1656,19 @@ static int __ps_process_application(xmlTextReaderPtr reader, application_x *appl
        __save_xml_attribute(reader, "on-boot", &application->onboot, "false");
 
        application->package= strdup(package);
+       /* overwrite some attributes if the app is widgetapp */
+       if (type == PMINFO_WIDGET_APP) {
+               free((void *)application->nodisplay);
+               application->nodisplay = strdup("true");
+               free((void *)application->multiple);
+               application->multiple = strdup("true");
+               free((void *)application->type);
+               application->type = strdup("capp");
+               free((void *)application->taskmanage);
+               application->taskmanage = strdup("false");
+               free((void *)application->indicatordisplay);
+               application->indicatordisplay = strdup("false");
+       }
 
        depth = xmlTextReaderDepth(reader);
        while ((ret = __next_child_element(reader, depth))) {
@@ -1822,7 +1835,7 @@ static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid)
                                return -1;
                        }
                        mfx->application = g_list_append(mfx->application, application);
-                       ret = __ps_process_application(reader, application, PMINFO_UI_APP, uid);
+                       ret = __ps_process_application(reader, application, PMINFO_WIDGET_APP, uid);
                } else if (!strcmp(ASCII(node), "icon")) {
                        icon_x *icon = calloc(1, sizeof(icon_x));
                        if (icon == NULL) {
@@ -1944,72 +1957,6 @@ END:
        return ret;
 }
 
-#define PRELOAD_PACKAGE_LIST SYSCONFDIR "/package-manager/preload/preload_list.txt"
-static int __add_preload_info(manifest_x * mfx, const char *manifest, uid_t uid)
-{
-       FILE *fp = NULL;
-       char buffer[1024] = { 0 };
-       int state = 0;
-
-       if(strstr(manifest, getUserManifestPath(uid))) {
-               free((void *)mfx->readonly);
-               mfx->readonly = strdup("True");
-
-               free((void *)mfx->preload);
-               mfx->preload = strdup("True");
-
-               free((void *)mfx->removable);
-               mfx->removable = strdup("False");
-
-               free((void *)mfx->system);
-               mfx->system = strdup("True");
-
-               return 0;
-       }
-
-       fp = fopen(PRELOAD_PACKAGE_LIST, "r");
-       if (fp == NULL) {
-               _LOGE("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, uid_t uid)
 {
        if (!strstr(manifest, getUserManifestPath(uid))) {
@@ -2022,51 +1969,6 @@ static int __check_preload_updated(manifest_x * mfx, const char *manifest, uid_t
        return 0;
 }
 
-
-API int pkgmgr_parser_preload_package_type(const char *package)
-{
-       FILE *fp = NULL;
-       char buffer[1024] = { 0 };
-       int state = 0;
-       int ret = PM_PRELOAD_NONE;
-
-       fp = fopen(PRELOAD_PACKAGE_LIST, "r");
-       if (fp == NULL) {
-               _LOGE("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(package, buffer)) {
-                       if(state == 2){
-                               ret = PM_PRELOAD_RW_NORM;
-                               break;
-                       } else if(state == 3){
-                               ret = PM_PRELOAD_RW_RM;
-                               break;
-                       }
-               }
-
-               memset(buffer, 0x00, sizeof(buffer));
-       }
-
-       if (fp != NULL)
-               fclose(fp);
-
-       return ret;
-}
-
 API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
 {
        /* desktop file is no longer used */
@@ -2235,7 +2137,6 @@ API int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx, const
        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");
@@ -2259,7 +2160,6 @@ API int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, c
        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");
@@ -2411,7 +2311,6 @@ API int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx, const char
        retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
        _LOGD("pkgmgr_parser_process_manifest_x_for_upgrade  parsing manifest for upgradation: %s\n", manifest);
        int ret = -1;
-       bool preload = false;
        bool system = false;
        char *csc_path = NULL;
        pkgmgrinfo_pkginfo_h handle = NULL;
@@ -2444,7 +2343,6 @@ API int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx, const char
        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");
@@ -2475,7 +2373,6 @@ API int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, const
        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");
@@ -2503,9 +2400,6 @@ API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, ch
 
        __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
 
-       __add_preload_info(mfx, manifest, GLOBAL_USER);
-       _LOGD("Added preload infomation\n");
-
        ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
        if (ret == -1)
                _LOGD("Removing metadata parser failed\n");
@@ -2577,7 +2471,6 @@ API int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx, con
 
        int ret = -1;
        xmlInitParser();
-       __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
 
        ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
        if (ret == -1)
@@ -2605,8 +2498,6 @@ API int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x* mfx,
        int ret = -1;
        xmlInitParser();
 
-       __ps_process_tag_parser(mfx, manifest, ACTION_UNINSTALL);
-
        ret = __ps_process_metadata_parser(mfx, ACTION_UNINSTALL);
        if (ret == -1)
                _LOGD("Removing metadata parser failed\n");