# HG changeset patch # User Mikael Berthe # Date 1274008458 -7200 # Node ID 3cabdacf58df87e1489d328e5bf6eeecda7def30 # Parent ee8657ff9aa80da5b10d6f2a84b1295f338a09b0 Add "error" field to the message-in hooks Bump API number diff -r ee8657ff9aa8 -r 3cabdacf58df mcabber/doc/HOWTO_modules.txt --- 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 diff -r ee8657ff9aa8 -r 3cabdacf58df mcabber/mcabber/api.h --- 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 // For MCABBER_BRANCH -#define MCABBER_API_VERSION 15 +#define MCABBER_API_VERSION 16 #define MCABBER_API_MIN 13 extern const gchar *mcabber_branch; diff -r ee8657ff9aa8 -r 3cabdacf58df mcabber/mcabber/hooks.c --- 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);