davew: clean ups, addition to documentation of API and addition of an event to clean...
authorWilfried Göesgens <willi@citadel.org>
Sun, 22 Jul 2007 10:46:47 +0000 (10:46 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 22 Jul 2007 10:46:47 +0000 (10:46 +0000)
citadel/housekeeping.c
citadel/msgbase.c
citadel/serv_sieve.c
citadel/server.h
citadel/techdoc/citadelapi.txt

index 365eeede3f306119ffa591badfc4cfb1272c04fa..99f0d792fa764e6ba488d1b003aa33885b127b75 100644 (file)
@@ -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) {
index 9e092a47b3177fbf258b381e7d8d75959527463e..e1f88781de7029513201aed871e1ac7281710ecb 100644 (file)
@@ -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);
 
index f20c49a17fbd4f6ec17e1d369a01839329ad6964..525bafb2da3e0d05f789f525e0780f924a277cad 100644 (file)
@@ -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$";
 }
index 96949ed154266375faeab30a5a7d673df70a786e..c455cff538c8f72f21b03baf53bb0add7296d0ce 100644 (file)
@@ -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
index 00dfa1b46398940e977bd8135669fab65d12bdc0..ef9e3e62b2d00c503b35dbd848e9d8685a9aea88 100644 (file)
@@ -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)