]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/modules/calendar/serv_calendar.c
move calendar prototypes around, add more with cproto
[citadel.git] / citadel / server / modules / calendar / serv_calendar.c
index 5e169c1b6a46ceb049bf9658f74bbf5a7b567108..4d86058276178341e488c71a2346c4b0324d48c2 100644 (file)
@@ -7,23 +7,15 @@
 // This program is open source software.  Use, duplication, or disclosure
 // are subject to the terms of the GNU General Public License version 3.
 
-#define PRODID "-//Citadel//NONSGML Citadel Calendar//EN"
-
-#include "../../ctdl_module.h"
 #include <libical/ical.h>
+#include "../../ctdl_module.h"
 #include "../../msgbase.h"
 #include "../../internet_addressing.h"
-#include "serv_calendar.h"
 #include "../../room_ops.h"
 #include "../../euidindex.h"
 #include "../../default_timezone.h"
 #include "../../config.h"
-
-struct ical_respond_data {
-       char desired_partnum[SIZ];
-       icalcomponent *cal;
-};
-
+#include "serv_calendar.h"
 
 // Utility function to create a new VCALENDAR component with some of the
 // required fields already set the way we like them.
@@ -1523,8 +1515,7 @@ void ical_getics_backend(long msgnum, void *data) {
                                if (p) {
                                        const char *tzid = icalproperty_get_tzid(p);
                                        if (!icalcomponent_get_timezone(encaps, tzid)) {
-                                               icalcomponent_add_component(encaps,
-                                                                       icalcomponent_new_clone(c));
+                                               icalcomponent_add_component(encaps, icalcomponent_new_clone(c));
                                        }
                                }
                        }
@@ -1545,8 +1536,9 @@ void ical_getics(void) {
        icalcomponent *encaps = NULL;
        char *ser = NULL;
 
+       // Only allow this operation if we're in a room containing a calendar or tasks view
        if (    (CC->room.QRdefaultview != VIEW_CALENDAR)
-               &&(CC->room.QRdefaultview != VIEW_TASKS)
+               && (CC->room.QRdefaultview != VIEW_TASKS)
        ) {
                cprintf("%d Not a calendar room\n", ERROR+NOT_HERE);
                return;         // This room does not contain a calendar.
@@ -1617,7 +1609,7 @@ void ical_putics(void) {
                && (CC->room.QRdefaultview != VIEW_TASKS)
        ) {
                cprintf("%d Not a calendar room\n", ERROR+NOT_HERE);
-               return;
+               return;         // This room does not contain a calendar.
        }
 
        // Only allow this operation if we have permission to overwrite the existing calendar
@@ -1711,74 +1703,6 @@ void ical_putics(void) {
 }
 
 
-// All Citadel calendar commands from the client come through here.
-void cmd_ical(char *argbuf) {
-       char subcmd[64];
-       long msgnum;
-       char partnum[256];
-       char action[256];
-       char who[256];
-
-       extract_token(subcmd, argbuf, 0, '|', sizeof subcmd);
-
-       // Allow "test" and "freebusy" subcommands without logging in.
-
-       if (!strcasecmp(subcmd, "test")) {
-               cprintf("%d This server supports calendaring\n", CIT_OK);
-               return;
-       }
-
-       if (!strcasecmp(subcmd, "freebusy")) {
-               extract_token(who, argbuf, 1, '|', sizeof who);
-               ical_freebusy(who);
-               return;
-       }
-
-       if (!strcasecmp(subcmd, "sgi")) {
-               CIT_ICAL->server_generated_invitations = (extract_int(argbuf, 1) ? 1 : 0) ;
-               cprintf("%d %d\n", CIT_OK, CIT_ICAL->server_generated_invitations);
-               return;
-       }
-
-       if (CtdlAccessCheck(ac_logged_in)) return;
-
-       if (!strcasecmp(subcmd, "respond")) {
-               msgnum = extract_long(argbuf, 1);
-               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
-               extract_token(action, argbuf, 3, '|', sizeof action);
-               ical_respond(msgnum, partnum, action);
-               return;
-       }
-
-       if (!strcasecmp(subcmd, "handle_rsvp")) {
-               msgnum = extract_long(argbuf, 1);
-               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
-               extract_token(action, argbuf, 3, '|', sizeof action);
-               ical_handle_rsvp(msgnum, partnum, action);
-               return;
-       }
-
-       if (!strcasecmp(subcmd, "conflicts")) {
-               msgnum = extract_long(argbuf, 1);
-               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
-               ical_conflicts(msgnum, partnum);
-               return;
-       }
-
-       if (!strcasecmp(subcmd, "getics")) {
-               ical_getics();
-               return;
-       }
-
-       if (!strcasecmp(subcmd, "putics")) {
-               ical_putics();
-               return;
-       }
-
-       cprintf("%d Invalid subcommand\n", ERROR + CMD_NOT_SUPPORTED);
-}
-
-
 // We don't know if the calendar room exists so we just create it at login
 void ical_CtdlCreateRoom(void) {
        struct ctdlroom qr;
@@ -2394,6 +2318,80 @@ void ical_fixed_output(char *ptr, int len) {
 }
 
 
+// All Citadel calendar commands from the client come through here.
+void cmd_ical(char *argbuf) {
+       char subcmd[64];
+       long msgnum;
+       char partnum[256];
+       char action[256];
+       char who[256];
+
+       extract_token(subcmd, argbuf, 0, '|', sizeof subcmd);
+
+       // Allow "test" and "freebusy" and "sgi" subcommands without logging in.
+
+       if (!strcasecmp(subcmd, "test")) {
+               cprintf("%d This server supports calendaring\n", CIT_OK);
+               return;
+       }
+
+       if (!strcasecmp(subcmd, "freebusy")) {
+               extract_token(who, argbuf, 1, '|', sizeof who);
+               ical_freebusy(who);
+               return;
+       }
+
+       if (!strcasecmp(subcmd, "sgi")) {
+               CIT_ICAL->server_generated_invitations = (extract_int(argbuf, 1) ? 1 : 0) ;
+               cprintf("%d %d\n", CIT_OK, CIT_ICAL->server_generated_invitations);
+               return;
+       }
+
+       // All other commands require a user to be logged in.
+       if (CtdlAccessCheck(ac_logged_in)) return;
+
+       if (!strcasecmp(subcmd, "report")) {
+               calendar_report();
+               return;
+       }
+
+       if (!strcasecmp(subcmd, "respond")) {
+               msgnum = extract_long(argbuf, 1);
+               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
+               extract_token(action, argbuf, 3, '|', sizeof action);
+               ical_respond(msgnum, partnum, action);
+               return;
+       }
+
+       if (!strcasecmp(subcmd, "handle_rsvp")) {
+               msgnum = extract_long(argbuf, 1);
+               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
+               extract_token(action, argbuf, 3, '|', sizeof action);
+               ical_handle_rsvp(msgnum, partnum, action);
+               return;
+       }
+
+       if (!strcasecmp(subcmd, "conflicts")) {
+               msgnum = extract_long(argbuf, 1);
+               extract_token(partnum, argbuf, 2, '|', sizeof partnum);
+               ical_conflicts(msgnum, partnum);
+               return;
+       }
+
+       if (!strcasecmp(subcmd, "getics")) {
+               ical_getics();
+               return;
+       }
+
+       if (!strcasecmp(subcmd, "putics")) {
+               ical_putics();
+               return;
+       }
+
+       cprintf("%d Invalid subcommand\n", ERROR + CMD_NOT_SUPPORTED);
+}
+
+
 // Initialization function, called from modules_init.c
 char *ctdl_module_init_calendar(void) {
        if (!threading) {