changeset 2156:a54c084af4d6

Add a "carbon" parameter to the hook-{pre,post}-message-in hooks
author Mikael Berthe <mikael@lilotux.net>
date Sat, 04 Oct 2014 20:38:41 +0200
parents a053629321ed
children 443d05b24762
files mcabber/doc/HOWTO_modules.txt mcabber/mcabber/hooks.c mcabber/mcabber/hooks.h mcabber/mcabber/xmpp.c
diffstat 4 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/doc/HOWTO_modules.txt	Sat Oct 04 18:49:52 2014 +0200
+++ b/mcabber/doc/HOWTO_modules.txt	Sat Oct 04 20:38:41 2014 +0200
@@ -201,6 +201,7 @@
    * delayed - message timestamp (ISO-8601 string) or empty string if
      the message wasn't delayed
    * error - "true" if this is an error message
+   * carbon - "true" if this is a message carbon (cf. XEP-0280)
  - hook-post-message-in (HOOK_POST_MESSAGE_IN) with parameters
    * jid - sender of the incoming message
    * resource - resource of the incoming message
@@ -212,6 +213,7 @@
    * delayed - message timestamp (ISO-8601 string) or empty string if
      the message wasn't delayed
    * error - "true" if this is an error message
+   * carbon - "true" if this is a message carbon (cf. XEP-0280)
  - hook-message-out (HOOK_MESSAGE_OUT) with parameters
    * jid - recipient of the outgoing message
    * message - message body, converted to locale charset
--- a/mcabber/mcabber/hooks.c	Sat Oct 04 18:49:52 2014 +0200
+++ b/mcabber/mcabber/hooks.c	Sat Oct 04 20:38:41 2014 +0200
@@ -183,7 +183,7 @@
 
 void hk_message_in(const char *bjid, const char *resname,
                    time_t timestamp, const char *msg, LmMessageSubType type,
-                   guint encrypted)
+                   guint encrypted, gboolean carbon)
 {
   int new_guy = FALSE;
   int is_groupchat = FALSE; // groupchat message
@@ -251,6 +251,7 @@
       { "groupchat", is_groupchat ? "true" : "false" },
       { "delayed", strdelay },
       { "error", error_msg_subtype ? "true" : "false" },
+      { "carbon", carbon ? "true" : "false" },
       { NULL, NULL },
     };
     h_result = hk_run_handlers(HOOK_PRE_MESSAGE_IN, args);
@@ -405,6 +406,7 @@
       { "attention", attention ? "true" : "false" },
       { "delayed", strdelay },
       { "error", error_msg_subtype ? "true" : "false" },
+      { "carbon", carbon ? "true" : "false" },
       { NULL, NULL },
     };
     hk_run_handlers(HOOK_POST_MESSAGE_IN, args);
--- a/mcabber/mcabber/hooks.h	Sat Oct 04 18:49:52 2014 +0200
+++ b/mcabber/mcabber/hooks.h	Sat Oct 04 20:38:41 2014 +0200
@@ -47,7 +47,7 @@
 
 void hk_message_in(const char *bjid, const char *resname,
                    time_t timestamp, const char *msg, LmMessageSubType type,
-                   guint encrypted);
+                   guint encrypted, gboolean carbon);
 void hk_message_out(const char *bjid, const char *nickname,
                     time_t timestamp, const char *msg,
                     guint encrypted,  gpointer xep184);
--- a/mcabber/mcabber/xmpp.c	Sat Oct 04 18:49:52 2014 +0200
+++ b/mcabber/mcabber/xmpp.c	Sat Oct 04 20:38:41 2014 +0200
@@ -1191,8 +1191,7 @@
         fullbody = g_strdup_printf("[%s]\n", subject);
       body = fullbody;
     }
-    // XXX/TODO: pass the carbon status (Mikael)
-    hk_message_in(bjid, rname, timestamp, body, type, encrypted);
+    hk_message_in(bjid, rname, timestamp, body, type, encrypted, carbon);
     g_free(fullbody);
   }