X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=bind.c;fp=bind.c;h=f4a760e9f6f160db3f556f18da937939747a08ea;hb=8729c58972d65ab4b4b7ef3da9bcaf0d7f237d4c;hp=0000000000000000000000000000000000000000;hpb=fee0c9537ee0b8dc497fd789d0c20e5db09766a8;p=cascardo%2Fhcxmpp.git diff --git a/bind.c b/bind.c new file mode 100644 index 0000000..f4a760e --- /dev/null +++ b/bind.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2008 Thadeu Lima de Souza Cascardo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + + +#include "xmpp_internal.h" +#include "bind.h" + +void +hc_xmpp_bind (hc_xmpp_t *xmpp) +{ + iks *iqbind; + iks *query; + iqbind = iks_new ("iq"); + iks_insert_attrib (iqbind, "type", "set"); + query = iks_insert (iqbind, "bind"); + iks_insert_attrib (query, "xmlns", HC_XMPP_NS_BIND); + hc_xmpp_send_iks (xmpp, iqbind); + iks_delete (iqbind); +} + +void +hc_xmpp_bind_result (hc_xmpp_t *xmpp, iks *result) +{ + if (!iks_strcmp (iks_find_attrib (result, "type"), "result")) + { + xmpp->status = HC_XMPP_BOUND; + xmpp->bind |= ENABLED; + } +} + +void +hc_xmpp_session (hc_xmpp_t *xmpp) +{ + iks *iqsession; + iks *query; + iqsession = iks_new ("iq"); + iks_insert_attrib (iqsession, "type", "set"); + query = iks_insert (iqsession, "session"); + iks_insert_attrib (query, "xmlns", HC_XMPP_NS_SESSION); + hc_xmpp_send_iks (xmpp, iqsession); + iks_delete (iqsession); +} + +void +hc_xmpp_session_result (hc_xmpp_t *xmpp, iks *result) +{ + if (!iks_strcmp (iks_find_attrib (result, "type"), "result")) + { + xmpp->status = HC_XMPP_SESSION; + xmpp->session |= ENABLED; + } +} +