xjab_jcon.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/un.h>
#include <string.h>
#include "../../mem/mem.h"
#include "../../mem/shm_mem.h"
#include "../../dprint.h"
#include "../../timer.h"
#include "xjab_jcon.h"
#include "xjab_util.h"
#include "xode.h"
#include "mdefines.h"

Include dependency graph for xjab_jcon.c:

Go to the source code of this file.

Defines

#define JB_CLIENT_OPEN_STREAM   "<stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
#define JB_ID_BASE   "SJ"
#define JB_IQ_ROSTER_GET   "<iq type='get'><query xmlns='jabber:iq:roster'/></iq>"
#define JB_START_STREAM   "<?xml version='1.0'?>"
#define JB_START_STREAM_LEN   21
#define XJ_MAX_JCONF   12

Functions

xj_jconf xj_jcon_check_jconf (xj_jcon jbc, char *id)
int xj_jcon_connect (xj_jcon jbc)
int xj_jcon_del_jconf (xj_jcon jbc, str *sid, char dl, int flag)
int xj_jcon_disconnect (xj_jcon jbc)
int xj_jcon_free (xj_jcon jbc)
xj_jconf xj_jcon_get_jconf (xj_jcon jbc, str *sid, char dl)
int xj_jcon_get_juid (xj_jcon jbc)
int xj_jcon_get_roster (xj_jcon jbc)
xj_jcon xj_jcon_init (char *hostname, int port)
int xj_jcon_is_ready (xj_jcon jbc, char *to, int tol, char dl)
int xj_jcon_jconf_presence (xj_jcon jbc, xj_jconf jcf, char *type, char *status)
int xj_jcon_recv_msg (xj_jcon jbc, char *from, char *msg)
int xj_jcon_send_msg (xj_jcon jbc, char *to, int tol, char *msg, int msgl, int type)
int xj_jcon_send_presence (xj_jcon jbc, char *sto, char *type, char *status, char *priority)
int xj_jcon_send_subscribe (xj_jcon jbc, char *to, char *from, char *type)
int xj_jcon_set_attrs (xj_jcon jbc, xj_jkey jkey, int cache_time, int delay_time)
void xj_jcon_set_juid (xj_jcon jbc, int _juid)
int xj_jcon_set_roster (xj_jcon jbc, char *jid, char *type)
int xj_jcon_update (xj_jcon jbc, int cache_time)
int xj_jcon_user_auth (xj_jcon jbc, char *username, char *passwd, char *resource)


Define Documentation

#define JB_CLIENT_OPEN_STREAM   "<stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"

Definition at line 50 of file xjab_jcon.c.

Referenced by xj_jcon_user_auth().

#define JB_ID_BASE   "SJ"

Definition at line 46 of file xjab_jcon.c.

#define JB_IQ_ROSTER_GET   "<iq type='get'><query xmlns='jabber:iq:roster'/></iq>"

Definition at line 52 of file xjab_jcon.c.

Referenced by xj_jcon_get_roster().

#define JB_START_STREAM   "<?xml version='1.0'?>"

Definition at line 47 of file xjab_jcon.c.

Referenced by xj_jcon_user_auth().

#define JB_START_STREAM_LEN   21

Definition at line 48 of file xjab_jcon.c.

Referenced by xj_jcon_user_auth().

#define XJ_MAX_JCONF   12

Definition at line 54 of file xjab_jcon.c.

Referenced by xj_jcon_get_jconf().


Function Documentation

xj_jconf xj_jcon_check_jconf ( xj_jcon  jbc,
char *  id 
)

int xj_jcon_connect ( xj_jcon  jbc  ) 

connect to JABBER server

Definition at line 97 of file xjab_jcon.c.

References _xj_jcon::hostname, LM_DBG, NULL, _xj_jcon::port, _xj_jcon::sock, and sock.

Referenced by xj_worker_process().

int xj_jcon_del_jconf ( xj_jcon  jbc,
str sid,
char  dl,
int  flag 
)

int xj_jcon_disconnect ( xj_jcon  jbc  ) 

disconnect from JABBER server

Definition at line 158 of file xjab_jcon.c.

References LM_DBG, NULL, _xj_jcon::sock, and xj_jcon_send_presence().

Referenced by xj_worker_check_jcons(), and xj_worker_process().

int xj_jcon_free ( xj_jcon  jbc  ) 

xj_jconf xj_jcon_get_jconf ( xj_jcon  jbc,
str sid,
char  dl 
)

