Skip to content

Commit

Permalink
Merge branch 'cbs' into 'master'
Browse files Browse the repository at this point in the history
Refactored QOfonoCellBroadcast

See merge request mer-core/libqofono!19
  • Loading branch information
monich committed Jun 24, 2020
2 parents 5e74475 + e551b0f commit 3bd0992
Show file tree
Hide file tree
Showing 38 changed files with 175 additions and 196 deletions.
3 changes: 1 addition & 2 deletions src/dbus/ofono_cell_broadcast.xml
Expand Up @@ -21,8 +21,7 @@
<signal name="EmergencyBroadcast">
<arg type="s"/>
<arg type="a{sv}"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/>
</signal>
</interface>

</node>
27 changes: 27 additions & 0 deletions src/dbustypes_p.h
@@ -0,0 +1,27 @@
/****************************************************************************
**
** Copyright (C) 2020 Jolla Ltd.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
****************************************************************************/

#ifndef DBUSTYPES_PRIVATE_H
#define DBUSTYPES_PRIVATE_H

#include "dbustypes.h"

namespace QOfonoDbus {
extern const QString Q_DECL_HIDDEN Service;
}

#define OFONO_SERVICE (QOfonoDbus::Service)
#define OFONO_BUS (QDBusConnection::systemBus())

#endif // DBUSTYPES_PRIVATE_H
6 changes: 3 additions & 3 deletions src/qofonoassistedsatellitenavigation.cpp
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013-2015 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 @@ -13,6 +12,7 @@
**
****************************************************************************/

#include "dbustypes_p.h"
#include "qofonoassistedsatellitenavigation.h"
#include "ofono_assisted_satellite_navigation_interface.h"

