Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
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
00054
00055 #define NET_IO_BUF_SIZE 4096
00056
00057 #define IKS_NET_EXPIRED 12
00058
00059 #include <iksemel.h>
00060 #include "asterisk/astobj.h"
00061 #include "asterisk/linkedlists.h"
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 #define AJI_MAX_JIDLEN 3071
00074 #define AJI_MAX_RESJIDLEN 1023
00075 #define AJI_MAX_ATTRLEN 256
00076
00077 #define MUC_NS "http://jabber.org/protocol/muc"
00078
00079 enum aji_state {
00080 AJI_DISCONNECTING,
00081 AJI_DISCONNECTED,
00082 AJI_CONNECTING,
00083 AJI_CONNECTED
00084 };
00085
00086 enum {
00087 AJI_AUTOPRUNE = (1 << 0),
00088 AJI_AUTOREGISTER = (1 << 1),
00089 AJI_AUTOACCEPT = (1 << 2),
00090 };
00091
00092 enum {
00093 AJI_XEP0248 = (1 << 0),
00094 AJI_PUBSUB = (1 << 1),
00095 AJI_PUBSUB_AUTOCREATE = (1 << 2),
00096 };
00097
00098 enum aji_btype {
00099 AJI_USER = 0,
00100 AJI_TRANS = 1,
00101 AJI_UTRANS = 2,
00102 };
00103
00104 struct aji_version {
00105 char version[50];
00106 int jingle;
00107 struct aji_capabilities *parent;
00108 struct aji_version *next;
00109 };
00110
00111 struct aji_capabilities {
00112 char node[200];
00113 struct aji_version *versions;
00114 struct aji_capabilities *next;
00115 };
00116
00117 struct aji_resource {
00118 int status;
00119 char resource[AJI_MAX_RESJIDLEN];
00120 char *description;
00121 struct aji_version *cap;
00122 int priority;
00123 struct aji_resource *next;
00124 };
00125
00126 struct aji_message {
00127 char *from;
00128 char *message;
00129 char id[25];
00130 struct timeval arrived;
00131 AST_LIST_ENTRY(aji_message) list;
00132 };
00133
00134 struct aji_buddy {
00135 ASTOBJ_COMPONENTS_FULL(struct aji_buddy, AJI_MAX_JIDLEN, 1);
00136 char channel[160];
00137 struct aji_resource *resources;
00138 enum aji_btype btype;
00139 struct ast_flags flags;
00140 };
00141
00142 struct aji_buddy_container {
00143 ASTOBJ_CONTAINER_COMPONENTS(struct aji_buddy);
00144 };
00145
00146 struct aji_transport_container {
00147 ASTOBJ_CONTAINER_COMPONENTS(struct aji_transport);
00148 };
00149
00150 struct aji_client {
00151 ASTOBJ_COMPONENTS(struct aji_client);
00152 char password[160];
00153 char user[AJI_MAX_JIDLEN];
00154 char serverhost[AJI_MAX_RESJIDLEN];
00155 char pubsub_node[AJI_MAX_RESJIDLEN];
00156 char statusmessage[256];
00157 char name_space[256];
00158 char sid[10];
00159 char mid[6];
00160 char context[AST_MAX_CONTEXT];
00161 iksid *jid;
00162 iksparser *p;
00163 iksfilter *f;
00164 ikstack *stack;
00165 #ifdef HAVE_OPENSSL
00166 SSL_CTX *ssl_context;
00167 SSL *ssl_session;
00168 const SSL_METHOD *ssl_method;
00169 unsigned int stream_flags;
00170 #endif
00171 enum aji_state state;
00172 int port;
00173 int debug;
00174 int usetls;
00175 int forcessl;
00176 int usesasl;
00177 int keepalive;
00178 int allowguest;
00179 int timeout;
00180 int message_timeout;
00181 int authorized;
00182 int distribute_events;
00183 int send_to_dialplan;
00184 struct ast_flags flags;
00185 int component;
00186 struct aji_buddy_container buddies;
00187 AST_LIST_HEAD(messages,aji_message) messages;
00188 void *jingle;
00189 pthread_t thread;
00190 int priority;
00191 enum ikshowtype status;
00192 };
00193
00194 struct aji_client_container{
00195 ASTOBJ_CONTAINER_COMPONENTS(struct aji_client);
00196 };
00197
00198
00199 int ast_aji_send(struct aji_client *client, iks *x);
00200
00201 int ast_aji_send_chat(struct aji_client *client, const char *address, const char *message);
00202
00203
00204 int ast_aji_send_groupchat(struct aji_client *client, const char *nick, const char *address, const char *message);
00205
00206 int ast_aji_disconnect(struct aji_client *client);
00207 int ast_aji_check_roster(void);
00208 void ast_aji_increment_mid(char *mid);
00209
00210 int ast_aji_create_chat(struct aji_client *client,char *room, char *server, char *topic);
00211
00212 int ast_aji_invite_chat(struct aji_client *client, char *user, char *room, char *message);
00213
00214 int ast_aji_join_chat(struct aji_client *client, char *room, char *nick);
00215 int ast_aji_leave_chat(struct aji_client *client, char *room, char *nick);
00216
00217 struct aji_client *ast_aji_get_client(const char *name);
00218 struct aji_client_container *ast_aji_get_clients(void);
00219
00220 void ast_aji_buddy_destroy(struct aji_buddy *obj);
00221
00222 void ast_aji_client_destroy(struct aji_client *obj);
00223
00224 #endif