12#include "modem3gpp_p.h"
14#include "dbus/fakedbus.h"
19ModemManager::Modem3gppPrivate::Modem3gppPrivate(
const QString &path, Modem3gpp *q)
20 : InterfacePrivate(
path, q)
28 if (modem3gppIface.isValid()) {
29 imei = modem3gppIface.imei();
30 registrationState = (MMModem3gppRegistrationState)modem3gppIface.registrationState();
31 operatorCode = modem3gppIface.operatorCode();
32 operatorName = modem3gppIface.operatorName();
33 enabledFacilityLocks = (QFlags<MMModem3gppFacility>)modem3gppIface.enabledFacilityLocks();
34#if MM_CHECK_VERSION(1, 2, 0)
35 subscriptionState = (MMModem3gppSubscriptionState)modem3gppIface.subscriptionState();
38 QStringView mcc(operatorCode);
39 if (!operatorCode.isEmpty() && operatorCode.size() > 3) {
40 mcc = mcc.sliced(0, 3);
42 QString cc = mobileCountryCodeToAlpha2CountryCode(mcc.toInt());
43 if (cc != countryCode) {
49ModemManager::Modem3gpp::Modem3gpp(
const QString &path,
QObject *parent)
50 : Interface(*new Modem3gppPrivate(
path, this), parent)
54 qRegisterMetaType<QFlags<MMModem3gppFacility>>();
55 qRegisterMetaType<MMModem3gppRegistrationState>();
56#if MM_CHECK_VERSION(1, 2, 0)
57 qRegisterMetaType<MMModem3gppSubscriptionState>();
63 QStringLiteral(
"PropertiesChanged"),
70 QStringLiteral(
"PropertiesChanged"),
76ModemManager::Modem3gpp::~Modem3gpp()
89 return d->registrationState;
95 return d->operatorCode;
101 return d->operatorName;
107 return d->countryCode;
113 return d->enabledFacilityLocks;
116#if MM_CHECK_VERSION(1, 2, 0)
117MMModem3gppSubscriptionState ModemManager::Modem3gpp::subscriptionState()
const
120 return d->subscriptionState;
127 d->modem3gppIface.Register(networkId);
133 return d->modem3gppIface.Scan();
139 d->modem3gppIface.setTimeout(timeout);
145 return d->modem3gppIface.timeout();
148void ModemManager::Modem3gppPrivate::onPropertiesChanged(
const QString &interface,
const QVariantMap &properties,
const QStringList &invalidatedProps)
151 Q_UNUSED(invalidatedProps);
152 qCDebug(MMQT) <<
interface << properties.keys();
154 if (interface ==
QLatin1String(MMQT_DBUS_INTERFACE_MODEM_MODEM3GPP)) {
155 QVariantMap::const_iterator it = properties.constFind(
QLatin1String(MM_MODEM_MODEM3GPP_PROPERTY_IMEI));
156 if (it != properties.constEnd()) {
157 imei = it->toString();
158 Q_EMIT q->imeiChanged(imei);
160 it = properties.constFind(
QLatin1String(MM_MODEM_MODEM3GPP_PROPERTY_REGISTRATIONSTATE));
161 if (it != properties.constEnd()) {
162 registrationState = (MMModem3gppRegistrationState)it->toUInt();
163 Q_EMIT q->registrationStateChanged(registrationState);
167 operatorCode = it->toString();
168 Q_EMIT q->operatorCodeChanged(operatorCode);
170 if (!operatorCode.isEmpty() && operatorCode.size() > 3) {
171 mcc = mcc.sliced(0, 3);
173 QString cc = mobileCountryCodeToAlpha2CountryCode(mcc.toInt());
174 if (cc != countryCode) {
176 Q_EMIT q->countryCodeChanged(countryCode);
181 operatorName = it->toString();
182 Q_EMIT q->operatorNameChanged(operatorName);
187 Q_EMIT q->enabledFacilityLocksChanged(enabledFacilityLocks);
189#if MM_CHECK_VERSION(1, 2, 0)
192 subscriptionState = (MMModem3gppSubscriptionState)it->toUInt();
193 Q_EMIT q->subscriptionStateChanged(subscriptionState);
202QString ModemManager::Modem3gppPrivate::mobileCountryCodeToAlpha2CountryCode(
int mcc)
const
204 const int n =
sizeof(mccList) /
sizeof(mccList[0]);
210 const int mid = (low + high) / 2;
211 if (mccList[mid].mcc >= mcc) {
218 if (high < n && mccList[high].mcc == mcc) {
221 qCWarning(MMQT) <<
"Unknown Mobile Country Code:" << mcc;
226#include "moc_modem3gpp.cpp"
QString countryCode() const
FacilityLocks enabledFacilityLocks() const
int timeout() const
Returns the current value of the DBus timeout in milliseconds.
void setTimeout(int timeout)
Sets the timeout in milliseconds for all async method DBus calls.
void registerToNetwork(const QString &networkId=QString())
Register the device to network.
QString operatorName() const
MMModem3gppRegistrationState registrationState() const
QString operatorCode() const
QDBusPendingReply< QVariantMapList > scan()
Scan for available networks.
QString path(const QString &relativePath)
QStringView countryCode(QStringView coachNumber)
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QDBusConnection sessionBus()
QDBusConnection systemBus()
QString fromLatin1(QByteArrayView str)