6a09647aaba1cfa19696e3aadbe7d9198e0da1c5
[situare] / src / engine / 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     void state();
71
72 private slots:
73     /**
74     * @brief Slot for ICD D-Bus state change.
75     *
76     * @param message received D-Bus message
77     */
78     void stateChanged(const QDBusMessage &message);
79
80 /*******************************************************************************
81  * SIGNALS
82  ******************************************************************************/
83 signals:
84     /**
85     * @brief Signals when connected to network.
86     */
87     void connected();
88
89     /**
90     * @brief Signals when disconnected from network.
91     */
92     void disconnected();
93
94 /*******************************************************************************
95  * DATA MEMBERS
96  ******************************************************************************/
97 private:
98     QDBusInterface *dBusInterface;  ///< D-Bus interface
99     bool m_connected;               ///< Connection state variable
100     bool m_connecting;              ///< Connecting state variable
101 };
102
103 #endif // NETWORKHANDLER_H