blob: dc5d68d2842bab2228bb4199a9875859d0b98569 (
plain)
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
|
/*
*
* (C) 2003-2023 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"
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->holds.erase(m);
if (ir->holds.empty() && ir->dispatched)
{
if (!ir->success)
ir->OnFail();
delete ir;
continue;
}
if (ir->owner == m)
{
if (!ir->success)
ir->OnFail();
delete ir;
}
}
}
|