Buteo Synchronization Framework: NetworkManager.h Source File

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
30class QNetworkConfigurationManager;
31
32namespace Buteo {
33
42 class NetworkManager : public QObject
43{
44 Q_OBJECT
45public:
50 NetworkManager(QObject *parent = 0);
51
55 ~NetworkManager();
56
62 bool isOnline();
63
68 Sync::InternetConnectionType connectionType() const;
69
81 void connectSession(bool connectInBackground = false);
82
85 void disconnectSession();
86
87signals:
92 void statusChanged(bool aConnected, Sync::InternetConnectionType aType);
93
96 void connectionSuccess();
97
100 void connectionError();
101
102private:
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
114private 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
Buteo::NetworkManager
Class for managing network sessions.
Definition: NetworkManager.h:43
Buteo::NetworkManager::isOnline
bool isOnline()
Returns if the device is currently online, i.e, a data sessions is possible.
Definition: NetworkManager.cpp:127
Buteo::NetworkManager::connectionSuccess
void connectionSuccess()
This signal is emitted when a network session gets connected.
Definition: moc_NetworkManager.cpp:213
Buteo::NetworkManager::~NetworkManager
~NetworkManager()
Destructor.
Definition: NetworkManager.cpp:118
Buteo::NetworkManager::connectionType
Sync::InternetConnectionType connectionType() const
Returns the type of connection used by the device.
Definition: NetworkManager.cpp:133
Buteo::NetworkManager::connectionError
void connectionError()
This signal is emitted when opening a network session fails.
Definition: moc_NetworkManager.cpp:219
Buteo::NetworkManager::disconnectSession
void disconnectSession()
Disconnects an open session.
Definition: NetworkManager.cpp:218
Buteo::NetworkManager::connectSession
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
Buteo::NetworkManager::statusChanged
void statusChanged(bool aConnected, Sync::InternetConnectionType aType)
This signal is emitted when the device's online status changes.
Definition: moc_NetworkManager.cpp:206
Buteo::NetworkManager::NetworkManager
NetworkManager(QObject *parent=0)
Constructor.
Definition: NetworkManager.cpp:70