]> code.citadel.org Git - citadel.git/blobdiff - webcit/paging.c
* add logging if auth-basic session connecting fails with weird conditions
[citadel.git] / webcit / paging.c
index acfcdd97c57d4b76c6730e26cfb2d092e74d219b..e93ac646bda13cd044668a182b47b3cef414b237 100644 (file)
@@ -1,15 +1,11 @@
 /*
  * $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)
 {
@@ -107,10 +103,13 @@ void do_chat(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;
        }
 
@@ -229,13 +228,13 @@ int setup_chat_socket(void) {
 
                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");
@@ -280,6 +279,7 @@ void chat_recv(void) {
        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"
@@ -382,7 +382,7 @@ void chat_recv(void) {
                                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=&quot;#FF0000&quot;>");
                                        }
                                        else {
@@ -427,6 +427,7 @@ void chat_send(void) {
 
        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();\" >"
        );
@@ -498,6 +499,25 @@ void chat_send(void) {
        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)
@@ -507,6 +527,14 @@ InitModule_PAGING
        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);
+}