X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fical_subst.c;h=db30c668971f0292cd48bb3ab814c6eda431b095;hb=c7295725d9b7693cafa84c65890f2f0fe14c333b;hp=43a10f2eb503cbbb336425ec0d7b0de1b43fc7f5;hpb=6cc8e02c78fa3b6e46f447396cda18f190f3d0d1;p=citadel.git diff --git a/webcit/ical_subst.c b/webcit/ical_subst.c index 43a10f2eb..db30c6689 100644 --- a/webcit/ical_subst.c +++ b/webcit/ical_subst.c @@ -20,6 +20,8 @@ CtxType CTX_ICAL = CTX_NONE; CtxType CTX_ICALPROPERTY = CTX_NONE; CtxType CTX_ICALMETHOD = CTX_NONE; CtxType CTX_ICALTIME = CTX_NONE; +CtxType CTX_ICALATTENDEE = CTX_NONE; +CtxType CTX_ICALCONFLICT = CTX_NONE; #if 0 void SortPregetMatter(HashList *Cals) { @@ -265,14 +267,16 @@ void tmplput_CtxICalPropertyDate(StrBuf *Target, WCTemplputParams *TP) -void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset) +void render_MIME_ICS_TPL(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset) { + wc_mime_attachment *Mime = CTX(CTX_MIME_ATACH); icalproperty_method the_method = ICAL_METHOD_NONE; icalproperty *method = NULL; icalcomponent *cal; icalcomponent *c; WCTemplputParams SubTP; WCTemplputParams SuperTP; + static int divcount = 0; if (StrLength(Mime->Data) == 0) { @@ -288,6 +292,8 @@ void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun } putlbstr("divname", ++divcount); + + putbstr("cal_partnum", NewStrBufDup(Mime->PartNum)); putlbstr("msgnum", Mime->msgnum); @@ -305,8 +311,12 @@ void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun the_method = icalproperty_get_method(method); } - SuperTP.Context = &the_method; - SuperTP.Filter.ContextType = CTX_ICALMETHOD, + StackContext (TP, + &SuperTP, + &the_method, + CTX_ICALMETHOD, + 0, + TP->Tokens); StackContext (&SuperTP, &SubTP, @@ -327,6 +337,7 @@ void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun "EnableOrDisableCheckButton(); \n" ); + UnStackContext(&SuperTP); UnStackContext(&SubTP); icalcomponent_free(cal); } @@ -367,41 +378,160 @@ int cond_ICalIsMethod(StrBuf *Target, WCTemplputParams *TP) } +typedef struct CalendarConflict +{ + long is_update; + long existing_msgnum; + StrBuf *conflict_event_uid; + StrBuf *conflict_event_summary; +}CalendarConflict; +void DeleteConflict(void *vConflict) +{ + CalendarConflict *c = (CalendarConflict *) vConflict; + + FreeStrBuf(&c->conflict_event_uid); + FreeStrBuf(&c->conflict_event_summary); + free(c); +} +HashList *iterate_FindConflict(StrBuf *Target, WCTemplputParams *TP) +{ + StrBuf *Line; + HashList *Conflicts = NULL; + CalendarConflict *Conflict; + wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH); + + serv_printf("ICAL conflicts|%ld|%s|", Mime->msgnum, ChrPtr(Mime->PartNum)); + + Line = NewStrBuf(); + StrBuf_ServGetln(Line); + if (GetServerStatus(Line, NULL) == 1) + { + const char *Pos = NULL; + int Done = 0; + int n = 0; + Conflicts = NewHash(1, Flathash); + while(!Done && (StrBuf_ServGetln(Line) >= 0) ) + if ( (StrLength(Line)==3) && + !strcmp(ChrPtr(Line), "000")) + { + Done = 1; + } + else { + Conflict = (CalendarConflict *) malloc(sizeof(CalendarConflict *)); + Conflict->conflict_event_uid = NewStrBufPlain(NULL, StrLength(Line)); + Conflict->conflict_event_summary = NewStrBufPlain(NULL, StrLength(Line)); + + Conflict->existing_msgnum = StrBufExtractNext_long(Line, &Pos, '|'); + StrBufSkip_NTokenS(Line, &Pos, '|', 1); + StrBufExtract_NextToken(Conflict->conflict_event_uid, Line, &Pos, '|'); + StrBufExtract_NextToken(Conflict->conflict_event_summary, Line, &Pos, '|'); + Conflict->is_update = StrBufExtractNext_long(Line, &Pos, '|'); + + Put(Conflicts, IKEY(n), Conflict, DeleteConflict); + n++; + Pos = NULL; + } + } + syslog(9, "...done.\n"); + return Conflicts; +} + +void tmplput_ConflictEventMsgID(StrBuf *Target, WCTemplputParams *TP) +{ + CalendarConflict *C = (CalendarConflict *) CTX(CTX_ICALCONFLICT); + char buf[sizeof(long) * 16]; + snprintf(buf, sizeof(buf), "%ld", C->existing_msgnum); + StrBufAppendTemplateStr(Target, TP, buf, 0); +} +void tmplput_ConflictEUID(StrBuf *Target, WCTemplputParams *TP) +{ + CalendarConflict *C = (CalendarConflict *) CTX(CTX_ICALCONFLICT); + + StrBufAppendTemplate(Target, TP, C->conflict_event_uid, 0); +} +void tmplput_ConflictSummary(StrBuf *Target, WCTemplputParams *TP) +{ + CalendarConflict *C = (CalendarConflict *) CTX(CTX_ICALCONFLICT); + StrBufAppendTemplate(Target, TP, C->conflict_event_summary, 0); +} +int cond_ConflictIsUpdate(StrBuf *Target, WCTemplputParams *TP) +{ + CalendarConflict *C = (CalendarConflict *) CTX(CTX_ICALCONFLICT); + return C->is_update; +} -void tmplput_Conflict(StrBuf *Target, WCTemplputParams *TP) -{} +typedef struct CalAttendee +{ + StrBuf *AttendeeStr; + icalparameter_partstat partstat; +} CalAttendee; -HashList* IterateGetAttendees() +void DeleteAtt(void *vAtt) { -/* - /* If the component has attendees, iterate through them. * / + CalAttendee *att = (CalAttendee*) vAtt; + FreeStrBuf(&att->AttendeeStr); + free(vAtt); +} + +HashList *iterate_get_ical_attendees(StrBuf *Target, WCTemplputParams *TP) +{ + icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL); + icalparameter *partstat_param; + icalproperty *p; + CalAttendee *Att; + HashList *Attendees = NULL; + const char *ch; + int n = 0; + + /* 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, "