#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::messages |
struct | aji_client_container |
struct | aji_message |
struct | aji_resource |
struct | aji_transport_container |
struct | aji_version |
Defines | |
#define | AJI_MAX_JIDLEN 3071 |
#define | AJI_MAX_RESJIDLEN 1023 |
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. | |
aji_client * | ast_aji_get_client (const char *name) |
grab a aji_client structure by label name or JID (without the resource string) | |
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, const char *address, const char *message) |
sends messages. |
#define AJI_MAX_JIDLEN 3071 |
anonymous enum |
Definition at line 46 of file jabber.h.
00046 { 00047 AJI_AUTOPRUNE = (1 << 0), 00048 AJI_AUTOREGISTER = (1 << 1) 00049 };
enum aji_btype |
Definition at line 51 of file jabber.h.
00051 { 00052 AJI_USER=0, 00053 AJI_TRANS=1, 00054 AJI_UTRANS=2 00055 };
enum aji_state |
Definition at line 39 of file jabber.h.
00039 { 00040 AJI_DISCONNECTING, 00041 AJI_DISCONNECTED, 00042 AJI_CONNECTING, 00043 AJI_CONNECTED 00044 };
int ast_aji_check_roster | ( | void | ) |
int ast_aji_create_chat | ( | struct aji_client * | client, | |
char * | room, | |||
char * | server, | |||
char * | topic | |||
) |
create a chatroom.
aji_client | struct , room, server, topic for the room. |
Definition at line 1452 of file res_jabber.c.
References ast_aji_increment_mid(), ast_log(), LOG_ERROR, aji_client::mid, and aji_client::p.
01453 { 01454 int res = 0; 01455 iks *iq = NULL; 01456 iq = iks_new("iq"); 01457 01458 if (iq && client) { 01459 iks_insert_attrib(iq, "type", "get"); 01460 iks_insert_attrib(iq, "to", server); 01461 iks_insert_attrib(iq, "id", client->mid); 01462 ast_aji_increment_mid(client->mid); 01463 iks_send(client->p, iq); 01464 } else 01465 ast_log(LOG_ERROR, "Out of memory.\n"); 01466 01467 iks_delete(iq); 01468 01469 return res; 01470 }
int ast_aji_disconnect | ( | struct aji_client * | client | ) |
disconnect from jabber server.
aji_client | struct. |
Definition at line 1927 of file res_jabber.c.
References aji_client_destroy(), ast_verbose(), ASTOBJ_UNREF, option_verbose, aji_client::p, and VERBOSE_PREFIX_3.
Referenced by unload_module().
01928 { 01929 if (client) { 01930 if (option_verbose > 3) 01931 ast_verbose(VERBOSE_PREFIX_3 "JABBER: Disconnecting\n"); 01932 iks_disconnect(client->p); 01933 iks_parser_delete(client->p); 01934 ASTOBJ_UNREF(client, aji_client_destroy); 01935 } 01936 01937 return 1; 01938 }
struct aji_client* ast_aji_get_client | ( | const char * | name | ) |
grab a aji_client structure by label name or JID (without the resource string)
name | label or JID |
Definition at line 2367 of file res_jabber.c.
References ast_strdupa, ASTOBJ_CONTAINER_FIND, ASTOBJ_CONTAINER_TRAVERSE, and clients.
Referenced by aji_send_exec(), aji_status_exec(), gtalk_create_member(), gtalk_newcall(), gtalk_request(), and manager_jabber_send().
02368 { 02369 struct aji_client *client = NULL; 02370 char *aux = NULL; 02371 02372 client = ASTOBJ_CONTAINER_FIND(&clients, name); 02373 if (!client && strchr(name, '@')) { 02374 ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, { 02375 aux = ast_strdupa(iterator->user); 02376 if (strchr(aux, '/')) { 02377 /* strip resource for comparison */ 02378 aux = strsep(&aux, "/"); 02379 } 02380 if (!strncasecmp(aux, name, strlen(aux))) { 02381 client = iterator; 02382 } 02383 }); 02384 } 02385 02386 return client; 02387 }
struct aji_client_container* ast_aji_get_clients | ( | void | ) |
Definition at line 2389 of file res_jabber.c.
References clients.
02390 { 02391 return &clients; 02392 }
void ast_aji_increment_mid | ( | char * | mid | ) |
increments the mid field for messages and other events.
message | id. |
Definition at line 1584 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(), and gtalk_invite_response().
01585 { 01586 int i = 0; 01587 01588 for (i = strlen(mid) - 1; i >= 0; i--) { 01589 if (mid[i] != 'z') { 01590 mid[i] = mid[i] + 1; 01591 i = 0; 01592 } else 01593 mid[i] = 'a'; 01594 } 01595 }
int ast_aji_invite_chat | ( | struct aji_client * | client, | |
char * | user, | |||
char * | room, | |||
char * | message | |||
) |
invite to a chatroom.
aji_client | struct ,user, room, message. |
Definition at line 1505 of file res_jabber.c.
References ast_aji_increment_mid(), ast_log(), LOG_ERROR, aji_client::mid, and aji_client::p.
01506 { 01507 int res = 0; 01508 iks *invite, *body, *namespace; 01509 01510 invite = iks_new("message"); 01511 body = iks_new("body"); 01512 namespace = iks_new("x"); 01513 if (client && invite && body && namespace) { 01514 iks_insert_attrib(invite, "to", user); 01515 iks_insert_attrib(invite, "id", client->mid); 01516 ast_aji_increment_mid(client->mid); 01517 iks_insert_cdata(body, message, 0); 01518 iks_insert_attrib(namespace, "xmlns", "jabber:x:conference"); 01519 iks_insert_attrib(namespace, "jid", room); 01520 iks_insert_node(invite, body); 01521 iks_insert_node(invite, namespace); 01522 res = iks_send(client->p, invite); 01523 } else 01524 ast_log(LOG_ERROR, "Out of memory.\n"); 01525 if (body) 01526 iks_delete(body); 01527 if (namespace) 01528 iks_delete(namespace); 01529 if (invite) 01530 iks_delete(invite); 01531 return res; 01532 }
int ast_aji_join_chat | ( | struct aji_client * | client, | |
char * | room | |||
) |
join a chatroom.
aji_client | struct , room. |
Definition at line 1477 of file res_jabber.c.
References ast_log(), LOG_ERROR, and aji_client::p.
01478 { 01479 int res = 0; 01480 iks *presence = NULL, *priority = NULL; 01481 presence = iks_new("presence"); 01482 priority = iks_new("priority"); 01483 if (presence && priority && client) { 01484 iks_insert_cdata(priority, "0", 1); 01485 iks_insert_attrib(presence, "to", room); 01486 iks_insert_node(presence, priority); 01487 res = iks_send(client->p, presence); 01488 iks_insert_cdata(priority, "5", 1); 01489 iks_insert_attrib(presence, "to", room); 01490 res = iks_send(client->p, presence); 01491 } else 01492 ast_log(LOG_ERROR, "Out of memory.\n"); 01493 if (presence) 01494 iks_delete(presence); 01495 if (priority) 01496 iks_delete(priority); 01497 return res; 01498 }
int ast_aji_send | ( | struct aji_client * | client, | |
const char * | address, | |||
const char * | message | |||
) |
sends messages.
aji_client | struct , reciever, message. |
Definition at line 1428 of file res_jabber.c.
References AJI_CONNECTED, ast_log(), aji_client::jid, LOG_ERROR, LOG_WARNING, aji_client::p, and aji_client::state.
Referenced by aji_send_exec(), aji_test(), and manager_jabber_send().
01429 { 01430 int res = 0; 01431 iks *message_packet = NULL; 01432 if (client->state == AJI_CONNECTED) { 01433 message_packet = iks_make_msg(IKS_TYPE_CHAT, address, message); 01434 if (message_packet) { 01435 iks_insert_attrib(message_packet, "from", client->jid->full); 01436 res = iks_send(client->p, message_packet); 01437 } else { 01438 ast_log(LOG_ERROR, "Out of memory.\n"); 01439 } 01440 if (message_packet) 01441 iks_delete(message_packet); 01442 } else 01443 ast_log(LOG_WARNING, "JABBER: Not connected can't send\n"); 01444 return 1; 01445 }