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