2 * This module handles instant message related functions.
4 * Copyright (c) 1996-2010 by the citadel.org team
6 * This program is free 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("<div class=\"fix_scrollbar_bug\">"
42 "<table class=\"paging_background\"><tr><td>\n");
44 wc_printf(_("Send an instant message to: "));
48 wc_printf("<FORM METHOD=\"POST\" action=\"page_user\">\n");
49 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
50 wc_printf("<input type=\"hidden\" name=\"template\" value=\"who\">\n");
52 wc_printf("<TABLE border=0 width=100%%><TR><TD>\n");
54 wc_printf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"");
58 wc_printf(_("Enter message text:"));
61 wc_printf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=5 COLS=40 "
62 "WIDTH=40></TEXTAREA>\n");
64 wc_printf("</TD></TR></TABLE><br />\n");
66 wc_printf("<INPUT TYPE=\"submit\" NAME=\"send_button\" VALUE=\"%s\">", _("Send message"));
67 wc_printf("<br /><a href=\"javascript:window.close();\"%s</A>\n", _("Cancel"));
69 wc_printf("</FORM></CENTER>\n");
70 wc_printf("</td></tr></table></div>\n");
82 safestrncpy(recp, bstr("recp"), sizeof recp);
84 if (!havebstr("send_button")) {
85 safestrncpy(WC->ImportantMessage,
86 _("Message was not sent."),
87 sizeof WC->ImportantMessage
90 serv_printf("SEXP %s|-", recp);
91 serv_getln(buf, sizeof buf);
94 text_to_server(bstr("msgtext"));
96 stresc(buf, 256, recp, 0, 0);
97 snprintf(WC->ImportantMessage,
98 sizeof WC->ImportantMessage,
100 _("Message has been sent to "),
105 safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
116 * If there are instant messages waiting, and we notice that we haven't checked them in
117 * a while, it probably means that we need to open the instant messenger window.
119 int Conditional_PAGE_WAITING(StrBuf *Target, WCTemplputParams *TP)
124 /** JavaScript function to alert the user that popups are probably blocked */
125 /** First, do the check as part of our page load. */
127 len = serv_getln(buf, sizeof buf);
128 if ((len >= 3) && (buf[3] == '*')) {
129 if ((time(NULL) - WC->last_pager_check) > 60) {
134 /* Then schedule it to happen again a minute from now if the user is idle. */
138 void ajax_send_instant_message(void) {
142 safestrncpy(recp, bstr("recp"), sizeof recp);
144 serv_printf("SEXP %s|-", recp);
145 serv_getln(buf, sizeof buf);
148 text_to_server(bstr("msg"));
152 escputs(buf); /* doesn't really matter what we return - the client ignores it */
160 WebcitAddUrlHandler(HKEY("display_page"), "", 0, display_page, 0);
161 WebcitAddUrlHandler(HKEY("page_user"), "", 0, page_user, 0);
162 WebcitAddUrlHandler(HKEY("ajax_send_instant_message"), "", 0, ajax_send_instant_message, AJAX);
163 RegisterConditional(HKEY("COND:PAGE:WAITING"), 0, Conditional_PAGE_WAITING, CTX_NONE);
168 SessionDestroyModule_PAGING
171 /* nothing here anymore */