Expand Down Expand Up @@ -54,7 +54,7 @@ void QOfonoAssistedSatelliteNavigation::setModemPath(const QString &path)
delete d_ptr->ofonoAssistedSatelliteNav;
d_ptr->ofonoAssistedSatelliteNav = 0;
}
d_ptr->ofonoAssistedSatelliteNav = new OfonoAssistedSatelliteNavigation("org.ofono", path, QDBusConnection::systemBus(),this);
d_ptr->ofonoAssistedSatelliteNav = new OfonoAssistedSatelliteNavigation(OFONO_SERVICE, path, OFONO_BUS,this);
if (d_ptr->ofonoAssistedSatelliteNav->isValid()) {
d_ptr->modemPath = path;
Q_EMIT modemPathChanged(path);
Expand Down
6 changes: 3 additions & 3 deletions src/qofonocallbarring.cpp
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013-2015 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 @@ -13,6 +12,7 @@
**
****************************************************************************/

#include "dbustypes_p.h"
#include "qofonocallbarring.h"
#include "ofono_call_barring_interface.h"

Expand All @@ -29,7 +29,7 @@ QOfonoCallBarring::~QOfonoCallBarring()

QDBusAbstractInterface *QOfonoCallBarring::createDbusInterface(const QString &path)
{
return new OfonoCallBarring("org.ofono", path, QDBusConnection::systemBus(), this);
return new OfonoCallBarring(OFONO_SERVICE, path, OFONO_BUS, this);
}

void QOfonoCallBarring::connectOfono()
Expand Down
6 changes: 3 additions & 3 deletions src/qofonocallforwarding.cpp
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013-2015 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 @@ -13,6 +12,7 @@
**
****************************************************************************/

#include "dbustypes_p.h"
#include "qofonocallforwarding.h"
#include "ofono_call_forwarding_interface.h"

Expand All @@ -29,7 +29,7 @@ QOfonoCallForwarding::~QOfonoCallForwarding()

QDBusAbstractInterface *QOfonoCallForwarding::createDbusInterface(const QString &path)
{
return new OfonoCallForwarding("org.ofono", path, QDBusConnection::systemBus(), this);
return new OfonoCallForwarding(OFONO_SERVICE, path, OFONO_BUS, this);
}

void QOfonoCallForwarding::connectOfono()
Expand Down
6 changes: 3 additions & 3 deletions src/qofonocallmeter.cpp
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013-2015 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 @@ -13,6 +12,7 @@
**
****************************************************************************/

#include "dbustypes_p.h"
#include "qofonocallmeter.h"
#include "ofono_callmeter_interface.h"

Expand All @@ -29,7 +29,7 @@ QOfonoCallMeter::~QOfonoCallMeter()

QDBusAbstractInterface *QOfonoCallMeter::createDbusInterface(const QString &path)
{
OfonoCallMeter *iface = new OfonoCallMeter("org.ofono", path, QDBusConnection::systemBus(), this);
OfonoCallMeter *iface = new OfonoCallMeter(OFONO_SERVICE, path, OFONO_BUS, this);
connect(iface, SIGNAL(NearMaximumWarning()), SIGNAL(nearMaximumWarning()));
return iface;
}
Expand Down
6 changes: 3 additions & 3 deletions src/qofonocallsettings.cpp
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013-2015 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 @@ -13,6 +12,7 @@
**
****************************************************************************/

#include "dbustypes_p.h"
#include "qofonocallsettings.h"
#include "ofono_call_settings_interface.h"

Expand All @@ -34,7 +34,7 @@ void QOfonoCallSettings::connectOfono()

QDBusAbstractInterface *QOfonoCallSettings::createDbusInterface(const QString &path)
{
return new OfonoCallSettings("org.ofono", path, QDBusConnection::systemBus(), this);
return new OfonoCallSettings(OFONO_SERVICE, path, OFONO_BUS, this);
}

void QOfonoCallSettings::propertyChanged(const QString &property, const QVariant &value)
Expand Down
6 changes: 3 additions & 3 deletions src/qofonocallvolume.cpp
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013-2015 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 @@ -13,6 +12,7 @@
**
****************************************************************************/

#include "dbustypes_p.h"
#include "qofonocallvolume.h"
#include "ofono_callvolume_interface.h"

Expand All @@ -29,7 +29,7 @@ QOfonoCallVolume::~QOfonoCallVolume()

QDBusAbstractInterface *QOfonoCallVolume::createDbusInterface(const QString &path)
{
return new OfonoCallVolume("org.ofono", path, QDBusConnection::systemBus(),this);
return new OfonoCallVolume(OFONO_SERVICE, path, OFONO_BUS,this);
}

void QOfonoCallVolume::propertyChanged(const QString &property, const QVariant &value)
Expand Down
52 changes: 17 additions & 35 deletions src/qofonocellbroadcast.cpp
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013-2015 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 @@ -13,13 +12,19 @@
**
****************************************************************************/

#include "dbustypes_p.h"
#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 @@ -29,7 +34,7 @@ QOfonoCellBroadcast::~QOfonoCellBroadcast()

QDBusAbstractInterface *QOfonoCellBroadcast::createDbusInterface(const QString &path)
{
OfonoCellBroadcast *iface = new OfonoCellBroadcast("org.ofono", path, QDBusConnection::systemBus(), this);
OfonoCellBroadcast *iface = new OfonoCellBroadcast(OFONO_SERVICE, path, OFONO_BUS, this);
connect(iface,
SIGNAL(IncomingBroadcast(QString,quint16)),
SIGNAL(incomingBroadcast(QString,quint16)));
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
6 changes: 3 additions & 3 deletions src/qofonoconnectioncontext.cpp
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2013-2015 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 @@ -17,6 +16,7 @@
#include <QtXmlPatterns/QXmlQuery>
#endif

#include "dbustypes_p.h"
#include "qofonoconnectioncontext.h"
#include "qofonoconnectionmanager.h"
#include "qofononetworkregistration.h"
Expand Down Expand Up @@ -45,7 +45,7 @@ QOfonoConnectionContext::~QOfonoConnectionContext()

QDBusAbstractInterface *QOfonoConnectionContext::createDbusInterface(const QString &path)
{
return new OfonoConnectionContext("org.ofono", path, QDBusConnection::systemBus(), this);
return new OfonoConnectionContext(OFONO_SERVICE, path, OFONO_BUS, this);
}

void QOfonoConnectionContext::objectPathChanged(const QString &path, const QVariantMap *properties)
Expand Down

0 comments on commit 3bd0992

Please sign in to comment.