edd0ff150f75f9daab5105fd8858f8be4e3a4156
[citadel.git] / webcit / ical_subst.c
1 /*
2  * Copyright (c) 1996-2012 by the citadel.org team
3  *
4  * This program is open source software.  You can redistribute it and/or
5  * modify it under the terms of the GNU General Public License, version 3.
6  * 
7  * 
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * 
15  * 
16  * 
17  */
18
19 #include "webcit.h"
20
21 extern IcalEnumMap icalproperty_kind_map[];
22
23 HashList *IcalComponentMap = NULL;
24
25 #if 0
26 void SortPregetMatter(HashList *Cals)
27 {
28         disp_cal *Cal;
29         void *vCal;
30         const char *Key;
31         long KLen;
32         IcalEnumMap *SortMap[10];
33         IcalEnumMap *Map;
34         void *vSort;
35         const char *Next = NULL;
36         const StrBuf *SortVector;
37         StrBuf *SortBy;
38         int i = 0;
39         HashPos *It;
40
41         SortVector = SBSTR("ICALSortVec");
42         if (SortVector == NULL)
43                 return;
44
45         for (i = 0; i < 10; i++) SortMap[i] = NULL;
46         SortBy = NewStrBuf();
47         while (StrBufExtract_NextToken(SortBy, SortVector, &Next, ':') > 0) {
48                 GetHash(IcalComponentMap, SKEY(SortBy), &vSort);
49                 Map = (IcalEnumMap*) vSort;
50                 SortMap[i] = Map;
51                 i++;
52                 if (i > 9)
53                         break;
54         }
55
56         if (i == 0)
57                 return;
58
59         switch (SortMap[i - 1]->map) {
60                 ///     case 
61
62         default:
63                 break;
64         }
65
66         It = GetNewHashPos(Cals, 0);
67         while (GetNextHashPos(Cals, It, &KLen, &Key, &vCal)) {
68                 i = 0;
69                 Cal = (disp_cal*) vCal;
70                 Cal->Status = icalcomponent_get_status(Cal->cal);
71                 Cal->SortBy = Cal->cal;
72                 
73
74                 while ((SortMap[i] != NULL) && 
75                        (Cal->SortBy != NULL)) 
76                 {
77                         /****Cal->SortBy = icalcomponent_get_first_property(Cal->SortBy, SortMap[i++]->map); */
78                 }
79         }
80 }
81 #endif
82
83
84 void tmplput_ICalItem(StrBuf *Target, WCTemplputParams *TP)
85 {
86
87 }
88
89 void CreateIcalComponendKindLookup(void)
90 {
91         int i = 0;
92
93         IcalComponentMap = NewHash (1, NULL);
94         while (icalproperty_kind_map[i].NameLen != 0) {
95                 RegisterNS(icalproperty_kind_map[i].Name, 
96                            icalproperty_kind_map[i].NameLen, 
97                            0, 
98                            10, 
99                            tmplput_ICalItem,
100                            NULL, 
101                            CTX_ICAL);
102                 Put(IcalComponentMap, 
103                     icalproperty_kind_map[i].Name, 
104                     icalproperty_kind_map[i].NameLen, 
105                     &icalproperty_kind_map[i],
106                     reference_free_handler);
107                            
108                            
109                 i++;
110         }
111 }
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128 void 
129 InitModule_ICAL_SUBST
130 (void)
131 {
132         CreateIcalComponendKindLookup ();
133
134 }
135
136 void 
137 ServerShutdownModule_ICAL
138 (void)
139 {
140         DeleteHash(&IcalComponentMap);
141 }