modem.cpp
connectivityqt/internal/dbus-property-cache.h
connectivityqt/modem.h
dbus-types.h
ModemInterface.h
modem.moc
modem.cpp
connectivityqt/modem.h
connectivityqt/sim.h
connectivityqt/sims-list-model.h
ModemInterface.h
QAbstractItemModel
QDBusConnection
QDBusObjectPath
QObject
connectivityqt/internal/dbus-property-cache.h
dbus-types.h
lomiri/util/DefinesPtrs.h
memory
modem.moc
connectivityqt

    /*
    *Copyright©2016CanonicalLtd.
    *
    *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<connectivityqt/internal/dbus-property-cache.h>
    #include<connectivityqt/modem.h>
    #include<dbus-types.h>

    #include<ModemInterface.h>

    usingnamespacestd;

    namespaceconnectivityqt
    {

    classModem::Priv:publicQObject
    {
    Q_OBJECT

    public:
    Priv(Modem&parent):
    p(parent)
    {
    }

    publicQ_SLOTS:
    voidpropertyChanged(constQString&name,constQVariant&value)
    {
    Q_UNUSED(value);

    if(name=="Sim")
    {
    simsUpdated();
    }
    }

    voidsimsUpdated()
    {
    autopath=m_propertyCache->get("Sim").value<QDBusObjectPath>();
    autosim=m_sims->getSimByPath(path);
    setSim(sim);
    }

    voidsetSim(Sim::SPtrsim)
    {
    if(m_sim==sim)
    {
    return;
    }
    m_sim=sim;
    Q_EMITp.simChanged(m_sim.get());
    }

    public:
    Modem&p;

    Sim::SPtrm_sim;
    SimsListModel::SPtrm_sims;

    unique_ptr<ComLomiriConnectivity1ModemInterface>m_modemInterface;

    internal::DBusPropertyCache::UPtrm_propertyCache;
    };

    Modem::Modem(constQDBusObjectPath&path,
    constQDBusConnection&connection,
    SimsListModel::SPtrsims,
    QObject*parent):
    QObject(parent),d(newPriv(*this))
    {
    d->m_sims=sims;
    d->m_modemInterface=make_unique<
    ComLomiriConnectivity1ModemInterface>(
    DBusTypes::DBUS_NAME,path.path(),connection);

    d->m_propertyCache=
    make_unique<internal::DBusPropertyCache>(
    DBusTypes::DBUS_NAME,
    ComLomiriConnectivity1ModemInterface::staticInterfaceName(),
    path.path(),connection);

    connect(d->m_propertyCache.get(),
    &internal::DBusPropertyCache::propertyChanged,d.get(),
    &Priv::propertyChanged);

    d->simsUpdated();

    connect(d->m_sims.get(),&SimsListModel::simsUpdated,d.get(),&Priv::simsUpdated);
    }

    Modem::~Modem()
    {
    }

    QDBusObjectPathModem::path()const
    {
    returnQDBusObjectPath(d->m_modemInterface->path());
    }

    intModem::index()const
    {
    returnd->m_propertyCache->get("Index").toInt();
    }

    Sim*Modem::sim()const
    {
    returnd->m_sim.get();
    }

    QStringModem::serial()const
    {
    returnd->m_propertyCache->get("Serial").toString();
    }

    }

    #include"modem.moc"