* copy daves great handler script and modify it to fit the simpler needs of webcit.
authorWilfried Göesgens <willi@citadel.org>
Sun, 13 Jul 2008 22:33:01 +0000 (22:33 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 13 Jul 2008 22:33:01 +0000 (22:33 +0000)
* add init functions to all handler containing .c files; Register these calls in the init function
* replace strcmp URL to handler dispatcher by hashlist
* wrap calls that had more than one call in simple functions

35 files changed:
webcit/Makefile.in
webcit/addressbook_popup.c
webcit/auth.c
webcit/autocompletion.c
webcit/calendar.c
webcit/configure.ac
webcit/downloads.c
webcit/floors.c
webcit/graphics.c
webcit/iconbar.c
webcit/inetconf.c
webcit/mainmenu.c
webcit/messages.c
webcit/mk_module_init.sh [new file with mode: 0755]
webcit/netconf.c
webcit/notes.c
webcit/openid.c
webcit/paging.c
webcit/preferences.c
webcit/pushemail.c
webcit/roomops.c
webcit/setup_wizard.c
webcit/sieve.c
webcit/siteconfig.c
webcit/smtpqueue.c
webcit/summary.c
webcit/sysmsgs.c
webcit/useredit.c
webcit/userlist.c
webcit/vcard_edit.c
webcit/webcit.c
webcit/webcit.h
webcit/webserver.c
webcit/who.c
webcit/wiki.c

index 28bbde07ff5451b5b9db1ac423c2da8052697b78..32401434b6fbd5e3f18ac973f8c5433a303fe4ac 100644 (file)
@@ -52,6 +52,7 @@ webcit: webserver.o context_loop.o ical_dezonify.o \
        groupdav_options.o autocompletion.o gettext.o tabs.o sieve.o \
        groupdav_delete.o groupdav_put.o http_datestring.o setup_wizard.o \
        downloads.o addressbook_popup.o pushemail.o sysdep.o openid.o \
+       modules_init.o \
        $(LIBOBJS)
        $(CC) webserver.o context_loop.o cookie_conversion.o \
        webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o listsub.o \
@@ -62,7 +63,7 @@ webcit: webserver.o context_loop.o ical_dezonify.o \
        availability.o ical_dezonify.o iconbar.o crypto.o inetconf.o notes.o \
        groupdav_main.o groupdav_get.o groupdav_propfind.o groupdav_delete.o \
        groupdav_options.o autocompletion.o tabs.o smtpqueue.o sieve.o \
-       groupdav_put.o http_datestring.o setup_wizard.o fmt_date.o \
+       groupdav_put.o http_datestring.o setup_wizard.o fmt_date.o modules_init.o \
        gettext.o downloads.o addressbook_popup.o pushemail.o sysdep.o \
        $(LIBOBJS) $(LIBS) $(LDFLAGS) -o webcit
 
index fe4ca703bad10d156f684a03a5c5ae6cdc9457da..230e09dc3d7369e48cbb7fa69d2b71723346bb60 100644 (file)
@@ -182,3 +182,14 @@ void display_address_book_inner_div() {
 
        end_ajax_response();
 }
+
+
+
+
+void 
+InitModule_ADDRBOOK_POPUP
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_address_book_middle_div"), display_address_book_middle_div, 0);
+       WebcitAddUrlHandler(HKEY("display_address_book_inner_div"), display_address_book_inner_div, 0);
+}
index d85ad0cb2c09bf377caf807c2d356d8a21a47462..c431c00555061a1db3e9e3f4380d715e2e8bb5ff 100644 (file)
@@ -875,10 +875,25 @@ void changepw(void)
        }
 }
 
+void _display_openid_login(void) {display_openid_login(NULL);}
+void _display_reg(void) {display_reg(0);}
 
 
-void InitModule_AUTH(void)
+void 
+InitModule_AUTH
+(void)
 {
-       WebcitAddUrlHandler(HKEY("do_welcome"), do_welcome, 0);
+       WebcitAddUrlHandler(HKEY("do_welcome"), do_welcome, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("login"), do_login, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("display_openid_login"), _display_openid_login, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("openid_login"), do_openid_login, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("finalize_openid_login"), finalize_openid_login, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("openid_manual_create"), openid_manual_create, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("do_logout"), do_logout, 0);
+       WebcitAddUrlHandler(HKEY("validate"), validate, 0);
+       WebcitAddUrlHandler(HKEY("display_reg"), _display_reg, 0);
+       WebcitAddUrlHandler(HKEY("display_changepw"), display_changepw, 0);
+       WebcitAddUrlHandler(HKEY("changepw"), changepw, 0);
+       WebcitAddUrlHandler(HKEY("termquit"), do_logout, 0);
        return ;
 }
index 327b98c6d3cec92a8895e4eb370a787c8e12e890..69564e812488dde771b64444327ce79cf39ea1b6 100644 (file)
@@ -43,3 +43,18 @@ void recp_autocomplete(char *partial) {
        wprintf("\r\n\r\n");
        wDumpContent(0);
 }
+
+
+void _recp_autocomplete(void) {recp_autocomplete(bstr("recp"));}
+void _cc_autocomplete(void)   {recp_autocomplete(bstr("cc"));} 
+void _bcc_autocomplete(void)  {recp_autocomplete(bstr("bcc"));}
+
+
+void 
+InitModule_AUTO_COMPLETE
+(void)
+{
+       WebcitAddUrlHandler(HKEY("recp_autocomplete"), _recp_autocomplete, 0);
+       WebcitAddUrlHandler(HKEY("cc_autocomplete"),   _cc_autocomplete, 0);
+       WebcitAddUrlHandler(HKEY("bcc_autocomplete"),  _bcc_autocomplete, 0);
+}
index 41395ef1155afb416efb7724bb65f2785f51a0f5..e91012eefcab1e131935a2354a2f2c79d7c2a9fb 100644 (file)
@@ -1057,3 +1057,18 @@ void do_freebusy(char *req) {
        free(fb);
 }
 
+
+
+
+
+void 
+InitModule_CALENDAR
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_edit_task"), display_edit_task, 0);
+       WebcitAddUrlHandler(HKEY("save_task"), save_task, 0);
+       WebcitAddUrlHandler(HKEY("display_edit_event"), display_edit_event, 0);
+       WebcitAddUrlHandler(HKEY("save_event"), save_event, 0);
+       WebcitAddUrlHandler(HKEY("respond_to_request"), respond_to_request, 0);
+       WebcitAddUrlHandler(HKEY("handle_rsvp"), handle_rsvp, 0);
+}
index 6601635f4d6c215258a66695f77dee100c8d4884..bb7663429d0f8a2458942daf5d71acfca51c1d20 100644 (file)
@@ -453,6 +453,7 @@ AC_ARG_WITH(editordir,
 )
 AC_DEFINE_UNQUOTED(EDITORDIR, "$editordir", [where to find our mail editor])
 
+./mk_module_init.sh
 AC_CONFIG_HEADER(sysdep.h)
 AC_OUTPUT(Makefile po/Makefile )
 
index 86c5108ab86e816ab4a17834f8860d72c990a11b..f2653746ab1ed4335c32906df94d5b0b8fa49a07 100644 (file)
@@ -381,7 +381,7 @@ void display_mime_icon(void)
 
 }
 
-void download_file(char *filename)
+void download_file(void)
 {
        char buf[256];
        off_t bytes;
@@ -391,7 +391,7 @@ void download_file(char *filename)
        /* Setting to nonzero forces a MIME type of application/octet-stream */
        int force_download = 1;
        
-       safestrncpy(buf, filename, sizeof buf);
+       safestrncpy(buf, ChrPtr(WC->UrlFragment1), sizeof buf);
        unescape_input(buf);
        serv_printf("OPEN %s", buf);
        serv_getln(buf, sizeof buf);
@@ -462,3 +462,13 @@ void upload_file(void)
        strcpy(WCC->ImportantMessage, &buf[4]);
        display_room_directory();
 }
+
+void 
+InitModule_DOWNLOAD
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_room_directory"), display_room_directory, 0);
+       WebcitAddUrlHandler(HKEY("display_pictureview"), display_pictureview, 0);
+       WebcitAddUrlHandler(HKEY("download_file"), download_file, NEED_URL);
+       WebcitAddUrlHandler(HKEY("upload_file"), upload_file, 0);
+}
index e06dfaa8d864bff8741912d023ac3af8d967acff..b5ee4028e52959afbb1967e247b8b64c13243a85 100644 (file)
@@ -196,5 +196,15 @@ void rename_floor(void) {
        display_floorconfig(message);
 }
 
+void _display_floorconfig(void) {display_floorconfig(NULL);}
 
