Merge lp:unity-scopes-api/staging into lp:unity-scopes-api

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 262
Merged at revision: 262
Proposed branch: lp:unity-scopes-api/staging
Merge into: lp:unity-scopes-api
Diff against target: 528 lines (+146/-84)
15 files modified
CMakeLists.txt (+1/-1)
CONFIGFILES (+2/-1)
RELEASE_NOTES.md (+4/-0)
debian/changelog (+6/-0)
debian/libunity-scopes3.symbols (+7/-2)
include/unity/scopes/internal/DfltConfig.h.in (+0/-1)
include/unity/scopes/internal/RegistryObject.h (+4/-0)
include/unity/scopes/internal/RuntimeImpl.h (+5/-1)
include/unity/scopes/internal/smartscopes/SSRegistryObject.h (+1/-0)
scoperegistry/scoperegistry.cpp (+11/-13)
scoperunner/scoperunner.cpp (+0/-15)
src/scopes/internal/RegistryObject.cpp (+18/-0)
src/scopes/internal/RuntimeImpl.cpp (+58/-41)
src/scopes/internal/smartscopes/SSRegistryObject.cpp (+16/-6)
src/scopes/internal/smartscopes/SmartScope.cpp (+13/-3)
To merge this branch: bzr merge lp:unity-scopes-api/staging
Reviewer Review Type Date Requested Status
Michi Henning (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+239330@code.launchpad.net

Commit message

Merge staging (Fixes bugs 1361221, 1376416, 1378805)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

No-one has commented on this. Marcus, do you need a top-approve for this?

Revision history for this message
Michi Henning (michihenning) wrote :

Looks fine!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-10-09 06:01:15 +0000
3+++ CMakeLists.txt 2014-10-22 23:13:36 +0000
4@@ -195,7 +195,7 @@
5 # API version
6 set(UNITY_SCOPES_MAJOR 0)
7 set(UNITY_SCOPES_MINOR 6)
8-set(UNITY_SCOPES_MICRO 7)
9+set(UNITY_SCOPES_MICRO 8)
10 set(UNITY_SCOPES_SOVERSION 3)
11
12 # Version for testing, with all symbols visible
13
14=== modified file 'CONFIGFILES'
15--- CONFIGFILES 2014-08-15 09:28:56 +0000
16+++ CONFIGFILES 2014-10-22 23:13:36 +0000
17@@ -102,7 +102,8 @@
18 Note that the actual files are written into subdirectories of
19 this directory, for example:
20
21- $HOME/.local/share/unity-scopes/<scope_id>/cache.db
22+ $HOME/.local/share/unity-scopes/leaf-net/<scope_id>/some_file (for confined scopes)
23+ and $HOME/.local/share/unity-scopes/unconfined/<scope_id>/some_file (for unconfined scopes).
24
25 - ConfigDir
26
27
28=== modified file 'RELEASE_NOTES.md'
29--- RELEASE_NOTES.md 2014-10-10 17:07:01 +0000
30+++ RELEASE_NOTES.md 2014-10-22 23:13:36 +0000
31@@ -1,6 +1,10 @@
32 Release notes
33 =============
34
35+Changes in version 0.6.8
36+========================
37+ - Replaced dbus-send with "list updated" pub/sub to invalidate smart scopes.
38+
39 Changes in version 0.6.7
40 ========================
41 - OnlineAccountClient fixes: run the internal event loop within its own context to avoid
42
43=== modified file 'debian/changelog'
44--- debian/changelog 2014-10-14 12:06:25 +0000
45+++ debian/changelog 2014-10-22 23:13:36 +0000
46@@ -1,3 +1,9 @@
47+unity-scopes-api (0.6.8-0ubuntu1) UNRELEASED; urgency=medium
48+
49+ * Replaced dbus-send with "list updated" pub/sub to invalidate smart scopes.
50+
51+ -- Marcus Tomlinson <marcus.tomlinson@canonical.com> Wed, 22 Oct 2014 17:44:46 +0200
52+
53 unity-scopes-api (0.6.7+14.10.20141014-0ubuntu1) 14.09; urgency=low
54
55 [ Marcus Tomlinson ]
56
57=== modified file 'debian/libunity-scopes3.symbols'
58--- debian/libunity-scopes3.symbols 2014-09-25 12:56:03 +0000
59+++ debian/libunity-scopes3.symbols 2014-10-22 23:13:36 +0000
60@@ -377,7 +377,7 @@
61 (c++)"unity::scopes::internal::RegistryObject::remove_desktop_file(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.6.6+14.10.20140916
62 (c++)"unity::scopes::internal::RegistryObject::remove_local_scope(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
63 (c++)"unity::scopes::internal::RegistryObject::ScopeExecData::~ScopeExecData()@Base" 0.4.2+14.04.20140404.2
64- (c++|arch=amd64)"unity::scopes::internal::RegistryObject::ScopeExecData::ScopeExecData(unity::scopes::internal::RegistryObject::ScopeExecData const&)@Base" 0.6.6+14.10.20140916
65+ (c++)"unity::scopes::internal::RegistryObject::ScopeExecData::ScopeExecData(unity::scopes::internal::RegistryObject::ScopeExecData const&)@Base" 0.6.6+14.10.20140916
66 (c++)"unity::scopes::internal::RegistryObject::ScopeProcess::clear_handle_unlocked()@Base" 0.4.2+14.04.20140404.2
67 (c++)"unity::scopes::internal::RegistryObject::ScopeProcess::exec(core::posix::ChildProcess::DeathObserver&, std::shared_ptr<unity::scopes::internal::Executor>)@Base" 0.4.3+14.10.20140428
68 (c++)"unity::scopes::internal::RegistryObject::ScopeProcess::expand_custom_exec()@Base" 0.5.0+14.10.20140619
69@@ -394,6 +394,7 @@
70 (c++)"unity::scopes::internal::RegistryObject::ScopeProcess::wait_for_state(std::unique_lock<std::mutex>&, unity::scopes::internal::RegistryObject::ScopeProcess::ProcessState) const@Base" 0.4.5+14.10.20140513
71 (c++)"unity::scopes::internal::RegistryObject::ScopeProcess::wait_for_state(unity::scopes::internal::RegistryObject::ScopeProcess::ProcessState) const@Base" 0.4.5+14.10.20140513
72 (c++)"unity::scopes::internal::RegistryObject::set_remote_registry(std::shared_ptr<unity::scopes::internal::MWRegistry> const&)@Base" 0.4.0+14.04.20140312.1
73+ (c++)"unity::scopes::internal::RegistryObject::ss_list_update()@Base" 0replaceme
74 (c++)"unity::scopes::internal::RegistryObject::state_receiver()@Base" 0.4.2+14.04.20140404.2
75 (c++)"unity::scopes::internal::RuntimeConfig::config_directory() const@Base" 0.6.2+rtm+rtm+rtm+14.09.20140818
76 (c++)"unity::scopes::internal::RuntimeConfig::data_directory() const@Base" 0.5.2+14.10.20140709.2
77@@ -410,10 +411,14 @@
78 (c++)"unity::scopes::internal::RuntimeConfig::ss_configfile() const@Base" 0.4.4+14.10.20140508
79 (c++)"unity::scopes::internal::RuntimeConfig::ss_registry_identity() const@Base" 0.4.4+14.10.20140508
80 (c++)"unity::scopes::internal::RuntimeImpl::async_pool() const@Base" 0.4.3+14.10.20140428
81+ (c++)"unity::scopes::internal::RuntimeImpl::confined() const@Base" 0replaceme
82+ (c++)"unity::scopes::internal::RuntimeImpl::confinement_type() const@Base" 0replaceme
83 (c++)"unity::scopes::internal::RuntimeImpl::create(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1
84+ (c++)"unity::scopes::internal::RuntimeImpl::demangled_id() const@Base" 0replaceme
85 (c++)"unity::scopes::internal::RuntimeImpl::destroy()@Base" 0.4.0+14.04.20140312.1
86 (c++)"unity::scopes::internal::RuntimeImpl::factory() const@Base" 0.4.0+14.04.20140312.1
87- (c++)"unity::scopes::internal::RuntimeImpl::find_cache_dir(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&) const@Base" 0.6.0+14.10.20140804.1
88+ (c++)"unity::scopes::internal::RuntimeImpl::find_cache_dir() const@Base" 0replaceme
89+ (c++)"unity::scopes::internal::RuntimeImpl::find_tmp_dir() const@Base" 0replaceme
90 (c++)"unity::scopes::internal::RuntimeImpl::future_queue() const@Base" 0.4.3+14.10.20140428
91 (c++)"unity::scopes::internal::RuntimeImpl::proxy_to_string(std::shared_ptr<unity::scopes::Object> const&) const@Base" 0.4.0+14.04.20140312.1
92 (c++)"unity::scopes::internal::RuntimeImpl::registry_configfile() const@Base" 0.4.0+14.04.20140312.1
93
94=== modified file 'include/unity/scopes/internal/DfltConfig.h.in'
95--- include/unity/scopes/internal/DfltConfig.h.in 2014-08-11 13:03:21 +0000
96+++ include/unity/scopes/internal/DfltConfig.h.in 2014-10-22 23:13:36 +0000
97@@ -39,7 +39,6 @@
98 static constexpr char const* DFLT_MIDDLEWARE_INI = DFLT_ZMQ_MIDDLEWARE_INI;
99 static constexpr char const* DFLT_SCOPE_INSTALL_DIR = "@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_PREFIX@/@UNITY_SCOPES_LIB@";
100 static constexpr char const* DFLT_OEM_INSTALL_DIR = "/custom/@LIB_INSTALL_PREFIX@/@UNITY_SCOPES_LIB@";
101-static constexpr char const* DFLT_CONFINEMENT_TYPE = "leaf-net";
102
103 static constexpr int DFLT_SS_HTTP_TIMEOUT = 20; // seconds
104 static constexpr int DFLT_SS_REG_REFRESH_RATE = 86400; // 24 hours as seconds
105
106=== modified file 'include/unity/scopes/internal/RegistryObject.h'
107--- include/unity/scopes/internal/RegistryObject.h 2014-09-15 14:15:10 +0000
108+++ include/unity/scopes/internal/RegistryObject.h 2014-10-22 23:13:36 +0000
109@@ -85,6 +85,8 @@
110 void create_desktop_file(ScopeMetadata const& metadata);
111 void remove_desktop_file(std::string const& scope_id);
112
113+ void ss_list_update();
114+
115 class ScopeProcess
116 {
117 public:
118@@ -144,6 +146,8 @@
119 mutable std::mutex mutex_;
120
121 MWPublisher::SPtr publisher_;
122+ MWSubscriber::SPtr ss_list_update_subscriber_;
123+ std::shared_ptr<core::ScopedConnection> ss_list_update_connection_;
124 bool generate_desktop_files_;
125 };
126
127
128=== modified file 'include/unity/scopes/internal/RuntimeImpl.h'
129--- include/unity/scopes/internal/RuntimeImpl.h 2014-08-14 13:19:28 +0000
130+++ include/unity/scopes/internal/RuntimeImpl.h 2014-10-22 23:13:36 +0000
131@@ -69,7 +69,11 @@
132 private:
133 RuntimeImpl(std::string const& scope_id, std::string const& configfile);
134 void waiter_thread(ThreadSafeQueue<std::future<void>>::SPtr const& queue) const noexcept;
135- std::string find_cache_dir(std::string& confinement_type) const;
136+ std::string demangled_id() const;
137+ bool confined() const;
138+ std::string confinement_type() const;
139+ std::string find_cache_dir() const;
140+ std::string find_tmp_dir() const;
141
142 bool destroyed_;
143 std::string scope_id_;
144
145=== modified file 'include/unity/scopes/internal/smartscopes/SSRegistryObject.h'
146--- include/unity/scopes/internal/smartscopes/SSRegistryObject.h 2014-08-20 07:58:15 +0000
147+++ include/unity/scopes/internal/smartscopes/SSRegistryObject.h 2014-10-22 23:13:36 +0000
148@@ -98,6 +98,7 @@
149
150 bool caching_enabled_;
151 std::string locale_;
152+ MWPublisher::SPtr publisher_;
153 };
154
155 } // namespace smartscopes
156
157=== modified file 'scoperegistry/scoperegistry.cpp'
158--- scoperegistry/scoperegistry.cpp 2014-09-15 14:15:10 +0000
159+++ scoperegistry/scoperegistry.cpp 2014-10-22 23:13:36 +0000
160@@ -20,10 +20,7 @@
161 #include "ScopesWatcher.h"
162
163 #include <unity/scopes/internal/IniSettingsSchema.h>
164-#include <unity/scopes/internal/MiddlewareFactory.h>
165-#include <unity/scopes/internal/MWRegistry.h>
166 #include <unity/scopes/internal/RegistryConfig.h>
167-#include <unity/scopes/internal/RegistryObject.h>
168 #include <unity/scopes/internal/RuntimeConfig.h>
169 #include <unity/scopes/internal/RuntimeImpl.h>
170 #include <unity/scopes/internal/ScopeConfig.h>
171@@ -31,18 +28,10 @@
172 #include <unity/scopes/internal/ScopeMetadataImpl.h>
173 #include <unity/scopes/ScopeExceptions.h>
174 #include <unity/UnityExceptions.h>
175-#include <unity/util/ResourcePtr.h>
176
177 #include <boost/algorithm/string.hpp>
178 #include <boost/filesystem/operations.hpp>
179
180-#include <algorithm>
181-#include <cassert>
182-#include <fstream>
183-#include <iostream>
184-#include <map>
185-#include <set>
186-
187 #include <sys/stat.h> // TODO: remove this once hack for creating data root dir is removed
188
189 using namespace scoperegistry;
190@@ -497,13 +486,22 @@
191 // TODO: HACK: We create the root of the data directory for confined scopes,
192 // in case the scope is confined and the dir doesn't exist
193 // yet. This really should be done by the click-installation but,
194- // prior to RTM, we don't rely on that. We check whether the
195- // directory exists first to avoid getting noise in the Apparmor log.
196+ // prior to RTM, we don't rely on that.
197 string data_root = rt_config.data_directory() + "/leaf-net";
198 boost::system::error_code ec;
199 !boost::filesystem::exists(data_root, ec) && ::mkdir(data_root.c_str(), 0700);
200 } // Release memory for config parser
201
202+ // Make sure that the parent directories for confined scope tmp directory exist.
203+ {
204+ string dir = string("/run/user/") + std::to_string(geteuid());
205+ dir += "/scopes";
206+ boost::system::error_code ec;
207+ !boost::filesystem::exists(dir, ec) && ::mkdir(dir.c_str(), 0700 | S_ISVTX);
208+ dir += "/leaf-net";
209+ !boost::filesystem::exists(dir, ec) && ::mkdir(dir.c_str(), 0700 | S_ISVTX);
210+ }
211+
212 // Collect the registry config data.
213
214 string mw_kind;
215
216=== modified file 'scoperunner/scoperunner.cpp'
217--- scoperunner/scoperunner.cpp 2014-08-28 00:20:56 +0000
218+++ scoperunner/scoperunner.cpp 2014-10-22 23:13:36 +0000
219@@ -16,16 +16,8 @@
220 * Authored by: Michi Henning <michi.henning@canonical.com>
221 */
222
223-#include <unity/scopes/internal/MWRegistry.h>
224-#include <unity/scopes/internal/MWStateReceiver.h>
225-#include <unity/scopes/internal/RegistryConfig.h>
226-#include <unity/scopes/internal/RuntimeConfig.h>
227 #include <unity/scopes/internal/RuntimeImpl.h>
228-#include <unity/scopes/internal/ScopeConfig.h>
229 #include <unity/scopes/internal/ScopeLoader.h>
230-#include <unity/scopes/internal/ScopeObject.h>
231-#include <unity/scopes/internal/ThreadSafeQueue.h>
232-#include <unity/scopes/ScopeExceptions.h>
233 #include <unity/UnityExceptions.h>
234
235 #include <boost/algorithm/string.hpp>
236@@ -33,13 +25,6 @@
237 #include <core/posix/signal.h>
238 #include <core/posix/this_process.h>
239
240-#include <cassert>
241-#include <future>
242-#include <iostream>
243-#include <string>
244-#include <unordered_map>
245-#include <vector>
246-
247 using namespace std;
248 using namespace unity::scopes;
249 using namespace unity::scopes::internal;
250
251=== modified file 'src/scopes/internal/RegistryObject.cpp'
252--- src/scopes/internal/RegistryObject.cpp 2014-10-06 08:17:09 +0000
253+++ src/scopes/internal/RegistryObject.cpp 2014-10-22 23:13:36 +0000
254@@ -78,6 +78,15 @@
255 try
256 {
257 publisher_ = middleware->create_publisher(middleware->runtime()->registry_identity());
258+
259+ ss_list_update_subscriber_ = middleware->create_subscriber(middleware->runtime()->ss_registry_identity());
260+ ss_list_update_connection_ = std::make_shared<core::ScopedConnection>
261+ (
262+ ss_list_update_subscriber_->message_received().connect([this](string const&)
263+ {
264+ ss_list_update();
265+ })
266+ );
267 }
268 catch (std::exception const& e)
269 {
270@@ -415,6 +424,15 @@
271 }
272 }
273
274+void RegistryObject::ss_list_update()
275+{
276+ if (publisher_)
277+ {
278+ // Send a blank message to subscribers to inform them that the samrt scopes proxy has been updated
279+ publisher_->send_message("");
280+ }
281+}
282+
283 RegistryObject::ScopeProcess::ScopeProcess(ScopeExecData exec_data, std::weak_ptr<MWPublisher> const& publisher)
284 : exec_data_(exec_data)
285 , reg_publisher_(publisher)
286
287=== modified file 'src/scopes/internal/RuntimeImpl.cpp'
288--- src/scopes/internal/RuntimeImpl.cpp 2014-09-08 05:55:39 +0000
289+++ src/scopes/internal/RuntimeImpl.cpp 2014-10-22 23:13:36 +0000
290@@ -350,17 +350,12 @@
291 string config_dir = config_dir_ + "/" + scope_id_;
292 string settings_db = config_dir + "/settings.ini";
293
294- string scope_data_dir = data_dir_ + "/" + scope_id_;
295 string scope_dir = scope_base->scope_directory();
296-
297 string settings_schema = scope_dir + "/" + scope_id_ + "-settings.ini";
298+
299 boost::system::error_code ec;
300 if (boost::filesystem::exists(settings_schema, ec))
301 {
302- // Make sure the data directories exist. (No permission for group and others; data might be sensitive.)
303- !boost::filesystem::exists(data_dir_, ec) && ::mkdir(data_dir_.c_str(), 0700);
304- !boost::filesystem::exists(scope_data_dir, ec) && ::mkdir(scope_data_dir.c_str(), 0700);
305-
306 shared_ptr<SettingsDB> db(SettingsDB::create_from_ini_file(settings_db, settings_schema));
307 scope_base->p->set_settings_db(db);
308 }
309@@ -371,25 +366,8 @@
310 }
311
312 scope_base->p->set_registry(registry_);
313-
314- string confinement_type;
315- scope_base->p->set_cache_directory(find_cache_dir(confinement_type));
316-
317- {
318- // Set tmp dir.
319- // We need to create any directories under /run/user/<uid> because they might not
320- // exist. (/run/user/<uid> gets cleaned out periodically.)
321- string path = string("/run/user/") + std::to_string(geteuid());
322- path += "/scopes";
323- boost::system::error_code ec;
324- !boost::filesystem::exists(path, ec) && ::mkdir(path.c_str(), 0700);
325- path += "/" + confinement_type;
326- !boost::filesystem::exists(path, ec) && ::mkdir(path.c_str(), 0700);
327- path += "/" + scope_id_;
328- !boost::filesystem::exists(path, ec) && ::mkdir(path.c_str(), 0700);
329-
330- scope_base->p->set_tmp_directory(path);
331- }
332+ scope_base->p->set_cache_directory(find_cache_dir());
333+ scope_base->p->set_tmp_directory(find_tmp_dir());
334
335 try
336 {
337@@ -508,23 +486,15 @@
338 }
339 }
340
341-string RuntimeImpl::find_cache_dir(string& confinement_type) const
342+string RuntimeImpl::demangled_id() const
343 {
344- // Find out whether we are confined. aa_getcon() returns -1 in that case.
345- char* con = nullptr;
346- char* mode;
347- int rc = aa_getcon(&con, &mode);
348- // Only con (not mode) must be deallocated
349- free(con);
350- confinement_type = rc == -1 ? "leaf-net" : "unconfined";
351-
352 // For scopes that are in a click package together with an app,
353 // such as YouTube, the cache directory is shared between the app and
354 // the scope. The cache directory name is the scope ID up to the first
355 // underscore. For example, com.ubuntu.scopes.youtube_youtube is the
356 // scope ID, but the cache dir name is com.ubuntu.scopes.youtube.
357 auto id = scope_id_;
358- if (confinement_type == "leaf-net")
359+ if (confined())
360 {
361 auto pos = id.find('_');
362 if (pos != string::npos)
363@@ -532,14 +502,61 @@
364 id = id.substr(0, pos);
365 }
366 }
367-
368+ return id;
369+}
370+
371+bool RuntimeImpl::confined() const
372+{
373+ auto is_confined = []
374+ {
375+ // Find out whether we are confined. aa_getcon() returns -1 in that case.
376+ char* con = nullptr;
377+ char* mode;
378+ int rc = aa_getcon(&con, &mode);
379+ // Only con (not mode) must be deallocated
380+ free(con);
381+ return rc == -1;
382+ };
383+ static bool confined = is_confined();
384+ return confined;
385+}
386+
387+string RuntimeImpl::confinement_type() const
388+{
389+ return confined() ? "leaf-net" : "unconfined";
390+}
391+
392+string RuntimeImpl::find_cache_dir() const
393+{
394 // Create the data_dir_/<confinement-type>/<id> directories if they don't exist.
395 boost::system::error_code ec;
396- !boost::filesystem::exists(data_dir_, ec) && ::mkdir(data_dir_.c_str(), 0700);
397- string dir = data_dir_ + "/" + confinement_type;
398- !boost::filesystem::exists(dir, ec) && ::mkdir(dir.c_str(), 0700);
399- dir += "/" + id;
400- !boost::filesystem::exists(dir, ec) && ::mkdir(dir.c_str(), 0700);
401+ !confined() && !boost::filesystem::exists(data_dir_, ec) && ::mkdir(data_dir_.c_str(), 0700);
402+ string dir = data_dir_ + "/" + confinement_type();
403+ !confined() && !boost::filesystem::exists(dir, ec) && ::mkdir(dir.c_str(), 0700);
404+
405+ // A confined scope is allowed to create this dir.
406+ dir += "/" + demangled_id();
407+ !boost::filesystem::exists(dir, ec) && ::mkdir(dir.c_str(), 0700);
408+
409+ return dir;
410+}
411+
412+string RuntimeImpl::find_tmp_dir() const
413+{
414+ // Set tmp dir.
415+ // We need to create any directories under /run/user/<uid> because they might not
416+ // exist. We set the sticky bit because, without this, things in
417+ // /run/user may be deleted if not accessed for more than six hours.
418+ string dir = string("/run/user/") + std::to_string(geteuid());
419+ dir += "/scopes";
420+ boost::system::error_code ec;
421+ !confined() && !boost::filesystem::exists(dir, ec) && ::mkdir(dir.c_str(), 0700 | S_ISVTX);
422+ dir += "/" + confinement_type();
423+ !confined() && !boost::filesystem::exists(dir, ec) && ::mkdir(dir.c_str(), 0700 | S_ISVTX);
424+
425+ // A confined scope is allowed to create this dir.
426+ dir += "/" + scope_id_; // Not demangled, use the real scope ID.
427+ !boost::filesystem::exists(dir, ec) && ::mkdir(dir.c_str(), 0700 | S_ISVTX);
428
429 return dir;
430 }
431
432=== modified file 'src/scopes/internal/smartscopes/SSRegistryObject.cpp'
433--- src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-08-26 04:00:56 +0000
434+++ src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-10-22 23:13:36 +0000
435@@ -22,6 +22,7 @@
436 #include <unity/scopes/internal/JsonSettingsSchema.h>
437 #include <unity/scopes/internal/RegistryException.h>
438 #include <unity/scopes/internal/RuntimeConfig.h>
439+#include <unity/scopes/internal/RuntimeImpl.h>
440 #include <unity/scopes/internal/ScopeImpl.h>
441 #include <unity/scopes/internal/ScopeMetadataImpl.h>
442 #include <unity/scopes/internal/smartscopes/HttpClientQt.h>
443@@ -31,8 +32,6 @@
444
445 #include <iostream>
446
447-static const char* c_dbussend_cmd = "dbus-send /com/canonical/unity/scopes com.canonical.unity.scopes.InvalidateResults string:smart-scopes";
448-
449 namespace unity
450 {
451
452@@ -86,6 +85,18 @@
453 }
454
455 refresh_thread_ = std::thread(&SSRegistryObject::refresh_thread, this);
456+
457+ if (middleware)
458+ {
459+ try
460+ {
461+ publisher_ = middleware->create_publisher(middleware->runtime()->ss_registry_identity());
462+ }
463+ catch (std::exception const& e)
464+ {
465+ std::cerr << "SSRegistryObject(): failed to create registry publisher: " << e.what() << std::endl;
466+ }
467+ }
468 }
469
470 SSRegistryObject::~SSRegistryObject()
471@@ -372,11 +383,10 @@
472 scopes_ = new_scopes_;
473 }
474
475- if (changed)
476+ if (changed && publisher_)
477 {
478- // something has changed, send invalidate signal
479- int result = safe_system_call(c_dbussend_cmd);
480- (void)result;
481+ // Send a blank message to subscribers to inform them that the smart scopes registry has been updated
482+ publisher_->send_message("");
483 }
484 }
485
486
487=== modified file 'src/scopes/internal/smartscopes/SmartScope.cpp'
488--- src/scopes/internal/smartscopes/SmartScope.cpp 2014-09-22 13:43:00 +0000
489+++ src/scopes/internal/smartscopes/SmartScope.cpp 2014-10-22 23:13:36 +0000
490@@ -160,7 +160,8 @@
491 }
492 };
493
494- ///! TODO: country (+location data)
495+
496+ ///! TODO: detailed location data
497 int query_id = 0;
498 std::string session_id;
499 std::string agent;
500@@ -186,9 +187,18 @@
501 {
502 agent = metadata["user-agent"].get_string();
503 }
504+ std::string country_code;
505+ if (metadata.has_location())
506+ {
507+ auto location = metadata.location();
508+ if (location.has_country_code())
509+ {
510+ country_code = location.country_code();
511+ }
512+ }
513
514 search_handle_ = ss_client_->search(handler, base_url_, query_.query_string(), query_.department_id(), session_id, query_id, hints_.form_factor(),
515- settings(), query_.filter_state().serialize(), hints_.locale(), "", agent, hints_.cardinality());
516+ settings(), query_.filter_state().serialize(), hints_.locale(), country_code, agent, hints_.cardinality());
517 search_handle_->wait();
518
519 std::cout << "SmartScope: query for \"" << scope_id_ << "\": \"" << query_.query_string() << "\" complete" << std::endl;
520@@ -256,7 +266,7 @@
521 }
522 };
523
524- ///! TODO: country (+location data)
525+ ///! TODO: country (+location data) - Preview metadata does not currently contain location data
526 std::string session_id;
527 std::string agent;
528 auto const metadata = action_metadata();

Subscribers

People subscribed via source and target branches

to all changes: