Merge lp:~mardy/ubuntu-system-settings-online-accounts/paths-1642225 into lp:ubuntu-system-settings-online-accounts

Proposed by Alberto Mardegan
Status: Merged
Approved by: Marcus Tomlinson
Approved revision: 410
Merged at revision: 407
Proposed branch: lp:~mardy/ubuntu-system-settings-online-accounts/paths-1642225
Merge into: lp:ubuntu-system-settings-online-accounts
Diff against target: 337 lines (+33/-185)
9 files modified
online-accounts-service/utils.cpp (+14/-0)
online-accounts-ui/dialog-request.cpp (+2/-1)
online-accounts-ui/online-accounts-ui.pro (+0/-2)
online-accounts-ui/panel-request.cpp (+0/-129)
online-accounts-ui/panel-request.h (+0/-50)
online-accounts-ui/provider-request.cpp (+3/-2)
online-accounts-ui/request.cpp (+7/-1)
online-accounts-ui/request.h (+2/-0)
tests/online-accounts-ui/mock/request-mock.cpp (+5/-0)
To merge this branch: bzr merge lp:~mardy/ubuntu-system-settings-online-accounts/paths-1642225
Reviewer Review Type Date Requested Status
Marcus Tomlinson (community) Approve
Review via email: mp+311009@code.launchpad.net

Commit message

Support running inside a snap

