]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_chat.c
Changes to dynloader et al to handle ICQ module being written
[citadel.git] / citadel / serv_chat.c
index 38b393e314394eb6b42b1fb35b258278d5f2380f..b050b963a101ca80de4ec0e7716233aa11f0540e 100644 (file)
@@ -59,6 +59,8 @@ static struct DLModule_Info info =
 
 struct DLModule_Info *Dynamic_Module_Init(void)
 {
+       CtdlSendExpressMessageFunc = send_express_message;
+
        CtdlRegisterProtoHook(cmd_chat, "CHAT", "Begin real-time chat");
        CtdlRegisterProtoHook(cmd_pexp, "PEXP", "Poll for express messages");
        CtdlRegisterProtoHook(cmd_gexp, "GEXP", "Get express messages");
@@ -164,19 +166,26 @@ t_context *find_context(char **unstr)
 }
 
 /*
- * List users in chat.  Setting allflag to 1 also lists users elsewhere.
+ * List users in chat.
+ * allflag ==  0 = list users in chat
+ *             1 = list users in chat, followed by users not in chat
+ *             2 = display count only
  */
 
 void do_chat_listing(int allflag)
 {
        struct CitContext *ccptr;
+       int count = 0;
 
-       cprintf(":|\n:| Users currently in chat:\n");
+       if ((allflag == 0) || (allflag == 1))
+               cprintf(":|\n:| Users currently in chat:\n");
        begin_critical_section(S_SESSION_TABLE);
        for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
+               if (!strcasecmp(ccptr->cs_room, "<chat>")) ++count;
                if ((!strcasecmp(ccptr->cs_room, "<chat>"))
                    && ((ccptr->cs_flags & CS_STEALTH) == 0)) {
-                       cprintf(":| %-25s <%s>\n", (ccptr->fake_username[0]) ? ccptr->fake_username : ccptr->curr_user, ccptr->chat_room);
+                       if ((allflag == 0) || (allflag == 1))
+                               cprintf(":| %-25s <%s>\n", (ccptr->fake_username[0]) ? ccptr->fake_username : ccptr->curr_user, ccptr->chat_room);
                }
        }
 
@@ -190,6 +199,14 @@ void do_chat_listing(int allflag)
                }
        }
        end_critical_section(S_SESSION_TABLE);
+
+       if (allflag == 2) {
+               if (count > 1) 
+                       cprintf(":|There are %d users here.\n", count);
+               else
+                       cprintf(":|Note: you are the only one here.\n");
+       }
+
        cprintf(":|\n");
 }
 
@@ -224,6 +241,8 @@ void cmd_chat(char *argbuf)
        }
        strcpy(cmdbuf, "");
 
+       do_chat_listing(2);
+
        while (1) {
                int ok_cmd;
 
@@ -505,7 +524,7 @@ int send_express_message(char *lun, char *x_user, char *x_msg)
                fprintf(fp, "N%s%c", NODENAME, 0);
                fprintf(fp, "M%s\n%c", x_msg, 0);
                fclose(fp);
-               save_message(CC->temp, "", config.c_logpages, M_LOCAL, 1);
+               save_message(CC->temp, "", config.c_logpages, MES_LOCAL, 1);
                unlink(CC->temp);
        }
        return (message_sent);