Merge lp:~mterry/ubuntu-system-settings/split-bg into lp:ubuntu-system-settings

Proposed by Michael Terry
Status: Merged
Approved by: Iain Lane
Approved revision: 729
Merged at revision: 726
Proposed branch: lp:~mterry/ubuntu-system-settings/split-bg
Merge into: lp:ubuntu-system-settings
Diff against target: 148 lines (+70/-7)
4 files modified
debian/ubuntu-system-settings.postrm (+9/-0)
plugins/background/background.cpp (+53/-5)
plugins/background/background.h (+4/-0)
plugins/background/utilities.js (+4/-2)
To merge this branch: bzr merge lp:~mterry/ubuntu-system-settings/split-bg
Reviewer Review Type Date Requested Status
Iain Lane Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+222092@code.launchpad.net

Commit message

Use XDG_GREETER_DATA_DIR to store background files in a folder that the greeter can also read. This fixes the recent regression in not being able to choose a ContentHub file for the welcome screen.

Description of the change

Use XDG_GREETER_DATA_DIR to store background files in a folder that the greeter can also read.

The greeter is a separate user and often can't read files inside the user's $HOME. But ContentHub puts files there. So we need to move those files to the greeter location.

If the package is purged, we clean up after ourselves.

I didn't worry about migration. If we wanted to do it, I imagine on startup, we could move files from $HOME to the greeter data dir and also make sure that the AccountsService field is updated.

== Checklist ==

 * Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
 - Yes

 * Did you build your software in a clean sbuild/pbuilder chroot or ppa?
 - Yes

 * Did you build your software in a clean sbuild/pbuilder armhf chroot or ppa?
 - Yes

 * Has your component "TestPlan” been executed successfully on emulator, N4?
 - Yes

 * Has a 5 minute exploratory testing run been executed on N4?
 - Yes

 * If you changed the packaging (debian), did you subscribe a core-dev to this MP?
 - I am a core-dev

 * If you changed the UI, did you subscribe the design-reviewers to this MP?
 - NA

 * What components might get impacted by your changes?
 - None really, though we rely on behavior of LightDM

 * Have you requested review by the teams of these owning components?
 - NA

To post a comment you must log in.
727. By Michael Terry

Remove unnecessary Qml exposure

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:726
http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-ci/856/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/672
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/615
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-amd64-ci/48
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/48
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/48/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-i386-ci/48
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/1104
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1283
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1283/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/8092
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/547
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/754
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/754/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-system-settings-ci/856/rebuild

review: Approve (continuous-integration)
Revision history for this message
Iain Lane (laney) wrote :

Cheers. I tried a review using the fancy inline comments, hope it worked.

Somehow I've not heard of this XDG_GREETER_DATA_DIR before. Is it actually an XDG standardised variable? I don't find it mentioned on fdo.

review: Needs Fixing
Revision history for this message
Michael Terry (mterry) wrote :

> Somehow I've not heard of this XDG_GREETER_DATA_DIR before.
> Is it actually an XDG standardised variable? I don't find
> it mentioned on fdo.

It's new in trusty's LightDM. And no, it's not an actual XDG standardized variable. LightDM just has a habit of taking the XDG namespace in vain.

Will fix up branch and try responding inline.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:727
http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-ci/857/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/677
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/620
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-amd64-ci/49
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/49
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/49/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-i386-ci/49
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/1109
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1288
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1288/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/8097
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/552
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/759
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/759/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-system-settings-ci/857/rebuild

review: Approve (continuous-integration)
728. By Michael Terry

Support modifying gsettings value as well as the AccountsService one

Revision history for this message
Michael Terry (mterry) wrote :

OK, addressed comments and also use the same logic for gsettings chooser (both sets of files should live in same place for ease of browsing them and sharing/comparing values).

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:728
http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-ci/858/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/680
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/623
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-amd64-ci/50
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/50
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/50/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-i386-ci/50
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/1111
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1292
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1292/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/8103
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/554
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/762
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/762/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-system-settings-ci/858/rebuild

review: Approve (continuous-integration)
Revision history for this message
Iain Lane (laney) wrote :

I think I'd rather if we only used this location when necessary, i.e. when setting the greeter background or when they are using the same one. You should be able to modify utilities.js to do that.

Revision history for this message
Michael Terry (mterry) wrote :

Well, I thought it was nicer if there was one directory where all images were kept, rather than trying to merge the greeter and ContentHub directory contents when showing past custom backgrounds to the user. It also made the urls more comparable.

