util.cc File Reference

utility functions for jsm More...

#include "jsm.h"

Functions

void js_bounce_xmpp (jsmi si, session s, xmlnode x, xterror xterr)
xmlnode js_config (jsmi si, const char *query, const char *lang)
int js_islocal (jsmi si, jid id)
jid js_trustees (udata u)
jid js_seen_jids (udata u)
void js_remove_trustee (udata u, jid id)
void js_remove_seen (udata u, jid id)
int _js_jidscanner (jid id, jid match)
int js_trust (udata u, jid id)
int js_seen (udata u, jid id)
int js_online (mapi m)


Detailed Description

utility functions for jsm


Function Documentation

int _js_jidscanner ( jid  id,
jid  match 
)

this tries to be a smarter jid matcher, where a "host" matches any "user@host" and "user@host" matches "user@host/resource"

Parameters:
id the jid that should be checked
match the jid that should be matched
Returns:
0 if it did not match, 1 if it did match

References xmppd::jabberid::get_domain(), xmppd::jabberid::get_node(), xmppd::jabberid::get_resource(), xmppd::jabberid::has_node(), and xmppd::jabberid::has_resource().

Referenced by js_seen(), and js_trust().

void js_bounce_xmpp ( jsmi  si,
session  s,
xmlnode  x,
xterror  xterr 
)

generate an error packet, that bounces a packet back to the server

Parameters:
si the session manger instance
s the session this bounce is related to (for selecting the right filters), NULL if not related to any session
x the xmlnode for which the bounce packet should be generated
xterr the reason for the bounce

References xterror_struct::code, jpacket_struct::flag, j_strcmp(), jpacket_new(), js_deliver(), jutil_error_xmpp(), jutil_iqresult(), log_debug2, LOGT_DELIVER, xterror_struct::msg, NS_SERVER, PACKET_PASS_FILTERS_MAGIC, xmlnode_free(), xmlnode_get_attrib(), xmlnode_get_localname(), xmlnode_get_namespace(), xmlnode_insert_cdata(), xmlnode_insert_tag_ns(), xmlnode_put_attrib_ns(), xmlnode_serialize_string(), and ZONE.

Referenced by js_deliver(), js_offline_main(), and js_server_main().

xmlnode js_config ( jsmi  si,
const char *  query,
const char *  lang 
)

get a configuration node inside the session manager configuration

Parameters:
si the session manager instance data
query the path through the tag hierarchy of the desired tag, eg. for the conf file <foo><bar>bar value</bar><baz/></foo> use "foo/bar" to retrieve the bar node, may be NULL to get the root node of the jsm config
lang the prefered language, NULL for no prefered language
Returns:
a pointer to the xmlnode (has to be freed by the caller!), or NULL if no such node could be found

References jid_new(), js_config(), log_debug2, LOGT_CONFIG, NS_JABBERD_CONFIG_JSM, pool_free(), pool_new, jsmi_struct::std_namespace_prefixes, jsmi_struct::xc, xdb_get(), xmlnode_get_tags(), xmlnode_select_by_lang(), and ZONE.

Referenced by _js_authreg_register(), js_config(), js_packet(), jsm(), mod_auth_crypt(), mod_auth_digest(), mod_auth_plain(), mod_last(), mod_log(), mod_offline(), mod_presence(), mod_version(), and mod_xml().

int js_islocal ( jsmi  si,
jid  id 
)

macro to make sure the jid is a local user

Parameters:
si the session manager instance data
id the user to test
Returns:
0 if the user is not local, 1 if the user is local

References xmppd::jabberid::get_domain(), xmppd::jabberid::has_node(), jsmi_struct::hosts, and xhash_get().

Referenced by js_server_main().

int js_online ( mapi  m  ) 

check if a mapi call is for the "online" event

sucks, should just rewrite the whole mapi to make things like this better

Parameters:
m the mapi call
Returns:
1 if the mapi call is for the "online" event, 0 else

References JPACKET__AVAILABLE, JPACKET__INVISIBLE, jpacket_subtype(), mapi_struct::packet, session_struct::priority, mapi_struct::s, and jpacket_struct::to.

void js_remove_seen ( udata  u,
jid  id 
)

remove a user from the list of seen users

Parameters:
u from which user's seen list the user 'id' should be removed
id which user should be removed

References jid_cmpx(), JID_SERVER, JID_USER, xmppd::jabberid_pool::next, and udata_struct::useen.

void js_remove_trustee ( udata  u,
jid  id 
)

remove a user from the list of trustees

Parameters:
u from which user's trustees list the user 'id' should be removed
id which user should be removed

References jid_cmpx(), JID_SERVER, JID_USER, xmppd::jabberid_pool::next, and udata_struct::utrust.

int js_seen ( udata  u,
jid  id 
)

check if a id is seen (allowed to send presence to a user)

Parameters:
u the user for which the check should be made
id the jid which should be checked if it is trusted
Returns:
0 if it is not trusted, 1 if it is trusted

References _js_jidscanner(), and js_seen_jids().

jid js_seen_jids ( udata  u  ) 

get the list of jids, that are allowed to send presence to a given user

Parameters:
u for which user to get the list
Returns:
pointer to the first list entry

References udata_struct::useen.

Referenced by js_seen().

int js_trust ( udata  u,
jid  id 
)

check if a id is trusted (allowed to see the presence of a user)

Parameters:
u the user for which the check should be made
id the jid which should be checked if it is trusted
Returns:
0 if it is not trusted, 1 if it is trusted

References _js_jidscanner(), acl_check_access(), ADMIN_SHOWPRES, js_trustees(), udata_struct::si, and jsmi_struct::xc.

jid js_trustees ( udata  u  ) 

get the list of jids, that are subscribed to a given user

Parameters:
u for which user to get the list
Returns:
pointer to the first list entry

References udata_struct::utrust.

Referenced by js_trust().


Generated on Wed Sep 10 01:59:48 2008 for jabberd14 by  doxygen 1.5.5