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
1=== modified file 'online-accounts-service/utils.cpp'
2--- online-accounts-service/utils.cpp 2016-10-04 07:18:05 +0000
3+++ online-accounts-service/utils.cpp 2016-11-17 08:37:38 +0000
4@@ -31,11 +31,21 @@
5
6 QString apparmorProfileOfPeer(const QDBusMessage &message)
7 {
8+ static QString ourProfile;
9+
10 QString uniqueConnectionId = message.service();
11 /* This is mainly for unit tests: real messages on the session bus always
12 * have a service name. */
13 if (uniqueConnectionId.isEmpty()) return QString();
14
15+ if (ourProfile.isEmpty()) {
16+ char *label = NULL;
17+ char *mode = NULL;
18+ aa_getcon(&label, &mode);
19+ ourProfile = QString::fromUtf8(label);
20+ free(label);
21+ }
22+
23 QString appId;
24
25 QDBusMessage msg =
26@@ -54,6 +64,10 @@
27 if (!context.isEmpty()) {
28 aa_splitcon(context.data(), NULL);
29 appId = QString::fromUtf8(context);
30+ if (appId == ourProfile) {
31+ qDebug() << "Same profile as ourselves, assuming unconfined";
32+ appId = "unconfined";
33+ }
34 }
35 qDebug() << "App ID:" << appId;
36 } else {
37
38=== modified file 'online-accounts-ui/dialog-request.cpp'
39--- online-accounts-ui/dialog-request.cpp 2016-04-07 12:57:06 +0000
40+++ online-accounts-ui/dialog-request.cpp 2016-11-17 08:37:38 +0000
41@@ -180,7 +180,8 @@
42 QObject::connect(m_dialog, SIGNAL(finished(int)),
43 this, SLOT(onFinished()));
44
45- m_dialog->engine()->addImportPath(PLUGIN_PRIVATE_MODULE_DIR);
46+ m_dialog->engine()->addImportPath(q->mountPoint() +
47+ PLUGIN_PRIVATE_MODULE_DIR);
48 m_dialog->rootContext()->setContextProperty("request", this);
49 m_dialog->setSource(QUrl("qrc:/qml/SignOnUiDialog.qml"));
50 q->setWindow(m_dialog);
51
52=== modified file 'online-accounts-ui/online-accounts-ui.pro'
53--- online-accounts-ui/online-accounts-ui.pro 2015-04-27 21:01:41 +0000
54+++ online-accounts-ui/online-accounts-ui.pro 2016-11-17 08:37:38 +0000
55@@ -49,7 +49,6 @@
56 i18n.cpp \
57 ipc.cpp \
58 main.cpp \
59- panel-request.cpp \
60 provider-request.cpp \
61 request.cpp \
62 signonui-request.cpp \
63@@ -63,7 +62,6 @@
64 dialog-request.h \
65 i18n.h \
66 ipc.h \
67- panel-request.h \
68 provider-request.h \
69 request.h \
70 signonui-request.h \
71
72=== removed file 'online-accounts-ui/panel-request.cpp'
73--- online-accounts-ui/panel-request.cpp 2014-10-03 14:56:11 +0000
74+++ online-accounts-ui/panel-request.cpp 1970-01-01 00:00:00 +0000
75@@ -1,129 +0,0 @@
76-/*
77- * Copyright (C) 2013 Canonical Ltd.
78- *
79- * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
80- *
81- * This file is part of online-accounts-ui
82- *
83- * This program is free software: you can redistribute it and/or modify it
84- * under the terms of the GNU General Public License version 3, as published
85- * by the Free Software Foundation.
86- *
87- * This program is distributed in the hope that it will be useful, but
88- * WITHOUT ANY WARRANTY; without even the implied warranties of
89- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
90- * PURPOSE. See the GNU General Public License for more details.
91- *
92- * You should have received a copy of the GNU General Public License along
93- * with this program. If not, see <http://www.gnu.org/licenses/>.
94- */
95-
96-#include "debug.h"
97-#include "globals.h"
98-#include "panel-request.h"
99-
100-#include <QDesktopServices>
101-#include <QGuiApplication>
102-#include <QStandardPaths>
103-#include <QQmlContext>
104-#include <QQmlEngine>
105-#include <QQuickView>
106-
107-using namespace OnlineAccountsUi;
108-
109-namespace OnlineAccountsUi {
110-
111-class PanelRequestPrivate: public QObject
112-{
113- Q_OBJECT
114- Q_DECLARE_PUBLIC(PanelRequest)
115-
116-public:
117- PanelRequestPrivate(PanelRequest *request);
118- ~PanelRequestPrivate();
119-
120- void start();
121-
122-private Q_SLOTS:
123- void onWindowVisibleChanged(bool visible);
124-
125-private:
126- mutable PanelRequest *q_ptr;
127- QQuickView *m_view;
128-};
129-
130-} // namespace
131-
132-PanelRequestPrivate::PanelRequestPrivate(PanelRequest *request):
133- QObject(request),
134- q_ptr(request),
135- m_view(0)
136-{
137-}
138-
139-PanelRequestPrivate::~PanelRequestPrivate()
140-{
141- DEBUG() << "view:" << m_view;
142- /* TODO Uncomment this once QTBUG-40766 is resolved:
143- delete m_view;
144- */
145-}
146-
147-void PanelRequestPrivate::start()
148-{
149- Q_Q(PanelRequest);
150-
151- m_view = new QQuickView;
152- QObject::connect(m_view, SIGNAL(visibleChanged(bool)),
153- this, SLOT(onWindowVisibleChanged(bool)));
154- m_view->setResizeMode(QQuickView::SizeRootObjectToView);
155- m_view->engine()->addImportPath(PLUGIN_PRIVATE_MODULE_DIR);
156-
157- QQmlContext *context = m_view->rootContext();
158-
159- context->setContextProperty("systemQmlPluginPath",
160- QUrl::fromLocalFile(OAU_PLUGIN_DIR));
161- context->setContextProperty("localQmlPluginPath",
162- QUrl::fromLocalFile(QStandardPaths::writableLocation(
163- QStandardPaths::GenericDataLocation) +
164- "/accounts/qml-plugins/"));
165- context->setContextProperty("pluginOptions", QVariantMap());
166- context->setContextProperty("mainWindow", m_view);
167-
168- m_view->setSource(QUrl(QStringLiteral("qrc:/qml/MainPage.qml")));
169- q->setWindow(m_view);
170-}
171-
172-void PanelRequestPrivate::onWindowVisibleChanged(bool visible)
173-{
174- Q_Q(PanelRequest);
175-
176- DEBUG() << visible;
177-
178- if (!visible) {
179- q->setResult(QVariantMap());
180- }
181-}
182-
183-PanelRequest::PanelRequest(const QString &interface,
184- int id,
185- const QString &clientProfile,
186- const QVariantMap &parameters,
187- QObject *parent):
188- Request(interface, id, clientProfile, parameters, parent),
189- d_ptr(new PanelRequestPrivate(this))
190-{
191-}
192-
193-PanelRequest::~PanelRequest()
194-{
195-}
196-
197-void PanelRequest::start()
198-{
199- Q_D(PanelRequest);
200- Request::start();
201- d->start();
202-}
203-
204-#include "panel-request.moc"
205
206=== removed file 'online-accounts-ui/panel-request.h'
207--- online-accounts-ui/panel-request.h 2014-08-07 13:41:03 +0000
208+++ online-accounts-ui/panel-request.h 1970-01-01 00:00:00 +0000
209@@ -1,50 +0,0 @@
210-/*
211- * Copyright (C) 2013-2014 Canonical Ltd.
212- *
213- * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
214- *
215- * This file is part of online-accounts-ui
216- *
217- * This program is free software: you can redistribute it and/or modify it
218- * under the terms of the GNU General Public License version 3, as published
219- * by the Free Software Foundation.
220- *
221- * This program is distributed in the hope that it will be useful, but
222- * WITHOUT ANY WARRANTY; without even the implied warranties of
223- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
224- * PURPOSE. See the GNU General Public License for more details.
225- *
226- * You should have received a copy of the GNU General Public License along
227- * with this program. If not, see <http://www.gnu.org/licenses/>.
228- */
229-
230-#ifndef OAU_PANEL_REQUEST_H
231-#define OAU_PANEL_REQUEST_H
232-
233-#include "request.h"
234-
235-namespace OnlineAccountsUi {
236-
237-class PanelRequestPrivate;
238-class PanelRequest: public Request
239-{
240- Q_OBJECT
241-
242-public:
243- explicit PanelRequest(const QString &interface,
244- int id,
245- const QString &clientProfile,
246- const QVariantMap &parameters,
247- QObject *parent = 0);
248- ~PanelRequest();
249-
250- void start() Q_DECL_OVERRIDE;
251-
252-private:
253- PanelRequestPrivate *d_ptr;
254- Q_DECLARE_PRIVATE(PanelRequest)
255-};
256-
257-} // namespace
258-
259-#endif // OAU_PANEL_REQUEST_H
260
261=== modified file 'online-accounts-ui/provider-request.cpp'
262--- online-accounts-ui/provider-request.cpp 2016-06-23 13:18:47 +0000
263+++ online-accounts-ui/provider-request.cpp 2016-11-17 08:37:38 +0000
264@@ -123,8 +123,9 @@
265 QObject::connect(m_view, SIGNAL(visibleChanged(bool)),
266 this, SLOT(onWindowVisibleChanged(bool)));
267 m_view->setResizeMode(QQuickView::SizeRootObjectToView);
268+ QString mountPoint = q->mountPoint();
269 QQmlEngine *engine = m_view->engine();
270- engine->addImportPath(PLUGIN_PRIVATE_MODULE_DIR);
271+ engine->addImportPath(mountPoint + PLUGIN_PRIVATE_MODULE_DIR);
272
273 /* If the plugin comes from a click package, also add
274 * <package-dir>/lib
275@@ -142,7 +143,7 @@
276 QQmlContext *context = m_view->rootContext();
277
278 context->setContextProperty("systemQmlPluginPath",
279- QUrl::fromLocalFile(OAU_PLUGIN_DIR));
280+ QUrl::fromLocalFile(mountPoint + OAU_PLUGIN_DIR));
281 context->setContextProperty("localQmlPluginPath",
282 QUrl::fromLocalFile(QStandardPaths::writableLocation(
283 QStandardPaths::GenericDataLocation) +
284
285=== modified file 'online-accounts-ui/request.cpp'
286--- online-accounts-ui/request.cpp 2015-06-24 14:58:01 +0000
287+++ online-accounts-ui/request.cpp 2016-11-17 08:37:38 +0000
288@@ -21,11 +21,11 @@
289 #include "debug.h"
290 // TODO #include "dialog-request.h"
291 #include "globals.h"
292-#include "panel-request.h"
293 #include "provider-request.h"
294 #include "request.h"
295 #include "signonui-request.h"
296
297+#include <QFile>
298 #include <QPointer>
299
300 using namespace OnlineAccountsUi;
301@@ -298,4 +298,10 @@
302 }
303 }
304
305+QString Request::mountPoint() const
306+{
307+ return qEnvironmentVariableIsSet("SNAP") ?
308+ QFile::decodeName(qgetenv("SNAP")) : "";
309+}
310+
311 #include "request.moc"
312
313=== modified file 'online-accounts-ui/request.h'
314--- online-accounts-ui/request.h 2014-11-21 13:50:15 +0000
315+++ online-accounts-ui/request.h 2016-11-17 08:37:38 +0000
316@@ -71,6 +71,8 @@
317 virtual void setWindow(QWindow *window);
318 void setDelay(int delay);
319
320+ QString mountPoint() const;
321+
322 protected Q_SLOTS:
323 void fail(const QString &name, const QString &message);
324 virtual void setCanceled();
325
326=== modified file 'tests/online-accounts-ui/mock/request-mock.cpp'
327--- tests/online-accounts-ui/mock/request-mock.cpp 2015-06-22 14:55:14 +0000
328+++ tests/online-accounts-ui/mock/request-mock.cpp 2016-11-17 08:37:38 +0000
329@@ -150,3 +150,8 @@
330 d->m_inProgress = false;
331 }
332 }
333+
334+QString Request::mountPoint() const
335+{
336+ return "";
337+}

Subscribers

People subscribed via source and target branches