Merge lp:~unity-team/unity-scopes-api/staging-rtm into lp:unity-scopes-api/rtm-14.09

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Michi Henning
Approved revision: 263
Merged at revision: 248
Proposed branch: lp:~unity-team/unity-scopes-api/staging-rtm
Merge into: lp:unity-scopes-api/rtm-14.09
Diff against target: 531 lines (+149/-84)
15 files modified
CMakeLists.txt (+1/-1)
CONFIGFILES (+2/-1)
RELEASE_NOTES.md (+4/-0)
debian/changelog (+9/-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-team/unity-scopes-api/staging-rtm
Reviewer Review Type Date Requested Status
Michi Henning (community) Approve
Review via email: mp+242050@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
Michi Henning (michihenning) wrote :

Looks right to me, thanks!

review: Approve
264. By Paweł Stołowski

Updated changelog.

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

Subscribers

People subscribed via source and target branches

to all changes: