Create a hook for sent messages
authorThadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
Tue, 25 Nov 2008 02:23:56 +0000 (00:23 -0200)
committerThadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
Tue, 25 Nov 2008 02:23:56 +0000 (00:23 -0200)
message.c
xmpp.c
xmpp.h
xmpp_internal.h

index be28d5d..f1d1941 100644 (file)
--- a/message.c
+++ b/message.c
@@ -28,5 +28,6 @@ hc_xmpp_send_message (hc_xmpp_t *xmpp, char *to, char *body)
   bd = iks_insert (msg, "body");
   iks_insert_cdata (bd, body, 0);
   hc_xmpp_send_iks (xmpp, msg);
+  hc_xmpp_sent_message (xmpp, msg);
   iks_delete (msg);
 }
diff --git a/xmpp.c b/xmpp.c
index 94cd9ab..8095af7 100644 (file)
--- a/xmpp.c
+++ b/xmpp.c
@@ -168,9 +168,22 @@ hc_xmpp_set_msg_hook (hc_xmpp_t *xmpp, hc_xmpp_hook_t hook)
   xmpp->msghook = hook;
 }
 
+void
+hc_xmpp_set_sent_msg_hook (hc_xmpp_t *xmpp, hc_xmpp_hook_t hook)
+{
+  xmpp->sentmsghook = hook;
+}
+
 void
 hc_xmpp_recv_message (hc_xmpp_t *xmpp, iks *stanza)
 {
   if (xmpp->msghook)
     xmpp->msghook (xmpp, stanza);
 }
+
+void
+hc_xmpp_sent_message (hc_xmpp_t *xmpp, iks *stanza)
+{
+  if (xmpp->sentmsghook)
+    xmpp->sentmsghook (xmpp, stanza);
+}
diff --git a/xmpp.h b/xmpp.h
index f04cddb..652ad5c 100644 (file)
--- a/xmpp.h
+++ b/xmpp.h
@@ -62,7 +62,9 @@ int hc_xmpp_status (hc_xmpp_t *);
 int hc_xmpp_hook (void *, int, iks *);
 void hc_xmpp_send_stream (hc_xmpp_t *);
 void hc_xmpp_set_msg_hook (hc_xmpp_t *, hc_xmpp_hook_t);
+void hc_xmpp_set_sent_msg_hook (hc_xmpp_t *, hc_xmpp_hook_t);
 void hc_xmpp_register_ns_hook (hc_xmpp_t *, char *, hc_xmpp_hook_t);
 void hc_xmpp_recv_message (hc_xmpp_t *, iks *);
+void hc_xmpp_sent_message (hc_xmpp_t *, iks *);
 
 #endif
index 1196cf8..68c60d6 100644 (file)
@@ -43,6 +43,7 @@ struct _hc_xmpp_t
   Gsasl *sasl_ctx;
   Gsasl_session *sasl_session;
   hc_xmpp_hook_t msghook;
+  hc_xmpp_hook_t sentmsghook;
   GHashTable *nshooks;
   int fd;
   int tls;