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 ROOM_VIEWS 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 */
29 * Given the default view for a room, this table defines
30 * which alternate views may be selected by the user.
32 ROOM_VIEWS exchangeable_views[VIEW_MAX][VIEW_MAX] = {
33 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, /* bulletin board */
34 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, /* mailbox summary */
35 { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, /* address book */
36 { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, /* calendar */
37 { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, /* tasks */
38 { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }, /* notes */
39 { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, /* wiki */
40 { 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 }, /* brief calendar */
41 { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }, /* journal */
42 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1 }, /* drafts */
43 { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 } /* blog */
47 * Initialize the viewdefs with localized strings
49 void initialize_viewdefs(void) {
50 viewdefs[VIEW_BBS] = _("Bulletin Board");
51 viewdefs[VIEW_MAILBOX] = _("Mail Folder");
52 viewdefs[VIEW_ADDRESSBOOK] = _("Address Book");
53 viewdefs[VIEW_CALENDAR] = _("Calendar");
54 viewdefs[VIEW_TASKS] = _("Task List");
55 viewdefs[VIEW_NOTES] = _("Notes List");
56 viewdefs[VIEW_WIKI] = _("Wiki");
57 viewdefs[VIEW_CALBRIEF] = _("Calendar List");
58 viewdefs[VIEW_JOURNAL] = _("Journal");
59 viewdefs[VIEW_DRAFTS] = _("Drafts");
60 viewdefs[VIEW_BLOG] = _("Blog");
64 void tmplput_ROOM_COLLECTIONTYPE(StrBuf *Target, WCTemplputParams *TP)
66 folder *Folder = (folder *)CTX;
68 switch(Folder->view) {
70 StrBufAppendBufPlain(Target, HKEY("vevent"), 0);
73 StrBufAppendBufPlain(Target, HKEY("vtodo"), 0);
75 case VIEW_ADDRESSBOOK:
76 StrBufAppendBufPlain(Target, HKEY("vcard"), 0);
79 StrBufAppendBufPlain(Target, HKEY("vnotes"), 0);
82 StrBufAppendBufPlain(Target, HKEY("vjournal"), 0);
85 StrBufAppendBufPlain(Target, HKEY("wiki"), 0);
92 int ConditionalRoomHasGroupdavContent(StrBuf *Target, WCTemplputParams *TP)
94 folder *Folder = (folder *)CTX;
96 syslog(0, "-> %s: %d\n", ChrPtr(Folder->name), Folder->view);
98 return ((Folder->view == VIEW_CALENDAR) ||
99 (Folder->view == VIEW_TASKS) ||
100 (Folder->view == VIEW_ADDRESSBOOK) ||
101 (Folder->view == VIEW_NOTES) ||
102 (Folder->view == VIEW_JOURNAL) );
108 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
113 (TP->Tokens->nParameters < 3))
115 return ((WCC->CurRoom.view < VIEW_BBS) ||
116 (WCC->CurRoom.view > VIEW_MAX));
119 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
123 void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
129 (WCC->CurRoom.defview >= VIEW_MAX) ||
130 (WCC->CurRoom.defview < VIEW_BBS))
132 LogTemplateError(Target, "Token", ERR_PARM2, TP,
133 "Roomview [%ld] not valid\n",
135 WCC->CurRoom.defview : -1);
139 Buf = NewStrBufPlain(_(viewdefs[WCC->CurRoom.defview]), -1);
140 StrBufAppendTemplate(Target, TP, Buf, 0);
144 void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
149 CheckThis = GetTemplateTokenNumber(Target, TP, 0, 0);
150 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
152 LogTemplateError(Target, "Token", ERR_PARM2, TP,
153 "Roomview [%ld] not valid\n",
158 Buf = NewStrBufPlain(_(viewdefs[CheckThis]), -1);
159 StrBufAppendTemplate(Target, TP, Buf, 0);
165 int ConditionalIsAllowedDefaultView(StrBuf *Target, WCTemplputParams *TP)
173 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
174 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
176 LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
177 "Roomview [%ld] not valid\n",
182 return allowed_default_views[CheckThis] != 0;
185 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
193 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
194 return CheckThis == WCC->CurRoom.defview;
197 int ConditionalThisRoomCurrView(StrBuf *Target, WCTemplputParams *TP)
205 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
206 return CheckThis == WCC->CurRoom.view;
209 int ConditionalThisRoomHaveView(StrBuf *Target, WCTemplputParams *TP)
217 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
218 if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
220 LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
221 "Roomview [%ld] not valid\n",
226 return exchangeable_views [WCC->CurRoom.defview][CheckThis] ;
229 void tmplput_ROOM_VIEW(StrBuf *Target, WCTemplputParams *TP)
231 folder *Folder = (folder *)CTX;
232 StrBufAppendPrintf(Target, "%d", Folder->view);
234 void tmplput_ROOM_DEFVIEW(StrBuf *Target, WCTemplputParams *TP)
236 folder *Folder = (folder *)CTX;
237 StrBufAppendPrintf(Target, "%d", Folder->defview);
241 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
245 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.defview);
252 initialize_viewdefs();
254 RegisterNamespace("THISROOM:VIEW_STRING", 0, 1, tmplput_CurrentRoomViewString, NULL, CTX_NONE);
255 RegisterNamespace("ROOM:VIEW_STRING", 1, 2, tmplput_RoomViewString, NULL, CTX_NONE);
257 RegisterConditional(HKEY("COND:ALLOWED_DEFAULT_VIEW"), 0, ConditionalIsAllowedDefaultView, CTX_NONE);
258 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
259 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
260 RegisterNamespace("ROOM:INFO:DEFVIEW", 0, 1, tmplput_ROOM_DEFVIEW, NULL, CTX_ROOMS);
262 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
264 RegisterConditional(HKEY("COND:THISROOM:HAVE_VIEW"), 0, ConditionalThisRoomHaveView, CTX_NONE);
265 RegisterConditional(HKEY("COND:ROOM:DAV_CONTENT"), 0, ConditionalRoomHasGroupdavContent, CTX_ROOMS);
267 RegisterConditional(HKEY("COND:THISROOM:CURR_VIEW"), 0, ConditionalThisRoomCurrView, CTX_NONE);
268 RegisterNamespace("ROOM:INFO:VIEW", 0, 1, tmplput_ROOM_VIEW, NULL, CTX_ROOMS);
270 RegisterNamespace("ROOM:INFO:COLLECTIONTYPE", 0, 1, tmplput_ROOM_COLLECTIONTYPE, NULL, CTX_ROOMS);