Merge lp:~marcustomlinson/unity-scopes-api/invalidate_on_sss_scopes into lp:unity-scopes-api/devel

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Michal Hruby
Approved revision: 282
Merged at revision: 280
Proposed branch: lp:~marcustomlinson/unity-scopes-api/invalidate_on_sss_scopes
Merge into: lp:unity-scopes-api/devel
Diff against target: 34 lines (+10/-1)
1 file modified
src/scopes/internal/smartscopes/SmartScopesClient.cpp (+10/-1)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scopes-api/invalidate_on_sss_scopes
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michal Hruby (community) Approve
Review via email: mp+211731@code.launchpad.net

Commit message

Send an invalidation signal when the smart scopes become available.

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Can we please send the signal only when something changes?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
281. By Marcus Tomlinson

Send signal only when something changes with the remote scopes

282. By Marcus Tomlinson

Oops, removed unused method from header

Revision history for this message
Michal Hruby (mhr3) wrote :

LGTM.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/scopes/internal/smartscopes/SmartScopesClient.cpp'
2--- src/scopes/internal/smartscopes/SmartScopesClient.cpp 2014-03-07 04:00:11 +0000
3+++ src/scopes/internal/smartscopes/SmartScopesClient.cpp 2014-03-19 14:50:06 +0000
4@@ -36,6 +36,8 @@
5 static const std::string c_scopes_cache_dir = std::string(getenv("HOME")) + "/.cache/unity-scopes/";
6 static const std::string c_scopes_cache_filename = "remote-scopes.json";
7
8+static const char* c_dbussend_cmd = "dbus-send /com/canonical/unity/scopes com.canonical.unity.scopes.InvalidateResults string:smart-scopes";
9+
10 using namespace unity::scopes;
11 using namespace unity::scopes::internal::smartscopes;
12
13@@ -609,6 +611,12 @@
14
15 void SmartScopesClient::write_cache(std::string const& scopes_json)
16 {
17+ if (scopes_json != cached_scopes_)
18+ {
19+ // something has changed, send invalidate signal
20+ system(c_dbussend_cmd);
21+ }
22+
23 // make cache directory (fails silently if already exists)
24 mkdir(c_scopes_cache_dir.c_str(), 0755);
25
26@@ -620,7 +628,8 @@
27 cache_file << scopes_json;
28 cache_file.close();
29
30- have_latest_cache_ = false;
31+ cached_scopes_ = scopes_json;
32+ have_latest_cache_ = true;
33 }
34 }
35

Subscribers

People subscribed via source and target branches

to all changes: