Add parser for widget component for widget db 17/250717/2
authorSukHyung, Kang <shine.kang@samsung.com>
Mon, 4 Jan 2021 05:03:17 +0000 (14:03 +0900)
committerSukHyung, Kang <shine.kang@samsung.com>
Mon, 4 Jan 2021 05:47:04 +0000 (14:47 +0900)
Change-Id: I53c4316c828ea10a965f6d56b6580804024ec6c7
Signed-off-by: SukHyung, Kang <shine.kang@samsung.com>
parser/widget.info
parser/widget_plugin_parser.c

index 1b949be..f229ac4 100644 (file)
@@ -1 +1,2 @@
 type="tag";name="widget-application";path="/etc/package-manager/parserlib/libwidget-application.so";vitalness="true"
+type="tag";name="component-based-application";path="/etc/package-manager/parserlib/libwidget-application.so";vitalness="true"
index 4b66b6c..1855a6a 100644 (file)
@@ -29,6 +29,8 @@
 
 enum widget_tag {
        TAG_WIDGET_APPLICATION = 1,
+       TAG_COMPONENT_BASED_APPLICATION,
+       TAG_WIDGET_COMPONENT,
        TAG_WIDGET_CLASS,
        TAG_LABEL,
        TAG_ICON,
@@ -42,6 +44,8 @@ struct tag_map {
 
 struct tag_map map[] = {
        { "widget-application", TAG_WIDGET_APPLICATION },
+       { "component-based-application", TAG_COMPONENT_BASED_APPLICATION },
+       { "widget-component", TAG_WIDGET_COMPONENT },
        { "widget-class", TAG_WIDGET_CLASS },
        { "label", TAG_LABEL },
        { "icon", TAG_ICON },
@@ -321,11 +325,93 @@ static int _parse_widget_application(xmlNode *node, GList **list)
        return 0;
 }
 
+static int _parse_widget_component(xmlNode *node, const char *appid,
+               GList **list)
+{
+       char *val;
+       xmlNode *tmp;
+       struct widget_class *wc;
+       char buf[128];
+
+       wc = calloc(1, sizeof(struct widget_class));
+       if (wc == NULL)
+               return -1;
+
+       wc->appid = strdup(appid);
+
+       val = _get_attribute(node, "id");
+       if (val == NULL) {
+               free(wc->appid);
+               free(wc);
+               return -1;
+       }
+       snprintf(buf, sizeof(buf), "%s@%s", val, appid);
+       free(val);
+       wc->classid = strdup(buf);
+
+       val = _get_attribute(node, "update-period");
+       if (val)
+               wc->update_period = atoi(val);
+       free(val);
+
+       val = _get_attribute(node, "icon-display");
+       if (val && strncmp(val, "true", strlen("true")) == 0)
+               wc->nodisplay = 1;
+       else
+               wc->nodisplay = 0;
+       free(val);
+
+       wc->setup_appid = _get_attribute(node, "setup-appid");
+
+       val = _get_attribute(node, "max-instance");
+       if (val)
+               wc->max_instance = atoi(val);
+       free(val);
+
+       val = _get_attribute(node, "main");
+       if (val && strcmp(val, "true") == 0)
+               wc->prime = 1;
+       else
+               wc->prime = 0;
+       free(val);
+
+       for (tmp = node->children; tmp; tmp = tmp->next) {
+               switch (_get_tag(tmp)) {
+               case TAG_SUPPORT_SIZE:
+                       if (_parse_support_size(tmp, &wc->support_size)) {
+                               _free_widget_class((gpointer)wc);
+                               return -1;
+                       }
+                       break;
+               case TAG_ICON:
+                       if (_parse_icon(tmp, &wc->icon)) {
+                               _free_widget_class((gpointer)wc);
+                               return -1;
+                       }
+                       break;
+               case TAG_LABEL:
+                       if (_parse_label(tmp, &wc->label)) {
+                               _free_widget_class((gpointer)wc);
+                               return -1;
+                       }
+                       break;
+               default:
+                       continue;
+               }
+       }
+
+       *list = g_list_append(*list, wc);
+
+       return 0;
+}
+
 GList *widget_plugin_parser_parse_manifest(xmlDocPtr doc)
 {
        xmlNode *root;
        xmlNode *tmp;
+       xmlNode *tmp_comp;
        GList *list = NULL;
+       char *appid;
 
        if (!tag_table) {
                LOGE("parser is not initialized");
@@ -344,12 +430,32 @@ GList *widget_plugin_parser_parse_manifest(xmlDocPtr doc)
        }
 
        for (tmp = root->children; tmp; tmp = tmp->next) {
-               if (_get_tag(tmp) != TAG_WIDGET_APPLICATION)
+               switch (_get_tag(tmp)) {
+               case TAG_WIDGET_APPLICATION:
+                       if (_parse_widget_application(tmp, &list)) {
+                               LOGE("parse failed");
+                               return NULL;
+                       }
+                       break;
+               case TAG_COMPONENT_BASED_APPLICATION:
+                       for (tmp_comp = tmp->children; tmp_comp; tmp_comp = tmp_comp->next) {
+                               if (_get_tag(tmp_comp) != TAG_WIDGET_COMPONENT)
+                                       continue;
+
+                               appid = _get_attribute(tmp, "appid");
+                               if (appid == NULL)
+                                       return NULL;
+
+                               if (_parse_widget_component(tmp_comp, appid, &list)) {
+                                       LOGE("parse failed");
+                                       free(appid);
+                                       return NULL;
+                               }
+                               free(appid);
+                       }
+                       break;
+               default:
                        continue;
-
-               if (_parse_widget_application(tmp, &list)) {
-                       LOGE("parse failed");
-                       return NULL;
                }
        }