diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-11-15 18:26:53 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-11-15 18:26:53 +0000 |
commit | fb3964d5c007900061e86e392ceb786bd47260c0 (patch) | |
tree | 41ff940cce47b6d8ba9aef701205dd0ea6707c6f /src | |
parent | 8ab1381e8d277152d99a72f33f3d1c0564060fee (diff) |
Add Inspircd::AddServices
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12135 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/base.cpp | 10 | ||||
-rw-r--r-- | src/command_parse.cpp | 8 | ||||
-rw-r--r-- | src/commands/cmd_commands.cpp | 2 | ||||
-rw-r--r-- | src/commands/cmd_server.cpp | 2 | ||||
-rw-r--r-- | src/commands/cmd_who.cpp | 2 | ||||
-rw-r--r-- | src/commands/cmd_whowas.cpp | 2 | ||||
-rw-r--r-- | src/inspstring.cpp | 2 | ||||
-rw-r--r-- | src/mode.cpp | 5 | ||||
-rw-r--r-- | src/modules.cpp | 25 | ||||
-rw-r--r-- | src/modules/m_check.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_customtitle.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_httpd_stats.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_sasl.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 4 | ||||
-rw-r--r-- | src/stats.cpp | 2 |
16 files changed, 57 insertions, 30 deletions
diff --git a/src/base.cpp b/src/base.cpp index 8e81f7b73..3ff3d5281 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -77,7 +77,11 @@ usecountbase::~usecountbase() (void*)this, usecount); } -ExtensionItem::ExtensionItem(const std::string& Key, Module* mod) : key(Key), owner(mod) +providerbase::~providerbase() +{ +} + +ExtensionItem::ExtensionItem(const std::string& Key, Module* mod) : providerbase(mod, Key, SERVICE_METADATA) { } @@ -122,7 +126,7 @@ void* ExtensionItem::unset_raw(Extensible* container) void ExtensionManager::Register(ExtensionItem* item) { - types.insert(std::make_pair(item->key, item)); + types.insert(std::make_pair(item->name, item)); } void ExtensionManager::BeginUnregister(Module* module, std::vector<reference<ExtensionItem> >& list) @@ -132,7 +136,7 @@ void ExtensionManager::BeginUnregister(Module* module, std::vector<reference<Ext { std::map<std::string, reference<ExtensionItem> >::iterator me = i++; ExtensionItem* item = me->second; - if (item->owner == module) + if (item->creator == module) { list.push_back(item); types.erase(me); diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 86f801d3e..d7a4eede7 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -366,7 +366,7 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd) { user->WriteNumeric(ERR_NEEDMOREPARAMS, "%s %s :Not enough parameters.", user->nick.c_str(), command.c_str()); if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (cm->second->syntax.length())) - user->WriteNumeric(RPL_SYNTAX, "%s :SYNTAX %s %s", user->nick.c_str(), cm->second->command.c_str(), cm->second->syntax.c_str()); + user->WriteNumeric(RPL_SYNTAX, "%s :SYNTAX %s %s", user->nick.c_str(), cm->second->name.c_str(), cm->second->syntax.c_str()); return do_more; } if ((user->registered != REG_ALL) && (!cm->second->WorksBeforeReg())) @@ -397,7 +397,7 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd) void CommandParser::RemoveCommand(Command* x) { - Commandtable::iterator n = cmdlist.find(x->command); + Commandtable::iterator n = cmdlist.find(x->name); if (n != cmdlist.end() && n->second == x) cmdlist.erase(n); } @@ -420,9 +420,9 @@ bool CommandParser::ProcessBuffer(std::string &buffer,User *user) bool CommandParser::AddCommand(Command *f) { /* create the command and push it onto the table */ - if (cmdlist.find(f->command) == cmdlist.end()) + if (cmdlist.find(f->name) == cmdlist.end()) { - cmdlist[f->command] = f; + cmdlist[f->name] = f; return true; } return false; diff --git a/src/commands/cmd_commands.cpp b/src/commands/cmd_commands.cpp index 63b4b24fb..cc662f3b6 100644 --- a/src/commands/cmd_commands.cpp +++ b/src/commands/cmd_commands.cpp @@ -53,7 +53,7 @@ CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user) Module* src = i->second->creator; user->WriteNumeric(RPL_COMMANDS, "%s :%s %s %d %d", user->nick.c_str(), - i->second->command.c_str(), + i->second->name.c_str(), src ? src->ModuleSourceFile.c_str() : "<core>", i->second->min_params, i->second->Penalty); diff --git a/src/commands/cmd_server.cpp b/src/commands/cmd_server.cpp index e5a7622b8..c6e7d9888 100644 --- a/src/commands/cmd_server.cpp +++ b/src/commands/cmd_server.cpp @@ -41,7 +41,7 @@ CmdResult CommandServer::Handle (const std::vector<std::string>&, User *user) } else { - user->WriteNumeric(ERR_NOTREGISTERED, "%s :You may not register as a server (servers have seperate ports from clients, change your config)",command.c_str()); + user->WriteNumeric(ERR_NOTREGISTERED, "%s :You may not register as a server (servers have seperate ports from clients, change your config)",name.c_str()); } return CMD_FAILURE; } diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index da797201b..b5ace291b 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -109,7 +109,7 @@ bool CommandWho::whomatch(User* cuser, User* user, const char* matchtext) match = false; const Extensible::ExtensibleStore& list = user->GetExtList(); for(Extensible::ExtensibleStore::const_iterator i = list.begin(); i != list.end(); ++i) - if (InspIRCd::Match(i->first->key, matchtext)) + if (InspIRCd::Match(i->first->name, matchtext)) match = true; } else if (opt_realname) diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp index 34e7e74e0..21c30d742 100644 --- a/src/commands/cmd_whowas.cpp +++ b/src/commands/cmd_whowas.cpp @@ -29,7 +29,7 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use /* if whowas disabled in config */ if (ServerInstance->Config->WhoWasGroupSize == 0 || ServerInstance->Config->WhoWasMaxGroups == 0) { - user->WriteNumeric(421, "%s %s :This command has been disabled.",user->nick.c_str(),command.c_str()); + user->WriteNumeric(421, "%s %s :This command has been disabled.",user->nick.c_str(),name.c_str()); return CMD_FAILURE; } diff --git a/src/inspstring.cpp b/src/inspstring.cpp index ff9c1875f..4f4cbd8ad 100644 --- a/src/inspstring.cpp +++ b/src/inspstring.cpp @@ -13,7 +13,7 @@ /* $Core */ -#include "inspstring.h" +#include "inspircd.h" /* * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> diff --git a/src/mode.cpp b/src/mode.cpp index e9635364e..441ca520d 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -46,8 +46,9 @@ #include "modes/umode_s.h" ModeHandler::ModeHandler(Module* Creator, const std::string& Name, char modeletter, ParamSpec Params, ModeType type) - : m_paramtype(TR_TEXT), parameters_taken(Params), mode(modeletter), prefix(0), oper(false), - list(false), m_type(type), count(0), levelrequired(HALFOP_VALUE), creator(Creator), name(Name) + : providerbase(Creator, Name, type == MODETYPE_CHANNEL ? SERVICE_CMODE : SERVICE_UMODE), m_paramtype(TR_TEXT), + parameters_taken(Params), mode(modeletter), prefix(0), oper(false), + list(false), m_type(type), count(0), levelrequired(HALFOP_VALUE) { } diff --git a/src/modules.cpp b/src/modules.cpp index a2c4aa6ea..d86dc6270 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -469,7 +469,30 @@ void InspIRCd::AddCommand(Command *f) { if (!this->Parser->AddCommand(f)) { - throw ModuleException("Command "+std::string(f->command)+" already exists."); + throw ModuleException("Command "+std::string(f->name)+" already exists."); + } +} + +void InspIRCd::AddService(providerbase& item) +{ + switch (item.service) + { + case SERVICE_COMMAND: + if (!Parser->AddCommand(static_cast<Command*>(&item))) + throw ModuleException("Command "+std::string(item.name)+" already exists."); + return; + case SERVICE_CMODE: + case SERVICE_UMODE: + if (!Modes->AddMode(static_cast<ModeHandler*>(&item))) + throw ModuleException("Mode "+std::string(item.name)+" already exists."); + return; + case SERVICE_METADATA: + Extensions.Register(static_cast<ExtensionItem*>(&item)); + return; + case SERVICE_DATA: + case SERVICE_IOHOOK: + default: + throw ModuleException("Cannot add unknown service type"); } } diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 0a0ecab2b..a907b06e8 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -41,9 +41,9 @@ class CommandCheck : public Command ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_USER, ext, i->second); if (!value.empty()) - user->SendText(checkstr + " meta:" + item->key + " " + value); - else if (!item->key.empty()) - dumpkeys << " " << item->key; + user->SendText(checkstr + " meta:" + item->name + " " + value); + else if (!item->name.empty()) + dumpkeys << " " << item->name; } if (!dumpkeys.str().empty()) user->SendText(checkstr + " metadata", dumpkeys); diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp index c89535a3c..8814e8cf6 100644 --- a/src/modules/m_customtitle.cpp +++ b/src/modules/m_customtitle.cpp @@ -53,14 +53,14 @@ class CommandTitle : public Command ConfigReader Conf; for (int i=0; i<Conf.Enumerate("title"); i++) { - std::string name = Conf.ReadValue("title", "name", "", i); + std::string Name = Conf.ReadValue("title", "name", "", i); std::string pass = Conf.ReadValue("title", "password", "", i); std::string hash = Conf.ReadValue("title", "hash", "", i); std::string host = Conf.ReadValue("title", "host", "*@*", i); std::string title = Conf.ReadValue("title", "title", "", i); std::string vhost = Conf.ReadValue("title", "vhost", "", i); - if (!strcmp(name.c_str(),parameters[0].c_str()) && !ServerInstance->PassCompare(user, pass.c_str(), parameters[1].c_str(), hash.c_str()) && OneOfMatches(TheHost,TheIP,host.c_str()) && !title.empty()) + if (!strcmp(Name.c_str(),parameters[0].c_str()) && !ServerInstance->PassCompare(user, pass.c_str(), parameters[1].c_str(), hash.c_str()) && OneOfMatches(TheHost,TheIP,host.c_str()) && !title.empty()) { ctitle.set(user, title); diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 36deda11b..e34c4b43f 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -75,9 +75,9 @@ class ModuleHttpStats : public Module ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_USER, ext, i->second); if (!value.empty()) - data << "<meta name=\"" << item->key << "\">" << Sanitize(value) << "</meta>"; - else if (!item->key.empty()) - data << "<meta name=\"" << item->key << "\"/>"; + data << "<meta name=\"" << item->name << "\">" << Sanitize(value) << "</meta>"; + else if (!item->name.empty()) + data << "<meta name=\"" << item->name << "\"/>"; } data << "</metadata>"; } diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index add530ff1..298544edc 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -229,10 +229,9 @@ class ModuleSASL : public Module Implementation eventlist[] = { I_OnEvent, I_OnUserRegister }; ServerInstance->Modules->Attach(eventlist, this, 2); - ServerInstance->AddCommand(&auth); - ServerInstance->AddCommand(&sasl); + providerbase* providelist[] = { &auth, &sasl, &authExt }; + ServerInstance->AddServices(providelist, 3); - ServerInstance->Extensions.Register(&authExt); if (!ServerInstance->Modules->Find("m_services_account.so") || !ServerInstance->Modules->Find("m_cap.so")) ServerInstance->Logs->Log("m_sasl", DEFAULT, "WARNING: m_services_account.so and m_cap.so are not loaded! m_sasl.so will NOT function correctly until these two modules are loaded!"); } diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 386c95dfc..fe2cfe9b6 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -615,7 +615,7 @@ void ModuleSpanningTree::OnUserConnect(LocalUser* user) ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_NETWORK, user, i->second); if (!value.empty()) - ServerInstance->PI->SendMetaData(user, item->key, value); + ServerInstance->PI->SendMetaData(user, item->name, value); } Utils->TreeRoot->SetUserCount(1); // increment by 1 diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 52ce5897d..61a5f66d2 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -225,7 +225,7 @@ void TreeSocket::SendChannelModes(TreeServer* Current) ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_NETWORK, c->second, i->second); if (!value.empty()) - Utils->Creator->ProtoSendMetaData(this, c->second, item->key, value); + Utils->Creator->ProtoSendMetaData(this, c->second, item->name, value); } FOREACH_MOD(I_OnSyncChannel,OnSyncChannel(c->second,Utils->Creator,this)); @@ -274,7 +274,7 @@ void TreeSocket::SendUsers(TreeServer* Current) ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_NETWORK, u->second, i->second); if (!value.empty()) - Utils->Creator->ProtoSendMetaData(this, u->second, item->key, value); + Utils->Creator->ProtoSendMetaData(this, u->second, item->name, value); } FOREACH_MOD(I_OnSyncUser,OnSyncUser(u->second,Utils->Creator,this)); diff --git a/src/stats.cpp b/src/stats.cpp index e8173e655..01d8b9611 100644 --- a/src/stats.cpp +++ b/src/stats.cpp @@ -142,7 +142,7 @@ void InspIRCd::DoStats(char statschar, User* user, string_list &results) if (i->second->use_count) { /* RPL_STATSCOMMANDS */ - results.push_back(sn+" 212 "+user->nick+" "+i->second->command+" "+ConvToStr(i->second->use_count)+" "+ConvToStr(i->second->total_bytes)); + results.push_back(sn+" 212 "+user->nick+" "+i->second->name+" "+ConvToStr(i->second->use_count)+" "+ConvToStr(i->second->total_bytes)); } } break; |