Some fixes to connection manager.
[jenirok] / src / daemon / calllistener.cpp
index 79a6485..c76cfdc 100644 (file)
@@ -157,12 +157,14 @@ void CallListener::requestFinished(QVector <Source::Result> const& results,
                                    Source::SearchDetails const& details,
                                    bool error)
 {
-    if(closeConnection_)
+    /*if(closeConnection_)
     {
         closeConnection_ = false;
         ConnectionManager cm;
         cm.disconnect(true);
-    }
+    }*/
+
+    qDebug() << "Request finished";
 
     // If box is not visible, the call must have been terminated already
     if(!initialized_ || !box_->isVisible() || !currentCall_)
@@ -401,6 +403,14 @@ void CallListener::searchClose()
 
     if(closeConnection_)
     {
+        QTimer::singleShot(500, this, SLOT(closeConnection()));
+    }
+}
+
+void CallListener::closeConnection()
+{
+    if(closeConnection_)
+    {
         closeConnection_ = false;
         ConnectionManager cm;
         cm.disconnect(true);
@@ -418,6 +428,7 @@ bool CallListener::handleConnection()
 
     if(cm.isConnected())
     {
+        cm.connect();
         closeConnection_ = false;
         return true;
     }
@@ -511,7 +522,7 @@ bool CallListener::handleConnection()
             return false;
         }
 
-        qDebug() << "Connecting to " << best.name;
+        qDebug() << "Connecting to " << best.name << " (" << best.id << ")";
 
         if(cm.connect(best.id))
         {
@@ -529,7 +540,8 @@ bool CallListener::handleConnection()
 
         if(retries < CONNECT_RETRIES)
         {
-            sendRetrySignal(best.id, initialized_);
+            sendRetrySignal(best.id, false);
+            sleep(WAIT_BETWEEN_RETRIES);
         }
 
     }
@@ -597,7 +609,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");