int xj_jcon_get_juid ( xj_jcon  jbc  ) 

return the Jabber internal ID

Definition at line 148 of file xjab_jcon.c.

References _xj_jcon::juid, and NULL.

int xj_jcon_get_roster ( xj_jcon  jbc  ) 

receive the list of the roster

Definition at line 346 of file xjab_jcon.c.

References JB_IQ_ROSTER_GET, and _xj_jcon::sock.

Referenced by xj_worker_process().

xj_jcon xj_jcon_init ( char *  hostname,
int  port 
)

int xj_jcon_is_ready ( xj_jcon  jbc,
char *  to,
int  tol,
char  dl 
)

int xj_jcon_jconf_presence ( xj_jcon  jbc,
xj_jconf  jcf,
char *  type,
char *  status 
)

int xj_jcon_recv_msg ( xj_jcon  jbc,
char *  from,
char *  msg 
)

receive a message from a JABBER connection NOT USED

Definition at line 455 of file xjab_jcon.c.

int xj_jcon_send_msg ( xj_jcon  jbc,
char *  to,
int  tol,
char *  msg,
int  msgl,
int  type 
)

send a message through a JABBER connection params are pairs (buffer, len)

Definition at line 403 of file xjab_jcon.c.

References LM_DBG, NULL, _xj_jcon::sock, XJ_JMSG_CHAT, XJ_JMSG_GROUPCHAT, xode_free(), xode_insert_cdata(), xode_new_tag(), xode_put_attrib(), xode_to_str(), and xode_wrap().

Referenced by xj_worker_check_qmsg(), and xj_worker_process().

int xj_jcon_send_presence ( xj_jcon  jbc,
char *  sto,
char *  type,
char *  status,
char *  priority 
)

send presence type - "unavailable", "subscribe", "subscribed" .... status - "online", "away", "unavailable" ... priority - "0", "1", ...

Definition at line 470 of file xjab_jcon.c.

References LM_DBG, NULL, _xj_jcon::sock, xode_free(), xode_insert_cdata(), xode_insert_tag(), xode_new_tag(), xode_put_attrib(), and xode_to_str().

Referenced by xj_jcon_disconnect(), xj_jcon_jconf_presence(), xj_manage_jab(), and xj_worker_process().

int xj_jcon_send_subscribe ( xj_jcon  jbc,
char *  to,
char *  from,
char *  type 
)

send subscribe for user's presence

Definition at line 522 of file xjab_jcon.c.

References LM_DBG, NULL, _xj_jcon::sock, xode_free(), xode_new_tag(), xode_put_attrib(), and xode_to_str().

Referenced by xj_worker_check_watcher().

int xj_jcon_set_attrs ( xj_jcon  jbc,
xj_jkey  jkey,
int  cache_time,
int  delay_time 
)

create a open connection to Jabber

  • id : id of the connection
  • jbc : pointer to Jabber connection
  • cache_time : life time of the connection
  • delay_time : time needed to became an active connection return : pointer to the structure or NULL on error

Definition at line 605 of file xjab_jcon.c.

References _xj_jcon::expire, get_ticks(), _xj_jkey::id, _xj_jcon::jkey, NULL, _xj_jcon::ready, and _str::s.

Referenced by xj_worker_process().

void xj_jcon_set_juid ( xj_jcon  jbc,
int  _juid 
)

set the Jabber internal ID

Definition at line 138 of file xjab_jcon.c.

References _xj_jcon::juid, and NULL.

int xj_jcon_set_roster ( xj_jcon  jbc,
char *  jid,
char *  type 
)

add a new contact in user's roster

Definition at line 357 of file xjab_jcon.c.

References LM_DBG, NULL, _xj_jcon::seq_nr, _xj_jcon::sock, xode_free(), xode_new_tag(), xode_put_attrib(), xode_to_str(), and xode_wrap().

int xj_jcon_update ( xj_jcon  jbc,
int  cache_time 
)

update the life time of the connection

  • ojc : pointer to the open connection
  • cache_time : number of seconds to keep the connection open return : 0 on success or <0 on error

Definition at line 624 of file xjab_jcon.c.

References _xj_jcon::expire, get_ticks(), _xj_jkey::id, _xj_jcon::jkey, _str::len, LM_DBG, NULL, and _str::s.

Referenced by xj_worker_process().

int xj_jcon_user_auth ( xj_jcon  jbc,
char *  username,
char *  passwd,
char *  resource 
)


Generated on Fri May 25 00:00:45 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6