2 * This module handles instant message related functions.
4 * Copyright (c) 1996-2010 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 as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * display the form for paging (x-messaging) another user
26 void display_page(void)
30 strcpy(recp, bstr("recp"));
32 output_headers(1, 1, 2, 0, 0, 0);
33 wc_printf("<div id=\"banner\">\n");
35 wc_printf(_("Send instant message"));
37 wc_printf("</div>\n");
39 wc_printf("<div id=\"content\" class=\"service\">\n");
41 wc_printf("<table class=\"paging_background\"><tr><td>\n");
43 wc_printf(_("Send an instant message to: "));
47 wc_printf("<FORM METHOD=\"POST\" action=\"page_user\">\n");
48 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
49 wc_printf("<input type=\"hidden\" name=\"template\" value=\"who\">\n");
51 wc_printf("<TABLE border=0 width=100%%><TR><TD>\n");
53 wc_printf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"");
57 wc_printf(_("Enter message text:"));
60 wc_printf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=5 COLS=40 "
61 "WIDTH=40></TEXTAREA>\n");
63 wc_printf("</TD></TR></TABLE><br>\n");
65 wc_printf("<INPUT TYPE=\"submit\" NAME=\"send_button\" VALUE=\"%s\">", _("Send message"));
66 wc_printf("<br><a href=\"javascript:window.close();\"%s</A>\n", _("Cancel"));
68 wc_printf("</FORM></CENTER>\n");
69 wc_printf("</td></tr></table>\n");
81 safestrncpy(recp, bstr("recp"), sizeof recp);
83 if (!havebstr("send_button")) {
84 AppendImportantMessage(_("Message was not sent."), -1);
87 serv_printf("SEXP %s|-", recp);
88 StrBuf_ServGetln(Line);
89 if (GetServerStatusMsg(Line, NULL, 0, 0) == 4) {
91 text_to_server(bstr("msgtext"));
93 stresc(buf, 256, recp, 0, 0);
94 AppendImportantMessage(buf, -1);
95 AppendImportantMessage(_("Message has been sent to "), -1);
106 * If there are instant messages waiting, and we notice that we haven't checked them in
107 * a while, it probably means that we need to open the instant messenger window.
109 int Conditional_PAGE_WAITING(StrBuf *Target, WCTemplputParams *TP)
114 /** JavaScript function to alert the user that popups are probably blocked */
115 /** First, do the check as part of our page load. */
117 len = serv_getln(buf, sizeof buf);
118 if ((len >= 3) && (buf[3] == '*')) {
119 if ((time(NULL) - WC->last_pager_check) > 60) {
124 /* Then schedule it to happen again a minute from now if the user is idle. */
128 void ajax_send_instant_message(void) {
132 safestrncpy(recp, bstr("recp"), sizeof recp);
134 serv_printf("SEXP %s|-", recp);
135 serv_getln(buf, sizeof buf);
138 text_to_server(bstr("msg"));
142 escputs(buf); /* doesn't really matter what we return - the client ignores it */
150 WebcitAddUrlHandler(HKEY("display_page"), "", 0, display_page, 0);
151 WebcitAddUrlHandler(HKEY("page_user"), "", 0, page_user, 0);
152 WebcitAddUrlHandler(HKEY("ajax_send_instant_message"), "", 0, ajax_send_instant_message, AJAX);
153 RegisterConditional(HKEY("COND:PAGE:WAITING"), 0, Conditional_PAGE_WAITING, CTX_NONE);
158 SessionDestroyModule_PAGING
161 /* nothing here anymore */