37 static void _status_os_replace(storage_t st,
const char *jid,
char *status,
char *show, time_t *lastlogin, time_t *lastlogout,
nad_t nad) {
39 os_object_t o = os_object_new(os);
40 os_object_put(o,
"status", status, os_type_STRING);
41 os_object_put(o,
"show", show, os_type_STRING);
42 os_object_put(o,
"last-login", (
void **) lastlogin, os_type_INTEGER);
43 os_object_put(o,
"last-logout", (
void **) lastlogout, os_type_INTEGER);
44 if(nad != NULL) os_object_put(o,
"xml", nad, os_type_NAD);
45 storage_replace(st,
"status", jid, NULL, os);
49 static void _status_store(storage_t st,
const char *jid,
pkt_t pkt, time_t *lastlogin, time_t *lastlogout) {
78 if(show_free) free(show);
93 if (ret == st_SUCCESS)
95 if (os_iter_first(os))
97 o = os_iter_object(os);
98 os_object_get_time(os, o,
"last-logout", &lastlogout);
99 os_object_get_nad(os, o,
"xml", &nad);
106 lastlogout = (time_t) 0;
130 if (ret == st_SUCCESS)
132 if (os_iter_first(os))
134 o = os_iter_object(os);
135 os_object_get_time(os, o,
"last-login", &lastlogin);
136 os_object_get_nad(os, o,
"xml", &nad);
143 lastlogin = (time_t) 0;
154 time_t lastlogin, lastlogout;
164 if (ret == st_SUCCESS)
166 if (os_iter_first(os))
168 o = os_iter_object(os);
169 os_object_get_time(os, o,
"last-login", &lastlogin);
170 os_object_get_time(os, o,
"last-logout", &lastlogout);
176 lastlogin = (time_t) 0;
177 lastlogout = (time_t) 0;
222 storage_delete(mi->
sm->
st,
"status",
jid_user(jid), NULL);
234 if (mod->
init)
return 0;
user_t user
user this session belongs to
static void _status_sess_end(mod_instance_t mi, sess_t sess)
pkt_type_t type
packet type
jid_t jid
session jid (user@host/res)
static int _status_sess_start(mod_instance_t mi, sess_t sess)
data structures and prototypes for the session manager
#define NAD_CDATA_L(N, E)
static void _status_user_delete(mod_instance_t mi, jid_t jid)
const char * jid_user(jid_t jid)
expand and return the user
const char * jid_full(jid_t jid)
expand and return the full
jid_t jid_new(const char *id, int len)
make a new jid
single instance of a module in a chain
int nad_find_elem(nad_t nad, int elem, int ns, const char *name, int depth)
locate the next elem at a given depth with an optional matching name
config_t config
config context
int init
number of times the module intialiser has been called
void(* sess_end)(mod_instance_t mi, sess_t sess)
sess-end handler
void nad_free(nad_t nad)
free that nad
nad_t nad_copy(nad_t nad)
copy a nad
sess_t top
top priority session
mod_ret_t(* in_sess)(mod_instance_t mi, sess_t sess, pkt_t pkt)
in-sess handler
jid_t jid_reset_components(jid_t jid, const char *node, const char *domain, const char *resource)
build a jid from components
module_t mod
module that this is an instance of
jid_t from
packet addressing (not used for routing)
void * private
module private data
packet summary data wrapper
storage_t st
storage subsystem
nad_t nad
nad of the entire packet
session manager global context
void jid_free(jid_t jid)
free a jid
void pkt_router(pkt_t pkt)
static void _status_os_replace(storage_t st, const char *jid, char *status, char *show, time_t *lastlogin, time_t *lastlogout, nad_t nad)
packet was unhandled, should be passed to the next module
static void _status_free(module_t mod)
There is one instance of this struct per user who is logged in to this c2s instance.
void(* user_delete)(mod_instance_t mi, jid_t jid)
user-delete handler
mod_ret_t(* pkt_sm)(mod_instance_t mi, pkt_t pkt)
pkt-sm handler
static void _status_store(storage_t st, const char *jid, pkt_t pkt, time_t *lastlogin, time_t *lastlogout)
static mod_ret_t _status_pkt_sm(mod_instance_t mi, pkt_t pkt)
DLLEXPORT int module_init(mod_instance_t mi, const char *arg)
int(* sess_start)(mod_instance_t mi, sess_t sess)
sess-start handler
const char * config_get_one(config_t c, const char *key, int num)
get config value n for this key
void(* free)(module_t mod)
called when module is freed
static mod_ret_t _status_in_sess(mod_instance_t mi, sess_t sess, pkt_t pkt)
struct _status_st * status_t
pkt_t pkt_create(sm_t sm, const char *elem, const char *type, const char *to, const char *from)
mod_ret_t
module return values