]> code.citadel.org Git - citadel.git/blob - webcit/summary.c
* Added a "summary" page (rather sparse for now)
[citadel.git] / webcit / summary.c
1 /* $Id$ */
2
3
4
5
6 #include <ctype.h>
7 #include <stdlib.h>
8 #include <unistd.h>
9 #include <stdio.h>
10 #include <fcntl.h>
11 #include <signal.h>
12 #include <sys/types.h>
13 #include <sys/wait.h>
14 #include <sys/socket.h>
15 #include <sys/time.h>
16 #include <limits.h>
17 #include <netinet/in.h>
18 #include <netdb.h>
19 #include <string.h>
20 #include <time.h>
21 #include <pwd.h>
22 #include <errno.h>
23 #include <stdarg.h>
24 #include <pthread.h>
25 #include <signal.h>
26 #include "webcit.h"
27
28 /*
29  * Display today's date in a friendly format
30  */
31 void output_date(void) {
32         struct tm tm;
33         time_t now;
34
35         static char *wdays[] = {
36                 "Sunday", "Monday", "Tuesday", "Wednesday",
37                 "Thursday", "Friday", "Saturday"
38         };
39         static char *months[] = {
40                 "January", "February", "March", "April", "May", "June", "July",
41                 "August", "September", "October", "November", "December"
42         };
43
44         time(&now);
45         localtime_r(&now, &tm);
46
47         wprintf("%s, %s %d, %d",
48                 wdays[tm.tm_wday],
49                 months[tm.tm_mon],
50                 tm.tm_mday,
51                 tm.tm_year + 1900
52         );
53 }
54
55
56
57 /*
58  * Display the title bar for a section
59  */
60 void section_title(char *title) {
61
62         wprintf("<TABLE width=100%% border=0 cellpadding=5 cellspacing=0>"
63                 "<TR><TD BGCOLOR=444455>"
64                 "<FONT COLOR=FFFFEE>");
65         escputs(title);
66         wprintf("</FONT></TD></TR></TABLE>\n");
67 }
68
69
70 /*
71  * Dummy section
72  */
73 void dummy_section(void) {
74         section_title("---");
75 }
76
77
78 /*
79  * New messages section
80  */
81 void new_messages_section(void) {
82         char buf[SIZ];
83         char room[SIZ];
84         int i;
85         int number_of_rooms_to_check;
86         char *rooms_to_check = "Mail|Lobby";
87
88         section_title("Messages");
89
90         number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
91         if (number_of_rooms_to_check == 0) return;
92
93         wprintf("<TABLE BORDER=0 WIDTH=100%%>\n");
94         for (i=0; i<number_of_rooms_to_check; ++i) {
95                 extract(room, rooms_to_check, i);
96
97                 serv_printf("GOTO %s", room);
98                 serv_gets(buf);
99                 if (buf[0] == '2') {
100                         extract(room, &buf[4], 0);
101                         wprintf("<TR><TD>");
102                         escputs(room);
103                         wprintf("</TD><TD>%d/%d</TD></TR>\n",
104                                 extract_int(&buf[4], 1),
105                                 extract_int(&buf[4], 2)
106                         );
107                 }
108         }
109         wprintf("</TABLE>\n");
110
111 }
112
113
114 /*
115  * Wholist section
116  */
117 void wholist_section(void) {
118         char buf[SIZ];
119         char user[SIZ];
120
121         section_title("Who's online now");
122         serv_puts("RWHO");
123         serv_gets(buf);
124         if (buf[0] == '1') while(serv_gets(buf), strcmp(buf, "000")) {
125                 extract(user, buf, 1);
126                 escputs(user);
127                 wprintf("<BR>\n");
128         }
129 }
130
131
132
133
134 /*
135  * Display this user's summary page
136  */
137 void summary(void) {
138         output_headers(7);
139
140         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>"
141                 "<FONT SIZE=+1 COLOR=\"FFFFFF\""
142                 "<B>Summary page for ");
143         escputs(WC->wc_username);
144         wprintf("</B><FONT></TD><TD>\n");
145         offer_start_page();
146         wprintf("</TD></TR></TABLE>\n");
147
148         wprintf("<DIV ALIGN=RIGHT>");
149         output_date();
150         wprintf("</DIV>\n");
151
152         /*
153          * Now let's do three columns of crap.  All portals and all groupware
154          * clients seem to want to do three columns, so we'll do three
155          * columns too.  Conformity is not inherently a virtue, but there are
156          * a lot of really shallow people out there, and even though they're
157          * not people I consider worthwhile, I still want them to use WebCit.
158          */
159
160         wprintf("<TABLE WIDTH=100%% BORDER=0 CELLPADDING=10><TR VALIGN=TOP>");
161
162         /*
163          * Column One
164          */
165         wprintf("<TD>");
166         wholist_section();
167
168         /*
169          * Column Two
170          */
171         wprintf("</TD><TD>");
172         dummy_section();
173
174         /*
175          * Column Three
176          */
177         wprintf("</TD><TD>");
178         new_messages_section();
179
180         /*
181          * End of columns
182          */
183         wprintf("</TD></TR></TABLE>\n");
184
185         wDumpContent(1);
186 }