But I'm not wedded to that. I can leave the images in ContentHub if you prefer for gsettings.

Revision history for this message
Iain Lane (laney) wrote :

On Thu, Jun 05, 2014 at 04:56:44PM -0000, Michael Terry wrote:
> Well, I thought it was nicer if there was one directory where all images were kept, rather than trying to merge the greeter and ContentHub directory contents when showing past custom backgrounds to the user. It also made the urls more comparable.
>
> But I'm not wedded to that. I can leave the images in ContentHub if you prefer for gsettings.

For me the idea is that things are only shared with the greeter if it's
necessary - that's putting things in AS only when the greeter needs
them, and now putting files in this directory too.

I did forget about the grid though, so there will be two custom
background directories which updateCustomBackgrounds() will need to take
care of. I think it'd be fine to point GSettings to an image in the
greeter directory if it's already there. Another thing is that we'd need
to do a move if the user selects 'same background' and we need to copy
the dash bg to the greeter. This one shouldn't be too hard.

Hrm. What about deleting from the greeter directory? AFAIK currently
it'll just grow with no easy way for the user to get rid of stuff in
there.

Do what you think is best for the dash background case. I won't insist
on it.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Revision history for this message
Michael Terry (mterry) wrote :

> Hrm. What about deleting from the greeter directory? AFAIK currently
> it'll just grow with no easy way for the user to get rid of stuff in
> there.

What happens with the ContentHub files currently? I didn't see any cleanup code there.

Revision history for this message
Iain Lane (laney) wrote :

On Thu, Jun 05, 2014 at 05:41:07PM -0000, Michael Terry wrote:
> > Hrm. What about deleting from the greeter directory? AFAIK currently
> > it'll just grow with no easy way for the user to get rid of stuff in
> > there.
>
> What happens with the ContentHub files currently? I didn't see any cleanup code there.

Indeed not, maybe it's just something to remember to do when resetting
is implemented.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

729. By Michael Terry

Allow looking in both local ContentHub folder as well as greeter data folder, and de-duplicate as needed

Revision history for this message
Michael Terry (mterry) wrote :

OK, I've changed it so that if you are just setting gsettings individually, we don't need to promote it into a greeter file. And the picker grid scans both locations.

But if you are setting the welcome screen or both, we do promote.

