jabberd2
2.2.17
Main Page
Data Structures
Files
File List
Globals
sm
mod_active.c
Go to the documentation of this file.
1
/*
2
* jabberd - Jabber Open Source Server
3
* Copyright (c) 2002-2003 Jeremie Miller, Thomas Muldowney,
4
* Ryan Eatmon, Robert Norris
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19
*/
20
28
#include "
sm.h
"
29
30
static
int
_active_user_load
(
mod_instance_t
mi,
user_t
user) {
31
os_t os;
32
os_object_t o;
33
34
/* get their active status */
35
if
(storage_get(user->
sm
->
st
,
"active"
,
jid_user
(user->
jid
), NULL, &os) == st_SUCCESS && os_iter_first(os)) {
36
o = os_iter_object(os);
37
os_object_get_time(os, o,
"time"
, &user->
active
);
38
os_free(os);
39
}
else
40
/* can't load them if they're inactive */
41
return
1;
42
43
return
0;
44
}
45
46
static
int
_active_user_create
(
mod_instance_t
mi,
jid_t
jid) {
47
time_t t;
48
os_t os;
49
os_object_t o;
50
51
log_debug
(
ZONE
,
"activating user %s"
,
jid_user
(jid));
52
53
t = time(NULL);
54
55
os = os_new();
56
o = os_object_new(os);
57
os_object_put_time(o,
"time"
, &t);
58
storage_put(mi->
sm
->
st
,
"active"
,
jid_user
(jid), os);
59
os_free(os);
60
61
return
0;
62
}
63
64
static
void
_active_user_delete
(
mod_instance_t
mi,
jid_t
jid) {
65
log_debug
(
ZONE
,
"deactivating user %s"
,
jid_user
(jid));
66
67
storage_delete(mi->
sm
->
st
,
"active"
,
jid_user
(jid), NULL);
68
}
69
70
DLLEXPORT
int
module_init
(
mod_instance_t
mi,
char
*arg) {
71
module_t
mod = mi->
mod
;
72
73
if
(mod->
init
)
return
0;
74
75
mod->
user_load
=
_active_user_load
;
76
mod->
user_create
=
_active_user_create
;
77
mod->
user_delete
=
_active_user_delete
;
78
79
return
0;
80
}
Generated by
1.8.1.1