… | |
… | |
8 | * Portions of this file were derived from sources bearing the following license: |
8 | * Portions of this file were derived from sources bearing the following license: |
9 | * Rights to this code are documented in doc/pod/license.pod. |
9 | * Rights to this code are documented in doc/pod/license.pod. |
10 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
10 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
11 | */ |
11 | */ |
12 | |
12 | |
13 | static char const rcsid[] = "$Id: users.C,v 1.6 2007/09/16 18:54:45 pippijn Exp $"; |
13 | static char const rcsid[] = "$Id: users.C,v 1.7 2007/09/22 14:27:30 pippijn Exp $"; |
14 | |
14 | |
15 | #include "atheme.h" |
15 | #include "atheme.h" |
|
|
16 | #include <libermyth.h> |
16 | #include "servers.h" |
17 | #include "servers.h" |
17 | #include <account/mynick.h> |
18 | #include <account/mynick.h> |
18 | #include <account/myuser.h> |
19 | #include <account/myuser.h> |
|
|
20 | #include <util/predicates.h> |
19 | |
21 | |
20 | user_map userlist; |
22 | user_t::map_type user_t::map; |
21 | typedef std::map<char const * const, user_t *, str_lt> uid_map; |
23 | typedef std::map<char const * const, user_t *, str_lt> uid_map; |
22 | static uid_map uidlist; |
24 | static uid_map uidlist; |
23 | user_t::callbacks user_t::callback; |
25 | user_t::callbacks user_t::callback; |
24 | |
26 | |
25 | /* |
27 | /* |
… | |
… | |
106 | if (ts) |
108 | if (ts) |
107 | u->ts = ts; |
109 | u->ts = ts; |
108 | else |
110 | else |
109 | u->ts = NOW; |
111 | u->ts = NOW; |
110 | |
112 | |
111 | userlist[u->nick] = u; |
113 | user_t::map[u->nick] = u; |
112 | |
114 | |
113 | cnt.user++; |
115 | cnt.user++; |
114 | |
116 | |
115 | u->callback.add (u); |
117 | u->callback.add (u); |
116 | |
118 | |
… | |
… | |
160 | cu = (chanuser_t *) n->data; |
162 | cu = (chanuser_t *) n->data; |
161 | |
163 | |
162 | chanuser_delete (cu->chan, u); |
164 | chanuser_delete (cu->chan, u); |
163 | } |
165 | } |
164 | |
166 | |
165 | userlist.erase (u->nick); |
167 | user_t::map.erase (u->nick); |
166 | |
168 | |
167 | if (*u->uid) |
169 | if (*u->uid) |
168 | uidlist.erase (u->uid); |
170 | uidlist.erase (u->uid); |
169 | |
171 | |
170 | n = node_find (u, &u->server->userlist); |
172 | n = node_find (u, &u->server->userlist); |
… | |
… | |
201 | * - none |
203 | * - none |
202 | */ |
204 | */ |
203 | user_t * |
205 | user_t * |
204 | user_find (char const * const nick) |
206 | user_find (char const * const nick) |
205 | { |
207 | { |
206 | user_map::iterator it; |
208 | user_t::map_type::iterator it; |
207 | uid_map::iterator idit; |
209 | uid_map::iterator idit; |
208 | |
210 | |
209 | if (nick == NULL) |
211 | if (nick == NULL) |
210 | return NULL; |
212 | return NULL; |
211 | |
213 | |
… | |
… | |
215 | |
217 | |
216 | if (idit != uidlist.end ()) |
218 | if (idit != uidlist.end ()) |
217 | return idit->second; |
219 | return idit->second; |
218 | } |
220 | } |
219 | |
221 | |
220 | it = userlist.find (nick); |
222 | it = user_t::map.find (nick); |
221 | |
223 | |
222 | if (it != userlist.end ()) |
224 | if (it != user_t::map.end ()) |
223 | { |
225 | { |
224 | if (ircd->uses_p10) |
226 | if (ircd->uses_p10) |
225 | wallops (_("user_find(): found user %s by nick!"), nick); |
227 | wallops (_("user_find(): found user %s by nick!"), nick); |
226 | return it->second; |
228 | return it->second; |
227 | } |
229 | } |
… | |
… | |
245 | * - none |
247 | * - none |
246 | */ |
248 | */ |
247 | user_t * |
249 | user_t * |
248 | user_find_named (char const * const nick) |
250 | user_find_named (char const * const nick) |
249 | { |
251 | { |
250 | user_map::iterator it = userlist.find (nick); |
252 | user_t::map_type::iterator it = user_t::map.find (nick); |
251 | |
253 | |
252 | if (it != userlist.end ()) |
254 | if (it != user_t::map.end ()) |
253 | return it->second; |
255 | return it->second; |
254 | |
256 | |
255 | return NULL; |
257 | return NULL; |
256 | } |
258 | } |
257 | |
259 | |
… | |
… | |
303 | { |
305 | { |
304 | mynick_t *mn; |
306 | mynick_t *mn; |
305 | |
307 | |
306 | if (u->myuser != NULL && (mn = mynick_t::find (u->nick)) != NULL && mn->owner == u->myuser) |
308 | if (u->myuser != NULL && (mn = mynick_t::find (u->nick)) != NULL && mn->owner == u->myuser) |
307 | mn->lastseen = NOW; |
309 | mn->lastseen = NOW; |
308 | userlist.erase (u->nick); |
310 | user_t::map.erase (u->nick); |
309 | |
311 | |
310 | strlcpy (u->nick, nick, NICKLEN); |
312 | strlcpy (u->nick, nick, NICKLEN); |
311 | u->ts = ts; |
313 | u->ts = ts; |
312 | |
314 | |
313 | userlist[u->nick] = u; |
315 | user_t::map[u->nick] = u; |
314 | } |
316 | } |
315 | |
317 | |
316 | /* |
318 | /* |
317 | * user_mode(user_t *user, char *modes) |
319 | * user_mode(user_t *user, char *modes) |
318 | * |
320 | * |