From 4edb7b450f6251cfd0da4e044c76c5eaf55f176e Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 24 Apr 2007 19:55:41 +0000 Subject: [PATCH] Meeting Accept/Decline and RSVP Update/Ignore controls are now AJAX-enabled. These dialogs now update 'in place' without a page refresh. --- webcit/calendar.c | 152 ++++++++++++++++------------------------- webcit/static/wclib.js | 15 ++++ 2 files changed, 74 insertions(+), 93 deletions(-) diff --git a/webcit/calendar.c b/webcit/calendar.c index d135355c4..73c3647c9 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -85,10 +85,14 @@ void cal_process_object(icalcomponent *cal, char conflict_name[256]; char conflict_message[256]; int is_update = 0; + char divname[32]; + static int divcount = 0; + + sprintf(divname, "rsvp%04x", ++divcount); /** Leading HTML for the display of this object */ if (recursion_level == 0) { - wprintf("
\n"); + wprintf("
\n"); } /** Look for a method */ @@ -97,40 +101,30 @@ void cal_process_object(icalcomponent *cal, /** See what we need to do with this */ if (method != NULL) { the_method = icalproperty_get_method(method); + char *title; + switch(the_method) { case ICAL_METHOD_REQUEST: - wprintf("\n"); + title = _("Meeting invitation"); break; case ICAL_METHOD_REPLY: - wprintf("\n"); + title = _("Attendee's reply to your invitation"); break; case ICAL_METHOD_PUBLISH: - wprintf("\n"); + title = _("Published event"); break; default: - wprintf("\n"); + title = _("This is an unknown type of calendar item."); break; } + + wprintf("\n", + title + ); } p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY); @@ -267,18 +261,23 @@ void cal_process_object(icalcomponent *cal, lprintf(9, "...done.\n"); /** Display the Accept/Decline buttons */ - wprintf("" - "\n", + "%s" + "" + "" + "\n", + divname, _("How would you like to respond to this invitation?"), - msgnum, cal_partnum, _("Accept"), - msgnum, cal_partnum, _("Tentative"), - msgnum, cal_partnum, _("Decline") + divname, divname, msgnum, cal_partnum, _("Accept"), + divname, divname, msgnum, cal_partnum, _("Tentative"), + divname, divname, msgnum, cal_partnum, _("Decline") ); } @@ -294,25 +293,27 @@ void cal_process_object(icalcomponent *cal, ***********/ /** Display the update buttons */ - wprintf("\n", + "" + "\n", + divname, _("Click Update to accept this reply and update your calendar."), - msgnum, cal_partnum, _("Update"), - msgnum, cal_partnum, _("Ignore") + divname, divname, msgnum, cal_partnum, _("Update"), + divname, divname, msgnum, cal_partnum, _("Ignore") ); } /** Trailing HTML for the display of this object */ if (recursion_level == 0) { - - wprintf("
\n" - "" - "  " - ""); - wprintf(_("Meeting invitation")); - wprintf("
\n" - "" - "  " - ""); - wprintf(_("Attendee's reply to your invitation")); - wprintf("
\n" - "" - "  " - ""); - wprintf(_("Published event")); - wprintf("
"); - wprintf(_("This is an unknown type of calendar item.")); - wprintf("
\n"); + wprintf("
", divname); + wprintf("" + "  %s
%s" - "%s" + wprintf("
" + "
" + "%s " + "" + "%s" " | " - "%s" + "%s" " | " - "%s" - "
" + wprintf("
" + "
" "%s" - "
" - "%s" + "" + "%s" " | " - "%s" + "%s" "" - "
\n"); + wprintf("\n"); } } @@ -351,18 +352,9 @@ void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum) { * Respond to a meeting request */ void respond_to_request(void) { - char buf[SIZ]; + char buf[1024]; - output_headers(1, 1, 2, 0, 0, 0); - - wprintf("
\n"); - wprintf("
" - ""); - wprintf(_("Respond to meeting request")); - wprintf("" - "
\n" - ); - wprintf("
\n
\n"); + begin_ajax_response(); serv_printf("ICAL respond|%s|%s|%s|", bstr("msgnum"), @@ -372,10 +364,8 @@ void respond_to_request(void) { serv_getln(buf, sizeof buf); if (buf[0] == '2') { - wprintf("
" - "" - "" - ); + wprintf("
"); + wprintf(""); if (!strcasecmp(bstr("sc"), "accept")) { wprintf(_("You have accepted this meeting invitation. " "It has been entered into your calendar.") @@ -391,19 +381,13 @@ void respond_to_request(void) { } wprintf(" "); wprintf(_("A reply has been sent to the meeting organizer.")); - wprintf("
\n"); + wprintf("
"); } else { - wprintf("" - "%s\n", &buf[4]); + wprintf(" "); + wprintf("%s\n", &buf[4]); } - wprintf("wc_roomname); - wprintf("\">
"); - wprintf(_("Return to messages")); - wprintf("

\n"); - - wDumpContent(1); + end_ajax_response(); } @@ -412,18 +396,9 @@ void respond_to_request(void) { * \brief Handle an incoming RSVP */ void handle_rsvp(void) { - char buf[SIZ]; - - output_headers(1, 1, 2, 0, 0, 0); + char buf[1024]; - wprintf("
\n"); - wprintf("
" - ""); - wprintf(_("Update your calendar with this RSVP")); - wprintf("" - "
\n" - "
\n
\n" - ); + begin_ajax_response(); serv_printf("ICAL handle_rsvp|%s|%s|%s|", bstr("msgnum"), @@ -433,10 +408,8 @@ void handle_rsvp(void) { serv_getln(buf, sizeof buf); if (buf[0] == '2') { - wprintf("
" - "" - "" - ); + wprintf("
"); + wprintf(""); if (!strcasecmp(bstr("sc"), "update")) { wprintf(_("Your calendar has been updated to reflect this RSVP.")); } else if (!strcasecmp(bstr("sc"), "ignore")) { @@ -444,20 +417,13 @@ void handle_rsvp(void) { "Your calendar has not been updated.") ); } - wprintf("
\n" - ); + wprintf("
"); } else { - wprintf("" - "%s\n", &buf[4]); + wprintf(" %s\n", &buf[4]); } - wprintf("wc_roomname); - wprintf("\">
"); - wprintf(_("Return to messages")); - wprintf("

\n"); + end_ajax_response(); - wDumpContent(1); } diff --git a/webcit/static/wclib.js b/webcit/static/wclib.js index 19557fd64..6f1c0a1cb 100644 --- a/webcit/static/wclib.js +++ b/webcit/static/wclib.js @@ -707,3 +707,18 @@ function AddContactsToTarget(target, whichaddr) { whichaddr.options[whichaddr.selectedIndex].selected = false; } } + +// Respond to a meeting invitation +function RespondToInvitation(question_divname, title_divname, msgnum, cal_partnum, sc) { + p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ; + new Ajax.Updater(title_divname, 'respond_to_request', { method: 'post', parameters: p } ); + Effect.Fade(question_divname, { duration: 0.5 }); +} + +// Handle a received RSVP +function HandleRSVP(question_divname, title_divname, msgnum, cal_partnum, sc) { + p = 'msgnum=' + msgnum + '&cal_partnum=' + cal_partnum + '&sc=' + sc ; + new Ajax.Updater(title_divname, 'handle_rsvp', { method: 'post', parameters: p } ); + Effect.Fade(question_divname, { duration: 0.5 }); +} + -- 2.39.2