Some fixes to connection manager.
[jenirok] / src / common / connectionmanager.h
index 6c5e2a1..b5a2c3c 100644 (file)
@@ -33,32 +33,29 @@ class ConnectionManager : public QObject
 
 public:
 
+    enum ConnectionType {NO_TYPE, WLAN, GPRS};
+    enum Error {NO_ERROR, NO_AVAILABLE_CONNECTIONS, INVALID_IAP, UNKNOWN_ERROR};
+
     struct Connection
     {
-        QString serviceType;
-        unsigned int serviceAttributes;
-        QString serviceID;
-        QString networkName;
-        QString networkType;
-        unsigned int networkAttributes;
-        QByteArray networkID;
+        ConnectionType type;
+        QString id;
+        QString name;
+        int strength;
     };
 
     ConnectionManager(QObject* parent = 0);
     ~ConnectionManager();
-    void setBlocking(bool value);
     bool connect();
     bool connect(Connection const& connection);
+    bool connect(QString const& id);
+    bool getBestConnection(Connection& connection, ConnectionType type = NO_TYPE);
     bool disconnect(bool force = false);
     bool isConnected();
-    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();
+    bool scanConnections(QList<Connection>& connections, ConnectionType type = NO_TYPE);
+    Error error() const;
+    static unsigned int const TIMEOUT = 15000;
+    static unsigned int const WAIT_AFTER_CONNECT = 400;
 
 protected:
     virtual void timerEvent(QTimerEvent* event);
@@ -69,18 +66,20 @@ private slots:
     void scanResult(const QDBusMessage& rep);
 
 private:
+    void sleep(unsigned int ms);
     bool waitSignal(bool* ready);
-    bool blocking_;
     bool stateReady_;
     bool connectionReady_;
     bool scanReady_;
-    bool connected_;
+    static bool connected_;
     bool timeout_;
     int numberOfConnections_;
     int scannedConnections_;
     int timer_;
+    ConnectionType searchType_;
+    Error error_;
     QList<Connection>* connections_;
-    QDBusInterface *icd2interface_;
+    QDBusInterface* icd2interface_;
 };
 
 #endif