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
=== modified file 'src/Unity/locationservice.h'
--- src/Unity/locationservice.h 2014-07-25 15:30:02 +0000
+++ src/Unity/locationservice.h 2014-10-16 09:00:44 +0000
@@ -49,6 +49,8 @@
4949
50 virtual unity::scopes::Location location() const = 0;50 virtual unity::scopes::Location location() const = 0;
5151
52 virtual bool hasLocation() const = 0;
53
52 virtual bool isActive() const = 0;54 virtual bool isActive() const = 0;
5355
54public Q_SLOTS:56public Q_SLOTS:
5557
=== modified file 'src/Unity/scopes.cpp'
--- src/Unity/scopes.cpp 2014-10-15 10:49:13 +0000
+++ src/Unity/scopes.cpp 2014-10-16 09:00:44 +0000
@@ -87,6 +87,7 @@
8787
88int Scopes::LIST_DELAY = -1;88int Scopes::LIST_DELAY = -1;
89const int Scopes::SCOPE_DELETE_DELAY = 3;89const int Scopes::SCOPE_DELETE_DELAY = 3;
90const int LOCATION_STARTUP_TIMEOUT = 1000;
9091
91class Scopes::Priv : public QObject {92class Scopes::Priv : public QObject {
92 Q_OBJECT93 Q_OBJECT
@@ -290,6 +291,34 @@
290 m_cachedMetadata[QString::fromStdString(it->first)] = std::make_shared<unity::scopes::ScopeMetadata>(it->second);291 m_cachedMetadata[QString::fromStdString(it->first)] = std::make_shared<unity::scopes::ScopeMetadata>(it->second);
291 }292 }
292293
294 if (m_locationService->hasLocation() || qEnvironmentVariableIsSet("UNITY_SCOPES_NO_WAIT_LOCATION"))
295 {
296 // If we already have a location just query the scopes now
297 completeDiscoveryFinished();
298 }
299 else
300 {
301 // Otherwise we have to wait for location data
302 // Either the the location data needs to change, or the timeout happens
303 connect(m_locationService.data(), &LocationService::locationChanged,
304 this, &Scopes::completeDiscoveryFinished);
305 connect(&m_startupQueryTimeout, &QTimer::timeout, this,
306 &Scopes::completeDiscoveryFinished);
307 m_startupQueryTimeout.setSingleShot(true);
308 m_startupQueryTimeout.setInterval(LOCATION_STARTUP_TIMEOUT);
309 m_startupQueryTimeout.start();
310 }
311}
312
313void Scopes::completeDiscoveryFinished()
314{
315 // Kill off everything that could potentially trigger the startup queries
316 m_startupQueryTimeout.stop();
317 disconnect(&m_startupQueryTimeout, &QTimer::timeout, this,
318 &Scopes::completeDiscoveryFinished);
319 disconnect(m_locationService.data(), &LocationService::locationChanged,
320 this, &Scopes::completeDiscoveryFinished);
321
293 processFavoriteScopes();322 processFavoriteScopes();
294 endResetModel();323 endResetModel();
295324
296325
=== modified file 'src/Unity/scopes.h'
--- src/Unity/scopes.h 2014-10-15 13:26:31 +0000
+++ src/Unity/scopes.h 2014-10-16 09:00:44 +0000
@@ -27,6 +27,7 @@
27// Qt27// Qt
28#include <QList>28#include <QList>
29#include <QThread>29#include <QThread>
30#include <QTimer>
30#include <QStringList>31#include <QStringList>
31#include <QSharedPointer>32#include <QSharedPointer>
32#include <QGSettings>33#include <QGSettings>
@@ -86,6 +87,7 @@
86 void initPopulateScopes();87 void initPopulateScopes();
87 void dpkgFinished();88 void dpkgFinished();
88 void lsbReleaseFinished();89 void lsbReleaseFinished();
90 void completeDiscoveryFinished();
8991
90private:92private:
91 void createUserAgentString();93 void createUserAgentString();
@@ -106,6 +108,7 @@
106 bool m_loaded;108 bool m_loaded;
107109
108 LocationService::Ptr m_locationService;110 LocationService::Ptr m_locationService;
111 QTimer m_startupQueryTimeout;
109112
110 unity::scopes::Runtime::SPtr m_scopesRuntime;113 unity::scopes::Runtime::SPtr m_scopesRuntime;
111114
112115
=== modified file 'src/Unity/ubuntulocationservice.cpp'
--- src/Unity/ubuntulocationservice.cpp 2014-09-22 14:53:16 +0000
+++ src/Unity/ubuntulocationservice.cpp 2014-10-16 09:00:44 +0000
@@ -355,6 +355,11 @@
355 culss::Interface::Updates::Status::enabled) : false;355 culss::Interface::Updates::Status::enabled) : false;
356}356}
357357
358bool UbuntuLocationService::hasLocation() const
359{
360 return p->m_result.valid || p->m_locationUpdatedAtLeastOnce;
361}
362
358void UbuntuLocationService::activate()363void UbuntuLocationService::activate()
359{364{
360 Q_EMIT enqueueActivate();365 Q_EMIT enqueueActivate();
361366
=== modified file 'src/Unity/ubuntulocationservice.h'
--- src/Unity/ubuntulocationservice.h 2014-09-22 14:23:44 +0000
+++ src/Unity/ubuntulocationservice.h 2014-10-16 09:00:44 +0000
@@ -40,6 +40,8 @@
4040
41 unity::scopes::Location location() const override;41 unity::scopes::Location location() const override;
4242
43 bool hasLocation() const override;
44
43 bool isActive() const override;45 bool isActive() const override;
4446
45 void activate() override;47 void activate() override;
4648
=== modified file 'tests/departmentstest.cpp'
--- tests/departmentstest.cpp 2014-10-15 14:08:09 +0000
+++ tests/departmentstest.cpp 2014-10-16 09:00:44 +0000
@@ -55,6 +55,7 @@
55private Q_SLOTS:55private Q_SLOTS:
56 void initTestCase()56 void initTestCase()
57 {57 {
58 qputenv("UNITY_SCOPES_NO_WAIT_LOCATION", "1");
58 m_registry.reset(new RegistrySpawner);59 m_registry.reset(new RegistrySpawner);
59 }60 }
6061
6162
=== modified file 'tests/resultstest.cpp'
--- tests/resultstest.cpp 2014-10-15 14:08:09 +0000
+++ tests/resultstest.cpp 2014-10-16 09:00:44 +0000
@@ -94,6 +94,7 @@
94private Q_SLOTS:94private Q_SLOTS:
95 void initTestCase()95 void initTestCase()
96 {96 {
97 qputenv("UNITY_SCOPES_NO_WAIT_LOCATION", "1");
97 m_registry.reset(new RegistrySpawner);98 m_registry.reset(new RegistrySpawner);
98 }99 }
99100

Subscribers

People subscribed via source and target branches

to all changes: