/*
* $Id$
- *
- * Functions which implement the chat and paging facilities.
*/
-
+/**
+ * \defgroup PageFunc Functions which implement the chat and paging facilities.
+ * \ingroup ClientPower
+ */
+/*@{*/
#include "webcit.h"
-/*
- * display the form for paging (x-messaging) another user
+/**
+ * \brief display the form for paging (x-messaging) another user
*/
void display_page(void)
{
"</div>\n<div id=\"content\">\n"
);
- wprintf("<div id=\"fix_scrollbar_bug\">"
+ wprintf("<div class=\"fix_scrollbar_bug\">"
"<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
wprintf(_("Send an instant message to: "));
wDumpContent(1);
}
-/*
- * page another user
+/**
+ * \brief page another user
*/
void page_user(void)
{
serv_getln(buf, sizeof buf);
if (buf[0] == '4') {
- text_to_server(bstr("msgtext"), 0);
+ text_to_server(bstr("msgtext"));
serv_puts("000");
wprintf("<EM>");
wprintf(_("Message has been sent to "));
-/*
- * multiuser chat
+/**
+ * \brief multiuser chat
*/
void do_chat(void)
{
char buf[SIZ];
- /* First, check to make sure we're still allowed in this room. */
+ /** First, check to make sure we're still allowed in this room. */
serv_printf("GOTO %s", WC->wc_roomname);
serv_getln(buf, sizeof buf);
if (buf[0] != '2') {
return;
}
- /* If the chat socket is still open from a previous chat,
+ /**
+ * If the chat socket is still open from a previous chat,
* close it -- because it might be stale or in the wrong room.
*/
if (WC->chat_sock < 0) {
WC->chat_sock = (-1);
}
- /* WebCit Chat works by having transmit, receive, and refresh
+ /**
+ * WebCit Chat works by having transmit, receive, and refresh
* frames. Load the frameset. (This isn't AJAX but the headers
* output by begin_ajax_response() happen to be the ones we need.)
*/
}
-/*
+/**
+ * \brief 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.
*/
{
char buf[SIZ];
- /* First, do the check as part of our page load. */
+ /** JavaScript function to alert the user that popups are probably blocked */
+ wprintf("<script type=\"text/javascript\"> "
+ "function PopUpFailed() { "
+ " alert(\"%s\"); "
+ "} "
+ "</script>\n",
+ _("You have one or more instant messages waiting, but the Citadel Instant Messenger "
+ "window failed to open. This is probably because you have a popup blocker "
+ "installed. Please configure your popup blocker to allow popups from this site "
+ "if you wish to receive instant messages.")
+ );
+
+ /** First, do the check as part of our page load. */
serv_puts("NOOP");
serv_getln(buf, sizeof buf);
if (buf[3] == '*') {
if ((time(NULL) - WC->last_pager_check) > 60) {
wprintf("<script type=\"text/javascript\">"
- " window.open('static/instant_messenger.html', 'CTDL_MESSENGER', "
- " 'width=700,height=400');"
+ " var oWin = window.open('static/instant_messenger.html', "
+ " 'CTDL_MESSENGER', 'width=700,height=400'); "
+ " if (oWin==null || typeof(oWin)==\"undefined\") { "
+ " PopUpFailed(); "
+ " } "
"</script>"
);
}
}
- /* Then schedule it to happen again a minute from now if the user is idle. */
- wprintf("<script type=\"text/javascript\"> \n"
- " function HandleSslp(sslg_xmlresponse) { \n"
- " sslg_response = sslg_xmlresponse.responseText.substr(0, 1); \n"
- " if (sslg_response == 'Y') { \n"
- " window.open('static/instant_messenger.html', 'CTDL_MESSENGER', \n"
- " 'width=700,height=400'); \n"
- " } \n"
- " } \n"
- " function CheckPager() { \n"
- " new Ajax.Request('sslg', { method: 'get', parameters: Math.random(), \n"
- " onSuccess: HandleSslp } ); \n"
- " } \n"
- " new PeriodicalExecuter(CheckPager, 30); \n"
- "</script> \n"
+ /** Then schedule it to happen again a minute from now if the user is idle. */
+ wprintf("<script type=\"text/javascript\"> "
+ " function HandleSslp(sslg_xmlresponse) { "
+ " sslg_response = sslg_xmlresponse.responseText.substr(0, 1); "
+ " if (sslg_response == 'Y') { "
+ " var oWin = window.open('static/instant_messenger.html', 'CTDL_MESSENGER', "
+ " 'width=700,height=400'); "
+ " if (oWin==null || typeof(oWin)==\"undefined\") { "
+ " PopUpFailed(); "
+ " } "
+ " } "
+ " } "
+ " function CheckPager() { "
+ " new Ajax.Request('sslg', { method: 'get', parameters: Math.random(), "
+ " onSuccess: HandleSslp } ); "
+ " } "
+ " new PeriodicalExecuter(CheckPager, 30); "
+ "</script> "
);
}
-/*
- * Support function for chat -- make sure the chat socket is connected
+/**
+ * \brief Support function for chat
+ * make sure the chat socket is connected
* and in chat mode.
*/
int setup_chat_socket(void) {
if (WC->chat_sock < 0) {
if (!strcasecmp(ctdlhost, "uds")) {
- /* unix domain socket */
+ /** unix domain socket */
sprintf(buf, "%s/citadel.socket", ctdlport);
WC->chat_sock = uds_connectsock(buf);
}
else {
- /* tcp socket */
+ /** tcp socket */
WC->chat_sock = tcp_connectsock(ctdlhost, ctdlport);
}
return(errno);
}
- /* Temporarily swap the serv and chat sockets during chat talk */
+ /** Temporarily swap the serv and chat sockets during chat talk */
i = WC->serv_sock;
WC->serv_sock = WC->chat_sock;
WC->chat_sock = i;
}
}
- /* Unswap the sockets. */
+ /** Unswap the sockets. */
i = WC->serv_sock;
WC->serv_sock = WC->chat_sock;
WC->chat_sock = i;
-/*
- * Receiving side of the chat window. This is implemented in a
+/**
+ * \brief Receiving side of the chat window.
+ * This is implemented in a
* tiny hidden IFRAME that just does JavaScript writes to
* other frames whenever it refreshes and finds new data.
*/
return;
}
- /*
+ /**
* See if there is any chat data waiting.
*/
output_data = strdup("");
if (poll(&pf, 1, 1) > 0) if (pf.revents & POLLIN) {
++got_data;
- /* Temporarily swap the serv and chat sockets during chat talk */
+ /** Temporarily swap the serv and chat sockets during chat talk */
i = WC->serv_sock;
WC->serv_sock = WC->chat_sock;
WC->chat_sock = i;
end_chat_now = 1;
}
- /* Unswap the sockets. */
+ /** Unswap the sockets. */
i = WC->serv_sock;
WC->serv_sock = WC->chat_sock;
WC->chat_sock = i;
- /* Append our output data */
+ /** Append our output data */
output_data = realloc(output_data, strlen(output_data) + strlen(buf) + 4);
strcat(output_data, buf);
strcat(output_data, "\n");
output_data[strlen(output_data)-1] = 0;
}
- /* Output our fun to the other frame. */
+ /** Output our fun to the other frame. */
wprintf("<img src=\"static/blank.gif\" WIDTH=1 HEIGHT=1\n"
"onLoad=\" \n"
);
if (strcasecmp(cl_user, WC->last_chat_user)) {
wprintf("<B>");
- if (!strcasecmp(cl_user, WC->wc_username)) {
+ if (!strcasecmp(cl_user, WC->wc_fullname)) {
wprintf("<FONT COLOR="#FF0000">");
}
else {
}
-/*
- * sending side of the chat window
+/**
+ * \brief sending side of the chat window
*/
void chat_send(void) {
int i;
return;
}
- /* Temporarily swap the serv and chat sockets during chat talk */
+ /** Temporarily swap the serv and chat sockets during chat talk */
i = WC->serv_sock;
WC->serv_sock = WC->chat_sock;
WC->chat_sock = i;
}
}
- /* Unswap the sockets. */
+ /** Unswap the sockets. */
i = WC->serv_sock;
WC->serv_sock = WC->chat_sock;
WC->chat_sock = i;
wDumpContent(0);
}
+/*@}*/