enum widget_tag {
TAG_WIDGET_APPLICATION = 1,
+ TAG_COMPONENT_BASED_APPLICATION,
+ TAG_WIDGET_COMPONENT,
TAG_WIDGET_CLASS,
TAG_LABEL,
TAG_ICON,
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 },
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");
}
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;
}
}