/*
* $Id$
*/
-/**
- * \defgroup PageFunc Functions which implement the chat and paging facilities.
- * \ingroup ClientPower
- */
-/*@{*/
+
#include "webcit.h"
-/**
- * \brief display the form for paging (x-messaging) another user
+/*
+ * display the form for paging (x-messaging) another user
*/
void display_page(void)
{
char buf[SIZ];
/** First, check to make sure we're still allowed in this room. */
- serv_printf("GOTO %s", WC->wc_roomname);
+ serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
serv_getln(buf, sizeof buf);
if (buf[0] != '2') {
- smart_goto("_BASEROOM_");
+ StrBuf *Buf;
+ Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
+ smart_goto(Buf);
+ FreeStrBuf(&Buf);
return;
}
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- serv_printf("USER %s", WC->wc_username);
+ serv_printf("USER %s", ChrPtr(WC->wc_username));
serv_getln(buf, sizeof buf);
if (buf[0] == '3') {
- serv_printf("PASS %s", WC->wc_password);
+ serv_printf("PASS %s", ChrPtr(WC->wc_password));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- serv_printf("GOTO %s", WC->wc_roomname);
+ serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
serv_puts("CHAT");
output_headers(0, 0, 0, 0, 0, 0);
hprintf("Content-type: text/html; charset=utf-8\r\n");
+ begin_burst();
wprintf("<html>\n"
"<head>\n"
"<meta http-equiv=\"refresh\" content=\"3\" />\n"
pf.fd = WC->chat_sock;
pf.events = POLLIN;
pf.revents = 0;
- if (poll(&pf, 1, 1) > 0) if (pf.revents & POLLIN) {
+ if ((poll(&pf, 1, 1) > 0) && (pf.revents & POLLIN)) {
++got_data;
/** Temporarily swap the serv and chat sockets during chat talk */
if (strcasecmp(cl_user, WC->last_chat_user)) {
wprintf("<B>");
- if (!strcasecmp(cl_user, WC->wc_fullname)) {
+ if (!strcasecmp(cl_user, ChrPtr(WC->wc_fullname))) {
wprintf("<FONT COLOR="#FF0000">");
}
else {
output_headers(0, 0, 0, 0, 0, 0);
hprintf("Content-type: text/html; charset=utf-8\r\n");
+ begin_burst();
wprintf("<HTML>"
"<BODY onLoad=\"document.chatsendform.send_this.focus();\" >"
);
wDumpContent(0);
}
+
+void ajax_send_instant_message(void) {
+ char recp[256];
+ char buf[256];
+
+ safestrncpy(recp, bstr("recp"), sizeof recp);
+
+ serv_printf("SEXP %s|-", recp);
+ serv_getln(buf, sizeof buf);
+
+ if (buf[0] == '4') {
+ text_to_server(bstr("msg"));
+ serv_puts("000");
+ }
+
+ escputs(buf); /* doesn't really matter what we return - the client ignores it */
+}
+
+
void
InitModule_PAGING
(void)
WebcitAddUrlHandler(HKEY("chat"), do_chat, 0);
WebcitAddUrlHandler(HKEY("chat_recv"), chat_recv, 0);
WebcitAddUrlHandler(HKEY("chat_send"), chat_send, 0);
+ WebcitAddUrlHandler(HKEY("ajax_send_instant_message"), ajax_send_instant_message, AJAX);
}
-/*@}*/
+
+void
+SessionDestroyModule_CHAT
+(wcsession *sess)
+{
+ if (sess->chat_sock > 0)
+ close(sess->chat_sock);
+}