+void 
+InitModule_FLOORS
+(void)
+{
+       WebcitAddUrlHandler(HKEY("delete_floor"), delete_floor, 0);
+       WebcitAddUrlHandler(HKEY("rename_floor"), rename_floor, 0);
+       WebcitAddUrlHandler(HKEY("create_floor"), create_floor, 0);
+       WebcitAddUrlHandler(HKEY("display_floorconfig"), _display_floorconfig, 0);
+}
 /*@}*/
index 6949e09fd81b8f0175f5b59c0554f0561acbf351..9cc0d4145babb464433ba2eabcec8e8ef3c48b66 100644 (file)
@@ -114,3 +114,66 @@ void do_graphics_upload(char *filename)
                return;
        }
 }
+
+
+void edithellopic(void)    { do_graphics_upload("hello"); }
+void editpic(void)         { do_graphics_upload("_userpic_"); }
+void editgoodbuyepic(void) { do_graphics_upload("UIMG 1|%s|goodbuye"); }
+
+/* The users photo display / upload facility */
+void display_editpic(void) {
+       display_graphics_upload(_("your photo"),
+                               "_userpic_",
+                               "editpic");
+}
+/* room picture dispay / upload facility */
+void display_editroompic(void) {
+       display_graphics_upload(_("the icon for this room"),
+                               "_roompic_",
+                               "editroompic");
+}
+
+/* the greetingpage hello pic */
+void display_edithello(void) {
+       display_graphics_upload(_("the Greetingpicture for the login prompt"),
+                               "hello",
+                               "edithellopic");
+}
+
+/* the logoff banner */
+void display_editgoodbyepic(void) {
+       display_graphics_upload(_("the Logoff banner picture"),
+                               "UIMG 0|%s|goodbuye",
+                               "editgoodbuyepic");
+}
+
+void display_editfloorpic(void) {
+       char buf[SIZ];
+       snprintf(buf, SIZ, "UIMG 0|_floorpic_|%s",
+                bstr("which_floor"));
+       display_graphics_upload(_("the icon for this floor"),
+                               buf,
+                               "editfloorpic");
+}
+
+void editfloorpic(void){
+       char buf[SIZ];
+       snprintf(buf, SIZ, "UIMG 1|_floorpic_|%s",
+                bstr("which_floor"));
+       do_graphics_upload(buf);
+}
+
+void 
+InitModule_GRAPHICS
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_editpic"), display_editpic, 0);
+       WebcitAddUrlHandler(HKEY("editpic"), editpic, 0);
+       WebcitAddUrlHandler(HKEY("display_editroompic"), display_editroompic, 0);
+       WebcitAddUrlHandler(HKEY("display_edithello"), display_edithello, 0);
+       WebcitAddUrlHandler(HKEY("edithellopic"), edithellopic, 0);
+       WebcitAddUrlHandler(HKEY("display_editgoodbyepic"), display_editgoodbyepic, 0);
+       WebcitAddUrlHandler(HKEY("editgoodbuyepic"), editgoodbuyepic, 0);
+       WebcitAddUrlHandler(HKEY("display_editfloorpic"), display_editfloorpic, 0);
+       WebcitAddUrlHandler(HKEY("editfloorpic"), editfloorpic, 0);
+}
index 981e2c9287eb8ed1f201d144b6c2cef192d39bfc..4b76d6bbf883d1263e342f7276035b9f9be62ba1 100644 (file)
@@ -795,5 +795,15 @@ void commit_iconbar(void) {
 }
 
 
+void 
+InitModule_ICONBAR
+(void)
+{
+       WebcitAddUrlHandler(HKEY("iconbar_ajax_menu"), do_iconbar, AJAX);
+       WebcitAddUrlHandler(HKEY("iconbar_ajax_rooms"), do_iconbar_roomlist, AJAX);
+       WebcitAddUrlHandler(HKEY("display_customize_iconbar"), display_customize_iconbar, 0);
+       WebcitAddUrlHandler(HKEY("commit_iconbar"), commit_iconbar, 0);
+}
+
 
 /*@}*/
index b483dd1aa873c7151e7c313b843b73337ae44458..ad27d97b595513639b3d4a44c33694e6754f4031 100644 (file)
@@ -207,3 +207,11 @@ void save_inetconf(void) {
        free(etype);
        free(newconfig);
 }
+
+void 
+InitModule_INETCONF
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_inetconf"), display_inetconf, 0);
+       WebcitAddUrlHandler(HKEY("save_inetconf"), save_inetconf, AJAX);
+}
index 14b3cedc3fb1e7e25af947bcfd6a2c39e4dafdcb..1ec145374b3d9a3894174584d2dd7bb9935b6bdf 100644 (file)
@@ -415,3 +415,17 @@ void display_shutdown(void)
                }
        }
 }
+
+void _display_menubar(void) { display_menubar(0); }
+
+void 
+InitModule_MAINMENU
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_aide_menu"), display_aide_menu, 0);
+       WebcitAddUrlHandler(HKEY("server_shutdown"), display_shutdown, 0);
+       WebcitAddUrlHandler(HKEY("display_main_menu"), display_main_menu, 0);
+       WebcitAddUrlHandler(HKEY("display_generic"), display_generic, 0);
+       WebcitAddUrlHandler(HKEY("do_generic"), do_generic, 0);
+       WebcitAddUrlHandler(HKEY("display_menubar"), _display_menubar, 0);
+}
index 4d2724c119969a652d2428f12205de0576d25f70..7676c9dd80ad04b0cc36e88043a596d0c7078fba 100644 (file)
@@ -1390,13 +1390,11 @@ ENDBODY:        /* If there are attached submessages, display them now... */
  *
  * msgnum_as_string == Message number, as a string instead of as a long int
  */
