ButeoSynchronizationFramework
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 {
34 
43  class NetworkManager : public QObject
44  {
45  Q_OBJECT
46  public:
51  NetworkManager(QObject *parent = 0);
52 
57 
63  bool isOnline();
64 
70  Sync::InternetConnectionType connectionType() const;
71 
83  void connectSession(bool connectInBackground = false);
84 
88  void disconnectSession();
89 signals:
95  void statusChanged(bool aConnected, Sync::InternetConnectionType aType);
96 
101  void connectionSuccess();
102 
107  void connectionError();
108  private:
109  QNetworkConfigurationManager *m_networkConfigManager; // QT network configuration manager
110  QNetworkSession *m_networkSession; // QT network session
111  static bool m_isSessionActive; // Flag to indicate if a network session is active
112  bool m_isOnline; // Flag to indicate if the device is online
113  static int m_refCount; // Reference counter for number of open connections
114  bool m_errorEmitted; // Network error emited flag
115  QTimer *m_sessionTimer;
116  Sync::InternetConnectionType m_connectionType;
117  QTimer m_idleRefreshTimer;
118 
119 private slots:
120  void slotSessionState(QNetworkSession::State status);
121  void slotSessionError(QNetworkSession::SessionError error);
122  void sessionConnectionTimeout();
123  void slotConfigurationChanged();
124  void idleRefresh();
125  };
126 }
127 
128 #endif//NETWORKMANAGER_H_
129 
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:111
~NetworkManager()
Destructor.
Definition: NetworkManager.cpp:85
Definition: AccountsHelper.h:31
Sync::InternetConnectionType connectionType() const
Returns the type of connection used by the device.
Definition: NetworkManager.cpp:106
void connectionSuccess()
This signal is emitted when a network session gets connected.
Definition: moc_NetworkManager.cpp:207
void connectionError()
This signal is emitted when opening a network session fails.
Definition: moc_NetworkManager.cpp:213
bool isOnline()
Returns if the device is currently online, i.e, a data sessions is possible.
Definition: NetworkManager.cpp:100
Class for managing network sessions.
Definition: NetworkManager.h:43
void statusChanged(bool aConnected, Sync::InternetConnectionType aType)
This signal is emitted when the device&#39;s online status changes.
Definition: moc_NetworkManager.cpp:200
NetworkManager(QObject *parent=0)
Constructor.
Definition: NetworkManager.cpp:36
void disconnectSession()
Disconnects an open session.
Definition: NetworkManager.cpp:199