X-Git-Url: http://git.maemo.org/git/?p=jenirok;a=blobdiff_plain;f=src%2Fcommon%2Fconnectionmanager.h;h=b5a2c3ca0afced0f2f76bce6adc1636c0251182a;hp=ea44605acaa0097b3fb30560ef8b23df4cc681b4;hb=f99718e69b270a89094113a26b22c694b79382f0;hpb=cf883c1283eb6b096592ef875a32696fee9dd6ff diff --git a/src/common/connectionmanager.h b/src/common/connectionmanager.h index ea44605..b5a2c3c 100644 --- a/src/common/connectionmanager.h +++ b/src/common/connectionmanager.h @@ -20,35 +20,66 @@ #define CONNECTIONMANAGER_H #include +#include #include -#include -#include -#include +#include +#include +#include +#include class ConnectionManager : public QObject { Q_OBJECT public: - static ConnectionManager& instance(); + + 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(); + bool scanConnections(QList& connections, ConnectionType type = NO_TYPE); + Error error() const; + static unsigned int const TIMEOUT = 15000; + static unsigned int const WAIT_AFTER_CONNECT = 400; -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); + void scanResult(const QDBusMessage& rep); private: - ConnectionManager(); - static void connectionHandler(ConIcConnection *connection, - ConIcConnectionEvent *event, - gpointer user_data); - static ConnectionManager* instance_; - ConIcConnection* connection_; - bool connected_; + void sleep(unsigned int ms); + bool waitSignal(bool* ready); + bool stateReady_; + bool connectionReady_; + bool scanReady_; + static bool connected_; + bool timeout_; + int numberOfConnections_; + int scannedConnections_; + int timer_; + ConnectionType searchType_; + Error error_; + QList* connections_; + QDBusInterface* icd2interface_; }; #endif