15#include "dbus/fakedbus.h"
19#include "generictypes_p.h"
26class ModemManager::BearerProperties::Private
33 MMBearerIpFamily ipType;
34 MMBearerAllowedAuth allowedAuth;
38 MMModemCdmaRmProtocol rmProtocol;
82 return d->allowedAuth;
87 d->allowedAuth = allowedAuth;
107 d->password = password;
112 return d->allowRoaming;
117 d->allowRoaming = allow;
122 return d->rmProtocol;
127 d->rmProtocol = rmProtocol;
142 if (
this == &other) {
150ModemManager::ModemPrivate::ModemPrivate(
const QString &path,
Modem *q)
151 : InterfacePrivate(path, q)
159 if (modemIface.isValid()) {
160 simPath = modemIface.sim().path();
161 Q_FOREACH (uint cap, modemIface.supportedCapabilities()) {
162 supportedCapabilities.append((MMModemCapability)cap);
165 maxBearers = modemIface.maxBearers();
166 maxActiveBearers = modemIface.maxActiveBearers();
167 manufacturer = modemIface.manufacturer();
168 model = modemIface.model();
169 revision = modemIface.revision();
170 deviceIdentifier = modemIface.deviceIdentifier();
171 device = modemIface.device();
172 drivers = modemIface.drivers();
173 plugin = modemIface.plugin();
174 primaryPort = modemIface.primaryPort();
175 ports = modemIface.ports();
176 equipmentIdentifier = modemIface.equipmentIdentifier();
177 unlockRequired = (MMModemLock)modemIface.unlockRequired();
178 unlockRetries = modemIface.unlockRetries();
179 state = (MMModemState)modemIface.state();
180 stateFailedReason = (MMModemStateFailedReason)modemIface.stateFailedReason();
182 signalQuality = modemIface.signalQuality();
183 ownNumbers = modemIface.ownNumbers();
184 powerState = (MMModemPowerState)modemIface.powerState();
185 supportedModes = modemIface.supportedModes();
186 currentModes = modemIface.currentModes();
187 Q_FOREACH (uint band, modemIface.supportedBands()) {
188 supportedBands.append((MMModemBand)band);
190 Q_FOREACH (uint band, modemIface.currentBands()) {
191 currentBands.append((MMModemBand)band);
199void ModemManager::ModemPrivate::initializeBearers()
203#if MM_CHECK_VERSION(1, 2, 0)
206 if (!bearers.contains(bearer.
path())) {
207 bearers.insert(bearer.
path(), Bearer::Ptr());
208 Q_EMIT q->bearerAdded(bearer.
path());
216 if (!bearers.contains(bearer.
path())) {
217 bearers.insert(bearer.
path(), Bearer::Ptr());
218 Q_EMIT q->bearerAdded(bearer.
path());
226 : Interface(*new ModemPrivate(
path, this), parent)
230 qRegisterMetaType<AccessTechnologies>();
231 qRegisterMetaType<Capabilities>();
232 qRegisterMetaType<ModemModes>();
233 qRegisterMetaType<IpBearerFamilies>();
234 qRegisterMetaType<MMModemLock>();
235 qRegisterMetaType<MMModemPowerState>();
236 qRegisterMetaType<MMModemState>();
237 qRegisterMetaType<MMModemStateChangeReason>();
238 qRegisterMetaType<MMModemStateFailedReason>();
240 if (d->modemIface.isValid()) {
258 connect(&d->modemIface, &OrgFreedesktopModemManager1ModemInterface::StateChanged, d, &ModemPrivate::onStateChanged);
261ModemManager::Modem::~Modem()
265QString ModemManager::Modem::uni()
const
274 return (MMModemPowerState)d->powerState == MM_MODEM_POWER_STATE_ON;
277bool ModemManager::Modem::isValid()
const
280 return d->modemIface.isValid();
286 return d->modemIface.Enable(enable);
293 map.insert(QStringLiteral(
"apn"), bearerProperties.
apn());
294 if (bearerProperties.
ipType() != MM_BEARER_IP_FAMILY_NONE) {
295 map.insert(QStringLiteral(
"ip-type"), (uint)bearerProperties.
ipType());
301 map.insert(QStringLiteral(
"user"), bearerProperties.
user());
304 map.insert(QStringLiteral(
"password"), bearerProperties.
password());
306 map.insert(QStringLiteral(
"allow-roaming"), bearerProperties.
allowRoaming());
307 if (bearerProperties.
rmProtocol() != MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN) {
308 map.insert(QStringLiteral(
"rm-protocol"), (uint)bearerProperties.
rmProtocol());
311 map.insert(QStringLiteral(
"number"), bearerProperties.
number());
313 return d->modemIface.CreateBearer(map);
328 while (i != d->bearers.constEnd()) {
341 return const_cast<ModemPrivate *
>(d)->findRegisteredBearer(bearer);
347 return d->modemIface.Reset();
353 return d->modemIface.FactoryReset(code);
359 return d->modemIface.SetPowerState(state);
365 return d->modemIface.SetCurrentCapabilities((uint)caps);
371 return d->modemIface.SetCurrentModes(mode);
378 Q_FOREACH (
const MMModemBand band, bands) {
381 return d->modemIface.SetCurrentBands(tmp);
387 return d->modemIface.Command(cmd, timeout);
399 return d->supportedCapabilities;
405 return d->currentCapabilities;
411 return d->maxBearers;
417 return d->maxActiveBearers;
423 return d->manufacturer;
441 return d->deviceIdentifier;
465 return d->primaryPort;
477 return d->equipmentIdentifier;
483 return d->unlockRequired;
489 return d->unlockRetries;
501 return d->stateFailedReason;
507 return d->accessTechnologies;
513 return d->signalQuality;
519 return d->ownNumbers;
525 return d->powerState;
531 return d->supportedModes;
537 return d->currentModes;
543 return d->supportedBands;
549 return d->currentBands;
555 return d->supportedIpFamilies;
563 bool contains = bearers.contains(path);
564 if (contains && bearers.value(path)) {
565 ret = bearers.value(path);
570 Q_EMIT q->bearerAdded(path);
580 d->modemIface.setTimeout(timeout);
586 return d->modemIface.timeout();
589void ModemManager::ModemPrivate::onPropertiesChanged(
const QString &ifaceName,
const QVariantMap &changedProps,
const QStringList &invalidatedProps)
591 Q_UNUSED(invalidatedProps);
593 qCDebug(MMQT) << ifaceName << changedProps.keys();
596 QVariantMap::const_iterator it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_SIM));
598 if (it != changedProps.constEnd()) {
599 Q_EMIT q->simPathChanged(simPath, it->toString());
600 simPath = it->toString();
602#if MM_CHECK_VERSION(1, 2, 0)
603 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_BEARERS));
604 if (it != changedProps.constEnd()) {
608 while (it != bearers.constEnd()) {
609 Q_EMIT q->bearerRemoved(it.key());
616 if (!bearers.contains(bearer.
path())) {
618 Q_EMIT q->bearerAdded(bearer.
path());
623 Q_FOREACH (
const QString &path, knownBearers) {
625 Q_EMIT q->bearerRemoved(path);
628 Q_EMIT q->bearersChanged();
631 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_SUPPORTEDCAPABILITIES));
632 if (it != changedProps.constEnd()) {
633 supportedCapabilities.clear();
634 Q_FOREACH (
const uint cap, qdbus_cast<
QList<uint>>(*it)) {
635 supportedCapabilities << ((MMModemCapability)cap);
637 Q_EMIT q->supportedCapabilitiesChanged(supportedCapabilities);
639 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_CURRENTCAPABILITIES));
640 if (it != changedProps.constEnd()) {
642 Q_EMIT q->currentCapabilitiesChanged(currentCapabilities);
644 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_MAXBEARERS));
645 if (it != changedProps.constEnd()) {
646 maxBearers = it->toUInt();
647 Q_EMIT q->maxBearersChanged(maxBearers);
649 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_MAXACTIVEBEARERS));
650 if (it != changedProps.constEnd()) {
651 maxActiveBearers = it->toUInt();
652 Q_EMIT q->maxActiveBearersChanged(maxActiveBearers);
654 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_MANUFACTURER));
655 if (it != changedProps.constEnd()) {
656 manufacturer = it->toString();
657 Q_EMIT q->manufacturerChanged(manufacturer);
659 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_MODEL));
660 if (it != changedProps.constEnd()) {
661 model = it->toString();
662 Q_EMIT q->modelChanged(model);
664 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_REVISION));
665 if (it != changedProps.constEnd()) {
666 revision = it->toString();
667 Q_EMIT q->revisionChanged(revision);
669 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_DEVICEIDENTIFIER));
670 if (it != changedProps.constEnd()) {
671 deviceIdentifier = it->toString();
672 Q_EMIT q->deviceIdentifierChanged(deviceIdentifier);
674 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_DEVICE));
675 if (it != changedProps.constEnd()) {
676 device = it->toString();
677 Q_EMIT q->deviceChanged(device);
679 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_DRIVERS));
680 if (it != changedProps.constEnd()) {
681 drivers = it->toStringList();
682 Q_EMIT q->driversChanged(drivers);
684 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_PLUGIN));
685 if (it != changedProps.constEnd()) {
686 plugin = it->toString();
687 Q_EMIT q->pluginChanged(plugin);
689 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_PRIMARYPORT));
690 if (it != changedProps.constEnd()) {
691 primaryPort = it->toString();
692 Q_EMIT q->primaryPortChanged(primaryPort);
694 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_PORTS));
695 if (it != changedProps.constEnd()) {
696 ports = qdbus_cast<QList<Port>>(*it);
697 Q_EMIT q->portsChanged(ports);
699 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_EQUIPMENTIDENTIFIER));
700 if (it != changedProps.constEnd()) {
701 equipmentIdentifier = it->toString();
702 Q_EMIT q->equipmentIdentifierChanged(equipmentIdentifier);
704 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_UNLOCKREQUIRED));
705 if (it != changedProps.constEnd()) {
706 unlockRequired = (MMModemLock)it->toUInt();
707 Q_EMIT q->unlockRequiredChanged(unlockRequired);
709 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_UNLOCKRETRIES));
710 if (it != changedProps.constEnd()) {
711 unlockRetries = qdbus_cast<UnlockRetriesMap>(*it);
712 Q_EMIT q->unlockRetriesChanged(unlockRetries);
714 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_STATE));
715 if (it != changedProps.constEnd()) {
720 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_STATEFAILEDREASON));
721 if (it != changedProps.constEnd()) {
722 stateFailedReason = (MMModemStateFailedReason)it->toUInt();
723 Q_EMIT q->stateFailedReasonChanged(stateFailedReason);
725 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_ACCESSTECHNOLOGIES));
726 if (it != changedProps.constEnd()) {
728 Q_EMIT q->accessTechnologiesChanged(accessTechnologies);
730 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_SIGNALQUALITY));
731 if (it != changedProps.constEnd()) {
732 signalQuality = qdbus_cast<SignalQualityPair>(*it);
733 Q_EMIT q->signalQualityChanged(signalQuality);
735 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_OWNNUMBERS));
736 if (it != changedProps.constEnd()) {
737 ownNumbers = it->toStringList();
738 Q_EMIT q->ownNumbersChanged(ownNumbers);
740 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_POWERSTATE));
741 if (it != changedProps.constEnd()) {
742 powerState = (MMModemPowerState)it->toUInt();
743 Q_EMIT q->powerStateChanged(powerState);
745 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_SUPPORTEDMODES));
746 if (it != changedProps.constEnd()) {
747 supportedModes = qdbus_cast<SupportedModesType>(*it);
748 Q_EMIT q->supportedModesChanged(supportedModes);
750 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_CURRENTMODES));
751 if (it != changedProps.constEnd()) {
752 currentModes = qdbus_cast<CurrentModesType>(*it);
753 Q_EMIT q->currentModesChanged(currentModes);
755 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_SUPPORTEDBANDS));
756 if (it != changedProps.constEnd()) {
757 supportedBands.clear();
758 Q_FOREACH (
const uint cap, qdbus_cast<
QList<uint>>(*it)) {
759 supportedBands << ((MMModemBand)cap);
761 Q_EMIT q->supportedBandsChanged(supportedBands);
763 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_CURRENTBANDS));
764 if (it != changedProps.constEnd()) {
765 currentBands.clear();
766 Q_FOREACH (
const uint cap, qdbus_cast<
QList<uint>>(*it)) {
767 currentBands << ((MMModemBand)cap);
769 Q_EMIT q->currentBandsChanged(currentBands);
771 it = changedProps.constFind(
QLatin1String(MM_MODEM_PROPERTY_SUPPORTEDIPFAMILIES));
772 if (it != changedProps.constEnd()) {
774 Q_EMIT q->supportedIpFamiliesChanged(supportedIpFamilies);
779void ModemManager::ModemPrivate::onStateChanged(
int oldState,
int newState, uint reason)
782 state = (MMModemState)newState;
783 Q_EMIT q->stateChanged((MMModemState)oldState, (MMModemState)newState, (MMModemStateChangeReason)reason);
786#include "moc_modem.cpp"
787#include "moc_modem_p.cpp"
This class represents bearer properties used for creating of new bearers.
QString password() const
Returns password.
QString apn() const
Returns Access Point Name.
~BearerProperties()
Destroys this BearerProperties object.
QString number() const
Returns telephone number to dial.
MMModemCdmaRmProtocol rmProtocol() const
Returns protocol of the Rm interface.
void setAllowedAuthentication(MMBearerAllowedAuth allowedAuth)
Sets the authentication method to use.
void setPassword(const QString &password)
Sets password.
bool allowRoaming() const
Returns whether connection is allowed during roaming.
BearerProperties()
Constructs an empty BearerProperties object.
void setApn(const QString &apn)
Sets Access Point Name.
BearerProperties & operator=(const BearerProperties &other)
Makes a copy of the IpConfig object other.
void setUser(const QString &user)
Sets user name.
MMBearerAllowedAuth allowedAuthentication() const
Returns used authentication method.
QString user() const
Returns user name.
MMBearerIpFamily ipType() const
Returns addressing type.
void setRmProtocol(MMModemCdmaRmProtocol rmProtocol)
Sets protocol of the Rm interface.
void setAllowRoaming(bool allow)
Sets whether connection is allowed during roaming.
void setNumber(const QString &number)
Sets telephone number to dial.
void setIpType(MMBearerIpFamily ipType)
Sets addressing type.
ModemManager::Bearer::Ptr findBearer(const QString &bearer) const
MMModemState state() const
IpBearerFamilies supportedIpFamilies() const
SupportedModesType supportedModes() const
QDBusPendingReply< void > setEnabled(bool enable)
Enable or disable the modem.
CurrentModesType currentModes() const
QString manufacturer() const
ModemManager::Bearer::List listBearers() const
QList< MMModemBand > currentBands() const
QDBusPendingReply< void > reset()
Clear non-persistent configuration and state, and return the device to a newly-powered-on state.
MMModemLock unlockRequired() const
QStringList ownNumbers() const
QDBusPendingReply< void > factoryReset(const QString &code)
Clear the modem's configuration (including persistent configuration and state), and return the device...
QString equipmentIdentifier() const
QDBusPendingReply< void > setPowerState(MMModemPowerState state)
Set the power state of the modem.
uint maxActiveBearers() const
MMModemStateFailedReason stateFailedReason() const
void setTimeout(int timeout)
Sets the timeout in milliseconds for all async method DBus calls.
QStringList drivers() const
AccessTechnologies accessTechnologies() const
UnlockRetriesMap unlockRetries() const
int timeout() const
Returns the current value of the DBus timeout in milliseconds.
QList< MMModemBand > supportedBands() const
QDBusPendingReply< void > setCurrentCapabilities(Capabilities caps)
Set the capabilities of the device.
QString deviceIdentifier() const
QString primaryPort() const
QDBusPendingReply< QDBusObjectPath > createBearer(const ModemManager::BearerProperties &bearerProperties)
Create a new packet data bearer using the given characteristics.
QDBusPendingReply< void > setCurrentModes(const CurrentModesType &mode)
Set the access technologies (e.g.
Capabilities currentCapabilities() const
SignalQualityPair signalQuality() const
QDBusPendingReply< void > setCurrentBands(const QList< MMModemBand > &bands)
Set the radio frequency and technology bands the device is currently allowed to use when connecting t...
MMModemPowerState powerState() const
QDBusPendingReply< void > deleteBearer(const QString &bearer)
Delete an existing packet data bearer.
QList< MMModemCapability > supportedCapabilities() const
QString path(const QString &relativePath)
This namespace allows to query the underlying system to discover the available modem interfaces respo...
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QDBusConnection sessionBus()
QDBusConnection systemBus()
QString path() const const
bool isValid() const const
typename Select< 0 >::Type value() const const
void append(QList< T > &&value)
bool isEmpty() const const
void remove(qsizetype i, qsizetype n)
bool removeOne(const AT &t)
bool isEmpty() const const
QString number(double n, char format, int precision)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)