networking-status.cpp
ubuntu/connectivity/networking-status.h
connectivityqt/connectivity.h
QDebug
networking-status.moc
functional
QObject
networking-status.moc
ubuntu/connectivity/networking-status.cpp
QDBusObjectPath
QScopedPointer
connectivityqt/connectivity.h
connectivityqt/vpn-connection.h
QDebug
unity/util/DefinesPtrs.h
QDBusConnection
ubuntu/connectivity/networking-status.h
QAbstractItemModel
connectivityqt/vpn-connections-list-model.h
QAbstractListModel
QStringList
memory
QVector
ubuntu::connectivity::NetworkingStatus
ubuntu
ubuntu::connectivity

    /*
    *Copyright©2014CanonicalLtd.
    *
    *Thisprogramisfreesoftware:youcanredistributeitand/ormodifyit
    *underthetermsoftheGNULesserGeneralPublicLicenseversion3,
    *aspublishedbytheFreeSoftwareFoundation.
    *
    *Thisprogramisdistributedinthehopethatitwillbeuseful,
    *butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof
    *MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe
    *GNULesserGeneralPublicLicenseformoredetails.
    *
    *YoushouldhavereceivedacopyoftheGNULesserGeneralPublicLicense
    *alongwiththisprogram.Ifnot,see<http://www.gnu.org/licenses/>.
    *
    *Authors:
    *AnttiKaijanmäki<antti.kaijanmaki@canonical.com>
    */

    #include<ubuntu/connectivity/networking-status.h>
    #include<connectivityqt/connectivity.h>

    #include<QDebug>

    usingnamespacestd;

    namespaceubuntu
    {
    namespaceconnectivity
    {

    classQ_DECL_HIDDENNetworkingStatus::Private:publicQObject
    {
    Q_OBJECT

    public:
    NetworkingStatus&p;

    connectivityqt::Connectivity::SPtrm_connectivity;

    Private(NetworkingStatus&parent):
    p(parent)
    {
    m_connectivity=make_shared<connectivityqt::Connectivity>();

    connect(m_connectivity.get(),
    &connectivityqt::Connectivity::limitationsUpdated,this,
    &Private::limitationsUpdated);

    connect(m_connectivity.get(),
    &connectivityqt::Connectivity::statusUpdated,this,
    &Private::statusUpdated);
    }

    publicQ_SLOTS:
    voidlimitationsUpdated(constQVector<connectivityqt::Connectivity::Limitations>&)
    {
    Q_EMITp.limitationsChanged();
    }

    voidstatusUpdated(connectivityqt::Connectivity::Statusvalue)
    {
    Q_EMITp.statusChanged(static_cast<NetworkingStatus::Status>(value));
    }
    };

    NetworkingStatus::NetworkingStatus(QObject*parent)
    :QObject(parent),
    d{newPrivate{*this}}
    {
    qRegisterMetaType<ubuntu::connectivity::NetworkingStatus::Limitations>();
    qRegisterMetaType<QVector<ubuntu::connectivity::NetworkingStatus::Limitations>>();
    qRegisterMetaType<ubuntu::connectivity::NetworkingStatus::Status>();
    }

    NetworkingStatus::~NetworkingStatus()
    {}

    QVector<NetworkingStatus::Limitations>
    NetworkingStatus::limitations()const
    {
    QVector<NetworkingStatus::Limitations>result;
    for(constauto&limitation:d->m_connectivity->limitations())
    {
    result.push_back(
    static_cast<NetworkingStatus::Limitations>(limitation));
    }
    returnresult;
    }

    NetworkingStatus::Status
    NetworkingStatus::status()const
    {
    returnstatic_cast<NetworkingStatus::Status>(d->m_connectivity->status());
    }

    }
    }

    #include"networking-status.moc"