]> www.infradead.org Git - users/dwmw2/ews-sync.git/commitdiff
Test hack for recursion for modified appointments
authorDavid Woodhouse <dwmw2@infradead.org>
Thu, 22 Jul 2010 13:23:18 +0000 (14:23 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Thu, 22 Jul 2010 13:23:18 +0000 (14:23 +0100)
ews2ical.c

index 9d9a6d2634e70329d3da0f21dcdcc21c90c08d1a..b46b2ac983c5b11cd1d7610006bdf8dcaf79ce03 100644 (file)
 
 #include "libews.h"
 
-icalcomponent *fetch_item(int xmlfd, GError **error);
+icalcomponent *fetch_item(int xmlfd, const char *parent_id, icaltimezone *zone, GError **error);
+
+icalcomponent *(hack_fetch_subitem)(void *priv,
+                                   const gchar *item_id,
+                                   const gchar *parent_id,
+                                   icaltimezone *zone,
+                                   GError **error);
 
 int main(int argc, char **argv)
 {
@@ -51,7 +57,7 @@ int main(int argc, char **argv)
                fprintf(stderr, "Too many args. Want only xml file and ical file\n");
                return -1;
        }
-       calcomp = fetch_item(xmlfd, &error);
+       calcomp = fetch_item(xmlfd, NULL, NULL, &error);
 
        if (!calcomp) {
                fprintf(stderr, "Failed to convert: %s\n", error->message);
@@ -64,7 +70,7 @@ int main(int argc, char **argv)
        return 0;
 }
 
-icalcomponent *fetch_item(int xmlfd, GError **error)
+icalcomponent *fetch_item(int xmlfd, const char *parent_id, icaltimezone *zone, GError **error)
 {
        xmlDocPtr xml_doc;
        xmlNode *xml_node;
@@ -147,6 +153,32 @@ icalcomponent *fetch_item(int xmlfd, GError **error)
                exit(1);
        }
 
-       return ews_calitem_to_ical(xml_node, NULL, NULL, NULL, NULL, error);
+       return ews_calitem_to_ical(xml_node, parent_id, zone, NULL /*hack_fetch_subitem*/, NULL, error);
 }
 
+
+icalcomponent *(hack_fetch_subitem)(void *priv,
+                                   const gchar *item_id,
+                                   const gchar *parent_id,
+                                   icaltimezone *zone,
+                                   GError **error)
+{
+       icalcomponent *comp;
+
+       int fd = open(item_id, O_RDONLY);
+       if (fd == -1) {
+               g_set_error(error, EWS_ERROR, EWS_ERROR_PARSE,
+                           "Failed to open file '%s'", item_id);
+               return NULL;
+       }
+       comp = fetch_item(fd, parent_id, zone, error);
+#if 0
+       printf("subitem %p\n", comp);
+       if (comp) {
+               char *outbuf =icalcomponent_as_ical_string_r(comp);
+               fprintf(stderr, "%s", outbuf);
+               free(outbuf);
+       }
+#endif
+       return comp;
+}