AJI - The Asterisk Jabber Interface. More...
#include <iksemel.h>
#include "asterisk/astobj.h"
#include "asterisk/linkedlists.h"
Go to the source code of this file.
Data Structures | |
struct | aji_buddy |
struct | aji_buddy_container |
struct | aji_capabilities |
struct | aji_client |
struct | aji_client_container |
struct | aji_message |
struct | aji_resource |
struct | aji_transport_container |
struct | aji_version |
struct | aji_client::messages |
Defines | |
#define | AJI_MAX_JIDLEN 3071 |
#define | AJI_MAX_RESJIDLEN 1023 |
#define | IKS_NET_EXPIRED 12 |
#define | NET_IO_BUF_SIZE 4096 |
Enumerations | |
enum | { AJI_AUTOPRUNE = (1 << 0), AJI_AUTOREGISTER = (1 << 1) } |
enum | aji_btype { AJI_USER = 0, AJI_TRANS = 1, AJI_UTRANS = 2 } |
enum | aji_state { AJI_DISCONNECTING, AJI_DISCONNECTED, AJI_CONNECTING, AJI_CONNECTED } |
Functions | |
int | ast_aji_check_roster (void) |
int | ast_aji_create_chat (struct aji_client *client, char *room, char *server, char *topic) |
create a chatroom. | |
int | ast_aji_disconnect (struct aji_client *client) |
disconnect from jabber server. | |
struct aji_client * | ast_aji_get_client (const char *name) |
grab a aji_client structure by label name or JID (without the resource string) | |
struct aji_client_container * | ast_aji_get_clients (void) |
void | ast_aji_increment_mid (char *mid) |
increments the mid field for messages and other events. | |
int | ast_aji_invite_chat (struct aji_client *client, char *user, char *room, char *message) |
invite to a chatroom. | |
int | ast_aji_join_chat (struct aji_client *client, char *room) |
join a chatroom. | |
int | ast_aji_send (struct aji_client *client, iks *x) |
Wraps raw sending. | |
int | ast_aji_send_chat (struct aji_client *client, const char *address, const char *message) |
sends messages. |
AJI - The Asterisk Jabber Interface.
Definition in file jabber.h.
#define AJI_MAX_JIDLEN 3071 |
Definition at line 73 of file jabber.h.
Referenced by gtalk_show_channels(), and jingle_show_channels().
#define IKS_NET_EXPIRED 12 |
Definition at line 57 of file jabber.h.
Referenced by aji_recv(), and aji_recv_loop().
#define NET_IO_BUF_SIZE 4096 |
Definition at line 55 of file jabber.h.
Referenced by aji_recv().
anonymous enum |
Definition at line 83 of file jabber.h.
{ AJI_AUTOPRUNE = (1 << 0), AJI_AUTOREGISTER = (1 << 1) };
enum aji_state |
int ast_aji_check_roster | ( | void | ) |
int ast_aji_create_chat | ( | struct aji_client * | client, |
char * | room, | ||
char * | server, | ||
char * | topic | ||
) |
create a chatroom.
Open Chat session
client | the configured XMPP client we use to connect to a XMPP server |
room | name of room |
server | name of server |
topic | topic for the room. |
Definition at line 1889 of file res_jabber.c.
References ast_aji_increment_mid(), ast_aji_send(), ast_log(), LOG_ERROR, and aji_client::mid.
{ int res = 0; iks *iq = NULL; iq = iks_new("iq"); if (iq && client) { iks_insert_attrib(iq, "type", "get"); iks_insert_attrib(iq, "to", server); iks_insert_attrib(iq, "id", client->mid); ast_aji_increment_mid(client->mid); ast_aji_send(client, iq); } else ast_log(LOG_ERROR, "Out of memory.\n"); iks_delete(iq); return res; }
int ast_aji_disconnect | ( | struct aji_client * | client | ) |
disconnect from jabber server.
Disconnect jabber client
client | the configured XMPP client we use to connect to a XMPP server |
Definition at line 2378 of file res_jabber.c.
References aji_client_destroy(), ast_verb, ASTOBJ_UNREF, and aji_client::p.
Referenced by unload_module().
{ if (client) { ast_verb(4, "JABBER: Disconnecting\n"); #ifdef HAVE_OPENSSL if (client->stream_flags & SECURE) { SSL_shutdown(client->ssl_session); SSL_CTX_free(client->ssl_context); SSL_free(client->ssl_session); } #endif iks_disconnect(client->p); iks_parser_delete(client->p); ASTOBJ_UNREF(client, aji_client_destroy); } return 1; }
struct aji_client* ast_aji_get_client | ( | const char * | name | ) | [read] |
grab a aji_client structure by label name or JID (without the resource string)
name | label or JID |
Definition at line 2952 of file res_jabber.c.
References ast_strdupa, ASTOBJ_CONTAINER_FIND, ASTOBJ_CONTAINER_TRAVERSE, clients, and strsep().
Referenced by acf_jabberstatus_read(), aji_send_exec(), aji_status_exec(), gtalk_create_member(), gtalk_newcall(), gtalk_request(), jingle_create_member(), jingle_newcall(), jingle_request(), and manager_jabber_send().
{ struct aji_client *client = NULL; char *aux = NULL; client = ASTOBJ_CONTAINER_FIND(&clients, name); if (!client && strchr(name, '@')) { ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { aux = ast_strdupa(iterator->user); if (strchr(aux, '/')) { /* strip resource for comparison */ aux = strsep(&aux, "/"); } if (!strncasecmp(aux, name, strlen(aux))) { client = iterator; } }); } return client; }
struct aji_client_container* ast_aji_get_clients | ( | void | ) | [read] |
Definition at line 2974 of file res_jabber.c.
References clients.
Referenced by gtalk_load_config(), and jingle_load_config().
{ return &clients; }
void ast_aji_increment_mid | ( | char * | mid | ) |
increments the mid field for messages and other events.
mid | char. |
Definition at line 2033 of file res_jabber.c.
Referenced by aji_act_hook(), aji_handle_presence(), aji_register_approve_handler(), ast_aji_create_chat(), ast_aji_invite_chat(), gtalk_action(), gtalk_create_candidates(), gtalk_digit(), gtalk_invite(), gtalk_invite_response(), jingle_accept_call(), jingle_action(), jingle_create_candidates(), jingle_digit(), and jingle_transmit_invite().
int ast_aji_invite_chat | ( | struct aji_client * | client, |
char * | user, | ||
char * | room, | ||
char * | message | ||
) |
invite to a chatroom.
Invite to opened Chat session
client | the configured XMPP client we use to connect to a XMPP server |
user | |
room | |
message |
Definition at line 1946 of file res_jabber.c.
References ast_aji_increment_mid(), ast_aji_send(), ast_log(), LOG_ERROR, and aji_client::mid.
{ int res = 0; iks *invite, *body, *namespace; invite = iks_new("message"); body = iks_new("body"); namespace = iks_new("x"); if (client && invite && body && namespace) { iks_insert_attrib(invite, "to", user); iks_insert_attrib(invite, "id", client->mid); ast_aji_increment_mid(client->mid); iks_insert_cdata(body, message, 0); iks_insert_attrib(namespace, "xmlns", "jabber:x:conference"); iks_insert_attrib(namespace, "jid", room); iks_insert_node(invite, body); iks_insert_node(invite, namespace); res = ast_aji_send(client, invite); } else ast_log(LOG_ERROR, "Out of memory.\n"); iks_delete(body); iks_delete(namespace); iks_delete(invite); return res; }
int ast_aji_join_chat | ( | struct aji_client * | client, |
char * | room | ||
) |
join a chatroom.
Join existing Chat session
client | the configured XMPP client we use to connect to a XMPP server |
room | room to join |
Definition at line 1915 of file res_jabber.c.
References ast_aji_send(), ast_log(), and LOG_ERROR.
{ int res = 0; iks *presence = NULL, *priority = NULL; presence = iks_new("presence"); priority = iks_new("priority"); if (presence && priority && client) { iks_insert_cdata(priority, "0", 1); iks_insert_attrib(presence, "to", room); iks_insert_node(presence, priority); res = ast_aji_send(client, presence); iks_insert_cdata(priority, "5", 1); iks_insert_attrib(presence, "to", room); res = ast_aji_send(client, presence); } else ast_log(LOG_ERROR, "Out of memory.\n"); iks_delete(presence); iks_delete(priority); return res; }
int ast_aji_send | ( | struct aji_client * | client, |
iks * | x | ||
) |
Wraps raw sending.
client | the configured XMPP client we use to connect to a XMPP server |
x | the XMPP packet to send |
Definition at line 813 of file res_jabber.c.
References aji_send_raw().
Referenced by aji_act_hook(), aji_client_info_handler(), aji_dinfo_handler(), aji_ditems_handler(), aji_get_roster(), aji_handle_presence(), aji_handle_subscribe(), aji_pruneregister(), aji_register_approve_handler(), aji_register_query_handler(), aji_set_presence(), aji_start_sasl(), ast_aji_create_chat(), ast_aji_invite_chat(), ast_aji_join_chat(), ast_aji_send_chat(), gtalk_action(), gtalk_add_candidate(), gtalk_create_candidates(), gtalk_digit(), gtalk_invite(), gtalk_invite_response(), gtalk_response(), jingle_accept_call(), jingle_action(), jingle_add_candidate(), jingle_create_candidates(), jingle_digit(), jingle_response(), and jingle_transmit_invite().
{ return aji_send_raw(client, iks_string(iks_stack(x), x)); }
int ast_aji_send_chat | ( | struct aji_client * | client, |
const char * | address, | ||
const char * | message | ||
) |
sends messages.
Send jabber chat message from connected client to jabber URI
client | the configured XMPP client we use to connect to a XMPP server |
address | |
message |
Definition at line 1862 of file res_jabber.c.
References AJI_CONNECTED, ast_aji_send(), ast_log(), aji_client::jid, LOG_ERROR, LOG_WARNING, and aji_client::state.
Referenced by aji_send_exec(), aji_test(), and manager_jabber_send().
{ int res = 0; iks *message_packet = NULL; if (client->state == AJI_CONNECTED) { message_packet = iks_make_msg(IKS_TYPE_CHAT, address, message); if (message_packet) { iks_insert_attrib(message_packet, "from", client->jid->full); res = ast_aji_send(client, message_packet); } else { ast_log(LOG_ERROR, "Out of memory.\n"); } iks_delete(message_packet); } else ast_log(LOG_WARNING, "JABBER: Not connected can't send\n"); return 1; }