}
+ConnectionManager::~ConnectionManager()
+{
+ QDBusConnection systemBus = QDBusConnection::systemBus();
+
+ systemBus.disconnect(ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH,
+ ICD_DBUS_API_INTERFACE, ICD_DBUS_API_STATE_SIG,
+ this, SLOT(stateChange(const QDBusMessage&)));
+
+ systemBus.disconnect(ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH,
+ ICD_DBUS_API_INTERFACE, ICD_DBUS_API_CONNECT_SIG,
+ this, SLOT(connectionChange(const QDBusMessage&)));
+}
+
bool ConnectionManager::connect()
{
ready_ = false;
switch(status)
{
case ICD_STATE_CONNECTING:
- qDebug() << "Connecting";
break;
case ICD_STATE_CONNECTED:
connected_ = true;
ready_ = true;
- qDebug() << "Connected";
break;
case ICD_STATE_DISCONNECTING:
- qDebug() << "Disconnecting";
break;
case ICD_STATE_DISCONNECTED:
connected_ = false;
ready_ = true;
- qDebug() << "Disconnected";
break;
case ICD_STATE_LIMITED_CONN_ENABLED:
connected_ = true;
ready_ = true;
- qDebug() << "Limited connection enabled";
break;
case ICD_STATE_LIMITED_CONN_DISABLED:
connected_ = false;
ready_ = true;
- qDebug() << "Limited connection disabled";
break;
case ICD_STATE_SEARCH_START:
- qDebug() << "Search start";
break;
case ICD_STATE_SEARCH_STOP:
- qDebug() << "Search stop";
break;
case ICD_STATE_INTERNAL_ADDRESS_ACQUIRED:
- qDebug() << "Internal address acquired";
break;
default:
qDebug() << "Unknown connection status";
case ICD_CONNECTION_SUCCESSFUL:
connected_ = true;
ready_ = true;
- qDebug() << "Connection successful";
break;
case ICD_CONNECTION_NOT_CONNECTED:
connected_ = false;
ready_ = true;
- qDebug() << "Connection not connected";
break;
case ICD_CONNECTION_DISCONNECTED:
connected_ = false;
ready_ = true;
- qDebug() << "Connection disconnected";
break;
default:
qDebug() << "Unknown connection status";
public:
ConnectionManager(QObject* parent = 0);
+ ~ConnectionManager();
bool connect();
bool disconnect();
bool isConnected();
return false;
}
+ e_book_query_unref(query);
+
if (g_contacts == 0)
{
qDebug() << "no contacts";
return true;
}
- qDebug() << "Loading addressbook";
-
GError *error;
error = 0;
book_ = e_book_new_system_addressbook(&error);
- qDebug() << "Loaded almost";
-
if (!book_)
{
- qDebug() << "Couldn't open addressbook: %s" << error->message;
+ qDebug() << "Couldn't open addressbook: %s" << error->message;
g_error_free(error);
return false;
}
- qDebug() << "Addressbook loaded";
-
/* Open connection to the address book */
if (!e_book_open(book_, FALSE, &error))
{
return false;
}
- qDebug() << "Addressbook opened";
-
return true;
}
SLOT(callTerminate()));
contactManager_ = new ContactManager;
- connectionManager_ = new ConnectionManager;
eniro_ = new Eniro(Eniro::stringToSite(Settings::instance()->get("site")));
{
showResult(tr("Searching..."));
retries_ = 0;
- currentSearch_ = details;
+ currentSearch_ = details.query;
+
+ if(connectionManager_)
+ {
+ delete connectionManager_;
+ connectionManager_ = 0;
+ }
+
+ connectionManager_ = new ConnectionManager;
if(!connectionManager_->isConnected())
{
Eniro::SearchDetails const& details,
bool error)
{
- qDebug() << "Found: " << results.size();
-
// If box is not visible, the call must have been terminated already
if(!box_->isVisible())
{
if(retries_ < NUMBER_OF_RETRIES && retries_ >= 0)
{
retries_++;
- eniro_->search(currentSearch_);
+ eniro_->search(Eniro::SearchDetails(currentSearch_));
return;
}
else
}
retries_ = -1;
+ currentSearch_ = "";
if(closeConnection_)
{
closeConnection_ = false;
}
- timedMessage_ = message;
+ delete connectionManager_;
+ connectionManager_ = 0;
showResult(message);
{
box_->hide();
}
+
box_->show();
}
box_->hide();
}
- if(closeConnection_)
+ if(closeConnection_ && connectionManager_)
{
connectionManager_->disconnect();
closeConnection_ = false;
}
+
+ delete connectionManager_;
+ connectionManager_ = 0;
}
void CallListener::showDelayedResult(QString const& text, int delay)
class CallListener: public QObject
{
-
Q_OBJECT
public:
QLabel* label_;
static QDBusConnection systemBus_;
int retries_;
- Eniro::SearchDetails currentSearch_;
+ QString currentSearch_;
};
#endif // CALLLISTENER_H
#include <QtCore/QLocale>
#include <QtCore/QString>
#include <QtGui/QApplication>
-#include <QDebug>
#include "calllistener.h"
#include "settings.h"
-#include "connectionmanager.h"
int main(int argc, char *argv[])
{