2 * Lots of different room-related operations.
8 char *viewdefs[VIEW_MAX]; /* the different kinds of available views */
10 ROOM_VIEWS exchangeable_views[VIEW_MAX][VIEW_MAX] = {
11 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 1 }, /* bulletin board */
12 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 1 }, /* mailbox summary */
13 { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, /* address book */
14 { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, /* calendar */
15 { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }, /* tasks */
16 { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, /* notes */
17 { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 }, /* wiki */
18 { 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 }, /* brief calendar */
19 { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, /* journal */
20 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 1 } /* blog */
23 ROOM_VIEWS allowed_default_views[VIEW_MAX] = {
24 1, /* VIEW_BBS Bulletin board view */
25 1, /* VIEW_MAILBOX Mailbox summary */
26 1, /* VIEW_ADDRESSBOOK Address book view */
27 1, /* VIEW_CALENDAR Calendar view */
28 1, /* VIEW_TASKS Tasks view */
29 1, /* VIEW_NOTES Notes view */
30 1, /* VIEW_WIKI Wiki view */
31 0, /* VIEW_CALBRIEF Brief Calendar view */
32 0, /* VIEW_JOURNAL Journal view */
33 0 /* VIEW_BLOG Blog view (not yet implemented) */
37 * Initialize the viewdefs with localized strings
39 void initialize_viewdefs(void) {
40 viewdefs[VIEW_BBS] = _("Bulletin Board");
41 viewdefs[VIEW_MAILBOX] = _("Mail Folder");
42 viewdefs[VIEW_ADDRESSBOOK] = _("Address Book");
43 viewdefs[VIEW_CALENDAR] = _("Calendar");
44 viewdefs[VIEW_TASKS] = _("Task List");
45 viewdefs[VIEW_NOTES] = _("Notes List");
46 viewdefs[VIEW_WIKI] = _("Wiki");
47 viewdefs[VIEW_CALBRIEF] = _("Calendar List");
48 viewdefs[VIEW_JOURNAL] = _("Journal");
49 viewdefs[VIEW_BLOG] = _("Blog");
54 void tmplput_ROOM_COLLECTIONTYPE(StrBuf *Target, WCTemplputParams *TP)
56 folder *Folder = (folder *)CTX;
58 switch(Folder->view) {
60 StrBufAppendBufPlain(Target, HKEY("vevent"), 0);
63 StrBufAppendBufPlain(Target, HKEY("vtodo"), 0);
65 case VIEW_ADDRESSBOOK:
66 StrBufAppendBufPlain(Target, HKEY("vcard"), 0);
69 StrBufAppendBufPlain(Target, HKEY("vnotes"), 0);
72 StrBufAppendBufPlain(Target, HKEY("vjournal"), 0);
75 StrBufAppendBufPlain(Target, HKEY("wiki"), 0);
82 int ConditionalRoomHasGroupdavContent(StrBuf *Target, WCTemplputParams *TP)
84 folder *Folder = (folder *)CTX;
86 lprintf(0, "-> %s: %ld\n", ChrPtr(Folder->name), Folder->view);
88 return ((Folder->view == VIEW_CALENDAR) ||
89 (Folder->view == VIEW_TASKS) ||
90 (Folder->view == VIEW_ADDRESSBOOK) ||
91 (Folder->view == VIEW_NOTES) ||
92 (Folder->view == VIEW_JOURNAL) );
98 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
103 (TP->Tokens->nParameters < 3))
105 return ((WCC->CurRoom.view < VIEW_BBS) ||
106 (WCC->CurRoom.view > VIEW_MAX));
109 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
113 void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
119 (WCC->CurRoom.defview >= VIEW_MAX) ||
120 (WCC->CurRoom.defview < VIEW_BBS))
122 LogTemplateError(Target, "Token", ERR_PARM2, TP,
123 "Roomview [%ld] not valid\n",
125 WCC->CurRoom.defview : -1);
129 Buf = NewStrBufPlain(_(viewdefs[WCC->CurRoom.defview]), -1);
130 StrBufAppendTemplate(Target, TP, Buf, 0);
134 void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
139 CheckThis = GetTemplateTokenNumber(Target, TP, 0, 0);
140 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
142 LogTemplateError(Target, "Token", ERR_PARM2, TP,
143 "Roomview [%ld] not valid\n",
148 Buf = NewStrBufPlain(_(viewdefs[CheckThis]), -1);
149 StrBufAppendTemplate(Target, TP, Buf, 0);
155 int ConditionalIsAllowedDefaultView(StrBuf *Target, WCTemplputParams *TP)
163 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
164 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
166 LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
167 "Roomview [%ld] not valid\n",
172 return allowed_default_views[CheckThis] != 0;
175 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
183 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
184 return CheckThis == WCC->CurRoom.defview;
187 int ConditionalThisRoomCurrView(StrBuf *Target, WCTemplputParams *TP)
195 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
196 return CheckThis == WCC->CurRoom.view;
199 int ConditionalThisRoomHaveView(StrBuf *Target, WCTemplputParams *TP)
207 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
208 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
210 LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
211 "Roomview [%ld] not valid\n",
216 return exchangeable_views [WCC->CurRoom.defview][CheckThis] ;
219 void tmplput_ROOM_VIEW(StrBuf *Target, WCTemplputParams *TP)
221 folder *Folder = (folder *)CTX;
222 StrBufAppendPrintf(Target, "%d", Folder->view);
224 void tmplput_ROOM_DEFVIEW(StrBuf *Target, WCTemplputParams *TP)
226 folder *Folder = (folder *)CTX;
227 StrBufAppendPrintf(Target, "%d", Folder->defview);
231 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
235 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.defview);
242 initialize_viewdefs();
244 RegisterNamespace("THISROOM:VIEW_STRING", 0, 1, tmplput_CurrentRoomViewString, NULL, CTX_NONE);
245 RegisterNamespace("ROOM:VIEW_STRING", 1, 2, tmplput_RoomViewString, NULL, CTX_NONE);
247 RegisterConditional(HKEY("COND:ALLOWED_DEFAULT_VIEW"), 0, ConditionalIsAllowedDefaultView, CTX_NONE);
248 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
249 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
250 RegisterNamespace("ROOM:INFO:DEFVIEW", 0, 1, tmplput_ROOM_DEFVIEW, NULL, CTX_ROOMS);
252 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
254 RegisterConditional(HKEY("COND:THISROOM:HAVE_VIEW"), 0, ConditionalThisRoomHaveView, CTX_NONE);
255 RegisterConditional(HKEY("COND:ROOM:GROUPDAV_CONTENT"), 0, ConditionalRoomHasGroupdavContent, CTX_ROOMS);
257 RegisterConditional(HKEY("COND:THISROOM:CURR_VIEW"), 0, ConditionalThisRoomCurrView, CTX_NONE);
258 RegisterNamespace("ROOM:INFO:VIEW", 0, 1, tmplput_ROOM_VIEW, NULL, CTX_ROOMS);
260 RegisterNamespace("ROOM:INFO:COLLECTIONTYPE", 0, 1, tmplput_ROOM_COLLECTIONTYPE, NULL, CTX_ROOMS);