* wDumpContent() is now responsible for </BODY></HTML> most of the
[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         wDumpContent(1);
60         }
61
62 /*
63  * page another user
64 */
65 void page_user(void) {
66         char recp[256];
67         char msgtext[256];
68         char sc[256];
69         char buf[256];
70         
71         printf("HTTP/1.0 200 OK\n");
72         output_headers(1, "bottom");
73
74         strcpy(recp,bstr("recp"));
75         strcpy(msgtext,bstr("msgtext"));
76         strcpy(sc,bstr("sc"));
77
78         if (strcmp(sc,"Send message")) {
79                 wprintf("<EM>Message was not sent.</EM><BR>\n");
80                 return;
81                 }
82
83         serv_printf("SEXP %s|%s",recp,msgtext);
84         serv_gets(buf); 
85
86         if (buf[0] == '2') {
87                 wprintf("<EM>Message has been sent to ");
88                 escputs(recp);
89                 wprintf(".</EM><BR>\n");
90                 }
91         else {
92                 wprintf("<EM>%s</EM><BR>\n",&buf[4]);
93                 }
94
95         wDumpContent(1);
96         }
97
98
99
100 /*
101  * multiuser chat
102  */
103 void do_chat(void) {
104
105         printf("HTTP/1.0 200 OK\n");
106         output_headers(1, "bottom");
107
108         wprintf("<TABLE WIDTH=100% BORDER=0 BGCOLOR=000077><TR><TD>");
109         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
110         wprintf("<B>Real-time chat</B>\n");
111         wprintf("</FONT></TD></TR></TABLE>\n");
112
113         wprintf("A chat window should be appearing on your screen ");
114         wprintf("momentarily.  When you're ");
115         wprintf("done, type <TT>/quit</TT> to exit.  You can also ");
116         wprintf("type <TT>/help</TT> for more commands.\n");
117
118         wprintf("<applet codebase=\"/static\" ");
119         wprintf("code=\"wcchat\" width=2 height=2>\n");
120         wprintf("<PARAM NAME=username VALUE=\"%s\">\n", wc_username);
121         wprintf("<PARAM NAME=password VALUE=\"%s\">\n", wc_password);
122         wprintf("<H2>Oops!</H2>Looks like your browser doesn't support Java, ");
123         wprintf("so you won't be able to access Chat.  Sorry.\n");
124         wprintf("</applet>\n");
125         wDumpContent(1);
126         }