Created extensible hooks
[cascardo/chat.git] / bind.c
1 /*
2  *  Copyright (C) 2008  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License along
15  *  with this program; if not, write to the Free Software Foundation, Inc.,
16  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19
20 #include "xmpp_internal.h"
21 #include "bind.h"
22
23 void
24 hc_xmpp_bind (hc_xmpp_t *xmpp)
25 {
26   iks *iqbind;
27   iks *query;
28   iqbind = iks_new ("iq");
29   iks_insert_attrib (iqbind, "type", "set");
30   query = iks_insert (iqbind, "bind");
31   iks_insert_attrib (query, "xmlns", HC_XMPP_NS_BIND);
32   hc_xmpp_send_iks (xmpp, iqbind);
33   iks_delete (iqbind);
34 }
35
36 void
37 hc_xmpp_bind_result (hc_xmpp_t *xmpp, iks *result)
38 {
39   if (!iks_strcmp (iks_find_attrib (result, "type"), "result"))
40     {
41       xmpp->status = HC_XMPP_BOUND;
42       xmpp->bind |= ENABLED;
43     }
44 }
45
46 void
47 hc_xmpp_session (hc_xmpp_t *xmpp)
48 {
49   iks *iqsession;
50   iks *query;
51   iqsession = iks_new ("iq");
52   iks_insert_attrib (iqsession, "type", "set");
53   query = iks_insert (iqsession, "session");
54   iks_insert_attrib (query, "xmlns", HC_XMPP_NS_SESSION);
55   hc_xmpp_send_iks (xmpp, iqsession);
56   iks_delete (iqsession);
57 }
58
59 void
60 hc_xmpp_session_result (hc_xmpp_t *xmpp, iks *result)
61 {
62   if (!iks_strcmp (iks_find_attrib (result, "type"), "result"))
63     {
64       xmpp->status = HC_XMPP_SESSION;
65       xmpp->session |= ENABLED;
66     }
67 }
68