Commit 64545be4 authored by spiiroin's avatar spiiroin

Merge branch 'jb43785_updates_enabled_permissions' into 'master'

Accept setUpdatesEnabled calls only from mce

See merge request !131
parents df532edc f8d94a77
......@@ -26,7 +26,7 @@ BuildRequires: pkgconfig(Qt5Sensors)
BuildRequires: pkgconfig(contentaction5)
BuildRequires: pkgconfig(mlite5) >= 0.2.19
BuildRequires: pkgconfig(mce) >= 1.22.0
BuildRequires: pkgconfig(mce-qt5) >= 1.2.0
BuildRequires: pkgconfig(mce-qt5) >= 1.4.0
BuildRequires: pkgconfig(keepalive)
BuildRequires: pkgconfig(dsme_dbus_if) >= 0.63.2
BuildRequires: pkgconfig(thermalmanager_dbus_if)
......
/***************************************************************************
**
** Copyright (C) 2013 Jolla Ltd.
** Contact: Aaron Kennedy <aaron.kennedy@jollamobile.com>
** Copyright (c) 2013-2019 Jolla Ltd.
** Copyright (c) 2019 Open Mobile Platform LLC.
**
** This file is part of lipstick.
**
......@@ -37,6 +37,8 @@
#include "hwcrenderstage.h"
#include <private/qguiapplication_p.h>
#include <QtGui/qpa/qplatformintegration.h>
#include <qmcenameowner.h>
#include <dbus/dbus-protocol.h>
LipstickCompositor *LipstickCompositor::m_instance = 0;
......@@ -59,6 +61,8 @@ LipstickCompositor::LipstickCompositor()
, m_onUpdatesDisabledUnfocusedWindowId(0)
, m_keymap(0)
, m_fakeRepaintTimerId(0)
, m_queuedSetUpdatesEnabledCalls()
, m_mceNameOwner(new QMceNameOwner(this))
{
setColor(Qt::black);
setRetainedSelectionEnabled(true);
......@@ -97,7 +101,12 @@ LipstickCompositor::LipstickCompositor()
HwcRenderStage::initialize(this);
setUpdatesEnabled(false);
QObject::connect(m_mceNameOwner, &QMceNameOwner::validChanged,
this, &LipstickCompositor::processQueuedSetUpdatesEnabledCalls);
QObject::connect(m_mceNameOwner, &QMceNameOwner::nameOwnerChanged,
this, &LipstickCompositor::processQueuedSetUpdatesEnabledCalls);
setUpdatesEnabledNow(false);
QTimer::singleShot(0, this, SLOT(initialize()));
setClientFullScreenHint(true);
......@@ -759,7 +768,7 @@ void LipstickCompositor::clipboardDataChanged()
overrideSelection(const_cast<QMimeData *>(mimeData));
}
void LipstickCompositor::setUpdatesEnabled(bool enabled)
void LipstickCompositor::setUpdatesEnabledNow(bool enabled)
{
if (m_updatesEnabled != enabled) {
m_updatesEnabled = enabled;
......@@ -801,6 +810,40 @@ void LipstickCompositor::setUpdatesEnabled(bool enabled)
}
}
void LipstickCompositor::setUpdatesEnabled(bool enabled)
{
if (!calledFromDBus()) {
setUpdatesEnabledNow(enabled);
} else {
if (message().isReplyRequired())
setDelayedReply(true);
m_queuedSetUpdatesEnabledCalls.append(QueuedSetUpdatesEnabledCall(connection(), message(), enabled));
QMetaObject::invokeMethod(this, "processQueuedSetUpdatesEnabledCalls", Qt::QueuedConnection);
}
}
void LipstickCompositor::processQueuedSetUpdatesEnabledCalls()
{
if (m_mceNameOwner->valid()) {
while (!m_queuedSetUpdatesEnabledCalls.isEmpty()) {
QueuedSetUpdatesEnabledCall queued(m_queuedSetUpdatesEnabledCalls.takeFirst());
if (queued.m_message.service() != m_mceNameOwner->nameOwner()) {
if (queued.m_message.isReplyRequired()) {
QDBusMessage reply(queued.m_message.createErrorReply(DBUS_ERROR_ACCESS_DENIED,
"Only mce is allowed to call this method"));
queued.m_connection.send(reply);
}
} else {
setUpdatesEnabledNow(queued.m_enable);
if (queued.m_message.isReplyRequired()) {
QDBusMessage reply(queued.m_message.createReply());
queued.m_connection.send(reply);
}
}
}
}
}
void LipstickCompositor::readContent()
{
m_recorder->recordFrame(this);
......
/***************************************************************************
**
** Copyright (C) 2013 Jolla Ltd.
** Contact: Aaron Kennedy <aaron.kennedy@jollamobile.com>
** Copyright (c) 2013-2019 Jolla Ltd.
** Copyright (c) 2019 Open Mobile Platform LLC.
**
** This file is part of lipstick.
**
......@@ -25,6 +25,9 @@
#include <QPointer>
#include <QTimer>
#include <MGConfItem>
#include <QDBusConnection>
#include <QDBusContext>
#include <QDBusMessage>
class WindowModel;
class LipstickCompositorWindow;
......@@ -32,13 +35,31 @@ class LipstickCompositorProcWindow;
class QOrientationSensor;
class LipstickRecorderManager;
class LipstickKeymap;
class QMceNameOwner;
namespace ContentAction {
class Action;
}
class LIPSTICK_EXPORT LipstickCompositor : public QQuickWindow, public QWaylandQuickCompositor,
public QQmlParserStatus
struct QueuedSetUpdatesEnabledCall
{
QueuedSetUpdatesEnabledCall(const QDBusConnection &connection, const QDBusMessage &message, bool enable)
: m_connection(connection)
, m_message(message)
, m_enable(enable)
{
}
QDBusConnection m_connection;
QDBusMessage m_message;
bool m_enable;
};
class LIPSTICK_EXPORT LipstickCompositor
: public QQuickWindow
, public QWaylandQuickCompositor
, public QQmlParserStatus
, public QDBusContext
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
......@@ -118,6 +139,7 @@ public:
bool completed();
void setUpdatesEnabledNow(bool enabled);
void setUpdatesEnabled(bool enabled);
QWaylandSurfaceView *createView(QWaylandSurface *surf) Q_DECL_OVERRIDE;
......@@ -183,6 +205,7 @@ private slots:
void onSurfaceDying();
void updateKeymap();
void initialize();
void processQueuedSetUpdatesEnabledCalls();
private:
friend class LipstickCompositorWindow;
......@@ -234,6 +257,8 @@ private:
LipstickKeymap *m_keymap;
int m_fakeRepaintTimerId;
QList<QueuedSetUpdatesEnabledCall> m_queuedSetUpdatesEnabledCalls;
QMceNameOwner *m_mceNameOwner;
};
#endif // LIPSTICKCOMPOSITOR_H
/***************************************************************************
**
** Copyright (c) 2013-2019 Jolla Ltd.
** Copyright (c) 2019 Open Mobile Platform LLC.
**
** This file is part of lipstick.
**
** This library is free software; you can redistribute it and/or
** modify it 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.
**
****************************************************************************/
#ifndef LIPSTICKCOMPOSITOR_STUB
#define LIPSTICKCOMPOSITOR_STUB
......@@ -374,7 +389,6 @@ QWaylandSurfaceView *LipstickCompositorStub::createView(QWaylandSurface *surf)
LipstickCompositorStub gDefaultLipstickCompositorStub;
LipstickCompositorStub *gLipstickCompositorStub = &gDefaultLipstickCompositorStub;
// 4. CREATE A PROXY WHICH CALLS THE STUB
LipstickCompositor::LipstickCompositor()
{
......@@ -633,4 +647,8 @@ QWaylandQuickCompositor::QWaylandQuickCompositor(QQuickWindow *, const char *, Q
{
}
void LipstickCompositor::processQueuedSetUpdatesEnabledCalls()
{
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment