From: Art Cancro Date: Wed, 11 Sep 2002 03:17:18 +0000 (+0000) Subject: * [EXPERIMENTAL] Link in the "libical" calendar library if present X-Git-Tag: v7.86~6250 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=3d7940f9f77a9a50a023b1c31092c56e6cfbe199;p=citadel.git * [EXPERIMENTAL] Link in the "libical" calendar library if present * Rename serv_ical to serv_calendar (because the resulting module would be named "libical" which conflicts with the external library by that name) --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 2a6f875e8..4facbdcac 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,9 @@ $Log$ + Revision 601.4 2002/09/11 03:17:18 ajc + * [EXPERIMENTAL] Link in the "libical" calendar library if present + * Rename serv_ical to serv_calendar (because the resulting module would be + named "libical" which conflicts with the external library by that name) + Revision 601.3 2002/09/10 08:07:38 error * update citadel.spec for 6.00* update citadel.spec for 6.00* update citadel.spec for 6.00* update citadel.spec for 6.00* update citadel.spec for 6.00* update citadel.spec for 6.00* update citadel.spec for 6.00* update citadel.spec for 6.00 @@ -3991,4 +3996,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/Makefile.in b/citadel/Makefile.in index e3bf0f17e..c2e82861e 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -41,7 +41,7 @@ SERV_MODULES=modules/libchat.la modules/libvcard.la \ modules/libbio.la \ modules/libexpire.la \ modules/libvandelay.la \ - modules/libical.la + modules/libcalendar.la UTIL_TARGETS=aidepost msgform readlog \ stats citmail userlist sendcommand \ base64 migratenet$(EXEEXT) @@ -91,7 +91,7 @@ SOURCES=aidepost.c citadel.c citmail.c citserver.c client_chat.c \ client_passwords.c imap_misc.c serv_netfilter.c serv_mrtg.c \ serv_spam.c citadel_ipc.c serv_listsub.c \ serv_imap.c imap_tools.c imap_fetch.c imap_search.c imap_store.c \ - serv_network.c serv_pas2.c serv_ical.c md5.c server_main.c + serv_network.c serv_pas2.c serv_calendar.c md5.c server_main.c DEP_FILES=$(SOURCES:.c=.d) @@ -213,8 +213,8 @@ aidepost: aidepost.o libcitserver.la $(LIBOBJS) modules/libpas2.la: serv_pas2.lo md5.lo $(LIBTOOL) libcitserver.la $(LTSHARE) -o libpas2.la ../serv_pas2.lo ../md5.lo ../libcitserver.la -modules/libical.la: serv_ical.lo $(LIBTOOL) libcitserver.la - $(LTSHARE) -o libical.la ../serv_ical.lo ../libcitserver.la +modules/libcalendar.la: serv_calendar.lo $(LIBTOOL) libcitserver.la + $(LTSHARE) -o libcalendar.la ../serv_calendar.lo ../libcitserver.la citmail: citmail.o config.o $(CC) citmail.o config.o $(LDFLAGS) -o citmail $(LIBS) diff --git a/citadel/acconfig.h b/citadel/acconfig.h index 6c9b2abd8..ceecff046 100644 --- a/citadel/acconfig.h +++ b/citadel/acconfig.h @@ -27,3 +27,6 @@ /* define this if you have zlib compression available */ #undef HAVE_ZLIB + +/* define this if you have the libical calendaring library available */ +#undef HAVE_LIBICAL diff --git a/citadel/citadel.spec b/citadel/citadel.spec index 5fa93b322..ec70db828 100644 --- a/citadel/citadel.spec +++ b/citadel/citadel.spec @@ -105,8 +105,8 @@ upgrading this package. /usr/local/citadel/modules/libexpire.la /usr/local/citadel/modules/libvandelay.so /usr/local/citadel/modules/libvandelay.la -/usr/local/citadel/modules/libical.so -/usr/local/citadel/modules/libical.la +/usr/local/citadel/modules/libcalendar.so +/usr/local/citadel/modules/libcalendar.la /usr/local/citadel/modules/liblistsub.so /usr/local/citadel/modules/liblistsub.la /usr/local/citadel/modules/libmrtg.so diff --git a/citadel/configure.ac b/citadel/configure.ac index fdf845fa7..2d54e4ded 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -32,6 +32,7 @@ AC_ARG_WITH(ssl, AC_ARG_WITH(ncurses, [ --without-ncurses don't use ncurses]) AC_ARG_WITH(with_zlib, [ --with-zlib use zlib compression if present]) +AC_ARG_WITH(with_libical, [ --with-libical use libical calendaring library]) if test "x$with_gdbm" != xno -a "x$with_gdbm" != xyes -a "$with_gdbm"; then db_dir="$with_gdbm" @@ -366,6 +367,8 @@ if test "x$with_gdbm" != xno -a "x$with_db" != xyes; then with_db=no]) fi + + dnl Checks for the zlib compression library. if test "x$with_zlib" != xno ; then AC_CHECK_HEADERS(zlib.h, @@ -379,6 +382,23 @@ if test "x$ok_zlib" != xno ; then AC_DEFINE(HAVE_ZLIB) fi + + +dnl Checks for the libical calendaring library. +if test "x$with_libical" != xno ; then + AC_CHECK_HEADERS(ical.h, + [AC_CHECK_LIB(ical, icalcomponent_new, + [ok_libical=yes],, + )]) +fi + +if test "x$ok_libical" != xno ; then + LIBS="-lical $LIBS" + AC_DEFINE(HAVE_LIBICAL) +fi + + + dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC diff --git a/citadel/serv_calendar.c b/citadel/serv_calendar.c new file mode 100644 index 000000000..bae86f404 --- /dev/null +++ b/citadel/serv_calendar.c @@ -0,0 +1,118 @@ +/* + * $Id$ + * + * This module implements iCalendar object processing and the My Calendar> + * room on a Citadel/UX server. It handles iCalendar objects using the + * iTIP protocol. See RFCs 2445 and 2446. + * + */ + +#include "sysdep.h" +#include +#include +#include +#include +#include +#ifdef HAVE_STRINGS_H +#include +#endif +#include "serv_ical.h" +#include "citadel.h" +#include "server.h" +#include "citserver.h" +#include "sysdep_decls.h" +#include "support.h" +#include "config.h" +#include "dynloader.h" +#include "user_ops.h" +#include "room_ops.h" + + +/* Tell clients what level of support to expect */ +void cmd_ical(char *argbuf) +{ + /* argbuf is not used */ + if (!(CC->logged_in)) { + cprintf("%d Not logged in.\n", ERROR+NOT_LOGGED_IN); + return; + } + + cprintf("%d I support|ICAL\n", CIT_OK); + return; +} + + +/* We don't know if the calendar room exists so we just create it at login */ +void ical_create_room(void) +{ + struct quickroom qr; + + /* Create the room if it doesn't already exist */ + create_room(USERCALENDARROOM, 4, "", 0, 1, 0); + /* Set expiration policy to manual; otherwise objects will be lost! */ + if (lgetroom(&qr, USERCALENDARROOM)) { + lprintf(3, "Couldn't get the user calendar room!\n"); + return; + } + qr.QRep.expire_mode = EXPIRE_MANUAL; + lputroom(&qr); + lprintf(9, "Set user calendar room to manual expire\n"); + return; +} + + +/* See if we need to prevent the object from being saved */ +int ical_obj_beforesave(struct CtdlMessage *msg) +{ + char roomname[ROOMNAMELEN]; + char *p; + int a; + + /* + * Only messages with content-type text/calendar or text/x-calendar + * may be saved to My Calendar>. If the message is bound for + * My Calendar> but doesn't have this content-type, throw an error + * so that the message may not be posted. + */ + + /* First determine if this is our room */ + MailboxName(roomname, sizeof roomname, &CC->usersupp, USERCALENDARROOM); + if (strncmp(roomname, msg->cm_fields['O'], ROOMNAMELEN)) + return 0; /* It's not us... */ + + /* Then determine content-type of the message */ + + /* It must be an RFC822 message! */ + /* FIXME: Not handling MIME multipart messages; implement with IMIP */ + if (msg->cm_format_type != 4) + return 1; /* You tried to save a non-RFC822 message! */ + + /* Find the Content-Type: header */ + p = msg->cm_fields['M']; + a = strlen(p); + while (--a > 0) { + if (!strncasecmp(p, "Content-Type: ", 14)) { /* Found it */ + if (!strncasecmp(p + 14, "text/x-calendar", 15) || + !strncasecmp(p + 14, "text/calendar", 13)) + return 0; + else + return 1; + } + p++; + } + + /* Oops! No Content-Type in this message! How'd that happen? */ + lprintf(7, "RFC822 message with no Content-Type header!\n"); + return 1; +} + + + +/* Register this module with the Citadel server. */ +char *Dynamic_Module_Init(void) +{ + CtdlRegisterSessionHook(ical_create_room, EVT_LOGIN); + CtdlRegisterMessageHook(ical_obj_beforesave, EVT_BEFORESAVE); + CtdlRegisterProtoHook(cmd_ical, "ICAL", "Register iCalendar support"); + return "$Id$"; +} diff --git a/citadel/serv_calendar.h b/citadel/serv_calendar.h new file mode 100644 index 000000000..059ba2d0d --- /dev/null +++ b/citadel/serv_calendar.h @@ -0,0 +1,9 @@ +/* + * $Id$ + * + * iCalendar implementation for Citadel/UX + * + */ + + +/* Hrm, we don't have anything to put here yet... */ diff --git a/citadel/serv_ical.c b/citadel/serv_ical.c deleted file mode 100644 index bae86f404..000000000 --- a/citadel/serv_ical.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * $Id$ - * - * This module implements iCalendar object processing and the My Calendar> - * room on a Citadel/UX server. It handles iCalendar objects using the - * iTIP protocol. See RFCs 2445 and 2446. - * - */ - -#include "sysdep.h" -#include -#include -#include -#include -#include -#ifdef HAVE_STRINGS_H -#include -#endif -#include "serv_ical.h" -#include "citadel.h" -#include "server.h" -#include "citserver.h" -#include "sysdep_decls.h" -#include "support.h" -#include "config.h" -#include "dynloader.h" -#include "user_ops.h" -#include "room_ops.h" - - -/* Tell clients what level of support to expect */ -void cmd_ical(char *argbuf) -{ - /* argbuf is not used */ - if (!(CC->logged_in)) { - cprintf("%d Not logged in.\n", ERROR+NOT_LOGGED_IN); - return; - } - - cprintf("%d I support|ICAL\n", CIT_OK); - return; -} - - -/* We don't know if the calendar room exists so we just create it at login */ -void ical_create_room(void) -{ - struct quickroom qr; - - /* Create the room if it doesn't already exist */ - create_room(USERCALENDARROOM, 4, "", 0, 1, 0); - /* Set expiration policy to manual; otherwise objects will be lost! */ - if (lgetroom(&qr, USERCALENDARROOM)) { - lprintf(3, "Couldn't get the user calendar room!\n"); - return; - } - qr.QRep.expire_mode = EXPIRE_MANUAL; - lputroom(&qr); - lprintf(9, "Set user calendar room to manual expire\n"); - return; -} - - -/* See if we need to prevent the object from being saved */ -int ical_obj_beforesave(struct CtdlMessage *msg) -{ - char roomname[ROOMNAMELEN]; - char *p; - int a; - - /* - * Only messages with content-type text/calendar or text/x-calendar - * may be saved to My Calendar>. If the message is bound for - * My Calendar> but doesn't have this content-type, throw an error - * so that the message may not be posted. - */ - - /* First determine if this is our room */ - MailboxName(roomname, sizeof roomname, &CC->usersupp, USERCALENDARROOM); - if (strncmp(roomname, msg->cm_fields['O'], ROOMNAMELEN)) - return 0; /* It's not us... */ - - /* Then determine content-type of the message */ - - /* It must be an RFC822 message! */ - /* FIXME: Not handling MIME multipart messages; implement with IMIP */ - if (msg->cm_format_type != 4) - return 1; /* You tried to save a non-RFC822 message! */ - - /* Find the Content-Type: header */ - p = msg->cm_fields['M']; - a = strlen(p); - while (--a > 0) { - if (!strncasecmp(p, "Content-Type: ", 14)) { /* Found it */ - if (!strncasecmp(p + 14, "text/x-calendar", 15) || - !strncasecmp(p + 14, "text/calendar", 13)) - return 0; - else - return 1; - } - p++; - } - - /* Oops! No Content-Type in this message! How'd that happen? */ - lprintf(7, "RFC822 message with no Content-Type header!\n"); - return 1; -} - - - -/* Register this module with the Citadel server. */ -char *Dynamic_Module_Init(void) -{ - CtdlRegisterSessionHook(ical_create_room, EVT_LOGIN); - CtdlRegisterMessageHook(ical_obj_beforesave, EVT_BEFORESAVE); - CtdlRegisterProtoHook(cmd_ical, "ICAL", "Register iCalendar support"); - return "$Id$"; -} diff --git a/citadel/serv_ical.h b/citadel/serv_ical.h deleted file mode 100644 index 059ba2d0d..000000000 --- a/citadel/serv_ical.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * $Id$ - * - * iCalendar implementation for Citadel/UX - * - */ - - -/* Hrm, we don't have anything to put here yet... */