Mon Mar 31 07:41:09 2008

Asterisk developer's documentation


jabber.h File Reference

#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

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_clientast_aji_get_client (const char *name)
 grab a aji_client structure by label name.
aji_client_containerast_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 Documentation

#define AJI_MAX_JIDLEN   3071

Definition at line 36 of file jabber.h.

Referenced by gtalk_show_channels().

#define AJI_MAX_RESJIDLEN   1023

Definition at line 37 of file jabber.h.


Enumeration Type Documentation

anonymous enum

Enumerator:
AJI_AUTOPRUNE 
AJI_AUTOREGISTER 

Definition at line 46 of file jabber.h.

00046      {
00047    AJI_AUTOPRUNE = (1 << 0),
00048    AJI_AUTOREGISTER = (1 << 1)
00049 };

enum aji_btype

Enumerator:
AJI_USER 
AJI_TRANS 
AJI_UTRANS 

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

Enumerator:
AJI_DISCONNECTING 
AJI_DISCONNECTED 
AJI_CONNECTING 
AJI_CONNECTED 

Definition at line 39 of file jabber.h.

00039                {
00040    AJI_DISCONNECTING,
00041    AJI_DISCONNECTED,
00042    AJI_CONNECTING,
00043    AJI_CONNECTED
00044 };


Function Documentation

int ast_aji_check_roster ( void   ) 

int ast_aji_create_chat ( struct aji_client client,
char *  room,
char *  server,
char *  topic 
)

create a chatroom.

Parameters:
aji_client struct , room, server, topic for the room.
Returns:
0.

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 *iq = NULL;
01457    iq = iks_new("iq");
01458 
01459    if (iq && client) {
01460       iks_insert_attrib(iq, "type", "get");
01461       iks_insert_attrib(iq, "to", server);
01462       iks_insert_attrib(iq, "id", client->mid);
01463       ast_aji_increment_mid(client->mid);
01464       iks_send(client->p, iq);
01465    } else 
01466       ast_log(LOG_ERROR, "Out of memory.\n");
01467 
01468    iks_delete(iq);
01469 
01470    return res;
01471 }

int ast_aji_disconnect ( struct aji_client client  ) 

disconnect from jabber server.

Parameters:
aji_client struct.
Returns:
1.

Definition at line 1925 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().

01926 {
01927    if (client) {
01928       if (option_verbose > 3)
01929          ast_verbose(VERBOSE_PREFIX_3 "JABBER: Disconnecting\n");
01930       iks_disconnect(client->p);
01931       iks_parser_delete(client->p);
01932       ASTOBJ_UNREF(client, aji_client_destroy);
01933    }
01934 
01935    return 1;
01936 }

struct aji_client* ast_aji_get_client ( const char *  name  ) 

grab a aji_client structure by label name.

Parameters:
void. 
Returns:
1.

Definition at line 2366 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().

02367 {
02368    struct aji_client *client = NULL;
02369 
02370    client = ASTOBJ_CONTAINER_FIND(&clients, name);
02371    if (!client && !strchr(name, '@'))
02372       client = ASTOBJ_CONTAINER_FIND_FULL(&clients, name, user,,, strcasecmp);
02373    return client;
02374 }

struct aji_client_container* ast_aji_get_clients ( void   ) 

Definition at line 2376 of file res_jabber.c.

References clients.

02377 {
02378    return &clients;
02379 }

void ast_aji_increment_mid ( char *  mid  ) 

increments the mid field for messages and other events.

Parameters:
message id.
Returns:
void.

Definition at line 1585 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().

01586 {
01587    int i = 0;
01588 
01589    for (i = strlen(mid) - 1; i >= 0; i--) {
01590       if (mid[i] != 'z') {
01591          mid[i] = mid[i] + 1;
01592          i = 0;
01593       } else
01594          mid[i] = 'a';
01595    }
01596 }

int ast_aji_invite_chat ( struct aji_client client,
char *  user,
char *  room,
char *  message 
)

invite to a chatroom.

Parameters:
aji_client struct ,user, room, message.
Returns:
res.

Definition at line 1506 of file res_jabber.c.

References ast_aji_increment_mid(), ast_log(), LOG_ERROR, aji_client::mid, and aji_client::p.

01507 {
01508    int res = 0;
01509    iks *invite, *body, *namespace;
01510 
01511    invite = iks_new("message");
01512    body = iks_new("body");
01513    namespace = iks_new("x");
01514    if (client && invite && body && namespace) {
01515       iks_insert_attrib(invite, "to", user);
01516       iks_insert_attrib(invite, "id", client->mid);
01517       ast_aji_increment_mid(client->mid);
01518       iks_insert_cdata(body, message, 0);
01519       iks_insert_attrib(namespace, "xmlns", "jabber:x:conference");
01520       iks_insert_attrib(namespace, "jid", room);
01521       iks_insert_node(invite, body);
01522       iks_insert_node(invite, namespace);
01523       res = iks_send(client->p, invite);
01524    } else 
01525       ast_log(LOG_ERROR, "Out of memory.\n");
01526    if (body)
01527       iks_delete(body);
01528    if (namespace)
01529       iks_delete(namespace);
01530    if (invite)
01531       iks_delete(invite);
01532    return res;
01533 }

int ast_aji_join_chat ( struct aji_client client,
char *  room 
)

join a chatroom.

Parameters:
aji_client struct , room.
Returns:
res.

Definition at line 1478 of file res_jabber.c.

References ast_log(), LOG_ERROR, and aji_client::p.

01479 {
01480    int res = 0;
01481    iks *presence = NULL, *priority = NULL;
01482    presence = iks_new("presence");
01483    priority = iks_new("priority");
01484    if (presence && priority && client) {
01485       iks_insert_cdata(priority, "0", 1);
01486       iks_insert_attrib(presence, "to", room);
01487       iks_insert_node(presence, priority);
01488       res = iks_send(client->p, presence);
01489       iks_insert_cdata(priority, "5", 1);
01490       iks_insert_attrib(presence, "to", room);
01491       res = iks_send(client->p, presence);
01492    } else 
01493       ast_log(LOG_ERROR, "Out of memory.\n");
01494    if (presence)
01495       iks_delete(presence);
01496    if (priority)
01497       iks_delete(priority);
01498    return res;
01499 }

int ast_aji_send ( struct aji_client client,
const char *  address,
const char *  message 
)

sends messages.

Parameters:
aji_client struct , reciever, message.
Returns:
1.

Definition at line 1429 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().

01430 {
01431    int res = 0;
01432    iks *message_packet = NULL;
01433    if (client->state == AJI_CONNECTED) {
01434       message_packet = iks_make_msg(IKS_TYPE_CHAT, address, message);
01435       if (message_packet) {
01436          iks_insert_attrib(message_packet, "from", client->jid->full);
01437          res = iks_send(client->p, message_packet);
01438       } else {
01439          ast_log(LOG_ERROR, "Out of memory.\n");
01440       }
01441       if (message_packet)
01442          iks_delete(message_packet);
01443    } else
01444       ast_log(LOG_WARNING, "JABBER: Not connected can't send\n");
01445    return 1;
01446 }


Generated on Mon Mar 31 07:41:10 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.1