fix dlen
[citadel.git] / webcit / siteconfig.c
index 253e1a5763c57292979cbaad45e071ac9635aa38..39e90e614e43a312690b9aeb4bf139f526d6b38f 100644 (file)
@@ -1,19 +1,22 @@
 /*
  * Administrative screen for site-wide configuration
  *
- * Copyright (c) 1996-2014 by the citadel.org team
+ * Copyright (c) 1996-2024 by the citadel.org team
  *
- * This program is open source software.  You can redistribute it and/or
- * modify it under the terms of the GNU General Public License, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is open source software.  Use, duplication, or disclosure
+ * are subject to the terms of the GNU General Public License version 3.
  */
 
 #include "webcit.h"
-#include "webserver.h"
+
+
+/*
+ * Expiry policy for the autopurger
+ */
+#define EXPIRE_NEXTLEVEL        0       /* Inherit expiration policy    */
+#define EXPIRE_MANUAL           1       /* Don't expire messages at all */
+#define EXPIRE_NUMMSGS          2       /* Keep only latest n messages  */
+#define EXPIRE_AGE              3       /* Expire messages after n days */
 
 CtxType CTX_SRVLOG = CTX_NONE;
 
@@ -28,10 +31,9 @@ ConstStr ExpirePolicyStrings[][2] = {
        { { CStrOf(mailboxespolicy)} , { strof(mailboxespolicy)"_value", sizeof(strof(mailboxespolicy)"_value") - 1 } }
 };
 
-void LoadExpirePolicy(GPEXWhichPolicy which)
-{
+
+void LoadExpirePolicy(GPEXWhichPolicy which) {
        StrBuf *Buf;
-       wcsession *WCC = WC;
        long State;
        const char *Pos = NULL;
 
@@ -40,16 +42,16 @@ void LoadExpirePolicy(GPEXWhichPolicy which)
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, &State) == 2) {
                Pos = ChrPtr(Buf) + 4;
-               WCC->Policy[which].expire_mode = StrBufExtractNext_long(Buf, &Pos, '|');
-               WCC->Policy[which].expire_value = StrBufExtractNext_long(Buf, &Pos, '|');
+               WC->Policy[which].expire_mode = StrBufExtractNext_long(Buf, &Pos, '|');
+               WC->Policy[which].expire_value = StrBufExtractNext_long(Buf, &Pos, '|');
        }
        else if (State == 550)
                AppendImportantMessage(_("Higher access is required to access this function."), -1);
        FreeStrBuf(&Buf);
 }
 
