#include <QtCore/QObject>
#include <QtCore/QTimerEvent>
+#include <QtCore/QString>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusMessage>
Q_OBJECT
public:
+
+ enum ConnectionType {NO_TYPE, WLAN, GPRS};
+ enum Error {NO_ERROR, NO_AVAILABLE_CONNECTIONS, INVALID_IAP, UNKNOWN_ERROR};
+
+ struct Connection
+ {
+ ConnectionType type;
+ QString id;
+ QString name;
+ int strength;
+ };
+
ConnectionManager(QObject* parent = 0);
+ ~ConnectionManager();
bool connect();
- bool disconnect();
+ 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();
- static unsigned int const TIMEOUT = 20000;
+ 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);
private slots:
void stateChange(const QDBusMessage& rep);
void connectionChange(const QDBusMessage& rep);
+ void scanResult(const QDBusMessage& rep);
private:
- bool waitSignal();
- bool ready_;
- bool connected_;
+ void sleep(unsigned int ms);
+ bool waitSignal(bool* ready);
+ bool stateReady_;
+ bool connectionReady_;
+ bool scanReady_;
+ static bool connected_;
bool timeout_;
- bool ignoreStateChanges_;
+ int numberOfConnections_;
+ int scannedConnections_;
int timer_;
- QDBusInterface *icd2interface_;
+ ConnectionType searchType_;
+ Error error_;
+ QList<Connection>* connections_;
+ QDBusInterface* icd2interface_;
};
#endif