sim.cpp
connectivityqt/internal/dbus-property-cache.h
connectivityqt/sim.h
dbus-types.h
SimInterface.h
sim.moc
sim.cpp
connectivityqt/sim.h
QDBusConnection
QDBusObjectPath
QObject
SimInterface.h
connectivityqt/internal/dbus-property-cache.h
dbus-types.h
lomiri/util/DefinesPtrs.h
sim.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/sim.h>
    #include<dbus-types.h>

    #include<SimInterface.h>

    usingnamespacestd;

    namespaceconnectivityqt
    {

    classSim::Priv:publicQObject
    {
    Q_OBJECT

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

    publicQ_SLOTS:
    voidpropertyChanged(constQString&name,constQVariant&value)
    {
    if(name=="Locked")
    {
    Q_EMITp.lockedChanged(value.toBool());
    }elseif(name=="Present")
    {
    Q_EMITp.presentChanged(value.toBool());
    }elseif(name=="DataRoamingEnabled")
    {
    Q_EMITp.dataRoamingEnabledChanged(value.toBool());
    }elseif(name=="Imsi")
    {
    Q_EMITp.imsiChanged(value.toString());
    }elseif(name=="PrimaryPhoneNumber")
    {
    Q_EMITp.primaryPhoneNumberChanged(value.toString());
    }elseif(name=="PreferredLanguages")
    {
    Q_EMITp.preferredLanguagesChanged();
    }else{
    qWarning()<<"connectivityqt::Sim::Priv::propertyChanged():"
    <<"Unexpectedproperty:"<<name;
    }
    }

    public:
    Sim&p;

    unique_ptr<ComLomiriConnectivity1SimInterface>m_simInterface;

    internal::DBusPropertyCache::UPtrm_propertyCache;
    };

    Sim::Sim(constQDBusObjectPath&path,constQDBusConnection&connection,QObject*parent):
    QObject(parent),d(newPriv(*this))
    {
    d->m_simInterface=make_unique<
    ComLomiriConnectivity1SimInterface>(
    DBusTypes::DBUS_NAME,path.path(),connection);

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

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

    Sim::~Sim()
    {
    }

    QDBusObjectPathSim::path()const
    {
    returnQDBusObjectPath(d->m_simInterface->path());
    }

    QStringSim::iccid()const
    {
    returnd->m_propertyCache->get("Iccid").toString();
    }

    QStringSim::imsi()const
    {
    returnd->m_propertyCache->get("Imsi").toString();
    }

    QStringSim::primaryPhoneNumber()const
    {
    returnd->m_propertyCache->get("PrimaryPhoneNumber").toString();
    }

    boolSim::locked()const
    {
    returnd->m_propertyCache->get("Locked").toBool();
    }

    boolSim::present()const
    {
    returnd->m_propertyCache->get("Present").toBool();
    }

    QStringSim::mcc()const
    {
    returnd->m_propertyCache->get("Mcc").toString();
    }

    QStringSim::mnc()const
    {
    returnd->m_propertyCache->get("Mnc").toString();
    }

    QList<QString>Sim::preferredLanguages()const
    {
    returnd->m_propertyCache->get("PreferredLanguages").toStringList();
    }

    boolSim::dataRoamingEnabled()const
    {
    returnd->m_propertyCache->get("DataRoamingEnabled").toBool();
    }

    voidSim::setDataRoamingEnabled(boolvalue)
    {
    d->m_propertyCache->set("DataRoamingEnabled",QVariant(value));
    }

    voidSim::unlock()
    {
    d->m_simInterface->Unlock();
    }

    }

    #include"sim.moc"