From 8d7c7778956ac166c76320272017ba0f25b735c2 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 24 Dec 2003 05:02:49 +0000 Subject: [PATCH] * 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. --- citadel/ChangeLog | 6 +++- citadel/citadel.h | 7 +++-- citadel/citadel_ipc.c | 12 ++++---- citadel/docs/citadel.html | 13 +++++++-- citadel/policy.c | 36 +++++++++++++++++++---- citadel/routines2.c | 58 ++++++++++++++++++++++++++++++------- citadel/serv_vandelay.c | 4 +++ citadel/techdoc/session.txt | 4 +-- 8 files changed, 110 insertions(+), 30 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index c8ebd49ab..b258e8c25 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -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 Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citadel.h b/citadel/citadel.h index 52944563d..3d74cec02 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -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 */ }; /* diff --git a/citadel/citadel_ipc.c b/citadel/citadel_ipc.c index 03891e2d7..7f26170b9 100644 --- a/citadel/citadel_ipc.c +++ b/citadel/citadel_ipc.c @@ -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; diff --git a/citadel/docs/citadel.html b/citadel/docs/citadel.html index 12ca50041..cfc410408 100644 --- a/citadel/docs/citadel.html +++ b/citadel/docs/citadel.html @@ -1605,7 +1605,12 @@ headers will never be altered.

The final set of options configures system-wide defaults for the auto-purger:

-
Default user purge time (days) [120]: 
Default room purge time (days) [30]:
System default message expire policy (? for list) [2]:
Keep how many messages online? [150]:
+
Default user purge time (days) [120]: 
+Default room purge time (days) [30]:
+System default message expire policy (? for list) [2]:
+Keep how many messages online? [150]:
+Mailbox default message expire policy (? for list) [1]:
+

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.

@@ -1619,7 +1624,11 @@ messages are expired (purged) off the system. You can specify any of:

  • Do not purge at all
  • Again, this setting may be overridden on a per-floor basis, and the -floor setting may be overridden on a per-room basis.

    +floor setting may be overridden on a per-room basis. You'll also notice +that you can set a different 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.

    Save this configuration? No

    When you're done, enter 'Yes' to confirm the changes, or 'No' to discard the changes.

    diff --git a/citadel/policy.c b/citadel/policy.c index 621e7a72a..7ad326c3c 100644 --- a/citadel/policy.c +++ b/citadel/policy.c @@ -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", diff --git a/citadel/routines2.c b/citadel/routines2.c index efc81a6e2..c3d4269f9 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -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); + } + } } diff --git a/citadel/serv_vandelay.c b/citadel/serv_vandelay.c index 5167d6792..831535029 100644 --- a/citadel/serv_vandelay.c +++ b/citadel/serv_vandelay.c @@ -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"); } diff --git a/citadel/techdoc/session.txt b/citadel/techdoc/session.txt index 8722b3ec4..69942b0a8 100644 --- a/citadel/techdoc/session.txt +++ b/citadel/techdoc/session.txt @@ -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 - The value of must be one of: "room" "floor" "site" + The value of must be one of: "room" "floor" "site" "mailboxes" If successful, GPEX returns OK followed by |. @@ -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 || - The value of must be one of: "room" "floor" "site" + The value of must be one of: "room" "floor" "site" "mailboxes" If successful, GPEX returns OK; otherwise, an ERROR code is returned. -- 2.39.2