a6a0a09a60788e02d5667bee29bcf8644452a425
[cascardo/chat.git] / xmpp.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 <stdlib.h>
21 #include "xmpp.h"
22 #include "xmpp_internal.h"
23 #include "iksemel_extra.h"
24
25 hc_xmpp_t *
26 hc_xmpp_new (iksStreamHook *hook, char *server)
27 {
28   hc_xmpp_t *xmpp = malloc (sizeof (hc_xmpp_t));
29   xmpp->server = strdup (server);
30   xmpp->parser = iks_extra_stream_new (xmpp, hook);
31   xmpp->fd = hc_tcp_connect (server, "xmpp-client");
32   xmpp->tls = NONE;
33   xmpp->sasl = NONE;
34   return xmpp;
35 }
36
37 int
38 hc_xmpp_is_tls_supported (hc_xmpp_t *xmpp)
39 {
40   return xmpp->tls & SUPPORTED;
41 }
42
43 int
44 hc_xmpp_is_tls_required (hc_xmpp_t *xmpp)
45 {
46   return xmpp->tls & REQUIRED;
47 }
48
49 int
50 hc_xmpp_is_tls_optional (hc_xmpp_t *xmpp)
51 {
52   return xmpp->tls & OPTIONAL;
53 }
54
55 int
56 hc_xmpp_is_tls_enabled (hc_xmpp_t *xmpp)
57 {
58   return xmpp->tls & ENABLED;
59 }
60
61 int
62 hc_xmpp_is_sasl_supported (hc_xmpp_t *xmpp)
63 {
64   return xmpp->sasl & SUPPORTED;
65 }
66
67 int
68 hc_xmpp_is_sasl_required (hc_xmpp_t *xmpp)
69 {
70   return xmpp->sasl & REQUIRED;
71 }
72
73 int
74 hc_xmpp_is_sasl_optional (hc_xmpp_t *xmpp)
75 {
76   return xmpp->sasl & OPTIONAL;
77 }
78
79 int
80 hc_xmpp_is_sasl_enabled (hc_xmpp_t *xmpp)
81 {
82   return xmpp->sasl & ENABLED;
83 }
84