* first work on doing ical elements in templates. does nothing usefull yet.
authorWilfried Göesgens <willi@citadel.org>
Sat, 11 Apr 2009 12:01:32 +0000 (12:01 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sat, 11 Apr 2009 12:01:32 +0000 (12:01 +0000)
webcit/Makefile.in
webcit/get_ical_data.sed [new file with mode: 0755]
webcit/get_ical_data.sh [new file with mode: 0755]
webcit/ical_subst.c [new file with mode: 0644]
webcit/subst.h

index d75761da0b757754a0c121b099789c5da664f9bd..5286d4e623d2a1665a145da847fc8364b2651041 100644 (file)
@@ -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 (executable)
index 0000000..d584f36
--- /dev/null
@@ -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 (executable)
index 0000000..62e94b8
--- /dev/null
@@ -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 (file)
index 0000000..8d44830
--- /dev/null
@@ -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 ();
+
+}
index a45dfb2582e08f61cac3ffaa4cde23490df3641b..fec6d958925861a2f98d5a74f36798de4ece996f 100644 (file)
@@ -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
 
 
 /**