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 iksid *jid;
00161 iksparser *p;
00162 iksfilter *f;
00163 ikstack *stack;
00164 #ifdef HAVE_OPENSSL
00165 SSL_CTX *ssl_context;
00166 SSL *ssl_session;
00167 const SSL_METHOD *ssl_method;
00168 unsigned int stream_flags;
00169 #endif
00170 enum aji_state state;
00171 int port;
00172 int debug;
00173 int usetls;
00174 int forcessl;
00175 int usesasl;
00176 int keepalive;
00177 int allowguest;
00178 int timeout;
00179 int message_timeout;
00180 int authorized;
00181 int distribute_events;
00182 struct ast_flags flags;
00183 int component;
00184 struct aji_buddy_container buddies;
00185 AST_LIST_HEAD(messages,aji_message) messages;
00186 void *jingle;
00187 pthread_t thread;
00188 int priority;
00189 enum ikshowtype status;
00190 };
00191
00192 struct aji_client_container{
00193 ASTOBJ_CONTAINER_COMPONENTS(struct aji_client);
00194 };
00195
00196
00197 int ast_aji_send(struct aji_client *client, iks *x);
00198
00199 int ast_aji_send_chat(struct aji_client *client, const char *address, const char *message);
00200
00201
00202 int ast_aji_send_groupchat(struct aji_client *client, const char *nick, const char *address, const char *message);
00203
00204 int ast_aji_disconnect(struct aji_client *client);
00205 int ast_aji_check_roster(void);
00206 void ast_aji_increment_mid(char *mid);
00207
00208 int ast_aji_create_chat(struct aji_client *client,char *room, char *server, char *topic);
00209
00210 int ast_aji_invite_chat(struct aji_client *client, char *user, char *room, char *message);
00211
00212 int ast_aji_join_chat(struct aji_client *client, char *room, char *nick);
00213 int ast_aji_leave_chat(struct aji_client *client, char *room, char *nick);
00214
00215 struct aji_client *ast_aji_get_client(const char *name);
00216 struct aji_client_container *ast_aji_get_clients(void);
00217
00218 void ast_aji_buddy_destroy(struct aji_buddy *obj);
00219
00220 void ast_aji_client_destroy(struct aji_client *obj);
00221
00222 #endif