X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fpolicy.c;h=804416e71df443932841ac0627b12041445c7ff9;hb=01cc19a4c2da27b4db0e980ccd3ca54d834319c8;hp=2ed72622f2fe6e065ef2f67f70a1de78083372d4;hpb=95340caeddca31acdfd6f966325833b8368c4556;p=citadel.git diff --git a/citadel/policy.c b/citadel/policy.c index 2ed72622f..804416e71 100644 --- a/citadel/policy.c +++ b/citadel/policy.c @@ -4,10 +4,6 @@ * Functions which manage policy for rooms (such as message expiry) */ -#ifdef DLL_EXPORT -#define IN_LIBCIT -#endif - #include "sysdep.h" #include #include @@ -30,7 +26,6 @@ #include "citadel.h" #include "server.h" #include "database.h" -#include "serv_extensions.h" #include "config.h" #include "room_ops.h" #include "sysdep_decls.h" @@ -44,7 +39,7 @@ /* * Retrieve the applicable expire policy for a specific room */ -void GetExpirePolicy(struct ExpirePolicy *epbuf, struct room *qrbuf) { +void GetExpirePolicy(struct ExpirePolicy *epbuf, struct ctdlroom *qrbuf) { struct floor *fl; /* If the room has its own policy, return it */ @@ -53,11 +48,26 @@ void GetExpirePolicy(struct ExpirePolicy *epbuf, struct room *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 */ @@ -71,9 +81,9 @@ void GetExpirePolicy(struct ExpirePolicy *epbuf, struct room *qrbuf) { void cmd_gpex(char *argbuf) { struct ExpirePolicy exp; struct floor *fl; - char which[SIZ]; + char which[128]; - extract(which, argbuf, 0); + extract_token(which, argbuf, 0, '|', sizeof which); if (!strcasecmp(which, "room")) { memcpy(&exp, &CC->room.QRep, sizeof(struct ExpirePolicy)); } @@ -81,11 +91,14 @@ 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)); } else { - cprintf("%d Invalid keyword \"%s\"\n", ERROR, which); + cprintf("%d Invalid keyword \"%s\"\n", ERROR + ILLEGAL_VALUE, which); return; } @@ -99,34 +112,34 @@ void cmd_gpex(char *argbuf) { void cmd_spex(char *argbuf) { struct ExpirePolicy exp; struct floor flbuf; - char which[SIZ]; + char which[128]; memset(&exp, 0, sizeof(struct ExpirePolicy)); - extract(which, argbuf, 0); + extract_token(which, argbuf, 0, '|', sizeof which); exp.expire_mode = extract_int(argbuf, 1); exp.expire_value = extract_int(argbuf, 2); if ((exp.expire_mode < 0) || (exp.expire_mode > 3)) { - cprintf("%d Invalid policy.\n", ERROR); + cprintf("%d Invalid policy.\n", ERROR + ILLEGAL_VALUE); return; } if (!strcasecmp(which, "room")) { if (!is_room_aide()) { cprintf("%d Higher access required.\n", - ERROR+HIGHER_ACCESS_REQUIRED); + ERROR + HIGHER_ACCESS_REQUIRED); return; } lgetroom(&CC->room, CC->room.QRname); memcpy(&CC->room.QRep, &exp, sizeof(struct ExpirePolicy)); lputroom(&CC->room); - cprintf("%d Room expire policy set.\n", CIT_OK); + cprintf("%d Room expire policy has been updated.\n", CIT_OK); return; } if (CC->user.axlevel < 6) { cprintf("%d Higher access required.\n", - ERROR+HIGHER_ACCESS_REQUIRED); + ERROR + HIGHER_ACCESS_REQUIRED); return; } @@ -134,24 +147,32 @@ void cmd_spex(char *argbuf) { lgetfloor(&flbuf, CC->room.QRfloor); memcpy(&flbuf.f_ep, &exp, sizeof(struct ExpirePolicy)); lputfloor(&flbuf, CC->room.QRfloor); - cprintf("%d Floor expire policy set.\n", CIT_OK); + cprintf("%d Floor expire policy has been updated.\n", CIT_OK); + 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", - ERROR); + ERROR + ILLEGAL_VALUE); return; } memcpy(&config.c_ep, &exp, sizeof(struct ExpirePolicy)); put_config(); - cprintf("%d Site expire policy set.\n", CIT_OK); + cprintf("%d Site expire policy has been updated.\n", CIT_OK); return; } else { - cprintf("%d Invalid keyword \"%s\"\n", ERROR, which); + cprintf("%d Invalid keyword \"%s\"\n", ERROR + ILLEGAL_VALUE, which); return; }