Skip to content

Commit

Permalink
[libqofono] Refactored QOfonoCellBroadcast. JB#50238
Browse files Browse the repository at this point in the history
1. Added setter for topics property.
2. Derived this class from QOfonoModemInterface.

This breaks ABI but since cell broadcast functionality had been broken
in our ofono fork all these years, it's very unlikely that this class
was actually being used by anyone in the entire Universe.
  • Loading branch information
monich committed Jun 24, 2020
1 parent 48a2bcf commit e551b0f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 48 deletions.
46 changes: 14 additions & 32 deletions src/qofonocellbroadcast.cpp
Expand Up @@ -16,10 +16,15 @@
#include "qofonocellbroadcast.h"
#include "ofono_cell_broadcast_interface.h"

#define SUPER QOfonoObject
#define SUPER QOfonoModemInterface

namespace {
const QString Powered("Powered");
const QString Topics("Topics");
}

QOfonoCellBroadcast::QOfonoCellBroadcast(QObject *parent) :
SUPER(parent)
SUPER(OfonoCellBroadcast::staticInterfaceName(), parent)
{
}

Expand All @@ -39,55 +44,32 @@ QDBusAbstractInterface *QOfonoCellBroadcast::createDbusInterface(const QString &
return iface;
}

void QOfonoCellBroadcast::objectPathChanged(const QString &path, const QVariantMap *properties)
{
SUPER::objectPathChanged(path, properties);
Q_EMIT modemPathChanged(path);
}

void QOfonoCellBroadcast::setModemPath(const QString &path)
{
setObjectPath(path);
}

QString QOfonoCellBroadcast::modemPath() const
{
return objectPath();
}

void QOfonoCellBroadcast::propertyChanged(const QString &property, const QVariant &value)
{
SUPER::propertyChanged(property, value);
if (property == QLatin1String("Powered")) {
if (property == Powered) {
Q_EMIT enabledChanged(value.toBool());
} else if (property == QLatin1String("Topics")) {
} else if (property == Topics) {
Q_EMIT topicsChanged(value.toString());
}
}

bool QOfonoCellBroadcast::enabled() const
{
return getBool("Powered");
return getBool(Powered);
}

void QOfonoCellBroadcast::setEnabled(bool b)
{
setProperty("Powered", b);
setProperty(Powered, b);
}

QString QOfonoCellBroadcast::topics() const
{
return getString("Topics");
}

void QOfonoCellBroadcast::setTopics(const QString &topics) const
{
// It's not clear why this method is const (probably, copy/paste artifact)
// but it has to remain const to maintain ABI
((QOfonoCellBroadcast*)this)->setProperty("Topics", topics);
return getString(Topics);
}

bool QOfonoCellBroadcast::isValid() const
void QOfonoCellBroadcast::setTopics(const QString &topics)
{
return SUPER::isValid();
setProperty(Topics, topics);
}
23 changes: 7 additions & 16 deletions src/qofonocellbroadcast.h
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013-2014 Jolla Ltd.
** Contact: lorn.potter@jollamobile.com
** Copyright (C) 2013-2020 Jolla Ltd.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
Expand All @@ -16,47 +15,39 @@
#ifndef QOFONOCELLBROADCAST_H
#define QOFONOCELLBROADCAST_H

#include "qofonoobject.h"
#include "qofonomodeminterface.h"
#include "qofono_global.h"

//! This class is used to access ofono cell broadcast API
/*!
* The API is documented in
* http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/cell-broadcast-api.txt
*/
class QOFONOSHARED_EXPORT QOfonoCellBroadcast : public QOfonoObject
class QOFONOSHARED_EXPORT QOfonoCellBroadcast : public QOfonoModemInterface
{
Q_OBJECT
Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(QString topics READ topics NOTIFY topicsChanged)
Q_PROPERTY(QString topics READ topics WRITE setTopics NOTIFY topicsChanged)

public:
explicit QOfonoCellBroadcast(QObject *parent = 0);
~QOfonoCellBroadcast();

QString modemPath() const;
void setModemPath(const QString &path);

bool enabled() const;
void setEnabled(bool b);

QString topics() const;
void setTopics(const QString &) const; // to maintain ABI

bool isValid() const;
void setTopics(const QString &);

Q_SIGNALS:
void enabledChanged(bool);
void topicsChanged(const QString &);
void incomingBroadcast(const QString &, quint16);
void emergencyBroadcast(const QString &, const QVariantMap &);
void modemPathChanged(const QString &path);
void incomingBroadcast(const QString &text, quint16 topic);
void emergencyBroadcast(const QString &text, const QVariantMap &properties);

protected:
QDBusAbstractInterface *createDbusInterface(const QString &path);
void propertyChanged(const QString &key, const QVariant &value);
void objectPathChanged(const QString &path, const QVariantMap *properties);
};

#endif // QOFONOCELLBROADCAST_H

0 comments on commit e551b0f

Please sign in to comment.