* fix_scrollbar_bug is now a class instead of an id. Fixes validator warnings.
[citadel.git] / webcit / webcit.c
index c58876f9b473e6e2039101342def2018b5802803..7220a5d7eae9eaf010e3bf3129cfa4e6563dfc10 100644 (file)
@@ -390,11 +390,8 @@ void output_headers(       int do_httpheaders,     /* 1 = output HTTP headers
        /* ICONBAR */
        if (do_htmlhead) {
 
-               if (WC->HaveInstantMessages) {
-                       wprintf("<div id=\"page_popup\">\n");
-                       page_popup();
-                       wprintf("</div>\n");
-               }
+
+               /* check for ImportantMessages (these display in a div overlaying the main screen) */
                if (strlen(WC->ImportantMessage) > 0) {
                        wprintf("<div id=\"important_message\">\n");
                        wprintf("<SPAN CLASS=\"imsg\">"
@@ -405,11 +402,15 @@ void output_headers(      int do_httpheaders,     /* 1 = output HTTP headers
                                "</script>\n");
                        safestrncpy(WC->ImportantMessage, "", sizeof WC->ImportantMessage);
                }
+
                if ( (WC->logged_in) && (!unset_cookies) ) {
                        wprintf("<div id=\"iconbar\">");
-                       do_iconbar();
-                       wprintf("</div>\n");
+                       do_selected_iconbar();
+                       /* check for instant messages (these display in a new window) 
+                       page_popup();  */
+                       wprintf("</div>");
                }
+
                if (do_room_banner == 1) {
                        wprintf("<div id=\"banner\">\n");
                        embed_room_banner(NULL, navbar_default);
@@ -438,18 +439,6 @@ void http_redirect(char *whichpage) {
 
 
 
-void check_for_instant_messages()
-{
-       char buf[SIZ];
-
-       serv_puts("NOOP");
-       serv_getln(buf, sizeof buf);
-       if (buf[3] == '*') WC->HaveInstantMessages = 1;
-}
-
-
-
-
 /* 
  * Output a piece of content to the web browser
  */
@@ -832,17 +821,16 @@ void ajax_servcmd(void)
 
        begin_ajax_response();
 
-       /* lprintf(9, "Sending cmd: %s\n", bstr("g_cmd")); */
        serv_printf("%s", bstr("g_cmd"));
        serv_getln(buf, sizeof buf);
-       /* lprintf(9, "   Response: %s\n", buf); */
+       wprintf("%s\n", buf);
 
        if (buf[0] == '8') {
                serv_printf("\n\n000");
        }
        if ((buf[0] == '1') || (buf[0] == '8')) {
                while (serv_getln(gcontent, sizeof gcontent), strcmp(gcontent, "000")) {
-                       /* maybe do something with it? */
+                       wprintf("%s\n", gcontent);
                }
                wprintf("000");
        }
@@ -865,9 +853,42 @@ void ajax_servcmd(void)
        }
 
        end_ajax_response();
+       
+       /* This is kind of an ugly hack, but this is the only place it can go.
+        * If the command was GEXP, then the instant messenger window must be
+        * running, so reset the "last_pager_check" watchdog timer so
+        * that page_popup() doesn't try to open it a second time.
+        */
+       if (!strncasecmp(bstr("g_cmd"), "GEXP", 4)) {
+               WC->last_pager_check = time(NULL);
+       }
 }
 
 
+/*
+ * Helper function for the asynchronous check to see if we need
+ * to open the instant messenger window.
+ */
+void seconds_since_last_gexp(void)
+{
+       char buf[256];
+
+       begin_ajax_response();
+       if ( (time(NULL) - WC->last_pager_check) < 30) {
+               wprintf("NO\n");
+       }
+       else {
+               serv_puts("NOOP");
+               serv_getln(buf, sizeof buf);
+               if (buf[3] == '*') {
+                       wprintf("YES");
+               }
+               else {
+                       wprintf("NO");
+               }
+       }
+       end_ajax_response();
+}
 
 
 
@@ -923,7 +944,6 @@ void session_loop(struct httprequest *req)
        WC->upload_length = 0;
        WC->upload = NULL;
        WC->vars = NULL;
-
        WC->is_wap = 0;
 
        hptr = req;
@@ -1232,11 +1252,6 @@ void session_loop(struct httprequest *req)
                }
        }
 
-       /*
-        * If there are instant messages waiting, retrieve them for display.
-        */
-       check_for_instant_messages();
-
        if (!strcasecmp(action, "image")) {
                output_image();
 
@@ -1266,6 +1281,8 @@ void session_loop(struct httprequest *req)
                display_main_menu();
        } else if (!strcasecmp(action, "who")) {
                who();
+       } else if (!strcasecmp(action, "sslg")) {
+               seconds_since_last_gexp();
        } else if (!strcasecmp(action, "who_inner_html")) {
                begin_ajax_response();
                who_inner_div();
@@ -1308,6 +1325,8 @@ void session_loop(struct httprequest *req)
                embed_message(arg1);
        } else if (!strcasecmp(action, "printmsg")) {
                print_message(arg1);
+       } else if (!strcasecmp(action, "msgheaders")) {
+               display_headers(arg1);
        } else if (!strcasecmp(action, "display_enter")) {
                display_enter();
        } else if (!strcasecmp(action, "post")) {
@@ -1355,7 +1374,7 @@ void session_loop(struct httprequest *req)
        } else if (!strcasecmp(action, "editinfo")) {
                save_edit(_("Room info"), "EINF 1", 1);
        } else if (!strcasecmp(action, "display_editbio")) {
-               sprintf(buf, "RBIO %s", WC->wc_username);
+               sprintf(buf, "RBIO %s", WC->wc_fullname);
                display_edit(_("Your bio"), "NOOP", buf, "editbio", 3);
        } else if (!strcasecmp(action, "editbio")) {
                save_edit(_("Your bio"), "EBIO", 0);
@@ -1498,6 +1517,8 @@ void session_loop(struct httprequest *req)
                recp_autocomplete(bstr("cc"));
        } else if (!strcasecmp(action, "bcc_autocomplete")) {
                recp_autocomplete(bstr("bcc"));
+       } else if (!strcasecmp(action, "set_floordiv_expanded")) {
+               set_floordiv_expanded(arg1);
        } else if (!strcasecmp(action, "diagnostics")) {
                output_headers(1, 1, 1, 0, 0, 0);
                wprintf("Session: %d<hr />\n", WC->wc_session);
@@ -1526,5 +1547,4 @@ SKIP_ALL_THIS_CRAP:
                free(WC->upload);
                WC->upload_length = 0;
        }
-
 }