+ delete connectionManager_;
+ connectionManager_ = 0;
+ delete eniro_;
+ eniro_ = 0;
+ delete box_;
+ box_ = 0;
+ label_ = 0;
+}
+
+bool CallListener::handleConnection()
+{
+ if(!connectionManager_)
+ {
+ qDebug() << "Error: connection manager not initialized";
+ return false;
+ }
+
+ if(connectionManager_->isConnected())
+ {
+ closeConnection_ = false;
+ return true;
+ }
+
+ closeConnection_ = true;
+ int retries = 0;
+
+ if(autoconnect_)
+ {
+ QString conn;
+
+ if(connectionName_.size() != 0 && connectionName_ != "0")
+ {
+ conn = connectionName_;
+ }
+ else
+ {
+ ConnectionManager::Connection best;
+
+ if(!connectionManager_->getBestConnection(best))
+ {
+ showError(tr("No network connections found."));
+ return false;
+ }
+
+ conn = best.id;
+ }
+
+ while(retries < CONNECT_RETRIES)
+ {
+ if(connectionManager_->connect(conn))
+ {
+ break;
+ }
+ else if(connectionManager_->error() == ConnectionManager::INVALID_IAP)
+ {
+ showError(tr("Selected access point doesn't exist."));
+ return false;
+ }
+
+ retries++;
+ }
+ }
+ else
+ {
+ while(retries < CONNECT_RETRIES)
+ {
+ if(connectionManager_->connect())
+ {
+ break;
+ }
+ else
+ {
+ qDebug() << "Automatic connection failed";
+ }
+
+ retries++;
+ }
+ }
+
+ if(retries >= CONNECT_RETRIES)
+ {
+ ConnectionManager::NetworkMode mode = connectionManager_->getNetworkMode();
+
+ if(mode != ConnectionManager::NETWORK_3G &&
+ mode != ConnectionManager::NETWORK_3_5G)
+ {
+ showError(tr("No 3G or WLAN network available."));
+ }
+ else
+ {
+ showError(tr("Unable to connect to network."));
+ }
+
+ return false;
+ }
+
+ return true;
+}
+
+void CallListener::showError(QString const& msg)
+{
+ qDebug() << "Error: " << msg;
+ box_->setTimeout(ERROR_BANNER_TIMEOUT);
+ showResult(msg);