summaryrefslogtreecommitdiffstats
path: root/src/crsm.cpp
diff options
context:
space:
mode:
authorMarkus Mittendrein <git@maxmitti.tk>2015-10-29 14:28:31 +0100
committerMarkus Mittendrein <git@maxmitti.tk>2015-10-29 14:32:16 +0100
commita51169e13f3136700c78771179f3956ba91f8194 (patch)
treeba15decc84ee608b177ba7f462ca4dcf8428bd71 /src/crsm.cpp
parentff28afc7cf330216e9b5bf8d489f0eb0be8004bf (diff)
downloadmanager-a51169e13f3136700c78771179f3956ba91f8194.tar.gz
manager-a51169e13f3136700c78771179f3956ba91f8194.zip
Connect to/disconnect from IRC in applyConfig instead of CRSM-
constructor
Diffstat (limited to 'src/crsm.cpp')
-rw-r--r--src/crsm.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/crsm.cpp b/src/crsm.cpp
index 73828b6..9bc2a19 100644
--- a/src/crsm.cpp
+++ b/src/crsm.cpp
@@ -77,15 +77,6 @@ CRSM::CRSM(QObject *parent) :
reallog->open(QIODevice::Append | QIODevice::Text);
logstream.setDevice(reallog);
- if(Config.IRC.Use)
- {
- prepareAndConnectIrc();
- }
- else
- {
- Config.IRC.UseIngameChat = false;
- }
-
ok = true;
}
@@ -489,9 +480,14 @@ void CRSM::ircMessageReceived(IrcMessage *message)
void CRSM::ircDisconnected()
{
- if(!finish)
+ if(connection != nullptr)
+ {
+ delete connection;
+ }
+ connection = nullptr;
+ if(!finish && Config.IRC.Use)
{
- reconnectIrc();
+ QTimer::singleShot(Config.IRC.ReconnectDelay * 1000, this, SLOT(reconnectIrc()));
}
}
@@ -1551,8 +1547,11 @@ void CRSM::prepareAndConnectIrc()
void CRSM::reconnectIrc()
{
- connection->close();
- delete connection;
+ if(connection != nullptr)
+ {
+ connection->close();
+ delete connection;
+ }
prepareAndConnectIrc();
}
@@ -1629,6 +1628,23 @@ void CRSM::applyConfig()
ok = false;
exit();
}
+
+ if(Config.IRC.Use)
+ {
+ if(connection == nullptr)
+ {
+ prepareAndConnectIrc();
+ }
+ }
+ else
+ {
+ Config.IRC.UseIngameChat = false;
+ if(connection != nullptr)
+ {
+ connection->quit(Config.IRC.QuitMessage);
+ }
+ }
+
setupCmds();
out(Stats.read(Config.CRSM.StatsFile));
out(Packs.read(Config.CRSM.PacksFile, Config.Auto.Volatile.Clonk.Directory));