2 * Lots of different room-related operations.
8 char *viewdefs[VIEW_MAX];
11 * This table defines which views may be selected as the
12 * default view for a room at the time of its creation.
14 int allowed_default_views[VIEW_MAX] = {
15 1, /* VIEW_BBS Bulletin board */
16 1, /* VIEW_MAILBOX Mailbox summary */
17 1, /* VIEW_ADDRESSBOOK Address book */
18 1, /* VIEW_CALENDAR Calendar */
19 1, /* VIEW_TASKS Tasks */
20 1, /* VIEW_NOTES Notes */
21 1, /* VIEW_WIKI Wiki */
22 0, /* VIEW_CALBRIEF Brief Calendar */
23 0, /* VIEW_JOURNAL Journal */
24 0, /* VIEW_DRAFTS Drafts */
25 1, /* VIEW_BLOG Blog */
26 0 /* VIEW_QUEUE Mail Queue */
30 * Given the default view for a room, this table defines
31 * which alternate views may be selected by the user.
33 ROOM_VIEWS exchangeable_views[VIEW_MAX][VIEW_MAX] = {
34 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, /* bulletin board */
35 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, /* mailbox summary */
36 { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* address book */
37 { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, /* calendar */
38 { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, /* tasks */
39 { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, /* notes */
40 { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }, /* wiki */
41 { 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 }, /* brief calendar */
42 { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 }, /* journal */
43 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 }, /* drafts */
44 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, /* blog */
48 * Initialize the viewdefs with localized strings
50 void initialize_viewdefs(void) {
51 viewdefs[VIEW_BBS] = _("Bulletin Board");
52 viewdefs[VIEW_MAILBOX] = _("Mail Folder");
53 viewdefs[VIEW_ADDRESSBOOK] = _("Address Book");
54 viewdefs[VIEW_CALENDAR] = _("Calendar");
55 viewdefs[VIEW_TASKS] = _("Task List");
56 viewdefs[VIEW_NOTES] = _("Notes List");
57 viewdefs[VIEW_WIKI] = _("Wiki");
58 viewdefs[VIEW_CALBRIEF] = _("Calendar List");
59 viewdefs[VIEW_JOURNAL] = _("Journal");
60 viewdefs[VIEW_DRAFTS] = _("Drafts");
61 viewdefs[VIEW_BLOG] = _("Blog");
65 void tmplput_ROOM_COLLECTIONTYPE(StrBuf *Target, WCTemplputParams *TP)
67 folder *Folder = (folder *)CTX(CTX_ROOMS);
69 switch(Folder->view) {
71 StrBufAppendBufPlain(Target, HKEY("vevent"), 0);
74 StrBufAppendBufPlain(Target, HKEY("vtodo"), 0);
76 case VIEW_ADDRESSBOOK:
77 StrBufAppendBufPlain(Target, HKEY("vcard"), 0);
80 StrBufAppendBufPlain(Target, HKEY("vnotes"), 0);
83 StrBufAppendBufPlain(Target, HKEY("vjournal"), 0);
86 StrBufAppendBufPlain(Target, HKEY("wiki"), 0);
93 int ConditionalRoomHasGroupdavContent(StrBuf *Target, WCTemplputParams *TP)
95 folder *Folder = (folder *)CTX(CTX_ROOMS);
97 syslog(LOG_DEBUG, "-> %s: %d\n", ChrPtr(Folder->name), Folder->view);
99 return ((Folder->view == VIEW_CALENDAR) ||
100 (Folder->view == VIEW_TASKS) ||
101 (Folder->view == VIEW_ADDRESSBOOK) ||
102 (Folder->view == VIEW_NOTES) ||
103 (Folder->view == VIEW_JOURNAL) );
109 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
114 (TP->Tokens->nParameters < 3))
116 return ((WCC->CurRoom.view < VIEW_BBS) ||
117 (WCC->CurRoom.view > VIEW_MAX));
120 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
124 void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
130 (WCC->CurRoom.defview >= VIEW_MAX) ||
131 (WCC->CurRoom.defview < VIEW_BBS))
133 LogTemplateError(Target, "Token", ERR_PARM2, TP,
134 "Roomview [%ld] not valid\n",
136 WCC->CurRoom.defview : -1);
140 Buf = NewStrBufPlain(_(viewdefs[WCC->CurRoom.defview]), -1);
141 StrBufAppendTemplate(Target, TP, Buf, 0);
145 void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
150 CheckThis = GetTemplateTokenNumber(Target, TP, 0, 0);
151 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
153 LogTemplateError(Target, "Token", ERR_PARM2, TP,
154 "Roomview [%ld] not valid\n",
159 Buf = NewStrBufPlain(_(viewdefs[CheckThis]), -1);
160 StrBufAppendTemplate(Target, TP, Buf, 0);
166 int ConditionalIsAllowedDefaultView(StrBuf *Target, WCTemplputParams *TP)
174 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
175 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
177 LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
178 "Roomview [%ld] not valid\n",
183 return allowed_default_views[CheckThis] != 0;
186 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
194 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
195 return CheckThis == WCC->CurRoom.defview;
198 int ConditionalThisRoomCurrView(StrBuf *Target, WCTemplputParams *TP)
206 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
207 return CheckThis == WCC->CurRoom.view;
210 int ConditionalThisRoomHaveView(StrBuf *Target, WCTemplputParams *TP)
218 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
219 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
221 LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
222 "Roomview [%ld] not valid\n",
227 return exchangeable_views [WCC->CurRoom.defview][CheckThis] ;
230 void tmplput_ROOM_VIEW(StrBuf *Target, WCTemplputParams *TP)
232 folder *Folder = (folder *)CTX(CTX_ROOMS);
233 StrBufAppendPrintf(Target, "%d", Folder->view);
235 void tmplput_ROOM_DEFVIEW(StrBuf *Target, WCTemplputParams *TP)
237 folder *Folder = (folder *)CTX(CTX_ROOMS);
238 StrBufAppendPrintf(Target, "%d", Folder->defview);
242 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
246 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.defview);
253 /* we duplicate this, just to be shure its already done. */
254 RegisterCTX(CTX_ROOMS);
255 RegisterCTX(CTX_FLOORS);
257 initialize_viewdefs();
259 RegisterNamespace("THISROOM:VIEW_STRING", 0, 1, tmplput_CurrentRoomViewString, NULL, CTX_NONE);
260 RegisterNamespace("ROOM:VIEW_STRING", 1, 2, tmplput_RoomViewString, NULL, CTX_NONE);
262 RegisterConditional("COND:ALLOWED_DEFAULT_VIEW", 0, ConditionalIsAllowedDefaultView, CTX_NONE);
263 RegisterConditional("COND:THISROOM:DEFAULT_VIEW", 0, ConditionalThisRoomDefView, CTX_NONE);
264 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
265 RegisterNamespace("ROOM:INFO:DEFVIEW", 0, 1, tmplput_ROOM_DEFVIEW, NULL, CTX_ROOMS);
267 RegisterConditional("COND:ROOM:TYPE_IS", 0, ConditionalIsRoomtype, CTX_NONE);
269 RegisterConditional("COND:THISROOM:HAVE_VIEW", 0, ConditionalThisRoomHaveView, CTX_NONE);
270 RegisterConditional("COND:ROOM:DAV_CONTENT", 0, ConditionalRoomHasGroupdavContent, CTX_ROOMS);
272 RegisterConditional("COND:THISROOM:CURR_VIEW", 0, ConditionalThisRoomCurrView, CTX_NONE);
273 RegisterNamespace("ROOM:INFO:VIEW", 0, 1, tmplput_ROOM_VIEW, NULL, CTX_ROOMS);
275 RegisterNamespace("ROOM:INFO:COLLECTIONTYPE", 0, 1, tmplput_ROOM_COLLECTIONTYPE, NULL, CTX_ROOMS);