2
* Copyright 2013-2014 Canonical Ltd.
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of version 3 of the GNU Lesser General Public
6
* License as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public
14
* License along with this library; if not, write to the
15
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
* Boston, MA 02110-1301, USA.
19
#ifndef TRANSFERS_LIB_NETWORK_SESSION_H
20
#define TRANSFERS_LIB_NETWORK_SESSION_H
23
#include <QNetworkConfigurationManager>
26
#include "nm_interface.h"
34
class NetworkSession : public QObject {
40
virtual bool isError();
41
virtual bool isOnline();
42
virtual QNetworkConfiguration::BearerType sessionType();
44
static NetworkSession* instance();
46
// only used for testing so that we can inject a fake
47
static void setInstance(NetworkSession* instance);
48
static void deleteInstance();
51
void sessionTypeChanged(QNetworkConfiguration::BearerType type);
52
void onlineStateChanged(bool state);
55
explicit NetworkSession(QObject* parent=0);
58
QNetworkConfiguration::BearerType convertNMString(const QString& str);
59
void onPropertiesChanged(const QVariantMap& changedProperties);
62
// used for the singleton
63
static NetworkSession* _instance;
66
QNetworkConfigurationManager* _configManager = nullptr;
67
NMInterface* _nm = nullptr;
68
QNetworkConfiguration::BearerType _sessionType =
69
QNetworkConfiguration::BearerUnknown;
71
QString _errorMsg = QString::null;