X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fcommon%2Fconnectionmanager.cpp;h=baa6e2d957895908977c96384b28f06f08f52851;hb=40fda96f3253fec26e64d5165fcc75011b976a66;hp=fb0f395882677db9a9513d6c30a10df9c251c84f;hpb=99cc5426ffa010cd2b6a871886b210faac34f69d;p=jenirok diff --git a/src/common/connectionmanager.cpp b/src/common/connectionmanager.cpp index fb0f395..baa6e2d 100644 --- a/src/common/connectionmanager.cpp +++ b/src/common/connectionmanager.cpp @@ -77,6 +77,12 @@ bool ConnectionManager::connect() icd2interface_->call(ICD_DBUS_API_CONNECT_REQ, QVariant(flags)); waitSignal(&connectionReady_); + + if(connected_) + { + sleep(WAIT_AFTER_CONNECT); + } + return connected_; } @@ -121,6 +127,8 @@ bool ConnectionManager::connect(QString const& id) connected_ = true; + sleep(WAIT_AFTER_CONNECT); + return true; } @@ -421,15 +429,31 @@ bool ConnectionManager::waitSignal(bool* ready) killTimer(timer_); + /*if(timeout_) + { + qDebug() << "Connection request timed out"; + }*/ + return *ready || !timeout_; } +void ConnectionManager::sleep(unsigned int ms) +{ + timeout_ = false; + timer_ = startTimer(ms); + + while(!timeout_) + { + QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); + } + + killTimer(timer_); +} + void ConnectionManager::timerEvent(QTimerEvent* event) { Q_UNUSED(event); killTimer(timer_); timeout_ = true; timer_ = 0; - - qDebug() << "Connection request timed out"; }