… | |
… | |
4 | * |
4 | * |
5 | * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
5 | * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
6 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
6 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
7 | */ |
7 | */ |
8 | |
8 | |
9 | static char const rcsid[] = "$Id: account.C,v 1.4 2007/08/28 17:08:12 pippijn Exp $"; |
9 | static char const rcsid[] = "$Id: account.C,v 1.5 2007/08/30 19:56:24 pippijn Exp $"; |
10 | |
10 | |
11 | #include <boost/foreach.hpp> |
11 | #include <boost/foreach.hpp> |
12 | |
12 | |
13 | #include "atheme.h" |
13 | #include "atheme.h" |
14 | #include <account/myuser.h> |
14 | #include <account/myuser.h> |
… | |
… | |
41 | mynick_heap = BlockHeapCreate (sizeof (myuser_t), HEAP_USER); |
41 | mynick_heap = BlockHeapCreate (sizeof (myuser_t), HEAP_USER); |
42 | mychan_heap = BlockHeapCreate (sizeof (mychan_t), HEAP_CHANNEL); |
42 | mychan_heap = BlockHeapCreate (sizeof (mychan_t), HEAP_CHANNEL); |
43 | chanacs_heap = BlockHeapCreate (sizeof (chanacs_t), HEAP_CHANUSER); |
43 | chanacs_heap = BlockHeapCreate (sizeof (chanacs_t), HEAP_CHANUSER); |
44 | metadata_heap = BlockHeapCreate (sizeof (metadata_t), HEAP_CHANUSER); |
44 | metadata_heap = BlockHeapCreate (sizeof (metadata_t), HEAP_CHANUSER); |
45 | #endif |
45 | #endif |
46 | |
|
|
47 | mclist = dictionary_create ("mychan", HASH_CHANNEL, irccasecmp); |
|
|
48 | } |
46 | } |
49 | |
47 | |
50 | static int |
48 | static int |
51 | expire_myuser_cb (myuser_pair &mup) |
49 | expire_myuser_cb (myuser_pair &mup) |
52 | { |
50 | { |
… | |
… | |
86 | expire_check (void *arg) |
84 | expire_check (void *arg) |
87 | { |
85 | { |
88 | mynick_t *mn; |
86 | mynick_t *mn; |
89 | mychan_t *mc; |
87 | mychan_t *mc; |
90 | user_t *u; |
88 | user_t *u; |
91 | dictionary_iteration_state_t state; |
|
|
92 | |
89 | |
93 | /* Let them know about this and the likely subsequent db_save() |
90 | /* Let them know about this and the likely subsequent db_save() |
94 | * right away -- jilles */ |
91 | * right away -- jilles */ |
95 | sendq_flush (curr_uplink->conn); |
92 | sendq_flush (curr_uplink->conn); |
96 | |
93 | |
… | |
… | |
126 | } |
123 | } |
127 | } |
124 | } |
128 | |
125 | |
129 | if (chansvs.expiry != 0) |
126 | if (chansvs.expiry != 0) |
130 | { |
127 | { |
131 | DICTIONARY_FOREACH (mc, mychan_t, &state, mclist) |
128 | foreach (mychan_pair &mp, mclist) |
132 | { |
129 | { |
|
|
130 | mc = mp.second; |
133 | if ((NOW - mc->used) >= 86400 - 3660) |
131 | if ((NOW - mc->used) >= 86400 - 3660) |
134 | { |
132 | { |
135 | /* keep last used time accurate to |
133 | /* keep last used time accurate to |
136 | * within a day, making sure an active |
134 | * within a day, making sure an active |
137 | * channel will never get "Last used" |
135 | * channel will never get "Last used" |
138 | * in /cs info -- jilles */ |
136 | * in /cs info -- jilles */ |
139 | if (mychan_isused (mc)) |
137 | if (mc->isused ()) |
140 | { |
138 | { |
141 | mc->used = NOW; |
139 | mc->used = NOW; |
142 | slog (LG_DEBUG, "expire_check(): updating last used time on %s because it appears to be still in use", mc->name); |
140 | slog (LG_DEBUG, "expire_check(): updating last used time on %s because it appears to be still in use", mc->name); |
143 | continue; |
141 | continue; |
144 | } |
142 | } |
145 | } |
143 | } |
146 | |
144 | |
147 | if ((NOW - mc->used) >= chansvs.expiry) |
145 | if ((NOW - mc->used) >= chansvs.expiry) |
148 | { |
146 | { |
149 | if (MC_HOLD & mc->flags) |
147 | if (MC_HOLD & mc->flags) |
150 | continue; |
148 | continue; |
151 | |
149 | |
152 | snoop (_("EXPIRE: \2%s\2 from \2%s\2"), mc->name, mychan_founder_names (mc)); |
150 | snoop (_("EXPIRE: \2%s\2 from \2%s\2"), mc->name, mc->founder_names ()); |
153 | slog (LG_REGISTER, "expire_check(): expiring channel %s (unused %ds, founder %s, chanacs %d)", |
151 | slog (LG_REGISTER, "expire_check(): expiring channel %s (unused %ds, founder %s, chanacs %d)", |
154 | mc->name, |
152 | mc->name, |
155 | NOW - mc->used, |
153 | NOW - mc->used, |
156 | mychan_founder_names (mc), |
154 | mc->founder_names (), |
157 | LIST_LENGTH (&mc->chanacs)); |
155 | LIST_LENGTH (&mc->chanacs)); |
158 | |
156 | |
159 | mc->callback.drop (mc); |
157 | mc->callback.drop (mc); |
160 | if ((config_options.chan && irccasecmp (mc->name, config_options.chan)) || !config_options.chan) |
158 | if ((config_options.chan && irccasecmp (mc->name, config_options.chan)) || !config_options.chan) |
161 | part (mc->name, chansvs.nick); |
159 | part (mc->name, chansvs.nick); |
162 | |
160 | |
163 | mc->refcnt_dec (); |
161 | mc->refcnt_dec (); |
164 | } |
162 | } |
165 | } |
163 | } |
166 | } |
164 | } |
167 | } |
165 | } |
168 | |
166 | |
169 | static int |
167 | static int |
170 | check_myuser_cb (myuser_pair &mup) |
168 | check_myuser_cb (myuser_pair &mup) |