Skip to content

Commit

Permalink
Remove MEEGO_ macros
Browse files Browse the repository at this point in the history
Replace all MEEGO_ macros with Q_ equivalents and remove those that are
not needed. Remove system_global.h.

Signed-off-by: Tomi Leppänen <tomi.leppanen@jolla.com>
  • Loading branch information
Tomin1 committed Apr 21, 2020
1 parent 1be3c2c commit 14f8292
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 158 deletions.
75 changes: 38 additions & 37 deletions src/devicestate/devicestate.cpp
Expand Up @@ -44,158 +44,159 @@
namespace DeviceState {

DeviceState::DeviceState(QObject *parent)
: QObject(parent) {
MEEGO_INITIALIZE(DeviceState);
: QObject(parent)
, d_ptr(new DeviceStatePrivate) {
Q_D(DeviceState);

connect(priv, SIGNAL(systemStateChanged(DeviceState::DeviceState::StateIndication)),
connect(d, SIGNAL(systemStateChanged(DeviceState::DeviceState::StateIndication)),
this, SIGNAL(systemStateChanged(DeviceState::DeviceState::StateIndication)));
connect(priv, SIGNAL(nextUserChanged(uint)),
connect(d, SIGNAL(nextUserChanged(uint)),
this, SIGNAL(nextUserChanged(uint)));
}

DeviceState::~DeviceState() {
MEEGO_PRIVATE(DeviceState)
Q_D(DeviceState);

disconnect(priv, SIGNAL(systemStateChanged(DeviceState::DeviceState::StateIndication)),
disconnect(d, SIGNAL(systemStateChanged(DeviceState::DeviceState::StateIndication)),
this, SIGNAL(systemStateChanged(DeviceState::DeviceState::StateIndication)));
disconnect(priv, SIGNAL(nextUserChanged(uint)),
disconnect(d, SIGNAL(nextUserChanged(uint)),
this, SIGNAL(nextUserChanged(uint)));

MEEGO_UNINITIALIZE(DeviceState);
delete d_ptr;
}

void DeviceState::connectNotify(const QMetaMethod &signal) {
MEEGO_PRIVATE(DeviceState)
Q_D(DeviceState);

/* QObject::connect() needs to be thread-safe */
QMutexLocker locker(&priv->connectMutex);
QMutexLocker locker(&d->connectMutex);

if (signal == QMetaMethod::fromSignal(&DeviceState::systemStateChanged)) {
if (0 == priv->connectCount[SIGNAL_SYSTEM_STATE]) {
if (0 == d->connectCount[SIGNAL_SYSTEM_STATE]) {
QDBusConnection::systemBus().connect(dsme_service,
dsme_sig_path,
dsme_sig_interface,
dsme_shutdown_ind,
priv,
d,
SLOT(emitShutdown()));
QDBusConnection::systemBus().connect(dsme_service,
dsme_sig_path,
dsme_sig_interface,
dsme_save_unsaved_data_ind,
priv,
d,
SLOT(emitSaveData()));
QDBusConnection::systemBus().connect(dsme_service,
dsme_sig_path,
dsme_sig_interface,
dsme_battery_empty_ind,
priv,
d,
SLOT(emitBatteryShutdown()));
QDBusConnection::systemBus().connect(dsme_service,
dsme_sig_path,
dsme_sig_interface,
dsme_state_req_denied_ind,
priv,
d,
SLOT(emitShutdownDenied(QString, QString)));
QDBusConnection::systemBus().connect(dsme_service,
dsme_sig_path,
dsme_sig_interface,
dsme_state_change_ind,
priv,
d,
SLOT(emitStateChangeInd(QString)));
QDBusConnection::systemBus().connect(thermalmanager_service,
thermalmanager_path,
thermalmanager_interface,
thermalmanager_state_change_ind,
priv,
d,
SLOT(emitThermalShutdown(QString)));
priv->userManagerWatcher = new QDBusServiceWatcher(SAILFISH_USERMANAGER_DBUS_INTERFACE,
d->userManagerWatcher = new QDBusServiceWatcher(SAILFISH_USERMANAGER_DBUS_INTERFACE,
QDBusConnection::systemBus(),
QDBusServiceWatcher::WatchForRegistration
| QDBusServiceWatcher::WatchForUnregistration,
this);
connect(priv->userManagerWatcher, &QDBusServiceWatcher::serviceRegistered,
connect(d->userManagerWatcher, &QDBusServiceWatcher::serviceRegistered,
this, &DeviceState::connectUserManager);
connect(priv->userManagerWatcher, &QDBusServiceWatcher::serviceUnregistered,
connect(d->userManagerWatcher, &QDBusServiceWatcher::serviceUnregistered,
this, &DeviceState::disconnectUserManager);
if (QDBusConnection::systemBus().interface()->isServiceRegistered(SAILFISH_USERMANAGER_DBUS_INTERFACE))
connectUserManager();
}
priv->connectCount[SIGNAL_SYSTEM_STATE]++;
d->connectCount[SIGNAL_SYSTEM_STATE]++;
}
}

void DeviceState::disconnectNotify(const QMetaMethod &signal) {
MEEGO_PRIVATE(DeviceState)
Q_D(DeviceState);

/* QObject::disconnect() needs to be thread-safe */
QMutexLocker locker(&priv->connectMutex);
QMutexLocker locker(&d->connectMutex);

if (signal == QMetaMethod::fromSignal(&DeviceState::systemStateChanged)) {
priv->connectCount[SIGNAL_SYSTEM_STATE]--;
d->connectCount[SIGNAL_SYSTEM_STATE]--;

if (0 == priv->connectCount[SIGNAL_SYSTEM_STATE]) {
if (0 == d->connectCount[SIGNAL_SYSTEM_STATE]) {
QDBusConnection::systemBus().disconnect(dsme_service,
dsme_sig_path,
dsme_sig_interface,
dsme_shutdown_ind,
priv,
d,
SLOT(emitShutdown()));
QDBusConnection::systemBus().disconnect(dsme_service,
dsme_sig_path,
dsme_sig_interface,
dsme_save_unsaved_data_ind,
priv,
d,
SLOT(emitSaveData()));
QDBusConnection::systemBus().disconnect(dsme_service,
dsme_sig_path,
dsme_sig_interface,
dsme_battery_empty_ind,
priv,
d,
SLOT(emitBatteryShutdown()));
QDBusConnection::systemBus().disconnect(dsme_service,
dsme_sig_path,
dsme_sig_interface,
dsme_state_req_denied_ind,
priv,
d,
SLOT(emitShutdownDenied(QString, QString)));
QDBusConnection::systemBus().disconnect(dsme_service,
dsme_sig_path,
dsme_sig_interface,
dsme_state_change_ind,
priv,
d,
SLOT(emitStateChangeInd(QString)));
QDBusConnection::systemBus().disconnect(thermalmanager_service,
thermalmanager_path,
thermalmanager_interface,
thermalmanager_state_change_ind,
priv,
d,
SLOT(emitThermalShutdown(QString)));
disconnectUserManager();
priv->userManagerWatcher->deleteLater();
priv->userManagerWatcher = nullptr;
d->userManagerWatcher->deleteLater();
d->userManagerWatcher = nullptr;
}
}
}

void DeviceState::connectUserManager()
{
MEEGO_PRIVATE(DeviceState)
Q_D(DeviceState);
QDBusConnection::systemBus().connect(SAILFISH_USERMANAGER_DBUS_INTERFACE,
SAILFISH_USERMANAGER_DBUS_OBJECT_PATH,
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"aboutToChangeCurrentUser",
priv,
d,
SLOT(emitUserSwitching(uint)));
}

void DeviceState::disconnectUserManager()
{
MEEGO_PRIVATE(DeviceState)
Q_D(DeviceState);
QDBusConnection::systemBus().disconnect(SAILFISH_USERMANAGER_DBUS_INTERFACE,
SAILFISH_USERMANAGER_DBUS_OBJECT_PATH,
SAILFISH_USERMANAGER_DBUS_INTERFACE,
"aboutToChangeCurrentUser",
priv,
d,
SLOT(emitUserChanging(uint)));
}

Expand Down
4 changes: 2 additions & 2 deletions src/devicestate/devicestate.h
Expand Up @@ -35,7 +35,6 @@
#ifndef DEVICESTATE_H
#define DEVICESTATE_H

#include "system_global.h"
#include <QtCore/qobject.h>

QT_BEGIN_HEADER
Expand Down Expand Up @@ -100,7 +99,8 @@ private slots:

private:
Q_DISABLE_COPY(DeviceState)
MEEGO_DECLARE_PRIVATE(DeviceState)
Q_DECLARE_PRIVATE(DeviceState)
DeviceStatePrivate *d_ptr;
};

} // DeviceState namespace
Expand Down
1 change: 0 additions & 1 deletion src/devicestate/devicestate_p.h
Expand Up @@ -43,7 +43,6 @@ namespace DeviceState
class DeviceStatePrivate : public QObject
{
Q_OBJECT
MEEGO_DECLARE_PUBLIC(DeviceState)

public:
DeviceStatePrivate() {
Expand Down
37 changes: 19 additions & 18 deletions src/devicestate/displaystate.cpp
Expand Up @@ -37,62 +37,63 @@
namespace DeviceState {

DisplayStateMonitor::DisplayStateMonitor(QObject *parent)
: QObject(parent) {
MEEGO_INITIALIZE(DisplayStateMonitor);
: QObject(parent)
, d_ptr(new DisplayStateMonitorPrivate) {
Q_D(DisplayStateMonitor);

connect(priv, SIGNAL(displayStateChanged(DeviceState::DisplayStateMonitor::DisplayState)),
this, SIGNAL(displayStateChanged(DeviceState::DisplayStateMonitor::DisplayState)));
connect(d, SIGNAL(displayStateChanged(DeviceState::DisplayStateMonitor::DisplayState)),
this, SIGNAL(displayStateChanged(DeviceState::DisplayStateMonitor::DisplayState)));
}

DisplayStateMonitor::~DisplayStateMonitor() {
MEEGO_PRIVATE(DisplayStateMonitor)
Q_D(DisplayStateMonitor);

disconnect(priv, SIGNAL(displayStateChanged(DeviceState::DisplayStateMonitor::DisplayState)),
disconnect(d, SIGNAL(displayStateChanged(DeviceState::DisplayStateMonitor::DisplayState)),
this, SIGNAL(displayStateChanged(DeviceState::DisplayStateMonitor::DisplayState)));

MEEGO_UNINITIALIZE(DisplayStateMonitor);
delete d_ptr;
}

void DisplayStateMonitor::connectNotify(const QMetaMethod &signal) {
MEEGO_PRIVATE(DisplayStateMonitor)
Q_D(DisplayStateMonitor);

/* QObject::connect() needs to be thread-safe */
QMutexLocker locker(&priv->connectMutex);
QMutexLocker locker(&d->connectMutex);

if (signal == QMetaMethod::fromSignal(&DisplayStateMonitor::displayStateChanged)) {
if (0 == priv->connectCount[SIGNAL_DISPLAY_STATE]) {
if (0 == d->connectCount[SIGNAL_DISPLAY_STATE]) {
QDBusConnection::systemBus().connect(MCE_SERVICE,
MCE_SIGNAL_PATH,
MCE_SIGNAL_IF,
MCE_DISPLAY_SIG,
priv,
d,
SLOT(slotDisplayStateChanged(QString)));

QDBusConnection::systemBus().callWithCallback(
QDBusMessage::createMethodCall(
MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, MCE_DISPLAY_STATUS_GET),
priv,
d,
SLOT(slotDisplayStateChanged(QString)));
}
priv->connectCount[SIGNAL_DISPLAY_STATE]++;
d->connectCount[SIGNAL_DISPLAY_STATE]++;
}
}

void DisplayStateMonitor::disconnectNotify(const QMetaMethod &signal) {
MEEGO_PRIVATE(DisplayStateMonitor)
Q_D(DisplayStateMonitor);

/* QObject::disconnect() needs to be thread-safe */
QMutexLocker locker(&priv->connectMutex);
QMutexLocker locker(&d->connectMutex);

if (signal == QMetaMethod::fromSignal(&DisplayStateMonitor::displayStateChanged)) {
priv->connectCount[SIGNAL_DISPLAY_STATE]--;
d->connectCount[SIGNAL_DISPLAY_STATE]--;

if (0 == priv->connectCount[SIGNAL_DISPLAY_STATE]) {
if (0 == d->connectCount[SIGNAL_DISPLAY_STATE]) {
QDBusConnection::systemBus().disconnect(MCE_SERVICE,
MCE_SIGNAL_PATH,
MCE_SIGNAL_IF,
MCE_DISPLAY_SIG,
priv,
d,
SLOT(slotDisplayStateChanged(QString)));
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/devicestate/displaystate.h
Expand Up @@ -32,7 +32,6 @@
*/
#ifndef DISPLAYSTATE_H
#define DISPLAYSTATE_H
#include "system_global.h"
#include <QtCore/qobject.h>

QT_BEGIN_HEADER
Expand Down Expand Up @@ -97,13 +96,12 @@ class DisplayStateMonitor : public QObject

private:
Q_DISABLE_COPY(DisplayStateMonitor)
MEEGO_DECLARE_PRIVATE(DisplayStateMonitor)
Q_DECLARE_PRIVATE(DisplayStateMonitor)
DisplayStateMonitorPrivate *d_ptr;
};

} //DeviceState namespace

QT_END_HEADER

#endif /* DISPLAYSTATE_H */

// End of file
1 change: 0 additions & 1 deletion src/devicestate/displaystate_p.h
Expand Up @@ -41,7 +41,6 @@ namespace DeviceState
class DisplayStateMonitorPrivate : public QObject
{
Q_OBJECT;
MEEGO_DECLARE_PUBLIC(DisplayStateMonitor)

public:
DisplayStateMonitorPrivate() {
Expand Down
2 changes: 0 additions & 2 deletions src/devicestate/ipcinterface_p.h
Expand Up @@ -33,8 +33,6 @@
#ifndef IPCINTERFACE_P_H
#define IPCINTERFACE_P_H

#include "system_global.h"

#include <QDBusAbstractInterface>

namespace DeviceState {
Expand Down

0 comments on commit 14f8292

Please sign in to comment.