X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fical_subst.c;h=adb923882994665fdf53883134a02ebc672ccf77;hb=HEAD;hp=43a10f2eb503cbbb336425ec0d7b0de1b43fc7f5;hpb=6cc8e02c78fa3b6e46f447396cda18f190f3d0d1;p=citadel.git diff --git a/webcit/ical_subst.c b/webcit/ical_subst.c index 43a10f2eb..adb923882 100644 --- a/webcit/ical_subst.c +++ b/webcit/ical_subst.c @@ -20,64 +20,8 @@ CtxType CTX_ICAL = CTX_NONE; CtxType CTX_ICALPROPERTY = CTX_NONE; CtxType CTX_ICALMETHOD = CTX_NONE; CtxType CTX_ICALTIME = CTX_NONE; -#if 0 -void SortPregetMatter(HashList *Cals) -{ - disp_cal *Cal; - void *vCal; - const char *Key; - long KLen; - IcalEnumMap *SortMap[10]; - IcalEnumMap *Map; - void *vSort; - const char *Next = NULL; - const StrBuf *SortVector; - StrBuf *SortBy; - int i = 0; - HashPos *It; - - SortVector = SBSTR("ICALSortVec"); - if (SortVector == NULL) - return; - - for (i = 0; i < 10; i++) SortMap[i] = NULL; - SortBy = NewStrBuf(); - while (StrBufExtract_NextToken(SortBy, SortVector, &Next, ':') > 0) { - GetHash(IcalComponentMap, SKEY(SortBy), &vSort); - Map = (IcalEnumMap*) vSort; - SortMap[i] = Map; - i++; - if (i > 9) - break; - } - - if (i == 0) - return; - - switch (SortMap[i - 1]->map) { - /* case */ - - default: - break; - } - - It = GetNewHashPos(Cals, 0); - while (GetNextHashPos(Cals, It, &KLen, &Key, &vCal)) { - i = 0; - Cal = (disp_cal*) vCal; - Cal->Status = icalcomponent_get_status(Cal->cal); - Cal->SortBy = Cal->cal; - - - while ((SortMap[i] != NULL) && - (Cal->SortBy != NULL)) - { - /****Cal->SortBy = icalcomponent_get_first_property(Cal->SortBy, SortMap[i++]->map); */ - } - } -} -#endif - +CtxType CTX_ICALATTENDEE = CTX_NONE; +CtxType CTX_ICALCONFLICT = CTX_NONE; void tmplput_ICalItem(StrBuf *Target, WCTemplputParams *TP) { @@ -265,14 +209,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; + icalcomponent *cal = NULL; + icalcomponent *c = NULL; WCTemplputParams SubTP; WCTemplputParams SuperTP; + static int divcount = 0; if (StrLength(Mime->Data) == 0) { @@ -288,6 +234,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 +253,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, @@ -315,7 +267,8 @@ void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun 0, SuperTP.Tokens); FlushStrBuf(Mime->Data); - DoTemplate(HKEY("ical_attachment_display"), Mime->Data, &SubTP); +/// DoTemplate(HKEY("ical_attachment_display"), Mime->Data, &SubTP); + DoTemplate(HKEY("ical_edit"), Mime->Data, &SubTP); /*/ cal_process_object(Mime->Data, cal, 0, Mime->msgnum, ChrPtr(Mime->PartNum)); */ @@ -327,6 +280,7 @@ void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun "EnableOrDisableCheckButton(); \n" ); + UnStackContext(&SuperTP); UnStackContext(&SubTP); icalcomponent_free(cal); } @@ -367,51 +321,169 @@ 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; + } + } + FreeStrBuf(&Line); + syslog(LOG_DEBUG, "...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; +} +typedef struct CalAttendee +{ + StrBuf *AttendeeStr; + icalparameter_partstat partstat; +} CalAttendee; -void tmplput_Conflict(StrBuf *Target, WCTemplputParams *TP) -{} +void DeleteAtt(void *vAtt) +{ + CalAttendee *att = (CalAttendee*) vAtt; + FreeStrBuf(&att->AttendeeStr); + free(vAtt); +} -HashList* IterateGetAttendees() +HashList *iterate_get_ical_attendees(StrBuf *Target, WCTemplputParams *TP) { -/* - /* If the component has attendees, iterate through them. * / + 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, "