From 744c57519f693b69cd2f5b602f26ba209bdf53ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sun, 22 Jul 2007 10:46:47 +0000 Subject: [PATCH] davew: clean ups, addition to documentation of API and addition of an event to clean the libsieve connection to housekeeping.c --- citadel/housekeeping.c | 5 ++--- citadel/msgbase.c | 14 -------------- citadel/serv_sieve.c | 2 ++ citadel/server.h | 2 +- citadel/techdoc/citadelapi.txt | 35 +++++++++++++++++++++++++++++++++- 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/citadel/housekeeping.c b/citadel/housekeeping.c index 365eeede3..99f0d792f 100644 --- a/citadel/housekeeping.c +++ b/citadel/housekeeping.c @@ -170,9 +170,8 @@ void do_housekeeping(void) { /* First, do the "as often as needed" stuff... */ JournalRunQueue(); -#ifdef HAVE_LIBSIEVE - perform_sieve_processing(); -#endif + + PerformSessionHooks(EVT_HOUSE); /* perform as needed housekeeping */ /* Then, do the "once per minute" stuff... */ if (do_perminute_housekeeping_now) { diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 9e092a47b..e1f88781d 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -2143,23 +2143,9 @@ int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newms lprintf(CTDL_DEBUG, "CtdlSaveMsgPointerInRoom() skips repl checks\n"); } -#if 0 - /* Submit this room for net processing */ - network_queue_room(&CC->room, NULL); -#endif - /* Submit this room for processing by hooks */ PerformRoomHooks(&CC->room); -#if 0 -#ifdef HAVE_LIBSIEVE - /* If this is someone's inbox, submit the room for sieve processing */ - if (!strcasecmp(&CC->room.QRname[11], MAILROOM)) { - sieve_queue_room(&CC->room); - } -#endif /* HAVE_LIBSIEVE */ -#endif - /* Go back to the room we were in before we wandered here... */ getroom(&CC->room, hold_rm); diff --git a/citadel/serv_sieve.c b/citadel/serv_sieve.c index f20c49a17..525bafb2d 100644 --- a/citadel/serv_sieve.c +++ b/citadel/serv_sieve.c @@ -1255,6 +1255,8 @@ char *serv_sieve_init(void) CtdlRegisterRoomHook(serv_sieve_room); + CtdlRegisterSessionHook(perform_sieve_processing, EVT_HOUSE); + /* return our Subversion id for the Log */ return "$Id$"; } diff --git a/citadel/server.h b/citadel/server.h index 96949ed15..c455cff53 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -346,7 +346,7 @@ extern struct SessionFunctionHook *SessionHookTable; #define EVT_TIMER 50 /* Timer events are called once per minute and are not tied to any session */ - +#define EVT_HOUSE 51 /* as needed houskeeping stuff */ /* * UserFunctionHook extensions are used for any type of hook which implements * an operation on a user or username (potentially) other than the one diff --git a/citadel/techdoc/citadelapi.txt b/citadel/techdoc/citadelapi.txt index 00dfa1b46..ef9e3e62b 100644 --- a/citadel/techdoc/citadelapi.txt +++ b/citadel/techdoc/citadelapi.txt @@ -165,7 +165,40 @@ registered. void CtdlUnregisterMessageHook(int (*handler) (struct CtdlMessage *), int EventType) - Please write documentation for me! + + CtdlRegisterMessageHook() registers a function with the message +handling subsystem. This function will be called with one parameter, +a pointer to a CtdlMessage structure, when the message triggers an event +of type EventType. The registered function should return non zero if it +has handled the event to prevent other hook functions from also processing +the event. + + CtdlUnregisterMessageHook() removes a function from the list of registered +message handlers. To successfully remove a function registered with +CtdlRegisterMessageHook() CtdlUnregisterMessageHook() must be called with +the same parameters. + + Possible values for EventType are: + EVT_BEFOREREAD Called after a message is loaded from disk but before +it is presented for reading. + EVT_BEFORESAVE Called before the message is saved to disk. returning +non zero for this event will prevent the message being saved to disk in the +normal manner. + EVT_AFTERSAVE Called after the message is saved to disk but before +any IGnet spooling is carried out. + EVT_SMTPSCAN Called during the SMTP reception of a message after the +message is received and before the response is sent to the sender. This is +intended for spam filters and virus checkers. A positive return code will +cause the message to be rejected by the SMTP server. + + + void CtdlRegisterRoomHook(int (*fcn_ptr) (char *)) + void CtdlUnregisterRoomHook(int (*fcn_ptr) (char *)) + + Register or remove a function with the room processing system. +Registered functions are called in the order they are registered when a message +is added to a room. This allows modules such as Sieve to process new messages +appearing in a room. void CtdlRegisterXmsgHook(int (*fcn_ptr) (char *, char *, char *), int order) -- 2.30.2