changeset 1892:ea3f9b4f3558

Add "delayed" argument to the message-in hooks
author Mikael Berthe <mikael@lilotux.net>
date Sun, 11 Apr 2010 17:20:32 +0200
parents 88c01c561a40
children dcefd1732a3c
files mcabber/doc/HOWTO_modules.txt mcabber/mcabber/api.h mcabber/mcabber/hooks.c
diffstat 3 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/doc/HOWTO_modules.txt	Sun Apr 11 16:20:18 2010 +0200
+++ b/mcabber/doc/HOWTO_modules.txt	Sun Apr 11 17:20:32 2010 +0200
@@ -198,6 +198,8 @@
    * resource - resource of the incoming message
    * message - message body, converted to locale charset
    * groupchat - ("true" or "false")
+   * delayed - message timestamp (ISO-8601 string) or empty string if
+     the message wasn't delayed
  - hook-post-message-in (HOOK_POST_MESSAGE_IN) with parameters
    * jid - sender of the incoming message
    * resource - resource of the incoming message
@@ -206,6 +208,8 @@
    * attention - In a MUC message, true if you've been highlighted
      In a regular message, true if the sender has requested your
      attention (only implemented for MUC currently)
+   * delayed - message timestamp (ISO-8601 string) or empty string if
+     the message wasn't delayed
  - 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	Sun Apr 11 16:20:18 2010 +0200
+++ b/mcabber/mcabber/api.h	Sun Apr 11 17:20:32 2010 +0200
@@ -3,7 +3,7 @@
 
 #include <mcabber/config.h> // For MCABBER_BRANCH
 
-#define MCABBER_API_VERSION 13
+#define MCABBER_API_VERSION 14
 #define MCABBER_API_MIN     13
 
 extern const gchar *mcabber_branch;
--- a/mcabber/mcabber/hooks.c	Sun Apr 11 16:20:18 2010 +0200
+++ b/mcabber/mcabber/hooks.c	Sun Apr 11 17:20:32 2010 +0200
@@ -197,6 +197,14 @@
   unsigned mucnicklen = 0;
   const char *ename = NULL;
   gboolean attention = FALSE, mucprivmsg = FALSE;
+#ifdef MODULES_ENABLE
+  gchar strdelay[32];
+
+  if (timestamp)
+    to_iso8601(strdelay, timestamp);
+  else
+    strdelay[0] = '\0';
+#endif
 
   if (encrypted == ENCRYPTED_PGP)
     message_flags |= HBB_PREFIX_PGPCRYPT;
@@ -240,6 +248,7 @@
       { "resource", resname },
       { "message", msg },
       { "groupchat", is_groupchat ? "true" : "false" },
+      { "delayed", strdelay },
       { NULL, NULL },
     };
     h_result = hk_run_handlers(HOOK_PRE_MESSAGE_IN, args);
@@ -389,6 +398,7 @@
       { "message", msg },
       { "groupchat", is_groupchat ? "true" : "false" },
       { "attention", attention ? "true" : "false" },
+      { "delayed", strdelay },
       { NULL, NULL },
     };
     hk_run_handlers(HOOK_POST_MESSAGE_IN, args);