]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_chat.c
* We now have a housekeeping thread and a housekeeping queue.
[citadel.git] / citadel / serv_chat.c
index 4511237020f75b95b5157ed7ef92e683504ba86f..9a3813f7d204e585f9be473804b202fdb2886d9b 100644 (file)
@@ -25,9 +25,6 @@
 #include "citadel.h"
 #include "server.h"
 #include <syslog.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
 #include "serv_chat.h"
 #include "sysdep_decls.h"
 #include "citserver.h"
@@ -42,15 +39,16 @@ int ChatLastMsg = 0;
 
 extern struct CitContext *ContextList;
 
+
+
 char *Dynamic_Module_Init(void)
 {
-       CtdlSendExpressMessageFunc = send_express_message;
-
        CtdlRegisterProtoHook(cmd_chat, "CHAT", "Begin real-time chat");
        CtdlRegisterProtoHook(cmd_pexp, "PEXP", "Poll for express messages");
        CtdlRegisterProtoHook(cmd_gexp, "GEXP", "Get express messages");
        CtdlRegisterProtoHook(cmd_sexp, "SEXP", "Send an express message");
        CtdlRegisterSessionHook(delete_express_messages, EVT_STOP);
+       CtdlRegisterXmsgHook(send_express_message, XMSG_PRI_LOCAL);
        return "$Id$";
 }
 
@@ -451,7 +449,6 @@ int send_express_message(char *lun, char *x_user, char *x_msg)
        struct CitContext *ccptr;
        struct ExpressMessage *newmsg, *findend;
        char *un;
-       FILE *fp;
        size_t msglen = 0;
        int do_send = 0;
 
@@ -497,21 +494,11 @@ int send_express_message(char *lun, char *x_user, char *x_msg)
        }
        end_critical_section(S_SESSION_TABLE);
 
-       /* Log the page to disk if configured to do so */
+       /* Log the page to disk if configured to do so  */
        if ((strlen(config.c_logpages) > 0) && (do_send) ) {
-               fp = fopen(CC->temp, "wb");
-               fprintf(fp, "%c%c%c", 255, MES_NORMAL, 0);
-               fprintf(fp, "Psysop%c", 0);
-               fprintf(fp, "T%ld%c", (long)time(NULL), 0);
-               fprintf(fp, "A%s%c", lun, 0);
-               fprintf(fp, "R%s%c", x_user, 0);
-               fprintf(fp, "O%s%c", config.c_logpages, 0);
-               fprintf(fp, "N%s%c", NODENAME, 0);
-               fprintf(fp, "M%s\n%c", x_msg, 0);
-               fclose(fp);
-               save_message(CC->temp, "", config.c_logpages, MES_LOCAL, 1);
-               unlink(CC->temp);
+               quickie_message(lun, x_user, config.c_logpages, x_msg);
        }
+
        return (message_sent);
 }
 
@@ -550,7 +537,7 @@ void cmd_sexp(char *argbuf)
        }
        /* This loop handles text-transfer pages */
        if (!strcmp(x_msg, "-")) {
-               message_sent = send_express_message(lun, x_user, "");
+               message_sent = PerformXmsgHooks(lun, x_user, "");
                if (message_sent == 0) {
                        cprintf("%d No user '%s' logged in.\n", ERROR, x_user);
                        return;
@@ -567,12 +554,12 @@ void cmd_sexp(char *argbuf)
                                strcat(x_big_msgbuf, "\n");
                        strcat(x_big_msgbuf, x_msg);
                }
-               send_express_message(lun, x_user, x_big_msgbuf);
+               PerformXmsgHooks(lun, x_user, x_big_msgbuf);
                phree(x_big_msgbuf);
 
                /* This loop handles inline pages */
        } else {
-               message_sent = send_express_message(lun, x_user, x_msg);
+               message_sent = PerformXmsgHooks(lun, x_user, x_msg);
 
                if (message_sent > 0) {
                        if (strlen(x_msg) > 0)