4 * This module handles instant message related functions.
6 * Copyright (c) 1996-2010 by the citadel.org team
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 * display the form for paging (x-messaging) another user
28 void display_page(void)
32 strcpy(recp, bstr("recp"));
34 output_headers(1, 1, 2, 0, 0, 0);
35 wc_printf("<div id=\"banner\">\n");
37 wc_printf(_("Send instant message"));
39 wc_printf("</div>\n");
41 wc_printf("<div id=\"content\" class=\"service\">\n");
43 wc_printf("<div class=\"fix_scrollbar_bug\">"
44 "<table class=\"paging_background\"><tr><td>\n");
46 wc_printf(_("Send an instant message to: "));
50 wc_printf("<FORM METHOD=\"POST\" action=\"page_user\">\n");
51 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
52 wc_printf("<input type=\"hidden\" name=\"template\" value=\"who\">\n");
54 wc_printf("<TABLE border=0 width=100%%><TR><TD>\n");
56 wc_printf("<INPUT TYPE=\"hidden\" NAME=\"recp\" VALUE=\"");
60 wc_printf(_("Enter message text:"));
63 wc_printf("<TEXTAREA NAME=\"msgtext\" wrap=soft ROWS=5 COLS=40 "
64 "WIDTH=40></TEXTAREA>\n");
66 wc_printf("</TD></TR></TABLE><br />\n");
68 wc_printf("<INPUT TYPE=\"submit\" NAME=\"send_button\" VALUE=\"%s\">", _("Send message"));
69 wc_printf("<br /><a href=\"javascript:window.close();\"%s</A>\n", _("Cancel"));
71 wc_printf("</FORM></CENTER>\n");
72 wc_printf("</td></tr></table></div>\n");
84 safestrncpy(recp, bstr("recp"), sizeof recp);
86 if (!havebstr("send_button")) {
87 safestrncpy(WC->ImportantMessage,
88 _("Message was not sent."),
89 sizeof WC->ImportantMessage
92 serv_printf("SEXP %s|-", recp);
93 serv_getln(buf, sizeof buf);
96 text_to_server(bstr("msgtext"));
98 stresc(buf, 256, recp, 0, 0);
99 snprintf(WC->ImportantMessage,
100 sizeof WC->ImportantMessage,
102 _("Message has been sent to "),
107 safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
118 * If there are instant messages waiting, and we notice that we haven't checked them in
119 * a while, it probably means that we need to open the instant messenger window.
121 int Conditional_PAGE_WAITING(StrBuf *Target, WCTemplputParams *TP)
126 /** JavaScript function to alert the user that popups are probably blocked */
127 /** First, do the check as part of our page load. */
129 len = serv_getln(buf, sizeof buf);
130 if ((len >= 3) && (buf[3] == '*')) {
131 if ((time(NULL) - WC->last_pager_check) > 60) {
136 /* Then schedule it to happen again a minute from now if the user is idle. */
140 void ajax_send_instant_message(void) {
144 safestrncpy(recp, bstr("recp"), sizeof recp);
146 serv_printf("SEXP %s|-", recp);
147 serv_getln(buf, sizeof buf);
150 text_to_server(bstr("msg"));
154 escputs(buf); /* doesn't really matter what we return - the client ignores it */
162 WebcitAddUrlHandler(HKEY("display_page"), "", 0, display_page, 0);
163 WebcitAddUrlHandler(HKEY("page_user"), "", 0, page_user, 0);
164 WebcitAddUrlHandler(HKEY("ajax_send_instant_message"), "", 0, ajax_send_instant_message, AJAX);
165 RegisterConditional(HKEY("COND:PAGE:WAITING"), 0, Conditional_PAGE_WAITING, CTX_NONE);
170 SessionDestroyModule_PAGING
173 /* nothing here anymore */