From 76baa5c46ceab25efd6f798ea18f96e16e91e56d Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Tue, 25 Nov 2008 00:23:56 -0200 Subject: [PATCH] Create a hook for sent messages --- message.c | 1 + xmpp.c | 13 +++++++++++++ xmpp.h | 2 ++ xmpp_internal.h | 1 + 4 files changed, 17 insertions(+) diff --git a/message.c b/message.c index be28d5d..f1d1941 100644 --- 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 --- 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 --- 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 diff --git a/xmpp_internal.h b/xmpp_internal.h index 1196cf8..68c60d6 100644 --- a/xmpp_internal.h +++ b/xmpp_internal.h @@ -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; -- 2.20.1