| 1 |
/* |
| 2 |
* Copyright © 2014 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software: you can redistribute it and/or modify it |
| 5 |
* under the terms of the GNU Lesser General Public License version 3, |
| 6 |
* as published by the Free Software Foundation. |
| 7 |
* |
| 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 |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
* |
| 16 |
* Authors: |
| 17 |
* Antti Kaijanmäki <[email protected]> |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "networking-status.h" |
| 21 |
|
| 22 |
NetworkingStatus::NetworkingStatus(QObject *parent) |
| 23 |
: QObject(parent) |
| 24 |
{ |
| 25 |
qRegisterMetaType<NetworkingStatus::Limitations>(); |
| 26 |
qRegisterMetaType<QVector<NetworkingStatus::Limitations>>(); |
| 27 |
qRegisterMetaType<NetworkingStatus::Status>(); |
| 28 |
} |
| 29 |
|
| 30 |
NetworkingStatus::~NetworkingStatus() |
| 31 |
{} |
| 32 |
|
| 33 |
QVector<NetworkingStatus::Limitations> |
| 34 |
NetworkingStatus::limitations() const |
| 35 |
{ |
| 36 |
return m_limitations; |
| 37 |
} |
| 38 |
|
| 39 |
NetworkingStatus::Status |
| 40 |
NetworkingStatus::status() const |
| 41 |
{ |
| 42 |
return m_status; |
| 43 |
} |
| 44 |
|
| 45 |
bool |
| 46 |
NetworkingStatus::online() const |
| 47 |
{ |
| 48 |
return status() == Status::Online; |
| 49 |
} |
| 50 |
|
| 51 |
bool |
| 52 |
NetworkingStatus::limitedBandwidth() const |
| 53 |
{ |
| 54 |
return limitations().contains(Limitations::Bandwidth); |
| 55 |
} |
| 56 |
|
| 57 |
void NetworkingStatus::setLimitedBandwidth(bool limited) |
| 58 |
{ |
| 59 |
if (limited) { |
| 60 |
m_limitations << Limitations::Bandwidth; |
| 61 |
} else if (limitedBandwidth()) { |
| 62 |
m_limitations.remove(m_limitations.indexOf(Limitations::Bandwidth)); |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
void NetworkingStatus::setStatus(Status status) |
| 67 |
{ |
| 68 |
m_status = status; |
| 69 |
Q_EMIT statusChanged(m_status); |
| 70 |
} |