Wed Oct 28 11:45:39 2009

Asterisk developer's documentation


jabber.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Matt O'Gorman <mogorman@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  * \brief AJI - The Asterisk Jabber Interface
00021  * \arg \ref AJI_intro
00022  * \ref res_jabber.c
00023  * \author Matt O'Gorman <mogorman@digium.com>
00024  * \extref IKSEMEL http://iksemel.jabberstudio.org
00025  *
00026  * \page AJI_intro AJI - The Asterisk Jabber Interface
00027  * 
00028  * The Asterisk Jabber Interface, AJI, publishes an API for
00029  * modules to use jabber communication. res_jabber.c implements
00030  * a Jabber client and a component that can connect as a service
00031  * to Jabber servers.
00032  *
00033  * \section External dependencies
00034  * AJI use the IKSEMEL library found at http://iksemel.jabberstudio.org/
00035  *
00036  * \section Files
00037  * - res_jabber.c
00038  * - jabber.h
00039  * - chan_gtalk.c
00040  *
00041  */
00042 
00043 #ifndef _ASTERISK_JABBER_H
00044 #define _ASTERISK_JABBER_H
00045 
00046 #ifdef HAVE_OPENSSL
00047 
00048 #include <openssl/ssl.h>
00049 #include <openssl/err.h>
00050 #define TRY_SECURE 2
00051 #define SECURE 4
00052 
00053 #endif /* HAVE_OPENSSL */
00054 /* file is read by blocks with this size */
00055 #define NET_IO_BUF_SIZE 4096
00056 /* Return value for timeout connection expiration */
00057 #define IKS_NET_EXPIRED 12
00058 
00059 #include <iksemel.h>
00060 #include "asterisk/astobj.h"
00061 #include "asterisk/linkedlists.h"
00062 
00063 /* 
00064  * As per RFC 3920 - section 3.1, the maximum length for a full Jabber ID 
00065  * is 3071 bytes.
00066  * The ABNF syntax for jid :
00067  * jid = [node "@" ] domain [ "/" resource ]
00068  * Each allowable portion of a JID (node identifier, domain identifier,
00069  * and resource identifier) MUST NOT be more than 1023 bytes in length,
00070  * resulting in a maximum total size (including the '@' and '/' separators) 
00071  * of 3071 bytes.
00072  */
00073 #define AJI_MAX_JIDLEN 3071
00074 #define AJI_MAX_RESJIDLEN 1023
00075 
00076 enum aji_state {
00077    AJI_DISCONNECTING,
00078    AJI_DISCONNECTED,
00079    AJI_CONNECTING,
00080    AJI_CONNECTED
00081 };
00082 
00083 enum {
00084    AJI_AUTOPRUNE = (1 << 0),
00085    AJI_AUTOREGISTER = (1 << 1)
00086 };
00087 
00088 enum aji_btype {
00089    AJI_USER=0,
00090    AJI_TRANS=1,
00091    AJI_UTRANS=2
00092 };
00093 
00094 struct aji_version {
00095    char version[50];
00096    int jingle;
00097    struct aji_capabilities *parent;
00098    struct aji_version *next;
00099 };
00100 
00101 struct aji_capabilities {
00102    char node[200];
00103    struct aji_version *versions;
00104    struct aji_capabilities *next;
00105 };
00106 
00107 struct aji_resource {
00108    int status;
00109    char resource[AJI_MAX_RESJIDLEN];
00110    char *description;
00111    struct aji_version *cap;
00112    int priority;
00113    struct aji_resource *next;
00114 };
00115 
00116 struct aji_message {
00117    char *from;
00118    char *message;
00119    char id[25];
00120    time_t arrived;
00121    AST_LIST_ENTRY(aji_message) list;
00122 };
00123 
00124 struct aji_buddy {
00125    ASTOBJ_COMPONENTS_FULL(struct aji_buddy, AJI_MAX_JIDLEN, 1);
00126    char channel[160];
00127    struct aji_resource *resources;
00128    enum aji_btype btype;
00129    struct ast_flags flags;
00130 };
00131 
00132 struct aji_buddy_container {
00133    ASTOBJ_CONTAINER_COMPONENTS(struct aji_buddy);
00134 };
00135 
00136 struct aji_transport_container {
00137    ASTOBJ_CONTAINER_COMPONENTS(struct aji_transport);
00138 };
00139 
00140 struct aji_client {
00141    ASTOBJ_COMPONENTS(struct aji_client);
00142    char password[160];
00143    char user[AJI_MAX_JIDLEN];
00144    char serverhost[AJI_MAX_RESJIDLEN];
00145    char statusmessage[256];
00146    char name_space[256];
00147    char sid[10]; /* Session ID */
00148    char mid[6]; /* Message ID */
00149    iksid *jid;
00150    iksparser *p;
00151    iksfilter *f;
00152    ikstack *stack;
00153 #ifdef HAVE_OPENSSL
00154    SSL_CTX *ssl_context;
00155    SSL *ssl_session;
00156    SSL_METHOD *ssl_method;
00157    unsigned int stream_flags;
00158 #endif /* HAVE_OPENSSL */
00159    enum aji_state state;
00160    int port;
00161    int debug;
00162    int usetls;
00163    int forcessl;
00164    int usesasl;
00165    int keepalive;
00166    int allowguest;
00167    int timeout;
00168    int message_timeout;
00169    int authorized;
00170    struct ast_flags flags;
00171    int component; /* 0 client,  1 component */
00172    struct aji_buddy_container buddies;
00173    AST_LIST_HEAD(messages,aji_message) messages;
00174    void *jingle;
00175    pthread_t thread;
00176    int priority;
00177    enum ikshowtype status;
00178 };
00179 
00180 struct aji_client_container{
00181    ASTOBJ_CONTAINER_COMPONENTS(struct aji_client);
00182 };
00183 
00184 /* !Send XML stanza over the established XMPP connection */
00185 int ast_aji_send(struct aji_client *client, iks *x);
00186 /*! Send jabber chat message from connected client to jabber URI */
00187 int ast_aji_send_chat(struct aji_client *client, const char *address, const char *message);
00188 /*! Disconnect jabber client */
00189 int ast_aji_disconnect(struct aji_client *client);
00190 int ast_aji_check_roster(void);
00191 void ast_aji_increment_mid(char *mid);
00192 /*! Open Chat session */
00193 int ast_aji_create_chat(struct aji_client *client,char *room, char *server, char *topic);
00194 /*! Invite to opened Chat session */
00195 int ast_aji_invite_chat(struct aji_client *client, char *user, char *room, char *message);
00196 /*! Join existing Chat session */
00197 int ast_aji_join_chat(struct aji_client *client,char *room);
00198 struct aji_client *ast_aji_get_client(const char *name);
00199 struct aji_client_container *ast_aji_get_clients(void);
00200 
00201 #endif

Generated on Wed Oct 28 11:45:39 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6