From a88250f5f9ec75f1610817fe22a9a605b56a5ec2 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 21 Jun 2003 05:17:24 +0000 Subject: [PATCH] * Better alignment of system messages * Exterminated display_error() and replaced it with WC->ImportantMessage which is displayed in a bubble on top of whatever page you're on next. * Small cosmetic changes * Fixed some nesting problems in output_headers() --- webcit/ChangeLog | 8 +++++ webcit/auth.c | 18 ++++++----- webcit/graphics.c | 15 ++++++--- webcit/messages.c | 31 ++++++++++-------- webcit/netconf.c | 3 +- webcit/paging.c | 2 +- webcit/roomops.c | 68 ++++++++++++++++++++++++---------------- webcit/serv_func.c | 4 +-- webcit/siteconfig.c | 3 +- webcit/static/login.html | 2 +- webcit/static/style.css | 8 ++--- webcit/subst.c | 2 +- webcit/sysmsgs.c | 19 ++++++----- webcit/userlist.c | 2 +- webcit/webcit.c | 32 +++++++++---------- webcit/webcit.h | 4 +-- 16 files changed, 129 insertions(+), 92 deletions(-) diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 310b013a6..30036251d 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,11 @@ $Log$ +Revision 500.3 2003/06/21 05:17:21 ajc +* Better alignment of system messages +* Exterminated display_error() and replaced it with WC->ImportantMessage + which is displayed in a bubble on top of whatever page you're on next. +* Small cosmetic changes +* Fixed some nesting problems in output_headers() + Revision 500.2 2003/06/20 03:39:27 ajc * Optimization to floor layout in box view @@ -1492,3 +1499,4 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/auth.c b/webcit/auth.c index 04f755e2b..5f4477394 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -191,7 +191,7 @@ void do_logout(void) if (WC->serv_sock >= 0) { if (buf[0] == '1') { - fmout(NULL); + fmout(NULL, "CENTER"); } else { wprintf("Goodbye\n"); } @@ -337,7 +337,7 @@ void display_changepw(void) serv_puts("MESG changepw"); serv_gets(buf); if (buf[0] == '1') { - fmout(NULL); + fmout(NULL, "CENTER"); } wprintf("
\n"); @@ -366,20 +366,22 @@ void changepw(void) char newpass1[32], newpass2[32]; if (strcmp(bstr("action"), "Change")) { - display_error("Cancelled. Password was not changed."); + strcpy(WC->ImportantMessage, + "Cancelled. Password was not changed."); + display_main_menu(); return; } strcpy(newpass1, bstr("newpass1")); strcpy(newpass2, bstr("newpass2")); if (strcasecmp(newpass1, newpass2)) { - display_error("They don't match. Password was not changed."); + strcpy(WC->ImportantMessage, + "They don't match. Password was not changed."); + display_main_menu(); return; } serv_printf("SETP %s", newpass1); serv_gets(buf); - if (buf[0] == '2') - display_success(&buf[4]); - else - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); } diff --git a/webcit/graphics.c b/webcit/graphics.c index 9922e1dbf..3cfb9533c 100644 --- a/webcit/graphics.c +++ b/webcit/graphics.c @@ -27,7 +27,8 @@ void display_graphics_upload(char *description, char *check_cmd, char *uplurl) serv_puts(check_cmd); serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } output_headers(3); @@ -68,18 +69,23 @@ void do_graphics_upload(char *upl_cmd) int thisblock; if (!strcasecmp(bstr("sc"), "Cancel")) { + strcpy(WC->ImportantMessage, + "Graphics upload cancelled."); display_main_menu(); return; } if (WC->upload_length == 0) { - display_error("You didn't upload a file.\n"); + strcpy(WC->ImportantMessage, + "You didn't upload a file."); + display_main_menu(); return; } serv_puts(upl_cmd); serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } bytes_remaining = WC->upload_length; @@ -88,9 +94,10 @@ void do_graphics_upload(char *upl_cmd) serv_printf("WRIT %d", thisblock); serv_gets(buf); if (buf[0] != '7') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); serv_puts("UCLS 0"); serv_gets(buf); + display_main_menu(); return; } thisblock = extract_int(&buf[4], 0); diff --git a/webcit/messages.c b/webcit/messages.c index 3f2762f19..5988a9599 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -364,10 +364,13 @@ void read_message(long msgnum) { wprintf("\n" "\n"); - wprintf("\n", msgnum); + /*** "Read" button is now superfluous + *** + ***wprintf("\n", msgnum); + ***/ wprintf("
" - "Read" - "" + *** "Read" + *** "" "\n"); + sprintf(WC->ImportantMessage, + "Cancelled. Message was not posted."); } else if (atol(bstr("postseq")) == dont_post) { - wprintf("Automatically cancelled because you have already " - "saved this message.
\n"); + sprintf(WC->ImportantMessage, + "Automatically cancelled because you have already " + "saved this message."); } else { sprintf(buf, "ENT0 1|%s|0|4|%s", bstr("recp"), @@ -1103,15 +1106,17 @@ void post_message(void) serv_gets(buf); if (buf[0] == '4') { post_mime_to_server(); - wprintf("Message has been posted.
\n"); + sprintf(WC->ImportantMessage, + "Message has been posted.\n"); dont_post = atol(bstr("postseq")); } else { - wprintf("%s
\n", &buf[4]); + sprintf(WC->ImportantMessage, + "%s", &buf[4]); } } - wDumpContent(1); free_attachments(WC); + readloop("readnew"); } diff --git a/webcit/netconf.c b/webcit/netconf.c index 211c2ef18..0131447cf 100644 --- a/webcit/netconf.c +++ b/webcit/netconf.c @@ -274,7 +274,8 @@ void add_node(void) wprintf("
Back to menu\n"); wDumpContent(1); } else { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_netconf(); } } } diff --git a/webcit/paging.c b/webcit/paging.c index 45514d545..690aa6db1 100644 --- a/webcit/paging.c +++ b/webcit/paging.c @@ -161,7 +161,7 @@ void page_popup(void) escputs(pagefrom); wprintf("
\n"); - fmout(NULL); + fmout(NULL, "LEFT"); } wprintf("
"); diff --git a/webcit/roomops.c b/webcit/roomops.c index aaac83ae6..8f580df66 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -301,7 +301,7 @@ void readinfo(void) serv_puts("RINF"); serv_gets(buf); if (buf[0] == '1') { - fmout(NULL); + fmout(NULL, "CENTER"); } } @@ -743,7 +743,8 @@ void display_editroom(void) serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } extract(er_name, &buf[4], 0); @@ -1178,14 +1179,17 @@ void editroom(void) if (strcmp(bstr("sc"), "OK")) { - display_error("Cancelled. Changes were not saved."); + strcpy(WC->ImportantMessage, + "Cancelled. Changes were not saved."); + display_main_menu(); return; } serv_puts("GETR"); serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } extract(er_name, &buf[4], 0); @@ -1291,7 +1295,8 @@ void editroom(void) serv_puts(buf); serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } gotoroom(er_name, 0); @@ -1301,7 +1306,8 @@ void editroom(void) serv_puts(buf); serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } } @@ -1319,28 +1325,24 @@ void display_whok(void) serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); - return; + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); + return; } extract(room, &buf[4], 0); strcpy(username, bstr("username")); - output_headers(1); - stresc(buf, WC->wc_roomname, 1); - svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf); - do_template("beginbox"); - if(!strcmp(bstr("sc"), "Kick")) { sprintf(buf, "KICK %s", username); serv_puts(buf); serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); - return; + strcpy(WC->ImportantMessage, &buf[4]); } else { - wprintf("User %s kicked out of room %s.\n", + sprintf(WC->ImportantMessage, + "User %s kicked out of room %s.\n", username, room); } } else if(!strcmp(bstr("sc"), "Invite")) { @@ -1349,15 +1351,18 @@ void display_whok(void) serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); - return; + strcpy(WC->ImportantMessage, &buf[4]); } else { - wprintf("User %s invited to room %s.\n", + sprintf(WC->ImportantMessage, + "User %s invited to room %s.\n", username, room); } } - + output_headers(1); + stresc(buf, WC->wc_roomname, 1); + svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf); + do_template("beginbox"); wprintf("" "
The users listed below have access to this room. " @@ -1411,7 +1416,8 @@ void display_entroom(void) serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } output_headers(3); @@ -1464,7 +1470,7 @@ void display_entroom(void) serv_printf("MESG roomaccess"); serv_gets(buf); if (buf[0] == '1') { - fmout(NULL); + fmout(NULL, "CENTER"); } do_template("endbox"); wDumpContent(1); @@ -1485,7 +1491,9 @@ void entroom(void) int er_num_type; if (strcmp(bstr("sc"), "OK")) { - display_error("Cancelled. No new room was created."); + strcpy(WC->ImportantMessage, + "Cancelled. No new room was created."); + display_main_menu(); return; } strcpy(er_name, bstr("er_name")); @@ -1508,7 +1516,8 @@ void entroom(void) serv_puts(buf); serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } smart_goto(er_name); @@ -1660,7 +1669,8 @@ void confirm_delete_room(void) serv_puts("KILL 0"); serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } output_headers(1); @@ -1694,13 +1704,17 @@ void delete_room(void) strcpy(sc, bstr("sc")); if (strcasecmp(sc, "Delete")) { - display_error("Cancelled. This room was not deleted."); + strcpy(WC->ImportantMessage, + "Cancelled. This room was not deleted."); + display_main_menu(); return; } serv_puts("KILL 1"); serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); + return; } else { smart_goto("_BASEROOM_"); } diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 40b911534..e99037e08 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -100,14 +100,14 @@ void get_serv_info(char *browser_host, char *user_agent) * If fp is non-null, it is considered to be the file handle to read the * text from. Otherwise, text is read from the server. */ -void fmout(FILE * fp) +void fmout(FILE *fp, char *align) { int intext = 0; int bq = 0; char buf[SIZ]; - wprintf("
\n"); + wprintf("
\n", align); while (1) { if (fp == NULL) serv_gets(buf); diff --git a/webcit/siteconfig.c b/webcit/siteconfig.c index dbe743ecf..239efb057 100644 --- a/webcit/siteconfig.c +++ b/webcit/siteconfig.c @@ -225,7 +225,8 @@ void siteconfig(void) serv_printf("CONF set"); serv_gets(buf); if (buf[0] != '4') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } serv_printf("%s", bstr("c_nodename")); diff --git a/webcit/static/login.html b/webcit/static/login.html index d80cf91b6..7fc2a9aae 100644 --- a/webcit/static/login.html +++ b/webcit/static/login.html @@ -4,7 +4,7 @@
-

+ diff --git a/webcit/static/style.css b/webcit/static/style.css index d34f52cae..82bfc3b8d 100644 --- a/webcit/static/style.css +++ b/webcit/static/style.css @@ -1,15 +1,15 @@ a:link { - color: #FF0000; + color: #0000FF; text-decoration: none; } a:visited { - color: #800080; + color: #0000FF; text-decoration: none; } a:active { - color: #00FF00; + color: #0000FF; text-decoration: none; } @@ -241,8 +241,6 @@ dt a { background: none } -.example { margin-left: 10% } - dfn { font-style: normal; font-weight: bolder diff --git a/webcit/subst.c b/webcit/subst.c index 97d00ed6f..87441c5e2 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -122,7 +122,7 @@ void pvo_do_cmd(char *servcmd) { wprintf("%s\n", &buf[4]); break; case '1': - fmout(NULL); + fmout(NULL, "CENTER"); break; case '4': wprintf("%s\n", &buf[4]); diff --git a/webcit/sysmsgs.c b/webcit/sysmsgs.c index 029bd0e45..d4b6545d4 100644 --- a/webcit/sysmsgs.c +++ b/webcit/sysmsgs.c @@ -40,7 +40,8 @@ void display_edit(char *description, char *check_cmd, serv_gets(buf); if (buf[0] != '2') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } output_headers(headers_type); @@ -78,15 +79,16 @@ void save_edit(char *description, char *enter_cmd, int regoto) char buf[SIZ]; if (strcmp(bstr("sc"), "Save")) { - output_headers(1); - wprintf("Cancelled. %s was not saved.
\n", description); - wDumpContent(1); + sprintf(WC->ImportantMessage, + "Cancelled. %s was not saved.\n", description); + display_main_menu(); return; } serv_puts(enter_cmd); serv_gets(buf); if (buf[0] != '4') { - display_error(&buf[4]); + strcpy(WC->ImportantMessage, &buf[4]); + display_main_menu(); return; } text_to_server(bstr("msgtext"), 0); @@ -95,8 +97,9 @@ void save_edit(char *description, char *enter_cmd, int regoto) if (regoto) { smart_goto(WC->wc_roomname); } else { - output_headers(1); - wprintf("%s has been saved.\n", description); - wDumpContent(1); + sprintf(WC->ImportantMessage, + "%s has been saved.\n", description); + display_main_menu(); + return; } } diff --git a/webcit/userlist.c b/webcit/userlist.c index 62190c1bb..a20028c02 100644 --- a/webcit/userlist.c +++ b/webcit/userlist.c @@ -141,7 +141,7 @@ void showuser(void) serv_printf("RBIO %s", who); serv_gets(buf); if (buf[0] == '1') { - fmout(NULL); + fmout(NULL, "JUSTIFY"); } wprintf("
wc_session, WC->wc_username, WC->wc_password, WC->wc_roomname); + if (print_standard_html_head == 2) { wprintf("Set-cookie: webcit=%s\n", unset); } else { @@ -346,14 +348,20 @@ void output_headers(int controlcode) do_template("background"); clear_local_substs(); + } if (print_standard_html_head == 1) { wprintf(""); - embed_room_banner(NULL); - - } } + + if (strlen(WC->ImportantMessage) > 0) { + do_template("beginbox_nt"); + wprintf("" + "%s
\n", WC->ImportantMessage); + do_template("endbox"); + strcpy(WC->ImportantMessage, ""); + } } @@ -628,7 +636,9 @@ void offer_start_page(void) { void change_start_page(void) { if (bstr("startpage") == NULL) { - display_error("startpage set to null"); + strcpy(WC->ImportantMessage, + "startpage set to null"); + display_main_menu(); return; } @@ -642,11 +652,6 @@ void change_start_page(void) { -void display_error(char *errormessage) -{ - convenience_page("770000", "Error", errormessage); -} - void display_success(char *successmessage) { convenience_page("007700", "OK", successmessage); @@ -693,9 +698,6 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp, { struct urlcontent *u; - lprintf(5, "Upload handler called: %s, %ld bytes\n", - cbtype, (long)length); - /* Form fields */ if ( (length > 0) && (strlen(cbtype) == 0) ) { u = (struct urlcontent *) malloc(sizeof(struct urlcontent)); @@ -719,8 +721,7 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp, memcpy(WC->upload, content, length); } else { - lprintf(9, "malloc() failed: %s\n", - strerror(errno)); + lprintf(3, "malloc() failed: %s\n", strerror(errno)); } } @@ -782,11 +783,9 @@ void session_loop(struct httprequest *req) c_username, c_password, c_roomname); } else if (!strncasecmp(buf, "Content-length: ", 16)) { - lprintf(9, "%s\n", buf); ContentLength = atoi(&buf[16]); } else if (!strncasecmp(buf, "Content-type: ", 14)) { - lprintf(9, "%s\n", buf); safestrncpy(ContentType, &buf[14], sizeof ContentType); } else if (!strncasecmp(buf, "User-agent: ", 12)) { @@ -822,7 +821,6 @@ void session_loop(struct httprequest *req) addurls(&content[body_start]); } else if (!strncasecmp(ContentType, "multipart", 9)) { content_end = content + ContentLength + body_start; - lprintf(9, "Calling MIME parser\n"); mime_parser(content, content_end, *upload_handler, NULL, NULL, NULL, 0); } diff --git a/webcit/webcit.h b/webcit/webcit.h index 39a5d39c8..f7a712bce 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -213,6 +213,7 @@ struct wcsession { int num_cal; #endif struct wc_attachment *first_attachment; + char ImportantMessage[SIZ]; }; #define extract(dest,source,parmnum) extract_token(dest,source,parmnum,'|') @@ -251,7 +252,7 @@ int tcp_connectsock(char *, char *); void serv_gets(char *strbuf); void serv_puts(char *string); void whobbs(void); -void fmout(FILE * fp); +void fmout(FILE *fp, char *align); void wDumpContent(int); void serv_printf(const char *format,...); char *bstr(char *key); @@ -289,7 +290,6 @@ void goto_private(void); void zapped_list(void); void display_zap(void); void zap(void); -void display_error(char *); void display_success(char *); void display_entroom(void); void entroom(void); -- 2.30.2