]> code.citadel.org Git - citadel.git/commitdiff
* Added [idle] to client wholist display for sessions idle >15 minutes
authorArt Cancro <ajc@citadel.org>
Sat, 5 Aug 2000 04:24:13 +0000 (04:24 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 5 Aug 2000 04:24:13 +0000 (04:24 +0000)
* Added a generic "void *userdata" field to CtdlForEachMessage()
* More prep for mailing list handling in the server

14 files changed:
citadel/ChangeLog
citadel/citadel.c
citadel/msgbase.c
citadel/msgbase.h
citadel/serv_expire.c
citadel/serv_inetcfg.c
citadel/serv_moderate.c
citadel/serv_network.c
citadel/serv_network.h
citadel/serv_pop3.c
citadel/serv_smtp.c
citadel/serv_vandelay.c
citadel/serv_vcard.c
citadel/techdoc/netconfigs.txt

index 8a9823efa607e7a617bc39369de02a3a8d2e5724..e40f735896546bcb61591f21594fc1db7aa81a2c 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 572.22  2000/08/05 04:24:00  ajc
+ * Added [idle] to client wholist display for sessions idle >15 minutes
+ * Added a generic "void *userdata" field to CtdlForEachMessage()
+ * More prep for mailing list handling in the server
+
  Revision 572.21  2000/07/30 04:36:12  ajc
  * Set up the SNET (Send NETwork config) and GNET (Get NETwork config) commands
    for the network overhaul.
@@ -1972,3 +1977,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
+
index e638835bdf8e953e6ac4f44fa263a66dc3be12cf..79589cb566be8ffd34504bd82426d7a5f771a42d 100644 (file)
@@ -736,15 +736,16 @@ void who_is_online(int longlist)
        time_t idletime, idlehours, idlemins, idlesecs;
        int last_session = (-1);
 
-       if (longlist) {
-               serv_puts("TIME");
-               serv_gets(tbuf);
-               if (tbuf[0] == '2') {
-                       timenow = extract_long(&tbuf[4], 0);
-               } else {
-                       time(&timenow);
-               }
-       } else {
+       serv_puts("TIME");
+       serv_gets(tbuf);
+       if (tbuf[0] == '2') {
+               timenow = extract_long(&tbuf[4], 0);
+       }
+       else {
+               time(&timenow);
+       }
+
+       if (!longlist) {
                color(BRIGHT_WHITE);
                pprintf("FLG ###        User Name                 Room                 From host\n");
                color(DIM_WHITE);
@@ -760,16 +761,24 @@ void who_is_online(int longlist)
                        extract(clientsoft, buf, 4);
                        extract(flags, buf, 7);
 
+                       idletime = timenow - extract_long(buf, 5);
+                       idlehours = idletime / 3600;
+                       idlemins = (idletime - (idlehours * 3600)) / 60;
+                       idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
+
+                       if (idletime > 900) {
+                               while (strlen(roomname) < 20) {
+                                       strcat(roomname, " ");
+                               }
+                               strcpy(&roomname[14], "[idle]");
+                       }
+
                        if (longlist) {
 
                                extract(actual_user, buf, 8);
                                extract(actual_room, buf, 9);
                                extract(actual_host, buf, 10);
 
-                               idletime = timenow - extract_long(buf, 5);
-                               idlehours = idletime / 3600;
-                               idlemins = (idletime - (idlehours * 3600)) / 60;
-                               idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60));
                                pprintf("\nFlags: %-3s  Sess# %-3d  Name: %-25s  Room: %s\n",
                                       flags, extract_int(buf, 0), username, roomname);
                                pprintf("from <%s> using <%s>, idle %ld:%02ld:%02ld\n",
index 086ca77e63b2aeaaf4d4fd49757677e714b630d6..d5cae708470e5727971a7ede9f73c32dc73c3ff1 100644 (file)
@@ -240,7 +240,7 @@ void get_mm(void)
 
 
 
-void simple_listing(long msgnum)
+void simple_listing(long msgnum, void *userdata)
 {
        cprintf("%ld\n", msgnum);
 }
@@ -286,7 +286,8 @@ int CtdlForEachMessage(int mode, long ref,
                        int moderation_level,
                        char *content_type,
                        struct CtdlMessage *compare,
-                       void (*CallBack) (long msgnum))
+                       void (*CallBack) (long, void *),
+                       void *userdata)
 {
 
        int a;
@@ -377,7 +378,7 @@ int CtdlForEachMessage(int mode, long ref,
                                || ((mode == MSGS_EQ) && (thismsg == ref))
                            )
                            ) {
-                               if (CallBack) CallBack(thismsg);
+                               if (CallBack) CallBack(thismsg, userdata);
                                ++num_processed;
                        }
                }
@@ -448,7 +449,7 @@ void cmd_msgs(char *cmdbuf)
 
        CtdlForEachMessage(mode, cm_ref,
                CC->usersupp.moderation_filter,
-               NULL, template, simple_listing);
+               NULL, template, simple_listing, NULL);
        if (template != NULL) CtdlFreeMessage(template);
        cprintf("000\n");
 }
