From 99cc5426ffa010cd2b6a871886b210faac34f69d Mon Sep 17 00:00:00 2001 From: eshe Date: Tue, 17 Aug 2010 14:21:18 +0100 Subject: [PATCH] Fixes to connection handling in daemon. --- src/common/connectionmanager.cpp | 7 ------- src/daemon/calllistener.cpp | 20 +++++++++++++++----- src/daemon/calllistener.h | 9 +++++---- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/common/connectionmanager.cpp b/src/common/connectionmanager.cpp index 510a504..fb0f395 100644 --- a/src/common/connectionmanager.cpp +++ b/src/common/connectionmanager.cpp @@ -192,13 +192,6 @@ bool ConnectionManager::disconnect(bool force) { if(force) { - // Do not allow forced disconnection if connection was not started - // by this class. - if(!connected_) - { - return false; - } - QDBusMessage msg = QDBusMessage::createSignal("/com/nokia/icd_ui", "com.nokia.icd_ui", "disconnect"); diff --git a/src/daemon/calllistener.cpp b/src/daemon/calllistener.cpp index 79a6485..0938fb8 100644 --- a/src/daemon/calllistener.cpp +++ b/src/daemon/calllistener.cpp @@ -157,12 +157,12 @@ void CallListener::requestFinished(QVector const& results, Source::SearchDetails const& details, bool error) { - if(closeConnection_) + /*if(closeConnection_) { closeConnection_ = false; ConnectionManager cm; cm.disconnect(true); - } + }*/ // If box is not visible, the call must have been terminated already if(!initialized_ || !box_->isVisible() || !currentCall_) @@ -401,6 +401,14 @@ void CallListener::searchClose() if(closeConnection_) { + QTimer::singleShot(500, this, SLOT(closeConnection())); + } +} + +void CallListener::closeConnection() +{ + if(closeConnection_) + { closeConnection_ = false; ConnectionManager cm; cm.disconnect(true); @@ -511,10 +519,11 @@ bool CallListener::handleConnection() return false; } - qDebug() << "Connecting to " << best.name; + qDebug() << "Connecting to " << best.name << " (" << best.id << ")"; if(cm.connect(best.id)) { + sleep(500); break; } else if(cm.error() == ConnectionManager::INVALID_IAP) @@ -529,7 +538,8 @@ bool CallListener::handleConnection() if(retries < CONNECT_RETRIES) { - sendRetrySignal(best.id, initialized_); + sendRetrySignal(best.id, false); + sleep(WAIT_BETWEEN_RETRIES); } } @@ -597,7 +607,7 @@ bool CallListener::is3g() void CallListener::sendRetrySignal(QString const& iap, bool retry) { - QDBusMessage msg = QDBusMessage::createSignal("/com/nokia/icd_ui", + QDBusMessage msg = QDBusMessage::createSignal("/com/nokia/icd_ui", "com.nokia.icd_ui", "retry"); diff --git a/src/daemon/calllistener.h b/src/daemon/calllistener.h index 23b97eb..0fba1c7 100644 --- a/src/daemon/calllistener.h +++ b/src/daemon/calllistener.h @@ -39,11 +39,11 @@ public: static const int REQUEST_TIMEOUT = 10000; static const int BANNER_DELAY = 350; static const int SEARCH_RETRIES = 2; - static const int CONNECT_RETRIES = 2; - static const int CONNECTION_LOOKUP_RETRIES = 8; + static const int CONNECT_RETRIES = 1; + static const int CONNECTION_LOOKUP_RETRIES = 7; static const int GPRS_SCANS = 2; - static const int WLAN_SCANS = 5; - static const int WAIT_BETWEEN_RETRIES = 500; + static const int WLAN_SCANS = 4; + static const int WAIT_BETWEEN_RETRIES = 400; static const int ERROR_BANNER_TIMEOUT = 4500; protected: @@ -55,6 +55,7 @@ private slots: void callTerminate(); void showTimedMessage(); void handleAnswer(); + void closeConnection(); private: Q_DISABLE_COPY(CallListener); -- 1.7.9.5