NetworkManager.h
/*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef NETWORKMANAGER_H_
#define NETWORKMANAGER_H_
#include <QNetworkSession>
#include <QTimer>
#include "SyncCommonDefs.h"
class QNetworkConfigurationManager;
namespace Buteo {
class NetworkManager : public QObject
{
Q_OBJECT
public:
NetworkManager(QObject *parent = nullptr);
~NetworkManager();
bool isOnline();
Sync::InternetConnectionType connectionType() const;
void connectSession(bool connectInBackground = false);
void disconnectSession();
signals:
void statusChanged(bool aConnected, Sync::InternetConnectionType aType);
void connectionSuccess();
void connectionError();
private:
static bool m_isSessionActive;
static int m_refCount; // Reference counter for number of open connections
QNetworkConfigurationManager *m_networkConfigManager;
QNetworkSession *m_networkSession;
bool m_isOnline;
bool m_errorEmitted;
QTimer *m_sessionTimer;
Sync::InternetConnectionType m_connectionType;
QTimer m_idleRefreshTimer;
private slots:
void slotSessionState(QNetworkSession::State status);
void slotSessionError(QNetworkSession::SessionError error);
void sessionConnectionTimeout();
void slotConfigurationChanged();
void idleRefresh();
};
}
#endif//NETWORKMANAGER_H_
Buteo::NetworkManager::isOnline
bool isOnline()
Returns if the device is currently online, i.e, a data sessions is possible.
Definition NetworkManager.cpp:129
Buteo::NetworkManager::connectionSuccess
void connectionSuccess()
This signal is emitted when a network session gets connected.
Buteo::NetworkManager::NetworkManager
NetworkManager(QObject *parent=nullptr)
Constructor.
Definition NetworkManager.cpp:71
Buteo::NetworkManager::~NetworkManager
~NetworkManager()
Destructor.
Definition NetworkManager.cpp:119
Buteo::NetworkManager::connectionType
Sync::InternetConnectionType connectionType() const
Returns the type of connection used by the device.
Definition NetworkManager.cpp:135
Buteo::NetworkManager::connectionError
void connectionError()
This signal is emitted when opening a network session fails.
Buteo::NetworkManager::disconnectSession
void disconnectSession()
Disconnects an open session.
Definition NetworkManager.cpp:222
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:140
Buteo::NetworkManager::statusChanged
void statusChanged(bool aConnected, Sync::InternetConnectionType aType)
This signal is emitted when the device's online status changes.