From 75f90e7b72f73c7758fc209116f40a598c4b1bbd Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 26 Aug 2002 01:24:09 +0000 Subject: [PATCH] * Added a "summary" page (rather sparse for now) --- webcit/ChangeLog | 4 + webcit/Makefile.in | 3 +- webcit/mainmenu.c | 9 ++- webcit/roomops.c | 38 +++++++-- webcit/summary.c | 186 +++++++++++++++++++++++++++++++++++++++++++++ webcit/webcit.c | 2 + webcit/webcit.h | 1 + 7 files changed, 233 insertions(+), 10 deletions(-) create mode 100644 webcit/summary.c diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 6a12ae69b..d7ccc390a 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -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 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/Makefile.in b/webcit/Makefile.in index dbe67e248..1c8fe12d2 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -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: diff --git a/webcit/mainmenu.c b/webcit/mainmenu.c index 2957e6db4..5305ca63e 100644 --- a/webcit/mainmenu.c +++ b/webcit/mainmenu.c @@ -79,8 +79,8 @@ void display_main_menu(void) wprintf(""); /* start of third column */ wprintf("
    "); - wprintf("
  • \n"); - wprintf("Who is online?
    (users currently logged on)
  • \n"); + wprintf("
  • \n"); + wprintf("Summary page
    Summary of my account
  • \n"); wprintf("
  • \n"); wprintf("User list
    (all registered users)
  • \n"); @@ -99,6 +99,9 @@ void display_main_menu(void) wprintf("\n"); wprintf("
      "); + wprintf("
    • \n"); + wprintf("Who is online? " + "(users currently logged on)\n"); wprintf("
    • "); wprintf("Chat with other online users\n"); @@ -318,3 +321,5 @@ void display_menubar(int as_single_page) { } + + diff --git a/webcit/roomops.c b/webcit/roomops.c index c943f7104..67269cf27 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -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 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("
        "); ++nests; } } if (levels < oldlevels) { for (k=0; k<(oldlevels-levels); ++k) { - wprintf("
      "); --nests; } } oldlevels = levels; - wprintf("
    • "); + for (t=0; t"); } + else { + wprintf(""); + } if (fold[i].hasnewmsgs) wprintf(""); extract(buf, fold[i].name, levels-1); escputs(buf); if (fold[i].hasnewmsgs) wprintf(""); - if (fold[i].selectable) wprintf("\n"); + if (fold[i].selectable) { + wprintf(""); + } + else { + wprintf(""); + } + if (!strcasecmp(fold[i].name, "My Folders|Mail")) { + wprintf(" (INBOX)"); + } + wprintf("
      \n"); } - while (nests-- > 0) wprintf("
    \n"); + while (nests-- > 0) ;; free(fold); wDumpContent(1); diff --git a/webcit/summary.c b/webcit/summary.c new file mode 100644 index 000000000..5c5bdf944 --- /dev/null +++ b/webcit/summary.c @@ -0,0 +1,186 @@ +/* $Id$ */ + + + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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("" + "
    " + ""); + escputs(title); + wprintf("
    \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("\n"); + for (i=0; i\n", + extract_int(&buf[4], 1), + extract_int(&buf[4], 2) + ); + } + } + wprintf("
    "); + escputs(room); + wprintf("%d/%d
    \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("
    \n"); + } +} + + + + +/* + * Display this user's summary page + */ +void summary(void) { + output_headers(7); + + wprintf("
    " + "Summary page for "); + escputs(WC->wc_username); + wprintf("\n"); + offer_start_page(); + wprintf("
    \n"); + + wprintf("
    "); + output_date(); + wprintf("
    \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(""); + + /* + * Column One + */ + wprintf("
    "); + wholist_section(); + + /* + * Column Two + */ + wprintf(""); + dummy_section(); + + /* + * Column Three + */ + wprintf(""); + new_messages_section(); + + /* + * End of columns + */ + wprintf("
    \n"); + + wDumpContent(1); +} diff --git a/webcit/webcit.c b/webcit/webcit.c index 3a6f13ec9..47b909a78 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -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); diff --git a/webcit/webcit.h b/webcit/webcit.h index 62ed9e26e..a656ebcf1 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -331,3 +331,4 @@ void create_floor(void); void rename_floor(void); void do_listsub(void); void toggle_self_service(void); +void summary(void); -- 2.39.2