Codename Pineapple

Home page | Mailing list | Docs

Last updated: Sat Feb 3 05:01:34 2007

Asterisk developer's documentation :: Codename Pineapple


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

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_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.


Enumeration Type Documentation

anonymous enum
 

Enumerator:
AJI_AUTOPRUNE 
AJI_AUTOREGISTER 

Definition at line 32 of file jabber.h.

00032      {
00033    AJI_AUTOPRUNE = (1 << 0),
00034    AJI_AUTOREGISTER = (1 << 1)
00035 };

enum aji_btype
 

Enumerator:
AJI_USER 
AJI_TRANS 
AJI_UTRANS 

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
 

Enumerator:
AJI_DISCONNECTED 
AJI_CONNECTING 
AJI_CONNECTED 

Definition at line 26 of file jabber.h.

00026                {
00027    AJI_DISCONNECTED = 0,
00028    AJI_CONNECTING,
00029    AJI_CONNECTED
00030 };


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 1397 of file res_jabber.c.

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

01398 {
01399    int res = 0;
01400    iks *iq = NULL;
01401    iq = iks_new("iq");
01402    if (iq && client) {
01403       iks_insert_attrib(iq, "type", "get");
01404       iks_insert_attrib(iq, "to", server);
01405       iks_insert_attrib(iq, "id", client->mid);
01406       ast_aji_increment_mid(client->mid);
01407       iks_send(client->p, iq);
01408    } else 
01409       ast_log(LOG_ERROR, "Out of memory.\n");
01410    return res;
01411 }

int ast_aji_disconnect struct aji_client client  ) 
 

disconnect from jabber server.

Parameters:
aji_client struct.
Returns:
1.

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

01859 {
01860    if (client) {
01861       if (option_verbose > 3)
01862          ast_verbose(VERBOSE_PREFIX_3 "JABBER: Disconnecting\n");
01863       iks_disconnect(client->p);
01864       iks_parser_delete(client->p);
01865       ASTOBJ_UNREF(client, aji_client_destroy);
01866    }
01867 
01868    return 1;
01869 }

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 2297 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(), jingle_create_member(), and manager_jabber_send().

02298 {
02299    struct aji_client *client = NULL;
02300 
02301    client = ASTOBJ_CONTAINER_FIND(&clients, name);
02302    if (!client && !strchr(name, '@'))
02303       client = ASTOBJ_CONTAINER_FIND_FULL(&clients, name, user,,, strcasecmp);
02304    return client;
02305 }

struct aji_client_container* ast_aji_get_clients void   ) 
 

Definition at line 2307 of file res_jabber.c.

References clients.

02308 {
02309    return &clients;
02310 }

void ast_aji_increment_mid char *  mid  ) 
 

increments the mid field for messages and other events.

Parameters:
message id.
Returns:
void.

Definition at line 1519 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_digit(), gtalk_invite_response(), jingle_accept_call(), jingle_action(), jingle_digit(), and jingle_transmit_invite().

01520 {
01521    int i = 0;
01522 
01523    for (i = strlen(mid) - 1; i >= 0; i--) {
01524       if (mid[i] != 'z') {
01525          mid[i] = mid[i] + 1;
01526          i = 0;
01527       } else
01528          mid[i] = 'a';
01529    }
01530 }

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 1446 of file res_jabber.c.

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

01447 {
01448    int res = 0;
01449    iks *invite, *body, *namespace;
01450 
01451    invite = iks_new("message");
01452    body = iks_new("body");
01453    namespace = iks_new("x");
01454    if (client && invite && body && namespace) {
01455       iks_insert_attrib(invite, "to", user);
01456       iks_insert_attrib(invite, "id", client->mid);
01457       ast_aji_increment_mid(client->mid);
01458       iks_insert_cdata(body, message, 0);
01459       iks_insert_attrib(namespace, "xmlns", "jabber:x:conference");
01460       iks_insert_attrib(namespace, "jid", room);
01461       iks_insert_node(invite, body);
01462       iks_insert_node(invite, namespace);
01463       res = iks_send(client->p, invite);
01464    } else 
01465       ast_log(LOG_ERROR, "Out of memory.\n");
01466    if (body)
01467       iks_delete(body);
01468    if (namespace)
01469       iks_delete(namespace);
01470    if (invite)
01471       iks_delete(invite);
01472    return res;
01473 }

int ast_aji_join_chat struct aji_client client,
char *  room
 

join a chatroom.

Parameters:
aji_client struct , room.
Returns:
res.

Definition at line 1418 of file res_jabber.c.

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

01419 {
01420    int res = 0;
01421    iks *presence = NULL, *priority = NULL;
01422    presence = iks_new("presence");
01423    priority = iks_new("priority");
01424    if (presence && priority && client) {
01425       iks_insert_cdata(priority, "0", 1);
01426       iks_insert_attrib(presence, "to", room);
01427       iks_insert_node(presence, priority);
01428       res = iks_send(client->p, presence);
01429       iks_insert_cdata(priority, "5", 1);
01430       iks_insert_attrib(presence, "to", room);
01431       res = iks_send(client->p, presence);
01432    } else 
01433       ast_log(LOG_ERROR, "Out of memory.\n");
01434    if (presence)
01435       iks_delete(presence);
01436    if (priority)
01437       iks_delete(priority);
01438    return res;
01439 }

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 1373 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().

01374 {
01375    int res = 0;
01376    iks *message_packet = NULL;
01377    if (client->state == AJI_CONNECTED) {
01378       message_packet = iks_make_msg(IKS_TYPE_CHAT, address, message);
01379       if (message_packet) {
01380          iks_insert_attrib(message_packet, "from", client->jid->full);
01381          res = iks_send(client->p, message_packet);
01382       } else {
01383          ast_log(LOG_ERROR, "Out of memory.\n");
01384       }
01385       if (message_packet)
01386          iks_delete(message_packet);
01387    } else
01388       ast_log(LOG_WARNING, "JABBER: Not connected can't send\n");
01389    return 1;
01390 }


Asterisk is a trademark for Digium, inc.. | Edvina.net | Asterisk.org | This documentation was generated with Doxygen