EPublishUri * e_publish_uri_from_xml (const gchar *xml) { xmlDocPtr doc; xmlNodePtr root, p; xmlChar *location, *enabled, *frequency; xmlChar *publish_time, *format, *username = NULL; GSList *events = NULL; EPublishUri *uri; doc = xmlParseDoc ((const unsigned char *)xml); if (doc == NULL) return NULL; root = doc->children; if (strcmp ((char *)root->name, "uri") != 0) return NULL; if ((username = xmlGetProp (root, (const unsigned char *)"username"))) { xmlFree (username); return migrateURI (xml, doc); } uri = g_new0 (EPublishUri, 1); location = xmlGetProp (root, (const unsigned char *)"location"); enabled = xmlGetProp (root, (const unsigned char *)"enabled"); frequency = xmlGetProp (root, (const unsigned char *)"frequency"); format = xmlGetProp (root, (const unsigned char *)"format"); publish_time = xmlGetProp (root, (const unsigned char *)"publish_time"); if (location != NULL) uri->location = (char *)location; if (enabled != NULL) uri->enabled = atoi ((char *)enabled); if (frequency != NULL) uri->publish_frequency = atoi ((char *)frequency); if (format != NULL) uri->publish_format = atoi ((char *)format); if (publish_time != NULL) uri->last_pub_time = (char *)publish_time; uri->password = g_strdup (""); for (p = root->children; p != NULL; p = p->next) { xmlChar *uid = xmlGetProp (p, (const unsigned char *)"uid"); if (strcmp ((char *)p->name, "event") == 0) { events = g_slist_append (events, uid); } else { g_free (uid); } } uri->events = events; xmlFree (enabled); xmlFree (frequency); xmlFree (format); xmlFreeDoc (doc); return uri; }
EPublishUri * e_publish_uri_from_xml (const gchar *xml) { xmlDocPtr doc; xmlNodePtr root, p; xmlChar *location, *enabled, *frequency, *fb_duration_value, *fb_duration_type; xmlChar *publish_time, *format, *username = NULL; GSList *events = NULL; EPublishUri *uri; doc = xmlParseDoc ((const guchar *) xml); if (doc == NULL) return NULL; root = doc->children; if (strcmp ((gchar *) root->name, "uri") != 0) return NULL; if ((username = xmlGetProp (root, (const guchar *)"username"))) { xmlFree (username); return migrateURI (xml, doc); } uri = g_new0 (EPublishUri, 1); location = xmlGetProp (root, (const guchar *)"location"); enabled = xmlGetProp (root, (const guchar *)"enabled"); frequency = xmlGetProp (root, (const guchar *)"frequency"); format = xmlGetProp (root, (const guchar *)"format"); publish_time = xmlGetProp (root, (const guchar *)"publish_time"); fb_duration_value = xmlGetProp (root, (xmlChar *)"fb_duration_value"); fb_duration_type = xmlGetProp (root, (xmlChar *)"fb_duration_type"); if (location != NULL) uri->location = (gchar *) location; if (enabled != NULL) uri->enabled = atoi ((gchar *) enabled); if (frequency != NULL) uri->publish_frequency = atoi ((gchar *) frequency); if (format != NULL) uri->publish_format = atoi ((gchar *) format); if (publish_time != NULL) uri->last_pub_time = (gchar *) publish_time; if (fb_duration_value) uri->fb_duration_value = atoi ((gchar *) fb_duration_value); else uri->fb_duration_value = -1; if (uri->fb_duration_value < 1) uri->fb_duration_value = 6; else if (uri->fb_duration_value > 100) uri->fb_duration_value = 100; if (fb_duration_type && g_str_equal ((gchar *) fb_duration_type, "days")) uri->fb_duration_type = FB_DURATION_DAYS; else if (fb_duration_type && g_str_equal ((gchar *) fb_duration_type, "months")) uri->fb_duration_type = FB_DURATION_MONTHS; else uri->fb_duration_type = FB_DURATION_WEEKS; uri->password = g_strdup (""); for (p = root->children; p != NULL; p = p->next) { xmlChar *uid = xmlGetProp (p, (const guchar *)"uid"); if (strcmp ((gchar *) p->name, "event") == 0) { events = g_slist_append (events, uid); } else { g_free (uid); } } uri->events = events; xmlFree (enabled); xmlFree (frequency); xmlFree (format); xmlFree (fb_duration_value); xmlFree (fb_duration_type); xmlFreeDoc (doc); return uri; }