From: Wilfried Göesgens Date: Sat, 11 Apr 2009 12:01:32 +0000 (+0000) Subject: * first work on doing ical elements in templates. does nothing usefull yet. X-Git-Tag: v7.86~1286 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=6c69c17330a725e46868931521dac203a9beb7f3 * first work on doing ical elements in templates. does nothing usefull yet. --- diff --git a/webcit/Makefile.in b/webcit/Makefile.in index d75761da0..5286d4e62 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -53,6 +53,7 @@ webcit: webserver.o context_loop.o ical_dezonify.o \ groupdav_delete.o groupdav_put.o http_datestring.o setup_wizard.o \ downloads.o addressbook_popup.o pushemail.o sysdep.o openid.o \ decode.o modules_init.o paramhandling.o utils.o \ + ical_maps.o ical_subst.o \ $(LIBOBJS) $(CC) $(LDFLAGS) $(LIBOBJS) $(LIBS) \ webserver.o context_loop.o cookie_conversion.o \ @@ -66,7 +67,7 @@ webcit: webserver.o context_loop.o ical_dezonify.o \ groupdav_options.o autocompletion.o tabs.o smtpqueue.o sieve.o \ groupdav_put.o http_datestring.o setup_wizard.o fmt_date.o modules_init.o \ gettext.o downloads.o addressbook_popup.o pushemail.o sysdep.o decode.o \ - paramhandling.o utils.o \ + paramhandling.o utils.o ical_maps.o ical_subst.o \ -o webcit \ $(LIBS) diff --git a/webcit/get_ical_data.sed b/webcit/get_ical_data.sed new file mode 100755 index 000000000..d584f3672 --- /dev/null +++ b/webcit/get_ical_data.sed @@ -0,0 +1,11 @@ +#! /bin/sed -nf + +H +$ { + x + s/\n//g + p +} +$ { + s/.*icalproperty_kind {\(.*\)} icalproperty_kind.*/\1/ + } diff --git a/webcit/get_ical_data.sh b/webcit/get_ical_data.sh new file mode 100755 index 000000000..62e94b836 --- /dev/null +++ b/webcit/get_ical_data.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +( +printf '#include "webcit.h"\n\n\nIcalEnumMap icalproperty_kind_map[] = {\n' +cat /usr/include/libical/ical.h |\ +sed 's;/\*.*\*/;;' |\ +./get_ical_data.sed |\ +sed -e 's;.*icalproperty_kind {\(.*\)} icalproperty_kind.*;\1,;' \ + -e 's;/\*.*\*/;;' \ + -e 's;/;\n/\n;g' \ + -e 's;,;,\n;g' \ + -e 's; *;;g' \ + -e 's;^t*;;g' \ + -e 's;\=0;;g'|\ +sed -e 's;\(.*\),;{HKEY("\1"), \1},;' +printf '{"", 0, 0}\n};\n' + +)>ical_maps.c \ No newline at end of file diff --git a/webcit/ical_subst.c b/webcit/ical_subst.c new file mode 100644 index 000000000..8d44830fe --- /dev/null +++ b/webcit/ical_subst.c @@ -0,0 +1,118 @@ +#include "webcit.h" + + +extern IcalEnumMap icalproperty_kind_map[]; + + +HashList *IcalComponentMap = NULL; + +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); + } + } + + +} + + +void tmplput_ICalItem(StrBuf *Target, WCTemplputParams *TP) +{ + +} + +void CreateIcalComponendKindLookup(void) +{ + int i = 0; + + IcalComponentMap = NewHash (1, NULL); + while (icalproperty_kind_map[i].NameLen != 0) { + RegisterNS(icalproperty_kind_map[i].Name, + icalproperty_kind_map[i].NameLen, + 0, + 10, + tmplput_ICalItem, + CTX_ICAL); + Put(IcalComponentMap, + icalproperty_kind_map[i].Name, + icalproperty_kind_map[i].NameLen, + &icalproperty_kind_map[i], + reference_free_handler); + + + i++; + } +} + + + + + + + + + + + + + + + + +void +InitModule_ICAL_SUBST +(void) +{ + CreateIcalComponendKindLookup (); + +} diff --git a/webcit/subst.h b/webcit/subst.h index a45dfb258..fec6d9589 100644 --- a/webcit/subst.h +++ b/webcit/subst.h @@ -50,8 +50,9 @@ enum { #define CTX_ROOMS 14 #define CTX_FLOORS 15 #define CTX_ITERATE 16 +#define CTX_ICAL 17 -#define CTX_UNKNOWN 17 +#define CTX_UNKNOWN 18 /**