Seperate ModeReference into ChanModeReference and UserModeReference

This commit is contained in:
attilamolnar 2013-07-15 00:20:28 +02:00
parent ac55270a08
commit 5288eb1594
7 changed files with 20 additions and 11 deletions

View File

@ -84,10 +84,16 @@ class dynamic_reference_nocheck : public dynamic_reference_base
};
class ModeHandler;
class ModeReference : public dynamic_reference_nocheck<ModeHandler>
class ChanModeReference : public dynamic_reference_nocheck<ModeHandler>
{
public:
ModeReference(Module* mod, const std::string& modename)
ChanModeReference(Module* mod, const std::string& modename)
: dynamic_reference_nocheck<ModeHandler>(mod, "mode/" + modename) {}
};
class UserModeReference : public dynamic_reference_nocheck<ModeHandler>
{
public:
UserModeReference(Module* mod, const std::string& modename)
: dynamic_reference_nocheck<ModeHandler>(mod, "umode/" + modename) {}
};

View File

@ -28,7 +28,7 @@
#include <cstdarg>
#include "mode.h"
static ModeReference ban(NULL, "ban");
static ChanModeReference ban(NULL, "ban");
Channel::Channel(const std::string &cname, time_t ts)
{

View File

@ -825,7 +825,7 @@ void ConfigReaderThread::Finish()
*/
ServerInstance->XLines->CheckELines();
ServerInstance->XLines->ApplyLines();
ModeReference ban(NULL, "ban");
ChanModeReference ban(NULL, "ban");
static_cast<ListModeBase*>(*ban)->DoRehash();
Config->ApplyDisabledCommands(Config->DisabledCommands);
User* user = ServerInstance->FindNick(TheUserUID);

View File

@ -415,11 +415,14 @@ void ModuleManager::AddService(ServiceProvider& item)
throw ModuleException("Command "+std::string(item.name)+" already exists.");
return;
case SERVICE_MODE:
if (!ServerInstance->Modes->AddMode(static_cast<ModeHandler*>(&item)))
{
ModeHandler* mh = static_cast<ModeHandler*>(&item);
if (!ServerInstance->Modes->AddMode(mh))
throw ModuleException("Mode "+std::string(item.name)+" already exists.");
DataProviders.insert(std::make_pair("mode/" + item.name, &item));
DataProviders.insert(std::make_pair((mh->GetModeType() == MODETYPE_CHANNEL ? "mode/" : "umode/") + item.name, &item));
dynamic_reference_base::reset_all();
return;
}
case SERVICE_METADATA:
if (!ServerInstance->Extensions.Register(static_cast<ExtensionItem*>(&item)))
throw ModuleException("Extension " + std::string(item.name) + " already exists.");
@ -427,8 +430,8 @@ void ModuleManager::AddService(ServiceProvider& item)
case SERVICE_DATA:
case SERVICE_IOHOOK:
{
if (item.name.substr(0, 5) == "mode/")
throw ModuleException("The \"mode/\" service name prefix is reserved.");
if ((item.name.substr(0, 5) == "mode/") || (item.name.substr(0, 6) == "umode/"))
throw ModuleException("The \"mode/\" and the \"umode\" service name prefixes are reserved.");
DataProviders.insert(std::make_pair(item.name, &item));
std::string::size_type slash = item.name.find('/');

View File

@ -44,7 +44,7 @@ typedef std::vector<BanRedirectEntry> BanRedirectList;
class BanRedirect : public ModeWatcher
{
ModeReference ban;
ChanModeReference ban;
public:
SimpleExtItem<BanRedirectList> extItem;
BanRedirect(Module* parent)

View File

@ -27,7 +27,7 @@
*/
class CommandCheck : public Command
{
ModeReference ban;
ChanModeReference ban;
public:
CommandCheck(Module* parent)
: Command(parent,"CHECK", 1)

View File

@ -108,7 +108,7 @@ void TreeSocket::SendFJoins(Channel* c)
}
this->WriteLine(line);
ModeReference ban(NULL, "ban");
ChanModeReference ban(NULL, "ban");
static_cast<ListModeBase*>(*ban)->DoSyncChannel(c, Utils->Creator, this);
}