]> code.citadel.org Git - citadel.git/blobdiff - webcit/calendar_tools.c
* Get ready for the 6.10 release
[citadel.git] / webcit / calendar_tools.c
index 1753a483c96bf3c5e28818581577a987f538bc14..dfc97f3bc3271e52b0ca030cb72a8f595bb29833 100644 (file)
@@ -43,7 +43,7 @@ char *hourname[] = {
        "7pm", "8pm", "9pm", "10pm", "11pm"
 };
 
-#ifdef HAVE_ICAL_H
+#ifdef WEBCIT_WITH_CALENDAR_SERVICE
 
 /*
  * The display_icaltimetype_as_webform() and icaltime_from_webform() functions
@@ -67,27 +67,27 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
        int i;
 
        time_t now;
-       struct tm *tm_now;
+       struct tm tm_now;
        int this_year;
 
        time_t tt;
-       struct tm *tm;
+       struct tm tm;
 
        const int span = 10;
 
        now = time(NULL);
-       tm_now = localtime(&now);
-       this_year = tm_now->tm_year + 1900;
+       memcpy(&tm_now, localtime(&now), sizeof(struct tm));
+       this_year = tm_now.tm_year + 1900;
 
        if (t == NULL) return;
        tt = icaltime_as_timet(*t);
-       tm = localtime(&tt);
+       memcpy(&tm, localtime(&tt), sizeof(struct tm));
 
        wprintf("Month: ");
        wprintf("<SELECT NAME=\"%s_month\" SIZE=\"1\">\n", prefix);
        for (i=0; i<=11; ++i) {
                wprintf("<OPTION %s VALUE=\"%d\">%s</OPTION>\n",
-                       ((tm->tm_mon == i) ? "SELECTED" : ""),
+                       ((tm.tm_mon == i) ? "SELECTED" : ""),
                        i+1,
                        months[i]
                );
@@ -98,7 +98,7 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
        wprintf("<SELECT NAME=\"%s_day\" SIZE=\"1\">\n", prefix);
        for (i=1; i<=31; ++i) {
                wprintf("<OPTION %s VALUE=\"%d\">%d</OPTION>\n",
-                       ((tm->tm_mday == i) ? "SELECTED" : ""),
+                       ((tm.tm_mday == i) ? "SELECTED" : ""),
                        i, i
                );
        }
@@ -126,7 +126,7 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
        wprintf("<SELECT NAME=\"%s_hour\" SIZE=\"1\">\n", prefix);
        for (i=0; i<=23; ++i) {
                wprintf("<OPTION %s VALUE=\"%d\">%s</OPTION>\n",
-                       ((tm->tm_hour == i) ? "SELECTED" : ""),
+                       ((tm.tm_hour == i) ? "SELECTED" : ""),
                        i, hourname[i]
                );
        }
@@ -136,7 +136,7 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
        wprintf("<SELECT NAME=\"%s_minute\" SIZE=\"1\">\n", prefix);
        for (i=0; i<=59; ++i) {
                wprintf("<OPTION %s VALUE=\"%d\">:%02d</OPTION>\n",
-                       ((tm->tm_min == i) ? "SELECTED" : ""),
+                       ((tm.tm_min == i) ? "SELECTED" : ""),
                        i, i
                );
        }
@@ -178,5 +178,54 @@ void generate_new_uid(char *buf) {
                serv_info.serv_fqdn);
 }
 
+/*
+ * Render a PARTSTAT parameter as a string (and put it in parentheses)
+ */
+void partstat_as_string(char *buf, icalproperty *attendee) {
+       icalparameter *partstat_param;
+       icalparameter_partstat partstat;
+
+       strcpy(buf, "(status unknown)");
+
+       partstat_param = icalproperty_get_first_parameter(
+                               attendee,
+                               ICAL_PARTSTAT_PARAMETER
+       );
+       if (partstat_param == NULL) {
+               return;
+       }
+
+       partstat = icalparameter_get_partstat(partstat_param);
+       switch(partstat) {
+               case ICAL_PARTSTAT_X:
+                       strcpy(buf, "(x)");
+                       break;
+               case ICAL_PARTSTAT_NEEDSACTION:
+                       strcpy(buf, "(needs action)");
+                       break;
+               case ICAL_PARTSTAT_ACCEPTED:
+                       strcpy(buf, "(accepted)");
+                       break;
+               case ICAL_PARTSTAT_DECLINED:
+                       strcpy(buf, "(declined)");
+                       break;
+               case ICAL_PARTSTAT_TENTATIVE:
+                       strcpy(buf, "(tenative)");
+                       break;
+               case ICAL_PARTSTAT_DELEGATED:
+                       strcpy(buf, "(delegated)");
+                       break;
+               case ICAL_PARTSTAT_COMPLETED:
+                       strcpy(buf, "(completed)");
+                       break;
+               case ICAL_PARTSTAT_INPROCESS:
+                       strcpy(buf, "(in process)");
+                       break;
+               case ICAL_PARTSTAT_NONE:
+                       strcpy(buf, "(none)");
+                       break;
+       }
+}
+
 
 #endif