4 * This module handles multiuser chat.
6 * Copyright (c) 1996-2010 by the citadel.org team
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Display the screen containing multiuser chat for a room.
33 WC->last_chat_seq = 0;
34 WC->last_chat_user[0] = 0;
36 output_headers(1, 1, 1, 0, 0, 0);
37 do_template("roomchat", NULL);
39 serv_puts("RCHT enter");
40 serv_getln(buf, sizeof buf);
47 * Receiving side of the chat window.
48 * This does JavaScript writes to
49 * other divs whenever it refreshes and finds new data.
51 void chat_recv(void) {
57 begin_ajax_response();
59 serv_printf("RCHT poll|%d", WC->last_chat_seq);
60 serv_getln(buf, sizeof buf);
62 WC->last_chat_seq = extract_int(&buf[4], 0);
63 extract_token(cl_user, &buf[4], 2, '|', sizeof cl_user);
66 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
67 safestrncpy(&cl_text[cl_text_len], buf, (sizeof(cl_text) - cl_text_len));
68 cl_text_len += strlen(buf);
71 wc_printf("<div id=\"chat_seq_%d\">", WC->last_chat_seq);
73 if (strcasecmp(cl_user, WC->last_chat_user)) {
74 wc_printf("<table border=0 width=100%% "
75 "cellspacing=1 cellpadding=0 "
76 "bgcolor="#ffffff">"
77 "<tr><td></tr></td></table>"
82 wc_printf("<table border=0 width=100%% cellspacing=0 cellpadding=0 "
83 "bgcolor="#eeeeee">");
85 wc_printf("<tr><td>");
87 if (!strcasecmp(cl_user, ":")) {
91 if (strcasecmp(cl_user, WC->last_chat_user)) {
94 if (!strcasecmp(cl_user, ChrPtr(WC->wc_fullname))) {
95 wc_printf("<FONT COLOR="#FF0000">");
98 wc_printf("<FONT COLOR="#0000FF">");
102 wc_printf("</FONT>: </B>");
105 wc_printf(" ");
108 if (!strcasecmp(cl_user, ":")) {
112 wc_printf("</TD></TR></TABLE>\n");
113 wc_printf("</div>\n");
115 strcpy(WC->last_chat_user, cl_user);
116 /* FIXME make this work wc_printf("parent.chat_transcript.scrollTo(999999,999999);\">\n"); */
125 * This is the sending side of the chat window. The form is designed to transmit asynchronously.
127 void chat_send(void) {
131 begin_ajax_response();
133 if (havebstr("send_this")) {
134 strcpy(send_this, bstr("send_this"));
137 strcpy(send_this, "");
140 if (havebstr("help_button")) {
141 strcpy(send_this, "/help");
144 if (havebstr("list_button")) {
145 strcpy(send_this, "/who");
148 if (havebstr("exit_button")) {
149 strcpy(send_this, "/quit");
152 if (!IsEmptyStr(send_this)) {
153 serv_puts("RCHT send");
154 serv_getln(buf, sizeof buf);
156 text_to_server(send_this);
168 WebcitAddUrlHandler(HKEY("chat"), "", 0, do_chat, 0);
169 WebcitAddUrlHandler(HKEY("chat_recv"), "", 0, chat_recv, 0);
170 WebcitAddUrlHandler(HKEY("chat_send"), "", 0, chat_send, 0);
175 SessionDestroyModule_ROOMCHAT
178 /* nothing here anymore */