From 89b8bb84814b774301e9b33512cf23d53b17bc9a Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 14 Dec 2010 17:13:03 -0500 Subject: [PATCH] Room info in banner was completely broken. Fixed. --- webcit/roomlist.c | 1 + webcit/roomops.c | 5 +++-- webcit/roomtokens.c | 19 ++++++++++++++++--- webcit/static/t/readinfo.html | 4 ++-- webcit/webcit.h | 2 +- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/webcit/roomlist.c b/webcit/roomlist.c index 2d1e09c5f..f30d0d82e 100644 --- a/webcit/roomlist.c +++ b/webcit/roomlist.c @@ -187,6 +187,7 @@ void FlushFolder(folder *room) FreeStrBuf(&room->Directory); FreeStrBuf(&room->RoomAide); FreeStrBuf(&room->XInfoText); + room->XHaveInfoTextLoaded = 0; FreeStrBuf(&room->name); diff --git a/webcit/roomops.c b/webcit/roomops.c index 076e5636b..11e536acd 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -568,8 +568,9 @@ void LoadXRoomInfoText(void) StrBuf *Buf; int Done = 0; - if (WCC->CurRoom.XHaveInfoTextLoaded) + if (WCC->CurRoom.XHaveInfoTextLoaded) { return; + } WCC->CurRoom.XHaveInfoTextLoaded = 1; Buf = NewStrBuf(); @@ -589,7 +590,7 @@ void LoadXRoomInfoText(void) } } - FreeStrBuf (&Buf); + FreeStrBuf(&Buf); } diff --git a/webcit/roomtokens.c b/webcit/roomtokens.c index 0e632365f..80561a457 100644 --- a/webcit/roomtokens.c +++ b/webcit/roomtokens.c @@ -407,6 +407,7 @@ void tmplput_ThisRoomOrder(StrBuf *Target, WCTemplputParams *TP) StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order); } + int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP) { wcsession *WCC = WC; @@ -420,6 +421,7 @@ int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP) CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0); return CheckThis == WCC->CurRoom.Order; } + void tmplput_ROOM_LISTORDER(StrBuf *Target, WCTemplputParams *TP) { folder *Folder = (folder *)CTX; @@ -455,10 +457,23 @@ int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP) void tmplput_ThisRoomInfoText(StrBuf *Target, WCTemplputParams *TP) { wcsession *WCC = WC; + long nchars = 0; LoadXRoomInfoText(); - StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1); + nchars = GetTemplateTokenNumber(Target, TP, 0, 0); + if (!nchars) { + /* the whole thing */ + StrBufAppendTemplate(Target, TP, WCC->CurRoom.XInfoText, 1); + } + else { + /* only a certain number of characters */ + StrBuf *SubBuf = NewStrBuf(); + StrBufSub(SubBuf, WCC->CurRoom.XInfoText, 0, nchars); + StrBufAppendBufPlain(SubBuf, HKEY("..."), 0); + StrBufAppendTemplate(Target, TP, SubBuf, 1); + FreeStrBuf(&SubBuf); + } } @@ -466,8 +481,6 @@ void tmplput_ThisRoomInfoText(StrBuf *Target, WCTemplputParams *TP) - - void tmplput_ROOM_LASTCHANGE(StrBuf *Target, WCTemplputParams *TP) { folder *Folder = (folder *)CTX; diff --git a/webcit/static/t/readinfo.html b/webcit/static/t/readinfo.html index 476586d75..1f64b7f16 100644 --- a/webcit/static/t/readinfo.html +++ b/webcit/static/t/readinfo.html @@ -1,7 +1,7 @@
- +
diff --git a/webcit/webcit.h b/webcit/webcit.h index ef7c2c456..cd12d7d98 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -127,7 +127,7 @@ extern char *ssl_cipher_list; #define SIZ 4096 /* generic buffer size */ -#define TRACE fprintf(stderr, "Checkpoint: %s, %d\n", __FILE__, __LINE__) +#define TRACE fprintf(stderr, "\033[7mCheckpoint: %s, %d\033[0m\n", __FILE__, __LINE__) #define SLEEPING 180 /* TCP connection timeout */ #define WEBCIT_TIMEOUT 900 /* WebCit session timeout */ -- 2.30.2