X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fhcxmpp.git;a=blobdiff_plain;f=xmpp.c;h=b25898466cedd68f375976bc7e93c4d38f41252f;hp=ca9501eced3af739d27632dee2c1b13ebd9f2581;hb=HEAD;hpb=fee0c9537ee0b8dc497fd789d0c20e5db09766a8 diff --git a/xmpp.c b/xmpp.c index ca9501e..b258984 100644 --- a/xmpp.c +++ b/xmpp.c @@ -38,6 +38,13 @@ 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->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); + g_hash_table_insert (xmpp->nshooks, HC_XMPP_NS_DISCO_INFO, + hc_xmpp_hook_disco); return xmpp; } @@ -89,12 +96,36 @@ hc_xmpp_is_sasl_enabled (hc_xmpp_t *xmpp) return xmpp->sasl & ENABLED; } +int +hc_xmpp_is_bind_supported (hc_xmpp_t *xmpp) +{ + return xmpp->bind & SUPPORTED; +} + +int +hc_xmpp_is_session_supported (hc_xmpp_t *xmpp) +{ + return xmpp->session & SUPPORTED; +} + +int +hc_xmpp_is_session_required (hc_xmpp_t *xmpp) +{ + return xmpp->session & REQUIRED; +} + char * hc_xmpp_server (hc_xmpp_t *xmpp) { return xmpp->server; } +int +hc_xmpp_fd (hc_xmpp_t *xmpp) +{ + return xmpp->fd; +} + void hc_xmpp_send_buffer (hc_xmpp_t *xmpp, char *buffer, size_t len) { @@ -125,3 +156,61 @@ 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_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) +{ + 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); +} + +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); +}