Skip to content

Commit

Permalink
[libqofono] Replaced hardcoded literals in QOfonoModem with QString c…
Browse files Browse the repository at this point in the history
…onstants
  • Loading branch information
monich committed Jun 15, 2017
1 parent 5f1494b commit aed2af0
Showing 1 changed file with 60 additions and 41 deletions.
101 changes: 60 additions & 41 deletions src/qofonomodem.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013-2015 Jolla Ltd.
** Contact: lorn.potter@jollamobile.com
** Copyright (C) 2013-2017 Jolla Ltd.
** Contact: slava.monich@jolla.com
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
Expand All @@ -24,15 +24,34 @@ typedef QMap<QString,QWeakPointer<QOfonoModem> > ModemMap;
Q_GLOBAL_STATIC(ModemMap, modemMap)

#define SUPER QOfonoObject
#define MODEM_PROPERTIES(p) \
p(Online) \
p(Powered) \
p(Lockdown) \
p(Emergency) \
p(Name) \
p(Manufacturer) \
p(Model) \
p(Revision) \
p(Serial) \
p(Type) \
p(Features) \
p(Interfaces) \

class QOfonoModem::Private : public SUPER::ExtData
{
public:
#define DECLARE_PROPERTY(p) static const QString p;
MODEM_PROPERTIES(DECLARE_PROPERTY)

bool modemPathValid;
QSharedPointer<QOfonoManager> mgr;
Private() : modemPathValid(false), mgr(QOfonoManager::instance()) {}
};

#define DEFINE_PROPERTY(p) const QString QOfonoModem::Private::p(QLatin1String(#p));
MODEM_PROPERTIES(DEFINE_PROPERTY)

QOfonoModem::QOfonoModem(QObject *parent) :
SUPER(new Private, parent)
{
Expand Down Expand Up @@ -76,106 +95,106 @@ QString QOfonoModem::modemPath() const

bool QOfonoModem::powered() const
{
return getBool("Powered");
return getBool(Private::Powered);
}

bool QOfonoModem::online() const
{
return getBool("Online");
return getBool(Private::Online);
}

bool QOfonoModem::lockdown() const
{
return getBool("Lockdown");
return getBool(Private::Lockdown);
}

bool QOfonoModem::emergency() const
{
return getBool("Emergency");
return getBool(Private::Emergency);
}

QString QOfonoModem::name() const
{
return getString("Name");
return getString(Private::Name);
}

QString QOfonoModem::manufacturer() const
{
return getString("Manufacturer");
return getString(Private::Manufacturer);
}

QString QOfonoModem::model() const
{
return getString("Model");
return getString(Private::Model);
}

QString QOfonoModem::revision() const
{
return getString("Revision");
return getString(Private::Revision);
}

QString QOfonoModem::serial() const
{
return getString("Serial");
return getString(Private::Serial);
}

QString QOfonoModem::type() const
{
return getString("Type");
return getString(Private::Type);
}

QStringList QOfonoModem::features() const
{
return getStringList("Features");
return getStringList(Private::Features);
}

QStringList QOfonoModem::interfaces() const
{
return getStringList("Interfaces");
return getStringList(Private::Interfaces);
}

void QOfonoModem::setPowered(bool powered)
{
setProperty("Powered", powered);
setProperty(Private::Powered, powered);
}

void QOfonoModem::setOnline(bool online)
{
setProperty("Online", online);
setProperty(Private::Online, online);
}

void QOfonoModem::setLockdown(bool lockdown)
{
setProperty("Lockdown", lockdown);
setProperty(Private::Lockdown, lockdown);
}

void QOfonoModem::propertyChanged(const QString &property, const QVariant &value)
{
SUPER::propertyChanged(property, value);
if (property == QLatin1String("Online")) {
Q_EMIT onlineChanged(value.value<bool>());
} else if (property == QLatin1String("Powered")) {
Q_EMIT poweredChanged(value.value<bool>());
} else if (property == QLatin1String("Lockdown")) {
Q_EMIT lockdownChanged(value.value<bool>());
} else if (property == QLatin1String("Emergency")) {
Q_EMIT emergencyChanged(value.value<bool>());
} else if (property == QLatin1String("Name")) {
Q_EMIT nameChanged(value.value<QString>());
} else if (property == QLatin1String("Manufacturer")) {
Q_EMIT manufacturerChanged(value.value<QString>());
} else if (property == QLatin1String("Model")) {
Q_EMIT modelChanged(value.value<QString>());
} else if (property == QLatin1String("Revision")) {
Q_EMIT revisionChanged(value.value<QString>());
} else if (property == QLatin1String("Serial")) {
Q_EMIT serialChanged(value.value<QString>());
} else if (property == QLatin1String("Type")) {
Q_EMIT typeChanged(value.value<QString>());
} else if (property == QLatin1String("Features")) {
Q_EMIT featuresChanged(value.value<QStringList>());
} else if (property == QLatin1String("Interfaces")) {
Q_EMIT interfacesChanged(value.value<QStringList>());
if (property == Private::Online) {
Q_EMIT onlineChanged(value.toBool());
} else if (property == Private::Powered) {
Q_EMIT poweredChanged(value.toBool());
} else if (property == Private::Lockdown) {
Q_EMIT lockdownChanged(value.toBool());
} else if (property == Private::Emergency) {
Q_EMIT emergencyChanged(value.toBool());
} else if (property == Private::Name) {
Q_EMIT nameChanged(value.toString());
} else if (property == Private::Manufacturer) {
Q_EMIT manufacturerChanged(value.toString());
} else if (property == Private::Model) {
Q_EMIT modelChanged(value.toString());
} else if (property == Private::Revision) {
Q_EMIT revisionChanged(value.toString());
} else if (property == Private::Serial) {
Q_EMIT serialChanged(value.toString());
} else if (property == Private::Type) {
Q_EMIT typeChanged(value.toString());
} else if (property == Private::Features) {
Q_EMIT featuresChanged(value.toStringList());
} else if (property == Private::Interfaces) {
Q_EMIT interfacesChanged(value.toStringList());
}
}

Expand Down

0 comments on commit aed2af0

Please sign in to comment.