#include <libxml/xmlschemas.h>
#include <vconf.h>
-
#include "pkgmgr_parser.h"
#include "pkgmgr_parser_internal.h"
#include "pkgmgr_parser_db.h"
int (*plugin_install) (xmlDocPtr, const char *);
int ret = -1;
char *ac = NULL;
- int cpid = -1;
- int status = 0;
- int w = 0;
switch (action) {
case ACTION_INSTALL:
if (!lib_path) {
goto END;
}
- /*fork a child*/
- cpid = fork();
- switch (cpid) {
- case -1:
- DBGE("fork() failed\n");
+
+ if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
+ DBGE("dlopen is failed lib_path[%s]\n", lib_path);
goto END;
- case 0:
- /*child process*/
- if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
- DBGE("dlopen is failed lib_path[%s]\n", lib_path);
- exit(-1);
- }
- if ((plugin_install =
- dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
- DBGE("can not find symbol \n");
- if (lib_handle)
- dlclose(lib_handle);
- exit(-1);
- }
- ret = plugin_install(docPtr, pkgid);
- if (lib_handle)
- dlclose(lib_handle);
- exit(ret);
- default:
- /*parent process*/
- do {
- w = waitpid(cpid, &status, WUNTRACED | WCONTINUED);
- if (w == -1) {
- DBGE("waitpid() failed\n");
- break;
- }
- } while (!WIFEXITED(status) && !WIFSIGNALED(status));
- if (WIFEXITED(status))
- ret = WEXITSTATUS(status);
- else if (WIFSIGNALED(status))
- ret = WTERMSIG(status);
- else
- ret = 0;
- DBGE("Child exit status=%d\n", ret);
- break;
}
+ if ((plugin_install =
+ dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
+ DBGE("can not find symbol \n");
+ goto END;
+ }
+
+ ret = plugin_install(docPtr, pkgid);
+
END:
if (lib_path)
free(lib_path);
+ if (lib_handle)
+ dlclose(lib_handle);
return ret;
}
free((void *)uiapplication->package);
uiapplication->package = NULL;
}
+ if (uiapplication->launchcondition) {
+ free((void *)uiapplication->launchcondition);
+ uiapplication->launchcondition = NULL;
+ }
/*Free Label*/
if (uiapplication->label) {
label_x *label = uiapplication->label;
free((void *)uiapplication->guestmode_visibility);
uiapplication->guestmode_visibility = NULL;
}
+ if (uiapplication->app_component) {
+ free((void *)uiapplication->app_component);
+ uiapplication->app_component = NULL;
+ }
+ if (uiapplication->permission_type) {
+ free((void *)uiapplication->permission_type);
+ uiapplication->permission_type = NULL;
+ }
+
free((void*)uiapplication);
uiapplication = NULL;
}
free((void *)serviceapplication->package);
serviceapplication->package = NULL;
}
+ if (serviceapplication->permission_type) {
+ free((void *)serviceapplication->permission_type);
+ serviceapplication->permission_type = NULL;
+ }
/*Free Label*/
if (serviceapplication->label) {
label_x *label = serviceapplication->label;
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);
}
}
+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)
{
free((void *)uiapplication->appid);
uiapplication->appid = newappid;
}
+ uiapplication->package= strdup(package);
}
if (xmlTextReaderGetAttribute(reader, XMLCHAR("exec")))
uiapplication->exec = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("exec")));
} 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)
} 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");
+ }
depth = xmlTextReaderDepth(reader);
while ((ret = __next_child_element(reader, depth))) {
} 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))) {
} 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");
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);
{
char filepath[PKG_STRING_LEN_MAX] = "";
int ret = 0;
+ uiapplication_x *uiapplication = mfx->uiapplication;
- for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
- snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
+ for(; uiapplication; uiapplication=uiapplication->next) {
+ snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
- __ail_change_info(AIL_REMOVE, mfx->uiapplication->appid);
+ __ail_change_info(AIL_REMOVE, uiapplication->appid);
ret = remove(filepath);
if (ret <0)
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 MANIFEST_RO_PREFIX "/usr/share/packages/"
#define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
static int __add_preload_info(manifest_x * mfx, const char *manifest)
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;
+ }
+
+ return 0;
+ }
+}
API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
{
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) {
API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
{
- char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
+ char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
if (manifest == NULL) {
DBG("argument supplied is NULL\n");
return PMINFO_R_EINVAL;
else
mfx->update = strdup("false");
+ __ps_process_tag(mfx, tagv);
+
ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
if (ret == -1)
DBG("DB Insert failed\n");
API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
{
- char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
+ char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
if (manifest == NULL) {
DBG("argument supplied is NULL\n");
return PMINFO_R_EINVAL;
DBG("parsing manifest for upgradation: %s\n", manifest);
manifest_x *mfx = NULL;
int ret = -1;
+ bool preload;
+ pkgmgrinfo_pkginfo_h handle;
+
xmlInitParser();
mfx = pkgmgr_parser_process_manifest_xml(manifest);
DBG("Parsing Finished\n");
__streamFile(manifest, ACTION_UPGRADE, temp, mfx->package);
__add_preload_info(mfx, manifest);
DBG("Added preload infomation\n");
+ __check_preload_updated(mfx, manifest);
+
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
+ if (ret != PMINFO_R_OK)
+ DBG("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
+
+ ret = pkgmgrinfo_pkginfo_is_preload(handle, &preload);
+ if (ret != PMINFO_R_OK)
+ DBG("pkgmgrinfo_pkginfo_is_preload failed\n");
+
+ if (preload){
+ free((void *)mfx->preload);
+ mfx->preload = strdup("true");
+ }
mfx->update = strdup("true");
ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
else
DBG("Creating desktop file Success\n");
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
pkgmgr_parser_free_manifest_xml(mfx);
DBG("Free Done\n");
xmlCleanupParser();
API int pkgmgr_parser_parse_manifest_for_uninstallation(const char *manifest, char *const tagv[])
{
- char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", NULL};
+ char *temp[] = {"shortcut-list", "livebox", "account", "notifications", "privileges", "ime", "font", NULL};
if (manifest == NULL) {
DBG("argument supplied is NULL\n");
return PMINFO_R_EINVAL;
else
DBG("Removing desktop file Success\n");
+ ret = __ps_remove_appsvc_db(mfx);
+ if (ret == -1)
+ DBG("Removing appsvc_db failed\n");
+ else
+ DBG("Removing appsvc_db Success\n");
+
pkgmgr_parser_free_manifest_xml(mfx);
DBG("Free Done\n");
xmlCleanupParser();