We also de-duplicate in the case of setting gsettings individually to a file that you previously promoted to the greeter (so you don't have both copies showing in the picker grid).

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:729
http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-ci/862/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/705
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/653
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-amd64-ci/54
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/54
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/54/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-i386-ci/54
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/1133
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1335
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/1335/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/8143
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/581
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/792
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/792/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-system-settings-ci/862/rebuild

review: Approve (continuous-integration)
Revision history for this message
Iain Lane (laney) wrote :

Thanks for updating, looks good to me now. I'll just give it a quick check on the device before top approving.

review: Approve
Revision history for this message
Iain Lane (laney) wrote :

Looks good. I've got a followup because the same/different toggle is buggy, but that's not your fault. Thanks Mike.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'debian/ubuntu-system-settings.postrm'
2--- debian/ubuntu-system-settings.postrm 1970-01-01 00:00:00 +0000
3+++ debian/ubuntu-system-settings.postrm 2014-06-05 19:33:36 +0000
4@@ -0,0 +1,9 @@
5+#!/bin/sh
6+set -e
7+
8+if [ "$1" = "purge" ] ; then
9+ rm -rf /var/lib/lightdm-data/*/ubuntu-system-settings/
10+fi
11+
12+#DEBHELPER#
13+exit 0
14
15=== modified file 'plugins/background/background.cpp'
16--- plugins/background/background.cpp 2014-02-18 14:18:27 +0000
17+++ plugins/background/background.cpp 2014-06-05 19:33:36 +0000
18@@ -89,10 +89,10 @@
19 void Background::updateCustomBackgrounds()
20 {
21 m_customBackgrounds.clear();
22- QString customPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation)+"/Pictures";
23- QDir dir(customPath);
24- dir.setFilter(QDir::Files | QDir::NoSymLinks);
25- QFileInfoList tmpList = dir.entryInfoList();
26+ QFileInfoList tmpList;
27+ tmpList << getCustomBackgroundFolder().entryInfoList(QDir::Files | QDir::NoSymLinks);
28+ if (getCustomBackgroundFolder() != getContentHubFolder())
29+ tmpList << getContentHubFolder().entryInfoList(QDir::Files | QDir::NoSymLinks);
30 if (!tmpList.isEmpty())
31 {
32 foreach (QFileInfo f, tmpList)
33@@ -101,6 +101,54 @@
34 Q_EMIT customBackgroundsChanged();
35 }
36
37+QUrl Background::prepareBackgroundFile(const QUrl &url, bool shareWithGreeter)
38+{
39+ QUrl prepared = url;
40+
41+ if (getCustomBackgroundFolder() != getContentHubFolder() &&
42+ url.path().startsWith(getContentHubFolder().path()))
43+ {
44+ QDir backgroundFolder = getCustomBackgroundFolder();
45+ QUrl newPath = QUrl::fromLocalFile(backgroundFolder.path() + "/" + url.fileName());
46+
47+ if (QFile(newPath.path()).exists())
48+ {
49+ // The file already exists in the shared greeter data folder...
50+ // Likely we just pulled the same file from ContentHub again.
51+ // We don't want to show both versions in the picker grid, so just
52+ // promote it to greeter location so we still just have one copy.
53+ if (QFile(newPath.path()).remove())
54+ shareWithGreeter = true;
55+ }
56+
57+ // Move file from local ContentHub dump to shared greeter data folder
58+ if (shareWithGreeter &&
59+ QDir::root().mkpath(backgroundFolder.path()) &&
60+ QFile::rename(url.path(), newPath.path()))
61+ {
62+ updateCustomBackgrounds();
63+ prepared = newPath;
64+ }
65+ }
66+
67+ return prepared;
68+}
69+
70+QDir Background::getCustomBackgroundFolder()
71+{
72+ // We want a location we can share with the greeter
73+ QString dataDir(qgetenv("XDG_GREETER_DATA_DIR"));
74+ if (dataDir.isEmpty())
75+ return getContentHubFolder();
76+ else
77+ return dataDir + "/ubuntu-system-settings/Pictures";
78+}
79+
80+QDir Background::getContentHubFolder()
81+{
82+ return QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/Pictures";
83+}
84+
85 QStringList Background::ubuntuArt()
86 {
87 return m_ubuntuArt;
88@@ -132,7 +180,7 @@
89 if (file.isEmpty() || file.isNull())
90 return;
91
92- if (!file.contains(QStandardPaths::writableLocation(QStandardPaths::DataLocation)))
93+ if (!file.contains(getCustomBackgroundFolder().path()) && !file.contains(getContentHubFolder().path()))
94 return;
95
96 QUrl fileUri(file);
97
98=== modified file 'plugins/background/background.h'
99--- plugins/background/background.h 2014-02-18 14:18:27 +0000
100+++ plugins/background/background.h 2014-06-05 19:33:36 +0000
101@@ -24,6 +24,7 @@
102 #include "accountsservice.h"
103
104 #include <QDBusInterface>
105+#include <QDir>
106 #include <QObject>
107 #include <QProcess>
108 #include <QUrl>
109@@ -49,6 +50,7 @@
110 ~Background();
111 QString backgroundFile();
112 void setBackgroundFile(QUrl backgroundFile);
113+ Q_INVOKABLE QUrl prepareBackgroundFile(const QUrl &url, bool shareWithGreeter);
114 Q_INVOKABLE bool fileExists(const QString &file);
115 Q_INVOKABLE void rmFile(const QString &file);
116 QStringList customBackgrounds();
117@@ -70,6 +72,8 @@
118 void updateUbuntuArt();
119 QString m_backgroundFile;
120 QString getBackgroundFile();
121+ QDir getCustomBackgroundFolder();
122+ QDir getContentHubFolder();
123 };
124
125 #endif // BACKGROUND_H
126
127=== modified file 'plugins/background/utilities.js'
128--- plugins/background/utilities.js 2013-12-06 19:20:15 +0000
129+++ plugins/background/utilities.js 2014-06-05 19:33:36 +0000
130@@ -34,14 +34,16 @@
131 }
132
133 function updateWelcome(uri) {
134- backgroundPanel.backgroundFile = uri;
135+ backgroundPanel.backgroundFile = backgroundPanel.prepareBackgroundFile(uri, true);
136 }
137
138 function updateHome(uri) {
139- background.pictureUri = uri;
140+ background.pictureUri = backgroundPanel.prepareBackgroundFile(uri, false);
141 }
142
143 function updateBoth(uri) {
144+ // multiple prepares on a uri is fine
145+ uri = backgroundPanel.prepareBackgroundFile(uri, true);
146 updateWelcome(uri);
147 updateHome(uri);
148 }

Subscribers

People subscribed via source and target branches