2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Matt O'Gorman <mogorman@digium.com>
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.
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.
20 * \brief AJI - The Asterisk Jabber Interface
23 * \author Matt O'Gorman <mogorman@digium.com>
24 * \extref IKSEMEL http://iksemel.jabberstudio.org
26 * \page AJI_intro AJI - The Asterisk Jabber Interface
28 * The Asterisk Jabber Interface, AJI, publishes an API for
29 * modules to use jabber communication. res_jabber.c implements
30 * a Jabber client and a component that can connect as a service
33 * \section External dependencies
34 * AJI use the IKSEMEL library found at http://iksemel.jabberstudio.org/
43 #ifndef _ASTERISK_JABBER_H
44 #define _ASTERISK_JABBER_H
48 #include <openssl/ssl.h>
49 #include <openssl/err.h>
52 /* file is read by blocks with this size */
53 #define NET_IO_BUF_SIZE 4096
54 /* Return value for timeout connection expiration */
55 #define IKS_NET_EXPIRED 12
57 #endif /* HAVE_OPENSSL */
60 #include "asterisk/astobj.h"
61 #include "asterisk/linkedlists.h"
64 * As per RFC 3920 - section 3.1, the maximum length for a full Jabber ID
66 * The ABNF syntax for jid :
67 * jid = [node "@" ] domain [ "/" resource ]
68 * Each allowable portion of a JID (node identifier, domain identifier,
69 * and resource identifier) MUST NOT be more than 1023 bytes in length,
70 * resulting in a maximum total size (including the '@' and '/' separators)
73 #define AJI_MAX_JIDLEN 3071
74 #define AJI_MAX_RESJIDLEN 1023
84 AJI_AUTOPRUNE = (1 << 0),
85 AJI_AUTOREGISTER = (1 << 1)
97 struct aji_capabilities *parent;
98 struct aji_version *next;
101 struct aji_capabilities {
103 struct aji_version *versions;
104 struct aji_capabilities *next;
107 struct aji_resource {
109 char resource[AJI_MAX_RESJIDLEN];
111 struct aji_version *cap;
113 struct aji_resource *next;
121 AST_LIST_ENTRY(aji_message) list;
125 ASTOBJ_COMPONENTS_FULL(struct aji_buddy, AJI_MAX_JIDLEN, 1);
127 struct aji_resource *resources;
128 enum aji_btype btype;
132 struct aji_buddy_container {
133 ASTOBJ_CONTAINER_COMPONENTS(struct aji_buddy);
136 struct aji_transport_container {
137 ASTOBJ_CONTAINER_COMPONENTS(struct aji_transport);
141 ASTOBJ_COMPONENTS(struct aji_client);
143 char user[AJI_MAX_JIDLEN];
144 char serverhost[AJI_MAX_RESJIDLEN];
145 char statusmessage[256];
146 char name_space[256];
147 char sid[10]; /* Session ID */
148 char mid[6]; /* Message ID */
154 SSL_CTX *ssl_context;
156 SSL_METHOD *ssl_method;
157 unsigned int stream_flags;
158 #endif /* HAVE_OPENSSL */
159 enum aji_state state;
171 int component; /* 0 client, 1 component */
172 struct aji_buddy_container buddies;
173 AST_LIST_HEAD(messages,aji_message) messages;
177 enum ikshowtype status;
180 struct aji_client_container{
181 ASTOBJ_CONTAINER_COMPONENTS(struct aji_client);
184 /* !Send XML stanza over the established XMPP connection */
185 int ast_aji_send(struct aji_client *client, iks *x);
186 /*! Send jabber chat message from connected client to jabber URI */
187 int ast_aji_send_chat(struct aji_client *client, const char *address, const char *message);
188 /*! Disconnect jabber client */
189 int ast_aji_disconnect(struct aji_client *client);
190 int ast_aji_check_roster(void);
191 void ast_aji_increment_mid(char *mid);
192 /*! Open Chat session */
193 int ast_aji_create_chat(struct aji_client *client,char *room, char *server, char *topic);
194 /*! Invite to opened Chat session */
195 int ast_aji_invite_chat(struct aji_client *client, char *user, char *room, char *message);
196 /*! Join existing Chat session */
197 int ast_aji_join_chat(struct aji_client *client,char *room);
198 struct aji_client *ast_aji_get_client(const char *name);
199 struct aji_client_container *ast_aji_get_clients(void);