* Made the frames stuff less dependent on the HTML TARGET= directive
[citadel.git] / webcit / paging.c
1 /* $Id$ */
2
3 #include <stdlib.h>
4 #ifdef HAVE_UNISTD_H
5 #include <unistd.h>
6 #endif
7 #include <stdio.h>
8 #include <signal.h>
9 #include <sys/types.h>
10 #include <ctype.h>
11 #include <string.h>
12 #include "webcit.h"
13 #include "child.h"
14
15 /*
16  * display the form for paging (x-messaging) another user
17  */
18 void display_page(void) {
19         char buf[256];
20         char user[256];
21
22         printf("HTTP/1.0 200 OK\n");
23         output_headers(1, "bottom");
24
25         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=007700><TR><TD>");
26         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
27         wprintf("<B>Page another user</B>\n");
28         wprintf("</FONT></TD></TR></TABLE>\n");
29
30         wprintf("This command sends a near-real-time message to any currently\n");
31         wprintf("logged in user.<BR><BR>\n");
32
33         wprintf("<FORM METHOD=\"POST\" ACTION=\"/page_user\">\n");
34
35         wprintf("Select a user to send a message to: <BR>");
36
37         wprintf("<SELECT NAME=\"recp\" SIZE=10>\n");
38         serv_puts("RWHO");
39         serv_gets(buf);
40         if (buf[0]=='1') {
41                 while(serv_gets(buf), strcmp(buf,"000")) {
42                         extract(user,buf,1);
43                         wprintf("<OPTION>");
44                         escputs(user);
45                         wprintf("\n");
46                         }
47                 }
48         wprintf("</SELECT>\n");
49         wprintf("<BR>\n");
50
51         wprintf("Enter message text:<BR>");
52         wprintf("<INPUT TYPE=\"text\" NAME=\"msgtext\" MAXLENGTH=80 SIZE=80>\n");
53         wprintf("<BR><BR>\n");
54
55         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Send message\">");
56         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\"><BR>\n");
57
58         wprintf("</FORM></CENTER>\n");
59         wprintf("</BODY></HTML>\n");
60         wDumpContent();
61         }
62
63 /*
64  * page another user
65 */
66 void page_user(void) {
67         char recp[256];
68         char msgtext[256];
69         char sc[256];
70         char buf[256];
71         
72         printf("HTTP/1.0 200 OK\n");
73         output_headers(1, "bottom");
74
75         strcpy(recp,bstr("recp"));
76         strcpy(msgtext,bstr("msgtext"));
77         strcpy(sc,bstr("sc"));
78
79         if (strcmp(sc,"Send message")) {
80                 wprintf("<EM>Message was not sent.</EM><BR>\n");
81                 return;
82                 }
83
84         serv_printf("SEXP %s|%s",recp,msgtext);
85         serv_gets(buf); 
86
87         if (buf[0] == '2') {
88                 wprintf("<EM>Message has been sent to ");
89                 escputs(recp);
90                 wprintf(".</EM><BR>\n");
91                 }
92         else {
93                 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
94                 }
95
96         wprintf("</BODY></HTML>\n");
97         wDumpContent();
98         }
99
100
101
102 /*
103  * multiuser chat
104  */
105 void do_chat(void) {
106
107         printf("HTTP/1.0 200 OK\n");
108         output_headers(1, "bottom");
109
110         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
111         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
112         wprintf("<B>Real-time chat</B>\n");
113         wprintf("</FONT></TD></TR></TABLE>\n");
114
115         wprintf("A chat window should be appearing on your screen ");
116         wprintf("momentarily.  When you're ");
117         wprintf("done, type <TT>/quit</TT> to exit.  You can also ");
118         wprintf("type <TT>/help</TT> for more commands.\n");
119
120         wprintf("<applet codebase=\"/static\" ");
121         wprintf("code=\"wcchat\" width=2 height=2>\n");
122         wprintf("<PARAM NAME=username VALUE=\"%s\">\n", wc_username);
123         wprintf("<PARAM NAME=password VALUE=\"%s\">\n", wc_password);
124         wprintf("<H2>Oops!</H2>Looks like your browser doesn't support Java, ");
125         wprintf("so you won't be able to access Chat.  Sorry.\n");
126         wprintf("</applet>\n");
127         wprintf("</BODY></HTML>\n");
128         wDumpContent();
129         }