Buteo Synchronization Framework
NetworkManager.h
1 /*
2  * This file is part of buteo-syncfw package
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1 as published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23 #ifndef NETWORKMANAGER_H_
24 #define NETWORKMANAGER_H_
25 
26 #include <QNetworkSession>
27 #include <QTimer>
28 #include "SyncCommonDefs.h"
29 
30 class QNetworkConfigurationManager;
31 
32 namespace Buteo {
33 
42 class NetworkManager : public QObject
43 {
44  Q_OBJECT
45 public:
50  NetworkManager(QObject *parent = 0);
51 
56 
62  bool isOnline();
63 
68  Sync::InternetConnectionType connectionType() const;
69 
81  void connectSession(bool connectInBackground = false);
82 
85  void disconnectSession();
86 
87 signals:
92  void statusChanged(bool aConnected, Sync::InternetConnectionType aType);
93 
96  void connectionSuccess();
97 
100  void connectionError();
101 
102 private:
103  static bool m_isSessionActive;
104  static int m_refCount; // Reference counter for number of open connections
105 
106  QNetworkConfigurationManager *m_networkConfigManager;
107  QNetworkSession *m_networkSession;
108  bool m_isOnline;
109  bool m_errorEmitted;
110  QTimer *m_sessionTimer;
111  Sync::InternetConnectionType m_connectionType;
112  QTimer m_idleRefreshTimer;
113 
114 private slots:
115  void slotSessionState(QNetworkSession::State status);
116  void slotSessionError(QNetworkSession::SessionError error);
117  void sessionConnectionTimeout();
118  void slotConfigurationChanged();
119  void idleRefresh();
120 };
121 }
122 
123 #endif//NETWORKMANAGER_H_
124 
Class for managing network sessions.
Definition: NetworkManager.h:43
bool isOnline()
Returns if the device is currently online, i.e, a data sessions is possible.
Definition: NetworkManager.cpp:127
void connectionSuccess()
This signal is emitted when a network session gets connected.
Definition: moc_NetworkManager.cpp:213
~NetworkManager()
Destructor.
Definition: NetworkManager.cpp:118
Sync::InternetConnectionType connectionType() const
Returns the type of connection used by the device.
Definition: NetworkManager.cpp:133
void connectionError()
This signal is emitted when opening a network session fails.
Definition: moc_NetworkManager.cpp:219
void disconnectSession()
Disconnects an open session.
Definition: NetworkManager.cpp:218
void connectSession(bool connectInBackground=false)
Connects a new network session. If a session was already open, the signal connectionSuccess will be e...
Definition: NetworkManager.cpp:138
void statusChanged(bool aConnected, Sync::InternetConnectionType aType)
This signal is emitted when the device's online status changes.
Definition: moc_NetworkManager.cpp:206
NetworkManager(QObject *parent=0)
Constructor.
Definition: NetworkManager.cpp:70