]> code.citadel.org Git - citadel.git/blob - citadel/serv_ical.c
267da1c731ae0b7fbe961c0861122996b13c4995
[citadel.git] / citadel / serv_ical.c
1 /* 
2  * $Id$ 
3  *
4  * This module implements iCalendar object processing and the My Calendar>
5  * room on a Citadel/UX server.  It handles iCalendar objects using the
6  * iTIP protocol.  See RFCs 2445 and 2446.
7  *
8  */
9
10 #include <unistd.h>
11 #include <sys/types.h>
12 #include <limits.h>
13 #include <stdio.h>
14 #include "sysdep.h"
15 #include "serv_ical.h"
16 #include "citadel.h"
17 #include "server.h"
18 #include "citserver.h"
19 #include "sysdep_decls.h"
20 #include "support.h"
21 #include "config.h"
22 #include "dynloader.h"
23 #include "user_ops.h"
24 #include "room_ops.h"
25
26
27 /* Tell clients what level of support to expect */
28 void cmd_ical(char *argbuf)
29 {
30         /* argbuf is not used */
31         if (!(CC->logged_in)) {
32                 cprintf("%d Not logged in.\n", ERROR+NOT_LOGGED_IN);
33                 return;
34         }
35
36         cprintf("%d I (will) support|ICAL,ITIP\n", OK);
37         return;
38 }
39
40
41 /* We can't know if the calendar room exists so we just create it at login */
42 void ical_create_room(void)
43 {
44         char roomname[ROOMNAMELEN];
45         struct quickroom qr;
46
47         /* Create the room if it doesn't already exist */
48         MailboxName(roomname, &CC->usersupp, USERCALENDARROOM);
49         create_room(roomname, 4, "", 0);
50         /* Set expiration policy to manual; otherwise objects will be lost! */
51         if (lgetroom(&qr, roomname)) {
52                 lprintf(3, "Couldn't get the user calendar room!\n");
53                 return;
54         }
55         qr.QRep.expire_mode = EXPIRE_MANUAL;
56         lputroom(&qr);
57         return;
58 }
59
60
61 /* User is reading a message */
62 int ical_obj_beforeread(struct CtdlMessage *msg)
63 {
64         return 0;
65 }
66
67
68 /* See if we need to prevent the object from being saved */
69 int ical_obj_beforesave(struct CtdlMessage *msg)
70 {
71         return 0;
72 }
73
74
75 /* aftersave processing */
76 int ical_obj_aftersave(struct CtdlMessage *msg)
77 {
78         return 0;
79 }
80
81
82 /* Register this module with the Citadel server. */
83 char *Dynamic_Module_Init(void)
84 {
85         CtdlRegisterSessionHook(ical_create_room, EVT_LOGIN);
86         CtdlRegisterMessageHook(ical_obj_beforeread, EVT_BEFOREREAD);
87         CtdlRegisterMessageHook(ical_obj_beforesave, EVT_BEFORESAVE);
88         CtdlRegisterMessageHook(ical_obj_aftersave, EVT_AFTERSAVE);
89         CtdlRegisterProtoHook(cmd_ical, "ICAL", "Register iCalendar support");
90         return "$Id$";
91 }