- If the $SNAP variable is set, prefix that to absolute paths
- If the client is running under the same confinement as our service (that is, it's in the same snap) treat it as unconfined.

Description of the change

Support running inside a snap

- If the $SNAP variable is set, prefix that to absolute paths
- If the client is running under the same confinement as our service (that is, it's in the same snap) treat it as unconfined.

To post a comment you must log in.
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Looks good, will test this in a moment. One inline comment so long.

review: Needs Fixing
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Hey, so with this fix I now see the UbuntuOne login page with email / password boxes etc. But when I enter my details and hit "Sign In", I get this error in red at the top:

GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name io.snapcraft.SnapdLoginService was not provided by any .service files

410. By Alberto Mardegan

Use QFile::decodeName

Revision history for this message
Alberto Mardegan (mardy) wrote :

Updated to use QFile::decodeName()

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'online-accounts-service/utils.cpp'
--- online-accounts-service/utils.cpp 2016-10-04 07:18:05 +0000
+++ online-accounts-service/utils.cpp 2016-11-17 08:37:38 +0000
@@ -31,11 +31,21 @@
3131
32QString apparmorProfileOfPeer(const QDBusMessage &message)32QString apparmorProfileOfPeer(const QDBusMessage &message)
33{33{
34 static QString ourProfile;
35
34 QString uniqueConnectionId = message.service();36 QString uniqueConnectionId = message.service();
35 /* This is mainly for unit tests: real messages on the session bus always37 /* This is mainly for unit tests: real messages on the session bus always
36 * have a service name. */38 * have a service name. */
37 if (uniqueConnectionId.isEmpty()) return QString();39 if (uniqueConnectionId.isEmpty()) return QString();
3840
41 if (ourProfile.isEmpty()) {
42 char *label = NULL;
43 char *mode = NULL;
44 aa_getcon(&label, &mode);
45 ourProfile = QString::fromUtf8(label);
46 free(label);
47 }
48
39 QString appId;49 QString appId;
4050
41 QDBusMessage msg =51 QDBusMessage msg =
@@ -54,6 +64,10 @@
54 if (!context.isEmpty()) {64 if (!context.isEmpty()) {
55 aa_splitcon(context.data(), NULL);65 aa_splitcon(context.data(), NULL);
56 appId = QString::fromUtf8(context);66 appId = QString::fromUtf8(context);
67 if (appId == ourProfile) {
68 qDebug() << "Same profile as ourselves, assuming unconfined";
69 appId = "unconfined";
70 }
57 }71 }
58 qDebug() << "App ID:" << appId;72 qDebug() << "App ID:" << appId;
59 } else {73 } else {
6074
=== modified file 'online-accounts-ui/dialog-request.cpp'
--- online-accounts-ui/dialog-request.cpp 2016-04-07 12:57:06 +0000
+++ online-accounts-ui/dialog-request.cpp 2016-11-17 08:37:38 +0000
@@ -180,7 +180,8 @@
180 QObject::connect(m_dialog, SIGNAL(finished(int)),180 QObject::connect(m_dialog, SIGNAL(finished(int)),
181 this, SLOT(onFinished()));181 this, SLOT(onFinished()));
182182
183 m_dialog->engine()->addImportPath(PLUGIN_PRIVATE_MODULE_DIR);183 m_dialog->engine()->addImportPath(q->mountPoint() +
184 PLUGIN_PRIVATE_MODULE_DIR);
184 m_dialog->rootContext()->setContextProperty("request", this);185 m_dialog->rootContext()->setContextProperty("request", this);
185 m_dialog->setSource(QUrl("qrc:/qml/SignOnUiDialog.qml"));186 m_dialog->setSource(QUrl("qrc:/qml/SignOnUiDialog.qml"));
186 q->setWindow(m_dialog);187 q->setWindow(m_dialog);
187188
=== modified file 'online-accounts-ui/online-accounts-ui.pro'
--- online-accounts-ui/online-accounts-ui.pro 2015-04-27 21:01:41 +0000
+++ online-accounts-ui/online-accounts-ui.pro 2016-11-17 08:37:38 +0000
@@ -49,7 +49,6 @@
49 i18n.cpp \49 i18n.cpp \
50 ipc.cpp \50 ipc.cpp \
51 main.cpp \51 main.cpp \
52 panel-request.cpp \
53 provider-request.cpp \52 provider-request.cpp \
54 request.cpp \53 request.cpp \
55 signonui-request.cpp \54 signonui-request.cpp \
@@ -63,7 +62,6 @@
63 dialog-request.h \62 dialog-request.h \
64 i18n.h \63 i18n.h \
65 ipc.h \64 ipc.h \
66 panel-request.h \
67 provider-request.h \65 provider-request.h \
68 request.h \66 request.h \
69 signonui-request.h \67 signonui-request.h \
7068
=== removed file 'online-accounts-ui/panel-request.cpp'
--- online-accounts-ui/panel-request.cpp 2014-10-03 14:56:11 +0000
+++ online-accounts-ui/panel-request.cpp 1970-01-01 00:00:00 +0000
@@ -1,129 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd.
3 *
4 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
5 *
6 * This file is part of online-accounts-ui
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "debug.h"
22#include "globals.h"
23#include "panel-request.h"
24
25#include <QDesktopServices>
26#include <QGuiApplication>
27#include <QStandardPaths>
28#include <QQmlContext>
29#include <QQmlEngine>
30#include <QQuickView>
31
32using namespace OnlineAccountsUi;
33
34namespace OnlineAccountsUi {
35
36class PanelRequestPrivate: public QObject
37{
38 Q_OBJECT
39 Q_DECLARE_PUBLIC(PanelRequest)
40
41public:
42 PanelRequestPrivate(PanelRequest *request);
43 ~PanelRequestPrivate();
44
45 void start();
46
47private Q_SLOTS:
48 void onWindowVisibleChanged(bool visible);
49
50private:
51 mutable PanelRequest *q_ptr;
52 QQuickView *m_view;
53};
54
55} // namespace
56
57PanelRequestPrivate::PanelRequestPrivate(PanelRequest *request):
58 QObject(request),
59 q_ptr(request),
60 m_view(0)
61{
62}
63
64PanelRequestPrivate::~PanelRequestPrivate()
65{
66 DEBUG() << "view:" << m_view;
67 /* TODO Uncomment this once QTBUG-40766 is resolved:
68 delete m_view;
69 */
70}
71
72void PanelRequestPrivate::start()
73{
74 Q_Q(PanelRequest);
75
76 m_view = new QQuickView;
77 QObject::connect(m_view, SIGNAL(visibleChanged(bool)),
78 this, SLOT(onWindowVisibleChanged(bool)));
79 m_view->setResizeMode(QQuickView::SizeRootObjectToView);
80 m_view->engine()->addImportPath(PLUGIN_PRIVATE_MODULE_DIR);
81
82 QQmlContext *context = m_view->rootContext();
83
84 context->setContextProperty("systemQmlPluginPath",
85 QUrl::fromLocalFile(OAU_PLUGIN_DIR));
86 context->setContextProperty("localQmlPluginPath",
87 QUrl::fromLocalFile(QStandardPaths::writableLocation(
88 QStandardPaths::GenericDataLocation) +
89 "/accounts/qml-plugins/"));
90 context->setContextProperty("pluginOptions", QVariantMap());
91 context->setContextProperty("mainWindow", m_view);
92
93 m_view->setSource(QUrl(QStringLiteral("qrc:/qml/MainPage.qml")));
94 q->setWindow(m_view);
95}
96
97void PanelRequestPrivate::onWindowVisibleChanged(bool visible)
98{
99 Q_Q(PanelRequest);
100
101 DEBUG() << visible;
102
103 if (!visible) {
104 q->setResult(QVariantMap());
105 }
106}
107
108PanelRequest::PanelRequest(const QString &interface,
109 int id,
110 const QString &clientProfile,
111 const QVariantMap &parameters,
112 QObject *parent):
113 Request(interface, id, clientProfile, parameters, parent),
114 d_ptr(new PanelRequestPrivate(this))
115{
116}
117
118PanelRequest::~PanelRequest()
119{
120}
121
122void PanelRequest::start()
123{
124 Q_D(PanelRequest);
125 Request::start();
126 d->start();
127}
128
129#include "panel-request.moc"
1300
=== removed file 'online-accounts-ui/panel-request.h'
--- online-accounts-ui/panel-request.h 2014-08-07 13:41:03 +0000
+++ online-accounts-ui/panel-request.h 1970-01-01 00:00:00 +0000
@@ -1,50 +0,0 @@
1/*
2 * Copyright (C) 2013-2014 Canonical Ltd.
3 *
4 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
5 *
6 * This file is part of online-accounts-ui
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef OAU_PANEL_REQUEST_H
22#define OAU_PANEL_REQUEST_H
23
24#include "request.h"
25
26namespace OnlineAccountsUi {
27
28class PanelRequestPrivate;
29class PanelRequest: public Request
30{
31 Q_OBJECT
32
33public:
34 explicit PanelRequest(const QString &interface,
35 int id,
36 const QString &clientProfile,
37 const QVariantMap &parameters,
38 QObject *parent = 0);
39 ~PanelRequest();
40
41 void start() Q_DECL_OVERRIDE;
42
43private:
44 PanelRequestPrivate *d_ptr;
45 Q_DECLARE_PRIVATE(PanelRequest)
46};
47
48} // namespace
49
50#endif // OAU_PANEL_REQUEST_H
510
=== modified file 'online-accounts-ui/provider-request.cpp'
--- online-accounts-ui/provider-request.cpp 2016-06-23 13:18:47 +0000
+++ online-accounts-ui/provider-request.cpp 2016-11-17 08:37:38 +0000
@@ -123,8 +123,9 @@
123 QObject::connect(m_view, SIGNAL(visibleChanged(bool)),123 QObject::connect(m_view, SIGNAL(visibleChanged(bool)),
124 this, SLOT(onWindowVisibleChanged(bool)));124 this, SLOT(onWindowVisibleChanged(bool)));
125 m_view->setResizeMode(QQuickView::SizeRootObjectToView);125 m_view->setResizeMode(QQuickView::SizeRootObjectToView);
126 QString mountPoint = q->mountPoint();
126 QQmlEngine *engine = m_view->engine();127 QQmlEngine *engine = m_view->engine();
127 engine->addImportPath(PLUGIN_PRIVATE_MODULE_DIR);128 engine->addImportPath(mountPoint + PLUGIN_PRIVATE_MODULE_DIR);
128129
129 /* If the plugin comes from a click package, also add130 /* If the plugin comes from a click package, also add
130 * <package-dir>/lib131 * <package-dir>/lib
@@ -142,7 +143,7 @@
142 QQmlContext *context = m_view->rootContext();143 QQmlContext *context = m_view->rootContext();
143144
144 context->setContextProperty("systemQmlPluginPath",145 context->setContextProperty("systemQmlPluginPath",
145 QUrl::fromLocalFile(OAU_PLUGIN_DIR));146 QUrl::fromLocalFile(mountPoint + OAU_PLUGIN_DIR));
146 context->setContextProperty("localQmlPluginPath",147 context->setContextProperty("localQmlPluginPath",
147 QUrl::fromLocalFile(QStandardPaths::writableLocation(148 QUrl::fromLocalFile(QStandardPaths::writableLocation(
148 QStandardPaths::GenericDataLocation) +149 QStandardPaths::GenericDataLocation) +
149150
=== modified file 'online-accounts-ui/request.cpp'
--- online-accounts-ui/request.cpp 2015-06-24 14:58:01 +0000
+++ online-accounts-ui/request.cpp 2016-11-17 08:37:38 +0000
@@ -21,11 +21,11 @@
21#include "debug.h"21#include "debug.h"
22// TODO #include "dialog-request.h"22// TODO #include "dialog-request.h"
23#include "globals.h"23#include "globals.h"
24#include "panel-request.h"
25#include "provider-request.h"24#include "provider-request.h"
26#include "request.h"25#include "request.h"
27#include "signonui-request.h"26#include "signonui-request.h"
2827
28#include <QFile>
29#include <QPointer>29#include <QPointer>
3030
31using namespace OnlineAccountsUi;31using namespace OnlineAccountsUi;
@@ -298,4 +298,10 @@
298 }298 }
299}299}
300300
301QString Request::mountPoint() const
302{
303 return qEnvironmentVariableIsSet("SNAP") ?
304 QFile::decodeName(qgetenv("SNAP")) : "";
305}
306
301#include "request.moc"307#include "request.moc"
302308
=== modified file 'online-accounts-ui/request.h'
--- online-accounts-ui/request.h 2014-11-21 13:50:15 +0000
+++ online-accounts-ui/request.h 2016-11-17 08:37:38 +0000
@@ -71,6 +71,8 @@
71 virtual void setWindow(QWindow *window);71 virtual void setWindow(QWindow *window);
72 void setDelay(int delay);72 void setDelay(int delay);
7373
74 QString mountPoint() const;
75
74protected Q_SLOTS:76protected Q_SLOTS:
75 void fail(const QString &name, const QString &message);77 void fail(const QString &name, const QString &message);
76 virtual void setCanceled();78 virtual void setCanceled();
7779
=== modified file 'tests/online-accounts-ui/mock/request-mock.cpp'
--- tests/online-accounts-ui/mock/request-mock.cpp 2015-06-22 14:55:14 +0000
+++ tests/online-accounts-ui/mock/request-mock.cpp 2016-11-17 08:37:38 +0000
@@ -150,3 +150,8 @@
150 d->m_inProgress = false;150 d->m_inProgress = false;
151 }151 }
152}152}
153
154QString Request::mountPoint() const
155{
156 return "";
157}

Subscribers

People subscribed via source and target branches