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