changeset 837:7c74eef1d0e0

New option "muc_auto_whois"
author Mikael Berthe <mikael@lilotux.net>
date Thu, 04 May 2006 18:39:25 +0200
parents cd011fe9f8a5
children ea1204c8a30b
files mcabber/mcabberrc.example mcabber/src/commands.c mcabber/src/commands.h mcabber/src/jabglue.c
diffstat 4 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabberrc.example	Thu May 04 17:54:06 2006 +0200
+++ b/mcabber/mcabberrc.example	Thu May 04 18:39:25 2006 +0200
@@ -132,6 +132,11 @@
 # won't be deleted.
 #set delete_on_reject = 0
 
+# MUC
+# Set 'muc_auto_whois' to 1 if you want to call /room whois each time
+# somebody joins a room. (default: 0)
+#set muc_auto_whois = 0
+
 # Status messages
 # The "message" value will override all others, take care!
 #set message = Unique message status
--- a/mcabber/src/commands.c	Thu May 04 17:54:06 2006 +0200
+++ b/mcabber/src/commands.c	Thu May 04 18:39:25 2006 +0200
@@ -1768,7 +1768,7 @@
   jb_room_unlock(buddy_getjid(bud));
 }
 
-static void room_whois(gpointer bud, char *arg)
+void room_whois(gpointer bud, char *arg)
 {
   char **paramlst;
   gchar *nick, *buffer;
--- a/mcabber/src/commands.h	Thu May 04 17:54:06 2006 +0200
+++ b/mcabber/src/commands.h	Thu May 04 18:39:25 2006 +0200
@@ -20,6 +20,8 @@
 extern char *mcabber_version(void);
 extern void mcabber_connect(void);
 
+void room_whois(gpointer bud, char *nick_locale);
+
 #endif /* __COMMANDS_H__ */
 
 /* vim: set expandtab cindent cinoptions=>2\:2(0:  For Vim users... */
--- a/mcabber/src/jabglue.c	Thu May 04 17:54:06 2006 +0200
+++ b/mcabber/src/jabglue.c	Thu May 04 18:39:25 2006 +0200
@@ -32,6 +32,7 @@
 #include "settings.h"
 #include "hbuf.h"
 #include "histolog.h"
+#include "commands.h"
 
 #define JABBERPORT      5222
 #define JABBERSSLPORT   5223
@@ -972,6 +973,7 @@
   enum imaffiliation mbaffil = affil_none;
   const char *mbjid = NULL, *mbnick = NULL;
   const char *actorjid = NULL, *reason = NULL;
+  bool new_member = FALSE; // True if somebody else joins the room (not us)
   unsigned int statuscode = 0;
   GSList *room_elt;
   int log_muc_conf;
@@ -1165,11 +1167,13 @@
         if (log_muc_conf) hlog_write_message(roomjid, 0, FALSE, mbuf);
         g_free(mbuf);
         mbuf = g_strdup_printf("%s has joined", rname);
+        new_member = TRUE;
       }
     } else {
-      if (strcmp(ournick, rname))
+      if (strcmp(ournick, rname)) {
         mbuf = g_strdup_printf("%s has joined", rname);
-      else
+        new_member = TRUE;
+      } else
         mbuf = NULL;
     }
 
@@ -1185,6 +1189,12 @@
   if (rname) {
     roster_setstatus(roomjid, rname, bpprio, ust, ustmsg, usttime,
                      mbrole, mbaffil, mbjid);
+    if (new_member && settings_opt_get_int("muc_auto_whois")) {
+      // FIXME: This will fail for some UTF-8 nicknames.
+      gchar *joiner_nick = from_utf8(rname);
+      room_whois(room_elt->data, joiner_nick);
+      g_free(joiner_nick);
+    }
   } else
     scr_LogPrint(LPRINT_LOGNORM, "MUC DBG: no rname!"); /* DBG */