From 716dc48890328a0d892ae02e1ff1b65917d76f54 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sat, 27 Oct 2012 20:09:52 +0200 Subject: [PATCH] ICAL-SUBST: work on viewing - flip stacking of contexts - won't work the other way around. - add missing bstrs for the template - fix copying of icaltimetype struct. --- webcit/ical_subst.c | 84 ++++++++++++---- webcit/static/t/ical/attachment/display.html | 100 ++++--------------- 2 files changed, 84 insertions(+), 100 deletions(-) diff --git a/webcit/ical_subst.c b/webcit/ical_subst.c index 1690b4b26..e48b2f990 100644 --- a/webcit/ical_subst.c +++ b/webcit/ical_subst.c @@ -157,34 +157,31 @@ int cond_ICalHaveTimeItem(StrBuf *Target, WCTemplputParams *TP) icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL); icalproperty *p; icalproperty_kind Kind; - struct icaltimetype tt; Kind = (icalproperty_kind) GetTemplateTokenNumber(Target, TP, 2, ICAL_ANY_PROPERTY); - - p = icalcomponent_get_first_property(cal, Kind); if (p != NULL) { struct icaltimetype *t; - time_t ttt; + struct icaltimetype tt; WCTemplputParams *DynamicTP; DynamicTP = (WCTemplputParams*) malloc(sizeof(WCTemplputParams) + sizeof(struct icaltimetype)); t = (struct icaltimetype *) ((char*)DynamicTP) + sizeof(WCTemplputParams); + memset(&tt, 0, sizeof(struct icaltimetype)); switch (Kind) { case ICAL_DTSTART_PROPERTY: - *t = icalproperty_get_dtstart(p); + tt = icalproperty_get_dtstart(p); break; case ICAL_DTEND_PROPERTY: tt = icalproperty_get_dtend(p); - ttt = icaltime_as_timet(tt); break; default: - memset(t, 0, sizeof(struct icaltimetype)); break; } - + memcpy(t, &tt, sizeof(struct icaltimetype)); + StackDynamicContext (TP, DynamicTP, t, @@ -275,7 +272,8 @@ void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun icalcomponent *cal; icalcomponent *c; WCTemplputParams SubTP; - WCTemplputParams SubSubTP; + WCTemplputParams SuperTP; + static int divcount = 0; if (StrLength(Mime->Data) == 0) { MimeLoadData(Mime); @@ -289,29 +287,33 @@ void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun return; } + putlbstr("divname", ++divcount); + putbstr("cal_partnum", NewStrBufDup(Mime->PartNum)); + putlbstr("msgnum", Mime->msgnum); + memset(&SubTP, 0, sizeof(WCTemplputParams)); - memset(&SubSubTP, 0, sizeof(WCTemplputParams)); - SubTP.Filter.ContextType = CTX_ICAL; + memset(&SuperTP, 0, sizeof(WCTemplputParams)); /*//ical_dezonify(cal); */ /* If the component has subcomponents, recurse through them. */ c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT); - c = (c != NULL) ? c : cal; - SubTP.Context = c; - method = icalcomponent_get_first_property(c, ICAL_METHOD_PROPERTY); + method = icalcomponent_get_first_property(cal, ICAL_METHOD_PROPERTY); if (method != NULL) { the_method = icalproperty_get_method(method); } - StackContext (&SubTP, - &SubSubTP, - &the_method, - CTX_ICALMETHOD, + SuperTP.Context = &the_method; + SuperTP.Filter.ContextType = CTX_ICALMETHOD, + + StackContext (&SuperTP, + &SubTP, + c, + CTX_ICAL, 0, - SubTP.Tokens); + SuperTP.Tokens); FlushStrBuf(Mime->Data); DoTemplate(HKEY("ical_attachment_display"), Mime->Data, &SubTP); @@ -325,7 +327,7 @@ void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun "EnableOrDisableCheckButton(); \n" ); - UnStackContext(&SubSubTP); + UnStackContext(&SubTP); icalcomponent_free(cal); } void CreateIcalComponendKindLookup(void) @@ -360,7 +362,7 @@ int cond_ICalIsMethod(StrBuf *Target, WCTemplputParams *TP) icalproperty_method *the_method = (icalproperty_method *) CTX(CTX_ICALMETHOD); icalproperty_method which_method; - which_method = GetTemplateTokenNumber(Target, TP, 3, ICAL_METHOD_X); + which_method = GetTemplateTokenNumber(Target, TP, 2, ICAL_METHOD_X); return *the_method == which_method; } @@ -370,7 +372,45 @@ int cond_ICalIsMethod(StrBuf *Target, WCTemplputParams *TP) +void tmplput_Conflict(StrBuf *Target, WCTemplputParams *TP) +{} +HashList* IterateGetAttendees() +{ +/* + /* If the component has attendees, iterate through them. * / + for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); + (p != NULL); + p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) { + StrBufAppendPrintf(Target, "
"); + StrBufAppendPrintf(Target, _("Attendee:")); + StrBufAppendPrintf(Target, "
"); + ch = icalproperty_get_attendee(p); + if ((ch != NULL) && !strncasecmp(buf, "MAILTO:", 7)) { + + /** screen name or email address * / + safestrncpy(buf, ch + 7, sizeof(buf)); + striplt(buf); + StrEscAppend(Target, NULL, buf, 0, 0); + StrBufAppendPrintf(Target, " "); + + /** participant status * / + partstat_as_string(buf, p); + StrEscAppend(Target, NULL, buf, 0, 0); + } + StrBufAppendPrintf(Target, "
\n"); + } +*/ + return NULL; + /* If the component has subcomponents, recurse through them. * / + for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT); + (c != 0); + c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) { + /* Recursively process subcomponent * / + cal_process_object(Target, c, recursion_level+1, msgnum, cal_partnum); + } + */ +} @@ -388,6 +428,8 @@ InitModule_ICAL_SUBST RegisterConditional("COND:ICAL:PROPERTY", 1, cond_ICalHaveItem, CTX_ICAL); RegisterConditional("COND:ICAL:IS:A", 1, cond_ICalIsA, CTX_ICAL); + RegisterNamespace("ICAL:SERV:CHECK:CONFLICT", 0, 0, tmplput_Conflict, NULL, CTX_ICAL); + RegisterCTX(CTX_ICALPROPERTY); RegisterNamespace("ICAL:ITEM", 1, 2, tmplput_ICalItem, NULL, CTX_ICAL); RegisterNamespace("ICAL:PROPERTY:STR", 0, 1, tmplput_CtxICalProperty, NULL, CTX_ICALPROPERTY); diff --git a/webcit/static/t/ical/attachment/display.html b/webcit/static/t/ical/attachment/display.html index 13dbc9c00..54e5b5625 100644 --- a/webcit/static/t/ical/attachment/display.html +++ b/webcit/static/t/ical/attachment/display.html @@ -1,51 +1,21 @@ -aaa - -abc - - -blarg - -blub - - -datum: - - - -xxxx - - - -cde - - - -efg - - - - -hij - -
-
_title"> +
_title">   
- + - - + + - - + + - +
@@ -61,12 +31,12 @@ hij - +
- +
- + @@ -85,38 +55,10 @@ hij
.
- /* If the component has attendees, iterate through them. */ - for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); - (p != NULL); - p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) { - StrBufAppendPrintf(Target, "
"); - StrBufAppendPrintf(Target, _("Attendee:")); - StrBufAppendPrintf(Target, "
"); - ch = icalproperty_get_attendee(p); - if ((ch != NULL) && !strncasecmp(buf, "MAILTO:", 7)) { - - /** screen name or email address */ - safestrncpy(buf, ch + 7, sizeof(buf)); - striplt(buf); - StrEscAppend(Target, NULL, buf, 0, 0); - StrBufAppendPrintf(Target, " "); - - /** participant status */ - partstat_as_string(buf, p); - StrEscAppend(Target, NULL, buf, 0, 0); - } - StrBufAppendPrintf(Target, "
\n"); - } - /* If the component has subcomponents, recurse through them. */ - for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT); - (c != 0); - c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) { - /* Recursively process subcomponent */ - cal_process_object(Target, c, recursion_level+1, msgnum, cal_partnum); - } - + + @@ -124,28 +66,28 @@ hij
-

_question"> +

_question">     -_question','_title','','','Accept');"> +_question','rsvp_title','','','Accept');">     -_question','_title','','','Tentative');"> +_question','rsvp_title','','','Tentative');">     -_question','_title','','','Decline');"> +_question','rsvp_title','','','Decline');">

- + -

_question" > +

_question" > Update to accept this reply and update your calendar.")>     -_question','_title','','','Update');"> +_question','rsvp_title','','','Update');">     -_question','_title','','','Ignore');"> +_question','rsvp_title','','','Ignore');">

- + if (recursion_level == 0) { -- 2.30.2