+/**
+ * \brief multiuser chat
+ */
+void do_chat(void)
+{
+ char buf[SIZ];
+
+ /** 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') {
+ smart_goto("_BASEROOM_");
+ return;
+ }
+
+ /**
+ * 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) {
+ close(WC->chat_sock);
+ WC->chat_sock = (-1);
+ }
+
+ /**
+ * 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.)
+ */
+ begin_ajax_response();
+ do_template("chatframeset");
+ end_ajax_response();
+ return;
+}
+
+
+/**
+ * \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.
+ */
+void page_popup(void)
+{
+ char buf[SIZ];
+
+ /** 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\">"
+ " var oWin = window.open('static/instant_messenger.html', "
+ " 'CTDL_MESSENGER', 'width=700,height=400'); "
+ " if (oWin==null || typeof(oWin)==\"undefined\") { "
+ " PopUpFailed(); "
+ " } "
+ "</script>"
+ );
+ }
+ }