00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SIGNON_CONNECTION_MANAGER_H
00024 #define SIGNON_CONNECTION_MANAGER_H
00025
00026 #include <QDBusConnection>
00027 #include <QObject>
00028
00029 class QDBusPendingCallWatcher;
00030
00031 namespace SignOn {
00032
00033 class ConnectionManager: public QObject
00034 {
00035 Q_OBJECT
00036
00037 enum SocketConnectionStatus {
00038 SocketConnectionOk = 0,
00039 SocketConnectionUnavailable,
00040 SocketConnectionNoService
00041 };
00042
00043 enum ServiceStatus {
00044 ServiceStatusUnknown = 0,
00045 ServiceActivating,
00046 ServiceActivated
00047 };
00048
00049 public:
00050 ConnectionManager(QObject *parent = 0);
00051 ~ConnectionManager();
00052
00053 static ConnectionManager *instance();
00054
00055 bool hasConnection() const;
00056 const QDBusConnection &connection() const { return m_connection; }
00057 static const QDBusConnection &get() { return instance()->connection(); }
00058
00059 public Q_SLOTS:
00060 void connect();
00061
00062 Q_SIGNALS:
00063 void connected(const QDBusConnection &connection);
00064 void disconnected();
00065
00066 private:
00067 SocketConnectionStatus setupSocketConnection();
00068 void init();
00069
00070 private Q_SLOTS:
00071 void onActivationDone(QDBusPendingCallWatcher *watcher);
00072 void onDisconnected();
00073
00074 private:
00075 QDBusConnection m_connection;
00076 ServiceStatus m_serviceStatus;
00077 };
00078
00079 }
00080
00081 #endif // SIGNON_CONNECTION_MANAGER_H