Changed daemon to auto disconnect if network connection was initialized by itself.
[jenirok] / src / common / connectionmanager.h
index e19f4e5..6c5e2a1 100644 (file)
@@ -21,6 +21,9 @@
 
 #include <QtCore/QObject>
 #include <QtCore/QTimerEvent>
+#include <QtCore/QString>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
 #include <QtDBus/QDBusInterface>
 #include <QtDBus/QDBusMessage>
 
@@ -29,12 +32,33 @@ class ConnectionManager : public QObject
     Q_OBJECT
 
 public:
+
+    struct Connection
+    {
+        QString serviceType;
+        unsigned int serviceAttributes;
+        QString serviceID;
+        QString networkName;
+        QString networkType;
+        unsigned int networkAttributes;
+        QByteArray networkID;
+    };
+
     ConnectionManager(QObject* parent = 0);
     ~ConnectionManager();
+    void setBlocking(bool value);
     bool connect();
-    bool disconnect();
+    bool connect(Connection const& connection);
+    bool disconnect(bool force = false);
     bool isConnected();
-    static unsigned int const TIMEOUT = 20000;
+    bool scanConnections(QList<Connection>& connections);
+    static unsigned int const TIMEOUT = 25000;
+
+signals:
+    void connectReply(bool connected);
+    void isConnectedReply(bool connected);
+    void newConnection(ConnectionManager::Connection const& connection);
+    void scanReady();
 
 protected:
     virtual void timerEvent(QTimerEvent* event);
@@ -42,14 +66,20 @@ protected:
 private slots:
     void stateChange(const QDBusMessage& rep);
     void connectionChange(const QDBusMessage& rep);
+    void scanResult(const QDBusMessage& rep);
 
 private:
-    bool waitSignal();
-    bool ready_;
+    bool waitSignal(bool* ready);
+    bool blocking_;
+    bool stateReady_;
+    bool connectionReady_;
+    bool scanReady_;
     bool connected_;
     bool timeout_;
-    bool ignoreStateChanges_;
+    int numberOfConnections_;
+    int scannedConnections_;
     int timer_;
+    QList<Connection>* connections_;
     QDBusInterface *icd2interface_;
 };