-void embed_message(char *msgnum_as_string) {
+void embed_message(void) {
        long msgnum = 0L;
 
-       msgnum = atol(msgnum_as_string);
-       begin_ajax_response();
+       msgnum = StrTol(WC->UrlFragment1);
        read_message(msgnum, 0, "");
-       end_ajax_response();
 }
 
 
@@ -1405,10 +1403,10 @@ void embed_message(char *msgnum_as_string) {
  *
  * msgnum_as_string == Message number, as a string instead of as a long int
  */
-void print_message(char *msgnum_as_string) {
+void print_message(void) {
        long msgnum = 0L;
 
-       msgnum = atol(msgnum_as_string);
+       msgnum = StrTol(WC->UrlFragment1);
        output_headers(0, 0, 0, 0, 0, 0);
 
        wprintf("Content-type: text/html\r\n"
@@ -1436,11 +1434,11 @@ void print_message(char *msgnum_as_string) {
  *
  * \param msgnum_as_string Message number, as a string instead of as a long int
  */
-void display_headers(char *msgnum_as_string) {
+void display_headers(void) {
        long msgnum = 0L;
        char buf[1024];
 
-       msgnum = atol(msgnum_as_string);
+       msgnum = StrTol(WC->UrlFragment1);
        output_headers(0, 0, 0, 0, 0, 0);
 
        wprintf("Content-type: text/plain\r\n"
@@ -3800,3 +3798,29 @@ void confirm_move_msg(void)
        wprintf("</CENTER>\n");
        wDumpContent(1);
 }
+
+void readnew(void) { readloop("readnew");}
+void readold(void) { readloop("readold");}
+void readfwd(void) { readloop("readfwd");}
+void headers(void) { readloop("headers");}
+void do_search(void) { readloop("do_search");}
+
+void 
+InitModule_MSG
+(void)
+{
+       WebcitAddUrlHandler(HKEY("readnew"), readnew, 0);
+       WebcitAddUrlHandler(HKEY("readold"), readold, 0);
+       WebcitAddUrlHandler(HKEY("readfwd"), readfwd, 0);
+       WebcitAddUrlHandler(HKEY("headers"), headers, 0);
+       WebcitAddUrlHandler(HKEY("do_search"), do_search, 0);
+       WebcitAddUrlHandler(HKEY("display_enter"), display_enter, 0);
+       WebcitAddUrlHandler(HKEY("post"), post_message, 0);
+       WebcitAddUrlHandler(HKEY("move_msg"), move_msg, 0);
+       WebcitAddUrlHandler(HKEY("delete_msg"), delete_msg, 0);
+       WebcitAddUrlHandler(HKEY("confirm_move_msg"), confirm_move_msg, 0);
+       WebcitAddUrlHandler(HKEY("msg"), embed_message, NEED_URL|AJAX);
+       WebcitAddUrlHandler(HKEY("printmsg"), print_message, NEED_URL);
+       WebcitAddUrlHandler(HKEY("msgheaders"), display_headers, NEED_URL);
+       return ;
+}
diff --git a/webcit/mk_module_init.sh b/webcit/mk_module_init.sh
new file mode 100755 (executable)
index 0000000..bf38637
--- /dev/null
@@ -0,0 +1,123 @@
+#!/bin/sh
+#
+# Script to generate $C_FILE
+#
+
+ECHO=/usr/bin/printf
+
+#MINUS_e=X`$ECHO -n -e`
+#if [ $MINUS_e != "X" ] ; then
+#      MINUS_e=""
+#else
+#      MINUS_e="-e"
+#fi
+
+#MINUS_E=X`$ECHO -n -E`
+#if [ $MINUS_E != "X" ] ; then
+#      MINUS_E=""
+#else
+#      MINUS_E="-E"
+#fi
+
+
+CUR_DIR=`pwd`
+C_FILE="$CUR_DIR/modules_init.c"
+H_FILE="$CUR_DIR/modules_init.h"
+MOD_FILE="$CUR_DIR/Make_modules"
+SRC_FILE="$CUR_DIR/Make_sources"
+U_FILE="$CUR_DIR/modules_upgrade.c"
+
+/usr/bin/printf "Scanning extension modules for entry points.\n"
+
+
+#start of the files which inturn removes any existing file
+#
+
+# start the Makefile included file for $SERV_MODULES
+cat <<EOF  >$MOD_FILE
+#
+# Make_modules
+# This file is to be included by Makefile to dynamically add modules to the build process
+# THIS FILE WAS AUTO GENERATED BY mk_modules_init.sh DO NOT EDIT THIS FILE
+#
+
+EOF
+
+# start the Makefile included file for $SOURCES
+cat <<EOF  >$SRC_FILE
+#
+# Make_sources
+# This file is to be included by Makefile to dynamically add modules to the build process
+# THIS FILE WAS AUTO GENERATED BY mk_modules_init.sh DO NOT EDIT THIS FILE
+#
+
+EOF
+
+# start the c file
+cat <<EOF  >$C_FILE
+/*
+ * $C_FILE
+ * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
+ */
+
+
+
+#include "sysdep.h"
+#include <stdlib.h>
+#include <time.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <libcitadel.h>
+#include "webcit.h"
+#include "modules_init.h"
+#include "webserver.h"
+
+void LogPrintMessages(long err);
+extern long DetailErrorFlags;
+
+
+
+void initialise_modules (void)
+{
+
+EOF
+
+
+#start the header file
+cat <<EOF > $H_FILE
+/* 
+ * $H_FILE
+ * Auto generated by mk_modules_init.sh DO NOT EDIT THIS FILE
+ */
+
+
+#ifndef MODULES_INIT_H
+#define MODULES_INIT_H
+extern size_t nSizErrmsg;
+void initialise_modules (void);
+
+
+EOF
+
+
+INIT_FUNCS=`grep InitModule_ *.c |sed "s;.*:;;"`
+
+for HOOK in $INIT_FUNCS; do
+HOOKNAME=`echo $HOOK |sed "s;InitModule_;;"`
+# Add this entry point to the .c file
+cat <<EOF >> $C_FILE
+       lprintf (CTDL_INFO, "Initializing $HOOKNAME\n");
+       $HOOK();
+EOF
+# Add this entry point to the .h file
+cat <<EOF >> $H_FILE
+       extern void $HOOK(void);
+EOF
+done
+
+
+/usr/bin/printf "}\n" >> $C_FILE
+
+/usr/bin/printf "\n#endif /* MODULES_INIT_H */\n" >> $H_FILE
index 79130b8db2fb5c78ea6723197f48c8d3664f0e5e..beb7e095f0608ae1ca0d55002ce098d19bd475ac 100644 (file)
@@ -294,5 +294,16 @@ void delete_node(void)
        display_netconf();
 }
 
+void 
+InitModule_NETCONF
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_edit_node"), display_edit_node, 0);
 
+       WebcitAddUrlHandler(HKEY("edit_node"), edit_node, 0);
+       WebcitAddUrlHandler(HKEY("display_netconf"), display_netconf, 0);
+       WebcitAddUrlHandler(HKEY("display_confirm_delete_node"), display_confirm_delete_node, 0);
+       WebcitAddUrlHandler(HKEY("delete_node"), delete_node, 0);
+       WebcitAddUrlHandler(HKEY("display_add_node"), display_add_node, 0);
+}
 /*@}*/
index 7478813d971ceae17c0b042a6a7d2c44045fc64d..497251d3997c81e25e910e207b0e8c2aa9b42075 100644 (file)
@@ -379,3 +379,11 @@ void add_new_note(void) {
        
        readloop("readfwd");
 }
+
+void 
+InitModule_NOTES
+(void)
+{
+       WebcitAddUrlHandler(HKEY("add_new_note"), add_new_note, 0);
+       WebcitAddUrlHandler(HKEY("ajax_update_note"), ajax_update_note, 0);
+}
index cae9de053cbb7203842100b7fbcaacb7deae847b..58c3503ab46049cc8f4aee249dfeb82fbade4c2a 100644 (file)
@@ -106,3 +106,12 @@ void openid_detach(void) {
 
        display_openids();
 }
+
+void 
+InitModule_OPENID
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_openids"), display_openids, 0);
+       WebcitAddUrlHandler(HKEY("openid_attach"), openid_attach, 0);
+       WebcitAddUrlHandler(HKEY("openid_detach"), openid_detach, 0);
+}
index 93c402501e4913d0543ec497219f230ebef7f1fa..1d79cddf5dc4343386efbf5c2b8ffbf71fe1bb01 100644 (file)
@@ -498,4 +498,15 @@ void chat_send(void) {
        wDumpContent(0);
 }
 
+void 
+InitModule_PAGING
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_page"), display_page, 0);
+       WebcitAddUrlHandler(HKEY("page_user"), page_user, 0);
+       WebcitAddUrlHandler(HKEY("chat"), do_chat, 0);
+       WebcitAddUrlHandler(HKEY("chat_recv"), chat_recv, 0);
+       WebcitAddUrlHandler(HKEY("chat_send"), chat_send, 0);
+}
+
 /*@}*/
index db35cedaeb4f56acbe6c0d915d5fded068009f34..5b47e1659afeacdf8ca2687c3bc2521817029c2d 100644 (file)
@@ -604,4 +604,11 @@ void set_preferences(void)
 }
 
 
+void 
+InitModule_PREFERENCES
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_preferences"), display_preferences, 0);
+       WebcitAddUrlHandler(HKEY("set_preferences"), set_preferences, 0);
+}
 /*@}*/
index e67c04b47e023364197743554385d586c89d8862..4b2e753d4ec203409f0b31cad281d81800853bf5 100644 (file)
@@ -111,3 +111,11 @@ void save_pushemail(void) {
        serv_getln(buf, sizeof buf);
        http_redirect("display_pushemail");
 }
+
+void 
+InitModule_PUSHMAIL
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_pushemail"), display_pushemail, 0);
+       WebcitAddUrlHandler(HKEY("save_pushemail"), save_pushemail, 0);
+}
index da33b279c917d90c52ce66636953dae5bd3da143..05a7feef41a6589020b2f1fda5d5e6b6ed70a290 100644 (file)
@@ -3187,10 +3187,14 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
  * \brief print a floor div???
  * \param which_floordiv name of the floordiv???
  */
-void set_floordiv_expanded(char *which_floordiv) {
-       begin_ajax_response();
-       StrBufPrintf(WC->floordiv_expanded, "%s", which_floordiv);
-       end_ajax_response();
+void set_floordiv_expanded(void) {
+       struct wcsession *WCC = WC;
+       
+       if (WCC->floordiv_expanded == NULL)
+               WCC->floordiv_expanded = NewStrBuf();
+       else
+               FlushStrBuf(WC->floordiv_expanded);
+       StrBufAppendBuf(WC->floordiv_expanded, WC->UrlFragment1, 0);
 }
 
 /**
@@ -3640,4 +3644,43 @@ void set_room_policy(void) {
        display_editroom();
 }
 
+
+void _gotonext(void) { slrp_highest(); gotonext(); }
+void dotskip(void) {smart_goto(bstr("room"));}
+void _display_private(void) { display_private("", 0); }
+void dotgoto(void) {
+       if (WC->wc_view != VIEW_MAILBOX) {      /* dotgoto acts like dotskip when we're in a mailbox view */
+               slrp_highest();
+       }
+       smart_goto(bstr("room"));
+}
+
+
+void 
+InitModule_ROOMOPS
+(void)
+{
+       WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
+       WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, 0);
+       WebcitAddUrlHandler(HKEY("skip"), gotonext, 0);
+       WebcitAddUrlHandler(HKEY("ungoto"), ungoto, 0);
+       WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, 0);
+       WebcitAddUrlHandler(HKEY("dotskip"), dotskip, 0);
+       WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
+       WebcitAddUrlHandler(HKEY("goto_private"), goto_private, 0);
+       WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
+       WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
+       WebcitAddUrlHandler(HKEY("zap"), zap, 0);
+       WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
+       WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
+       WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
+       WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
+       WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
+       WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
+       WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
+       WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
+       WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
+       WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
+}
+
 /*@}*/
