Back to index

webcit  8.12-dfsg
Classes | Typedefs | Enumerations | Functions
calendar.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _calview

Typedefs

typedef struct _calview calview
typedef void(* IcalCallbackFunc )(icalcomponent *, long, char *, int, calview *)

Enumerations

enum  {
  calview_month, calview_day, calview_week, calview_brief,
  calview_summary
}

Functions

void display_individual_cal (icalcomponent *cal, long msgnum, char *from, int unread, calview *calv)
void load_ical_object (long msgnum, int unread, icalcomponent_kind which_kind, IcalCallbackFunc CallBack, calview *calv, int RenderAsync)
int calendar_LoadMsgFromServer (SharedMessageStatus *Stat, void **ViewSpecific, message_summary *Msg, int is_new, int i)
int calendar_RenderView_or_Tail (SharedMessageStatus *Stat, void **ViewSpecific, long oper)
int calendar_GetParamsGetServerCall (SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen)
int calendar_Cleanup (void **ViewSpecific)
int __calendar_Cleanup (void **ViewSpecific)
void render_calendar_view (calview *c)
void display_edit_individual_event (icalcomponent *supplied_vtodo, long msgnum, char *from, int unread, calview *calv)
void save_individual_event (icalcomponent *supplied_vtodo, long msgnum, char *from, int unread, calview *calv)
void ical_dezonify (icalcomponent *cal)
int tasks_LoadMsgFromServer (SharedMessageStatus *Stat, void **ViewSpecific, message_summary *Msg, int is_new, int i)
void display_edit_task (void)
void display_edit_event (void)
icaltimezone * get_default_icaltimezone (void)
void display_icaltimetype_as_webform (struct icaltimetype *, char *, int)
void icaltime_from_webform (struct icaltimetype *result, char *prefix)
void icaltime_from_webform_dateonly (struct icaltimetype *result, char *prefix)
void partstat_as_string (char *buf, icalproperty *attendee)
icalcomponent * ical_encapsulate_subcomponent (icalcomponent *subcomp)
void check_attendee_availability (icalcomponent *supplied_vevent)
int ical_ctdl_is_overlap (struct icaltimetype t1start, struct icaltimetype t1end, struct icaltimetype t2start, struct icaltimetype t2end)

Class Documentation

struct _calview

Definition at line 33 of file calendar.h.

Class Members
int day
time_t lower_bound
int month
time_t upper_bound
int view
int year

Typedef Documentation

typedef struct _calview calview
typedef void(* IcalCallbackFunc)(icalcomponent *, long, char *, int, calview *)

Definition at line 42 of file calendar.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
calview_month 
calview_day 
calview_week 
calview_brief 
calview_summary 

Definition at line 25 of file calendar.h.


Function Documentation

int __calendar_Cleanup ( void **  ViewSpecific)

Definition at line 893 of file calendar.c.

{
       calview *c;
       
       c = (calview *) *ViewSpecific;

       free (c);
       *ViewSpecific = NULL;

       return 0;
}

Here is the caller graph for this function:

int calendar_Cleanup ( void **  ViewSpecific)

Definition at line 880 of file calendar.c.

{
       calview *c;
       
       c = (calview *) *ViewSpecific;

       wDumpContent(1);
       free (c);
       *ViewSpecific = NULL;

       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int calendar_GetParamsGetServerCall ( SharedMessageStatus Stat,
void **  ViewSpecific,
long  oper,
char *  cmd,
long  len,
char *  filter,
long  flen 
)

Definition at line 1422 of file calendar_view.c.

{
       wcsession *WCC = WC;
       calview *c;
       time_t now;
       struct tm tm;
       char cv[32];

       int span = 3888000;

       c = (calview*) malloc(sizeof(calview));
       memset(c, 0, sizeof(calview));
       *ViewSpecific = (void*)c;

       Stat->load_seen = 1;
       strcpy(cmd, "MSGS ALL");
       Stat->maxmsgs = 32767;

       /* In case no date was specified, go with today */
       now = time(NULL);
       localtime_r(&now, &tm);
       c->year = tm.tm_year + 1900;
       c->month = tm.tm_mon + 1;
       c->day = tm.tm_mday;

       /* Now see if a date was specified */
       if (havebstr("year")) c->year = ibstr("year");
       if (havebstr("month")) c->month = ibstr("month");
       if (havebstr("day")) c->day = ibstr("day");

       /* How would you like that cooked? */
       if (havebstr("calview")) {
              strcpy(cv, bstr("calview"));
       }
       else {
              strcpy(cv, "month");
       }

       /* Display the selected view */
       if (!strcasecmp(cv, "day")) {
              c->view = calview_day;
       }
       else if (!strcasecmp(cv, "week")) {
              c->view = calview_week;
       }
       else if (!strcasecmp(cv, "summary")) {    /* shouldn't ever happen, but just in case */
              c->view = calview_day;
       }
       else {
              if (WCC->CurRoom.view == VIEW_CALBRIEF) {
                     c->view = calview_brief;
              }
              else {
                     c->view = calview_month;
              }
       }

       /* Now try and set the lower and upper bounds so that we don't
        * burn too many cpu cycles parsing data way in the past or future
        */

       tm.tm_year = c->year - 1900;
       tm.tm_mon = c->month - 1;
       tm.tm_mday = c->day;
       now = mktime(&tm);

       if (c->view == calview_month)      span = 3888000;
       if (c->view == calview_brief)      span = 3888000;
       if (c->view == calview_week)       span = 604800;
       if (c->view == calview_day) span = 86400;
       if (c->view == calview_summary)    span = 86400;

       c->lower_bound = now - span;
       c->upper_bound = now + span;
       return 200;
}

Here is the caller graph for this function:

int calendar_LoadMsgFromServer ( SharedMessageStatus Stat,
void **  ViewSpecific,
message_summary Msg,
int  is_new,
int  i 
)

Definition at line 789 of file calendar.c.

{
       calview *c = (calview*) *ViewSpecific;
       load_ical_object(Msg->msgnum, is_new, (-1), display_individual_cal, c, 1);
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int calendar_RenderView_or_Tail ( SharedMessageStatus Stat,
void **  ViewSpecific,
long  oper 
)

Definition at line 1510 of file calendar_view.c.

{
       wcsession *WCC = WC;
       calview *c = (calview*) *ViewSpecific;

       if (c->view == calview_day) {
              calendar_day_view(c->year, c->month, c->day);
       }
       else if (c->view == calview_week) {
              calendar_week_view(c->year, c->month, c->day);
       }
       else {
              if (WCC->CurRoom.view == VIEW_CALBRIEF) {
                     calendar_brief_month_view(c->year, c->month, c->day);
              }
              else {
                     calendar_month_view(c->year, c->month, c->day);
              }
       }

       /* Free the in-memory list of calendar items */
       DeleteHash(&WC->disp_cal_items);
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void check_attendee_availability ( icalcomponent *  supplied_vevent)

< Convert everything to UTC

screen name or email address

Replace the attendee name with an annotated one.

Definition at line 197 of file availability.c.

                                                        {
       icalproperty *attendee = NULL;
       icalproperty *dtstart_p = NULL;
       icalproperty *dtend_p = NULL;
       struct icaltimetype dtstart_t;
       struct icaltimetype dtend_t;
       char attendee_string[SIZ];
       char annotated_attendee_string[SIZ];
       char annotation[SIZ];
       const char *ch;

       if (vevent == NULL) {
              return;
       }

       /*
        * If we're looking at a fully encapsulated VCALENDAR
        * rather than a VEVENT component, attempt to use the first
        * relevant VEVENT subcomponent.  If there is none, the
        * NULL returned by icalcomponent_get_first_component() will
        * tell the next iteration of this function to create a
        * new one.
        */
       if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
              check_attendee_availability(
                     icalcomponent_get_first_component(
                            vevent, ICAL_VEVENT_COMPONENT
                     )
              );
              return;
       }

       ical_dezonify(vevent);             
       /*
        * Learn the start and end times.
        */
       dtstart_p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY);
       if (dtstart_p != NULL) dtstart_t = icalproperty_get_dtstart(dtstart_p);

       dtend_p = icalcomponent_get_first_property(vevent, ICAL_DTEND_PROPERTY);
       if (dtend_p != NULL) dtend_t = icalproperty_get_dtend(dtend_p);

       /*
        * Iterate through attendees.
        */
       for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY);
           attendee != NULL;
           attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
              ch = icalproperty_get_attendee(attendee);
              if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {

                     safestrncpy(attendee_string, ch + 7, sizeof(attendee_string));
                     striplt(attendee_string);

                     check_individual_attendee(attendee_string,
                                          dtstart_t, dtend_t,
                                          annotation);

                     snprintf(annotated_attendee_string, sizeof annotated_attendee_string,
                            "MAILTO:%s (%s)", attendee_string, annotation);
                     icalproperty_set_attendee(attendee, annotated_attendee_string);

              }
       }

}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_edit_event ( void  )

