Fix bug with uninitialized variable.
[cascardo/chat.git] / xmpp.c
diff --git a/xmpp.c b/xmpp.c
index 8095af7..b258984 100644 (file)
--- a/xmpp.c
+++ b/xmpp.c
@@ -39,6 +39,7 @@ hc_xmpp_new (iksStreamHook *hook, char *server, char *user, char *pass)
   xmpp->sasl = NONE;
   xmpp->status = HC_XMPP_NONE;
   xmpp->msghook = NULL;
+  xmpp->sentmsghook = NULL;
   xmpp->nshooks = g_hash_table_new (g_str_hash, g_str_equal);
   g_hash_table_insert (xmpp->nshooks, HC_XMPP_NS_BIND, hc_xmpp_hook_bind);
   g_hash_table_insert (xmpp->nshooks, HC_XMPP_NS_SESSION, hc_xmpp_hook_session);
@@ -174,6 +175,18 @@ hc_xmpp_set_sent_msg_hook (hc_xmpp_t *xmpp, hc_xmpp_hook_t hook)
   xmpp->sentmsghook = hook;
 }
 
+void
+hc_xmpp_set_pres_hook (hc_xmpp_t *xmpp, hc_xmpp_hook_t hook)
+{
+  xmpp->preshook = hook;
+}
+
+void
+hc_xmpp_set_sent_pres_hook (hc_xmpp_t *xmpp, hc_xmpp_hook_t hook)
+{
+  xmpp->sentpreshook = hook;
+}
+
 void
 hc_xmpp_recv_message (hc_xmpp_t *xmpp, iks *stanza)
 {
@@ -187,3 +200,17 @@ hc_xmpp_sent_message (hc_xmpp_t *xmpp, iks *stanza)
   if (xmpp->sentmsghook)
     xmpp->sentmsghook (xmpp, stanza);
 }
+
+void
+hc_xmpp_recv_presence (hc_xmpp_t *xmpp, iks *stanza)
+{
+  if (xmpp->preshook)
+    xmpp->preshook (xmpp, stanza);
+}
+
+void
+hc_xmpp_sent_presence (hc_xmpp_t *xmpp, iks *stanza)
+{
+  if (xmpp->sentpreshook)
+    xmpp->sentpreshook (xmpp, stanza);
+}