From eb0e07d5645c06eb034cfcfbf91883158ba9dc00 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 4 May 2012 16:03:02 -0400 Subject: Use Unreal's MLOCK command if supported --- modules/protocol/unreal.cpp | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'modules/protocol/unreal.cpp') 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(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(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(ci->c->creation_time) << " " << ci->name << " " << modes; + } + + return EVENT_CONTINUE; + } }; MODULE_INIT(ProtoUnreal) -- cgit