--- a/mcabber/mcabberrc.example Sat Jan 20 18:41:13 2007 +0100
+++ b/mcabber/mcabberrc.example Sat Jan 20 19:39:54 2007 +0100
@@ -128,6 +128,8 @@
# External command for events
# You can specify a script or process to be launched when an event occurs.
+# Set 'events_ignore_active_window' to 1 if you don't want the script to
+# be run for a message to the current active window (default: 0).
#
# If 'event_log_files' is set, a file is created and contains the body of
# the message (incoming messages only); the file name is the last parameter.
@@ -144,6 +146,8 @@
# See sample script in contrib/ directory.
#set events_command = /home/mikael/.mcabber/eventcmd
#
+#set events_ignore_active_window = 0
+#
#set event_log_files = 0
#set event_log_dir = /home/mikael/.mcabber/event_files
--- a/mcabber/src/hooks.c Sat Jan 20 18:41:13 2007 +0100
+++ b/mcabber/src/hooks.c Sat Jan 20 19:39:54 2007 +0100
@@ -43,6 +43,7 @@
int is_groupchat = FALSE; // groupchat message
int is_room = FALSE; // window is a room window
int log_muc_conf = FALSE;
+ int active_window = FALSE;
int message_flags = 0;
guint rtype = ROSTER_TYPE_USER;
char *wmsg = NULL, *bmsg = NULL, *mmsg = NULL;
@@ -136,10 +137,21 @@
(!is_room || (is_groupchat && log_muc_conf && !timestamp)))
hlog_write_message(bjid, timestamp, FALSE, wmsg);
+ if (settings_opt_get_int("events_ignore_active_window") &&
+ current_buddy && scr_get_chatmode()) {
+ gpointer bud = BUDDATA(current_buddy);
+ if (bud) {
+ const char *cjid = buddy_getjid(bud);
+ if (cjid && !strcasecmp(cjid, bjid))
+ active_window = TRUE;
+ }
+ }
+
// External command
// - We do not call hk_ext_cmd() for history lines in MUC
// - We do call hk_ext_cmd() for private messages in a room
- if ((is_groupchat && !timestamp) || !is_groupchat)
+ // - We do call hk_ext_cmd() for messages to the current window
+ if (!active_window && ((is_groupchat && !timestamp) || !is_groupchat))
hk_ext_cmd(bjid, (is_groupchat ? 'G' : 'M'), 'R', wmsg);
// Display the sender in the log window
--- a/mcabber/src/screen.c Sat Jan 20 18:41:13 2007 +0100
+++ b/mcabber/src/screen.c Sat Jan 20 19:39:54 2007 +0100
@@ -1974,6 +1974,13 @@
scr_UpdateChatStatus(TRUE);
}
+// scr_get_chatmode()
+// Public function to get chatmode state.
+inline int scr_get_chatmode(void)
+{
+ return chatmode;
+}
+
// scr_get_multimode()
// Public function to get multimode status...
inline int scr_get_multimode(void)
--- a/mcabber/src/screen.h Sat Jan 20 18:41:13 2007 +0100
+++ b/mcabber/src/screen.h Sat Jan 20 19:39:54 2007 +0100
@@ -88,6 +88,7 @@
int scr_BuddyBufferExists(const char *jid);
inline void scr_UpdateBuddyWindow(void);
inline void scr_set_chatmode(int enable);
+inline int scr_get_chatmode(void);
inline void scr_set_multimode(int enable, char *subject);
inline int scr_get_multimode(void);
void scr_setmsgflag_if_needed(const char *jid, int special);