* Added a "summary" page (rather sparse for now)
authorArt Cancro <ajc@citadel.org>
Mon, 26 Aug 2002 01:24:09 +0000 (01:24 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 26 Aug 2002 01:24:09 +0000 (01:24 +0000)
webcit/ChangeLog
webcit/Makefile.in
webcit/mainmenu.c
webcit/roomops.c
webcit/summary.c [new file with mode: 0644]
webcit/webcit.c
webcit/webcit.h

index 6a12ae69b602fc2118e59a7902d8ce36159917b6..d7ccc390a701eeb682e92df404a2a8b039e339c4 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 323.65  2002/08/26 01:24:09  ajc
+* Added a "summary" page (rather sparse for now)
+
 Revision 323.64  2002/08/24 15:30:48  ajc
 * GET instead of POST for listsub.  Also add a 'Back...' link.
 
@@ -919,3 +922,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index dbe67e24838c02c6a6ac5ff9a4a3d3cec657f0dc..1c8fe12d254b28f926cdf2cfa702b151a60ebd13 100644 (file)
@@ -23,7 +23,7 @@ distclean: clean
 
 
 webserver: webserver.o context_loop.o tools.o \
-       cookie_conversion.o locate_host.o floors.o \
+       cookie_conversion.o locate_host.o floors.o summary.o \
        webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o \
        roomops.o messages.o userlist.o paging.o sysmsgs.o useredit.o \
        vcard.o vcard_edit.o preferences.o html2html.o listsub.o \
@@ -33,6 +33,7 @@ webserver: webserver.o context_loop.o tools.o \
        roomops.o messages.o userlist.o paging.o sysmsgs.o useredit.o \
        locate_host.o siteconfig.o subst.o vcard.o vcard_edit.o floors.o \
        mime_parser.o graphics.o netconf.o preferences.o html2html.o \
+       summary.o \
        $(LIBOBJS) $(LIBS) -o webserver
 
 .c.o:
index 2957e6db441f4e533d25230d391e6169aa516374..5305ca63e9d506845fe1a7c3188ad8c112793b38 100644 (file)
@@ -79,8 +79,8 @@ void display_main_menu(void)
        wprintf("</TD><TD>");   /* start of third column */
 
        wprintf("<UL>");
-       wprintf("<LI><B><A HREF=\"/whobbs\">\n");
-       wprintf("Who is online?</B></A><BR>(users <EM>currently</EM> logged on)</LI>\n");
+       wprintf("<LI><B><A HREF=\"/summary\">\n");
+       wprintf("Summary page</B></A><BR>Summary of my account</LI>\n");
 
        wprintf("<LI><B><A HREF=\"/userlist\">\n");
        wprintf("User list</B></A><BR>(all registered users)</LI>\n");
@@ -99,6 +99,9 @@ void display_main_menu(void)
        wprintf("</FONT></TD></TR></TABLE>\n");
 
        wprintf("<UL>");
+       wprintf("<LI><A HREF=\"/whobbs\">\n");
+       wprintf("Who is online?</A><font size=-2> "
+               "(users <EM>currently</EM> logged on)</font>\n");
        wprintf("<LI><A HREF=\"/chat\">");
        wprintf("Chat with other online users</A>\n");
 
@@ -318,3 +321,5 @@ void display_menubar(int as_single_page) {
 
 
 }
+
+
index c943f7104a2085cc014d23a6da3a17a6d9bb4de6..67269cf276716507749253ac173df84546a5a7df 100644 (file)
@@ -1797,6 +1797,7 @@ void folders(void) {
        char buf[SIZ];
 
        int levels, oldlevels;
+       int swap = 0;
 
        struct folder {
                char room[SIZ];
@@ -1810,7 +1811,7 @@ void folders(void) {
        struct folder ftmp;
        int max_folders = 0;
        int alloc_folders = 0;
-       int i, j, k;
+       int i, j, k, t;
        int p;
        int flags;
        int floor;
@@ -1822,6 +1823,7 @@ void folders(void) {
        fold = malloc(sizeof(struct folder));
        memset(fold, 0, sizeof(struct folder));
        strcpy(fold[0].name, "My folders");
+       fold[0].is_mailbox = 1;
 
        /* Then add floors */
        serv_puts("LFLR");
@@ -1868,7 +1870,19 @@ void folders(void) {
        /* Bubble-sort the folder list */
        for (i=0; i<max_folders; ++i) {
                for (j=0; j<(max_folders-1)-i; ++j) {
-                       if (strcasecmp(fold[j].name, fold[j+1].name) > 0) {
+                       if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
+                               swap = strcasecmp(fold[j].name, fold[j+1].name);
+                       }
+                       else {
+                               if ( (fold[j+1].is_mailbox)
+                                  && (!fold[j].is_mailbox)) {
+                                       swap = 1;
+                               }
+                               else {
+                                       swap = 0;
+                               }
+                       }
+                       if (swap > 0) {
                                memcpy(&ftmp, &fold[j], sizeof(struct folder));
                                memcpy(&fold[j], &fold[j+1],
                                                        sizeof(struct folder));
@@ -1887,31 +1901,41 @@ void folders(void) {
                levels = num_tokens(fold[i].name, '|');
                if (levels > oldlevels) {
                        for (k=0; k<(levels-oldlevels); ++k) {
-                               wprintf("<UL>");
                                ++nests;
                        }
                }
                if (levels < oldlevels) {
                        for (k=0; k<(oldlevels-levels); ++k) {
-                               wprintf("</UL>");
                                --nests;
                        }
                }
                oldlevels = levels;
 
-               wprintf("<LI>");
+               for (t=0; t<nests; ++t) wprintf("&nbsp;&nbsp;&nbsp;");
                if (fold[i].selectable) {
                        wprintf("<A HREF=\"/dotgoto?room=");
                        urlescputs(fold[i].room);
                        wprintf("\">");
                }
+               else {
+                       wprintf("<i>");
+               }
                if (fold[i].hasnewmsgs) wprintf("<B>");
                extract(buf, fold[i].name, levels-1);
                escputs(buf);
                if (fold[i].hasnewmsgs) wprintf("</B>");
-               if (fold[i].selectable) wprintf("</A>\n");
+               if (fold[i].selectable) {
+                       wprintf("</A>");
+               }
+               else {
+                       wprintf("</i>");
+               }
+               if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
+                       wprintf(" (INBOX)");
+               }
+               wprintf("<BR>\n");
        }
-       while (nests-- > 0) wprintf("</UL>\n");
+       while (nests-- > 0) ;; 
 
        free(fold);
        wDumpContent(1);
diff --git a/webcit/summary.c b/webcit/summary.c
new file mode 100644 (file)
index 0000000..5c5bdf9
--- /dev/null
@@ -0,0 +1,186 @@
+/* $Id$ */
+
+
+
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <limits.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <string.h>
+#include <time.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include <signal.h>
+#include "webcit.h"
+
+/*
+ * Display today's date in a friendly format
+ */
+void output_date(void) {
+       struct tm tm;
+       time_t now;
+
+       static char *wdays[] = {
+               "Sunday", "Monday", "Tuesday", "Wednesday",
+               "Thursday", "Friday", "Saturday"
+       };
+       static char *months[] = {
+               "January", "February", "March", "April", "May", "June", "July",
+               "August", "September", "October", "November", "December"
+       };
+
+       time(&now);
+       localtime_r(&now, &tm);
+
+       wprintf("%s, %s %d, %d",
+               wdays[tm.tm_wday],
+               months[tm.tm_mon],
+               tm.tm_mday,
+               tm.tm_year + 1900
+       );
+}
+
+
+
+/*
+ * Display the title bar for a section
+ */
+void section_title(char *title) {
+
+       wprintf("<TABLE width=100%% border=0 cellpadding=5 cellspacing=0>"
+               "<TR><TD BGCOLOR=444455>"
+               "<FONT COLOR=FFFFEE>");
+       escputs(title);
+       wprintf("</FONT></TD></TR></TABLE>\n");
+}
+
+
+/*
+ * Dummy section
+ */
+void dummy_section(void) {
+       section_title("---");
+}
+
+
+/*
+ * New messages section
+ */
+void new_messages_section(void) {
+       char buf[SIZ];
+       char room[SIZ];
+       int i;
+       int number_of_rooms_to_check;
+       char *rooms_to_check = "Mail|Lobby";
+
+       section_title("Messages");
+
+       number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
+       if (number_of_rooms_to_check == 0) return;
+
+       wprintf("<TABLE BORDER=0 WIDTH=100%%>\n");
+       for (i=0; i<number_of_rooms_to_check; ++i) {
+               extract(room, rooms_to_check, i);
+
+               serv_printf("GOTO %s", room);
+               serv_gets(buf);
+               if (buf[0] == '2') {
+                       extract(room, &buf[4], 0);
+                       wprintf("<TR><TD>");
+                       escputs(room);
+                       wprintf("</TD><TD>%d/%d</TD></TR>\n",
+                               extract_int(&buf[4], 1),
+                               extract_int(&buf[4], 2)
+                       );
+               }
+       }
+       wprintf("</TABLE>\n");
+
+}
+
+
+/*
+ * Wholist section
+ */
+void wholist_section(void) {
+       char buf[SIZ];
+       char user[SIZ];
+
+       section_title("Who's online now");
+       serv_puts("RWHO");
+       serv_gets(buf);
+       if (buf[0] == '1') while(serv_gets(buf), strcmp(buf, "000")) {
+               extract(user, buf, 1);
+               escputs(user);
+               wprintf("<BR>\n");
+       }
+}
+
+
+
+
+/*
+ * Display this user's summary page
+ */
+void summary(void) {
+       output_headers(7);
+
+       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>"
+               "<FONT SIZE=+1 COLOR=\"FFFFFF\""
+               "<B>Summary page for ");
+       escputs(WC->wc_username);
+       wprintf("</B><FONT></TD><TD>\n");
+       offer_start_page();
+       wprintf("</TD></TR></TABLE>\n");
+
+       wprintf("<DIV ALIGN=RIGHT>");
+       output_date();
+       wprintf("</DIV>\n");
+
+       /*
+        * Now let's do three columns of crap.  All portals and all groupware
+        * clients seem to want to do three columns, so we'll do three
+        * columns too.  Conformity is not inherently a virtue, but there are
+        * a lot of really shallow people out there, and even though they're
+        * not people I consider worthwhile, I still want them to use WebCit.
+        */
+
+       wprintf("<TABLE WIDTH=100%% BORDER=0 CELLPADDING=10><TR VALIGN=TOP>");
+
+       /*
+        * Column One
+        */
+       wprintf("<TD>");
+       wholist_section();
+
+       /*
+        * Column Two
+        */
+       wprintf("</TD><TD>");
+       dummy_section();
+
+       /*
+        * Column Three
+        */
+       wprintf("</TD><TD>");
+       new_messages_section();
+
+       /*
+        * End of columns
+        */
+       wprintf("</TD></TR></TABLE>\n");
+
+       wDumpContent(1);
+}
index 3a6f13ec919489d47f507934f1e0bc3aa521e823..47b909a78e60f2b0f4e8f74905443ee0274eafea 100644 (file)
@@ -1153,6 +1153,8 @@ void session_loop(struct httprequest *req)
                display_floorconfig(NULL);
        } else if (!strcasecmp(action, "toggle_self_service")) {
                toggle_self_service();
+       } else if (!strcasecmp(action, "summary")) {
+               summary();
        } else if (!strcasecmp(action, "diagnostics")) {
                output_headers(1);
 
index 62ed9e26e401e26bceb95c847c3e0fd9d64bc027..a656ebcf10dd3408358d0d06ebf1f226f15cc641 100644 (file)
@@ -331,3 +331,4 @@ void create_floor(void);
 void rename_floor(void);
 void do_listsub(void);
 void toggle_self_service(void);
+void summary(void);