@@ -1442,7 +1443,7 @@ void serialize_message(struct ser_ret *ret,               /* return values */
 /*
  * Back end for the ReplicationChecks() function
  */
-void check_repl(long msgnum) {
+void check_repl(long msgnum, void *userdata) {
        struct CtdlMessage *msg;
        time_t timestamp = (-1L);
 
@@ -1492,7 +1493,8 @@ int ReplicationChecks(struct CtdlMessage *msg) {
        memset(template, 0, sizeof(struct CtdlMessage));
        template->cm_fields['E'] = strdoop(msg->cm_fields['E']);
 
-       CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, template, check_repl);
+       CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, template,
+               check_repl, NULL);
 
        /* If a newer message exists with the same Extended ID, abort
         * this save.
@@ -2545,7 +2547,7 @@ void CtdlWriteObject(char *req_room,              /* Room to stuff it in */
 
 
 
-void CtdlGetSysConfigBackend(long msgnum) {
+void CtdlGetSysConfigBackend(long msgnum, void *userdata) {
        config_msgnum = msgnum;
 }
 
@@ -2568,7 +2570,7 @@ char *CtdlGetSysConfig(char *sysconfname) {
        begin_critical_section(S_CONFIG);
        config_msgnum = (-1L);
        CtdlForEachMessage(MSGS_LAST, 1, (-127), sysconfname, NULL,
-               CtdlGetSysConfigBackend);
+               CtdlGetSysConfigBackend, NULL);
        msgnum = config_msgnum;
        end_critical_section(S_CONFIG);
 
index 8daaaec721adfb8dcd349d9bbdf6441f5c93d621..a0a17eb278b7b6861ce2f11a34ecd251cd876214 100644 (file)
@@ -69,13 +69,14 @@ void cmd_move (char *args);
 void GetSuppMsgInfo(struct SuppMsgInfo *, long);
 void PutSuppMsgInfo(struct SuppMsgInfo *);
 void AdjRefCount(long, int);
-void simple_listing(long);
+void simple_listing(long, void *);
 int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template);
 int CtdlForEachMessage(int mode, long ref,
                        int moderation_level,
                        char *content_type,
                        struct CtdlMessage *compare,
-                        void (*CallBack) (long msgnum) );
+                        void (*CallBack) (long, void *),
+                       void *userdata);
 int CtdlDeleteMessages(char *, long, char *);
 void CtdlWriteObject(char *, char *, char *, struct usersupp *,
                        int, int, unsigned int);
index 1918ce958306350ff9cfdc927c508d714c76a550..6cf08d77c9794456eb888784afd92adebe1014c3 100644 (file)
@@ -533,7 +533,7 @@ void cmd_expi(char *argbuf) {
 /*****************************************************************************/
 
 
-void do_fsck_msg(long msgnum) {
+void do_fsck_msg(long msgnum, void *userdata) {
        struct roomref *ptr;
 
        ptr = (struct roomref *)mallok(sizeof(struct roomref));
@@ -545,7 +545,8 @@ void do_fsck_msg(long msgnum) {
 void do_fsck_room(struct quickroom *qrbuf, void *data)
 {
        getroom(&CC->quickroom, qrbuf->QRname);
-       CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, NULL, do_fsck_msg);
+       CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, NULL,
+               do_fsck_msg, NULL);
 }
 
 /*
index 101bad90e9d38fedea154fa0eb3cd282c547edd1..bedcd965d01e320a2bb90fe489be08bb822c86cd 100644 (file)
@@ -94,7 +94,7 @@ int inetcfg_aftersave(struct CtdlMessage *msg) {
 }
 
 
-void inetcfg_init_backend(long msgnum) {
+void inetcfg_init_backend(long msgnum, void *userdata) {
        struct CtdlMessage *msg;
 
                msg = CtdlFetchMessage(msgnum);
@@ -108,7 +108,7 @@ void inetcfg_init_backend(long msgnum) {
 void inetcfg_init(void) {
        if (getroom(&CC->quickroom, SYSCONFIGROOM) != 0) return;
        CtdlForEachMessage(MSGS_LAST, 1, (-127), INTERNETCFG, NULL,
-               inetcfg_init_backend);
+               inetcfg_init_backend, NULL);
 }
 
 
index 77c210798515592c71d53ea3c267487fd56bb100..867584a0683e22c9e0daaa36fab9ef977aacd2ac 100644 (file)
@@ -58,7 +58,7 @@ void cmd_mmod(char *argbuf) {
        }
 
        is_message_in_room = CtdlForEachMessage(MSGS_EQ, msgnum, (-127),
-                               NULL, NULL, NULL);
+                               NULL, NULL, NULL, NULL);
        if (!is_message_in_room) {
                cprintf("%d Message %ld is not in this room.\n",
                        ERROR+ILLEGAL_VALUE, msgnum);
index 8ed03aa6ffdeec14fdb04ff0fbe5cbc9fb2d052f..87bc6f1a318334dea469c4494e74cce66a990af7 100644 (file)
@@ -7,6 +7,14 @@
  *
  */
 
+
+/* FIXME
+
+there's stuff in here that makes the assumption that /tmp is on the same
+filesystem as Citadel, and makes calls to link() on that basis.  fix this.
+
+*/
+
 #include "sysdep.h"
 #include <stdlib.h>
 #include <unistd.h>
@@ -93,9 +101,109 @@ void cmd_snet(char *argbuf) {
 }
 
 
+
+
+/*
+ * Batch up and send all outbound traffic from the current room
+ */
+void network_spoolout_current_room(void) {
+       char filename[256];
+       char buf[256];
+       char instr[256];
+       FILE *fp;
+       long lastsent = 0L;
+       struct namelist *listrecps = NULL;
+       /* struct namelist *digestrecps = NULL; */
+       struct namelist *nptr;
+
+       assoc_file_name(filename, &CC->quickroom, "netconfigs");
+
+       fp = fopen(filename, "r");
+       if (fp == NULL) {
+               lprintf(7, "Outbound batch processing skipped for <%s>\n",
+                       CC->quickroom.QRname);
+               return;
+       }
+
+       lprintf(5, "Outbound batch processing started for <%s>\n",
+               CC->quickroom.QRname);
+
+       while (fgets(buf, sizeof buf, fp) != NULL) {
+               buf[strlen(buf)-1] = 0;
+
+               extract(instr, buf, 0);
+               if (!strcasecmp(instr, "lastsent")) {
+                       lastsent = extract_long(buf, 1);
+               }
+               else if (!strcasecmp(instr, "listrecp")) {
+                       nptr = (struct namelist *)
+                               mallok(sizeof(struct namelist));
+                       nptr->next = listrecps;
+                       extract(nptr->name, buf, 1);
+                       listrecps = nptr;
+               }
+
+
+       }
+       fclose(fp);
+
+
+       /* Do something useful */
+
+
+
+
+
+
+
+       /* Now rewrite the config file */
+       fp = fopen(filename, "w");
+       if (fp == NULL) {
+               lprintf(1, "ERROR: cannot open %s: %s\n",
+                       filename, strerror(errno));
+       }
+       else {
+               fprintf(fp, "lastsent|%ld\n", lastsent);
+
+               /* Write out the listrecps while freeing from memory at the
+                * same time.  Am I clever or what?  :)
+                */
+               while (listrecps != NULL) {
+                       fprintf(fp, "listrecp|%s\n", listrecps->name);
+                       nptr = listrecps->next;
+                       phree(listrecps);
+                       listrecps = nptr;
+               }
+
+               fclose(fp);
+       }
+
+       lprintf(5, "Outbound batch processing finished for <%s>\n",
+               CC->quickroom.QRname);
+}
+
+
+
+/* FIXME temporary server command for batch send */
+void cmd_batc(char *argbuf) {
+       if (CtdlAccessCheck(ac_aide)) return;
+
+       network_spoolout_current_room();
+
+       cprintf("%d ok\n", OK);
+}
+
+
+
 char *Dynamic_Module_Init(void)
 {
        CtdlRegisterProtoHook(cmd_gnet, "GNET", "Get network config");
        CtdlRegisterProtoHook(cmd_snet, "SNET", "Get network config");
+
+       /* FIXME
+          temporary server command for batch send
+        */
+       CtdlRegisterProtoHook(cmd_batc, "BATC", "send out batch (temp)");
+
        return "$Id$";
 }
index b28b04f643122b019e912540f228c8ed20be9eeb..699e39b50ffa36b765941713aadaad63b9679269 100644 (file)
@@ -1,3 +1,6 @@
 
-
+struct namelist {
+       struct namelist *next;
+       char name[256];
+};
 
index 2d88dbba35c1bafaa714f1d2ef786da709b77cdf..2827c7cdef883ca2088a29ab828e67964859ae43 100644 (file)
@@ -120,7 +120,7 @@ void pop3_user(char *argbuf) {
 /*
  * Back end for pop3_grab_mailbox()
  */
-void pop3_add_message(long msgnum) {
+void pop3_add_message(long msgnum, void *userdata) {
        FILE *fp;
        lprintf(9, "in pop3_add_message()\n");
 
@@ -154,7 +154,8 @@ int pop3_grab_mailbox(void) {
        if (getroom(&CC->quickroom, MAILROOM) != 0) return(-1);
 
        /* Load up the messages */
-       CtdlForEachMessage(MSGS_ALL, 0L, (-63), NULL, NULL, pop3_add_message);
+       CtdlForEachMessage(MSGS_ALL, 0L, (-63), NULL, NULL,
+               pop3_add_message, NULL);
 
        /* Figure out which are old and which are new */
         CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
index 5d0cd08845bfd31ba030a5c0ea479b8c9d7e418d..4c557a94b3c24a61ec073e225ab127ff40127e63 100644 (file)
@@ -1256,7 +1256,7 @@ int smtp_purge_completed_deliveries(char *instr) {
  *
  * Called by smtp_do_queue() to handle an individual message.
  */
-void smtp_do_procmsg(long msgnum) {
+void smtp_do_procmsg(long msgnum, void *userdata) {
        struct CtdlMessage *msg;
        char *instr = NULL;
        char *results = NULL;
@@ -1447,7 +1447,7 @@ void smtp_do_queue(void) {
                return;
        }
        CtdlForEachMessage(MSGS_ALL, 0L, (-127),
-               SPOOLMIME, NULL, smtp_do_procmsg);
+               SPOOLMIME, NULL, smtp_do_procmsg, NULL);
 
        lprintf(7, "SMTP: queue run completed\n");
        doing_queue = 0;
index 7c5dac0d2795dc0d2490a3f36a92df546c49a0c0..29ee4ecd3e55cee467283835e0d3f522befe30dc 100644 (file)
@@ -63,7 +63,7 @@ void artv_export_users(void) {
 }
 
 
-void artv_export_room_msg(long msgnum) {
+void artv_export_room_msg(long msgnum, void *userdata) {
        cprintf("%ld\n", msgnum);
        fprintf(artv_global_message_list, "%ld\n", msgnum);
 }
@@ -91,7 +91,7 @@ void artv_export_rooms_backend(struct quickroom *qrbuf, void *data) {
         * one per line terminated by a 0.
         */
        CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, NULL,
-               artv_export_room_msg);
+               artv_export_room_msg, NULL);
        cprintf("0\n");
 
 }
index 4540de4d512472eddf4b99f46f83b18b8f166e54..e7a8e61bd4bbe91eec08528f20e3a8c6d0a258c5 100644 (file)
@@ -188,7 +188,7 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) {
 /*
  * back end function used for callbacks
  */
-void vcard_gu_backend(long msgnum) {
+void vcard_gu_backend(long msgnum, void *userdata) {
        VC->msgnum = msgnum;
 }
 
@@ -214,7 +214,7 @@ struct vCard *vcard_get_user(struct usersupp *u) {
         /* We want the last (and probably only) vcard in this room */
        VC->msgnum = (-1);
         CtdlForEachMessage(MSGS_LAST, 1, (-127), "text/x-vcard",
-               NULL, vcard_gu_backend);
+               NULL, vcard_gu_backend, NULL);
         getroom(&CC->quickroom, hold_rm);      /* return to saved room */
 
        if (VC->msgnum < 0L) return vcard_new();
index ba7c19866f6e92f18df0838e67d90bea69fdcd74..16a5613b99a133e633c7d01c98a75427878d6764 100644 (file)
@@ -20,6 +20,8 @@ we have performed outbound network processing on.  Any batch job which sends
 out messages should do stuff.
  
  
- INSTRUCTION:  foo
- SYNTAX:       lastsent|0000000
+ INSTRUCTION:  listrecp
+ SYNTAX:       listrecp|friko@mumjiboolean.com
  DESCRIPTION:
+    Defines a recipient to whom all messages in this room should be sent.  This
+is used for "list serve" applications.