#endif
#define LOG_TAG "PKGMGR_PARSER"
-#define ASCII(s) (const char *)s
+#define ASCII(s) (char *)s
#define XMLCHAR(s) (const xmlChar *)s
-//#define METADATA_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/metadata/metadata_parser_list.txt"
#define METADATA_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/metadata/mdparser_list.txt"
#define METADATA_PARSER_NAME "metadataparser:"
#define BUFSIZE 4096
#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
-/* operation_type */
-typedef enum {
- ACTION_INSTALL = 0,
- ACTION_UPGRADE,
- ACTION_UNINSTALL,
- ACTION_FOTA,
- ACTION_MAX
-} ACTION_TYPE;
-
/* plugin process_type */
typedef enum {
PLUGIN_PRE_PROCESS = 0,
PLUGIN_POST_PROCESS
} PLUGIN_PROCESS_TYPE;
-typedef struct {
- const char *key;
- const char *value;
-} __metadata_t;
-
-typedef struct {
- const char *name;
-} __category_t;
-
const char *package;
static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
-static int __ps_process_privilege(xmlTextReaderPtr reader, const char **privilege);
+static int __ps_process_privilege(xmlTextReaderPtr reader, char **privilege);
static int __ps_process_privileges(xmlTextReaderPtr reader, GList **privileges);
-static int __ps_process_allowed(xmlTextReaderPtr reader, const char **allowed);
-static int __ps_process_condition(xmlTextReaderPtr reader, const char **condition);
+static int __ps_process_allowed(xmlTextReaderPtr reader, char **allowed);
+static int __ps_process_condition(xmlTextReaderPtr reader, char **condition);
static int __ps_process_notification(xmlTextReaderPtr reader, notification_x *notifiation);
-static int __ps_process_category(xmlTextReaderPtr reader, const char **category);
+static int __ps_process_category(xmlTextReaderPtr reader, char **category);
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_request(xmlTextReaderPtr reader, const char **request);
+static int __ps_process_request(xmlTextReaderPtr reader, char **request);
static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
static int __ps_process_launchconditions(xmlTextReaderPtr reader, GList **launchconditions);
static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
static int __ps_process_appcontrol(xmlTextReaderPtr reader, GList **appcontrol);
static int __ps_process_datacontrol(xmlTextReaderPtr reader, datacontrol_x *datacontrol);
static int __ps_process_application(xmlTextReaderPtr reader, application_x *application, int type, uid_t uid);
-static char *__pkgid_to_manifest(const char *pkgid, uid_t uid);
static int __next_child_element(xmlTextReaderPtr reader, int depth);
static int __start_process(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid);
static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx, uid_t uid);
static void __str_trim(char *input);
static char *__get_parser_plugin(const char *type);
-static int __ps_run_parser(xmlDocPtr docPtr, const char *tag, ACTION_TYPE action, const char *pkgid);
API int __is_admin();
-static void __save_xml_attribute(xmlTextReaderPtr reader, char *attribute, const char **xml_attribute, char *default_value)
+static void __save_xml_attribute(xmlTextReaderPtr reader, char *attribute, 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) {
+ if (default_value != NULL)
*xml_attribute = strdup(default_value);
- }
}
}
-static void __save_xml_lang(xmlTextReaderPtr reader, const char **xml_attribute)
+static void __save_xml_lang(xmlTextReaderPtr reader, char **xml_attribute)
{
const xmlChar *attrib_val = xmlTextReaderConstXmlLang(reader);
if (attrib_val != NULL)
*xml_attribute = strdup(DEFAULT_LOCALE);
}
-static void __save_xml_value(xmlTextReaderPtr reader, const char **xml_attribute)
+static void __save_xml_value(xmlTextReaderPtr reader, char **xml_attribute)
{
xmlTextReaderRead(reader);
const xmlChar *attrib_val = xmlTextReaderConstValue(reader);
mfx->readonly = strdup("False");
mfx->update = strdup("False");
mfx->system = strdup("False");
- mfx->installed_storage= strdup("installed_internal");
+ mfx->installed_storage = strdup("installed_internal");
package = mfx->package;
}
API int __is_admin()
{
uid_t uid = getuid();
- if ((uid_t) 0 == uid )
+ if ((uid_t)0 == uid)
return 1;
else
return 0;
fclose(fp);
if (path == NULL) {
- _LOGE("no matching [%s] [%s]\n", METADATA_PARSER_NAME,type);
+ _LOGE("no matching [%s] [%s]\n", METADATA_PARSER_NAME, type);
return NULL;
}
fclose(fp);
if (path == NULL) {
- _LOGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME,type);
+ _LOGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME, type);
return NULL;
}
if ((metadata_parser_plugin =
dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
- _LOGE("can not find symbol[%s] \n",ac);
+ _LOGE("can not find symbol[%s] \n", ac);
goto END;
}
if ((category_parser_plugin =
dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
- _LOGE("can not find symbol[%s] \n",ac);
+ _LOGE("can not find symbol[%s] \n", ac);
goto END;
}
return ret;
}
-static int __ps_run_parser(xmlDocPtr docPtr, const char *tag,
- ACTION_TYPE action, const char *pkgid)
-{
- char *lib_path = NULL;
- void *lib_handle = NULL;
- int (*plugin_install) (xmlDocPtr, const char *);
- int ret = -1;
- char *ac = NULL;
-
- switch (action) {
- case ACTION_INSTALL:
- ac = "PKGMGR_PARSER_PLUGIN_INSTALL";
- break;
- case ACTION_UPGRADE:
- ac = "PKGMGR_PARSER_PLUGIN_UPGRADE";
- break;
- case ACTION_UNINSTALL:
- ac = "PKGMGR_PARSER_PLUGIN_UNINSTALL";
- break;
- default:
- goto END;
- }
-
- lib_path = __get_parser_plugin(tag);
- if (!lib_path) {
- goto END;
- }
-
- if ((lib_handle = dlopen(lib_path, RTLD_LAZY)) == NULL) {
- _LOGE("dlopen is failed lib_path[%s]\n", lib_path);
- goto END;
- }
- if ((plugin_install =
- dlsym(lib_handle, ac)) == NULL || dlerror() != NULL) {
- _LOGE("can not find symbol[%s] \n", ac);
- goto END;
- }
-
- ret = plugin_install(docPtr, pkgid);
- if (ret < 0)
- _LOGD("[pkgid = %s, libpath = %s plugin fail\n", pkgid, lib_path);
- else
- _LOGD("[pkgid = %s, libpath = %s plugin success\n", pkgid, lib_path);
-
-END:
- if (lib_path)
- free(lib_path);
- if (lib_handle)
- dlclose(lib_handle);
- return ret;
-}
-
-static char *__pkgid_to_manifest(const char *pkgid, uid_t uid)
-{
- char *manifest;
- int size;
-
- if (pkgid == NULL) {
- _LOGE("pkgid is NULL");
- return NULL;
- }
-
- size = strlen(getUserManifestPath(uid)) + strlen(pkgid) + 10;
- manifest = malloc(size);
- if (manifest == NULL) {
- _LOGE("No memory");
- return NULL;
- }
- memset(manifest, '\0', size);
- snprintf(manifest, size, "%s%s.xml", getUserManifestPath(uid), pkgid);
-
- if (access(manifest, F_OK)) {
- snprintf(manifest, size, "%s%s.xml", getUserManifestPath(uid), pkgid);
- }
-
- return manifest;
-}
-
static void __metadata_parser_clear_dir_list(GList* dir_list)
{
GList *list = NULL;
value = xmlTextReaderConstValue(reader);
if (value != NULL) {
- if (xmlStrlen(value) > 40) {
+ if (xmlStrlen(value) > 40)
_LOGD(" %.40s...", value);
- } else {
+ else
_LOGD(" %s", value);
- }
}
name = xmlTextReaderConstName(reader);
if (temp == NULL)
return -1;
xmlNode *next_node = NULL;
- while(cur_node != NULL) {
- if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
- (temp->line == cur_node->line) ) {
+ while (cur_node != NULL) {
+ if ((strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
+ (temp->line == cur_node->line)) {
break;
- }
- else {
+ } else {
next_node = xmlNextElementSibling(cur_node);
xmlUnlinkNode(cur_node);
xmlFreeNode(cur_node);
return ret;
}
-static int __run_metadata_parser_prestep (manifest_x *mfx, char *md_key, ACTION_TYPE action)
+static int __run_metadata_parser_prestep(manifest_x *mfx, char *md_key, ACTION_TYPE action)
{
int ret = -1;
int tag_exist = 0;
md = (metadata_x *)md_tmp->data;
if (md == NULL)
continue;
- //get glist of metadata key and value combination
+ /* get glist of metadata key and value combination */
memset(buffer, 0x00, 1024);
snprintf(buffer, 1024, "%s/", md_key);
if ((md->key && md->value) && (strncmp(md->key, md_key, strlen(md_key)) == 0) && (strncmp(buffer, md->key, strlen(buffer)) == 0)) {
}
}
- //send glist to parser when tags for metadata plugin parser exist.
+ /* send glist to parser when tags for metadata plugin parser exist. */
if (tag_exist) {
ret = __ps_run_metadata_parser(md_list, md_tag, action, mfx->package, app->appid);
- if (ret < 0){
+ if (ret < 0)
_LOGD("metadata_parser failed[%d] for tag[%s]\n", ret, md_tag);
- }
- else{
+ else
_LOGD("metadata_parser success for tag[%s]\n", md_tag);
- }
}
__metadata_parser_clear_dir_list(md_list);
md_list = NULL;
return ret;
}
-static int __run_category_parser_prestep (manifest_x *mfx, char *category_key, ACTION_TYPE action)
+static int __run_category_parser_prestep(manifest_x *mfx, char *category_key, ACTION_TYPE action)
{
int ret = -1;
int tag_exist = 0;
continue;
for (category_tmp = app->category; category_tmp; category_tmp = category_tmp->next) {
category = (const char *)category_tmp->data;
- //get glist of category key and value combination
+ /* get glist of category key and value combination */
memset(buffer, 0x00, 1024);
snprintf(buffer, 1024, "%s/", category_key);
if ((category) && (strncmp(category, category_key, strlen(category_key)) == 0)) {
}
}
- //send glist to parser when tags for metadata plugin parser exist.
+ /* send glist to parser when tags for metadata plugin parser exist. */
if (tag_exist) {
ret = __ps_run_category_parser(category_list, category_tag, action, mfx->package, app->appid);
if (ret < 0)
}
case XML_READER_TYPE_ELEMENT:
{
- // Elements without closing tag don't receive
+ /* Elements without closing tag don't receive */
const xmlChar *elementName =
xmlTextReaderLocalName(reader);
- if (elementName == NULL) {
+ if (elementName == NULL)
break;
- }
if (strcmp(tag, ASCII(elementName)) == 0) {
_LOGD("find : tag[%s] ACTION_TYPE[%d] pkg[%s]\n", tag, action, pkgid);
}
xmlFreeTextReader(reader);
- if (ret != 0) {
+ if (ret != 0)
_LOGD("%s : failed to parse", filename);
- }
} else {
_LOGD("Unable to open %s", filename);
}
int __ps_process_metadata_parser(manifest_x *mfx, ACTION_TYPE action)
{
- fprintf(stdout,"__ps_process_metadata_parser\n");
+ fprintf(stdout, "__ps_process_metadata_parser\n");
int ret = 0;
FILE *fp = NULL;
char md_key[PKG_STRING_LEN_MAX] = { 0 };
return ret;
}
-static int __ps_process_allowed(xmlTextReaderPtr reader, const char **allowed)
+static int __ps_process_allowed(xmlTextReaderPtr reader, char **allowed)
{
__save_xml_value(reader, allowed);
return 0;
}
-static int __ps_process_condition(xmlTextReaderPtr reader, const char **condition)
+static int __ps_process_condition(xmlTextReaderPtr reader, char **condition)
{
__save_xml_attribute(reader, "name", condition, NULL);
return 0;
return 0;
}
-static int __ps_process_category(xmlTextReaderPtr reader, const char **category)
+static int __ps_process_category(xmlTextReaderPtr reader, char **category)
{
__save_xml_attribute(reader, "name", category, NULL);
return 0;
}
-static int __ps_process_privilege(xmlTextReaderPtr reader, const char **privilege)
+static int __ps_process_privilege(xmlTextReaderPtr reader, char **privilege)
{
__save_xml_value(reader, privilege);
return 0;
return 0;
}
-static int __ps_process_request(xmlTextReaderPtr reader, const char **request)
+static int __ps_process_request(xmlTextReaderPtr reader, char **request)
{
__save_xml_value(reader, request);
return 0;
const xmlChar *node;
int ret = -1;
int depth = -1;
- const char *val;
+ char *val;
__save_xml_attribute(reader, "path", &define->path, NULL);
const xmlChar *node;
int ret = -1;
int depth = -1;
- const char *val;
+ char *val;
GList *operations = NULL;
GList *uris = NULL;
GList *mimes = NULL;
const xmlChar *node;
int ret = -1;
int depth = -1;
- const char *val;
+ char *val;
depth = xmlTextReaderDepth(reader);
while ((ret = __next_child_element(reader, depth))) {
const xmlChar *node;
int ret = -1;
int depth = -1;
- const char *val;
+ char *val;
depth = xmlTextReaderDepth(reader);
while ((ret = __next_child_element(reader, depth))) {
const xmlChar *node;
int ret = -1;
int depth = -1;
- const char *val;
+ char *val;
depth = xmlTextReaderDepth(reader);
while ((ret = __next_child_element(reader, depth))) {
node = xmlTextReaderConstName(reader);
return strdup(icon);
do {
- snprintf(icon_with_path, sizeof(icon_with_path), "%s%s",
- getIconPath(uid), icon);
- if (access(icon_with_path, F_OK) == 0)
- break;
+ if (uid == GLOBAL_USER || uid == OWNER_ROOT) {
+ snprintf(icon_with_path, sizeof(icon_with_path),
+ "%s%s", getIconPath(uid, true), icon);
+ if (access(icon_with_path, F_OK) == 0)
+ break;
- /* for backward compatibility (.../default/small/...)
- * this should be removed
- */
- snprintf(icon_with_path, sizeof(icon_with_path),
+ snprintf(icon_with_path, sizeof(icon_with_path),
+ "%s%s", getIconPath(uid, false), icon);
+ if (access(icon_with_path, F_OK) == 0)
+ break;
+
+ /* for backward compatibility (.../default/small/...)
+ * this should be removed
+ */
+ snprintf(icon_with_path, sizeof(icon_with_path),
"%sdefault/small/%s",
- getIconPath(uid), icon);
- if (access(icon_with_path, F_OK) == 0)
- break;
+ getIconPath(uid, true), icon);
+ if (access(icon_with_path, F_OK) == 0)
+ break;
+
+ snprintf(icon_with_path, sizeof(icon_with_path),
+ "%sdefault/small/%s",
+ getIconPath(uid, false), icon);
+ if (access(icon_with_path, F_OK) == 0)
+ break;
+
+ /* If doesn't exist in case of Global app,
+ * try to get icon directly into app's directory
+ */
+ app_path = tzplatform_getenv(TZ_SYS_RO_APP);
+
+ snprintf(icon_with_path, sizeof(icon_with_path),
+ "%s/%s/%s", app_path, package, icon);
+ if (access(icon_with_path, F_OK) == 0)
+ break;
- if (uid == GLOBAL_USER || uid == OWNER_ROOT) {
app_path = tzplatform_getenv(TZ_SYS_RW_APP);
+
+ snprintf(icon_with_path, sizeof(icon_with_path),
+ "%s/%s/%s", app_path, package, icon);
+ if (access(icon_with_path, F_OK) == 0)
+ break;
} else {
tzplatform_set_user(uid);
app_path = tzplatform_getenv(TZ_USER_APP);
tzplatform_reset_user();
- }
- /* If doesn't exist in case of Global app,
- * try to get icon directly into app's directory
- */
- snprintf(icon_with_path, sizeof(icon_with_path),
+ snprintf(icon_with_path, sizeof(icon_with_path),
"%s/%s/%s", app_path, package, icon);
- if (access(icon_with_path, F_OK) == 0)
- break;
+ if (access(icon_with_path, F_OK) == 0)
+ break;
+ }
/* some preload package has icons at below path */
snprintf(icon_with_path, sizeof(icon_with_path),
char delims[] = "=";
char *ret_result = NULL;
char *tag = NULL;
+ char *ptr = NULL;
if (tagv == NULL)
return;
for (tag = strdup(tagv[0]); tag != NULL; ) {
- ret_result = strtok(tag, delims);
+ ret_result = strtok_r(tag, delims, &ptr);
/*check tag : preload */
if (strcmp(ret_result, "preload") == 0) {
- ret_result = strtok(NULL, delims);
+ ret_result = strtok_r(NULL, delims, &ptr);
if (strcmp(ret_result, "true") == 0) {
free((void *)mfx->preload);
mfx->preload = strdup("true");
}
/*check tag : removable*/
} else if (strcmp(ret_result, "removable") == 0) {
- ret_result = strtok(NULL, delims);
- if (strcmp(ret_result, "true") == 0){
+ ret_result = strtok_r(NULL, delims, &ptr);
+ if (strcmp(ret_result, "true") == 0) {
free((void *)mfx->removable);
mfx->removable = strdup("true");
} else if (strcmp(ret_result, "false") == 0) {
static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon, uid_t uid)
{
- __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);
- const char *text = ASCII(xmlTextReaderValue(reader));
+ char *text = ASCII(xmlTextReaderValue(reader));
if (text) {
- icon->text = (const char *)__get_icon_with_path(text, uid);
- free((void *)text);
+ icon->text = __get_icon_with_path(text, uid);
+ free(text);
}
return 0;
static int __ps_process_image(xmlTextReaderPtr reader, image_x *image)
{
- __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_splashscreen(xmlTextReaderPtr reader, splashscreen_x *splashscreen)
+{
+ __save_xml_attribute(reader, "src", &splashscreen->src, NULL);
+ __save_xml_attribute(reader, "type", &splashscreen->type, NULL);
+ __save_xml_attribute(reader, "dpi", &splashscreen->dpi, NULL);
+ __save_xml_attribute(reader, "orientation", &splashscreen->orientation, NULL);
+ __save_xml_attribute(reader, "indicator-display", &splashscreen->indicatordisplay, NULL);
+ __save_xml_attribute(reader, "app-control-operation", &splashscreen->operation, NULL);
+ __save_xml_attribute(reader, "color-depth", &splashscreen->color_depth, NULL);
+ return 0;
+}
+
+static int __ps_process_splashscreens(xmlTextReaderPtr reader, GList **splashscreens)
+{
+ const xmlChar *node;
+ int ret = -1;
+ int depth = -1;
+ splashscreen_x *splashscreen;
+
+ 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), "splash-screen") == 0) {
+ splashscreen = calloc(1, sizeof(splashscreen_x));
+ if (splashscreen == NULL) {
+ _LOGD("Malloc Failed\n");
+ return -1;
+ }
+ *splashscreens = g_list_append(*splashscreens, splashscreen);
+ ret = __ps_process_splashscreen(reader, splashscreen);
+ } else {
+ return -1;
+ }
+
+ if (ret < 0) {
+ _LOGD("Processing splash-screen failed\n");
+ return ret;
+ }
+ }
+ return 0;
+}
+
static int __ps_process_application(xmlTextReaderPtr reader, application_x *application, int type, uid_t uid)
{
const xmlChar *node;
int ret = -1;
int depth = -1;
- const char *val;
+ char *val;
__save_xml_attribute(reader, "appid", &application->appid, NULL);
retvm_if(application->appid == NULL, PM_PARSER_R_ERROR, "appid cant be NULL, appid field is mandatory\n");
__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");
__save_xml_attribute(reader, "ui-gadget", &application->ui_gadget, "false");
__save_xml_attribute(reader, "auto-restart", &application->autorestart, "false");
__save_xml_attribute(reader, "on-boot", &application->onboot, "false");
-
- application->package= strdup(package);
+ __save_xml_attribute(reader, "splash-screen-display", &application->splash_screen_display, "true");
+
+ application->package = strdup(package);
+ /* overwrite some attributes if the app is widgetapp */
+ if (type == PMINFO_WIDGET_APP || type == PMINFO_WATCH_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");
+ }
+
+ /* hw-acceleration values are changed from use-GL/not-use-GL/use-system-setting to on/off/default */
+ if (strcmp(application->hwacceleration, "use-GL") == 0) {
+ free((void *)application->hwacceleration);
+ application->hwacceleration = strdup("on");
+ } else if (strcmp(application->hwacceleration, "not-use-GL") == 0) {
+ free((void *)application->hwacceleration);
+ application->hwacceleration = strdup("off");
+ } else if (strcmp(application->hwacceleration, "use-system-setting") == 0) {
+ free((void *)application->hwacceleration);
+ application->hwacceleration = strdup("default");
+ }
depth = xmlTextReaderDepth(reader);
while ((ret = __next_child_element(reader, depth))) {
}
application->datacontrol = g_list_append(application->datacontrol, datacontrol);
ret = __ps_process_datacontrol(reader, datacontrol);
+ } else if (!strcmp(ASCII(node), "splash-screens") == 0) {
+ ret = __ps_process_splashscreens(reader, &application->splashscreens);
} else
continue;
if (ret < 0) {
}
mfx->application = g_list_append(mfx->application, application);
ret = __ps_process_application(reader, application, PMINFO_SVC_APP, uid);
+ } else if (!strcmp(ASCII(node), "widget-application")) {
+ application_x *application = calloc(1, sizeof(application_x));
+ if (application == NULL) {
+ _LOGD("Malloc Failed\n");
+ return -1;
+ }
+ mfx->application = g_list_append(mfx->application, application);
+ ret = __ps_process_application(reader, application, PMINFO_WIDGET_APP, uid);
+ } else if (!strcmp(ASCII(node), "watch-application")) {
+ application_x *application = calloc(1, sizeof(application_x));
+ if (application == NULL) {
+ _LOGD("Malloc Failed\n");
+ return -1;
+ }
+ mfx->application = g_list_append(mfx->application, application);
+ ret = __ps_process_application(reader, application, PMINFO_WATCH_APP, uid);
} else if (!strcmp(ASCII(node), "icon")) {
icon_x *icon = calloc(1, sizeof(icon_x));
if (icon == NULL) {
__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, "type", &mfx->type, "tpk");
__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");
if (application == NULL)
continue;
ret = appsvc_operation(application->appid, uid);
- if (ret <0)
+ if (ret < 0)
_LOGE("can not operation symbol \n");
}
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))) {
+ if (!strstr(manifest, getUserManifestPath(uid,
+ strcmp(mfx->preload, "true") == 0))) {
/* if downloaded app is updated, then update tag set true*/
if (mfx->update)
free((void *)mfx->update);
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 */
- return 0;
-}
-
-API int pkgmgr_parser_create_usr_desktop_file(manifest_x *mfx, uid_t uid)
-{
- /* desktop file is no longer used */
- return 0;
-}
-
-
API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
{
pkgmgrinfo_basic_free_package((package_x *)mfx);
}
-API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
+DEPRECATED API manifest_x *pkgmgr_parser_process_manifest_xml(const char *manifest)
{
_LOGD("parsing start pkgmgr_parser_process_manifest_xml\n");
xmlTextReaderPtr reader;
}
-API manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
+DEPRECATED API manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *manifest, uid_t uid)
{
_LOGD("parsing start pkgmgr_parser_usr_process_manifest_xml\n");
xmlTextReaderPtr reader;
return pkgmgr_parser_update_tep_info_in_db(pkgid, tep_path);
}
-API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
+DEPRECATED API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
{
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("parsing manifest for installation: %s\n", manifest);
return PMINFO_R_OK;
}
-API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
+
+DEPRECATED API int pkgmgr_parser_parse_usr_manifest_for_installation(const char *manifest, uid_t uid, char *const tagv[])
{
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("parsing manifest for installation: %s\n", manifest);
return PMINFO_R_OK;
}
-API int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx, const char *manifest) {
+API int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx, const char *manifest)
+{
retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("processing manifest_x for installation: %s\n", manifest);
int ret = -1;
- xmlInitParser();
-
- _LOGD("Added preload infomation\n");
-
ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
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");
-
- ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
- if (ret == -1)
- _LOGD("Creating category parser failed\n");
- xmlCleanupParser();
-
return PMINFO_R_OK;
}
-API int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, const char *manifest, uid_t uid) {
+API int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, const char *manifest, uid_t uid)
+{
retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("processing manifest_x for installation: %s\n", manifest);
int ret = -1;
- xmlInitParser();
ret = pkgmgr_parser_insert_manifest_info_in_usr_db(mfx, uid);
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");
- ret = __ps_process_category_parser(mfx, ACTION_INSTALL);
- if (ret == -1)
- _LOGD("Creating category parser failed\n");
- xmlCleanupParser();
return PMINFO_R_OK;
}
-API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
+DEPRECATED API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
{
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("pkgmgr_parser_parse_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
mfx->csc_path = strdup(csc_path);
}
+ /*Delete from cert table*/
+ ret = pkgmgrinfo_delete_certinfo(mfx->package);
+ if (ret) {
+ _LOGD("Cert Info DB Delete Failed\n");
+ return -1;
+ }
+
ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
retvm_if(ret == PMINFO_R_ERROR, PMINFO_R_ERROR, "DB Insert failed");
__ps_process_tag_parser(mfx, manifest, ACTION_UPGRADE);
ret = __ps_process_metadata_parser(mfx, ACTION_UPGRADE);
- if (ret == -1){
+ 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");
return PMINFO_R_OK;
}
-API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
+DEPRECATED API int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest, uid_t uid, char *const tagv[])
{
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD(" pkgmgr_parser_parse_usr_manifest_for_upgrade parsing manifest for upgradation: %s\n", manifest);
mfx->csc_path = strdup(csc_path);
}
+ /*Delete from cert table*/
+ ret = pkgmgrinfo_delete_certinfo(mfx->package);
+ if (ret) {
+ _LOGD("Cert Info DB Delete Failed\n");
+ return -1;
+ }
+
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");
return PMINFO_R_OK;
}
-API int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest) {
+API int pkgmgr_parser_process_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest)
+{
retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
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;
-
- xmlInitParser();
-
- ret = pkgmgrinfo_pkginfo_get_pkginfo(mfx->package, &handle);
- if (ret != PMINFO_R_OK)
- _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
-
- ret = pkgmgrinfo_pkginfo_is_system(handle, &system);
- if (ret != PMINFO_R_OK)
- _LOGD("pkgmgrinfo_pkginfo_is_system failed\n");
- if (system) {
- free((void *)mfx->system);
- mfx->system = strdup("true");
- }
-
- ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
- if (ret != PMINFO_R_OK)
- _LOGD("pkgmgrinfo_pkginfo_get_csc_path failed\n");
-
- if (csc_path != NULL) {
- if (mfx->csc_path)
- free((void *)mfx->csc_path);
- mfx->csc_path = strdup(csc_path);
- }
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");
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- xmlCleanupParser();
-
return PMINFO_R_OK;
}
-API int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest, uid_t uid) {
+API int pkgmgr_parser_process_usr_manifest_x_for_upgrade(manifest_x* mfx, const char *manifest, uid_t uid)
+{
retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD(" pkgmgr_parser_process_usr_manifest_x_for_upgrade parsing manifest for upgradation: %s\n", manifest);
int ret = -1;
- pkgmgrinfo_pkginfo_h handle = NULL;
-
- xmlInitParser();
-
- ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(mfx->package, uid, &handle);
- if (ret != PMINFO_R_OK)
- _LOGD("pkgmgrinfo_pkginfo_get_pkginfo failed\n");
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");
- __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");
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- xmlCleanupParser();
-
return PMINFO_R_OK;
}
__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");
if (ret == -1)
_LOGD("Creating category parser failed\n");
+ /*Delete from cert table*/
+ ret = pkgmgrinfo_delete_certinfo(mfx->package);
+ if (ret) {
+ _LOGD("Cert Info DB Delete Failed\n");
+ return -1;
+ }
+
ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
if (ret == -1)
_LOGD("DB Delete failed\n");
if (ret == -1)
_LOGD("Creating category parser failed\n");
+ /*Delete from cert table*/
+ ret = pkgmgrinfo_delete_certinfo(mfx->package);
+ if (ret) {
+ _LOGD("Cert Info DB Delete Failed\n");
+ return -1;
+ }
+
ret = pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, uid);
if (ret == -1)
_LOGD("DB Delete failed\n");
return PMINFO_R_OK;
}
-API int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest) {
+API int pkgmgr_parser_process_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest)
+{
retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("processing manifest_x for uninstallation: %s\n", manifest);
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");
-
- ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
- if (ret == -1)
- _LOGD("Creating category parser failed\n");
-
ret = pkgmgr_parser_delete_manifest_info_from_db(mfx);
if (ret == -1)
_LOGD("DB Delete failed\n");
else
_LOGD("DB Delete Success\n");
- xmlCleanupParser();
return PMINFO_R_OK;
}
-API int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest, uid_t uid) {
+API int pkgmgr_parser_process_usr_manifest_x_for_uninstallation(manifest_x* mfx, const char *manifest, uid_t uid)
+{
retvm_if(mfx == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
_LOGD("processing manifest_x for uninstallation: %s\n", manifest);
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");
-
- ret = __ps_process_category_parser(mfx, ACTION_UNINSTALL);
- if (ret == -1)
- _LOGD("Creating category parser failed\n");
ret = pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, uid);
if (ret == -1)
_LOGD("Removing appsvc_db failed\n");
else
_LOGD("Removing appsvc_db Success\n");
- xmlCleanupParser();
return PMINFO_R_OK;
}
-API int pkgmgr_parser_parse_manifest_for_preload()
-{
- return pkgmgr_parser_update_preload_info_in_db();
-}
-
-API int pkgmgr_parser_parse_usr_manifest_for_preload(uid_t uid)
-{
- return pkgmgr_parser_update_preload_info_in_usr_db(uid);
-}
-
-
-API char *pkgmgr_parser_get_usr_manifest_file(const char *pkgid, uid_t uid)
-{
- return __pkgid_to_manifest(pkgid, uid);
-}
-
-API char *pkgmgr_parser_get_manifest_file(const char *pkgid)
-{
- return __pkgid_to_manifest(pkgid, GLOBAL_USER);
-}
-
-API int pkgmgr_parser_run_parser_for_installation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
-{
- return __ps_run_parser(docPtr, tag, ACTION_INSTALL, pkgid);
-}
-
-API int pkgmgr_parser_run_parser_for_upgrade(xmlDocPtr docPtr, const char *tag, const char *pkgid)
-{
- return __ps_run_parser(docPtr, tag, ACTION_UPGRADE, pkgid);
-}
-
-API int pkgmgr_parser_run_parser_for_uninstallation(xmlDocPtr docPtr, const char *tag, const char *pkgid)
-{
- return __ps_run_parser(docPtr, tag, ACTION_UNINSTALL, pkgid);
-}
-
#define SCHEMA_FILE SYSCONFDIR "/package-manager/preload/manifest.xsd"
-#if 1
API int pkgmgr_parser_check_manifest_validation(const char *manifest)
{
if (manifest == NULL) {
_LOGE("xmlSchemaValidateFile() failed\n");
return PMINFO_R_ERROR;
} else if (ret == 0) {
- _LOGE("Manifest is Valid\n");
+ _LOGD("Manifest is Valid\n");
return PMINFO_R_OK;
} else {
_LOGE("Manifest Validation Failed with error code %d\n", ret);
return PMINFO_R_OK;
}
-#else
-API int pkgmgr_parser_check_manifest_validation(const char *manifest)
-{
- int err = 0;
- int status = 0;
- pid_t pid;
-
- pid = fork();
-
- switch (pid) {
- case -1:
- _LOGE("fork failed\n");
- return -1;
- case 0:
- /* child */
- {
- int dev_null_fd = open ("/dev/null", O_RDWR);
- if (dev_null_fd >= 0)
- {
- dup2 (dev_null_fd, 0);/*stdin*/
- dup2 (dev_null_fd, 1);/*stdout*/
- dup2 (dev_null_fd, 2);/*stderr*/
- }
-
- if (execl("/usr/bin/xmllint", "xmllint", manifest, "--schema",
- SCHEMA_FILE, NULL) < 0) {
- _LOGE("execl error\n");
- }
-
- _exit(100);
- }
- default:
- /* parent */
- break;
- }
-
- while ((err = waitpid(pid, &status, WNOHANG)) != pid) {
- if (err < 0) {
- if (errno == EINTR)
- continue;
- _LOGE("waitpid failed\n");
- return -1;
- }
- }
-
-
- if(WIFEXITED(status) && !WEXITSTATUS(status))
- return 0;
- else
- return -1;
-}
-#endif