index d2d177a2bee34651eb85aebb976f7b4531c07df2..8b52e0616f812a609beea2e2a6e840f1e45a7025 100644 (file)
@@ -52,4 +52,9 @@ void do_setup_wizard(void)
        wDumpContent(1);
 }
 
-
+void 
+InitModule_SETUP_WIZARD
+(void)
+{
+       WebcitAddUrlHandler(HKEY("setup_wizard"), do_setup_wizard, 0);
+}
index cf68af89ae1eb3f19b364f15af1b8e3cf3749f74..d4d00dab74771c026a5db96cd60bc1e8f8981f87 100644 (file)
@@ -1155,3 +1155,16 @@ void display_rules_editor_inner_div(void) {
 
        free(rooms);
 }
+
+void _display_add_remove_scripts(void) {display_add_remove_scripts(NULL);}
+
+void 
+InitModule_SIEVE
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_sieve"), display_sieve, 0);
+       WebcitAddUrlHandler(HKEY("save_sieve"), save_sieve, 0);
+       WebcitAddUrlHandler(HKEY("display_add_remove_scripts"), _display_add_remove_scripts, 0);
+       WebcitAddUrlHandler(HKEY("create_script"), create_script, 0);
+       WebcitAddUrlHandler(HKEY("delete_script"), delete_script, 0);
+}
index 7a7288dee90c92b874d44dc8f8b3efbfff41a3b2..5a2ee2e6f4f780db460788e1d6513f24fe9ad12c 100644 (file)
@@ -845,5 +845,11 @@ void siteconfig(void)
        display_aide_menu();
 }
 
-
+void 
+InitModule_SITECONFIG
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_siteconfig"), display_siteconfig, 0);
+       WebcitAddUrlHandler(HKEY("siteconfig"), siteconfig, 0);
+}
 /*@}*/
index 3a1b29f2dac1a3537b9e686120defb4f412d83a2..16a2491ffb417be18d54c9aeaada22f101b7c65c 100644 (file)
@@ -265,7 +265,12 @@ void display_smtpqueue(void)
 
 }
 
-
-
+void 
+InitModule_SMTP_QUEUE
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_smtpqueue"), display_smtpqueue, 0);
+       WebcitAddUrlHandler(HKEY("display_smtpqueue_inner_div"), display_smtpqueue_inner_div, 0);
+}
 
 /*@}*/
index f71a43b080c5589ff1f8b71dcb2dd9972be00853..f7230e6b6aafd42bff7ec3122a6d387c89d69940 100644 (file)
@@ -288,5 +288,16 @@ void summary(void) {
        wDumpContent(1);
 }
 
+void 
+InitModule_SUMMARY
+(void)
+{
+       WebcitAddUrlHandler(HKEY("new_messages_html"), new_messages_section, AJAX);
+       WebcitAddUrlHandler(HKEY("tasks_inner_html"), tasks_section, AJAX);
+       WebcitAddUrlHandler(HKEY("calendar_inner_html"), calendar_section, AJAX);
+       WebcitAddUrlHandler(HKEY("mini_calendar"), ajax_mini_calendar, AJAX);
+       WebcitAddUrlHandler(HKEY("summary"), summary, 0);
+       WebcitAddUrlHandler(HKEY("summary_inner_div"), summary_inner_div, AJAX);
+}
 
 /*@}*/
index 00abb6cc5eefec13b01e683e6466c579f1093220..b734e16f01b80559e1981b099688dbbfe419231c 100644 (file)
@@ -101,4 +101,23 @@ void save_edit(char *description, char *enter_cmd, int regoto)
 }
 
 
+void display_editinfo(void){ display_edit(_("Room info"), "EINF 0", "RINF", "editinfo", 1);}
+void editinfo(void) {save_edit(_("Room info"), "EINF 1", 1);}
+void display_editbio(void) {
+       char buf[SIZ];
+
+       snprintf(buf, SIZ, "RBIO %s", WC->wc_fullname);
+       display_edit(_("Your bio"), "NOOP", buf, "editbio", 3);
+}
+void editbio(void) { save_edit(_("Your bio"), "EBIO", 0); }
+
+void 
+InitModule_SYSMSG
+(void)
+{
+       WebcitAddUrlHandler(HKEY("display_editinfo"), display_editinfo, 0);
+       WebcitAddUrlHandler(HKEY("editinfo"), editinfo, 0);
+       WebcitAddUrlHandler(HKEY("display_editbio"), display_editbio, 0);
+       WebcitAddUrlHandler(HKEY("editbio"), editbio, 0);
+}
 /*@}*/
index e7ac53bd243d405b081dfb906cbbb507fbb3cd5f..d5b9f44e0a7b44212a3e43c46e93aabcf8fd9c30 100644 (file)
@@ -529,5 +529,17 @@ void create_user(void) {
 }
 
 
+void _select_user_to_edit(void){select_user_to_edit(NULL, NULL);}
+void _display_edituser(void) {display_edituser(NULL, 0);}
 
+void 
+InitModule_USEREDIT
+(void)
+{
+       WebcitAddUrlHandler(HKEY("select_user_to_edit"), _select_user_to_edit, 0);
+       WebcitAddUrlHandler(HKEY("display_edituser"), _display_edituser, 0);
+       WebcitAddUrlHandler(HKEY("edituser"), edituser, 0);
+       WebcitAddUrlHandler(HKEY("create_user"), create_user, 0);
+       WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);
+}
 /*@}*/
index 20450d9281d7a7b8309c669d3b6f7cccea1e9ddf..0733851d2dd39b22a8494e132d74de4ddd44919f 100644 (file)
@@ -170,5 +170,11 @@ void showuser(void)
        wDumpContent(1);
 }
 
-
+void 
+InitModule_USERLIST
+(void)
+{
+       WebcitAddUrlHandler(HKEY("userlist"), userlist, 0);
+       WebcitAddUrlHandler(HKEY("showuser"), showuser, 0);
+}
 /*@}*/
