Emit error signal when login fails
[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 <QObject>
26
27 class NetworkHandlerPrivate;
28
29 /**
30 * @brief NetworkHandler class.
31 *
32 * This class handles network connection. Class notifies about
33 * network connection states.
34 */
35 class NetworkHandler : public QObject
36 {
37     Q_OBJECT
38
39 public:
40     /**
41     * @brief Friend class for NetworkHandlerPrivate.
42     */
43     friend class NetworkHandlerPrivate;
44
45     /**
46     * @brief Returns instance of NetworkHandler.
47     *
48     * Creates instance if not created.
49     */
50     static NetworkHandler *instance();
51
52 /*******************************************************************************
53  * MEMBER FUNCTIONS AND SLOTS
54  ******************************************************************************/
55 public:
56     /**
57     * @brief Requests network connection.
58     *
59     * Request is done via ICD D-Bus.
60     */
61     void connect();
62
63     /**
64     * @brief Requests to disconnect a connection.
65     *
66     * Request is done via ICD D-Bus.
67     */
68     void disconnect();
69
70     /**
71     * @brief Checks if connected to network.
72     *
73     * @return true if connected, false otherwise
74     */
75     bool isConnected();
76
77     /**
78     * @brief Requests network state.
79     */
80     void state();
81
82 protected:
83     /**
84     * @brief Constructor.
85     *
86     * Instance of this class can only be created by using instance method.
87     */
88     NetworkHandler();
89
90     /**
91     * @brief Destructor.
92     *
93     * Destructor is not accessible.
94     */
95     ~NetworkHandler();
96 /*******************************************************************************
97  * SIGNALS
98  ******************************************************************************/
99 signals:
100     /**
101     * @brief Signals when connected to network.
102     */
103     void connected();
104
105     /**
106     * @brief Signals when disconnected from network.
107     */
108     void disconnected();
109
110 /*******************************************************************************
111  * DATA MEMBERS
112  ******************************************************************************/
113 private:
114     static NetworkHandler *m_instance;              ///< Instance of NetworkHandler
115     NetworkHandlerPrivate *m_networkHandlerPrivate; ///< Instance of NetworkHandlerPrivate
116 };
117
118 #endif // NETWORKHANDLER_H