]> www.infradead.org Git - users/dwmw2/ews-sync.git/commitdiff
Handle numbered recurrences
authorDavid Woodhouse <dwmw2@infradead.org>
Sat, 17 Jul 2010 16:19:08 +0000 (17:19 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Sat, 17 Jul 2010 16:19:08 +0000 (17:19 +0100)
ews2ical.c

index bcb299222b6f0686fdf0be23b1ec403b5dec2bca..bd3c8835b0dc61fe2092748e871d76fddf1af2ae 100644 (file)
@@ -317,6 +317,7 @@ int process_recurrence(xmlNode *xml_node)
        const char *end_date = NULL;
        const char *day_of_month = NULL;
        const char *month = NULL;
+       const char *nr_recurrences = NULL;
 
        for (xml_node = xml_node->children; xml_node; xml_node = xml_node->next) {
                if (xml_node->type != XML_ELEMENT_NODE)
@@ -349,6 +350,14 @@ int process_recurrence(xmlNode *xml_node)
                                if (!strcmp((char *)xml_node2->name, "EndDate"))
                                        end_date = (char *)xmlNodeGetContent(xml_node2);
                        }
+               } else if (!strcmp((char *)xml_node->name, "NumberedRecurrence")) {
+                       for (xml_node2 = xml_node->children; xml_node2;
+                            xml_node2 = xml_node2->next) {
+                               if (xml_node2->type != XML_ELEMENT_NODE)
+                                       continue;
+                               if (!strcmp((char *)xml_node2->name, "NumberOfOccurrences")) 
+                                       nr_recurrences = (char *)xmlNodeGetContent(xml_node2);
+                       }
                }
        }
        if (day_of_month && month) {
@@ -360,7 +369,7 @@ int process_recurrence(xmlNode *xml_node)
                        fprintf(stderr, "Unrecognised month name '%s'\n", month);
                        return -1;
                }
-               fprintf(calfile, "RRULE:FREQ=YEARLY;BYMONTH=%d;BYMONTHDAY=%s\n",
+               fprintf(calfile, "RRULE:FREQ=YEARLY;BYMONTH=%d;BYMONTHDAY=%s",
                        monthnr+1, day_of_month);
        } else if (weekly_interval && weekday) {
                char day[3];
@@ -370,13 +379,20 @@ int process_recurrence(xmlNode *xml_node)
 
                fprintf(calfile, "RRULE:FREQ=WEEKLY;INTERVAL=%s;BYDAY=%s;WKST=SU",
                        weekly_interval, day);
-               if (end_date)
-                       fprintf(calfile, ";UNTIL=%.4s%.2s%.2sT235959Z",
-                               end_date, end_date + 5, end_date + 8);
-               fputc('\n', calfile);
-               return 0;
+       } else {
+               fprintf(stderr, "Unknown Recurrence type\n");
+               return -1;
        }
-       return -1;
+
+       if (end_date) {
+               fprintf(calfile, ";UNTIL=%.4s%.2s%.2sT235959Z",
+                       end_date, end_date + 5, end_date + 8);
+       } else if (nr_recurrences) {
+               fprintf(calfile, ";COUNT=%s", nr_recurrences);
+       }
+
+       fputc('\n', calfile);
+       return 0;
 }
 
 int process_itemid(xmlNode *xml_node)