30 #define uri_VACATION "http://jabber.org/protocol/vacation" 99 if(start < 0 || end < 0 || msg < 0) {
108 storage_delete(mi->
sm->
st,
"vacation-settings",
jid_user(sess->
jid), NULL);
136 o = os_object_new(os);
137 os_object_put(o,
"start", &v->
start, os_type_INTEGER);
138 os_object_put(o,
"end", &v->
end, os_type_INTEGER);
139 os_object_put(o,
"message", v->
msg, os_type_STRING);
141 if(storage_replace(mod->
mm->
sm->
st,
"vacation-settings",
jid_user(sess->
user->
jid), NULL, os) != st_SUCCESS) {
207 if(storage_get(mod->
mm->
sm->
st,
"vacation-settings",
jid_user(user->
jid), NULL, &os) == st_SUCCESS) {
208 if(os_iter_first(os)) {
209 o = os_iter_object(os);
211 if(os_object_get_time(os, o,
"start", &v->
start) &&
212 os_object_get_time(os, o,
"end", &v->
end) &&
213 os_object_get_str(os, o,
"message", &v->
msg))
233 storage_delete(mi->
sm->
st,
"vacation-settings",
jid_user(jid), NULL);
244 if(mod->
init)
return 0;
static mod_ret_t _vacation_in_sess(mod_instance_t mi, sess_t sess, pkt_t pkt)
user_t user
user this session belongs to
pkt_type_t type
packet type
int sm_register_ns(sm_t sm, const char *uri)
register a new global ns
jid_t jid
session jid (user@host/res)
data structures and prototypes for the session manager
struct _vacation_st * vacation_t
#define NAD_CDATA_L(N, E)
static mod_ret_t _vacation_pkt_user(mod_instance_t mi, user_t user, pkt_t pkt)
void sm_unregister_ns(sm_t sm, const char *uri)
unregister a global ns
const char * jid_user(jid_t jid)
expand and return the user
const char * jid_full(jid_t jid)
expand and return the full
pkt_t pkt_tofrom(pkt_t pkt)
swap a packet's to and from attributes
single instance of a module in a chain
void nad_set_attr(nad_t nad, unsigned int elem, int ns, const char *name, const char *val, int vallen)
create, update, or zap any matching attr on this elem
int init
number of times the module intialiser has been called
static void _vacation_user_free(vacation_t v)
int nad_insert_elem(nad_t nad, unsigned int parent, int ns, const char *name, const char *cdata)
shove in a new child elem after the given one
void jid_expand(jid_t jid)
build user and full if they're out of date
sess_t top
top priority session
void pool_cleanup(pool_t p, pool_cleanup_t f, void *arg)
public cleanup utils, insert in a way that they are run FIFO, before mem frees
mod_ret_t(* in_sess)(mod_instance_t mi, sess_t sess, pkt_t pkt)
in-sess handler
pool_t p
memory pool this user is allocated off
module_t mod
module that this is an instance of
jid_t from
packet addressing (not used for routing)
void feature_unregister(sm_t sm, const char *feature)
unregister feature
packet summary data wrapper
DLLEXPORT int module_init(mod_instance_t mi, const char *arg)
storage_t st
storage subsystem
nad_t nad
nad of the entire packet
void datetime_out(time_t t, datetime_t type, char *date, int datelen)
#define stanza_err_BAD_REQUEST
void pkt_id(pkt_t src, pkt_t dest)
convenience - copy the packet id from src to dest
mod_ret_t(* pkt_user)(mod_instance_t mi, user_t user, pkt_t pkt)
pkt-user handler
static int _vacation_user_load(mod_instance_t mi, user_t user)
void pkt_router(pkt_t pkt)
void feature_register(sm_t sm, const char *feature)
register a feature
static void _vacation_free(module_t mod)
packet was unhandled, should be passed to the next module
packet was handled (and freed)
There is one instance of this struct per user who is logged in to this c2s instance.
int(* user_load)(mod_instance_t mi, user_t user)
user-load handler
int nad_find_elem(nad_t nad, unsigned int elem, int ns, const char *name, int depth)
locate the next elem at a given depth with an optional matching name
time_t datetime_in(char *date)
void(* user_delete)(mod_instance_t mi, jid_t jid)
user-delete handler
static void _vacation_user_delete(mod_instance_t mi, jid_t jid)
jid_t jid
user jid (user@host)
void(* free)(module_t mod)
called when module is freed
void ** module_data
per-user module data
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
#define stanza_err_INTERNAL_SERVER_ERROR
void pkt_sess(pkt_t pkt, sess_t sess)
int nad_find_scoped_namespace(nad_t nad, const char *uri, const char *prefix)
find a namespace in scope