* "reply" button on pop-up pages
[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("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
38         wprintf("<B>Page another user</B>\n");
39         wprintf("</FONT></TD></TR></TABLE>\n");
40
41         wprintf("<CENTER>This will send a page (instant message) "
42                 "to %s.\n", recp);
43
44         wprintf("<FORM METHOD=\"POST\" ACTION=\"/page_user\">\n");
45
46
47         wprintf("<TABLE border=0 width=100%%><TR><TD>\n");
48
49         wprintf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"");
50         escputs(recp);
51         wprintf("\">\n");
52
53         wprintf("<INPUT TYPE=\"hidden\" NAME=\"closewin\" VALUE=\"");
54         escputs(bstr("closewin"));
55         wprintf("\">\n");
56
57         wprintf("Enter message text:<BR>");
58
59         wprintf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=5 COLS=40 "
60                 "WIDTH=40></TEXTAREA>\n");
61
62         wprintf("</TD></TR></TABLE><BR>\n");
63
64         wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Send message\">");
65         wprintf("<BR><A HREF=\"javascript:window.close();\"Cancel</A>\n");
66
67         wprintf("</FORM></CENTER>\n");
68         wDumpContent(1);
69 }
70
71 /*
72  * page another user
73  */
74 void page_user(void)
75 {
76         char recp[SIZ];
77         char sc[SIZ];
78         char buf[SIZ];
79         char closewin[SIZ];
80
81         output_headers(1);
82
83         strcpy(recp, bstr("recp"));
84         strcpy(sc, bstr("sc"));
85         strcpy(closewin, bstr("closewin"));
86
87         if (strcmp(sc, "Send message")) {
88                 wprintf("<EM>Message was not sent.</EM><BR>\n");
89         } else {
90                 serv_printf("SEXP %s|-", recp);
91                 serv_gets(buf);
92
93                 if (buf[0] == '4') {
94                         text_to_server(bstr("msgtext"));
95                         serv_puts("000");
96                         wprintf("<EM>Message has been sent to ");
97                         escputs(recp);
98                         wprintf(".</EM><BR>\n");
99                 }
100                 else {
101                         wprintf("<EM>%s</EM><BR>\n", &buf[4]);
102                 }
103         }
104         
105         if (!strcasecmp(closewin, "yes")) {
106                 wprintf("<CENTER><A HREF=\"javascript:window.close();\">"
107                         "[ close window ]</A></CENTER>\n");
108         }
109
110         wDumpContent(1);
111 }
112
113
114
115 /*
116  * multiuser chat
117  */
118 void do_chat(void)
119 {
120
121         output_headers(1);
122
123         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=000077><TR><TD>");
124         wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\"");
125         wprintf("<B>Real-time chat</B>\n");
126         wprintf("</FONT></TD></TR></TABLE>\n");
127
128         wprintf("A chat window should be appearing on your screen ");
129         wprintf("momentarily.  When you're ");
130         wprintf("done, type <TT>/quit</TT> to exit.  You can also ");
131         wprintf("type <TT>/help</TT> for more commands.\n");
132
133         wprintf("<applet codebase=\"/static\" ");
134         wprintf("code=\"wcchat\" width=2 height=2>\n");
135         wprintf("<PARAM NAME=username VALUE=\"%s\">\n", WC->wc_username);
136         wprintf("<PARAM NAME=password VALUE=\"%s\">\n", WC->wc_password);
137         wprintf("<PARAM NAME=roomname VALUE=\"%s\">\n", WC->wc_roomname);
138         wprintf("<H2>Oops!</H2>Looks like your browser doesn't support Java, ");
139         wprintf("so you won't be able to access Chat.  Sorry.\n");
140         wprintf("</applet>\n");
141         wDumpContent(1);
142 }
143
144
145 /*
146  *
147  */
148 void page_popup(void)
149 {
150         char buf[SIZ];
151         char pagefrom[SIZ];
152
153         /* suppress express message check, do headers but no fake frames */
154         output_headers(0x08 | 0x03);
155
156         while (serv_puts("GEXP"), serv_gets(buf), buf[0]=='1') {
157
158                 extract(pagefrom, &buf[4], 3);
159
160                 wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>");
161                 wprintf("<FONT SIZE=+1 COLOR=\"FFFFFF\""
162                         "<B>Express message from ");
163                 escputs(pagefrom);
164                 wprintf("</B></FONT></TD></TR></TABLE>\n");
165                 
166                 fmout(NULL);
167         }
168
169         wprintf("<CENTER>");
170         wprintf("<A HREF=\"/display_page&closewin=yes&recp=");
171         urlescputs(pagefrom);
172         wprintf("\">[ reply ]</A>&nbsp;&nbsp;&nbsp;\n");
173
174         wprintf("<A HREF=\"javascript:window.close();\">"
175                 "[ close window ]</A></B>\n"
176                 "</CENTER>");
177
178         wDumpContent(1);
179         WC->HaveExpressMessages = 0;
180 }
181
182