Anope IRC Services  Version 2.0
account.cpp
Go to the documentation of this file.
1 /*
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  */
12 
13 #include "services.h"
14 #include "account.h"
15 #include "modules.h"
16 #include "users.h"
17 #include "protocol.h"
18 #include "regchannel.h"
19 
20 std::set<IdentifyRequest *> IdentifyRequest::Requests;
21 
22 IdentifyRequest::IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass) : owner(o), account(acc), password(pass), dispatched(false), success(false)
23 {
24  Requests.insert(this);
25 }
26 
28 {
29  Requests.erase(this);
30 }
31 
33 {
34  holds.insert(m);
35 }
36 
38 {
39  holds.erase(m);
40  if (holds.empty() && dispatched)
41  {
42  if (!success)
43  this->OnFail();
44  delete this;
45  }
46 }
47 
49 {
50  if (!success)
51  {
52  this->OnSuccess();
53  success = true;
54  }
55 }
56 
58 {
59  if (holds.empty())
60  {
61  if (!success)
62  this->OnFail();
63  delete this;
64  }
65  else
66  dispatched = true;
67 }
68 
70 {
71  for (std::set<IdentifyRequest *>::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end;)
72  {
73  IdentifyRequest *ir = *it;
74  ++it;
75 
76  ir->Release(m);
77  if (ir->owner == m)
78  delete ir;
79  }
80 }
void Release(Module *m)
Definition: account.cpp:37
virtual ~IdentifyRequest()
Definition: account.cpp:27
void Hold(Module *m)
Definition: account.cpp:32
IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass)
Definition: account.cpp:22
virtual void OnSuccess()=0
void Dispatch()
Definition: account.cpp:57
std::set< Module * > holds
Definition: account.h:235
static void ModuleUnload(Module *m)
Definition: account.cpp:69
void Success(Module *m)
Definition: account.cpp:48
virtual void OnFail()=0
bool dispatched
Definition: account.h:236
Module * owner
Definition: account.h:231
static std::set< IdentifyRequest * > Requests
Definition: account.h:239