* add THISROOM:FILES:N and THISROOM:FILES:STR
authorWilfried Göesgens <willi@citadel.org>
Thu, 5 Aug 2010 22:12:38 +0000 (22:12 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 5 Aug 2010 22:12:38 +0000 (22:12 +0000)
webcit/roomops.c
webcit/roomops.h

index eba4ce174553da7fb81cd2da82f7a6a71a2d715b..970c4a0c8ea33073dfd95366aba40bb4027d48c3 100644 (file)
@@ -951,6 +951,55 @@ void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
        StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1);
 }
 
+void LoadXRoomXCountFiles(void)
+{
+       wcsession *WCC = WC;
+       StrBuf *Buf;
+       int Done = 0;
+       
+       if (WCC->CurRoom.XHaveDownloadCount)
+               return;
+
+       WCC->CurRoom.XHaveDownloadCount = 1;
+
+       Buf = NewStrBuf();
+       serv_puts("RDIR");
+       StrBuf_ServGetln(Buf);
+       if (GetServerStatus(Buf, NULL) == 1) {
+               
+               while (!Done && StrBuf_ServGetln(Buf)>=0) {
+                       if ( (StrLength(Buf)==3) && 
+                            !strcmp(ChrPtr(Buf), "000")) 
+                               Done = 1;
+                       else 
+                               WCC->CurRoom.XDownloadCount++;
+               }
+       }
+
+       FreeStrBuf (&Buf);
+}
+
+void tmplput_CurrentRoomXNFiles(StrBuf *Target, WCTemplputParams *TP) 
+{
+       wcsession *WCC = WC;
+
+       LoadXRoomXCountFiles();
+
+       StrBufAppendPrintf(Target, "%d", WCC->CurRoom.XDownloadCount);
+}
+
+void tmplput_CurrentRoomX_FileString(StrBuf *Target, WCTemplputParams *TP) 
+{
+       wcsession *WCC = WC;
+
+       LoadXRoomXCountFiles();
+
+       if (WCC->CurRoom.XDownloadCount == 1)
+               StrBufAppendBufPlain(Target, _("file"), -1, 0);
+       else
+               StrBufAppendBufPlain(Target, _("files"), -1, 0);
+}
+
 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP) 
 {
        wcsession *WCC = WC;
@@ -3456,7 +3505,8 @@ InitModule_ROOMOPS
        RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
        RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
        RegisterConditional(HKEY("COND:THISROOM:HAVE_INFOTEXT"), 0, ConditionalThisRoomXHaveInfoText, CTX_NONE);
-
+       RegisterNamespace("THISROOM:FILES:N", 0, 1, tmplput_CurrentRoomXNFiles, NULL, CTX_NONE);
+       RegisterNamespace("THISROOM:FILES:STR", 0, 1, tmplput_CurrentRoomX_FileString, NULL, CTX_NONE);
 
        REGISTERTokenParamDefine(QR_PERMANENT);
        REGISTERTokenParamDefine(QR_INUSE);
index c2ad6bdec5371f5e12f6685614538b360f73b402..ea7f7ab42852abfcd8a6f6ffa0e79956557e861c 100644 (file)
@@ -106,6 +106,9 @@ typedef struct _folder {
        int XHaveInfoTextLoaded;
        StrBuf *XInfoText;
 
+       int XHaveDownloadCount;
+       int XDownloadCount;
+
        HashList *IgnetCfgs[maxRoomNetCfg];
 
 }folder;