]> code.citadel.org Git - citadel.git/blobdiff - webcit/paging.c
* Repaired all my b0rken COLOR tags
[citadel.git] / webcit / paging.c
index 47a5654352340672e36c3f022ae21e549645ca7e..ecad487ffc0b42dfe00a4972a6f74e85deb96e13 100644 (file)
 /* $Id$ */
 
+#include <ctype.h>
 #include <stdlib.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
 #include <stdio.h>
+#include <fcntl.h>
 #include <signal.h>
 #include <sys/types.h>
-#include <ctype.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <limits.h>
+#include <netinet/in.h>
+#include <netdb.h>
 #include <string.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include <signal.h>
 #include "webcit.h"
-#include "child.h"
+
 
 /*
  * display the form for paging (x-messaging) another user
  */
-void display_page(void) {
-       char buf[256];
-       char user[256];
+void display_page(void)
+{
+       char recp[SIZ];
+
+       strcpy(recp, bstr("recp"));
 
-        printf("HTTP/1.0 200 OK\n");
-        output_headers(1, "bottom");
+       output_headers(3);
 
-        wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
-        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-        wprintf("<B>Page another user</B>\n");
-        wprintf("</FONT></TD></TR></TABLE>\n");
+       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#007700\"><TR><TD>");
+       wprintf("<SPAN CLASS=\"titlebar\">Page another user</SPAN>\n");
+       wprintf("</TD></TR></TABLE>\n");
 
-       wprintf("This command sends a near-real-time message to any currently\n");
-       wprintf("logged in user.<BR><BR>\n");
+       wprintf("<CENTER>This will send a page (instant message) "
+               "to %s.\n", recp);
 
        wprintf("<FORM METHOD=\"POST\" ACTION=\"/page_user\">\n");
 
-       wprintf("Select a user to send a message to: <BR>");
-
-       wprintf("<SELECT NAME=\"recp\" SIZE=10>\n");
-       serv_puts("RWHO");
-       serv_gets(buf);
-       if (buf[0]=='1') {
-               while(serv_gets(buf), strcmp(buf,"000")) {
-                       extract(user,buf,1);
-                       wprintf("<OPTION>");
-                       escputs(user);
-                       wprintf("\n");
-                       }
-               }
-       wprintf("</SELECT>\n");
-       wprintf("<BR>\n");
+
+       wprintf("<TABLE border=0 width=100%%><TR><TD>\n");
+
+       wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"");
+       escputs(recp);
+       wprintf("\">\n");
+
+       wprintf("<INPUT TYPE=\"hidden\" NAME=\"closewin\" VALUE=\"");
+       escputs(bstr("closewin"));
+       wprintf("\">\n");
 
        wprintf("Enter message text:<BR>");
-       wprintf("<INPUT TYPE=\"text\" NAME=\"msgtext\" MAXLENGTH=80 SIZE=80>\n");
-       wprintf("<BR><BR>\n");
+
+       wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=5 COLS=40 "
+               "WIDTH=40></TEXTAREA>\n");
+
+       wprintf("</TD></TR></TABLE><BR>\n");
 
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Send message\">");
-       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
+       wprintf("<BR><A HREF=\"javascript:window.close();\"Cancel</A>\n");
 
        wprintf("</FORM></CENTER>\n");
