]> code.citadel.org Git - citadel.git/blobdiff - webcit/calendar_tools.c
* Calendar objects UID now generated by generate_uuid() which creates
[citadel.git] / webcit / calendar_tools.c
index 74e19970d6f8aa8cd60e9e49e8aeb7e5f8230c84..713a7feb046990b3ee705faeccca300c977cef83 100644 (file)
@@ -65,23 +65,27 @@ char *hourname[] = {
 
 void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
        int i;
-
        time_t now;
        struct tm tm_now;
        int this_year;
-
        time_t tt;
        struct tm tm;
-
        const int span = 10;
+       int all_day_event = 0;
 
        now = time(NULL);
-       memcpy(&tm_now, localtime(&now), sizeof(struct tm));
+       localtime_r(&now, &tm_now);
        this_year = tm_now.tm_year + 1900;
 
        if (t == NULL) return;
+       if (t->is_date) all_day_event = 1;
        tt = icaltime_as_timet(*t);
-       memcpy(&tm, localtime(&tt), sizeof(struct tm));
+       if (all_day_event) {
+               gmtime_r(&tt, &tm);
+       }
+       else {
+               localtime_r(&tt, &tm);
+       }
 
        wprintf("Month: ");
        wprintf("<SELECT NAME=\"%s_month\" SIZE=\"1\">\n", prefix);
@@ -153,7 +157,7 @@ struct icaltimetype icaltime_from_webform(char *prefix) {
        char vname[SIZ];
 
        tt = time(NULL);
-       memcpy(&tm, localtime(&tt), sizeof(struct tm));
+       localtime_r(&tt, &tm);
 
        sprintf(vname, "%s_month", prefix);     tm.tm_mon = atoi(bstr(vname)) - 1;
        sprintf(vname, "%s_day", prefix);       tm.tm_mday = atoi(bstr(vname));
@@ -168,18 +172,6 @@ struct icaltimetype icaltime_from_webform(char *prefix) {
 }
 
 
-/*
- * Generae a new, globally unique UID parameter for a calendar object.
- */
-void generate_new_uid(char *buf) {
-       static int seq = 0;
-
-       sprintf(buf, "%ld-%d@%s",
-               (long)time(NULL),
-               (seq++),
-               serv_info.serv_fqdn);
-}
-
 /*
  * Render a PARTSTAT parameter as a string (and put it in parentheses)
  */
@@ -252,7 +244,6 @@ icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) {
        }
 
        /* Encapsulate the VEVENT component into a complete VCALENDAR */
-       lprintf(9, "Creating new calendar component\n");
        encaps = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
        if (encaps == NULL) {
                lprintf(3, "Error at %s:%d - could not allocate component!\n",
@@ -268,24 +259,14 @@ icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) {
 
        /* Encapsulate the subcomponent inside */
        lprintf(9, "Doing the encapsulation\n");
-
-       lprintf(9, "Here's what we've got so far:\n-----%s\n-----\n",
-               icalcomponent_as_ical_string(encaps)
-       );
-       lprintf(9, "Here's what we want to insert:\n-----%s\n-----\n",
-               icalcomponent_as_ical_string(subcomp)
-       );
-
        icalcomponent_add_component(encaps, subcomp);
 
        /* Convert all timestamps to UTC so we don't have to deal with
         * stupid VTIMEZONE crap.
         */
-       lprintf(9, "Dezonifying it all\n");
        ical_dezonify(encaps);
 
        /* Return the object we just created. */
-       lprintf(9, "...done!\n");
        return(encaps);
 }