X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fpaging.c;h=4b3dc217a716983c01875f6c31fbf74fd74741b6;hb=HEAD;hp=a3987058e13493f1e8563f78c9b28bab669bcc57;hpb=49e0586e3a6421aff891e75d81c22318f7b25e0e;p=citadel.git diff --git a/webcit/paging.c b/webcit/paging.c index a3987058e..f022c48bc 100644 --- a/webcit/paging.c +++ b/webcit/paging.c @@ -1,182 +1,146 @@ -/* $Id$ */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "webcit.h" +// 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(3); + output_headers(1, 1, 1, 0, 0, 0); + wc_printf("
\n"); + wc_printf("

"); + wc_printf(_("Send instant message")); + wc_printf("

"); + wc_printf("
\n"); - wprintf("
"); - wprintf("Page another user\n"); - wprintf("
\n"); + wc_printf("
\n"); - wprintf("
This will send a page (instant message) " - "to %s.\n", recp); + wc_printf("
\n"); - wprintf("
\n"); + wc_printf(_("Send an instant message to: ")); + escputs(recp); + wc_printf("
\n"); + wc_printf("\n"); + wc_printf("\n", WC->nonce); + wc_printf("\n"); - wprintf("
\n"); + wc_printf("
\n"); - wprintf("\n"); + wc_printf("\">\n"); - wprintf("\n"); + wc_printf(_("Enter message text:")); + wc_printf("
"); - wprintf("Enter message text:
"); - - wprintf("\n"); - wprintf("

\n"); + wc_printf("

\n"); - wprintf(""); - wprintf("
\n"); + wc_printf("", _("Send message")); + wc_printf("
\n", _("Cancel")); - wprintf("\n"); + wc_printf("\n"); + wc_printf("
\n"); wDumpContent(1); } -/* - * page another user - */ -void page_user(void) -{ - char recp[SIZ]; - char sc[SIZ]; - char buf[SIZ]; - char closewin[SIZ]; - output_headers(3); +// page another user +void page_user(void) { + char recp[256]; + StrBuf *Line; - strcpy(recp, bstr("recp")); - strcpy(sc, bstr("sc")); - strcpy(closewin, bstr("closewin")); + safestrncpy(recp, bstr("recp"), sizeof recp); - if (strcmp(sc, "Send message")) { - wprintf("Message was not sent.
\n"); - } else { + if (!havebstr("send_button")) { + AppendImportantMessage(_("Message was not sent."), -1); + } + else { + Line = NewStrBuf(); serv_printf("SEXP %s|-", recp); - serv_gets(buf); - - if (buf[0] == '4') { - text_to_server(bstr("msgtext"), 0); + StrBuf_ServGetln(Line); + if (GetServerStatusMsg(Line, NULL, 0, 0) == 4) { + char buf[256]; + text_to_server(bstr("msgtext")); serv_puts("000"); - wprintf("Message has been sent to "); - escputs(recp); - wprintf(".
\n"); + stresc(buf, 256, recp, 0, 0); + AppendImportantMessage(buf, -1); + AppendImportantMessage(_("Message has been sent to "), -1); } - else { - wprintf("%s
\n", &buf[4]); - } - } - - if (!strcasecmp(closewin, "yes")) { - wprintf("
" - "[ close window ]
\n"); } - wDumpContent(1); + url_do_template(); } +// 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]; -/* - * multiuser chat - */ -void do_chat(void) -{ - - output_headers(1); - - wprintf("
"); - wprintf("Real-time chat\n"); - wprintf("
\n"); - - wprintf("A chat window should be appearing on your screen "); - wprintf("momentarily. When you're "); - wprintf("done, type /quit to exit. You can also "); - wprintf("type /help for more commands.\n"); - - wprintf("\n"); - wprintf("\n", WC->wc_username); - wprintf("\n", WC->wc_password); - wprintf("\n", WC->wc_roomname); - wprintf("

Oops!

Looks like your browser doesn't support Java, "); - wprintf("so you won't be able to access Chat. Sorry.\n"); - wprintf("
\n"); - wDumpContent(1); + // 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] == '*')) { + if ((time(NULL) - WC->last_pager_check) > 60) { + return 1; + } + } + return 0; + // Then schedule it to happen again a minute from now if the user is idle. } -/* - * - */ -void page_popup(void) -{ - char buf[SIZ]; - char pagefrom[SIZ]; - - /* suppress express message check, do headers but no fake frames */ - output_headers(0x08 | 0x03); +void ajax_send_instant_message(void) { + char recp[256]; + char buf[256]; - while (serv_puts("GEXP"), serv_gets(buf), buf[0]=='1') { + safestrncpy(recp, bstr("recp"), sizeof recp); - extract(pagefrom, &buf[4], 3); + serv_printf("SEXP %s|-", recp); + serv_getln(buf, sizeof buf); - wprintf("
"); - wprintf("Express message from "); - escputs(pagefrom); - wprintf("
\n"); - - fmout(NULL); + if (buf[0] == '4') { + text_to_server(bstr("msg")); + serv_puts("000"); } - wprintf("
"); - wprintf("[ reply ]   \n"); + escputs(buf); // doesn't really matter what we return - the client ignores it +} - wprintf("" - "[ close window ]\n" - "
"); - wDumpContent(1); - WC->HaveExpressMessages = 0; +void +InitModule_PAGING +(void) +{ + 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("COND:PAGE:WAITING", 0, Conditional_PAGE_WAITING, CTX_NONE); } +void +SessionDestroyModule_PAGING +(wcsession *sess) +{ + /* nothing here anymore */ +}