* Repaired all my b0rken COLOR tags
[citadel.git] / webcit / paging.c
1 /* $Id$ */
2
3 #include <ctype.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <stdio.h>
7 #include <fcntl.h>
8 #include <signal.h>
9 #include <sys/types.h>
10 #include <sys/wait.h>
11 #include <sys/socket.h>
12 #include <sys/time.h>
13 #include <limits.h>
14 #include <netinet/in.h>
15 #include <netdb.h>
16 #include <string.h>
17 #include <pwd.h>
18 #include <errno.h>
19 #include <stdarg.h>
20 #include <pthread.h>
21 #include <signal.h>
22 #include "webcit.h"
23
24
25 /*
26  * display the form for paging (x-messaging) another user
27  */
28 void display_page(void)
29 {
30         char recp[SIZ];
31
32         strcpy(recp, bstr("recp"));
33
34         output_headers(3);
35
36         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#007700\"><TR><TD>");
37         wprintf("<SPAN CLASS=\"titlebar\">Page another user</SPAN>\n");
38         wprintf("</TD></TR></TABLE>\n");
39
40         wprintf("<CENTER>This will send a page (instant message) "
41                 "to %s.\n", recp);
42
43         wprintf("<FORM METHOD=\"POST\" ACTION=\"/page_user\">\n");
44
45
46         wprintf("<TABLE border=0 width=100%%><TR><TD>\n");
47
48         wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"");
49         escputs(recp);
50         wprintf("\">\n");
51
52         wprintf("<INPUT TYPE=\"hidden\" NAME=\"closewin\" VALUE=\"");
53         escputs(bstr("closewin"));
54         wprintf("\">\n");
55
56         wprintf("Enter message text:<BR>");
57
58         wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=5 COLS=40 "
59                 "WIDTH=40></TEXTAREA>\n");
60
61         wprintf("</TD></TR></TABLE><BR>\n");
62
63         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Send message\">");
64         wprintf("<BR><A HREF=\"javascript:window.close();\"Cancel</A>\n");
65
66         wprintf("</FORM></CENTER>\n");
67         wDumpContent(1);
68 }
69
70 /*
71  * page another user
72  */
73 void page_user(void)
74 {
75         char recp[SIZ];
76         char sc[SIZ];
77         char buf[SIZ];
78         char closewin[SIZ];
79
80         output_headers(3);
81
82         strcpy(recp, bstr("recp"));
83         strcpy(sc, bstr("sc"));
84         strcpy(closewin, bstr("closewin"));
85
86         if (strcmp(sc, "Send message")) {
87                 wprintf("<EM>Message was not sent.</EM><BR>\n");
88         } else {
89                 serv_printf("SEXP %s|-", recp);
90                 serv_gets(buf);
91
92                 if (buf[0] == '4') {
93                         text_to_server(bstr("msgtext"), 0);
94                         serv_puts("000");
95                         wprintf("<EM>Message has been sent to ");
96                         escputs(recp);
97                         wprintf(".</EM><BR>\n");
98                 }
99                 else {
100                         wprintf("<EM>%s</EM><BR>\n", &buf[4]);
101                 }
102         }
103         
104         if (!strcasecmp(closewin, "yes")) {
105                 wprintf("<CENTER><A HREF=\"javascript:window.close();\">"
106                         "[ close window ]</A></CENTER>\n");
107         }
108
109         wDumpContent(1);
110 }
111
112
113
114 /*
115  * multiuser chat
116  */
117 void do_chat(void)
118 {
119
120         output_headers(1);
121
122         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#000077\"><TR><TD>");
123         wprintf("<SPAN CLASS=\"titlebar\">Real-time chat</SPAN>\n");
124         wprintf("</TD></TR></TABLE>\n");
125
126         if (!strcasecmp(ctdlhost, "uds")) {
127                 wprintf("<I>Sorry ... chat is not available here.</i></BR>\n");
128         }
129         else {
130                 wprintf("A chat window should be appearing on your screen ");
131                 wprintf("momentarily.  When you're ");
132                 wprintf("done, type <TT>/quit</TT> to exit.  You can also ");
133                 wprintf("type <TT>/help</TT> for more commands.\n");
134         
135                 wprintf("<applet codebase=\"/static\" ");
136                 wprintf("code=\"wcchat\" width=2 height=2>\n");
137                 wprintf("<PARAM NAME=username VALUE=\"%s\">\n", WC->wc_username);
138                 wprintf("<PARAM NAME=password VALUE=\"%s\">\n", WC->wc_password);
139                 wprintf("<PARAM NAME=roomname VALUE=\"%s\">\n", WC->wc_roomname);
140                 wprintf("<H2>Oops!</H2>Looks like your browser doesn't support Java, ");
141                 wprintf("so you won't be able to access Chat.  Sorry.\n");
142                 wprintf("</applet>\n");
143         }
144         wDumpContent(1);
145 }
146
147
148 /*
149  *
150  */
151 void page_popup(void)
152 {
153         char buf[SIZ];
154         char pagefrom[SIZ];
155
156         /* suppress express message check, do headers but no fake frames */
157         output_headers(0x08 | 0x03);
158
159         while (serv_puts("GEXP"), serv_gets(buf), buf[0]=='1') {
160
161                 extract(pagefrom, &buf[4], 3);
162
163                 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#007700\"><TR><TD>");
164                 wprintf("<SPAN CLASS=\"titlebar\">Express message from ");
165                 escputs(pagefrom);
166                 wprintf("</SPAN></TD></TR></TABLE>\n");
167                 
168                 fmout(NULL);
169         }
170
171         wprintf("<CENTER>");
172         wprintf("<A HREF=\"/display_page&closewin=yes&recp=");
173         urlescputs(pagefrom);
174         wprintf("\">[ reply ]</A>&nbsp;&nbsp;&nbsp;\n");
175
176         wprintf("<A HREF=\"javascript:window.close();\">"
177                 "[ close window ]</A></B>\n"
178                 "</CENTER>");
179
180         wDumpContent(1);
181         WC->HaveExpressMessages = 0;
182 }
183
184