summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-05-04 16:03:02 -0400
committerAdam <Adam@anope.org>2012-05-04 16:03:02 -0400
commiteb0e07d5645c06eb034cfcfbf91883158ba9dc00 (patch)
tree044178ba86fef5fc176bdc55261eb1133e15a34e
parent1b5805eeb08d80f9163a732fa367f9a077f19112 (diff)
Use Unreal's MLOCK command if supported
-rw-r--r--modules/protocol/unreal.cpp42
1 files changed, 39 insertions, 3 deletions
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index 2ec4a3b2c..0fdb0d1e0 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -243,13 +243,14 @@ class UnrealIRCdProto : public IRCDProto
TKLEXT = Extended TKL we don't use it but best to have it
SJB64 = Base64 encoded time stamps
ESVID = Allows storing account names as services stamp
+ MLOCK = Supports the MLOCK server command
VL = Version Info
NS = Config->Numeric Server
*/
if (!Config->Numeric.empty())
- UplinkSocket::Message() << "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT ESVID VL";
+ UplinkSocket::Message() << "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT ESVID MLOCK VL";
else
- UplinkSocket::Message() << "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT ESVID";
+ UplinkSocket::Message() << "PROTOCTL NICKv2 VHP UMODE2 NICKIP TOKEN SJOIN SJOIN2 SJ3 NOQUIT TKLEXT ESVID MLOCK";
UplinkSocket::Message() << "PASS :" << Config->Uplinks[CurrentUplink]->password;
SendServer(Me);
}
@@ -1211,7 +1212,9 @@ class ProtoUnreal : public Module
this->AddModes();
- ModuleManager::Attach(I_OnUserNickChange, this);
+ Implementation i[] = { I_OnUserNickChange, I_OnChannelCreate, I_OnMLock, I_OnUnMLock };
+ ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
+ ModuleManager::SetPriority(this, PRIORITY_FIRST);
}
~ProtoUnreal()
@@ -1226,6 +1229,39 @@ class ProtoUnreal : public Module
{
u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED));
}
+
+ void OnChannelCreate(Channel *c) anope_override
+ {
+ if (Capab.count("MLOCK") > 0 && c->ci)
+ {
+ Anope::string modes = c->ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
+ UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(c->creation_time) << " " << c->ci->name << " " << modes;
+ }
+ }
+
+ EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
+ {
+ ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
+ if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Capab.count("MLOCK") > 0)
+ {
+ Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->ModeChar;
+ UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
+ }
+
+ return EVENT_CONTINUE;
+ }
+
+ EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
+ {
+ ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
+ if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Capab.count("MLOCK") > 0)
+ {
+ Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->ModeChar, "");
+ UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
+ }
+
+ return EVENT_CONTINUE;
+ }
};
MODULE_INIT(ProtoUnreal)