#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"

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 JB_CLIENT_OPEN_STREAM "<stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>" |
| #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>" |
| #define JB_START_STREAM "<?xml version='1.0'?>" |
| #define JB_START_STREAM_LEN 21 |
| #define XJ_MAX_JCONF 12 |
Definition at line 727 of file xjab_jcon.c.
References find234(), _xj_jcon::jconf, _str::len, LM_DBG, _xj_jcon::nrjconf, NULL, _str::s, xj_jconf_free(), xj_jconf_init_jab(), and xj_jconf_new().
Referenced by xj_manage_jab().
| 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().
Definition at line 774 of file xjab_jcon.c.
References del234(), _xj_jkey::id, _xj_jcon::jconf, _xj_jcon::jkey, _str::len, LM_DBG, _xj_jcon::nrjconf, NULL, _str::s, XJ_JCMD_UNSUBSCRIBE, xj_jcon_jconf_presence(), xj_jconf_free(), xj_jconf_init_sip(), and xj_jconf_new().
Referenced by xj_worker_process().
| 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 | ) |
free the allocated memory space of a JABBER connection
Definition at line 560 of file xjab_jcon.c.
References _M_FREE, delpos234(), _xj_jcon::hostname, _xj_jcon::jconf, LM_DBG, _xj_jcon::nrjconf, NULL, _xj_jcon::plist, _xj_jcon::resource, _xj_jcon::stream_id, xj_jconf_free(), and xj_pres_list_free().
Referenced by xj_jcon_pool_del(), xj_jcon_pool_free(), xj_worker_check_jcons(), and xj_worker_process().
Definition at line 682 of file xjab_jcon.c.
References add234(), find234(), _xj_jkey::id, _xj_jcon::jconf, _xj_jcon::jkey, _str::len, LM_DBG, newtree234(), _xj_jcon::nrjconf, NULL, _str::s, xj_jconf_cmp(), xj_jconf_free(), xj_jconf_init_sip(), xj_jconf_new(), and XJ_MAX_JCONF.
Referenced by xj_jcon_is_ready(), and xj_worker_process().
| 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 | |||
| ) |
init a JABBER connection
Definition at line 60 of file xjab_jcon.c.
References _M_FREE, _M_MALLOC, _xj_jcon::allowed, _xj_jcon::hostname, _xj_jcon::jconf, _xj_jcon::juid, _xj_jcon::nrjconf, NULL, _xj_jcon::plist, _xj_jcon::port, _xj_jcon::ready, _xj_jcon::seq_nr, _xj_jcon::sock, XJ_NET_NUL, and xj_pres_list_init().
Referenced by xj_worker_process().
| int xj_jcon_is_ready | ( | xj_jcon | jbc, | |
| char * | to, | |||
| int | tol, | |||
| char | dl | |||
| ) |
Definition at line 636 of file xjab_jcon.c.
References _xj_jcon::allowed, _str::len, LM_DBG, NULL, _xj_jcon::ready, _str::s, _xj_jconf::status, XJ_AIM_LEN, XJ_AIM_NAME, XJ_ICQ_LEN, XJ_ICQ_NAME, xj_jcon_get_jconf(), xj_jconf_check_addr(), XJ_JCONF_READY, XJ_MSN_LEN, XJ_MSN_NAME, XJ_NET_AIM, XJ_NET_ICQ, XJ_NET_MSN, XJ_NET_YAH, XJ_YAH_LEN, and XJ_YAH_NAME.
Referenced by xj_worker_check_qmsg(), and xj_worker_process().
Definition at line 759 of file xjab_jcon.c.
References _str::len, _xj_jconf::nick, NULL, _xj_jconf::room, _str::s, _xj_jconf::server, and xj_jcon_send_presence().
Referenced by xj_jcon_del_jconf(), xj_manage_jab(), xj_worker_check_jcons(), and xj_worker_process().
| 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().
create a open connection to Jabber
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
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 | |||
| ) |
authentication to the JABBER server
Definition at line 181 of file xjab_jcon.c.
References _M_MALLOC, _xj_jcon::allowed, _xj_jcon::hostname, JB_CLIENT_OPEN_STREAM, JB_START_STREAM, JB_START_STREAM_LEN, NULL, _xj_jcon::ready, _xj_jcon::resource, _xj_jcon::seq_nr, shahash(), _xj_jcon::sock, _xj_jcon::stream_id, XJ_NET_ALL, XJ_NET_JAB, xode_free(), xode_from_strx(), xode_get_attrib(), xode_get_name(), xode_get_tag(), xode_insert_cdata(), xode_insert_tag(), xode_new_tag(), xode_put_attrib(), xode_to_str(), and xode_wrap().
Referenced by xj_worker_process().
1.5.6