index 17b781778c9804509c0c7d6138bf97b922ae4e13..d0e3ef7a074e5733721c98254d52327a8abdbce9 100644 (file)
@@ -485,4 +485,12 @@ void submit_vcard(void) {
 
 
 
+void 
+InitModule_VCARD
+(void)
+{
+       WebcitAddUrlHandler(HKEY("edit_vcard"), edit_vcard, 0);
+       WebcitAddUrlHandler(HKEY("submit_vcard"), submit_vcard, 0);
+}
+
 /*@}*/
index 8892ece71d52a95408daf39fdc9fd91b27705bcf..2660b3d2f0c883ae68a6b348cc162f337309e083 100644 (file)
@@ -22,8 +22,10 @@ static char *unset = "; expires=28-May-1971 18:10:00 GMT";
 
 HashList *HandlerHash = NULL;
 
-
-void WebcitAddUrlHandler(const char * UrlString, long UrlSLen, WebcitHandlerFunc F, int IsAjax)
+void WebcitAddUrlHandler(const char * UrlString, 
+                        long UrlSLen, 
+                        WebcitHandlerFunc F, 
+                        long Flags)
 {
        WebcitHandler *NewHandler;
 
@@ -32,8 +34,7 @@ void WebcitAddUrlHandler(const char * UrlString, long UrlSLen, WebcitHandlerFunc
        
        NewHandler = (WebcitHandler*) malloc(sizeof(WebcitHandler));
        NewHandler->F = F;
-       NewHandler->IsAjax = IsAjax;
-
+       NewHandler->Flags = Flags;
        Put(HandlerHash, UrlString, UrlSLen, NewHandler, NULL);
 }
 
@@ -935,7 +936,7 @@ void output_image()
 /*
  * Extract an embedded photo from a vCard for display on the client
  */
-void display_vcard_photo_img(char *msgnum_as_string)
+void display_vcard_photo_img(void)
 {
        long msgnum = 0L;
        char *vcard;
@@ -945,7 +946,7 @@ void display_vcard_photo_img(char *msgnum_as_string)
        int decoded;
        const char *contentType;
 
-       msgnum = atol(msgnum_as_string);
+       msgnum = StrTol(WC->UrlFragment1);
        
        vcard = load_mimepart(msgnum,"1");
        v = vcard_load(vcard);
@@ -976,7 +977,7 @@ void display_vcard_photo_img(char *msgnum_as_string)
  * partnum             The MIME part to be output
  * force_download      Nonzero to force set the Content-Type: header to "application/octet-stream"
  */
-void mimepart(char *msgnum, char *partnum, int force_download)
+void mimepart(const char *msgnum, const char *partnum, int force_download)
 {
        char buf[256];
        off_t bytes;
@@ -1366,6 +1367,7 @@ void session_loop(struct httprequest *req)
        char c_httpauth_user[SIZ];
        char c_httpauth_pass[SIZ];
        char cookie[SIZ];
+       struct wcsession *WCC = WC;
 
        safestrncpy(c_username, "", sizeof c_username);
        safestrncpy(c_password, "", sizeof c_password);
@@ -1375,9 +1377,9 @@ void session_loop(struct httprequest *req)
        safestrncpy(c_httpauth_pass, DEFAULT_HTTPAUTH_PASS, sizeof c_httpauth_pass);
        strcpy(browser_host, "");
 
-       WC->upload_length = 0;
-       WC->upload = NULL;
-       WC->is_mobile = 0;
+       WCC->upload_length = 0;
+       WCC->upload = NULL;
+       WCC->is_mobile = 0;
 
        hptr = req;
        if (hptr == NULL) return;
@@ -1436,17 +1438,17 @@ void session_loop(struct httprequest *req)
                else if (!strncasecmp(buf, "User-agent: ", 12)) {
                        safestrncpy(user_agent, &buf[12], sizeof user_agent);
                        if (is_mobile_ua(&buf[12])) {
-                               WC->is_mobile = 1;
+                               WCC->is_mobile = 1;
                        }
                }
                else if (!strncasecmp(buf, "X-Forwarded-Host: ", 18)) {
                        if (follow_xff) {
-                               safestrncpy(WC->http_host, &buf[18], sizeof WC->http_host);
+                               safestrncpy(WCC->http_host, &buf[18], sizeof WCC->http_host);
                        }
                }
                else if (!strncasecmp(buf, "Host: ", 6)) {
-                       if (IsEmptyStr(WC->http_host)) {
-                               safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
+                       if (IsEmptyStr(WCC->http_host)) {
+                               safestrncpy(WCC->http_host, &buf[6], sizeof WCC->http_host);
                        }
                }
                else if (!strncasecmp(buf, "X-Forwarded-For: ", 17)) {
@@ -1470,7 +1472,7 @@ void session_loop(struct httprequest *req)
                body_start = strlen(content);
 
                /** Read the entire input data at once. */
-               client_read(WC->http_sock, &content[body_start], ContentLength);
+               client_read(WCC->http_sock, &content[body_start], ContentLength);
 
                if (!strncasecmp(ContentType, "application/x-www-form-urlencoded", 33)) {
                        addurls(&content[body_start], ContentLength);
@@ -1483,9 +1485,9 @@ void session_loop(struct httprequest *req)
        }
 
        /* make a note of where we are in case the user wants to save it */
-       safestrncpy(WC->this_page, cmd, sizeof(WC->this_page));
-       remove_token(WC->this_page, 2, ' ');
-       remove_token(WC->this_page, 0, ' ');
+       safestrncpy(WCC->this_page, cmd, sizeof(WCC->this_page));
+       remove_token(WCC->this_page, 2, ' ');
+       remove_token(WCC->this_page, 0, ' ');
 
        /* If there are variables in the URL, we must grab them now */
        len = strlen(cmd);
@@ -1552,8 +1554,8 @@ void session_loop(struct httprequest *req)
        /* If the client sent a nonce that is incorrect, kill the request. */
        if (strlen(bstr("nonce")) > 0) {
                lprintf(9, "Comparing supplied nonce %s to session nonce %ld\n", 
-                       bstr("nonce"), WC->nonce);
-               if (ibstr("nonce") != WC->nonce) {
+                       bstr("nonce"), WCC->nonce);
+               if (ibstr("nonce") != WCC->nonce) {
                        lprintf(9, "Ignoring request with mismatched nonce.\n");
                        wprintf("HTTP/1.1 404 Security check failed\r\n");
                        wprintf("Content-Type: text/plain\r\n");
@@ -1567,23 +1569,23 @@ void session_loop(struct httprequest *req)
         * If we're not connected to a Citadel server, try to hook up the
         * connection now.
         */
-       if (!WC->connected) {
+       if (!WCC->connected) {
                if (!strcasecmp(ctdlhost, "uds")) {
                        /* unix domain socket */
                        snprintf(buf, SIZ, "%s/citadel.socket", ctdlport);
-                       WC->serv_sock = uds_connectsock(buf);
+                       WCC->serv_sock = uds_connectsock(buf);
                }
                else {
                        /* tcp socket */
-                       WC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
+                       WCC->serv_sock = tcp_connectsock(ctdlhost, ctdlport);
                }
 
-               if (WC->serv_sock < 0) {
+               if (WCC->serv_sock < 0) {
                        do_logout();
                        goto SKIP_ALL_THIS_CRAP;
                }
                else {
-                       WC->connected = 1;
+                       WCC->connected = 1;
                        serv_getln(buf, sizeof buf);    /** get the server welcome message */
 
                        /**
@@ -1593,7 +1595,7 @@ void session_loop(struct httprequest *req)
                         * and such a header has already turned up something.
                         */
                        if ( (!follow_xff) || (strlen(browser_host) == 0) ) {
-                               locate_host(browser_host, WC->http_sock);
+                               locate_host(browser_host, WCC->http_sock);
                        }
 
                        get_serv_info(browser_host, user_agent);
@@ -1630,7 +1632,7 @@ void session_loop(struct httprequest *req)
         * If we're not logged in, but we have HTTP Authentication data,
         * try logging in to Citadel using that.
         */
-       if ((!WC->logged_in)
+       if ((!WCC->logged_in)
           && (strlen(c_httpauth_user) > 0)
           && (strlen(c_httpauth_pass) > 0)) {
                serv_printf("USER %s", c_httpauth_user);
@@ -1641,8 +1643,8 @@ void session_loop(struct httprequest *req)
                        if (buf[0] == '2') {
                                become_logged_in(c_httpauth_user,
                                                c_httpauth_pass, buf);
-                               safestrncpy(WC->httpauth_user, c_httpauth_user, sizeof WC->httpauth_user);
-                               safestrncpy(WC->httpauth_pass, c_httpauth_pass, sizeof WC->httpauth_pass);
+                               safestrncpy(WCC->httpauth_user, c_httpauth_user, sizeof WCC->httpauth_user);
+                               safestrncpy(WCC->httpauth_pass, c_httpauth_pass, sizeof WCC->httpauth_pass);
                        } else {
                                /* Should only display when password is wrong */
                                authorization_required(&buf[4]);
@@ -1666,8 +1668,8 @@ void session_loop(struct httprequest *req)
        if (!strncasecmp(action, "groupdav", 8)) {
                groupdav_main(req, ContentType, /* do GroupDAV methods */
                        ContentLength, content+body_start);
-               if (!WC->logged_in) {
-                       WC->killthis = 1;       /* If not logged in, don't */
+               if (!WCC->logged_in) {
+                       WCC->killthis = 1;      /* If not logged in, don't */
                }                               /* keep the session active */
                goto SKIP_ALL_THIS_CRAP;
        }
@@ -1680,8 +1682,8 @@ void session_loop(struct httprequest *req)
        if ((strcasecmp(request_method, "GET")) && (strcasecmp(request_method, "POST"))) {
                groupdav_main(req, ContentType, /** do GroupDAV methods */
                        ContentLength, content+body_start);
-               if (!WC->logged_in) {
-                       WC->killthis = 1;       /** If not logged in, don't */
+               if (!WCC->logged_in) {
+                       WCC->killthis = 1;      /** If not logged in, don't */
                }                               /** keep the session active */
                goto SKIP_ALL_THIS_CRAP;
        }
@@ -1690,7 +1692,7 @@ void session_loop(struct httprequest *req)
         * If we're not logged in, but we have username and password cookies
         * supplied by the browser, try using them to log in.
         */
-       if ((!WC->logged_in)
+       if ((!WCC->logged_in)
           && (!IsEmptyStr(c_username))
           && (!IsEmptyStr(c_password))) {
                serv_printf("USER %s", c_username);
@@ -1707,11 +1709,11 @@ void session_loop(struct httprequest *req)
         * If we don't have a current room, but a cookie specifying the
         * current room is supplied, make an effort to go there.
         */
-       if ((IsEmptyStr(WC->wc_roomname)) && (!IsEmptyStr(c_roomname))) {
+       if ((IsEmptyStr(WCC->wc_roomname)) && (!IsEmptyStr(c_roomname))) {
                serv_printf("GOTO %s", c_roomname);
                serv_getln(buf, sizeof buf);
                if (buf[0] == '2') {
-                       safestrncpy(WC->wc_roomname, c_roomname, sizeof WC->wc_roomname);
+                       safestrncpy(WCC->wc_roomname, c_roomname, sizeof WCC->wc_roomname);
                }
        }
 
@@ -1719,392 +1721,39 @@ void session_loop(struct httprequest *req)
                output_image();
        } else if (!strcasecmp(action, "display_mime_icon")) {
                display_mime_icon();
-
-       /*
-        * All functions handled below this point ... make sure we log in
-        * before doing anything else!
-        */
-       } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) {
-               do_login();
-       } else if ((!WC->logged_in) && (!strcasecmp(action, "display_openid_login"))) {
-               display_openid_login(NULL);
-       } else if ((!WC->logged_in) && (!strcasecmp(action, "openid_login"))) {
-               do_openid_login();
-       } else if (!strcasecmp(action, "finalize_openid_login")) {
-               finalize_openid_login();
-       } else if (!strcasecmp(action, "openid_manual_create")) {
-               openid_manual_create();
-       } else if (!WC->logged_in) {
-               display_login(NULL);
        }
-
-       /*
-        * Various commands...
-        */
-
        else {
                void *vHandler;
                WebcitHandler *Handler;
-
+               
                GetHash(HandlerHash, action, strlen(action) /* TODO*/, &vHandler),
                        Handler = (WebcitHandler*) vHandler;
                if (Handler != NULL) {
-                       if (Handler->IsAjax)
-                               begin_ajax_response();
-                       Handler->F();
-                       if (Handler->IsAjax)
-                               end_ajax_response();
-               }
-               
-
-       else if (!strcasecmp(action, "do_welcome")) {
-               do_welcome();
-       } else if (!strcasecmp(action, "blank")) {
-               blank_page();
-       } else if (!strcasecmp(action, "do_template")) {
-               url_do_template();
-       } else if (!strcasecmp(action, "display_aide_menu")) {
-               display_aide_menu();
-       } else if (!strcasecmp(action, "server_shutdown")) {
-               display_shutdown();
-       } else if (!strcasecmp(action, "display_main_menu")) {
-               display_main_menu();
-       } else if (!strcasecmp(action, "who")) {
-               who();
-       } else if (!strcasecmp(action, "sslg")) {
-               seconds_since_last_gexp();
-       } else if (!strcasecmp(action, "who_inner_html")) {
-               begin_ajax_response();
-               who_inner_div();
-               end_ajax_response();
-       } else if (!strcasecmp(action, "wholist_section")) {
-               begin_ajax_response();
-               wholist_section();
-               end_ajax_response();
-       } else if (!strcasecmp(action, "new_messages_html")) {
-               begin_ajax_response();
-               new_messages_section();
-               end_ajax_response();
-       } else if (!strcasecmp(action, "tasks_inner_html")) {
-               begin_ajax_response();
-               tasks_section();
-               end_ajax_response();
-       } else if (!strcasecmp(action, "calendar_inner_html")) {
-               begin_ajax_response();
-               calendar_section();
-               end_ajax_response();
-       } else if (!strcasecmp(action, "mini_calendar")) {
-               begin_ajax_response();
-               ajax_mini_calendar();
-               end_ajax_response();
-       } else if (!strcasecmp(action, "iconbar_ajax_menu")) {
-               begin_ajax_response();
-               do_iconbar();
-               end_ajax_response();
-       } else if (!strcasecmp(action, "iconbar_ajax_rooms")) {
-               begin_ajax_response();
-               do_iconbar_roomlist();
-               end_ajax_response();
-       } else if (!strcasecmp(action, "knrooms")) {
-               knrooms();
-       } else if (!strcasecmp(action, "gotonext")) {
-               slrp_highest();
-               gotonext();
-       } else if (!strcasecmp(action, "skip")) {
-               gotonext();
-       } else if (!strcasecmp(action, "ungoto")) {
-               ungoto();
-       } else if (!strcasecmp(action, "dotgoto")) {
-               if (WC->wc_view != VIEW_MAILBOX) {      /* dotgoto acts like dotskip when we're in a mailbox view */
-                       slrp_highest();
+                       if (!WCC->logged_in && ((Handler->Flags & ANONYMOUS) == 0)) {
+                               display_login(NULL);
+                       }
+                       else {
+                               if((Handler->Flags & NEED_URL)) {
+                                       if (WCC->UrlFragment1 == NULL)
+                                               WCC->UrlFragment1 = NewStrBuf();
+                                       if (WCC->UrlFragment2 == NULL)
+                                               WCC->UrlFragment2 = NewStrBuf();
+                                       StrBufPrintf(WCC->UrlFragment1, "%s", index[1]);
+                                       StrBufPrintf(WCC->UrlFragment2, "%s", index[2]);
+                               }
+                               if ((Handler->Flags & AJAX) != 0)
+                                       begin_ajax_response();
+                               Handler->F();
+                               if ((Handler->Flags & AJAX) != 0)
+                                       end_ajax_response();
+                       }
                }
-               smart_goto(bstr("room"));
-       } else if (!strcasecmp(action, "dotskip")) {
-               smart_goto(bstr("room"));
-       } else if (!strcasecmp(action, "termquit")) {
-               do_logout();
-       } else if (!strcasecmp(action, "readnew")) {
-               readloop("readnew");
-       } else if (!strcasecmp(action, "readold")) {
-               readloop("readold");
-       } else if (!strcasecmp(action, "readfwd")) {
-               readloop("readfwd");
-       } else if (!strcasecmp(action, "headers")) {
-               readloop("headers");
-       } else if (!strcasecmp(action, "do_search")) {
-               readloop("do_search");
-       } else if (!strcasecmp(action, "msg")) {
-               embed_message(index[1]);
-       } else if (!strcasecmp(action, "printmsg")) {
-               print_message(index[1]);
-       } else if (!strcasecmp(action, "msgheaders")) {
-               display_headers(index[1]);
-       } else if (!strcasecmp(action, "vcardphoto")) {
-               display_vcard_photo_img(index[1]);      
-       } else if (!strcasecmp(action, "wiki")) {
-               display_wiki_page();
-       } else if (!strcasecmp(action, "display_enter")) {
-               display_enter();
-       } else if (!strcasecmp(action, "post")) {
-               post_message();
-       } else if (!strcasecmp(action, "move_msg")) {
-               move_msg();
-       } else if (!strcasecmp(action, "delete_msg")) {
-               delete_msg();
-       } else if (!strcasecmp(action, "userlist")) {
-               userlist();
-       } else if (!strcasecmp(action, "showuser")) {
-               showuser();
-       } else if (!strcasecmp(action, "display_page")) {
-               display_page();
-       } else if (!strcasecmp(action, "page_user")) {
-               page_user();
-       } else if (!strcasecmp(action, "chat")) {
-               do_chat();
-       } else if (!strcasecmp(action, "display_private")) {
-               display_private("", 0);
-       } else if (!strcasecmp(action, "goto_private")) {
-               goto_private();
-       } else if (!strcasecmp(action, "zapped_list")) {
-               zapped_list();
-       } else if (!strcasecmp(action, "display_zap")) {
-               display_zap();
-       } else if (!strcasecmp(action, "zap")) {
-               zap();
-       } else if (!strcasecmp(action, "display_entroom")) {
-               display_entroom();
-       } else if (!strcasecmp(action, "entroom")) {
-               entroom();
-       } else if (!strcasecmp(action, "display_whok")) {
-               display_whok();
-       } else if (!strcasecmp(action, "do_invt_kick")) {
-               do_invt_kick();
-       } else if (!strcasecmp(action, "display_editroom")) {
-               display_editroom();
-       } else if (!strcasecmp(action, "netedit")) {
-               netedit();
-       } else if (!strcasecmp(action, "editroom")) {
-               editroom();
-       } else if (!strcasecmp(action, "display_editinfo")) {
-               display_edit(_("Room info"), "EINF 0", "RINF", "editinfo", 1);
-       } else if (!strcasecmp(action, "editinfo")) {
-               save_edit(_("Room info"), "EINF 1", 1);
-       } else if (!strcasecmp(action, "display_editbio")) {
-               snprintf(buf, SIZ, "RBIO %s", WC->wc_fullname);
-               display_edit(_("Your bio"), "NOOP", buf, "editbio", 3);
-       } else if (!strcasecmp(action, "editbio")) {
-               save_edit(_("Your bio"), "EBIO", 0);
-       } else if (!strcasecmp(action, "confirm_move_msg")) {
-               confirm_move_msg();
-       } else if (!strcasecmp(action, "delete_room")) {
-               delete_room();
-       } else if (!strcasecmp(action, "validate")) {
-               validate();
-               /* The users photo display / upload facility */
-       } else if (!strcasecmp(action, "display_editpic")) {
-               display_graphics_upload(_("your photo"),
-                                       "_userpic_",
-                                       "editpic");
-       } else if (!strcasecmp(action, "editpic")) {
-               do_graphics_upload("_userpic_");
-                /* room picture dispay / upload facility */
-       } else if (!strcasecmp(action, "display_editroompic")) {
-               display_graphics_upload(_("the icon for this room"),
-                                       "_roompic_",
-                                       "editroompic");
-       } else if (!strcasecmp(action, "editroompic")) {
-               do_graphics_upload("_roompic_");
-               /* the greetingpage hello pic */
-       } else if (!strcasecmp(action, "display_edithello")) {
-               display_graphics_upload(_("the Greetingpicture for the login prompt"),
-                                       "hello",
-                                       "edithellopic");
-       } else if (!strcasecmp(action, "edithellopic")) {
-               do_graphics_upload("hello");
-               /* the logoff banner */
-       } else if (!strcasecmp(action, "display_editgoodbyepic")) {
-               display_graphics_upload(_("the Logoff banner picture"),
-                                       "UIMG 0|%s|goodbuye",
-                                       "editgoodbuyepic");
-       } else if (!strcasecmp(action, "editgoodbuyepic")) {
-               do_graphics_upload("UIMG 1|%s|goodbuye");
-
-       } else if (!strcasecmp(action, "delete_floor")) {
-               delete_floor();
-       } else if (!strcasecmp(action, "rename_floor")) {
-               rename_floor();
-       } else if (!strcasecmp(action, "create_floor")) {
-               create_floor();
-       } else if (!strcasecmp(action, "display_editfloorpic")) {
-               snprintf(buf, SIZ, "UIMG 0|_floorpic_|%s",
-                       bstr("which_floor"));
-               display_graphics_upload(_("the icon for this floor"),
-                                       buf,
-                                       "editfloorpic");
-       } else if (!strcasecmp(action, "editfloorpic")) {
-               snprintf(buf, SIZ, "UIMG 1|_floorpic_|%s",
-                       bstr("which_floor"));
-               do_graphics_upload(buf);
-       } else if (!strcasecmp(action, "display_reg")) {
-               display_reg(0);
-       } else if (!strcasecmp(action, "display_changepw")) {
-               display_changepw();
-       } else if (!strcasecmp(action, "changepw")) {
-               changepw();
-       } else if (!strcasecmp(action, "display_edit_node")) {
-               display_edit_node();
-       } else if (!strcasecmp(action, "edit_node")) {
-               edit_node();
-       } else if (!strcasecmp(action, "display_netconf")) {
-               display_netconf();
-       } else if (!strcasecmp(action, "display_confirm_delete_node")) {
-               display_confirm_delete_node();
-       } else if (!strcasecmp(action, "delete_node")) {
-               delete_node();
-       } else if (!strcasecmp(action, "display_add_node")) {
-               display_add_node();
-       } else if (!strcasecmp(action, "terminate_session")) {
-               slrp_highest();
-               terminate_session();
-       } else if (!strcasecmp(action, "edit_me")) {
-               edit_me();
-       } else if (!strcasecmp(action, "display_siteconfig")) {
-               display_siteconfig();
-       } else if (!strcasecmp(action, "chat_recv")) {
-               chat_recv();
-       } else if (!strcasecmp(action, "chat_send")) {
-               chat_send();
-       } else if (!strcasecmp(action, "siteconfig")) {
-               siteconfig();
-       } else if (!strcasecmp(action, "display_generic")) {
-               display_generic();
-       } else if (!strcasecmp(action, "do_generic")) {
-               do_generic();
-       } else if (!strcasecmp(action, "ajax_servcmd")) {
-               ajax_servcmd();
-       } else if (!strcasecmp(action, "display_menubar")) {
-               display_menubar(1);
-       } else if (!strcasecmp(action, "mimepart")) {
-               mimepart(index[1], index[2], 0);
-       } else if (!strcasecmp(action, "mimepart_download")) {
-               mimepart(index[1], index[2], 1);
-       } else if (!strcasecmp(action, "edit_vcard")) {
-               edit_vcard();
-       } else if (!strcasecmp(action, "submit_vcard")) {
-               submit_vcard();
-       } else if (!strcasecmp(action, "select_user_to_edit")) {
-               select_user_to_edit(NULL, NULL);
-       } else if (!strcasecmp(action, "display_edituser")) {
-               display_edituser(NULL, 0);
-       } else if (!strcasecmp(action, "edituser")) {
-               edituser();
-       } else if (!strcasecmp(action, "create_user")) {
-               create_user();
-       } else if (!strcasecmp(action, "changeview")) {
-               change_view();
-       } else if (!strcasecmp(action, "change_start_page")) {
-               change_start_page();
-       } else if (!strcasecmp(action, "display_floorconfig")) {
-               display_floorconfig(NULL);
-       } else if (!strcasecmp(action, "toggle_self_service")) {
-               toggle_self_service();
-       } else if (!strcasecmp(action, "display_edit_task")) {
-               display_edit_task();
-       } else if (!strcasecmp(action, "save_task")) {
-               save_task();
-       } else if (!strcasecmp(action, "display_edit_event")) {
-               display_edit_event();
-       } else if (!strcasecmp(action, "save_event")) {
-               save_event();
-       } else if (!strcasecmp(action, "respond_to_request")) {
-               respond_to_request();
-       } else if (!strcasecmp(action, "handle_rsvp")) {
-               handle_rsvp();
-       } else if (!strcasecmp(action, "summary")) {
-               summary();
-       } else if (!strcasecmp(action, "summary_inner_div")) {
-               begin_ajax_response();
-               summary_inner_div();
-               end_ajax_response();
-       } else if (!strcasecmp(action, "display_customize_iconbar")) {
-               display_customize_iconbar();
-       } else if (!strcasecmp(action, "commit_iconbar")) {
-               commit_iconbar();
-       } else if (!strcasecmp(action, "set_room_policy")) {
-               set_room_policy();
-       } else if (!strcasecmp(action, "display_inetconf")) {
-               display_inetconf();
-       } else if (!strcasecmp(action, "save_inetconf")) {
-               save_inetconf();
-       } else if (!strcasecmp(action, "display_smtpqueue")) {
-               display_smtpqueue();
-       } else if (!strcasecmp(action, "display_smtpqueue_inner_div")) {
-               display_smtpqueue_inner_div();
-       } else if (!strcasecmp(action, "display_sieve")) {
-               display_sieve();
-       } else if (!strcasecmp(action, "save_sieve")) {
-               save_sieve();
-       } else if (!strcasecmp(action, "display_pushemail")) {
-               display_pushemail();
-       } else if (!strcasecmp(action, "save_pushemail")) {
-               save_pushemail();
-       } else if (!strcasecmp(action, "display_add_remove_scripts")) {
-               display_add_remove_scripts(NULL);
-       } else if (!strcasecmp(action, "create_script")) {
-               create_script();
-       } else if (!strcasecmp(action, "delete_script")) {
-               delete_script();
-       } else if (!strcasecmp(action, "setup_wizard")) {
-               do_setup_wizard();
-       } else if (!strcasecmp(action, "display_preferences")) {
-               display_preferences();
-       } else if (!strcasecmp(action, "set_preferences")) {
-               set_preferences();
-       } else if (!strcasecmp(action, "recp_autocomplete")) {
-               recp_autocomplete(bstr("recp"));
-       } else if (!strcasecmp(action, "cc_autocomplete")) {
-               recp_autocomplete(bstr("cc"));
-       } else if (!strcasecmp(action, "bcc_autocomplete")) {
-               recp_autocomplete(bstr("bcc"));
-       } else if (!strcasecmp(action, "display_address_book_middle_div")) {
-               display_address_book_middle_div();
-       } else if (!strcasecmp(action, "display_address_book_inner_div")) {
-               display_address_book_inner_div();
-       } else if (!strcasecmp(action, "set_floordiv_expanded")) {
-               set_floordiv_expanded(index[1]);
-       } else if (!strcasecmp(action, "diagnostics")) {
-               output_headers(1, 1, 1, 0, 0, 0);
-               wprintf("Session: %d<hr />\n", WC->wc_session);
-               wprintf("Command: <br /><PRE>\n");
-               escputs(cmd);
-               wprintf("</PRE><hr />\n");
-               wprintf("Variables: <br /><PRE>\n");
-               dump_vars();
-               wprintf("</PRE><hr />\n");
-               wDumpContent(1);
-       } else if (!strcasecmp(action, "add_new_note")) {
-               add_new_note();
-       } else if (!strcasecmp(action, "ajax_update_note")) {
-               ajax_update_note();
-       } else if (!strcasecmp(action, "display_room_directory")) {
-               display_room_directory();
-       } else if (!strcasecmp(action, "display_pictureview")) {
-               display_pictureview();
-       } else if (!strcasecmp(action, "download_file")) {
-               download_file(index[1]);
-       } else if (!strcasecmp(action, "upload_file")) {
-               upload_file();
-       } else if (!strcasecmp(action, "display_openids")) {
-               display_openids();
-       } else if (!strcasecmp(action, "openid_attach")) {
-               openid_attach();
-       } else if (!strcasecmp(action, "openid_detach")) {
-               openid_detach();
-       }
-
        /* When all else fais, display the main menu. */
        else {
-               display_main_menu();
+               if (!WCC->logged_in) 
+                       display_login(NULL);
+               else
+                       display_main_menu();
        }
 }
 SKIP_ALL_THIS_CRAP:
@@ -2114,9 +1763,9 @@ SKIP_ALL_THIS_CRAP:
                content = NULL;
        }
        free_urls();
-       if (WC->upload_length > 0) {
-               free(WC->upload);
-               WC->upload_length = 0;
+       if (WCC->upload_length > 0) {
+               free(WCC->upload);
+               WCC->upload_length = 0;
        }
 }
 
@@ -2133,4 +1782,45 @@ void sleeeeeeeeeep(int seconds)
        select(0, NULL, NULL, NULL, &tv);
 }
 
+void diagnostics(void)
+{
+       output_headers(1, 1, 1, 0, 0, 0);
+       wprintf("Session: %d<hr />\n", WC->wc_session);
+       wprintf("Command: <br /><PRE>\n");
+       escputs(WC->UrlFragment1);
+       wprintf("<br />\n");
+       escputs(WC->UrlFragment2);
+       wprintf("</PRE><hr />\n");
+       wprintf("Variables: <br /><PRE>\n");
+       dump_vars();
+       wprintf("</PRE><hr />\n");
+       wDumpContent(1);
+}
+
+void view_mimepart(void) {
+       mimepart(ChrPtr(WC->UrlFragment1),
+                ChrPtr(WC->UrlFragment2),
+                0);
+}
 
+void download_mimepart(void) {
+       mimepart(ChrPtr(WC->UrlFragment1),
+                ChrPtr(WC->UrlFragment2),
+                1);
+}
+
+void 
+InitModule_WEBCIT
+(void)
+{
+       WebcitAddUrlHandler(HKEY("blank"), blank_page, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("do_template"), url_do_template, ANONYMOUS);
+       WebcitAddUrlHandler(HKEY("sslg"), seconds_since_last_gexp, AJAX);
+       WebcitAddUrlHandler(HKEY("ajax_servcmd"), ajax_servcmd, 0);
+       WebcitAddUrlHandler(HKEY("change_start_page"), change_start_page, 0);
+       WebcitAddUrlHandler(HKEY("toggle_self_service"), toggle_self_service, 0);
+       WebcitAddUrlHandler(HKEY("vcardphoto"), display_vcard_photo_img, NEED_URL);
+       WebcitAddUrlHandler(HKEY("mimepart"), view_mimepart, NEED_URL);
+       WebcitAddUrlHandler(HKEY("mimepart_download"), download_mimepart, NEED_URL);
+       WebcitAddUrlHandler(HKEY("diagnostics"), diagnostics, NEED_URL);
+}
index 337063f5b2d3b5a25304ac4242b6c9ec49d8ae00..1a8cd774ff46d2a9bc888bef703d25f1d6aa3aea 100644 (file)
@@ -426,6 +426,8 @@ struct wcsession {
        time_t last_pager_check;                /**< last time we polled for instant msgs */
        int nonce;                              /**< session nonce (to prevent session riding) */
        int time_format_cache;                  /**< which timeformat does our user like? */
+       StrBuf *UrlFragment1;                   /**< first urlfragment, if NEED_URL is specified by the handler*/
+       StrBuf *UrlFragment2;                   /**< second urlfragment, if NEED_URL is specified by the handler*/
 };
 
 /** values for WC->current_iconbar */
@@ -572,9 +574,9 @@ void embed_main_menu(void);
 void serv_read(char *buf, int bytes);
 void readloop(char *oper);
 void read_message(long msgnum, int printable_view, char *section);
-void embed_message(char *msgnum_as_string);
-void print_message(char *msgnum_as_string);
-void display_headers(char *msgnum_as_string);
+void embed_message(void);
+void print_message(void);
+void display_headers(void);
 void text_to_server(char *ptr);
 void text_to_server_qp(char *ptr);
 void display_enter(void);
@@ -769,7 +771,7 @@ void list_all_rooms_by_floor(const char *viewpref);
 void display_room_directory(void);
 void display_picture(void);
 void display_pictureview(void);
-void download_file(char *);
+void download_file(void);
 void upload_file(void);
 
 void display_edit_task(void);
@@ -818,7 +820,7 @@ void commit_iconbar(void);
 int CtdlDecodeQuotedPrintable(char *decoded, char *encoded, int sourcelen);
 void spawn_another_worker_thread(void);
 void display_rss(char *roomname, char *request_method);
-void set_floordiv_expanded(char *which_floordiv);
+void set_floordiv_expanded(void);
 void offer_languages(void);
 void set_selected_language(char *);
 void go_selected_language(void);
@@ -879,10 +881,13 @@ void http_datestring(char *buf, size_t n, time_t xtime);
 typedef void (*WebcitHandlerFunc)(void);
 typedef struct  _WebcitHandler{
        WebcitHandlerFunc F;
-       int IsAjax;
+       long Flags;
 } WebcitHandler;
-void WebcitAddUrlHandler(const char * UrlString, long UrlSLen, WebcitHandlerFunc F, int IsAjax);
+void WebcitAddUrlHandler(const char * UrlString, long UrlSLen, WebcitHandlerFunc F, long Flags);
 
+#define AJAX (1<<0)
+#define ANONYMOUS (1<<1)
+#define NEED_URL (1<<2)
 
 
 /* These should be empty, but we have them for testing */
index 7ff612a6954e82d72072c2e1115322a4f045fdfd..3bb95099b351b628f1ac4e707871fc7fe0092b98 100644 (file)
@@ -13,7 +13,7 @@
 #if HAVE_BACKTRACE
 #include <execinfo.h>
 #endif
-
+#include "modules_init.h"
 #ifndef HAVE_SNPRINTF
 int vsnprintf(char *buf, size_t max, const char *fmt, va_list argp);
 #endif
@@ -663,6 +663,8 @@ void spawn_another_worker_thread()
        pthread_attr_destroy(&attr);
 }
 
+const char foobuf[32];
+const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return foobuf;}
 /*
  * \brief Here's where it all begins.
  * \param argc number of commandline args
@@ -690,7 +692,10 @@ int main(int argc, char **argv)
 #endif /* ENABLE_NLS */
        char uds_listen_path[PATH_MAX]; /*< listen on a unix domain socket? */
 
-       HandlerHash = NewHash (1, NULL);
+       HandlerHash = NewHash(1, NULL);
+       initialise_modules();
+       dbg_PrintHash(HandlerHash, nix, NULL);
+
        /* Ensure that we are linked to the correct version of libcitadel */
        if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
                fprintf(stderr, " You are running libcitadel version %d.%02d\n",
index 834eb48177259bcf13cf88a245d99f1caa1a722b..d37105c2b252c525a701980cd3d466952682e80e 100644 (file)
@@ -434,3 +434,19 @@ void wholist_section(void) {
        }
        DeleteHash(&List);
 }
+
+void _terminate_session(void) {
+       slrp_highest();
+       terminate_session();
+}
+
+void 
+InitModule_WHO
+(void)
+{
+       WebcitAddUrlHandler(HKEY("who"), who, 0);
+       WebcitAddUrlHandler(HKEY("who_inner_html"), who_inner_div, AJAX);
+       WebcitAddUrlHandler(HKEY("wholist_section"), wholist_section, AJAX);
+       WebcitAddUrlHandler(HKEY("terminate_session"), _terminate_session, 0);
+       WebcitAddUrlHandler(HKEY("edit_me"), edit_me, 0);
+}
index 6efa604710b52f815d6c313a90cc4cade5ad6152..7a9a66c9d9491b5a4422e7e4f972c3e39e9a7f70 100644 (file)
@@ -97,3 +97,11 @@ void display_wiki_page(void)
        wprintf("</td></tr></table></div>\n");
        wDumpContent(1);
 }
+
+void 
+InitModule_WIKI
+(void)
+{
+       WebcitAddUrlHandler(HKEY("wiki"), display_wiki_page, 0);
+       return ;
+}