Some fixes to connection manager.
[jenirok] / src / common / connectionmanager.cpp
index fb0f395..f7b0f32 100644 (file)
@@ -77,6 +77,12 @@ bool ConnectionManager::connect()
     icd2interface_->call(ICD_DBUS_API_CONNECT_REQ, QVariant(flags));
 
     waitSignal(&connectionReady_);
     icd2interface_->call(ICD_DBUS_API_CONNECT_REQ, QVariant(flags));
 
     waitSignal(&connectionReady_);
+
+    if(connected_)
+    {
+        sleep(WAIT_AFTER_CONNECT);
+    }
+
     return connected_;
 }
 
     return connected_;
 }
 
@@ -121,6 +127,8 @@ bool ConnectionManager::connect(QString const& id)
 
     connected_ = true;
 
 
     connected_ = true;
 
+    sleep(WAIT_AFTER_CONNECT);
+
     return true;
 }
 
     return true;
 }
 
@@ -421,15 +429,31 @@ bool ConnectionManager::waitSignal(bool* ready)
 
     killTimer(timer_);
 
 
     killTimer(timer_);
 
+    if(timeout_)
+    {
+        qDebug() << "Connection request timed out";
+    }
+
     return *ready || !timeout_;
 }
 
     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;
 void ConnectionManager::timerEvent(QTimerEvent* event)
 {
     Q_UNUSED(event);
     killTimer(timer_);
     timeout_ = true;
     timer_ = 0;
-
-    qDebug() << "Connection request timed out";
 }
 }