Still a mess, but the refactor is right around the corner anyway. Now at
least Quassel should no longer reconnect automagically if disconnected
explicitly.
_model(model),
_state(Disconnected),
_wantReconnect(false),
_model(model),
_state(Disconnected),
_wantReconnect(false),
_progressMinimum(0),
_progressMaximum(-1),
_progressValue(-1),
_progressMinimum(0),
_progressMaximum(-1),
_progressValue(-1),
- _wasReconnect(false),
- _requestedDisconnect(false),
_resetting(false)
{
qRegisterMetaType<ConnectionState>("CoreConnection::ConnectionState");
_resetting(false)
{
qRegisterMetaType<ConnectionState>("CoreConnection::ConnectionState");
void CoreConnection::init()
{
Client::signalProxy()->setHeartBeatInterval(30);
void CoreConnection::init()
{
Client::signalProxy()->setHeartBeatInterval(30);
- connect(Client::signalProxy(), SIGNAL(disconnected()), SLOT(coreSocketDisconnected()));
connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), SIGNAL(lagUpdated(int)));
_reconnectTimer.setSingleShot(true);
connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), SIGNAL(lagUpdated(int)));
_reconnectTimer.setSingleShot(true);
void CoreConnection::coreSocketDisconnected()
{
void CoreConnection::coreSocketDisconnected()
{
- _wasReconnect = !_requestedDisconnect;
- resetConnection(true);
+ _wasReconnect = false;
+ resetConnection(_wantReconnect);
// FIXME handle disconnects gracefully
}
// FIXME handle disconnects gracefully
}
void CoreConnection::disconnectFromCore()
{
void CoreConnection::disconnectFromCore()
{
- if (_socket) {
- _requestedDisconnect = true;
disconnectFromCore(QString(), false); // requested disconnect, so don't try to reconnect
disconnectFromCore(QString(), false); // requested disconnect, so don't try to reconnect
if (!wantReconnect)
_reconnectTimer.stop();
if (!wantReconnect)
_reconnectTimer.stop();
- _wasReconnect = wantReconnect; // store if disconnect was requested
+ _wantReconnect = wantReconnect; // store if disconnect was requested
+ _wasReconnect = false;
- resetConnection(wantReconnect);
+ if (_socket)
+ _socket->close();
if (errorString.isEmpty())
emit connectionError(tr("Disconnected"));
if (errorString.isEmpty())
emit connectionError(tr("Disconnected"));
- _requestedDisconnect = false;
-
_coreMsgBuffer.clear();
_netsToSync.clear();
_numNetsToSync = 0;
_coreMsgBuffer.clear();
_netsToSync.clear();
_numNetsToSync = 0;
void CoreConnection::reconnectToCore()
{
void CoreConnection::reconnectToCore()
{
- if (currentAccount().isValid())
+ if (currentAccount().isValid()) {
+ _wasReconnect = true;
connectToCore(currentAccount().accountId());
connectToCore(currentAccount().accountId());
QTimer _reconnectTimer;
bool _wantReconnect;
QTimer _reconnectTimer;
bool _wantReconnect;
QSet<QObject *> _netsToSync;
int _numNetsToSync;
QSet<QObject *> _netsToSync;
int _numNetsToSync;
QString _progressText;
QString _coreInfoString(const QVariantMap &);
QString _progressText;
QString _coreInfoString(const QVariantMap &);
- bool _wasReconnect;
- bool _requestedDisconnect;
bool _resetting;
inline CoreAccountModel *accountModel() const;
bool _resetting;
inline CoreAccountModel *accountModel() const;