#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 |
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. | |
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, const char *address, const char *message) |
sends messages. |
anonymous enum |
Definition at line 33 of file jabber.h.
00033 { 00034 AJI_AUTOPRUNE = (1 << 0), 00035 AJI_AUTOREGISTER = (1 << 1) 00036 };
enum aji_btype |
Definition at line 38 of file jabber.h.
00038 { 00039 AJI_USER=0, 00040 AJI_TRANS=1, 00041 AJI_UTRANS=2 00042 };
enum aji_state |
Definition at line 26 of file jabber.h.
00026 { 00027 AJI_DISCONNECTING, 00028 AJI_DISCONNECTED, 00029 AJI_CONNECTING, 00030 AJI_CONNECTED 00031 };
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 1430 of file res_jabber.c.
01431 { 01432 int res = 0; 01433 iks *iq = NULL; 01434 iq = iks_new("iq"); 01435 if (iq && client) { 01436 iks_insert_attrib(iq, "type", "get"); 01437 iks_insert_attrib(iq, "to", server); 01438 iks_insert_attrib(iq, "id", client->mid); 01439 ast_aji_increment_mid(client->mid); 01440 iks_send(client->p, iq); 01441 } else 01442 ast_log(LOG_ERROR, "Out of memory.\n"); 01443 return res; 01444 }
int ast_aji_disconnect | ( | struct aji_client * | client | ) |
disconnect from jabber server.
aji_client | struct. |
Definition at line 1898 of file res_jabber.c.
Referenced by unload_module().
01899 { 01900 if (client) { 01901 if (option_verbose > 3) 01902 ast_verbose(VERBOSE_PREFIX_3 "JABBER: Disconnecting\n"); 01903 iks_disconnect(client->p); 01904 iks_parser_delete(client->p); 01905 ASTOBJ_UNREF(client, aji_client_destroy); 01906 } 01907 01908 return 1; 01909 }
struct aji_client* ast_aji_get_client | ( | const char * | name | ) | [read] |
grab a aji_client structure by label name.
void. |
Definition at line 2338 of file res_jabber.c.
Referenced by aji_send_exec(), aji_status_exec(), gtalk_create_member(), and manager_jabber_send().
02339 { 02340 struct aji_client *client = NULL; 02341 02342 client = ASTOBJ_CONTAINER_FIND(&clients, name); 02343 if (!client && !strchr(name, '@')) 02344 client = ASTOBJ_CONTAINER_FIND_FULL(&clients, name, user,,, strcasecmp); 02345 return client; 02346 }
struct aji_client_container* ast_aji_get_clients | ( | void | ) | [read] |
Definition at line 2348 of file res_jabber.c.
Referenced by gtalk_load_config().
02349 { 02350 return &clients; 02351 }
void ast_aji_increment_mid | ( | char * | mid | ) |
increments the mid field for messages and other events.
message | id. |
Definition at line 1558 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().
01559 { 01560 int i = 0; 01561 01562 for (i = strlen(mid) - 1; i >= 0; i--) { 01563 if (mid[i] != 'z') { 01564 mid[i] = mid[i] + 1; 01565 i = 0; 01566 } else 01567 mid[i] = 'a'; 01568 } 01569 }
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 1479 of file res_jabber.c.
01480 { 01481 int res = 0; 01482 iks *invite, *body, *namespace; 01483 01484 invite = iks_new("message"); 01485 body = iks_new("body"); 01486 namespace = iks_new("x"); 01487 if (client && invite && body && namespace) { 01488 iks_insert_attrib(invite, "to", user); 01489 iks_insert_attrib(invite, "id", client->mid); 01490 ast_aji_increment_mid(client->mid); 01491 iks_insert_cdata(body, message, 0); 01492 iks_insert_attrib(namespace, "xmlns", "jabber:x:conference"); 01493 iks_insert_attrib(namespace, "jid", room); 01494 iks_insert_node(invite, body); 01495 iks_insert_node(invite, namespace); 01496 res = iks_send(client->p, invite); 01497 } else 01498 ast_log(LOG_ERROR, "Out of memory.\n"); 01499 if (body) 01500 iks_delete(body); 01501 if (namespace) 01502 iks_delete(namespace); 01503 if (invite) 01504 iks_delete(invite); 01505 return res; 01506 }
int ast_aji_join_chat | ( | struct aji_client * | client, | |
char * | room | |||
) |
join a chatroom.
aji_client | struct , room. |
Definition at line 1451 of file res_jabber.c.
01452 { 01453 int res = 0; 01454 iks *presence = NULL, *priority = NULL; 01455 presence = iks_new("presence"); 01456 priority = iks_new("priority"); 01457 if (presence && priority && client) { 01458 iks_insert_cdata(priority, "0", 1); 01459 iks_insert_attrib(presence, "to", room); 01460 iks_insert_node(presence, priority); 01461 res = iks_send(client->p, presence); 01462 iks_insert_cdata(priority, "5", 1); 01463 iks_insert_attrib(presence, "to", room); 01464 res = iks_send(client->p, presence); 01465 } else 01466 ast_log(LOG_ERROR, "Out of memory.\n"); 01467 if (presence) 01468 iks_delete(presence); 01469 if (priority) 01470 iks_delete(priority); 01471 return res; 01472 }
int ast_aji_send | ( | struct aji_client * | client, | |
const char * | address, | |||
const char * | message | |||
) |
sends messages.
aji_client | struct , reciever, message. |
Definition at line 1406 of file res_jabber.c.
Referenced by aji_send_exec(), aji_test(), and manager_jabber_send().
01407 { 01408 int res = 0; 01409 iks *message_packet = NULL; 01410 if (client->state == AJI_CONNECTED) { 01411 message_packet = iks_make_msg(IKS_TYPE_CHAT, address, message); 01412 if (message_packet) { 01413 iks_insert_attrib(message_packet, "from", client->jid->full); 01414 res = iks_send(client->p, message_packet); 01415 } else { 01416 ast_log(LOG_ERROR, "Out of memory.\n"); 01417 } 01418 if (message_packet) 01419 iks_delete(message_packet); 01420 } else 01421 ast_log(LOG_WARNING, "JABBER: Not connected can't send\n"); 01422 return 1; 01423 }