fdfa94f9a651897bb1655bde9e62164a3bb72ad6
[asterisk/asterisk.git] / include / asterisk / jabber.h
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Matt O'Gorman <mogorman@digium.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18
19 #ifndef _ASTERISK_JABBER_H
20 #define _ASTERISK_JABBER_H
21
22 #include <iksemel.h>
23 #include "asterisk/astobj.h"
24 #include "asterisk/linkedlists.h"
25
26 enum aji_state {
27         AJI_DISCONNECTED = 0,
28         AJI_CONNECTING,
29         AJI_CONNECTED
30 };
31
32 enum {
33         AJI_AUTOPRUNE = (1 << 0),
34         AJI_AUTOREGISTER = (1 << 1)
35 };
36
37 enum aji_btype {
38         AJI_USER=0,
39         AJI_TRANS=1,
40         AJI_UTRANS=2
41 };
42
43 struct aji_version {
44         char version[50];
45         int jingle;
46         struct aji_capabilities *parent;
47         struct aji_version *next;
48 };
49
50 struct aji_capabilities {
51         char node[200];
52         struct aji_version *versions;
53         struct aji_capabilities *next;
54 };
55
56 struct aji_resource {
57         int status;
58         char resource[80];
59         char *description;
60         struct aji_version *cap;
61         int priority;
62         struct aji_resource *next;
63 };
64
65 struct aji_message {
66         char *from;
67         char *message;
68         char id[25];
69         time_t arrived;
70         AST_LIST_ENTRY(aji_message) list;
71 };
72
73 struct aji_buddy {
74         ASTOBJ_COMPONENTS(struct aji_buddy);
75         char channel[160];
76         struct aji_resource *resources;
77         enum aji_btype btype;
78         unsigned int flags;
79 };
80
81 struct aji_buddy_container {
82         ASTOBJ_CONTAINER_COMPONENTS(struct aji_buddy);
83 };
84
85 struct aji_transport_container {
86         ASTOBJ_CONTAINER_COMPONENTS(struct aji_transport);
87 };
88
89 struct aji_client {
90         ASTOBJ_COMPONENTS(struct aji_client);
91         char password[160];
92         char user[160];
93         char serverhost[160];
94         char context[100];
95         char statusmessage[256];
96         char sid[10]; /* Session ID */
97         char mid[6]; /* Message ID */
98         iksid *jid;
99         iksparser *p;
100         iksfilter *f;
101         ikstack *stack;
102         enum aji_state state;
103         int port;
104         int debug;
105         int usetls;
106         int forcessl;
107         int usesasl;
108         int keepalive;
109         int allowguest;
110         int timeout;
111         int message_timeout;
112         int authorized;
113         unsigned int flags;
114         int component; /* 0 client,  1 component */
115         struct aji_buddy_container buddies;
116         AST_LIST_HEAD(messages,aji_message) messages;
117         void *jingle;
118         pthread_t thread;
119 };
120
121 struct aji_client_container{
122         ASTOBJ_CONTAINER_COMPONENTS(struct aji_client);
123 };
124
125 int ast_aji_send(struct aji_client *client, const char *address, const char *message);
126 int ast_aji_disconnect(struct aji_client *client);
127 int ast_aji_check_roster(void);
128 void ast_aji_increment_mid(char *mid);
129 int ast_aji_create_chat(struct aji_client *client,char *room, char *server, char *topic);
130 int ast_aji_invite_chat(struct aji_client *client, char *user, char *room, char *message);
131 int ast_aji_join_chat(struct aji_client *client,char *room);
132 struct aji_client *ast_aji_get_client(const char *name);
133 struct aji_client_container *ast_aji_get_clients(void);
134
135 #endif