* Allow a separate default message expire policy for mailbox rooms. The
authorArt Cancro <ajc@citadel.org>
Wed, 24 Dec 2003 05:02:49 +0000 (05:02 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 24 Dec 2003 05:02:49 +0000 (05:02 +0000)
  floor default setting is now ignored for mailboxes.  Updated client and
  documentation to match.

citadel/ChangeLog
citadel/citadel.h
citadel/citadel_ipc.c
citadel/docs/citadel.html
citadel/policy.c
citadel/routines2.c
citadel/serv_vandelay.c
citadel/techdoc/session.txt

index c8ebd49ab3e268825d67d72da76b65b058b63a03..b258e8c253d5dcc8e3ff9158f23f674538c2bf84 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 613.11  2003/12/24 05:02:49  ajc
+ * Allow a separate default message expire policy for mailbox rooms.  The
+   floor default setting is now ignored for mailboxes.  Updated client and
+   documentation to match.
+
  Revision 613.10  2003/12/23 03:53:49  ajc
  * Expanded the size of all string fields in "struct CtdlIPCMessage" to
    the standard SIZ length, in order to accomodate "weird" messages
@@ -5199,4 +5204,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 52944563d598453bdf6b15a8316f2050bff72c91..3d74cec02535678fc2d40fd147fb1469699f0f02 100644 (file)
@@ -32,7 +32,7 @@ extern "C" {
 /*
  * Text description of this software
  */
-#define CITADEL        "Citadel/UX 6.13"
+#define CITADEL        "Citadel/UX 6.14"
 
 /*
  * REV_LEVEL is the current version number (multiplied by 100 to avoid having
@@ -44,9 +44,9 @@ extern "C" {
  * usually more strict because you're not really supposed to dump/load and
  * upgrade at the same time.
  */
-#define REV_LEVEL      613             /* This version */
+#define REV_LEVEL      614             /* This version */
 #define REV_MIN                591             /* Oldest compatible database */
-#define EXPORT_REV_MIN 612             /* Oldest compatible export files */
+#define EXPORT_REV_MIN 614             /* Oldest compatible export files */
 
 #define SERVER_TYPE 0  /* zero for stock Citadel/UX; other developers please
                           obtain SERVER_TYPE codes for your implementations */
@@ -129,6 +129,7 @@ struct config {
        char c_baseroom[ROOMNAMELEN];   /* Name of baseroom (Lobby)         */
        char c_aideroom[ROOMNAMELEN];   /* Name of aideroom (Aide)          */
        int c_purge_hour;               /* Hour during which db purges run  */
+       struct ExpirePolicy c_mbxep;    /* Expire policy for mailbox rooms  */
 };
 
 /*
index 03891e2d793c985274002382e645c712cbe3fe35..7f26170b9f9577365e17c023c988ba8384e81907 100644 (file)
@@ -1712,12 +1712,12 @@ int CtdlIPCAideSetUserParameters(CtdlIPC *ipc, const struct ctdluser *uret, char
 
 
 /* GPEX */
-/* which is 0 = room, 1 = floor, 2 = site */
+/* which is 0 = room, 1 = floor, 2 = site, 3 = default for mailboxes */
 /* caller must free the struct ExpirePolicy */
 int CtdlIPCGetMessageExpirationPolicy(CtdlIPC *ipc, int which,
                struct ExpirePolicy **policy, char *cret)
 {
-       static char *proto[] = {"room", "floor", "site"};
+       static char *proto[] = {"room", "floor", "site", "mailboxes" };
        char aaa[11];
        register int ret;
 
@@ -1725,7 +1725,7 @@ int CtdlIPCGetMessageExpirationPolicy(CtdlIPC *ipc, int which,
        if (!policy) return -2;
        if (!*policy) *policy = (struct ExpirePolicy *)calloc(1, sizeof(struct ExpirePolicy));
        if (!*policy) return -1;
-       if (which < 0 || which > 2) return -2;
+       if (which < 0 || which > 3) return -2;
        
        sprintf(aaa, "GPEX %s", proto[which]);
        ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
@@ -1739,16 +1739,16 @@ int CtdlIPCGetMessageExpirationPolicy(CtdlIPC *ipc, int which,
 
 
 /* SPEX */
-/* which is 0 = room, 1 = floor, 2 = site */
+/* which is 0 = room, 1 = floor, 2 = site, 3 = default for mailboxes */
 /* policy is 0 = inherit, 1 = no purge, 2 = by count, 3 = by age (days) */
 int CtdlIPCSetMessageExpirationPolicy(CtdlIPC *ipc, int which,
                struct ExpirePolicy *policy, char *cret)
 {
        char aaa[38];
-       char *whichvals[] = { "room", "floor", "site" };
+       char *whichvals[] = { "room", "floor", "site", "mailboxes" };
 
        if (!cret) return -2;
-       if (which < 0 || which > 2) return -2;
+       if (which < 0 || which > 3) return -2;
        if (!policy) return -2;
        if (policy->expire_mode < 0 || policy->expire_mode > 3) return -2;
        if (policy->expire_mode >= 2 && policy->expire_value < 1) return -2;
index 12ca500416d503d11b1f138f5c749710b304404e..cfc410408bd44deb4623d73688990dd998ff9492 100644 (file)
@@ -1605,7 +1605,12 @@ headers
 will never be altered.</p>
 <p>The final set of options configures system-wide defaults for the
 auto-purger:</p>
-<pre>Default user purge time (days) [120]: <br>Default room purge time (days) [30]: <br>System default message expire policy (? for list) [2]: <br>Keep how many messages online? [150]:<br></pre>
+<pre>Default user purge time (days) [120]: <br>
+Default room purge time (days) [30]: <br>
+System default message expire policy (? for list) [2]: <br>
+Keep how many messages online? [150]:<br>
+Mailbox default message expire policy (? for list) [1]: <br>
+</pre>
 <p>Any user who does not log in for the period specified in 'Default
 user purge time' will be deleted the next time a purge is run. This
 setting may be modified on a per-user basis.</p>
@@ -1619,7 +1624,11 @@ messages are expired (purged) off the system. You can specify any of:</p>
   <li>Do not purge at all </li>
 </ul>
 <p>Again, this setting may be overridden on a per-floor basis, and the
-floor setting may be overridden on a per-room basis.</p>
+floor setting may be overridden on a per-room basis.  You'll also notice
+that you can set a <i>different</i> default for mailbox rooms if you want
+to.  This can allow you, for example, to set a policy under which old
+messages scroll out of public rooms, but private mail stays online indefinitely
+until deleted by the mailbox owners.</p>
 <pre>Save this configuration? No<br></pre>
 <p>When you're done, enter 'Yes' to confirm the changes, or 'No' to
 discard the changes.</p>
index 621e7a72ad662a5469c31e86e1973209a153cdda..7ad326c3c274bf8812a9680156a66818102e238e 100644 (file)
@@ -53,11 +53,26 @@ void GetExpirePolicy(struct ExpirePolicy *epbuf, struct ctdlroom *qrbuf) {
                return;
        }
 
-       /* Otherwise, if the floor has its own policy, return it */
-       fl = cgetfloor(qrbuf->QRfloor);
-       if (fl->f_ep.expire_mode != 0) {
-               memcpy(epbuf, &fl->f_ep, sizeof(struct ExpirePolicy));
-               return;
+       /* (non-mailbox rooms)
+        * If the floor has its own policy, return it
+        */
+       if ( (qrbuf->QRflags & QR_MAILBOX) == 0) {
+               fl = cgetfloor(qrbuf->QRfloor);
+               if (fl->f_ep.expire_mode != 0) {
+                       memcpy(epbuf, &fl->f_ep, sizeof(struct ExpirePolicy));
+                       return;
+               }
+       }
+
+       /* (Mailbox rooms)
+        * If there is a default policy for mailbox rooms, return it
+        */
+       if (qrbuf->QRflags & QR_MAILBOX) {
+               if (&config.c_mbxep.expire_mode != 0) {
+                       memcpy(epbuf, &config.c_mbxep,
+                               sizeof(struct ExpirePolicy));
+                       return;
+               }
        }
 
        /* Otherwise, fall back on the system default */
@@ -81,6 +96,9 @@ void cmd_gpex(char *argbuf) {
                fl = cgetfloor(CC->room.QRfloor);
                memcpy(&exp, &fl->f_ep, sizeof(struct ExpirePolicy));
        }
+       else if (!strcasecmp(which, "mailboxes")) {
+               memcpy(&exp, &config.c_mbxep, sizeof(struct ExpirePolicy));
+       }
        else if (!strcasecmp(which, "site")) {
                memcpy(&exp, &config.c_ep, sizeof(struct ExpirePolicy));
        }
@@ -138,6 +156,14 @@ void cmd_spex(char *argbuf) {
                return;
        }
 
+       else if (!strcasecmp(which, "mailboxes")) {
+               memcpy(&config.c_mbxep, &exp, sizeof(struct ExpirePolicy));
+               put_config();
+               cprintf("%d Default expire policy for mailboxes set.\n",
+                       CIT_OK);
+               return;
+       }
+
        else if (!strcasecmp(which, "site")) {
                if (exp.expire_mode == EXPIRE_NEXTLEVEL) {
                        cprintf("%d Invalid policy (no higher level)\n",
index efc81a6e202df26cb03c060f18c97b084c33d215..c3d4269f9cfb316d7c6de287c7c6297275a95f6f 100644 (file)
@@ -645,7 +645,8 @@ void do_system_configuration(CtdlIPC *ipc)
        char buf[SIZ];
        char sc[32][SIZ];
        char *resp = NULL;
-       struct ExpirePolicy *expirepolicy = NULL;
+       struct ExpirePolicy *site_expirepolicy = NULL;
+       struct ExpirePolicy *mbx_expirepolicy = NULL;
        int a;
        int logpages = 0;
        int r;                  /* IPC response code */
@@ -671,7 +672,8 @@ void do_system_configuration(CtdlIPC *ipc)
        /* Fetch the expire policy (this will silently fail on old servers,
         * resulting in "default" policy)
         */
-       r = CtdlIPCGetMessageExpirationPolicy(ipc, 2, &expirepolicy, buf);
+       r = CtdlIPCGetMessageExpirationPolicy(ipc, 2, &site_expirepolicy, buf);
+       r = CtdlIPCGetMessageExpirationPolicy(ipc, 3, &mbx_expirepolicy, buf);
 
        /* Identification parameters */
 
@@ -751,7 +753,7 @@ void do_system_configuration(CtdlIPC *ipc)
 
        /* Angels and demons dancing in my head... */
        do {
-               snprintf(buf, sizeof buf, "%d", expirepolicy->expire_mode);
+               snprintf(buf, sizeof buf, "%d", site_expirepolicy->expire_mode);
                strprompt("System default message expire policy (? for list)",
                          buf, 1);
                if (buf[0] == '?') {
@@ -761,18 +763,45 @@ void do_system_configuration(CtdlIPC *ipc)
                                "3. Expire by message age\n");
                }
        } while ((buf[0] < '1') || (buf[0] > '3'));
-       expirepolicy->expire_mode = buf[0] - '0';
+       site_expirepolicy->expire_mode = buf[0] - '0';
 
        /* ...lunatics and monsters underneath my bed */
-       if (expirepolicy->expire_mode == 2) {
-               snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
+       if (site_expirepolicy->expire_mode == 2) {
+               snprintf(buf, sizeof buf, "%d", site_expirepolicy->expire_value);
                strprompt("Keep how many messages online?", buf, 10);
-               expirepolicy->expire_value = atol(buf);
+               site_expirepolicy->expire_value = atol(buf);
        }
-       if (expirepolicy->expire_mode == 3) {
-               snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
+       if (site_expirepolicy->expire_mode == 3) {
+               snprintf(buf, sizeof buf, "%d", site_expirepolicy->expire_value);
                strprompt("Keep messages for how many days?", buf, 10);
-               expirepolicy->expire_value = atol(buf);
+               site_expirepolicy->expire_value = atol(buf);
+       }
+
+       /* Media messiahs preying on my fears... */
+       do {
+               snprintf(buf, sizeof buf, "%d", mbx_expirepolicy->expire_mode);
+               strprompt("Mailbox default message expire policy (? for list)",
+                         buf, 1);
+               if (buf[0] == '?') {
+                       scr_printf("\n"
+                               "0. Go with the system default\n"
+                               "1. Never automatically expire messages\n"
+                               "2. Expire by message count\n"
+                               "3. Expire by message age\n");
+               }
+       } while ((buf[0] < '0') || (buf[0] > '3'));
+       mbx_expirepolicy->expire_mode = buf[0] - '0';
+
+       /* ...Pop culture prophets playing in my ears */
+       if (mbx_expirepolicy->expire_mode == 2) {
+               snprintf(buf, sizeof buf, "%d", mbx_expirepolicy->expire_value);
+               strprompt("Keep how many messages online?", buf, 10);
+               mbx_expirepolicy->expire_value = atol(buf);
+       }
+       if (mbx_expirepolicy->expire_mode == 3) {
+               snprintf(buf, sizeof buf, "%d", mbx_expirepolicy->expire_value);
+               strprompt("Keep messages for how many days?", buf, 10);
+               mbx_expirepolicy->expire_value = atol(buf);
        }
 
        strprompt("How often to run network jobs (in seconds)", &sc[28][0], 5);
@@ -798,10 +827,17 @@ void do_system_configuration(CtdlIPC *ipc)
                        err_printf("%s\n", buf);
                }
                free(resp);
-               r = CtdlIPCSetMessageExpirationPolicy(ipc, 2, expirepolicy, buf);
+
+               r = CtdlIPCSetMessageExpirationPolicy(ipc, 2, site_expirepolicy, buf);
                if (r / 100 != 2) {
                        err_printf("%s\n", buf);
                }
+
+               r = CtdlIPCSetMessageExpirationPolicy(ipc, 3, mbx_expirepolicy, buf);
+               if (r / 100 != 2) {
+                       err_printf("%s\n", buf);
+               }
+
        }
 }
 
index 5167d67924a015cd0d7a630f47fcf71164328a23..83153502934169a6625a16aa728d60bad00a75ad 100644 (file)
@@ -283,6 +283,8 @@ void artv_do_export(void) {
        cprintf("%d\n", config.c_pop3_port);
        cprintf("%d\n", config.c_smtp_port);
        cprintf("%d\n", config.c_purge_hour);
+       cprintf("%d\n", config.c_mbxep.expire_mode);
+       cprintf("%d\n", config.c_mbxep.expire_value);
 
        /* Export the control file */
        get_control();
@@ -340,6 +342,8 @@ void artv_import_config(void) {
        client_gets(buf);       config.c_pop3_port = atoi(buf);
        client_gets(buf);       config.c_smtp_port = atoi(buf);
        client_gets(buf);       config.c_purge_hour = atoi(buf);
+       client_gets(buf);       config.c_mbxep.expire_mode = atoi(buf);
+       client_gets(buf);       config.c_mbxep.expire_value = atoi(buf);
        put_config();
        lprintf(7, "Imported config file\n");
 }
index 8722b3ec4a8245e86514a977f285cfc5ef1f6345..69942b0a827dba987ecca76059bc560aad42c488 100644 (file)
@@ -1690,7 +1690,7 @@ purging (expiration) of messages.  The following policies are available:
    3  -  Purge by message age.  (Requires a value: number of days)
 
  The format of this command is:  GPEX <which>
- The value of <which> must be one of: "room" "floor" "site"
+ The value of <which> must be one of: "room" "floor" "site" "mailboxes"
 
  If successful, GPEX returns OK followed by <policy>|<value>.
 
@@ -1703,7 +1703,7 @@ purging (expiration) of messages.  See the writeup for the GPEX command for
 the list of available policies.
 
  The format of this command is:  SPEX <which>|<policy>|<value>
- The value of <which> must be one of: "room" "floor" "site"
+ The value of <which> must be one of: "room" "floor" "site" "mailboxes"
 
  If successful, GPEX returns OK; otherwise, an ERROR code is returned.