anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
account.cpp (1575B)
1 /* 2 * 3 * (C) 2003-2022 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 #include "services.h" 13 #include "account.h" 14 #include "modules.h" 15 #include "users.h" 16 #include "protocol.h" 17 #include "regchannel.h" 18 19 std::set<IdentifyRequest *> IdentifyRequest::Requests; 20 21 IdentifyRequest::IdentifyRequest(Module *o, const Anope::string &acc, const Anope::string &pass) : owner(o), account(acc), password(pass), dispatched(false), success(false) 22 { 23 Requests.insert(this); 24 } 25 26 IdentifyRequest::~IdentifyRequest() 27 { 28 Requests.erase(this); 29 } 30 31 void IdentifyRequest::Hold(Module *m) 32 { 33 holds.insert(m); 34 } 35 36 void IdentifyRequest::Release(Module *m) 37 { 38 holds.erase(m); 39 if (holds.empty() && dispatched) 40 { 41 if (!success) 42 this->OnFail(); 43 delete this; 44 } 45 } 46 47 void IdentifyRequest::Success(Module *m) 48 { 49 if (!success) 50 { 51 this->OnSuccess(); 52 success = true; 53 } 54 } 55 56 void IdentifyRequest::Dispatch() 57 { 58 if (holds.empty()) 59 { 60 if (!success) 61 this->OnFail(); 62 delete this; 63 } 64 else 65 dispatched = true; 66 } 67 68 void IdentifyRequest::ModuleUnload(Module *m) 69 { 70 for (std::set<IdentifyRequest *>::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end;) 71 { 72 IdentifyRequest *ir = *it; 73 ++it; 74 75 ir->holds.erase(m); 76 if (ir->holds.empty() && ir->dispatched) 77 { 78 if (!ir->success) 79 ir->OnFail(); 80 delete ir; 81 continue; 82 } 83 84 if (ir->owner == m) 85 { 86 if (!ir->success) 87 ir->OnFail(); 88 delete ir; 89 } 90 } 91 }