summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-10-07 22:39:58 -0400
committerAdam <Adam@anope.org>2012-10-07 22:39:58 -0400
commitb8b63ff115f0daddf479b0da507a2f731255a06d (patch)
treed6b82bf0dfc39fdfe6a6a23ba318bb0c2906d6c1 /src
parent0a111c19764ed14ab5f724c78d9dd8c08a3c124f (diff)
Remove the asynchronous identifing hack and replace it with something better. Fixes m_*_authentication only being able to properly work when people identify normally using nickserv/identify
Diffstat (limited to 'src')
-rw-r--r--src/module.cpp1
-rw-r--r--src/nickserv.cpp59
2 files changed, 60 insertions, 0 deletions
diff --git a/src/module.cpp b/src/module.cpp
index 2f70cb96b..e69b7c6a3 100644
--- a/src/module.cpp
+++ b/src/module.cpp
@@ -52,6 +52,7 @@ Module::~Module()
ModuleManager::DetachAll(this);
/* Clear any active callbacks this module has */
ModuleManager::ClearCallBacks(this);
+ IdentifyRequest::ModuleUnload(this);
std::list<Module *>::iterator it = std::find(Modules.begin(), Modules.end(), this);
if (it != Modules.end())
diff --git a/src/nickserv.cpp b/src/nickserv.cpp
index 65126b987..53939c6d3 100644
--- a/src/nickserv.cpp
+++ b/src/nickserv.cpp
@@ -93,3 +93,62 @@ void change_core_display(NickCore *nc)
change_core_display(nc, na->nick);
}
+std::set<IdentifyRequest *> IdentifyRequest::requests;
+
+IdentifyRequest::IdentifyRequest(const Anope::string &acc, const Anope::string &pass) : 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);
+ }
+}