From: eshe Date: Wed, 16 Jun 2010 13:28:53 +0000 (+0100) Subject: Fixed a bug that caused connections to not being found when keyboard is closed during... X-Git-Url: http://git.maemo.org/git/?p=jenirok;a=commitdiff_plain;h=c90925f1b3fcd64f3c5b3799a6caac3fd3a4f05a;hp=fb4bb7bd5d9798da774223ab81d2115a92a05a94 Fixed a bug that caused connections to not being found when keyboard is closed during call. --- diff --git a/src/common/connectionmanager.cpp b/src/common/connectionmanager.cpp index 4f0d99e..e8d9ad4 100644 --- a/src/common/connectionmanager.cpp +++ b/src/common/connectionmanager.cpp @@ -363,7 +363,7 @@ void ConnectionManager::scanResult(const QDBusMessage& rep) return; } - if(status != ICD_SCAN_NEW) + if(status != ICD_SCAN_NEW && status != ICD_SCAN_NOTIFY) { return; } @@ -400,6 +400,19 @@ void ConnectionManager::scanResult(const QDBusMessage& rep) connection.name = args.value(8).toString(); connection.strength = args.value(11).toInt(); + for(int i = 0; i < connections_->size(); i++) + { + if(connections_->at(i).id == connection.id) + { + if(status == ICD_SCAN_NEW) + { + connections_->insert(i, connection); + } + + return; + } + } + connections_->push_back(connection); } diff --git a/src/daemon/calllistener.cpp b/src/daemon/calllistener.cpp index 9110ff7..343ecf7 100644 --- a/src/daemon/calllistener.cpp +++ b/src/daemon/calllistener.cpp @@ -145,6 +145,13 @@ void CallListener::requestFinished(QVector const& results, Source::SearchDetails const& details, bool error) { + 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()) { @@ -204,13 +211,6 @@ void CallListener::requestFinished(QVector const& results, retries_ = -1; currentSearch_ = ""; - - if(closeConnection_) - { - closeConnection_ = false; - ConnectionManager cm; - cm.disconnect(true); - } } QString CallListener::createResult(QString const& name, QString const& street, QString const& city) @@ -276,14 +276,7 @@ void CallListener::callTerminate() { if(box_ && box_->isVisible()) { - box_->hide(); - } - - if(closeConnection_) - { - closeConnection_ = false; - ConnectionManager cm; - cm.disconnect(true); + box_->close(); } searchClose(); @@ -357,6 +350,13 @@ void CallListener::searchClose() delete box_; box_ = 0; label_ = 0; + + if(closeConnection_) + { + closeConnection_ = false; + ConnectionManager cm; + cm.disconnect(true); + } } bool CallListener::handleConnection() @@ -408,7 +408,7 @@ bool CallListener::handleConnection() bool found = false; int maxScans = GPRS_SCANS; - if(lookupType == ConnectionManager::WLAN) + if(lookupType != ConnectionManager::GPRS) { maxScans = WLAN_SCANS; } @@ -475,16 +475,26 @@ bool CallListener::handleConnection() return false; } - sleep(WAIT_BETWEEN_RETRIES); + retries++; qDebug() << "Unable to connect, retrying..."; - retries++; + + if(retries < CONNECT_RETRIES) + { + sendRetrySignal(best.id, initialized_); + } } - if(initialized_ && retries >= CONNECT_RETRIES) + if(retries >= CONNECT_RETRIES) { - showError(tr("Unable to connect to network.")); + sendRetrySignal(best.id, false); + + if(initialized_) + { + showError(tr("Unable to connect to network.")); + } + return false; } @@ -529,19 +539,30 @@ bool CallListener::is3g() uint status = rep.arguments().value(6).toUInt(); - if(status & 0x10) // 3.5G (HSUPA) - { - return true; - } - else if(status & 0x08) // 3G (HSDPA) + if(status & 0x10 || status & 0x08) { return true; } - // Something else return false; } +void CallListener::sendRetrySignal(QString const& iap, bool retry) +{ + QDBusMessage msg = QDBusMessage::createSignal("/com/nokia/icd_ui", + "com.nokia.icd_ui", + "retry"); + + QList arguments; + arguments.append(QVariant(iap)); + arguments.append(QVariant(retry)); + msg.setArguments(arguments); + + QDBusConnection::systemBus().send(msg); + + qDebug() << "Retry signal sent"; +} + void CallListener::timerEvent(QTimerEvent* event) { Q_UNUSED(event); diff --git a/src/daemon/calllistener.h b/src/daemon/calllistener.h index cf47953..cbc4698 100644 --- a/src/daemon/calllistener.h +++ b/src/daemon/calllistener.h @@ -39,8 +39,8 @@ public: static const int REQUEST_TIMEOUT = 10000; static const int BANNER_DELAY = 350; static const int SEARCH_RETRIES = 2; - static const int CONNECT_RETRIES = 3; - static const int CONNECTION_LOOKUP_RETRIES = 10; + static const int CONNECT_RETRIES = 2; + static const int CONNECTION_LOOKUP_RETRIES = 8; static const int GPRS_SCANS = 2; static const int WLAN_SCANS = 5; static const int WAIT_BETWEEN_RETRIES = 500; @@ -67,6 +67,7 @@ private: void showError(QString const& msg, int delay = 0); bool is3g(); void sleep(int ms); + void sendRetrySignal(QString const& iap, bool retry); QString createResult(QString const& name, QString const& street, QString const& city); QString timedMessage_; Source* source_; diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp index 3d3b672..69964f3 100644 --- a/src/daemon/main.cpp +++ b/src/daemon/main.cpp @@ -20,7 +20,7 @@ #include #include "calllistener.h" #include "settings.h" -#include "connectionmanager.h" + int main(int argc, char *argv[]) {