]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_reloadmodule.cpp
Fix a bunch of weird indentation and spacing issues.
[user/henk/code/inspircd.git] / src / coremods / core_reloadmodule.cpp
index ea5d40abdc72d8c6841c06f90db9af98cd71b597..ce1f636677694ef7b48edddc7dc0e41dc8c93cb8 100644 (file)
@@ -1,9 +1,12 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2015 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2017-2019, 2021 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2014-2016, 2018 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2007, 2010 Craig Edwards <brain@inspircd.org>
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -28,10 +31,10 @@ static ClientProtocol::Serializer* dummyserializer;
 
 class DummySerializer : public ClientProtocol::Serializer
 {
-       bool Parse(LocalUser* user, const std::string& line, ClientProtocol::ParseOutput& parseoutput) CXX11_OVERRIDE
-       {
-               return false;
-       }
+       bool Parse(LocalUser* user, const std::string& line, ClientProtocol::ParseOutput& parseoutput) CXX11_OVERRIDE
+       {
+               return false;
+       }
 
        ClientProtocol::SerializedMessage Serialize(const ClientProtocol::Message& msg, const ClientProtocol::TagSelection& tagwl) const CXX11_OVERRIDE
        {
@@ -281,7 +284,7 @@ class DataKeeper
 
        /** Restore all modes and extensions of all members on a channel
         * @param chan Channel whose members are being restored
-        * @param memberdata Data to restore
+        * @param memberdatalist Data to restore
         * @param modechange Mode change to populate with prefix modes
         */
        void RestoreMemberData(Channel* chan, const std::vector<ChanData::MemberData>& memberdatalist, Modes::ChangeList& modechange);
@@ -379,7 +382,7 @@ void DataKeeper::SaveExtensions(Extensible* extensible, std::vector<InstanceData
                if (it == setexts.end())
                        continue;
 
-               std::string value = item->serialize(FORMAT_INTERNAL, extensible, it->second);
+               std::string value = item->ToInternal(extensible, it->second);
                // If the serialized value is empty the extension won't be saved and restored
                if (!value.empty())
                        extdata.push_back(InstanceData(index, value));
@@ -597,7 +600,7 @@ void DataKeeper::RestoreExtensions(const std::vector<InstanceData>& list, Extens
        for (std::vector<InstanceData>::const_iterator i = list.begin(); i != list.end(); ++i)
        {
                const InstanceData& id = *i;
-               handledexts[id.index].extitem->unserialize(FORMAT_INTERNAL, extensible, id.serialized);
+               handledexts[id.index].extitem->FromInternal(extensible, id.serialized);
        }
 }
 
@@ -717,25 +720,31 @@ class ReloadAction : public ActionBase
                ReloadModule::DataKeeper datakeeper;
                datakeeper.Save(mod);
 
-               DLLManager* dll = mod->ModuleDLLManager;
                std::string name = mod->ModuleSourceFile;
                ServerInstance->Modules->DoSafeUnload(mod);
                ServerInstance->GlobalCulls.Apply();
-               delete dll;
                bool result = ServerInstance->Modules->Load(name);
 
                if (result)
                {
                        Module* newmod = ServerInstance->Modules->Find(name);
                        datakeeper.Restore(newmod);
+                       ServerInstance->SNO->WriteGlobalSno('a', "The %s module was reloaded.", passedname.c_str());
                }
                else
+               {
                        datakeeper.Fail();
+                       ServerInstance->SNO->WriteGlobalSno('a', "Failed to reload the %s module.", passedname.c_str());
+               }
 
-               ServerInstance->SNO->WriteGlobalSno('a', "RELOAD MODULE: %s %ssuccessfully reloaded", passedname.c_str(), result ? "" : "un");
                User* user = ServerInstance->FindUUID(uuid);
                if (user)
-                       user->WriteNumeric(RPL_LOADEDMODULE, passedname, InspIRCd::Format("Module %ssuccessfully reloaded.", (result ? "" : "un")));
+               {
+                       if (result)
+                               user->WriteNumeric(RPL_LOADEDMODULE, passedname, InspIRCd::Format("The %s module was reloaded.", passedname.c_str()));
+                       else
+                               user->WriteNumeric(ERR_CANTUNLOADMODULE, passedname, InspIRCd::Format("Failed to reload the %s module.", passedname.c_str()));
+               }
 
                ServerInstance->GlobalCulls.AddItem(this);
        }
@@ -746,7 +755,7 @@ CmdResult CommandReloadmodule::Handle(User* user, const Params& parameters)
        Module* m = ServerInstance->Modules->Find(parameters[0]);
        if (m == creator)
        {
-               user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "You cannot reload core_reloadmodule (unload and load it)");
+               user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], "You cannot reload core_reloadmodule (unload and load it)");
                return CMD_FAILURE;
        }
 
@@ -760,7 +769,7 @@ CmdResult CommandReloadmodule::Handle(User* user, const Params& parameters)
        }
        else
        {
-               user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "Could not find module by that name");
+               user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], "Could not find a loaded module by that name");
                return CMD_FAILURE;
        }
 }