final touches on dkim test harness
[citadel.git] / webcit / paging.c
index 307e225a27ec5c30cfbab551d8137aa43eed00df..f022c48bc10576e450a79c28fcc2a74c7fcb4485 100644 (file)
@@ -1,36 +1,25 @@
-/*
- * This module handles instant message related functions.
- *
- * Copyright (c) 1996-2010 by the citadel.org team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
+// This module handles instant message related functions.
+//
+// Copyright (c) 1996-2023 by the citadel.org team
+//
+// This program is open source software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 3.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
 
 #include "webcit.h"
 
-/*
- * display the form for paging (x-messaging) another user
- */
-void display_page(void)
-{
+// display the form for paging (x-messaging) another user
+void display_page(void) {
        char recp[SIZ];
 
        strcpy(recp, bstr("recp"));
 
-        output_headers(1, 1, 2, 0, 0, 0);
-        wc_printf("<div id=\"banner\">\n");
+        output_headers(1, 1, 1, 0, 0, 0);
+        wc_printf("<div id=\"room_banner_override\">\n");
         wc_printf("<h1>");
        wc_printf(_("Send instant message"));
        wc_printf("</h1>");
@@ -38,8 +27,7 @@ void display_page(void)
 
        wc_printf("<div id=\"content\" class=\"service\">\n");
 
-        wc_printf("<div class=\"fix_scrollbar_bug\">"
-               "<table class=\"paging_background\"><tr><td>\n");
+       wc_printf("<table class=\"paging_background\"><tr><td>\n");
 
        wc_printf(_("Send an instant message to: "));
        escputs(recp);
@@ -56,53 +44,43 @@ void display_page(void)
        wc_printf("\">\n");
 
        wc_printf(_("Enter message text:"));
-       wc_printf("<br />");
+       wc_printf("<br>");
 
        wc_printf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=5 COLS=40 "
                "WIDTH=40></TEXTAREA>\n");
 
-       wc_printf("</TD></TR></TABLE><br />\n");
+       wc_printf("</TD></TR></TABLE><br>\n");
 
        wc_printf("<INPUT TYPE=\"submit\" NAME=\"send_button\" VALUE=\"%s\">", _("Send message"));
-       wc_printf("<br /><a href=\"javascript:window.close();\"%s</A>\n", _("Cancel"));
+       wc_printf("<br><a href=\"javascript:window.close();\"%s</A>\n", _("Cancel"));
 
        wc_printf("</FORM></CENTER>\n");
-       wc_printf("</td></tr></table></div>\n");
+       wc_printf("</td></tr></table>\n");
        wDumpContent(1);
 }
 
-/*
- * page another user
- */
-void page_user(void)
-{
+
+// page another user
+void page_user(void) {
        char recp[256];
-       char buf[256];
+       StrBuf *Line;
 
        safestrncpy(recp, bstr("recp"), sizeof recp);
 
        if (!havebstr("send_button")) {
-               safestrncpy(WC->ImportantMessage,
-                       _("Message was not sent."),
-                       sizeof WC->ImportantMessage
-               );
-       } else {
+               AppendImportantMessage(_("Message was not sent."), -1);
+       }
+       else {
+               Line = NewStrBuf();
                serv_printf("SEXP %s|-", recp);
-               serv_getln(buf, sizeof buf);
-
-               if (buf[0] == '4') {
+               StrBuf_ServGetln(Line);
+               if (GetServerStatusMsg(Line, NULL, 0, 0) == 4) {
+                       char buf[256];
                        text_to_server(bstr("msgtext"));
                        serv_puts("000");
                        stresc(buf, 256, recp, 0, 0);
-                       snprintf(WC->ImportantMessage,
-                               sizeof WC->ImportantMessage,
-                               "%s%s.",
-                               _("Message has been sent to "),
-                               buf
-                       );
-               }
-               else {
-                       safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
+                       AppendImportantMessage(buf, -1);
+                       AppendImportantMessage(_("Message has been sent to "), -1);
                }
        }
 
@@ -110,19 +88,15 @@ void page_user(void)
 }
 
 
-
-/*
- * display page popup
- * If there are instant messages waiting, and we notice that we haven't checked them in
- * a while, it probably means that we need to open the instant messenger window.
- */
-int Conditional_PAGE_WAITING(StrBuf *Target, WCTemplputParams *TP)
-{
+// display page popup
+// If there are instant messages waiting, and we notice that we haven't checked them in
+// a while, it probably means that we need to open the instant messenger window.
+int Conditional_PAGE_WAITING(StrBuf *Target, WCTemplputParams *TP) {
        int len;
        char buf[SIZ];
 
-       /** JavaScript function to alert the user that popups are probably blocked */
-       /** First, do the check as part of our page load. */
+       // JavaScript function to alert the user that popups are probably blocked
+       // First, do the check as part of our page load.
        serv_puts("NOOP");
        len = serv_getln(buf, sizeof buf);
        if ((len >= 3) && (buf[3] == '*')) {
@@ -131,7 +105,7 @@ int Conditional_PAGE_WAITING(StrBuf *Target, WCTemplputParams *TP)
                }
        }
        return 0;
-       /* Then schedule it to happen again a minute from now if the user is idle. */
+       // Then schedule it to happen again a minute from now if the user is idle.
 }
 
 
@@ -149,7 +123,7 @@ void ajax_send_instant_message(void) {
                serv_puts("000");
        }
 
-       escputs(buf);   /* doesn't really matter what we return - the client ignores it */
+       escputs(buf);   // doesn't really matter what we return - the client ignores it
 }
 
 
@@ -160,7 +134,7 @@ InitModule_PAGING
        WebcitAddUrlHandler(HKEY("display_page"), "", 0, display_page, 0);
        WebcitAddUrlHandler(HKEY("page_user"), "", 0, page_user, 0);
        WebcitAddUrlHandler(HKEY("ajax_send_instant_message"), "", 0, ajax_send_instant_message, AJAX);
-       RegisterConditional(HKEY("COND:PAGE:WAITING"), 0, Conditional_PAGE_WAITING, CTX_NONE);
+       RegisterConditional("COND:PAGE:WAITING", 0, Conditional_PAGE_WAITING, CTX_NONE);
 }