From: Wilfried Göesgens Date: Thu, 5 Aug 2010 22:12:38 +0000 (+0000) Subject: * add THISROOM:FILES:N and THISROOM:FILES:STR X-Git-Tag: v8.01~952 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=3c60e89fcac38892ae69d719391149a318088f17 * add THISROOM:FILES:N and THISROOM:FILES:STR --- diff --git a/webcit/roomops.c b/webcit/roomops.c index eba4ce174..970c4a0c8 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -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); diff --git a/webcit/roomops.h b/webcit/roomops.h index c2ad6bdec..ea7f7ab42 100644 --- a/webcit/roomops.h +++ b/webcit/roomops.h @@ -106,6 +106,9 @@ typedef struct _folder { int XHaveInfoTextLoaded; StrBuf *XInfoText; + int XHaveDownloadCount; + int XDownloadCount; + HashList *IgnetCfgs[maxRoomNetCfg]; }folder;