]> code.citadel.org Git - citadel.git/blobdiff - webcit/roomops.c
* new tokens for THISROOM:MSGS:NEW THISROOM:MSGS:TOTAL
[citadel.git] / webcit / roomops.c
index 982dfd8879c8e4864fd9c793946603bd92fefe34..ea6acbef220b7fd8a56312b73b6c1c73028ce7f5 100644 (file)
@@ -347,7 +347,6 @@ void embed_room_banner(char *got, int navbar_style) {
                 with_files
                );
        svcallback("VIEWOMATIC", embed_view_o_matic); 
-       svcallback("START", offer_start_page); 
  
        do_template("roombanner", NULL);
        /* roombanner contains this for mobile */
@@ -952,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;
@@ -985,6 +1033,23 @@ void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
        StrBufAppendPrintf(Target, "%d", WCC->CurRoom.DefView);
 }
 
+void tmplput_CurrentRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP) 
+{
+       wcsession *WCC = WC;
+
+       LoadRoomXA();
+
+       StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
+}
+
+void tmplput_CurrentRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP) 
+{
+       wcsession *WCC = WC;
+
+       LoadRoomXA();
+
+       StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nTotalMessages);
+}
 
 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
 {
@@ -3446,6 +3511,9 @@ InitModule_ROOMOPS
        RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
 
        RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
+       RegisterNamespace("THISROOM:MSGS:NEW", 0, 0, tmplput_CurrentRoom_nNewMessages, NULL, CTX_NONE);
+       RegisterNamespace("THISROOM:MSGS:TOTAL", 0, 0, tmplput_CurrentRoom_nTotalMessages, NULL, CTX_NONE);
+
        RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
        RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
        RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
@@ -3457,7 +3525,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);