X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Froomchat.c;h=3b0091e441a3d55799b1ce56e836c03705990eb7;hb=HEAD;hp=0933fa6168e1647a91300e3f57ff813306c73a5b;hpb=8ce55d0a3cc3011b8e8bb08106f6a067f68d9df9;p=citadel.git diff --git a/webcit/roomchat.c b/webcit/roomchat.c index 0933fa616..ea43afde0 100644 --- a/webcit/roomchat.c +++ b/webcit/roomchat.c @@ -1,23 +1,15 @@ /* - * $Id$ - * * This module handles multiuser chat. * - * Copyright (c) 1996-2010 by the citadel.org team + * Copyright (c) 1996-2012 by the citadel.org team * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. + * This program is open source software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "webcit.h" @@ -34,7 +26,7 @@ void do_chat(void) WC->last_chat_user[0] = 0; output_headers(1, 1, 1, 0, 0, 0); - do_template("roomchat", NULL); + do_template("roomchat"); serv_puts("RCHT enter"); serv_getln(buf, sizeof buf); @@ -51,73 +43,38 @@ void do_chat(void) void chat_recv(void) { char buf[SIZ]; char cl_user[SIZ]; - char cl_text[SIZ]; - int cl_text_len = 0; - - begin_ajax_response(); serv_printf("RCHT poll|%d", WC->last_chat_seq); serv_getln(buf, sizeof buf); if (buf[0] == '1') { WC->last_chat_seq = extract_int(&buf[4], 0); extract_token(cl_user, &buf[4], 2, '|', sizeof cl_user); - cl_text[0] = 0; - cl_text_len = 0; - while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { - safestrncpy(&cl_text[cl_text_len], buf, (sizeof(cl_text) - cl_text_len)); - cl_text_len += strlen(buf); - } - - wc_printf("
", WC->last_chat_seq); - - if (strcasecmp(cl_user, WC->last_chat_user)) { - wc_printf("" - "
" - ); - - } - - wc_printf(""); - - wc_printf("
"); - - if (!strcasecmp(cl_user, ":")) { - wc_printf(""); - } + /* who is speaking ... */ if (strcasecmp(cl_user, WC->last_chat_user)) { - wc_printf(""); - + wc_printf("
\n"); if (!strcasecmp(cl_user, ChrPtr(WC->wc_fullname))) { - wc_printf(""); + wc_printf(""); } else { - wc_printf(""); + wc_printf(""); } - jsescputs(cl_user); + escputs(cl_user); + strcpy(WC->last_chat_user, cl_user); - wc_printf(":
"); + wc_printf(": "); } else { wc_printf("   "); } - jsescputs(cl_text); - if (!strcasecmp(cl_user, ":")) { - wc_printf("
"); - } - - wc_printf("
\n"); - wc_printf("
\n"); - strcpy(WC->last_chat_user, cl_user); - /* FIXME make this work wc_printf("parent.chat_transcript.scrollTo(999999,999999);\">\n"); */ + /* what did they say ... */ + wc_printf(""); + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + escputs(buf); + } + wc_printf("
\n"); } - - end_ajax_response(); - } @@ -137,14 +94,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"); } @@ -161,12 +110,50 @@ 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"); + } + } +} + + +/* + * advise the Citadel server that the user is navigating away from the chat window + */ +void chat_exit(void) { + char buf[1024]; + + serv_puts("RCHT exit"); + serv_getln(buf, sizeof buf); /* Throw away the server reply */ +} + + + void InitModule_ROOMCHAT (void) { WebcitAddUrlHandler(HKEY("chat"), "", 0, do_chat, 0); - WebcitAddUrlHandler(HKEY("chat_recv"), "", 0, chat_recv, 0); + WebcitAddUrlHandler(HKEY("chat_recv"), "", 0, chat_recv, AJAX); + WebcitAddUrlHandler(HKEY("chat_rwho"), "", 0, chat_rwho, AJAX); + WebcitAddUrlHandler(HKEY("chat_exit"), "", 0, chat_exit, AJAX); WebcitAddUrlHandler(HKEY("chat_send"), "", 0, chat_send, 0); }