2 * This module handles instant message related functions.
4 * Copyright (c) 1996-2012 by the citadel.org team
6 * This program is open source software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
18 * display the form for paging (x-messaging) another user
20 void display_page(void)
24 strcpy(recp, bstr("recp"));
26 output_headers(1, 1, 1, 0, 0, 0);
27 wc_printf("<div id=\"room_banner_override\">\n");
29 wc_printf(_("Send instant message"));
31 wc_printf("</div>\n");
33 wc_printf("<div id=\"content\" class=\"service\">\n");
35 wc_printf("<table class=\"paging_background\"><tr><td>\n");
37 wc_printf(_("Send an instant message to: "));
41 wc_printf("<FORM METHOD=\"POST\" action=\"page_user\">\n");
42 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
43 wc_printf("<input type=\"hidden\" name=\"template\" value=\"who\">\n");
45 wc_printf("<TABLE border=0 width=100%%><TR><TD>\n");
47 wc_printf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"");
51 wc_printf(_("Enter message text:"));
54 wc_printf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=5 COLS=40 "
55 "WIDTH=40></TEXTAREA>\n");
57 wc_printf("</TD></TR></TABLE><br>\n");
59 wc_printf("<INPUT TYPE=\"submit\" NAME=\"send_button\" VALUE=\"%s\">", _("Send message"));
60 wc_printf("<br><a href=\"javascript:window.close();\"%s</A>\n", _("Cancel"));
62 wc_printf("</FORM></CENTER>\n");
63 wc_printf("</td></tr></table>\n");
75 safestrncpy(recp, bstr("recp"), sizeof recp);
77 if (!havebstr("send_button")) {
78 AppendImportantMessage(_("Message was not sent."), -1);
81 serv_printf("SEXP %s|-", recp);
82 StrBuf_ServGetln(Line);
83 if (GetServerStatusMsg(Line, NULL, 0, 0) == 4) {
85 text_to_server(bstr("msgtext"));
87 stresc(buf, 256, recp, 0, 0);
88 AppendImportantMessage(buf, -1);
89 AppendImportantMessage(_("Message has been sent to "), -1);
100 * If there are instant messages waiting, and we notice that we haven't checked them in
101 * a while, it probably means that we need to open the instant messenger window.
103 int Conditional_PAGE_WAITING(StrBuf *Target, WCTemplputParams *TP)
108 /** JavaScript function to alert the user that popups are probably blocked */
109 /** First, do the check as part of our page load. */
111 len = serv_getln(buf, sizeof buf);
112 if ((len >= 3) && (buf[3] == '*')) {
113 if ((time(NULL) - WC->last_pager_check) > 60) {
118 /* Then schedule it to happen again a minute from now if the user is idle. */
122 void ajax_send_instant_message(void) {
126 safestrncpy(recp, bstr("recp"), sizeof recp);
128 serv_printf("SEXP %s|-", recp);
129 serv_getln(buf, sizeof buf);
132 text_to_server(bstr("msg"));
136 escputs(buf); /* doesn't really matter what we return - the client ignores it */
144 WebcitAddUrlHandler(HKEY("display_page"), "", 0, display_page, 0);
145 WebcitAddUrlHandler(HKEY("page_user"), "", 0, page_user, 0);
146 WebcitAddUrlHandler(HKEY("ajax_send_instant_message"), "", 0, ajax_send_instant_message, AJAX);
147 RegisterConditional(HKEY("COND:PAGE:WAITING"), 0, Conditional_PAGE_WAITING, CTX_NONE);
152 SessionDestroyModule_PAGING
155 /* nothing here anymore */