]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_permchannels.cpp
Merge tag 'v2.0.25' into master.
[user/henk/code/inspircd.git] / src / modules / m_permchannels.cpp
index d23af04bcc53b22a56d6f8fe4646a94ffda4fccd..0f2a2ef6f3506c069fa6d0175bd462474e2ed2c0 100644 (file)
@@ -66,8 +66,8 @@ static bool WriteDatabase(PermChannel& permchanmode, Module* mod, bool save_list
        std::ofstream stream(permchannelsnewconf.c_str());
        if (!stream.is_open())
        {
-               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Cannot create database! %s (%d)", strerror(errno), errno);
-               ServerInstance->SNO->WriteToSnoMask('a', "database: cannot create new db: %s (%d)", strerror(errno), errno);
+               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Cannot create database \"%s\"! %s (%d)", permchannelsnewconf.c_str(), strerror(errno), errno);
+               ServerInstance->SNO->WriteToSnoMask('a', "database: cannot create new permchan db \"%s\": %s (%d)", permchannelsnewconf.c_str(), strerror(errno), errno);
                return false;
        }
 
@@ -137,25 +137,20 @@ static bool WriteDatabase(PermChannel& permchanmode, Module* mod, bool save_list
 
        if (stream.fail())
        {
-               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Cannot write to new database! %s (%d)", strerror(errno), errno);
-               ServerInstance->SNO->WriteToSnoMask('a', "database: cannot write to new db: %s (%d)", strerror(errno), errno);
+               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Cannot write to new database \"%s\"! %s (%d)", permchannelsnewconf.c_str(), strerror(errno), errno);
+               ServerInstance->SNO->WriteToSnoMask('a', "database: cannot write to new permchan db \"%s\": %s (%d)", permchannelsnewconf.c_str(), strerror(errno), errno);
                return false;
        }
        stream.close();
 
 #ifdef _WIN32
-       if (remove(permchannelsconf.c_str()))
-       {
-               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Cannot remove old database! %s (%d)", strerror(errno), errno);
-               ServerInstance->SNO->WriteToSnoMask('a', "database: cannot remove old database: %s (%d)", strerror(errno), errno);
-               return false;
-       }
+       remove(permchannelsconf.c_str());
 #endif
        // Use rename to move temporary to new db - this is guarenteed not to fuck up, even in case of a crash.
        if (rename(permchannelsnewconf.c_str(), permchannelsconf.c_str()) < 0)
        {
-               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Cannot move new to old database! %s (%d)", strerror(errno), errno);
-               ServerInstance->SNO->WriteToSnoMask('a', "database: cannot replace old with new db: %s (%d)", strerror(errno), errno);
+               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Cannot replace old database \"%s\" with new database \"%s\"! %s (%d)", permchannelsconf.c_str(), permchannelsnewconf.c_str(), strerror(errno), errno);
+               ServerInstance->SNO->WriteToSnoMask('a', "database: cannot replace old permchan db \"%s\" with new db \"%s\": %s (%d)", permchannelsconf.c_str(), permchannelsnewconf.c_str(), strerror(errno), errno);
                return false;
        }
 
@@ -212,16 +207,16 @@ public:
                                c = new Channel(channel, TS);
 
                                unsigned int topicset = tag->getInt("topicts");
-                               c->topic = tag->getString("topic");
+                               std::string topic = tag->getString("topic");
 
-                               if ((topicset != 0) || (!c->topic.empty()))
+                               if ((topicset != 0) || (!topic.empty()))
                                {
                                        if (topicset == 0)
                                                topicset = ServerInstance->Time();
-                                       c->topicset = topicset;
-                                       c->setby = tag->getString("topicsetby");
-                                       if (c->setby.empty())
-                                               c->setby = ServerInstance->Config->ServerName;
+                                       std::string topicsetby = tag->getString("topicsetby");
+                                       if (topicsetby.empty())
+                                               topicsetby = ServerInstance->Config->ServerName;
+                                       c->SetTopic(ServerInstance->FakeClient, topic, topicset, &topicsetby);
                                }
 
                                ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Added %s with topic %s", channel.c_str(), c->topic.c_str());
@@ -241,7 +236,7 @@ public:
                                        ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL);
                                        if (mode)
                                        {
-                                               if (mode->GetNumParams(true))
+                                               if (mode->NeedsParam(true))
                                                        list.GetToken(par);
                                                else
                                                        par.clear();
@@ -249,6 +244,10 @@ public:
                                                mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, c, par, true);
                                        }
                                }
+
+                               // We always apply the permchannels mode to permanent channels.
+                               par.clear();
+                               p.OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, c, par, true);
                        }
                }
        }
@@ -274,7 +273,7 @@ public:
                dirty = false;
        }
 
-       void Prioritize()
+       void Prioritize() CXX11_OVERRIDE
        {
                // XXX: Load the DB here because the order in which modules are init()ed at boot is
                // alphabetical, this means we must wait until all modules have done their init()