AJI - The Asterisk Jabber Interface. More...
#include <openssl/ssl.h>#include <openssl/err.h>#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_ATTRLEN 256 |
| #define | AJI_MAX_JIDLEN 3071 |
| #define | AJI_MAX_RESJIDLEN 1023 |
| #define | IKS_NET_EXPIRED 12 |
| #define | MUC_NS "http://jabber.org/protocol/muc" |
| #define | NET_IO_BUF_SIZE 4096 |
| #define | SECURE 4 |
| #define | TRY_SECURE 2 |
Enumerations | |
| enum | { AJI_AUTOPRUNE = (1 << 0), AJI_AUTOREGISTER = (1 << 1), AJI_AUTOACCEPT = (1 << 2) } |
| enum | { AJI_XEP0248 = (1 << 0), AJI_PUBSUB = (1 << 1), AJI_PUBSUB_AUTOCREATE = (1 << 2) } |
| enum | aji_btype { AJI_USER = 0, AJI_TRANS = 1, AJI_UTRANS = 2 } |
| enum | aji_state { AJI_DISCONNECTING, AJI_DISCONNECTED, AJI_CONNECTING, AJI_CONNECTED } |
Functions | |
| void | ast_aji_buddy_destroy (struct aji_buddy *obj) |
| int | ast_aji_check_roster (void) |
| void | ast_aji_client_destroy (struct aji_client *obj) |
| 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. Bumps the refcount. (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, char *nick) |
| join a chatroom. | |
| int | ast_aji_leave_chat (struct aji_client *client, char *room, char *nick) |
| leave 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. | |
| int | ast_aji_send_groupchat (struct aji_client *client, const char *nick, const char *address, const char *message) |
| sends message to a groupchat Prior to sending messages to a groupchat, one must be connected to it. | |
AJI - The Asterisk Jabber Interface.
Definition in file jabber.h.
| #define AJI_MAX_ATTRLEN 256 |
Definition at line 75 of file jabber.h.
Referenced by aji_act_hook().
| #define AJI_MAX_JIDLEN 3071 |
Definition at line 73 of file jabber.h.
Referenced by acf_jabberreceive_read(), aji_send_raw_chat(), aji_set_group_presence(), gtalk_show_channels(), and jingle_show_channels().
| #define AJI_MAX_RESJIDLEN 1023 |
Definition at line 74 of file jabber.h.
Referenced by aji_join_exec(), aji_leave_exec(), and aji_sendgroup_exec().
| #define IKS_NET_EXPIRED 12 |
Definition at line 57 of file jabber.h.
Referenced by aji_recv(), aji_recv_loop(), xmpp_client_receive(), and xmpp_client_thread().
| #define MUC_NS "http://jabber.org/protocol/muc" |
Definition at line 77 of file jabber.h.
Referenced by aji_set_group_presence().
| #define NET_IO_BUF_SIZE 4096 |
Definition at line 55 of file jabber.h.
Referenced by aji_recv(), and xmpp_client_receive().
| #define SECURE 4 |
Definition at line 51 of file jabber.h.
Referenced by aji_is_secure(), aji_tls_handshake(), ast_aji_disconnect(), ast_xmpp_client_disconnect(), xmpp_client_requested_tls(), and xmpp_is_secure().
| #define TRY_SECURE 2 |
Definition at line 50 of file jabber.h.
Referenced by aji_act_hook(), aji_start_tls(), aji_tls_handshake(), xmpp_client_request_tls(), and xmpp_client_requested_tls().
| anonymous enum |
Definition at line 86 of file jabber.h.
{
AJI_AUTOPRUNE = (1 << 0),
AJI_AUTOREGISTER = (1 << 1),
AJI_AUTOACCEPT = (1 << 2),
};
| anonymous enum |
Definition at line 92 of file jabber.h.
{
AJI_XEP0248 = (1 << 0),
AJI_PUBSUB = (1 << 1),
AJI_PUBSUB_AUTOCREATE = (1 << 2),
};
| enum aji_btype |
Definition at line 98 of file jabber.h.
{
AJI_USER = 0,
AJI_TRANS = 1,
AJI_UTRANS = 2,
};
| enum aji_state |
| void ast_aji_buddy_destroy | ( | struct aji_buddy * | obj | ) |
Destructor function for buddies to be used with ASTOBJ_UNREF
Definition at line 442 of file res_jabber.c.
References ast_free, aji_resource::description, aji_resource::next, and aji_buddy::resources.
Referenced by acf_jabberstatus_read(), aji_client_info_handler(), aji_create_buddy(), aji_dinfo_handler(), aji_handle_presence(), aji_handle_subscribe(), aji_register_query_handler(), aji_status_exec(), ast_aji_client_destroy(), gtalk_alloc(), gtalk_member_destroy(), jingle_alloc(), and jingle_member_destroy().
{
struct aji_resource *tmp;
while ((tmp = obj->resources)) {
obj->resources = obj->resources->next;
ast_free(tmp->description);
ast_free(tmp);
}
ast_free(obj);
}
| int ast_aji_check_roster | ( | void | ) |
| void ast_aji_client_destroy | ( | struct aji_client * | obj | ) |
Destructor function for clients to be used with ASTOBJ_UNREF after calls to ast_aji_get_client
Definition at line 420 of file res_jabber.c.
References aji_message_destroy(), ast_aji_buddy_destroy(), ast_free, AST_LIST_HEAD_DESTROY, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, ASTOBJ_CONTAINER_DESTROY, ASTOBJ_CONTAINER_DESTROYALL, aji_client::buddies, aji_client::f, aji_message::list, aji_client::messages, aji_client::p, and aji_client::stack.
Referenced by acf_jabberreceive_read(), acf_jabberstatus_read(), aji_act_hook(), aji_cli_create_collection(), aji_cli_create_leafnode(), aji_cli_delete_pubsub_node(), aji_cli_list_pubsub_nodes(), aji_cli_purge_pubsub_nodes(), aji_client_connect(), aji_client_info_handler(), aji_create_client(), aji_devstate_cb(), aji_dinfo_handler(), aji_ditems_handler(), aji_handle_pubsub_error(), aji_join_exec(), aji_leave_exec(), aji_log_hook(), aji_mwi_cb(), aji_receive_node_list(), aji_recv_loop(), aji_register_approve_handler(), aji_register_query_handler(), aji_reload(), aji_send_exec(), aji_sendgroup_exec(), aji_status_exec(), ast_aji_disconnect(), gtalk_load_config(), gtalk_member_destroy(), gtalk_newcall(), gtalk_request(), jingle_load_config(), jingle_member_destroy(), jingle_newcall(), jingle_request(), manager_jabber_send(), msg_send_cb(), and unload_module().
{
struct aji_message *tmp;
ASTOBJ_CONTAINER_DESTROYALL(&obj->buddies, ast_aji_buddy_destroy);
ASTOBJ_CONTAINER_DESTROY(&obj->buddies);
iks_filter_delete(obj->f);
iks_parser_delete(obj->p);
iks_stack_delete(obj->stack);
AST_LIST_LOCK(&obj->messages);
while ((tmp = AST_LIST_REMOVE_HEAD(&obj->messages, list))) {
aji_message_destroy(tmp);
}
AST_LIST_HEAD_DESTROY(&obj->messages);
ast_free(obj);
}
| 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 2702 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 3209 of file res_jabber.c.
References ast_aji_client_destroy(), ast_verb, ASTOBJ_UNREF, aji_client::p, SECURE, aji_client::ssl_context, aji_client::ssl_session, and aji_client::stream_flags.
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, ast_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. Bumps the refcount. (without the resource string)
Get a client via its name. Increases refcount of client by 1
| name | label or JID |
Definition at line 4637 of file res_jabber.c.
References ASTOBJ_CONTAINER_FIND, ASTOBJ_CONTAINER_TRAVERSE, ASTOBJ_REF, and clients.
Referenced by acf_jabberreceive_read(), acf_jabberstatus_read(), aji_join_exec(), aji_leave_exec(), aji_send_exec(), aji_sendgroup_exec(), aji_status_exec(), gtalk_create_member(), gtalk_newcall(), gtalk_request(), jingle_create_member(), jingle_newcall(), jingle_request(), manager_jabber_send(), and msg_send_cb().
{
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 = ASTOBJ_REF(iterator);
}
});
}
return client;
}
| struct aji_client_container* ast_aji_get_clients | ( | void | ) | [read] |
Definition at line 4659 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 2846 of file res_jabber.c.
Referenced by aji_act_hook(), aji_handle_presence(), aji_pubsub_iq_create(), aji_register_approve_handler(), ast_aji_create_chat(), ast_aji_invite_chat(), gtalk_action(), gtalk_create_candidates(), gtalk_invite(), 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 2754 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, | ||
| char * | nick | ||
| ) |
join a chatroom.
Join/leave existing Chat session
| client | the configured XMPP client we use to connect to a XMPP server |
| room | room to join |
| nick | the nickname to use in this room |
Definition at line 2730 of file res_jabber.c.
References aji_set_group_presence().
Referenced by aji_join_exec().
{
return aji_set_group_presence(client, room, IKS_SHOW_AVAILABLE, nick, NULL);
}
| int ast_aji_leave_chat | ( | struct aji_client * | client, |
| char * | room, | ||
| char * | nick | ||
| ) |
leave a chatroom.
| client | the configured XMPP client we use to connect to a XMPP server |
| room | room to leave |
| nick | the nickname used in this room |
Definition at line 2742 of file res_jabber.c.
References aji_set_group_presence().
Referenced by aji_leave_exec().
{
return aji_set_group_presence(client, room, IKS_SHOW_UNAVAILABLE, nick, NULL);
}
| 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 1478 of file res_jabber.c.
References aji_send_raw().
Referenced by aji_act_hook(), aji_client_info_handler(), aji_create_pubsub_node(), aji_delete_pubsub_node(), aji_dinfo_handler(), aji_ditems_handler(), aji_get_roster(), aji_handle_presence(), aji_handle_pubsub_error(), aji_handle_subscribe(), aji_pruneregister(), aji_publish_device_state(), aji_publish_mwi(), aji_pubsub_purge_nodes(), aji_pubsub_subscribe(), aji_register_approve_handler(), aji_register_query_handler(), aji_request_pubsub_nodes(), aji_send_raw_chat(), aji_set_group_presence(), aji_set_presence(), aji_start_sasl(), ast_aji_create_chat(), ast_aji_invite_chat(), gtalk_action(), gtalk_add_candidate(), gtalk_create_candidates(), gtalk_invite(), 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 |
| IKS_OK | success |
| -1 | failure |
Definition at line 2638 of file res_jabber.c.
References aji_send_raw_chat().
Referenced by aji_send_exec(), gtalk_sendtext(), jingle_sendtext(), manager_jabber_send(), and msg_send_cb().
{
return aji_send_raw_chat(client, 0, NULL, address, message);
}
| int ast_aji_send_groupchat | ( | struct aji_client * | client, |
| const char * | nick, | ||
| const char * | address, | ||
| const char * | message | ||
| ) |
sends message to a groupchat Prior to sending messages to a groupchat, one must be connected to it.
Send jabber chat message from connected client to a groupchat using a given nickname
| client | the configured XMPP client we use to connect to a XMPP server |
| nick | the nickname we use in the chatroom |
| address | the user the messages must be sent to |
| message | the message to send |
Definition at line 2652 of file res_jabber.c.
References aji_send_raw_chat().
Referenced by aji_sendgroup_exec().
{
return aji_send_raw_chat(client, 1, nick, address, message);
}