-void SaveExpirePolicyFromHTTP(GPEXWhichPolicy which)
-{
+
+void SaveExpirePolicyFromHTTP(GPEXWhichPolicy which) {
        StrBuf *Buf;
        long State;
 
@@ -66,9 +68,8 @@ void SaveExpirePolicyFromHTTP(GPEXWhichPolicy which)
        FreeStrBuf(&Buf);
 }
 
-int ConditionalExpire(StrBuf *Target, WCTemplputParams *TP)
-{
-       wcsession *WCC = WC;
+
+int ConditionalExpire(StrBuf *Target, WCTemplputParams *TP) {
        GPEXWhichPolicy which;
        int CompareWith;
 
@@ -77,33 +78,29 @@ int ConditionalExpire(StrBuf *Target, WCTemplputParams *TP)
 
        LoadExpirePolicy(which);
        
-       return WCC->Policy[which].expire_mode == CompareWith;
+       return WC->Policy[which].expire_mode == CompareWith;
 }
 
-void tmplput_ExpireValue(StrBuf *Target, WCTemplputParams *TP)
-{
+
+void tmplput_ExpireValue(StrBuf *Target, WCTemplputParams *TP) {
        GPEXWhichPolicy which;
-       wcsession *WCC = WC;
                
        which = GetTemplateTokenNumber(Target, TP, 0, 0);
        LoadExpirePolicy(which);
-       StrBufAppendPrintf(Target, "%d", WCC->Policy[which].expire_value);
+       StrBufAppendPrintf(Target, "%d", WC->Policy[which].expire_value);
 }
 
 
-void tmplput_ExpireMode(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ExpireMode(StrBuf *Target, WCTemplputParams *TP) {
        GPEXWhichPolicy which;
-       wcsession *WCC = WC;
                
        which = GetTemplateTokenNumber(Target, TP, 2, 0);
        LoadExpirePolicy(which);
-       StrBufAppendPrintf(Target, "%d", WCC->Policy[which].expire_mode);
+       StrBufAppendPrintf(Target, "%d", WC->Policy[which].expire_mode);
 }
 
 
-void LoadZoneFiles(void)
-{
+void LoadZoneFiles(void) {
        icalarray *zones;
        int z;
        long len;
@@ -214,25 +211,23 @@ CfgMapping ServerConfig[] = {
        {CFG_STR, 0, 0, "", HKEY("c_port_number")},
        {CFG_STR, 0, 0, "", HKEY("c_ctdluid")},
        {CFG_STR, 0, 0, "", HKEY("c_nntp_port")},
-       {CFG_STR, 0, 0, "", HKEY("c_nntps_port")}
+       {CFG_STR, 0, 0, "", HKEY("c_nntps_port")},
+       {CFG_YES, 0, 0, "", HKEY("smtp_advertise_starttls")}
 };
 
 
-
 /*
  *  display all configuration items
  */
-void load_siteconfig(void)
-{
-       wcsession *WCC = WC;
+void load_siteconfig(void) {
        StrBuf *Buf;
        HashList *Cfg;
        long len;
        int i, j;
        
-       if (WCC->ServCfg == NULL)
-               WCC->ServCfg = NewHash(1, NULL);
-       Cfg = WCC->ServCfg;
+       if (WC->ServCfg == NULL)
+               WC->ServCfg = NewHash(1, NULL);
+       Cfg = WC->ServCfg;
 
        Buf = NewStrBuf();
 
@@ -276,13 +271,10 @@ void load_siteconfig(void)
 }
 
 
-
 /*
  * parse siteconfig changes 
  */
-void siteconfig(void)
-{
-       wcsession *WCC = WC;
+void siteconfig(void) {
        int i, value;
        StrBuf *Line;
 
@@ -333,39 +325,38 @@ void siteconfig(void)
        SaveExpirePolicyFromHTTP(sitepolicy);
        SaveExpirePolicyFromHTTP(mailboxespolicy);
 
-       FreeStrBuf(&WCC->serv_info->serv_default_cal_zone);
-       WCC->serv_info->serv_default_cal_zone = NewStrBufDup(sbstr("c_default_cal_zone"));
+       FreeStrBuf(&WC->serv_info->serv_default_cal_zone);
+       WC->serv_info->serv_default_cal_zone = NewStrBufDup(sbstr("c_default_cal_zone"));
 
        AppendImportantMessage(_("Your system configuration has been updated."), -1);
-       DeleteHash(&WCC->ServCfg);
+       DeleteHash(&WC->ServCfg);
        display_aide_menu();
 }
 
-void tmplput_servcfg(StrBuf *Target, WCTemplputParams *TP)
-{
-       wcsession *WCC = WC;
+
+// if WebCit Classic wasn't obsolete we would replace this with a "CONF GETVAL" type of thing
+void tmplput_servcfg(StrBuf *Target, WCTemplputParams *TP) {
        void *vBuf;
        StrBuf *Buf;
 
-       if (WCC->is_aide) {
-               if (WCC->ServCfg == NULL)
+       if (WC->is_aide) {
+               if (WC->ServCfg == NULL)
                        load_siteconfig();
-               GetHash(WCC->ServCfg, TKEY(0), &vBuf);
+               GetHash(WC->ServCfg, TKEY(0), &vBuf);
                Buf = (StrBuf*) vBuf;
                StrBufAppendTemplate(Target, TP, Buf, 1);
        }
 }
 
-int ConditionalServCfg(StrBuf *Target, WCTemplputParams *TP)
-{
-       wcsession *WCC = WC;
+
+int ConditionalServCfg(StrBuf *Target, WCTemplputParams *TP) {
        void *vBuf;
        StrBuf *Buf;
 
-       if (WCC->is_aide) {
-               if (WCC->ServCfg == NULL)
+       if (WC->is_aide) {
+               if (WC->ServCfg == NULL)
                        load_siteconfig();
-               GetHash(WCC->ServCfg, TKEY(2), &vBuf);
+               GetHash(WC->ServCfg, TKEY(2), &vBuf);
                if (vBuf == NULL) return 0;
                Buf = (StrBuf*) vBuf;
                if (TP->Tokens->nParameters == 3) {
@@ -388,17 +379,15 @@ int ConditionalServCfg(StrBuf *Target, WCTemplputParams *TP)
        else return 0;
 }
 
-int ConditionalServCfgCTXStrBuf(StrBuf *Target, WCTemplputParams *TP)
-{
-       wcsession *WCC = WC;
+int ConditionalServCfgCTXStrBuf(StrBuf *Target, WCTemplputParams *TP) {
        void *vBuf;
        StrBuf *Buf;
        StrBuf *ZoneToCheck = (StrBuf*) CTX(CTX_STRBUF);
 
-       if ((WCC->is_aide) || (ZoneToCheck == NULL)) {
-               if (WCC->ServCfg == NULL)
+       if ((WC->is_aide) || (ZoneToCheck == NULL)) {
+               if (WC->ServCfg == NULL)
                        load_siteconfig();
-               GetHash(WCC->ServCfg, TKEY(2), &vBuf);
+               GetHash(WC->ServCfg, TKEY(2), &vBuf);
                if (vBuf == NULL) return 0;
                Buf = (StrBuf*) vBuf;
 
@@ -429,6 +418,8 @@ void tmplput_servcfg_LogName(StrBuf *Target, WCTemplputParams *TP)
        StrBufAppendTemplate(Target, TP, Stat->Name, 1);
 }
 
+
+
 int ConditionalServCfgThisLogEnabled(StrBuf *Target, WCTemplputParams *TP)
 {
         LogStatusStruct *Stat = (LogStatusStruct*) CTX(CTX_SRVLOG);
@@ -504,7 +495,6 @@ InitModule_SITECONFIG
        RegisterConditional("COND:EXPIRE:MODE", 2, ConditionalExpire, CTX_NONE);
        RegisterNamespace("EXPIRE:VALUE", 1, 2, tmplput_ExpireValue, NULL, CTX_NONE);
        RegisterNamespace("EXPIRE:MODE", 1, 2, tmplput_ExpireMode, NULL, CTX_NONE);
-
        RegisterConditional("COND:SERVCFG:THISLOGENABLE", 4, ConditionalServCfgThisLogEnabled, CTX_SRVLOG);
        RegisterIterator("SERVCFG:LOGENABLE", 0, NULL, iterate_GetSrvLogEnable, NULL, DeleteHash, CTX_SRVLOG, CTX_NONE, IT_NOFLAG);
        RegisterNamespace("SERVCFG:LOGNAME", 0, 1, tmplput_servcfg_LogName, NULL, CTX_SRVLOG);