#define CONNECTIONMANAGER_H
#include <QtCore/QObject>
-#include <QtCore/QString>
-#include <conic/conic.h>
-#include <glib-object.h>
-#include <dbus/dbus-glib-lowlevel.h>
+#include <QtCore/QTimerEvent>
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusMessage>
class ConnectionManager : public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
- static ConnectionManager& instance();
- bool connect();
- bool disconnect();
- bool isConnected();
+ ConnectionManager(QObject* parent = 0);
+ ~ConnectionManager();
+ bool connect();
+ bool disconnect();
+ bool isConnected();
+ static unsigned int const TIMEOUT = 20000;
-signals:
- void connected();
- void disconnected();
- void error(QString const& error);
+protected:
+ virtual void timerEvent(QTimerEvent* event);
+private slots:
+ void stateChange(const QDBusMessage& rep);
+ void connectionChange(const QDBusMessage& rep);
private:
- ConnectionManager();
- static void connectionHandler(ConIcConnection *connection,
- ConIcConnectionEvent *event,
- gpointer user_data);
- static ConnectionManager* instance_;
- ConIcConnection* connection_;
- bool connected_;
+ bool waitSignal();
+ bool ready_;
+ bool connected_;
+ bool timeout_;
+ bool ignoreStateChanges_;
+ int timer_;
+ QDBusInterface *icd2interface_;
};
#endif