From 5669e907fb3ae48d363283f55d69907422971bd2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Thu, 5 Aug 2010 21:07:58 +0000 Subject: [PATCH] * remove the room infomatic, add templates --- webcit/roomlist.c | 1 + webcit/roomops.c | 99 +++++++++++++++++++++++++---------------------- webcit/roomops.h | 2 + 3 files changed, 56 insertions(+), 46 deletions(-) diff --git a/webcit/roomlist.c b/webcit/roomlist.c index c9ca82537..c692236f0 100644 --- a/webcit/roomlist.c +++ b/webcit/roomlist.c @@ -138,6 +138,7 @@ void FlushFolder(folder *room) FreeStrBuf(&room->XAPass); FreeStrBuf(&room->Directory); FreeStrBuf(&room->RoomAide); + FreeStrBuf(&room->XInfoText); FreeStrBuf(&room->name); if (room->IgnetCfgs[0] == (HashList*) StrBufNOTNULL) diff --git a/webcit/roomops.c b/webcit/roomops.c index e49816b75..982dfd887 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -231,51 +231,6 @@ void zapped_list(void) wDumpContent(1); } - -/* - * read this room's info file (set v to 1 for verbose mode) - */ -void readinfo(StrBuf *Target, WCTemplputParams *TP) -{ - char buf[256]; - char briefinfo[128]; - char fullinfo[8192]; - int fullinfo_len = 0; - - serv_puts("RINF"); - serv_getln(buf, sizeof buf); - if (buf[0] == '1') { - - while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { - if (fullinfo_len < (sizeof fullinfo - sizeof buf)) { - strcpy(&fullinfo[fullinfo_len], buf); - fullinfo_len += strlen(buf); - } - } - - safestrncpy(briefinfo, fullinfo, sizeof briefinfo); - strcpy(&briefinfo[50], "..."); - - wc_printf("
" - ); - escputs(briefinfo); - wc_printf("
"); - wc_printf("\"%s\"", - _("Close window") - ); - escputs(fullinfo); - wc_printf("
"); - } - else { - wc_printf(" "); - } -} - - /* * Display the current view and offer an option to change it */ @@ -391,7 +346,6 @@ void embed_room_banner(char *got, int navbar_style) { extract_int(&got[4], 2), with_files ); - svcallback("ROOMINFO", readinfo); svcallback("VIEWOMATIC", embed_view_o_matic); svcallback("START", offer_start_page); @@ -948,6 +902,56 @@ int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP) return WCC->CurRoom.XHaveRoomPic == 1; } +void LoadXRoomInfoText(void) +{ + wcsession *WCC = WC; + StrBuf *Buf; + int Done = 0; + + if (WCC->CurRoom.XHaveInfoTextLoaded) + return; + + WCC->CurRoom.XHaveInfoTextLoaded = 1; + Buf = NewStrBuf(); + + serv_puts("RINF"); + + StrBuf_ServGetln(Buf); + if (GetServerStatus(Buf, NULL) == 1) { + WCC->CurRoom.XInfoText = NewStrBuf (); + + while (!Done && StrBuf_ServGetln(Buf)>=0) { + if ( (StrLength(Buf)==3) && + !strcmp(ChrPtr(Buf), "000")) + Done = 1; + else + StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0); + } + } + + FreeStrBuf (&Buf); +} + +int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + if (WCC == NULL) + return 0; + + LoadXRoomInfoText(); + return (StrLength(WCC->CurRoom.XInfoText)>0); +} + +void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + LoadXRoomInfoText(); + + StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1); +} + void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP) { wcsession *WCC = WC; @@ -3448,9 +3452,12 @@ InitModule_ROOMOPS RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE); RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE); RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE); + RegisterNamespace("THISROOM:INFOTEXT", 1, 2, tmplput_CurrentRoomInfoText, NULL, CTX_NONE); RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE); 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); + REGISTERTokenParamDefine(QR_PERMANENT); REGISTERTokenParamDefine(QR_INUSE); diff --git a/webcit/roomops.h b/webcit/roomops.h index 37a9471b7..c2ad6bdec 100644 --- a/webcit/roomops.h +++ b/webcit/roomops.h @@ -103,6 +103,8 @@ typedef struct _folder { int XHaveRoomPic; int XHaveRoomPicLoaded; + int XHaveInfoTextLoaded; + StrBuf *XInfoText; HashList *IgnetCfgs[maxRoomNetCfg]; -- 2.30.2