Included a public function into the header
[cascardo/chat.git] / xmpp.c
diff --git a/xmpp.c b/xmpp.c
index 283c68a..94cd9ab 100644 (file)
--- a/xmpp.c
+++ b/xmpp.c
@@ -38,6 +38,12 @@ hc_xmpp_new (iksStreamHook *hook, char *server, char *user, char *pass)
   xmpp->tls = NONE;
   xmpp->sasl = NONE;
   xmpp->status = HC_XMPP_NONE;
+  xmpp->msghook = 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);
+  g_hash_table_insert (xmpp->nshooks, HC_XMPP_NS_DISCO_INFO,
+                       hc_xmpp_hook_disco);
   return xmpp;
 }
 
@@ -149,3 +155,22 @@ hc_xmpp_status (hc_xmpp_t *xmpp)
 {
   return xmpp->status;
 }
+
+void
+hc_xmpp_register_ns_hook (hc_xmpp_t *xmpp, char *ns, hc_xmpp_hook_t hook)
+{
+  g_hash_table_insert (xmpp->nshooks, ns, hook);
+}
+
+void
+hc_xmpp_set_msg_hook (hc_xmpp_t *xmpp, hc_xmpp_hook_t hook)
+{
+  xmpp->msghook = hook;
+}
+
+void
+hc_xmpp_recv_message (hc_xmpp_t *xmpp, iks *stanza)
+{
+  if (xmpp->msghook)
+    xmpp->msghook (xmpp, stanza);
+}