From 76d71f40827318aa0f29c41332e446bc6a277175 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 26 Apr 2010 18:48:24 +0000 Subject: [PATCH] * More tweaks to the room chat window. Now displays the list of users in chat. --- citadel/modules/roomchat/serv_roomchat.c | 35 ++++++++++++++++ webcit/roomchat.c | 37 ++++++++++++----- webcit/static/t/roomchat.html | 6 +++ webcit/static/webcit.css | 52 +++++++++++++++++++----- 4 files changed, 110 insertions(+), 20 deletions(-) diff --git a/citadel/modules/roomchat/serv_roomchat.c b/citadel/modules/roomchat/serv_roomchat.c index c1a08c566..b3348078c 100644 --- a/citadel/modules/roomchat/serv_roomchat.c +++ b/citadel/modules/roomchat/serv_roomchat.c @@ -198,6 +198,38 @@ void roomchat_poll(char *argbuf) { } + +/* + * list users in chat in this room + */ +void roomchat_rwho(char *argbuf) { + struct CitContext *nptr; + int nContexts, i; + + if (!CC->cs_flags & CS_CHAT) { + cprintf("%d Session is not in chat mode.\n", ERROR); + return; + } + + cprintf("%d%c \n", LISTING_FOLLOWS, CtdlCheckExpress() ); + + nptr = CtdlGetContextArray(&nContexts) ; // grab a copy of the wholist + if (nptr) { + for (i=0; iroom.QRnumber) + && (nptr[i].cs_flags & CS_CHAT) + ) { + cprintf("%s\n", nptr[i].user.fullname); + } + } + free(nptr); // free our copy + } + + cprintf("000\n"); +} + + + /* * Participate in real time chat in a room */ @@ -223,6 +255,9 @@ void cmd_rcht(char *argbuf) else if (!strcasecmp(subcmd, "poll")) { roomchat_poll(argbuf); } + else if (!strcasecmp(subcmd, "rwho")) { + roomchat_rwho(argbuf); + } else { cprintf("%d Invalid subcommand\n", ERROR + CMD_NOT_SUPPORTED); } diff --git a/webcit/roomchat.c b/webcit/roomchat.c index 1e2d84991..c7eed1334 100644 --- a/webcit/roomchat.c +++ b/webcit/roomchat.c @@ -62,10 +62,10 @@ void chat_recv(void) { if (strcasecmp(cl_user, WC->last_chat_user)) { wc_printf("
\n"); if (!strcasecmp(cl_user, ChrPtr(WC->wc_fullname))) { - wc_printf(""); + wc_printf(""); } else { - wc_printf(""); + wc_printf(""); } escputs(cl_user); strcpy(WC->last_chat_user, cl_user); @@ -102,14 +102,6 @@ void chat_send(void) { strcpy(send_this, ""); } - if (havebstr("help_button")) { - strcpy(send_this, "/help"); - } - - if (havebstr("list_button")) { - strcpy(send_this, "/who"); - } - if (havebstr("exit_button")) { strcpy(send_this, "/quit"); } @@ -126,12 +118,37 @@ void chat_send(void) { } +/* + * wholist for chat + */ +void chat_rwho(void) { + char buf[1024]; + + serv_puts("RCHT rwho"); + serv_getln(buf, sizeof buf); + if (buf[0] == '1') { + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + if (!strcasecmp(buf, ChrPtr(WC->wc_fullname))) { + wc_printf(""); + } + else { + wc_printf(""); + } + wc_printf(""); + escputs(buf); + wc_printf("
\n"); + } + } +} + + void InitModule_ROOMCHAT (void) { WebcitAddUrlHandler(HKEY("chat"), "", 0, do_chat, 0); WebcitAddUrlHandler(HKEY("chat_recv"), "", 0, chat_recv, AJAX); + WebcitAddUrlHandler(HKEY("chat_rwho"), "", 0, chat_rwho, AJAX); WebcitAddUrlHandler(HKEY("chat_send"), "", 0, chat_send, 0); } diff --git a/webcit/static/t/roomchat.html b/webcit/static/t/roomchat.html index 5cb9559b6..f5daf0a39 100644 --- a/webcit/static/t/roomchat.html +++ b/webcit/static/t/roomchat.html @@ -2,6 +2,8 @@
+
+
@@ -37,4 +39,8 @@ new Ajax.PeriodicalUpdater('chatrecv', 'chat_recv', { } }); +new Ajax.PeriodicalUpdater('chat_userlist', 'chat_rwho', { + method: 'get', frequency: 15 +}); + diff --git a/webcit/static/webcit.css b/webcit/static/webcit.css index 1778aa34e..79e46b92c 100644 --- a/webcit/static/webcit.css +++ b/webcit/static/webcit.css @@ -1615,13 +1615,37 @@ li.event_unread span, a.event_read_title { } .chatrecv_history { - margin-left: 5px; - margin-right: 5px; + position: absolute; + top: 0; + left: 1%; + width: 74%; + margin-top: 5px; + margin-bottom: 5px; + height: 70%; + background-color: #FFFFFF; + overflow: auto; + border-style: solid; + border-color: #022750; + border-width: 1px; + padding-left: 3px; + padding-right: 3px; +} + +.chat_userlist { + position: absolute; + top: 0; + right: 1%; + width: 23%; margin-top: 5px; margin-bottom: 5px; height: 70%; background-color: #FFFFFF; overflow: auto; + border-style: solid; + border-color: #022750; + border-width: 1px; + padding-left: 3px; + padding-right: 3px; } .chatrecv { @@ -1629,20 +1653,28 @@ li.event_unread span, a.event_read_title { } .chatsend { - width: 90%; + position: absolute; + left: 1%; + right: 1%; + top: 71%; margin-left: auto; margin-right: auto; + border-style: solid; + border-color: #022750; + border-width: 1px; + padding-left: 3px; + padding-right: 3px; } -.chat_username_me { +.chat_myname { font-weight: bold; - color: #f00; -}; + color: #ff0000; +} -.chat_username_notme { +.chat_notmyname { font-weight: bold; - color: #00f; -}; + color: #0000ff; +} .chat_text { -}; +} -- 2.30.2