changeset 1913:3cabdacf58df

Add "error" field to the message-in hooks Bump API number
author Mikael Berthe <mikael@lilotux.net>
date Sun, 16 May 2010 13:14:18 +0200
parents ee8657ff9aa8
children 356daacdbe54
files mcabber/doc/HOWTO_modules.txt mcabber/mcabber/api.h mcabber/mcabber/hooks.c
diffstat 3 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/doc/HOWTO_modules.txt	Fri May 14 11:58:13 2010 +0200
+++ b/mcabber/doc/HOWTO_modules.txt	Sun May 16 13:14:18 2010 +0200
@@ -200,6 +200,7 @@
    * groupchat - ("true" or "false")
    * delayed - message timestamp (ISO-8601 string) or empty string if
      the message wasn't delayed
+   * error - "true" if this is an error message
  - hook-post-message-in (HOOK_POST_MESSAGE_IN) with parameters
    * jid - sender of the incoming message
    * resource - resource of the incoming message
@@ -210,6 +211,7 @@
      attention (only implemented for MUC currently)
    * delayed - message timestamp (ISO-8601 string) or empty string if
      the message wasn't delayed
+   * error - "true" if this is an error message
  - hook-message-out (HOOK_MESSAGE_OUT) with parameters
    * jid - recipient of the outgoing message
    * message - message body, converted to locale charset
--- a/mcabber/mcabber/api.h	Fri May 14 11:58:13 2010 +0200
+++ b/mcabber/mcabber/api.h	Sun May 16 13:14:18 2010 +0200
@@ -3,7 +3,7 @@
 
 #include <mcabber/config.h> // For MCABBER_BRANCH
 
-#define MCABBER_API_VERSION 15
+#define MCABBER_API_VERSION 16
 #define MCABBER_API_MIN     13
 
 extern const gchar *mcabber_branch;
--- a/mcabber/mcabber/hooks.c	Fri May 14 11:58:13 2010 +0200
+++ b/mcabber/mcabber/hooks.c	Sun May 16 13:14:18 2010 +0200
@@ -197,6 +197,7 @@
   unsigned mucnicklen = 0;
   const char *ename = NULL;
   gboolean attention = FALSE, mucprivmsg = FALSE;
+  gboolean error_msg_subtype = (type == LM_MESSAGE_SUB_TYPE_ERROR);
 #ifdef MODULES_ENABLE
   gchar strdelay[32];
 
@@ -249,6 +250,7 @@
       { "message", msg },
       { "groupchat", is_groupchat ? "true" : "false" },
       { "delayed", strdelay },
+      { "error", error_msg_subtype ? "true" : "false" },
       { NULL, NULL },
     };
     h_result = hk_run_handlers(HOOK_PRE_MESSAGE_IN, args);
@@ -332,7 +334,7 @@
     }
   }
 
-  if (type  == LM_MESSAGE_SUB_TYPE_ERROR) {
+  if (error_msg_subtype) {
     message_flags = HBB_PREFIX_ERR | HBB_PREFIX_IN;
     scr_LogPrint(LPRINT_LOGNORM, "Error message received from <%s>", bjid);
   }
@@ -399,6 +401,7 @@
       { "groupchat", is_groupchat ? "true" : "false" },
       { "attention", attention ? "true" : "false" },
       { "delayed", strdelay },
+      { "error", error_msg_subtype ? "true" : "false" },
       { NULL, NULL },
     };
     hk_run_handlers(HOOK_POST_MESSAGE_IN, args);