f85d156a3292e5fbf03fe26492aa12d954f208f6
[situare] / src / network / networkhandler.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jussi Laitinen - jussi.laitinen@ixonos.com
6
7    Situare is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    version 2 as published by the Free Software Foundation.
10
11    Situare is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with Situare; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19    USA.
20 */
21
22 #ifndef NETWORKHANDLER_H
23 #define NETWORKHANDLER_H
24
25 #include <QtDBus>
26
27 /**
28 * @brief NetworkHandler class.
29 *
30 * This class handles network connection. Class notifies about
31 * network connection states.
32 */
33 class NetworkHandler : public QObject
34 {
35     Q_OBJECT
36
37 public:
38     /**
39     * @brief Constructor.
40     *
41     * Creates ICD D-Bus interface.
42     */
43     NetworkHandler(QObject *parent = 0);
44
45 /*******************************************************************************
46  * MEMBER FUNCTIONS AND SLOTS
47  ******************************************************************************/
48 public:
49     /**
50     * @brief Requests network connection.
51     *
52     * Request is done via ICD D-Bus.
53     */
54     void connect();
55
56     /**
57     * @brief Requests to disconnect a connection.
58     *
59     * Request is done via ICD D-Bus.
60     */
61     void disconnect();
62
63     /**
64     * @brief Checks if connected to network.
65     *
66     * @return true if connected, false otherwise
67     */
68     bool isConnected();
69
70     /**
71     * @brief Requests network state.
72     */
73     void state();
74
75 private slots:
76     /**
77     * @brief Slot for ICD D-Bus state change.
78     *
79     * @param message received D-Bus message
80     */
81     void stateChanged(const QDBusMessage &message);
82
83 /*******************************************************************************
84  * SIGNALS
85  ******************************************************************************/
86 signals:
87     /**
88     * @brief Signals when connected to network.
89     */
90     void connected();
91
92     /**
93     * @brief Signals when disconnected from network.
94     */
95     void disconnected();
96
97 /*******************************************************************************
98  * DATA MEMBERS
99  ******************************************************************************/
100 private:
101     QDBusInterface *dBusInterface;  ///< D-Bus interface
102     bool m_connected;               ///< Connection state variable
103     bool m_connecting;              ///< Connecting state variable
104 };
105
106 #endif // NETWORKHANDLER_H