#include <iksemel.h>
#include "asterisk/astobj.h"
#include "asterisk/linkedlists.h"
Include dependency graph for jabber.h:
This graph shows which files directly or indirectly include this file:
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 |
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_DISCONNECTED = 0, 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. | |
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. |
anonymous enum |
Definition at line 32 of file jabber.h.
00032 { 00033 AJI_AUTOPRUNE = (1 << 0), 00034 AJI_AUTOREGISTER = (1 << 1) 00035 };
enum aji_btype |
Definition at line 37 of file jabber.h.
00037 { 00038 AJI_USER=0, 00039 AJI_TRANS=1, 00040 AJI_UTRANS=2 00041 };
enum aji_state |
Definition at line 26 of file jabber.h.
00026 { 00027 AJI_DISCONNECTED = 0, 00028 AJI_CONNECTING, 00029 AJI_CONNECTED 00030 };
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 1404 of file res_jabber.c.
References ast_aji_increment_mid(), ast_log(), LOG_ERROR, aji_client::mid, and aji_client::p.
01405 { 01406 int res = 0; 01407 iks *iq = NULL; 01408 iq = iks_new("iq"); 01409 if (iq && client) { 01410 iks_insert_attrib(iq, "type", "get"); 01411 iks_insert_attrib(iq, "to", server); 01412 iks_insert_attrib(iq, "id", client->mid); 01413 ast_aji_increment_mid(client->mid); 01414 iks_send(client->p, iq); 01415 } else 01416 ast_log(LOG_ERROR, "Out of memory.\n"); 01417 return res; 01418 }
int ast_aji_disconnect | ( | struct aji_client * | client | ) |
disconnect from jabber server.
aji_client | struct. |
Definition at line 1865 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().
01866 { 01867 if (client) { 01868 if (option_verbose > 3) 01869 ast_verbose(VERBOSE_PREFIX_3 "JABBER: Disconnecting\n"); 01870 iks_disconnect(client->p); 01871 iks_parser_delete(client->p); 01872 ASTOBJ_UNREF(client, aji_client_destroy); 01873 } 01874 01875 return 1; 01876 }
struct aji_client* ast_aji_get_client | ( | const char * | name | ) |
grab a aji_client structure by label name.
void. |
Definition at line 2304 of file res_jabber.c.
References ASTOBJ_CONTAINER_FIND, ASTOBJ_CONTAINER_FIND_FULL, clients, and aji_client::user.
Referenced by aji_send_exec(), aji_status_exec(), gtalk_create_member(), and manager_jabber_send().
02305 { 02306 struct aji_client *client = NULL; 02307 02308 client = ASTOBJ_CONTAINER_FIND(&clients, name); 02309 if (!client && !strchr(name, '@')) 02310 client = ASTOBJ_CONTAINER_FIND_FULL(&clients, name, user,,, strcasecmp); 02311 return client; 02312 }
struct aji_client_container* ast_aji_get_clients | ( | void | ) |
Definition at line 2314 of file res_jabber.c.
References clients.
02315 { 02316 return &clients; 02317 }
void ast_aji_increment_mid | ( | char * | mid | ) |
increments the mid field for messages and other events.
message | id. |
Definition at line 1526 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().
01527 { 01528 int i = 0; 01529 01530 for (i = strlen(mid) - 1; i >= 0; i--) { 01531 if (mid[i] != 'z') { 01532 mid[i] = mid[i] + 1; 01533 i = 0; 01534 } else 01535 mid[i] = 'a'; 01536 } 01537 }
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 1453 of file res_jabber.c.
References ast_aji_increment_mid(), ast_log(), LOG_ERROR, aji_client::mid, and aji_client::p.
01454 { 01455 int res = 0; 01456 iks *invite, *body, *namespace; 01457 01458 invite = iks_new("message"); 01459 body = iks_new("body"); 01460 namespace = iks_new("x"); 01461 if (client && invite && body && namespace) { 01462 iks_insert_attrib(invite, "to", user); 01463 iks_insert_attrib(invite, "id", client->mid); 01464 ast_aji_increment_mid(client->mid); 01465 iks_insert_cdata(body, message, 0); 01466 iks_insert_attrib(namespace, "xmlns", "jabber:x:conference"); 01467 iks_insert_attrib(namespace, "jid", room); 01468 iks_insert_node(invite, body); 01469 iks_insert_node(invite, namespace); 01470 res = iks_send(client->p, invite); 01471 } else 01472 ast_log(LOG_ERROR, "Out of memory.\n"); 01473 if (body) 01474 iks_delete(body); 01475 if (namespace) 01476 iks_delete(namespace); 01477 if (invite) 01478 iks_delete(invite); 01479 return res; 01480 }
int ast_aji_join_chat | ( | struct aji_client * | client, | |
char * | room | |||
) |
join a chatroom.
aji_client | struct , room. |
Definition at line 1425 of file res_jabber.c.
References ast_log(), LOG_ERROR, aji_client::p, and aji_resource::priority.
01426 { 01427 int res = 0; 01428 iks *presence = NULL, *priority = NULL; 01429 presence = iks_new("presence"); 01430 priority = iks_new("priority"); 01431 if (presence && priority && client) { 01432 iks_insert_cdata(priority, "0", 1); 01433 iks_insert_attrib(presence, "to", room); 01434 iks_insert_node(presence, priority); 01435 res = iks_send(client->p, presence); 01436 iks_insert_cdata(priority, "5", 1); 01437 iks_insert_attrib(presence, "to", room); 01438 res = iks_send(client->p, presence); 01439 } else 01440 ast_log(LOG_ERROR, "Out of memory.\n"); 01441 if (presence) 01442 iks_delete(presence); 01443 if (priority) 01444 iks_delete(priority); 01445 return res; 01446 }
int ast_aji_send | ( | struct aji_client * | client, | |
const char * | address, | |||
const char * | message | |||
) |
sends messages.
aji_client | struct , reciever, message. |
Definition at line 1380 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().
01381 { 01382 int res = 0; 01383 iks *message_packet = NULL; 01384 if (client->state == AJI_CONNECTED) { 01385 message_packet = iks_make_msg(IKS_TYPE_CHAT, address, message); 01386 if (message_packet) { 01387 iks_insert_attrib(message_packet, "from", client->jid->full); 01388 res = iks_send(client->p, message_packet); 01389 } else { 01390 ast_log(LOG_ERROR, "Out of memory.\n"); 01391 } 01392 if (message_packet) 01393 iks_delete(message_packet); 01394 } else 01395 ast_log(LOG_WARNING, "JABBER: Not connected can't send\n"); 01396 return 1; 01397 }