-        wDumpContent(1);
-       }
+       wDumpContent(1);
+}
 
 /*
  * page another user
-*/
-void page_user(void) {
-       char recp[256];
-       char msgtext[256];
-       char sc[256];
-       char buf[256];
-       
-        printf("HTTP/1.0 200 OK\n");
-        output_headers(1, "bottom");
-
-       strcpy(recp,bstr("recp"));
-       strcpy(msgtext,bstr("msgtext"));
-       strcpy(sc,bstr("sc"));
+ */
+void page_user(void)
+{
+       char recp[SIZ];
+       char sc[SIZ];
+       char buf[SIZ];
+       char closewin[SIZ];
 
-       if (strcmp(sc,"Send message")) {
-               wprintf("<EM>Message was not sent.</EM><BR>\n");
-               return;
-               }
+       output_headers(3);
 
-       serv_printf("SEXP %s|%s",recp,msgtext);
-       serv_gets(buf); 
+       strcpy(recp, bstr("recp"));
+       strcpy(sc, bstr("sc"));
+       strcpy(closewin, bstr("closewin"));
 
-       if (buf[0] == '2') {
-               wprintf("<EM>Message has been sent to ");
-               escputs(recp);
-               wprintf(".</EM><BR>\n");
+       if (strcmp(sc, "Send message")) {
+               wprintf("<EM>Message was not sent.</EM><BR>\n");
+       } else {
+               serv_printf("SEXP %s|-", recp);
+               serv_gets(buf);
+
+               if (buf[0] == '4') {
+                       text_to_server(bstr("msgtext"), 0);
+                       serv_puts("000");
+                       wprintf("<EM>Message has been sent to ");
+                       escputs(recp);
+                       wprintf(".</EM><BR>\n");
                }
-       else {
-               wprintf("<EM>%s</EM><BR>\n",&buf[4]);
+               else {
+                       wprintf("<EM>%s</EM><BR>\n", &buf[4]);
                }
-
-        wDumpContent(1);
+       }
+       
+       if (!strcasecmp(closewin, "yes")) {
+               wprintf("<CENTER><A HREF=\"javascript:window.close();\">"
+                       "[ close window ]</A></CENTER>\n");
        }
 
+       wDumpContent(1);
+}
+
 
 
 /*
  * multiuser chat
  */
-void do_chat(void) {
-
-        printf("HTTP/1.0 200 OK\n");
-        output_headers(1, "bottom");
-
-        wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
-        wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
-        wprintf("<B>Real-time chat</B>\n");
-        wprintf("</FONT></TD></TR></TABLE>\n");
-
-       wprintf("A chat window should be appearing on your screen ");
-       wprintf("momentarily.  When you're ");
-       wprintf("done, type <TT>/quit</TT> to exit.  You can also ");
-       wprintf("type <TT>/help</TT> for more commands.\n");
-
-       wprintf("<applet codebase=\"/static\" ");
-       wprintf("code=\"wcchat\" width=2 height=2>\n");
-       wprintf("<PARAM NAME=username VALUE=\"%s\">\n", wc_username);
-       wprintf("<PARAM NAME=password VALUE=\"%s\">\n", wc_password);
-       wprintf("<H2>Oops!</H2>Looks like your browser doesn't support Java, ");
-       wprintf("so you won't be able to access Chat.  Sorry.\n");
-       wprintf("</applet>\n");
-        wDumpContent(1);
+void do_chat(void)
+{
+
+       output_headers(1);
+
+       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#000077\"><TR><TD>");
+       wprintf("<SPAN CLASS=\"titlebar\">Real-time chat</SPAN>\n");
+       wprintf("</TD></TR></TABLE>\n");
+
+       if (!strcasecmp(ctdlhost, "uds")) {
+               wprintf("<I>Sorry ... chat is not available here.</i></BR>\n");
        }
+       else {
+               wprintf("A chat window should be appearing on your screen ");
+               wprintf("momentarily.  When you're ");
+               wprintf("done, type <TT>/quit</TT> to exit.  You can also ");
+               wprintf("type <TT>/help</TT> for more commands.\n");
+       
+               wprintf("<applet codebase=\"/static\" ");
+               wprintf("code=\"wcchat\" width=2 height=2>\n");
+               wprintf("<PARAM NAME=username VALUE=\"%s\">\n", WC->wc_username);
+               wprintf("<PARAM NAME=password VALUE=\"%s\">\n", WC->wc_password);
+               wprintf("<PARAM NAME=roomname VALUE=\"%s\">\n", WC->wc_roomname);
+               wprintf("<H2>Oops!</H2>Looks like your browser doesn't support Java, ");
+               wprintf("so you won't be able to access Chat.  Sorry.\n");
+               wprintf("</applet>\n");
+       }
+       wDumpContent(1);
+}
+
+
+/*
+ *
+ */
+void page_popup(void)
+{
+       char buf[SIZ];
+       char pagefrom[SIZ];
+
+       /* suppress express message check, do headers but no fake frames */
+       output_headers(0x08 | 0x03);
+
+       while (serv_puts("GEXP"), serv_gets(buf), buf[0]=='1') {
+
+               extract(pagefrom, &buf[4], 3);
+
+               wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#007700\"><TR><TD>");
+               wprintf("<SPAN CLASS=\"titlebar\">Express message from ");
+               escputs(pagefrom);
+               wprintf("</SPAN></TD></TR></TABLE>\n");
+               
+               fmout(NULL);
+       }
+
+       wprintf("<CENTER>");
+       wprintf("<A HREF=\"/display_page&closewin=yes&recp=");
+       urlescputs(pagefrom);
+        wprintf("\">[ reply ]</A>&nbsp;&nbsp;&nbsp;\n");
+
+       wprintf("<A HREF=\"javascript:window.close();\">"
+               "[ close window ]</A></B>\n"
+               "</CENTER>");
+
+       wDumpContent(1);
+       WC->HaveExpressMessages = 0;
+}
+
+