Definition at line 803 of file calendar.c.

                              {
       long msgnum = 0L;

       msgnum = lbstr("msgnum");
       if (msgnum > 0L) {
              /* existing event */
              load_ical_object(msgnum, 0, ICAL_VEVENT_COMPONENT, display_edit_individual_event, NULL, 0);
       }
       else {
              /* new event */
              display_edit_individual_event(NULL, 0L, "", 0, NULL);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_edit_individual_event ( icalcomponent *  supplied_vtodo,
long  msgnum,
char *  from,
int  unread,
calview calv 
)

Definition at line 24 of file event.c.

{
       icalcomponent *vevent;
       icalproperty *p;
       icalvalue *v;
       struct icaltimetype t_start, t_end;
       time_t now;
       struct tm tm_now;
       int created_new_vevent = 0;
       icalproperty *organizer = NULL;
       char organizer_string[SIZ];
       icalproperty *attendee = NULL;
       char attendee_string[SIZ];
       char buf[SIZ];
       int organizer_is_me = 0;
       int i, j = 0;
       /************************************************************
        * Uncomment this to see the UID in calendar events for debugging
       int sequence = 0;
       */
       char weekday_labels[7][32];
       char month_labels[12][32];
       long weekstart = 0;
       icalproperty *rrule = NULL;
       struct icalrecurrencetype recur;
       char weekday_is_selected[7];
       int which_rrmonthtype_is_preselected = 0;

       int rrmday;
       int rrmweekday;

       icaltimetype day1;
       int weekbase;
       int rrmweek;
       int rrymweek;
       int rrymweekday;
       int rrymonth;
       int which_rrend_is_preselected;
       int which_rryeartype_is_preselected;

       const char *ch;
       char *tabnames[3];
       const char *frequency_units[8];
       const char *ordinals[6];

       frequency_units[0] = _("seconds");
       frequency_units[1] = _("minutes");
       frequency_units[2] = _("hours");
       frequency_units[3] = _("days");
       frequency_units[4] = _("weeks");
       frequency_units[5] = _("months");
       frequency_units[6] = _("years");
       frequency_units[7] = _("never");


       ordinals[0] = "0";
       ordinals[1] = _("first");
       ordinals[2] = _("second");
       ordinals[3] = _("third");
       ordinals[4] = _("fourth");
       ordinals[5] = _("fifth");


       tabnames[0] = _("Event");
       tabnames[1] = _("Attendees");
       tabnames[2] = _("Recurrence");

       get_pref_long("weekstart", &weekstart, 17);
       if (weekstart > 6) weekstart = 0;

       syslog(9, "display_edit_individual_event(%ld) calview=%s year=%s month=%s day=%s\n",
              msgnum, bstr("calview"), bstr("year"), bstr("month"), bstr("day")
       );

       /* populate the weekday names - begin */
       now = time(NULL);
       localtime_r(&now, &tm_now);
       while (tm_now.tm_wday != 0) {
              now -= 86400L;
              localtime_r(&now, &tm_now);
       }
       for (i=0; i<7; ++i) {
              localtime_r(&now, &tm_now);
              wc_strftime(weekday_labels[i], 32, "%A", &tm_now);
              now += 86400L;
       }
       /* populate the weekday names - end */

       /* populate the month names - begin */
       now = 259200L;       /* 1970-jan-04 is the first Sunday ever */
       localtime_r(&now, &tm_now);
       for (i=0; i<12; ++i) {
              localtime_r(&now, &tm_now);
              wc_strftime(month_labels[i], 32, "%B", &tm_now);
              now += 2678400L;
       }
       /* populate the month names - end */

       now = time(NULL);
       strcpy(organizer_string, "");
       strcpy(attendee_string, "");

       if (supplied_vevent != NULL) {
              vevent = supplied_vevent;

              /* Convert all timestamps to UTC to make them easier to process. */
              ical_dezonify(vevent);

              /*
               * If we're looking at a fully encapsulated VCALENDAR
               * rather than a VEVENT component, attempt to use the first
               * relevant VEVENT subcomponent.  If there is none, the
               * NULL returned by icalcomponent_get_first_component() will
               * tell the next iteration of this function to create a
               * new one.
               */
              if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
                     display_edit_individual_event(
                            icalcomponent_get_first_component(
                                   vevent, ICAL_VEVENT_COMPONENT), 
                            msgnum, from, unread, NULL
                     );
                     return;
              }
       }
       else {
              vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
              created_new_vevent = 1;
       }

       /* Learn the sequence */
       p = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY);
       /************************************************************
        * Uncomment this to see the UID in calendar events for debugging
       if (p != NULL) {
              sequence = icalproperty_get_sequence(p);
       }
       */
       /* Begin output */
       output_headers(1, 1, 1, 0, 0, 0);
       wc_printf("<div id=\"room_banner_override\">\n");
       wc_printf("<h1>");
       wc_printf(_("Add or edit an event"));
       wc_printf("</h1>");
       wc_printf("</div>\n");

       wc_printf("<div id=\"content\" class=\"service\">\n");

       /************************************************************
        * Uncomment this to see the UID in calendar events for debugging
       wc_printf("UID == ");
       p = icalcomponent_get_first_property(vevent, ICAL_UID_PROPERTY);
       if (p != NULL) {
              escputs((char *)icalproperty_get_comment(p));
       }
       wc_printf("<br>\n");
       wc_printf("SEQUENCE == %d<br>\n", sequence);
       *************************************************************/

       wc_printf("<form name=\"EventForm\" method=\"POST\" action=\"save_event\">\n");
       wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);

       wc_printf("<input type=\"hidden\" name=\"msgnum\" value=\"%ld\">\n",
              msgnum);
       wc_printf("<input type=\"hidden\" name=\"calview\" value=\"%s\">\n",
              bstr("calview"));
       wc_printf("<input type=\"hidden\" name=\"year\" value=\"%s\">\n",
              bstr("year"));
       wc_printf("<input type=\"hidden\" name=\"month\" value=\"%s\">\n",
              bstr("month"));
       wc_printf("<input type=\"hidden\" name=\"day\" value=\"%s\">\n",
              bstr("day"));


       tabbed_dialog(3, tabnames);
       begin_tab(0, 3);

       /* Put it in a borderless table so it lines up nicely */
       wc_printf("<table border='0' width='100%%'>\n");

       wc_printf("<tr><td><b>");
       wc_printf(_("Summary"));
       wc_printf("</b></td><td>\n"
              "<input type=\"text\" name=\"summary\" "
              "maxlength=\"64\" size=\"64\" value=\"");
       p = icalcomponent_get_first_property(vevent, ICAL_SUMMARY_PROPERTY);
       if (p != NULL) {
              escputs((char *)icalproperty_get_comment(p));
       }
       wc_printf("\"></td></tr>\n");

       wc_printf("<tr><td><b>");
       wc_printf(_("Location"));
       wc_printf("</b></td><td>\n"
              "<input type=\"text\" name=\"location\" "
              "maxlength=\"64\" size=\"64\" value=\"");
       p = icalcomponent_get_first_property(vevent, ICAL_LOCATION_PROPERTY);
       if (p != NULL) {
              escputs((char *)icalproperty_get_comment(p));
       }
       wc_printf("\"></td></tr>\n");

       wc_printf("<tr><td><b>");
       wc_printf(_("Start"));
       wc_printf("</b></td><td>\n");
       p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY);
       if (p != NULL) {
              t_start = icalproperty_get_dtstart(p);
              if (t_start.is_date) {
                     t_start.hour = 0;
                     t_start.minute = 0;
                     t_start.second = 0;
              }
       }
       else {
              localtime_r(&now, &tm_now);
              if (havebstr("year")) {
                     tm_now.tm_year = ibstr("year") - 1900;
                     tm_now.tm_mon = ibstr("month") - 1;
                     tm_now.tm_mday = ibstr("day");
              }
              if (havebstr("hour")) {
                     tm_now.tm_hour = ibstr("hour");
                     tm_now.tm_min = ibstr("minute");
                     tm_now.tm_sec = 0;
              }
              else {
                     tm_now.tm_hour = 0;
                     tm_now.tm_min = 0;
                     tm_now.tm_sec = 0;
              }

              t_start = icaltime_from_timet_with_zone(
                     mktime(&tm_now),
                     ((yesbstr("alldayevent")) ? 1 : 0),
                     icaltimezone_get_utc_timezone()
              );
              t_start.is_utc = 1;

       }
       display_icaltimetype_as_webform(&t_start, "dtstart", 0);

       wc_printf("<input type=\"checkbox\" id=\"alldayevent\" name=\"alldayevent\" "
              "value=\"yes\" onclick=\"eventEditAllDay();\""
              " %s >%s",
              (t_start.is_date ? "checked=\"checked\"" : "" ),
              _("All day event")
       );

       wc_printf("</td></tr>\n");

       wc_printf("<tr><td><b>");
       wc_printf(_("End"));
       wc_printf("</b></td><td id=\"dtendcell\">\n");
       p = icalcomponent_get_first_property(vevent,
                                          ICAL_DTEND_PROPERTY);
       if (p != NULL) {
              t_end = icalproperty_get_dtend(p);

              /*
               * If this is an all-day-event, the end time is set to real end
               * day + 1, so we have to adjust accordingly.
               */
              if (t_start.is_date) {
                     icaltime_adjust(&t_end, -1, 0, 0, 0);
              }
       }
       else {
              if (created_new_vevent == 1) {
                     /* set default duration */
                     if (t_start.is_date) {
                            /*
                             * If this is an all-day-event, set the end time to be identical to
                             * the start time (the hour/minute/second will be set to midnight).
                             */
                            t_end = t_start;
                     }
                     else {
                            /*
                             * If this is not an all-day event and there is no
                             * end time specified, make the default one hour
                             * from the start time.
                             */
                            t_end = t_start;
                            t_end.hour += 1;
                            t_end.second = 0;
                            t_end = icaltime_normalize(t_end);
                            /* t_end = icaltime_from_timet(now, 0); */
                     }
              }
              else {
                     /*
                      * If an existing event has no end date/time this is
                      * supposed to mean end = start.
                      */
                     t_end = t_start;
              }
       }
       display_icaltimetype_as_webform(&t_end, "dtend", 0);
       wc_printf("</td></tr>\n");

       wc_printf("<tr><td><b>");
       wc_printf(_("Notes"));
       wc_printf("</b></td><td>\n"
              "<textarea name=\"description\" "
              "rows='5' cols='72' style='width:72'>\n"
       );
       p = icalcomponent_get_first_property(vevent, ICAL_DESCRIPTION_PROPERTY);
       if (p != NULL) {
              escputs((char *)icalproperty_get_comment(p));
       }
       wc_printf("</textarea></td></tr>");

       /*
        * For a new event, the user creating the event should be the
        * organizer.  Set this field accordingly.
        */
       if (icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY)
          == NULL) {
              sprintf(organizer_string, "mailto:%s", ChrPtr(WC->cs_inet_email));
              icalcomponent_add_property(vevent,
                     icalproperty_new_organizer(organizer_string)
              );
       }

       /*
        * Determine who is the organizer of this event.
        * We need to determine "me" or "not me."
        */
       organizer = icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY);
       if (organizer != NULL) {
              strcpy(organizer_string, icalproperty_get_organizer(organizer));
              if (!strncasecmp(organizer_string, "mailto:", 7)) {
                     strcpy(organizer_string, &organizer_string[7]);
                     striplt(organizer_string);
                     serv_printf("ISME %s", organizer_string);
                     serv_getln(buf, sizeof buf);
                     if (buf[0] == '2') {
                            organizer_is_me = 1;
                     }
              }
       }

       wc_printf("<tr><td><b>");
       wc_printf(_("Organizer"));
       wc_printf("</b></td><td>");
       escputs(organizer_string);
       if (organizer_is_me) {
              wc_printf(" <font size='-1'><i>");
              wc_printf(_("(you are the organizer)"));
              wc_printf("</i></font>\n");
       }

       /*
        * Transmit the organizer as a hidden field.   We don't want the user
        * to be able to change it, but we do want it fed back to the server,
        * especially if this is a new event and there is no organizer already
        * in the calendar object.
        */
       wc_printf("<input type=\"hidden\" name=\"organizer\" value=\"");
       escputs(organizer_string);
       wc_printf("\">");

       wc_printf("</td></tr>\n");

       /* Transparency */
       wc_printf("<tr><td><b>");
       wc_printf(_("Show time as:"));
       wc_printf("</b></td><td>");

       p = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY);
       if (p == NULL) {
              /* No transparency found.  Default to opaque (busy). */
              p = icalproperty_new_transp(ICAL_TRANSP_OPAQUE);
              if (p != NULL) {
                     icalcomponent_add_property(vevent, p);
              }
       }
       if (p != NULL) {
              v = icalproperty_get_value(p);
       }
       else {
              v = NULL;
       }

       wc_printf("<input type=\"radio\" name=\"transp\" value=\"transparent\"");
       if ((v != NULL) && (icalvalue_get_transp(v) == ICAL_TRANSP_TRANSPARENT)) {
              wc_printf(" CHECKED");
       }
       wc_printf(">");
       wc_printf(_("Free"));
       wc_printf("&nbsp;&nbsp;");

       wc_printf("<input type=\"radio\" name=\"transp\" value=\"opaque\"");
       if ((v != NULL) && (icalvalue_get_transp(v) == ICAL_TRANSP_OPAQUE)) {
              wc_printf(" CHECKED");
       }
       wc_printf(">");
       wc_printf(_("Busy"));

       wc_printf("</td></tr>\n");


       /* Done with properties. */
       wc_printf("</TABLE>\n");

       end_tab(0, 3);

       /* Attendees tab (need to move things here) */
       begin_tab(1, 3);
       wc_printf("<table border='0' width='100%%'>\n"); /* same table style as the event tab */
       wc_printf("<tr><td><b>");
       wc_printf(_("Attendees"));
       wc_printf("</b><br>"
              "<font size='-2'>");
       wc_printf(_("(One per line)"));
       wc_printf("</font>\n");

       /* Pop open an address book -- begin */
       wc_printf(
              "&nbsp;<a href=\"javascript:PopOpenAddressBook('attendees_box|%s');\" "
              "title=\"%s\">"
              "<img alt='' align='middle' border='0' width='16' height='16' src=\"static/webcit_icons/essen/16x16/contact.png\">"
              "</a>",
              _("Attendees"),
              _("Contacts")
       );
       /* Pop open an address book -- end */

       wc_printf("</td><td>"
              "<textarea %s name=\"attendees\" id=\"attendees_box\" "
              "onchange=\"EnableOrDisableCheckButton();\" "
              "onKeyPress=\"EnableOrDisableCheckButton();\" "
              "rows='10' cols='72' style='width:72'>\n",
              (organizer_is_me ? "" : "disabled='disabled' ")
       );
       i = 0;
       for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY);
           attendee != NULL;
           attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
              ch = icalproperty_get_attendee(attendee);
              if ((ch != NULL) && !strncasecmp(ch, "mailto:", 7)) {

                     /* screen name or email address */
                     safestrncpy(attendee_string, ch + 7, sizeof(attendee_string));
                     striplt(attendee_string);
                     if (i++) wc_printf("\n");
                     escputs(attendee_string);
                     wc_printf(" ");

                     /* participant status */
                     partstat_as_string(buf, attendee);
                     escputs(buf);
              }
       }
       wc_printf("</textarea></td></tr>\n");
       wc_printf("</table>\n");
       end_tab(1, 3);

       /* Recurrence tab */
       begin_tab(2, 3);

       rrule = icalcomponent_get_first_property(vevent, ICAL_RRULE_PROPERTY);
       if (rrule) {
              recur = icalproperty_get_rrule(rrule);
       }
       else {
              /* blank recurrence with some sensible defaults */
              memset(&recur, 0, sizeof(struct icalrecurrencetype));
              recur.count = 3;
              recur.until = icaltime_null_time();
              recur.interval = 1;
              recur.freq = ICAL_WEEKLY_RECURRENCE;
       }

       wc_printf("<input type=\"checkbox\" id=\"is_recur\" name=\"is_recur\" "
              "value=\"yes\" "
              "onclick=\"RecurrenceShowHide();\""
              " %s >%s",
              (rrule ? "checked=\"checked\"" : "" ),
              _("This is a recurring event")
       );

       wc_printf("<div id=\"rrule_div\">\n");           /* begin 'rrule_div' div */

       wc_printf("<table border='0' cellspacing='10' width='100%%'>\n");

       wc_printf("<tr><td><b>");
       wc_printf(_("Recurrence rule"));
       wc_printf("</b></td><td>");

       if ((recur.freq < 0) || (recur.freq > 6)) recur.freq = 4;
       wc_printf("%s ", _("Repeats every"));

       wc_printf("<input type=\"text\" name=\"interval\" maxlength=\"3\" size=\"3\" ");
       wc_printf("value=\"%d\">&nbsp;", recur.interval);

       wc_printf("<select name=\"freq\" id=\"freq_selector\" size=\"1\" "
              "onChange=\"RecurrenceShowHide();\">\n");
       for (i=0; i<(sizeof frequency_units / sizeof(char *)); ++i) {
              wc_printf("<option %s%svalue=\"%d\">%s</option>\n",
                     ((i == recur.freq) ? "selected='selected' " : ""),
                     (((i == recur.freq) || ((i>=3)&&(i<=6))) ? "" : "disabled='disabled' "),
                     i,
                     frequency_units[i]
              );
       }
       wc_printf("</select>\n");

       wc_printf("<div id=\"weekday_selector\">");      /* begin 'weekday_selector' div */
       wc_printf("%s<br>", _("on these weekdays:"));

       memset(weekday_is_selected, 0, 7);

       for (i=0; i<ICAL_BY_DAY_SIZE; ++i) {
              if (recur.by_day[i] == ICAL_RECURRENCE_ARRAY_MAX) {
                     i = ICAL_RECURRENCE_ARRAY_MAX;                   /* all done */
              }
              else {
                     for (j=0; j<7; ++j) {
                            if (icalrecurrencetype_day_day_of_week(recur.by_day[i]) == j+1) {
                                   weekday_is_selected[j] = 1;
                            }
                     }
              }
       }

       for (j=0; j<7; ++j) {
              i = ((j + (int)weekstart) % 7);
              wc_printf("<input type=\"checkbox\" name=\"weekday%d\" value=\"yes\"", i);
              if (weekday_is_selected[i]) wc_printf(" checked='checked'");
              wc_printf(">%s\n", weekday_labels[i]);
       }
       wc_printf("</div>\n");                           /* end 'weekday_selector' div */





       wc_printf("<div id=\"monthday_selector\">");     /* begin 'monthday_selector' div */

       wc_printf("<input type=\"radio\" name=\"rrmonthtype\" id=\"rrmonthtype_mday\" "
              "value=\"rrmonthtype_mday\" "
              "%s onChange=\"RecurrenceShowHide();\">",
              ((which_rrmonthtype_is_preselected == 0) ? "checked='checked'" : "")
       );

       rrmday = t_start.day;
       rrmweekday = icaltime_day_of_week(t_start) - 1;

       /* Figure out what week of the month we're in */
       day1 = t_start;
       day1.day = 1;
       weekbase = icaltime_week_number(day1);
       rrmweek = icaltime_week_number(t_start) - weekbase + 1;

       /* Are we going by day of the month or week/day? */

       if (recur.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
              which_rrmonthtype_is_preselected = 0;
              rrmday = recur.by_month_day[0];
       }
       else if (recur.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
              which_rrmonthtype_is_preselected = 1;
              rrmweek = icalrecurrencetype_day_position(recur.by_day[0]);
              rrmweekday = icalrecurrencetype_day_day_of_week(recur.by_day[0]) - 1;
       }

       wc_printf(_("on day %s%d%s of the month"), "<span id=\"rrmday\">", rrmday, "</span>");
       wc_printf("<br>\n");

       wc_printf("<input type=\"radio\" name=\"rrmonthtype\" id=\"rrmonthtype_wday\" "
              "value=\"rrmonthtype_wday\" "
              "%s onChange=\"RecurrenceShowHide();\">",
              ((which_rrmonthtype_is_preselected == 1) ? "checked='checked'" : "")
       );

       wc_printf(_("on the "));
       wc_printf("<select name=\"rrmweek\" id=\"rrmweek\" size=\"1\" "
              "onChange=\"RecurrenceShowHide();\">\n");
       for (i=1; i<=5; ++i) {
              wc_printf("<option %svalue=\"%d\">%s</option>\n",
                     ((i==rrmweek) ? "selected='selected' " : ""),
                     i,
                     ordinals[i]
              );
       }
       wc_printf("</select> \n");

       wc_printf("<select name=\"rrmweekday\" id=\"rrmweekday\" size=\"1\" "
              "onChange=\"RecurrenceShowHide();\">\n");
       for (j=0; j<7; ++j) {
              i = ((j + (int)weekstart) % 7);
              wc_printf("<option %svalue=\"%d\">%s</option>\n",
                     ((i==rrmweekday) ? "selected='selected' " : ""),
                     i,
                     weekday_labels[i]
              );
       }
       wc_printf("</select>");

       wc_printf(" %s<br>\n", _("of the month"));

       wc_printf("</div>\n");                           /* end 'monthday_selector' div */


       rrymweek = rrmweek;
       rrymweekday = rrmweekday;
       rrymonth = t_start.month;
       which_rryeartype_is_preselected = 0;

       if (
              (recur.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX)
              && (recur.by_day[0] != 0)
              && (recur.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX)
              && (recur.by_month[0] != 0)
       ) {
              which_rryeartype_is_preselected = 1;
              rrymweek = icalrecurrencetype_day_position(recur.by_day[0]);
              rrymweekday = icalrecurrencetype_day_day_of_week(recur.by_day[0]) - 1;
              rrymonth = recur.by_month[0];
       }

       wc_printf("<div id=\"yearday_selector\">");      /* begin 'yearday_selector' div */

       wc_printf("<input type=\"radio\" name=\"rryeartype\" id=\"rryeartype_ymday\" "
              "value=\"rryeartype_ymday\" "
              "%s onChange=\"RecurrenceShowHide();\">",
              ((which_rryeartype_is_preselected == 0) ? "checked='checked'" : "")
       );
       wc_printf(_("every "));
       wc_printf("<span id=\"ymday\">%s</span><br>", _("year on this date"));

       wc_printf("<input type=\"radio\" name=\"rryeartype\" id=\"rryeartype_ywday\" "
              "value=\"rryeartype_ywday\" "
              "%s onChange=\"RecurrenceShowHide();\">",
              ((which_rryeartype_is_preselected == 1) ? "checked='checked'" : "")
       );

       wc_printf(_("on the "));
       wc_printf("<select name=\"rrymweek\" id=\"rrymweek\" size=\"1\" "
              "onChange=\"RecurrenceShowHide();\">\n");
       for (i=1; i<=5; ++i) {
              wc_printf("<option %svalue=\"%d\">%s</option>\n",
                     ((i==rrymweek) ? "selected='selected' " : ""),
                     i,
                     ordinals[i]
              );
       }
       wc_printf("</select> \n");

       wc_printf("<select name=\"rrymweekday\" id=\"rrymweekday\" size=\"1\" "
              "onChange=\"RecurrenceShowHide();\">\n");
       for (j=0; j<7; ++j) {
              i = ((j + (int)weekstart) % 7);
              wc_printf("<option %svalue=\"%d\">%s</option>\n",
                     ((i==rrymweekday) ? "selected='selected' " : ""),
                     i,
                     weekday_labels[i]
              );
       }
       wc_printf("</select>");

       wc_printf(" %s ", _("of"));

       wc_printf("<select name=\"rrymonth\" id=\"rrymonth\" size=\"1\" "
              "onChange=\"RecurrenceShowHide();\">\n");
       for (i=1; i<=12; ++i) {
              wc_printf("<option %svalue=\"%d\">%s</option>\n",
                     ((i==rrymonth) ? "selected='selected' " : ""),
                     i,
                     month_labels[i-1]
              );
       }
       wc_printf("</select>");
       wc_printf("<br>\n");

       wc_printf("</div>\n");                           /* end 'yearday_selector' div */

       wc_printf("</td></tr>\n");


       which_rrend_is_preselected = 0;
       if (!icaltime_is_null_time(recur.until)) which_rrend_is_preselected = 2;
       if (recur.count > 0) which_rrend_is_preselected = 1;

       wc_printf("<tr><td><b>");
       wc_printf(_("Recurrence range"));
       wc_printf("</b></td><td>\n");

       wc_printf("<input type=\"radio\" name=\"rrend\" id=\"rrend_none\" "
              "value=\"rrend_none\" "
              "%s onChange=\"RecurrenceShowHide();\">",
              ((which_rrend_is_preselected == 0) ? "checked='checked'" : "")
       );
       wc_printf("%s<br>\n", _("No ending date"));

       wc_printf("<input type=\"radio\" name=\"rrend\" id=\"rrend_count\" "
              "value=\"rrend_count\" "
              "%s onChange=\"RecurrenceShowHide();\">",
              ((which_rrend_is_preselected == 1) ? "checked='checked'" : "")
       );
       wc_printf(_("Repeat this event"));
       wc_printf(" <input type=\"text\" name=\"rrcount\" id=\"rrcount\" maxlength=\"3\" size=\"3\" ");
       wc_printf("value=\"%d\"> ", recur.count);
       wc_printf(_("times"));
       wc_printf("<br>\n");

       wc_printf("<input type=\"radio\" name=\"rrend\" id=\"rrend_until\" "
              "value=\"rrend_until\" "
              "%s onChange=\"RecurrenceShowHide();\">",
              ((which_rrend_is_preselected == 2) ? "checked='checked'" : "")
       );
       wc_printf(_("Repeat this event until "));

       if (icaltime_is_null_time(recur.until)) {
              recur.until = icaltime_add(t_start, icaldurationtype_from_int(604800));
       }
       display_icaltimetype_as_webform(&recur.until, "rruntil", 1);
       wc_printf("<br>\n");

       wc_printf("</td></tr>\n");

       wc_printf("</table>\n");
       wc_printf("</div>\n");                           /* end 'rrule' div */

       end_tab(2, 3);

       /* submit buttons (common area beneath the tabs) */
       begin_tab(3, 3);
       wc_printf("<center>"
              "<input type=\"submit\" name=\"save_button\" value=\"%s\">"
              "&nbsp;&nbsp;"
              "<input type=\"submit\" name=\"delete_button\" value=\"%s\">\n"
              "&nbsp;&nbsp;"
              "<input type=\"submit\" id=\"check_button\" name=\"check_button\" value=\"%s\">\n"
              "&nbsp;&nbsp;"
              "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n"
              "</center>\n",
              _("Save"),
              _("Delete"),
              _("Check attendee availability"),
              _("Cancel")
       );
       end_tab(3, 3);
       wc_printf("</form>\n");

       StrBufAppendPrintf(WC->trailing_javascript,
              "eventEditAllDay();         \n"
              "RecurrenceShowHide();             \n"
              "EnableOrDisableCheckButton();     \n"
       );
       address_book_popup();
       wDumpContent(1);

       if (created_new_vevent) {
              icalcomponent_free(vevent);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_edit_task ( void  )

Definition at line 680 of file tasks.c.

                             {
       long msgnum = 0L;
                     
       /* Force change the room if we have to */
       if (havebstr("taskrm")) {
              gotoroom(sbstr("taskrm"));
       }

       msgnum = lbstr("msgnum");
       if (msgnum > 0L) {
              /* existing task */
              load_ical_object(msgnum, 0,
                             ICAL_VTODO_COMPONENT,
                             display_edit_individual_task,
                             NULL, 0
              );
       }
       else {
              /* new task */
              display_edit_individual_task(NULL, 0L, "", 0, NULL);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_icaltimetype_as_webform ( struct icaltimetype *  ,
char *  ,
int   
)

Definition at line 45 of file calendar_tools.c.

                                                                                          {
       wcsession *WCC = WC;
       int i;
       time_t now;
       struct tm tm_now;
       time_t tt;
       struct tm tm;
       int all_day_event = 0;
       int time_format;
       char timebuf[32];
       
       time_format = get_time_format_cached ();

       now = time(NULL);
       localtime_r(&now, &tm_now);

       if (t == NULL) return;
       if (t->is_date) all_day_event = 1;
       tt = icaltime_as_timet(*t);
       if (all_day_event) {
              gmtime_r(&tt, &tm);
       }
       else {
              localtime_r(&tt, &tm);
       }

       wc_printf("<input type=\"text\" name=\"");
       StrBufAppendBufPlain(WCC->WBuf, prefix, -1, 0);
       wc_printf("\" id=\"");
       StrBufAppendBufPlain(WCC->WBuf, prefix, -1, 0);
       wc_printf("\" size=\"10\" maxlength=\"10\" value=\"");
       wc_strftime(timebuf, 32, "%Y-%m-%d", &tm);
       StrBufAppendBufPlain(WCC->WBuf, timebuf, -1, 0);
       wc_printf("\">");

       StrBufAppendPrintf(WC->trailing_javascript, "attachDatePicker('");
       StrBufAppendPrintf(WC->trailing_javascript, prefix);
       StrBufAppendPrintf(WC->trailing_javascript, "', '%s');\n", get_selected_language());

       /* If we're editing a date only, we still generate the time boxes, but we hide them.
        * This keeps the data model consistent.
        */
       if (date_only) {
              wc_printf("<div style=\"display:none\">");
       }

       wc_printf("<span ID=\"");
       StrBufAppendBufPlain(WCC->WBuf, prefix, -1, 0);
       wc_printf("_time\">");
       wc_printf(_("Hour: "));
       wc_printf("<SELECT NAME=\"%s_hour\" SIZE=\"1\">\n", prefix);
       for (i=0; i<=23; ++i) {

              if (time_format == WC_TIMEFORMAT_24) {
                     wc_printf("<OPTION %s VALUE=\"%d\">%d</OPTION>\n",
                            ((tm.tm_hour == i) ? "SELECTED" : ""),
                            i, i
                            );
              }
              else {
                     wc_printf("<OPTION %s VALUE=\"%d\">%s</OPTION>\n",
                            ((tm.tm_hour == i) ? "SELECTED" : ""),
                            i, hourname[i]
                            );
              }

       }
       wc_printf("</SELECT>\n");

       wc_printf(_("Minute: "));
       wc_printf("<SELECT NAME=\"%s_minute\" SIZE=\"1\">\n", prefix);
       for (i=0; i<=59; ++i) {
              if ( (i % 5 == 0) || (tm.tm_min == i) ) {
                     wc_printf("<OPTION %s VALUE=\"%d\">:%02d</OPTION>\n",
                            ((tm.tm_min == i) ? "SELECTED" : ""),
                            i, i
                            );
              }
       }
       wc_printf("</SELECT></span>\n");

       if (date_only) {
              wc_printf("</div>");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_individual_cal ( icalcomponent *  cal,
long  msgnum,
char *  from,
int  unread,
calview calv 
)

Definition at line 411 of file calendar.c.

{
       icalproperty *ps = NULL;
       struct icaltimetype dtstart, dtend;
       struct icaldurationtype dur;
       wcsession *WCC = WC;
       disp_cal *Cal;
       size_t len;
       time_t final_recurrence = 0;
       icalcomponent *cptr = NULL;

       /* recur variables */
       icalproperty *rrule = NULL;
       struct icalrecurrencetype recur;
       icalrecur_iterator *ritr = NULL;
       struct icaltimetype next;
       int num_recur = 0;
       int stop_rr = 0;

       /* first and foremost, check for bogosity.  bail if we see no DTSTART property */

       if (icalcomponent_get_first_property(icalcomponent_get_first_component(
              event, ICAL_VEVENT_COMPONENT), ICAL_DTSTART_PROPERTY) == NULL)
       {
              return;
       }

       /* ok, chances are we've got a live one here.  let's try to figure out where it goes. */

       dtstart = icaltime_null_time();
       dtend = icaltime_null_time();
       
       if (WCC->disp_cal_items == NULL) {
              WCC->disp_cal_items = NewHash(0, Flathash);
       }

       /* Note: anything we do here, we also have to do below for the recurrences. */
       Cal = (disp_cal*) malloc(sizeof(disp_cal));
       memset(Cal, 0, sizeof(disp_cal));
       Cal->cal = icalcomponent_new_clone(event);

       /* Dezonify and decapsulate at the very last moment */
       ical_dezonify(Cal->cal);
       if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
              cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
              if (cptr) {
                     cptr = icalcomponent_new_clone(cptr);
                     icalcomponent_free(Cal->cal);
                     Cal->cal = cptr;
              }
       }

       Cal->unread = unread;
       len = strlen(from);
       Cal->from = (char*)malloc(len+ 1);
       memcpy(Cal->from, from, len + 1);
       Cal->cal_msgnum = msgnum;

       /* Precalculate the starting date and time of this event, and store it in our top-level
        * structure.  Later, when we are rendering the calendar, we can just peek at these values
        * without having to break apart every calendar item.
        */
       ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
       if (ps != NULL) {
              dtstart = icalproperty_get_dtstart(ps);
              Cal->event_start = icaltime_as_timet(dtstart);
       }

       /* Do the same for the ending date and time.  It makes the day view much easier to render. */
       ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
       if (ps != NULL) {
              dtend = icalproperty_get_dtend(ps);
              Cal->event_end = icaltime_as_timet(dtend);
       }

       /* Store it in the hash list. */
       /* syslog(LOG_DEBUG, "INITIAL: %s", ctime(&Cal->event_start)); */
       Put(WCC->disp_cal_items, 
           (char*) &Cal->event_start,
           sizeof(Cal->event_start), 
           Cal, 
           delete_cal);

       /****************************** handle recurring events ******************************/

       if (icaltime_is_null_time(dtstart)) return;      /* Can't recur without a start time */

       if (!icaltime_is_null_time(dtend)) {             /* Need duration for recurrences */
              dur = icaltime_subtract(dtend, dtstart);
       }
       else {
              dur = icaltime_subtract(dtstart, dtstart);
       }

       /*
        * Just let libical iterate the recurrence, and keep looping back to the top of this function,
        * adding new hash entries that all point back to the same msgnum, until either the iteration
        * stops or some outer bound is reached.  The display code will automatically do the Right Thing.
        */
       cptr = event;
       if (icalcomponent_isa(cptr) != ICAL_VEVENT_COMPONENT) {
              cptr = icalcomponent_get_first_component(cptr, ICAL_VEVENT_COMPONENT);
       }
       if (!cptr) return;
       ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY);
       if (ps == NULL) return;
       dtstart = icalproperty_get_dtstart(ps);
       rrule = icalcomponent_get_first_property(cptr, ICAL_RRULE_PROPERTY);
       if (!rrule) return;
       recur = icalproperty_get_rrule(rrule);
       ritr = icalrecur_iterator_new(recur, dtstart);
       if (!ritr) return;

       while (next = icalrecur_iterator_next(ritr), ((!icaltime_is_null_time(next))&&(!stop_rr)) ) {
              ++num_recur;
              if (num_recur > 1) {        /* Skip the first one.  We already did it at the root. */
                     icalcomponent *cptr;

                     /* Note: anything we do here, we also have to do above for the root event. */
                     Cal = (disp_cal*) malloc(sizeof(disp_cal));
                     memset(Cal, 0, sizeof(disp_cal));
                     Cal->cal = icalcomponent_new_clone(event);
                     Cal->unread = unread;
                     len = strlen(from);
                     Cal->from = (char*)malloc(len+ 1);
                     memcpy(Cal->from, from, len + 1);
                     Cal->cal_msgnum = msgnum;

                     if (icalcomponent_isa(Cal->cal) == ICAL_VEVENT_COMPONENT) {
                            cptr = Cal->cal;
                     }
                     else {
                            cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
                     }
                     if (cptr) {

                            /* Remove any existing DTSTART properties */
                            while (       ps = icalcomponent_get_first_property(cptr, ICAL_DTSTART_PROPERTY),
                                   ps != NULL
                            ) {
                                   icalcomponent_remove_property(cptr, ps);
                            }

                            /* Add our shiny new DTSTART property from the iteration */
                            ps = icalproperty_new_dtstart(next);
                            icalcomponent_add_property(cptr, ps);
                            Cal->event_start = icaltime_as_timet(next);
                            final_recurrence = Cal->event_start;

                            /* Remove any existing DTEND properties */
                            while (       ps = icalcomponent_get_first_property(cptr, ICAL_DTEND_PROPERTY),
                                   (ps != NULL)
                            ) {
                                   icalcomponent_remove_property(cptr, ps);
                            }

                            /* Add our shiny new DTEND property from the iteration */
                            ps = icalproperty_new_dtend(icaltime_add(next, dur));
                            icalcomponent_add_property(cptr, ps);

                     }

                     /* Dezonify and decapsulate at the very last moment */
                     ical_dezonify(Cal->cal);
                     if (icalcomponent_isa(Cal->cal) != ICAL_VEVENT_COMPONENT) {
                            cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VEVENT_COMPONENT);
                            if (cptr) {
                                   cptr = icalcomponent_new_clone(cptr);
                                   icalcomponent_free(Cal->cal);
                                   Cal->cal = cptr;
                            }
                     }

                     if (   (Cal->event_start > calv->lower_bound)
                            && (Cal->event_start < calv->upper_bound)
                     ) {
                            /* syslog(LOG_DEBUG, "REPEATS: %s", ctime(&Cal->event_start)); */
                            Put(WCC->disp_cal_items, 
                                   (char*) &Cal->event_start,
                                   sizeof(Cal->event_start), 
                                   Cal, 
                                   delete_cal
                            );
                     }
                     else {
                            delete_cal(Cal);
                     }

                     /* If an upper bound is set, stop when we go out of scope */
                     if (final_recurrence > calv->upper_bound) stop_rr = 1;
              }
       }
       icalrecur_iterator_free(ritr);
       /* syslog(9, "Performed %d recurrences; final one is %s", num_recur, ctime(&final_recurrence)); */
}

Here is the call graph for this function:

Here is the caller graph for this function:

icaltimezone* get_default_icaltimezone ( void  )

Definition at line 18 of file ical_dezonify.c.

                                             {

        icaltimezone *zone = NULL;
       const char *default_zone_name = ChrPtr(WC->serv_info->serv_default_cal_zone);

        if (!zone) {
                zone = icaltimezone_get_builtin_timezone(default_zone_name);
        }
        if (!zone) {
              syslog(1, "Unable to load '%s' time zone.  Defaulting to UTC.\n", default_zone_name);
                zone = icaltimezone_get_utc_timezone();
       }
       if (!zone) {
              syslog(1, "Unable to load UTC time zone!\n");
       }
        return zone;
}

Here is the caller graph for this function:

int ical_ctdl_is_overlap ( struct icaltimetype  t1start,
struct icaltimetype  t1end,
struct icaltimetype  t2start,
struct icaltimetype  t2end 
)

Definition at line 55 of file availability.c.

  {

       if (icaltime_is_null_time(t1start)) return(0);
       if (icaltime_is_null_time(t2start)) return(0);

       /* if either event lacks end time, assume end = start */
       if (icaltime_is_null_time(t1end))
              memcpy(&t1end, &t1start, sizeof(struct icaltimetype));
       else {
              if (t1end.is_date && icaltime_compare(t1start, t1end)) {
                        /*
                         * the end date is non-inclusive so adjust it by one
                         * day because our test is inclusive, note that a day is
                         * not too much because we are talking about all day
                         * events
                      * if start = end we assume that nevertheless the whole
                      * day is meant
                         */
                     icaltime_adjust(&t1end, -1, 0, 0, 0);     
              }
       }

       if (icaltime_is_null_time(t2end))
              memcpy(&t2end, &t2start, sizeof(struct icaltimetype));
       else {
              if (t2end.is_date && icaltime_compare(t2start, t2end)) {
                     icaltime_adjust(&t2end, -1, 0, 0, 0);     
              }
       }

       /* First, check for all-day events */
       if (t1start.is_date || t2start.is_date) {
              /* If event 1 ends before event 2 starts, we're in the clear. */
              if (icaltime_compare_date_only(t1end, t2start) < 0) return(0);

              /* If event 2 ends before event 1 starts, we're also ok. */
              if (icaltime_compare_date_only(t2end, t1start) < 0) return(0);

              return(1);
       }

       /* syslog(9, "Comparing t1start %d:%d t1end %d:%d t2start %d:%d t2end %d:%d \n",
              t1start.hour, t1start.minute, t1end.hour, t1end.minute,
              t2start.hour, t2start.minute, t2end.hour, t2end.minute);
       */

       /* Now check for overlaps using date *and* time. */

       /* If event 1 ends before event 2 starts, we're in the clear. */
       if (icaltime_compare(t1end, t2start) <= 0) return(0);
       /* syslog(9, "first passed\n"); */

       /* If event 2 ends before event 1 starts, we're also ok. */
       if (icaltime_compare(t2end, t1start) <= 0) return(0);
       /* syslog(9, "second passed\n"); */

       /* Otherwise, they overlap. */
       return(1);
}

Here is the caller graph for this function:

void ical_dezonify ( icalcomponent *  cal)

Definition at line 218 of file ical_dezonify.c.

                                       {
       icalcomponent *vt = NULL;

#ifdef DBG_ICAL
       syslog(9, "ical_dezonify() started\n");
#endif

       /* Convert all times to UTC */
       ical_dezonify_recurse(cal, cal);

       /* Strip out VTIMEZONE subcomponents -- we don't need them anymore */
       while (vt = icalcomponent_get_first_component(
                     cal, ICAL_VTIMEZONE_COMPONENT), vt != NULL) {
              icalcomponent_remove_component(cal, vt);
              icalcomponent_free(vt);
       }

#ifdef DBG_ICAL
       syslog(9, "ical_dezonify() completed\n");
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

icalcomponent* ical_encapsulate_subcomponent ( icalcomponent *  subcomp)

Definition at line 235 of file calendar_tools.c.

                                                                     {
       icalcomponent *encaps;
       icalproperty *p;
       struct icaltimetype t;
       const icaltimezone *attached_zones[5] = { NULL, NULL, NULL, NULL, NULL };
       int i;
       const icaltimezone *z;
       int num_zones_attached = 0;
       int zone_already_attached;

       if (subcomp == NULL) {
              syslog(3, "ERROR: ical_encapsulate_subcomponent() called with NULL argument\n");
              return NULL;
       }

       /*
        * If we're already looking at a full VCALENDAR component, this is probably an error.
        */
       if (icalcomponent_isa(subcomp) == ICAL_VCALENDAR_COMPONENT) {
              syslog(3, "ERROR: component sent to ical_encapsulate_subcomponent() already top level\n");
              return subcomp;
       }

       /* search for... */
       for (p = icalcomponent_get_first_property(subcomp, ICAL_ANY_PROPERTY);
            p != NULL;
            p = icalcomponent_get_next_property(subcomp, ICAL_ANY_PROPERTY))
       {
              if ( (icalproperty_isa(p) == ICAL_COMPLETED_PROPERTY)
                || (icalproperty_isa(p) == ICAL_CREATED_PROPERTY)
                || (icalproperty_isa(p) == ICAL_DATEMAX_PROPERTY)
                || (icalproperty_isa(p) == ICAL_DATEMIN_PROPERTY)
                || (icalproperty_isa(p) == ICAL_DTEND_PROPERTY)
                || (icalproperty_isa(p) == ICAL_DTSTAMP_PROPERTY)
                || (icalproperty_isa(p) == ICAL_DTSTART_PROPERTY)
                || (icalproperty_isa(p) == ICAL_DUE_PROPERTY)
                || (icalproperty_isa(p) == ICAL_EXDATE_PROPERTY)
                || (icalproperty_isa(p) == ICAL_LASTMODIFIED_PROPERTY)
                || (icalproperty_isa(p) == ICAL_MAXDATE_PROPERTY)
                || (icalproperty_isa(p) == ICAL_MINDATE_PROPERTY)
                || (icalproperty_isa(p) == ICAL_RECURRENCEID_PROPERTY)
              ) {
                     t = icalproperty_get_dtstart(p);   /*/ it's safe to use dtstart for all of them */
                     if ((icaltime_is_valid_time(t)) && (z=icaltime_get_timezone(t), z)) {
                     
                            zone_already_attached = 0;
                            for (i=0; i<5; ++i) {
                                   if (z == attached_zones[i]) {
                                          ++zone_already_attached;
                                          syslog(9, "zone already attached!!\n");
                                   }
                            }
                            if ((!zone_already_attached) && (num_zones_attached < 5)) {
                                   syslog(9, "attaching zone %d!\n", num_zones_attached);
                                   attached_zones[num_zones_attached++] = z;
                            }

                            icalproperty_set_parameter(p,
                                   icalparameter_new_tzid(icaltimezone_get_tzid((icaltimezone *)z))
                            );
                     }
              }
       }

       /* Encapsulate the VEVENT component into a complete VCALENDAR */
       encaps = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
       if (encaps == NULL) {
              syslog(3, "ERROR: ical_encapsulate_subcomponent() could not allocate component\n");
              return NULL;
       }

       /* Set the Product ID */
       icalcomponent_add_property(encaps, icalproperty_new_prodid(PRODID));

       /* Set the Version Number */
       icalcomponent_add_property(encaps, icalproperty_new_version("2.0"));

       /* Attach any timezones we need */
       if (num_zones_attached > 0) for (i=0; i<num_zones_attached; ++i) {
              icalcomponent *zc;
              zc = icalcomponent_new_clone(icaltimezone_get_component((icaltimezone *)attached_zones[i]));
              icalcomponent_add_component(encaps, zc);
       }

       /* Encapsulate the subcomponent inside */
       icalcomponent_add_component(encaps, subcomp);

       /* Return the object we just created. */
       return(encaps);
}

Here is the caller graph for this function:

void icaltime_from_webform ( struct icaltimetype *  result,
char *  prefix 
)

Definition at line 134 of file calendar_tools.c.

                                                                 {
       char vname[32];

       if (!t) return;

       /* Stuff with zero values */
       memset(t, 0, sizeof(struct icaltimetype));

       /* Get the year/month/date all in one shot -- it will be in ISO YYYY-MM-DD format */
       sscanf((char*)BSTR(prefix), "%04d-%02d-%02d", &t->year, &t->month, &t->day);

       /* hour */
       sprintf(vname, "%s_hour", prefix);
       t->hour = IBSTR(vname);

       /* minute */
       sprintf(vname, "%s_minute", prefix);
       t->minute = IBSTR(vname);

       /* time zone is set to the default zone for this server */
       t->is_utc = 0;
       t->is_date = 0;
       t->zone = get_default_icaltimezone();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void icaltime_from_webform_dateonly ( struct icaltimetype *  result,
char *  prefix 
)

Definition at line 163 of file calendar_tools.c.

                                                                          {
       if (!t) return;

       /* Stuff with zero values */
       memset(t, 0, sizeof(struct icaltimetype));

       /* Get the year/month/date all in one shot -- it will be in ISO YYYY-MM-DD format */
       sscanf((char*)BSTR(prefix), "%04d-%02d-%02d", &t->year, &t->month, &t->day);

       /* time zone is set to the default zone for this server */
       t->is_utc = 1;
       t->is_date = 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void load_ical_object ( long  msgnum,
int  unread,
icalcomponent_kind  which_kind,
IcalCallbackFunc  CallBack,
calview calv,
int  RenderAsync 
)

Definition at line 657 of file calendar.c.

{
       StrBuf *Buf;
       StrBuf *Data = NULL;
       const char *bptr;
       int Done = 0;
       char from[128] = "";
       char mime_partnum[256];
       char mime_filename[256];
       char mime_content_type[256];
       char mime_disposition[256];
       char relevant_partnum[256];
       char *relevant_source = NULL;
       int phase = 0;                            /* 0 = citadel headers, 1 = mime headers, 2 = body */
       char msg4_content_type[256] = "";
       char msg4_content_encoding[256] = "";
       int msg4_content_length = 0;

       relevant_partnum[0] = '\0';
       serv_printf("MSG4 %ld", msgnum);   /* we need the mime headers */
       Buf = NewStrBuf();
       StrBuf_ServGetln(Buf);
       if (GetServerStatus(Buf, NULL) != 1) {
              FreeStrBuf (&Buf);
              return;
       }
       while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
              if ( (StrLength(Buf)==3) && 
                   !strcmp(ChrPtr(Buf), "000")) {
                     Done = 1;
                     break;
              }
              bptr = ChrPtr(Buf);
              switch (phase) {
              case 0:
                     if (!strncasecmp(bptr, "part=", 5)) {
                            extract_token(mime_filename, &bptr[5], 1, '|', sizeof mime_filename);
                            extract_token(mime_partnum, &bptr[5], 2, '|', sizeof mime_partnum);
                            extract_token(mime_disposition, &bptr[5], 3, '|', sizeof mime_disposition);
                            extract_token(mime_content_type, &bptr[5], 4, '|', sizeof mime_content_type);
                            /* do we care? mime_length = */extract_int(&bptr[5], 5);

                            if (  (!strcasecmp(mime_content_type, "text/calendar"))
                                  || (!strcasecmp(mime_content_type, "application/ics"))
                                  || (!strcasecmp(mime_content_type, "text/vtodo"))
                                  || (!strcasecmp(mime_content_type, "text/todo"))
                                   ) {
                                   strcpy(relevant_partnum, mime_partnum);
                            }
                     }
                     else if (!strncasecmp(bptr, "from=", 4)) {
                            extract_token(from, bptr, 1, '=', sizeof(from));
                     }
                     else if ((phase == 0) && (!strncasecmp(bptr, "text", 4))) {
                            phase = 1;
                     }
              break;
              case 1:
                     if (!IsEmptyStr(bptr)) {
                            if (!strncasecmp(bptr, "Content-type: ", 14)) {
                                   safestrncpy(msg4_content_type, &bptr[14], sizeof msg4_content_type);
                                   striplt(msg4_content_type);
                            }
                            else if (!strncasecmp(bptr, "Content-transfer-encoding: ", 27)) {
                                   safestrncpy(msg4_content_encoding, &bptr[27], sizeof msg4_content_encoding);
                                   striplt(msg4_content_type);
                            }
                            else if ((!strncasecmp(bptr, "Content-length: ", 16))) {
                                   msg4_content_length = atoi(&bptr[16]);
                            }
                            break;
                     }
                     else {
                            phase++;
                            
                            if ((msg4_content_length > 0)
                                && ( !strcasecmp(msg4_content_encoding, "7bit"))
                                && ((!strcasecmp(mime_content_type, "text/calendar"))
                                   || (!strcasecmp(mime_content_type, "application/ics"))
                                   || (!strcasecmp(mime_content_type, "text/vtodo"))
                                   || (!strcasecmp(mime_content_type, "text/todo"))
                                       )
                                   ) 
                            {
                            }
                     }
              case 2:
                     if (Data == NULL)
                            Data = NewStrBufPlain(NULL, msg4_content_length * 2);
                     if (msg4_content_length > 0) {
                            StrBuf_ServGetBLOBBuffered(Data, msg4_content_length);
                            phase ++;
                     }
                     else {
                            StrBufAppendBuf(Data, Buf, 0);
                            StrBufAppendBufPlain(Data, "\r\n", 1, 0);
                     }
              case 3:
                     StrBufAppendBuf(Data, Buf, 0);
              }
       }
       FreeStrBuf(&Buf);

       /* If MSG4 didn't give us the part we wanted, but we know that we can find it
        * as one of the other MIME parts, attempt to load it now.
        */
       if ((Data == NULL) && (!IsEmptyStr(relevant_partnum))) {
              Data = load_mimepart(msgnum, relevant_partnum);
       }

       if (Data != NULL) {
              relevant_source = (char*) ChrPtr(Data);
              process_ical_object(msgnum, unread,
                                from, 
                                relevant_source, 
                                which_kind,
                                CallBack,
                                calv);
       }
       FreeStrBuf (&Data);

       icalmemory_free_ring();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void partstat_as_string ( char *  buf,
icalproperty *  attendee 
)

Definition at line 181 of file calendar_tools.c.

                                                           {
       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;
       }
}

Here is the caller graph for this function:

void save_individual_event ( icalcomponent *  supplied_vtodo,
long  msgnum,
char *  from,
int  unread,
calview calv 
)

Definition at line 791 of file event.c.

                                                {
       char buf[SIZ];
       icalproperty *prop;
       icalcomponent *vevent, *encaps;
       int created_new_vevent = 0;
       int all_day_event = 0;
       struct icaltimetype event_start, t;
       icalproperty *attendee = NULL;
       char attendee_string[SIZ];
       int i, j;
       int foundit;
       char form_attendees[SIZ];
       char organizer_string[SIZ];
       int sequence = 0;
       enum icalproperty_transp formtransp = ICAL_TRANSP_NONE;
       const char *ch;

       if (supplied_vevent != NULL) {
              vevent = supplied_vevent;

              /* Convert all timestamps to UTC to make them easier to process. */
              ical_dezonify(vevent);

              /*
               * If we're looking at a fully encapsulated VCALENDAR
               * rather than a VEVENT component, attempt to use the first
               * relevant VEVENT subcomponent.  If there is none, the
               * NULL returned by icalcomponent_get_first_component() will
               * tell the next iteration of this function to create a
               * new one.
               */
              if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
                     save_individual_event(
                            icalcomponent_get_first_component(
                                   vevent, ICAL_VEVENT_COMPONENT),
                            msgnum, from, unread, NULL
                     );
                     return;
              }
       }
       else {
              vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
              created_new_vevent = 1;
       }

       if ( (havebstr("save_button"))
          || (havebstr("check_button")) ) {

              /* Replace values in the component with ones from the form */

              while (prop = icalcomponent_get_first_property(vevent,
                    ICAL_SUMMARY_PROPERTY), prop != NULL) {
                     icalcomponent_remove_property(vevent, prop);
                     icalproperty_free(prop);
              }

              /* Add NOW() to the calendar object... */
              icalcomponent_set_dtstamp(vevent,
                                     icaltime_from_timet(
                                            time(NULL), 0));

              if (havebstr("summary")) {
                     icalcomponent_add_property(vevent,
                                   icalproperty_new_summary(bstr("summary")));
              } else {
                     icalcomponent_add_property(vevent,
                                   icalproperty_new_summary(_("Untitled Event")));
              }

              while (prop = icalcomponent_get_first_property(vevent,
                                   ICAL_LOCATION_PROPERTY), prop != NULL) {
                     icalcomponent_remove_property(vevent, prop);
                     icalproperty_free(prop);
              }
              if (havebstr("location")) {
                     icalcomponent_add_property(vevent,
                                   icalproperty_new_location(bstr("location")));
              }
              while (prop = icalcomponent_get_first_property(vevent,
                              ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
                     icalcomponent_remove_property(vevent, prop);
                     icalproperty_free(prop);
              }
              if (havebstr("description")) {
                     icalcomponent_add_property(vevent,
                            icalproperty_new_description(bstr("description")));
              }

              while (prop = icalcomponent_get_first_property(vevent,
                    ICAL_DTSTART_PROPERTY), prop != NULL) {
                     icalcomponent_remove_property(vevent, prop);
                     icalproperty_free(prop);
              }

              if (yesbstr("alldayevent")) {
                     all_day_event = 1;
              }
              else {
                     all_day_event = 0;
              }

              if (all_day_event) {
                     icaltime_from_webform_dateonly(&event_start, "dtstart");
              }
              else {
                     icaltime_from_webform(&event_start, "dtstart");
              }

              prop = icalproperty_new_dtstart(event_start);

              if (all_day_event) {
                     /* Force it to serialize as a date-only rather than date/time */
                     icalproperty_set_value(prop, icalvalue_new_date(event_start));
              }

              if (prop) icalcomponent_add_property(vevent, prop);
              else icalproperty_free(prop);

              while (prop = icalcomponent_get_first_property(vevent,
                    ICAL_DTEND_PROPERTY), prop != NULL) {
                     icalcomponent_remove_property(vevent, prop);
                     icalproperty_free(prop);
              }
              while (prop = icalcomponent_get_first_property(vevent,
                    ICAL_DURATION_PROPERTY), prop != NULL) {
                     icalcomponent_remove_property(vevent, prop);
                     icalproperty_free(prop);
              }

              if (all_day_event) {
                     icaltime_from_webform_dateonly(&t, "dtend");

                     /* with this field supposed to be non-inclusive we have to add one day */
                     icaltime_adjust(&t, 1, 0, 0, 0);
              }
              else {
                     icaltime_from_webform(&t, "dtend");
              }

              icalcomponent_add_property(vevent,
                     icalproperty_new_dtend(icaltime_normalize(t)
                     )
              );

              /* recurrence rules -- begin */

              /* remove any existing rule */
              while (prop = icalcomponent_get_first_property(vevent, ICAL_RRULE_PROPERTY), prop != NULL) {
                     icalcomponent_remove_property(vevent, prop);
                     icalproperty_free(prop);
              }

              if (yesbstr("is_recur")) {
                     struct icalrecurrencetype recur;
                     icalrecurrencetype_clear(&recur);

                     recur.interval = atoi(bstr("interval"));
                     recur.freq = atoi(bstr("freq"));

                     switch(recur.freq) {

                            /* These can't happen; they're disabled. */
                            case ICAL_SECONDLY_RECURRENCE:
                                   break;
                            case ICAL_MINUTELY_RECURRENCE:
                                   break;
                            case ICAL_HOURLY_RECURRENCE:
                                   break;

                            /* Daily is valid but there are no further inputs. */
                            case ICAL_DAILY_RECURRENCE:
                                   break;

                            /* These are the real options. */

                            case ICAL_WEEKLY_RECURRENCE:
                                   j=0;
                                   for (i=0; i<7; ++i) {
                                          snprintf(buf, sizeof buf, "weekday%d", i);
                                          if (YESBSTR(buf)) recur.by_day[j++] =
                                                 icalrecurrencetype_day_day_of_week(i+1);
                                   }
                                   recur.by_day[j++] = ICAL_RECURRENCE_ARRAY_MAX;
                                   break;

                            case ICAL_MONTHLY_RECURRENCE:
                                   if (!strcasecmp(bstr("rrmonthtype"), "rrmonthtype_mday")) {
                                          recur.by_month_day[0] = event_start.day;
                                          recur.by_month_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
                                   }
                                   else if (!strcasecmp(bstr("rrmonthtype"), "rrmonthtype_wday")) {
                                          recur.by_day[0] = (atoi(bstr("rrmweek")) * 8)
                                                        + atoi(bstr("rrmweekday")) + 1;
                                          recur.by_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
                                   }
                                   break;

                            case ICAL_YEARLY_RECURRENCE:
                                   if (!strcasecmp(bstr("rryeartype"), "rryeartype_ymday")) {
                                          /* no further action is needed here */
                                   }
                                   else if (!strcasecmp(bstr("rryeartype"), "rryeartype_ywday")) {
                                          recur.by_month[0] = atoi(bstr("rrymonth"));
                                          recur.by_month[1] = ICAL_RECURRENCE_ARRAY_MAX;
                                          recur.by_day[0] = (atoi(bstr("rrymweek")) * 8)
                                                        + atoi(bstr("rrymweekday")) + 1;
                                          recur.by_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
                                   }
                                   break;

                            /* This one can't happen either. */
                            case ICAL_NO_RECURRENCE:
                                   break;
                     }

                     if (!strcasecmp(bstr("rrend"), "rrend_count")) {
                            recur.count = atoi(bstr("rrcount"));
                     }
                     else if (!strcasecmp(bstr("rrend"), "rrend_until")) {
                            icaltime_from_webform_dateonly(&recur.until, "rruntil");
                     }

                     icalcomponent_add_property(vevent, icalproperty_new_rrule(recur));
              }

              /* recurrence rules -- end */

              /* See if transparency is indicated */
              if (havebstr("transp")) {
                     if (!strcasecmp(bstr("transp"), "opaque")) {
                            formtransp = ICAL_TRANSP_OPAQUE;
                     }
                     else if (!strcasecmp(bstr("transp"), "transparent")) {
                            formtransp = ICAL_TRANSP_TRANSPARENT;
                     }

                     while (prop = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY),
                           (prop != NULL)) {
                            icalcomponent_remove_property(vevent, prop);
                            icalproperty_free(prop);
                     }

                     icalcomponent_add_property(vevent, icalproperty_new_transp(formtransp));
              }

              /* Give this event a UID if it doesn't have one. */
              if (icalcomponent_get_first_property(vevent,
                 ICAL_UID_PROPERTY) == NULL) {
                     generate_uuid(buf);
                     icalcomponent_add_property(vevent, icalproperty_new_uid(buf));
              }

              /* Increment the sequence ID */
              while (prop = icalcomponent_get_first_property(vevent,
                    ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
                     i = icalproperty_get_sequence(prop);
                     if (i > sequence) sequence = i;
                     icalcomponent_remove_property(vevent, prop);
                     icalproperty_free(prop);
              }
              ++sequence;
              icalcomponent_add_property(vevent,
                     icalproperty_new_sequence(sequence)
              );

              /*
               * Set the organizer, only if one does not already exist *and*
               * the form is supplying one
               */
              strcpy(buf, bstr("organizer"));
              if ( (icalcomponent_get_first_property(vevent,
                 ICAL_ORGANIZER_PROPERTY) == NULL)
                 && (!IsEmptyStr(buf)) ) {

                     /* set new organizer */
                     sprintf(organizer_string, "MAILTO:%s", buf);
                     icalcomponent_add_property(vevent,
                            icalproperty_new_organizer(organizer_string)
                     );

              }

              /*
               * Add any new attendees listed in the web form
               */

              /* First, strip out the parenthesized partstats.  */
              strcpy(form_attendees, bstr("attendees"));
              while (       stripout(form_attendees, '(', ')') != 0);

              /* Next, change any commas to newlines, because we want newline-separated attendees. */
              j = strlen(form_attendees);
              for (i=0; i<j; ++i) {
                     if (form_attendees[i] == ',') {
                            form_attendees[i] = '\n';
                            while (isspace(form_attendees[i+1])) {
                                   strcpy(&form_attendees[i+1], &form_attendees[i+2]);
                            }
                     }
              }

              /* Now iterate! */
              for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
                     extract_token(buf, form_attendees, i, '\n', sizeof buf);
                     striplt(buf);
                     if (!IsEmptyStr(buf)) {
                            sprintf(attendee_string, "MAILTO:%s", buf);
                            foundit = 0;

                            for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
                                   ch = icalproperty_get_attendee(attendee);
                                   if ((ch != NULL) && !strcasecmp(attendee_string, ch))
                                          ++foundit;
                            }


                            if (foundit == 0) {
                                   icalcomponent_add_property(vevent,
                                                           icalproperty_new_attendee(attendee_string)
                                   );
                            }
                     }
              }

              /*
               * Remove any attendees *not* listed in the web form
               */
STARTOVER:    for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
                     ch = icalproperty_get_attendee(attendee);
                     if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
                            safestrncpy(attendee_string, ch + 7, sizeof(attendee_string));
                            striplt(attendee_string);
                            foundit = 0;
                            for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
                                   extract_token(buf, form_attendees, i, '\n', sizeof buf);
                                   striplt(buf);
                                   if (!strcasecmp(buf, attendee_string)) ++foundit;
                            }
                            if (foundit == 0) {
                                   icalcomponent_remove_property(vevent, attendee);
                                   icalproperty_free(attendee);
                                   goto STARTOVER;
                            }
                     }
              }

              /*
               * Encapsulate event into full VCALENDAR component.  Clone it first,
               * for two reasons: one, it's easier to just free the whole thing
               * when we're done instead of unbundling, but more importantly, we
               * can't encapsulate something that may already be encapsulated
               * somewhere else.
               */
              encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(vevent));

              /* Set the method to PUBLISH */
              icalcomponent_set_method(encaps, ICAL_METHOD_PUBLISH);

              /* If the user clicked 'Save' then save it to the server. */
              if ( (encaps != NULL) && (havebstr("save_button")) ) {
                     serv_puts("ENT0 1|||4|||1|");
                     serv_getln(buf, sizeof buf);
                     switch (buf[0]) {
                     case '8':
                            serv_puts("Content-type: text/calendar");
                            serv_puts("Content-Transfer-Encoding: quoted-printable");
                            serv_puts("");
                            text_to_server_qp(icalcomponent_as_ical_string(encaps));
//                          serv_puts(icalcomponent_as_ical_string(encaps));
                            serv_puts("000");
                     case '4':
                            while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {}
                            break;
                     case '2':
                            AppendImportantMessage(buf + 4, - 1);
                            break;
                     default:
                            break;
                     }
                     icalmemory_free_ring ();
                     icalcomponent_free(encaps);
                     encaps = NULL;
              }

              /* Or, check attendee availability if the user asked for that. */
              if ( (encaps != NULL) && (havebstr("check_button")) ) {

                     /* Call this function, which does the real work */
                     check_attendee_availability(encaps);

                     /* This displays the form again, with our annotations */
                     display_edit_individual_event(encaps, msgnum, from, unread, NULL);

                     icalcomponent_free(encaps);
                     encaps = NULL;
              }
              if (encaps != NULL) {
                     icalcomponent_free(encaps);
                     encaps = NULL;
              }

       }

       /*
        * If the user clicked 'Delete' then delete it.
        */
       if ( (havebstr("delete_button")) && (msgnum > 0L) ) {
              serv_printf("DELE %ld", lbstr("msgnum"));
              serv_getln(buf, sizeof buf);
       }

       if (created_new_vevent) {
              icalcomponent_free(vevent);
       }

       /* If this was a save or delete, go back to the calendar or summary view. */
       if (!havebstr("check_button")) {
              if (!strcasecmp(bstr("calview"), "summary")) {
                     display_summary_page();
              }
              else {
                     readloop(readfwd, eUseDefault);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int tasks_LoadMsgFromServer ( SharedMessageStatus Stat,
void **  ViewSpecific,
message_summary Msg,
int  is_new,
int  i 
)

Definition at line 665 of file tasks.c.

{
       /* Not (yet?) needed here? calview *c = (calview *) *ViewSpecific; */

       load_ical_object(Msg->msgnum, is_new, ICAL_VTODO_COMPONENT, load_task, NULL, 0);
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function: