1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/* NickServ functions.
*
* (C) 2003-2012 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
#include "services.h"
#include "account.h"
#include "modules.h"
#include "users.h"
#include "protocol.h"
#include "regchannel.h"
NickAlias* findnick(const Anope::string &nick)
{
nickalias_map::const_iterator it = NickAliasList->find(nick);
if (it != NickAliasList->end())
{
it->second->QueueUpdate();
return it->second;
}
return NULL;
}
/*************************************************************************/
NickCore* findcore(const Anope::string &nick)
{
nickcore_map::const_iterator it = NickCoreList->find(nick);
if (it != NickCoreList->end())
{
it->second->QueueUpdate();
return it->second;
}
return NULL;
}
/** Is the user's address on the nickcores access list?
* @param u The user
* @param nc The nickcore
* @return true or false
*/
bool is_on_access(const User *u, const NickCore *nc)
{
if (!u || !nc || nc->access.empty())
return false;
Anope::string buf = u->GetIdent() + "@" + u->host, buf2, buf3;
if (!u->vhost.empty())
buf2 = u->GetIdent() + "@" + u->vhost;
if (!u->GetCloakedHost().empty())
buf3 = u->GetIdent() + "@" + u->GetCloakedHost();
for (unsigned i = 0, end = nc->access.size(); i < end; ++i)
{
Anope::string access = nc->GetAccess(i);
if (Anope::Match(buf, access) || (!buf2.empty() && Anope::Match(buf2, access)) || (!buf3.empty() && Anope::Match(buf3, access)))
return true;
}
return false;
}
/*************************************************************************/
/* Sets nc->display to newdisplay. If newdisplay is NULL, it will change
* it to the first alias in the list.
*/
void change_core_display(NickCore *nc, const Anope::string &newdisplay)
{
FOREACH_MOD(I_OnChangeCoreDisplay, OnChangeCoreDisplay(nc, newdisplay));
/* Remove the core from the list */
NickCoreList->erase(nc->display);
nc->display = newdisplay;
(*NickCoreList)[nc->display] = nc;
}
void change_core_display(NickCore *nc)
{
const NickAlias *na;
if (nc->aliases.empty())
return;
na = nc->aliases.front();
change_core_display(nc, na->nick);
}
std::set<IdentifyRequest *> IdentifyRequest::requests;
IdentifyRequest::IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass) : owner(o), account(acc), password(pass), dispatched(false), success(false)
{
requests.insert(this);
}
IdentifyRequest::~IdentifyRequest()
{
requests.erase(this);
}
void IdentifyRequest::Hold(Module *m)
{
holds.insert(m);
}
void IdentifyRequest::Release(Module *m)
{
holds.erase(m);
if (holds.empty() && dispatched)
{
if (!success)
this->OnFail();
delete this;
}
}
void IdentifyRequest::Success(Module *m)
{
if (!success)
{
this->OnSuccess();
success = true;
}
}
void IdentifyRequest::Dispatch()
{
if (holds.empty())
{
if (!success)
this->OnFail();
delete this;
}
else
dispatched = true;
}
void IdentifyRequest::ModuleUnload(Module *m)
{
for (std::set<IdentifyRequest *>::iterator it = requests.begin(), it_end = requests.end(); it != it_end;)
{
IdentifyRequest *ir = *it;
++it;
ir->Release(m);
if (ir->owner == m)
delete ir;
}
}
|