diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2015-10-30 15:24:53 +0100 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2015-10-31 01:52:09 +0100 |
| commit | 9cbc1db9c20aba934c2184cb3496aec854e19dbc (patch) | |
| tree | 29ea54e27fcf81e9be86b6dd29efd0c0687df9d7 /src/crsm.cpp | |
| parent | 00a8804ab8cc0bfd7b67a3c947f5d0de0eb958dc (diff) | |
| download | manager-9cbc1db9c20aba934c2184cb3496aec854e19dbc.tar.gz manager-9cbc1db9c20aba934c2184cb3496aec854e19dbc.zip | |
Use communi's automatic reconnecting for IRC and join channels in
connected()-slot
Diffstat (limited to 'src/crsm.cpp')
| -rw-r--r-- | src/crsm.cpp | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/src/crsm.cpp b/src/crsm.cpp index c1fa131..ec1bf46 100644 --- a/src/crsm.cpp +++ b/src/crsm.cpp @@ -507,16 +507,20 @@ void CRSM::ircMessageReceived(IrcMessage *message) } } -void CRSM::ircDisconnected() +void CRSM::ircConnected() { - if(connection != nullptr) + IrcConnection* conn = (IrcConnection*)sender(); + Q_ASSERT(conn == connection); + connection->sendCommand(IrcCommand::createMode(Config.IRC.Nick, "+B")); + connection->sendCommand(IrcCommand::createJoin(Config.IRC.Channel)); + if(Config.IRC.UseIngameChat && !Config.IRC.IngameChannel.isEmpty()) { - delete connection; + connection->sendCommand(IrcCommand::createJoin(Config.IRC.IngameChannel)); + ircSetIngameChannelTopic(); } - connection = nullptr; - if(!finish && Config.IRC.Use) + else { - QTimer::singleShot(Config.IRC.ReconnectDelay * 1000, this, SLOT(reconnectIrc())); + Session.IRC.UseIngameChat = Config.IRC.UseIngameChat = false; } } @@ -1557,21 +1561,10 @@ void CRSM::prepareAndConnectIrc() connection->setNickName(Config.IRC.Nick); connection->setRealName(Config.IRC.RealName); connection->setReconnectDelay(Config.IRC.ReconnectDelay); - connection->sendCommand(IrcCommand::createMode(Config.IRC.Nick, "+B")); - connection->sendCommand(IrcCommand::createJoin(Config.IRC.Channel)); - if(Config.IRC.UseIngameChat && !Config.IRC.IngameChannel.isEmpty()) - { - connection->sendCommand(IrcCommand::createJoin(Config.IRC.IngameChannel)); - ircSetIngameChannelTopic(); - } - else - { - Session.IRC.UseIngameChat = Config.IRC.UseIngameChat = false; - } - connection->setPassword(Config.IRC.Password); + connect(connection, SIGNAL(messageReceived(IrcMessage*)), this, SLOT(ircMessageReceived(IrcMessage*))); - connect(connection, SIGNAL(disconnected()), this, SLOT(ircDisconnected())); + connect(connection, SIGNAL(connected()), this, SLOT(ircConnected())); connection->open(); } |
