Merge lp:~unity-api-team/unity-scopes-shell/wait-for-geoip-at-startup into lp:unity-scopes-shell

Proposed by Pete Woods
Status: Merged
Approved by: Marcus Tomlinson
Approved revision: 163
Merged at revision: 162
Proposed branch: lp:~unity-api-team/unity-scopes-shell/wait-for-geoip-at-startup
Merge into: lp:unity-scopes-shell
Diff against target: 139 lines (+43/-0)
7 files modified
src/Unity/locationservice.h (+2/-0)
src/Unity/scopes.cpp (+29/-0)
src/Unity/scopes.h (+3/-0)
src/Unity/ubuntulocationservice.cpp (+5/-0)
src/Unity/ubuntulocationservice.h (+2/-0)
tests/departmentstest.cpp (+1/-0)
tests/resultstest.cpp (+1/-0)
To merge this branch: bzr merge lp:~unity-api-team/unity-scopes-shell/wait-for-geoip-at-startup
Reviewer Review Type Date Requested Status
Marcus Tomlinson (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+238433@code.launchpad.net

Commit message

Wait for location data at startup (with 1 second timeout)

Description of the change

Wait for location data at startup (with 1 second timeout)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
160. By Paweł Stołowski

Don't query all favorite scopes on startup - query only next two scopes following current active. Fixes: 1374481
Approved by: PS Jenkins bot, Marcus Tomlinson

161. By PS Jenkins bot

Releasing 0.5.4+14.10.20141015-0ubuntu1

162. By Pete Woods

Wait for location data at startup (with 1 second timeout)

163. By Pete Woods

Don't wait for location in the longer tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Looks good. Tested a few reboots with the Nearby and Dashboard scopes favorited, and they seem to surface just fine now. Good work!

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

Tried again with News and Nearby (As described in the bug), and all looks good. (Tested on mako #91)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Unity/locationservice.h'
2--- src/Unity/locationservice.h 2014-07-25 15:30:02 +0000
3+++ src/Unity/locationservice.h 2014-10-16 09:00:44 +0000
4@@ -49,6 +49,8 @@
5
6 virtual unity::scopes::Location location() const = 0;
7
8+ virtual bool hasLocation() const = 0;
9+
10 virtual bool isActive() const = 0;
11
12 public Q_SLOTS:
13
14=== modified file 'src/Unity/scopes.cpp'
15--- src/Unity/scopes.cpp 2014-10-15 10:49:13 +0000
16+++ src/Unity/scopes.cpp 2014-10-16 09:00:44 +0000
17@@ -87,6 +87,7 @@
18
19 int Scopes::LIST_DELAY = -1;
20 const int Scopes::SCOPE_DELETE_DELAY = 3;
21+const int LOCATION_STARTUP_TIMEOUT = 1000;
22
23 class Scopes::Priv : public QObject {
24 Q_OBJECT
25@@ -290,6 +291,34 @@
26 m_cachedMetadata[QString::fromStdString(it->first)] = std::make_shared<unity::scopes::ScopeMetadata>(it->second);
27 }
28
29+ if (m_locationService->hasLocation() || qEnvironmentVariableIsSet("UNITY_SCOPES_NO_WAIT_LOCATION"))
30+ {
31+ // If we already have a location just query the scopes now
32+ completeDiscoveryFinished();
33+ }
34+ else
35+ {
36+ // Otherwise we have to wait for location data
37+ // Either the the location data needs to change, or the timeout happens
38+ connect(m_locationService.data(), &LocationService::locationChanged,
39+ this, &Scopes::completeDiscoveryFinished);
40+ connect(&m_startupQueryTimeout, &QTimer::timeout, this,
41+ &Scopes::completeDiscoveryFinished);
42+ m_startupQueryTimeout.setSingleShot(true);
43+ m_startupQueryTimeout.setInterval(LOCATION_STARTUP_TIMEOUT);
44+ m_startupQueryTimeout.start();
45+ }
46+}
47+
48+void Scopes::completeDiscoveryFinished()
49+{
50+ // Kill off everything that could potentially trigger the startup queries
51+ m_startupQueryTimeout.stop();
52+ disconnect(&m_startupQueryTimeout, &QTimer::timeout, this,
53+ &Scopes::completeDiscoveryFinished);
54+ disconnect(m_locationService.data(), &LocationService::locationChanged,
55+ this, &Scopes::completeDiscoveryFinished);
56+
57 processFavoriteScopes();
58 endResetModel();
59
60
61=== modified file 'src/Unity/scopes.h'
62--- src/Unity/scopes.h 2014-10-15 13:26:31 +0000
63+++ src/Unity/scopes.h 2014-10-16 09:00:44 +0000
64@@ -27,6 +27,7 @@
65 // Qt
66 #include <QList>
67 #include <QThread>
68+#include <QTimer>
69 #include <QStringList>
70 #include <QSharedPointer>
71 #include <QGSettings>
72@@ -86,6 +87,7 @@
73 void initPopulateScopes();
74 void dpkgFinished();
75 void lsbReleaseFinished();
76+ void completeDiscoveryFinished();
77
78 private:
79 void createUserAgentString();
80@@ -106,6 +108,7 @@
81 bool m_loaded;
82
83 LocationService::Ptr m_locationService;
84+ QTimer m_startupQueryTimeout;
85
86 unity::scopes::Runtime::SPtr m_scopesRuntime;
87
88
89=== modified file 'src/Unity/ubuntulocationservice.cpp'
90--- src/Unity/ubuntulocationservice.cpp 2014-09-22 14:53:16 +0000
91+++ src/Unity/ubuntulocationservice.cpp 2014-10-16 09:00:44 +0000
92@@ -355,6 +355,11 @@
93 culss::Interface::Updates::Status::enabled) : false;
94 }
95
96+bool UbuntuLocationService::hasLocation() const
97+{
98+ return p->m_result.valid || p->m_locationUpdatedAtLeastOnce;
99+}
100+
101 void UbuntuLocationService::activate()
102 {
103 Q_EMIT enqueueActivate();
104
105=== modified file 'src/Unity/ubuntulocationservice.h'
106--- src/Unity/ubuntulocationservice.h 2014-09-22 14:23:44 +0000
107+++ src/Unity/ubuntulocationservice.h 2014-10-16 09:00:44 +0000
108@@ -40,6 +40,8 @@
109
110 unity::scopes::Location location() const override;
111
112+ bool hasLocation() const override;
113+
114 bool isActive() const override;
115
116 void activate() override;
117
118=== modified file 'tests/departmentstest.cpp'
119--- tests/departmentstest.cpp 2014-10-15 14:08:09 +0000
120+++ tests/departmentstest.cpp 2014-10-16 09:00:44 +0000
121@@ -55,6 +55,7 @@
122 private Q_SLOTS:
123 void initTestCase()
124 {
125+ qputenv("UNITY_SCOPES_NO_WAIT_LOCATION", "1");
126 m_registry.reset(new RegistrySpawner);
127 }
128
129
130=== modified file 'tests/resultstest.cpp'
131--- tests/resultstest.cpp 2014-10-15 14:08:09 +0000
132+++ tests/resultstest.cpp 2014-10-16 09:00:44 +0000
133@@ -94,6 +94,7 @@
134 private Q_SLOTS:
135 void initTestCase()
136 {
137+ qputenv("UNITY_SCOPES_NO_WAIT_LOCATION", "1");
138 m_registry.reset(new RegistrySpawner);
139 }
140

Subscribers

People subscribed via source and target branches

to all changes: