]> www.infradead.org Git - users/dwmw2/ews-sync.git/commitdiff
Add absolute annual recurrence rules
authorDavid Woodhouse <dwmw2@infradead.org>
Sat, 17 Jul 2010 15:39:20 +0000 (16:39 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Sat, 17 Jul 2010 15:39:20 +0000 (16:39 +0100)
ews2ical.c

index db39b2d5dd242b98b81f54231ee573d5e27bb1a1..a8a448060df9d3618acb10778c72c9839fd3ac38 100644 (file)
@@ -304,12 +304,19 @@ int process_subject(xmlNode *xml_node)
        return 0;
 }
 
+char *months[] = {
+       "January", "February", "March", "April", "May", "June", "July", 
+       "August", "September", "October", "November", "December"
+};
+
 int process_recurrence(xmlNode *xml_node)
 {
        xmlNode *xml_node2;
        const char *weekly_interval = NULL;
        const char *weekday = NULL;
        const char *end_date = NULL;
+       const char *day_of_month = NULL;
+       const char *month = NULL;
 
        for (xml_node = xml_node->children; xml_node; xml_node = xml_node->next) {
                if (xml_node->type != XML_ELEMENT_NODE)
@@ -324,6 +331,16 @@ int process_recurrence(xmlNode *xml_node)
                                else if (!strcmp((char *)xml_node2->name, "DaysOfWeek"))
                                        weekday = (char *)xmlNodeGetContent(xml_node2);
                        }
+               } else if (!strcmp((char *)xml_node->name, "AbsoluteYearlyRecurrence")) {
+                       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, "DayOfMonth"))
+                                       day_of_month = (char *)xmlNodeGetContent(xml_node2);
+                               else if (!strcmp((char *)xml_node2->name, "Month"))
+                                       month = (char *)xmlNodeGetContent(xml_node2);
+                       }
                } else if (!strcmp((char *)xml_node->name, "EndDateRecurrence")) {
                        for (xml_node2 = xml_node->children; xml_node2;
                             xml_node2 = xml_node2->next) {
@@ -334,7 +351,18 @@ int process_recurrence(xmlNode *xml_node)
                        }
                }
        }
-       if (weekly_interval && weekday) {
+       if (day_of_month && month) {
+               int monthnr;
+               for (monthnr = 0; monthnr < 12; monthnr++)
+                       if (!strcmp(month, months[monthnr]))
+                               break;
+               if (monthnr == 12) {
+                       fprintf(stderr, "Unrecognised month name '%s'\n", month);
+                       return -1;
+               }
+               fprintf(calfile, "RRULE;FREQ=YEARLY;BYMONTH=%d;BYMONTHDAY=%s\n",
+                       monthnr+1, day_of_month);
+       } else if (weekly_interval && weekday) {
                char day[3];
                day[0] = toupper(weekday[0]);
                day[1] = toupper(weekday[1]);