Merge lp:~stolowski/libunity/libunity.private-content into lp:libunity

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 174
Merged at revision: 169
Proposed branch: lp:~stolowski/libunity/libunity.private-content
Merge into: lp:libunity
Diff against target: 244 lines (+96/-2)
8 files modified
configure.ac (+1/-1)
src/unity-lens-private.vala (+19/-1)
src/unity-scope-private.vala (+2/-0)
src/unity-scope-proxy-local.vala (+6/-0)
src/unity-scope-proxy-remote.vala (+11/-0)
src/unity-scope-proxy.vala (+1/-0)
src/unity-scope.vala (+1/-0)
test/vala/test-lens.vala (+55/-0)
To merge this branch: bzr merge lp:~stolowski/libunity/libunity.private-content
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+121589@code.launchpad.net

Commit message

Implemented provides_private_content flag.

Description of the change

Implemented provides_private_content flag.

To post a comment you must log in.
169. By Paweł Stołowski

Use hints hastable to carry provides_private_content flag rather than a new attribute in LensInfo / ScopeInfo; this doesn't break ABI.

170. By Paweł Stołowski

Support provides_private_content property notification in ScopeProxyLocal.

171. By Paweł Stołowski

Added test case for provides_private_content property.

172. By Paweł Stołowski

Merged trunk.

173. By Paweł Stołowski

Bumped micro version for provides_private_content change.

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

Looking good, there's one issue though:

17 info.hints = new HashTable<string, Variant> (null, null);

Now that the hints are actually used, the funcs should be str_hash and str_equal.

review: Needs Fixing
174. By Paweł Stołowski

Properly initialize info_hints hashtable.

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

Great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2012-08-27 16:24:45 +0000
3+++ configure.ac 2012-08-29 11:40:31 +0000
4@@ -1,5 +1,5 @@
5 # When releasing also remember to update the soname as instructed below
6-AC_INIT(libunity, 5.97.0)
7+AC_INIT(libunity, 5.97.1)
8
9 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
10 AM_CONFIG_HEADER(config.h)
11
12=== modified file 'src/unity-lens-private.vala'
13--- src/unity-lens-private.vala 2012-06-25 09:02:44 +0000
14+++ src/unity-lens-private.vala 2012-08-29 11:40:31 +0000
15@@ -215,7 +215,19 @@
16 info.global_results_model_name = _global_results_model.get_swarm_name ();
17 info.categories_model_name = _categories_model.get_swarm_name ();
18 info.filters_model_name = _filters_model.get_swarm_name ();
19- info.hints = new HashTable<string, Variant> (null, null);
20+ info.hints = new HashTable<string, Variant> (str_hash, str_equal);
21+
22+ // lenses provide private content if at least one of its scopes has provides_private_content = true
23+ bool provides_private_content = false;
24+ foreach (var scope in _scope_factory.scopes)
25+ {
26+ if (scope.provides_private_content)
27+ {
28+ provides_private_content = true;
29+ break;
30+ }
31+ }
32+ info.hints.insert ("provides-private-content", provides_private_content);
33
34 changed (info);
35
36@@ -242,6 +254,7 @@
37 scope.notify["global-results-model"].connect (on_scope_global_results_model_changed);
38 scope.notify["filters-model"].connect (on_scope_filters_model_changed);
39 scope.notify["sources"].connect (on_scope_sources_updated);
40+ scope.notify["provides-private-content"].connect (on_scope_private_content_flag_changed);
41 }
42
43 private void on_scope_results_model_changed (Object obj, ParamSpec? pspec)
44@@ -288,6 +301,11 @@
45 _filters_sync.remove_receiver (filter_model);
46 }
47
48+ private void on_scope_private_content_flag_changed (Object obj, ParamSpec pspec)
49+ {
50+ queue_info_changed ();
51+ }
52+
53 private void on_scope_sources_updated (Object obj, ParamSpec pspec)
54 {
55 ScopeProxy? scope = obj as ScopeProxy;
56
57=== modified file 'src/unity-scope-private.vala'
58--- src/unity-scope-private.vala 2012-08-16 07:54:51 +0000
59+++ src/unity-scope-private.vala 2012-08-29 11:40:31 +0000
60@@ -53,6 +53,7 @@
61 {
62 owner.notify["search-in-global"].connect (queue_info_changed);
63 owner.notify["visible"].connect (queue_info_changed);
64+ owner.notify["provides-private-content"].connect (queue_info_changed);
65 owner.sources.changed.connect (queue_info_changed);
66
67 _action_map = new HashTable<string, PreviewAction> (str_hash, str_equal);
68@@ -169,6 +170,7 @@
69 info.global_results_model_name = get_model_name (_global_results_model);
70 info.filters_model_name = get_model_name (_filters_model);
71 info.hints = new HashTable<string, Variant> (str_hash, str_equal);
72+ info.hints.insert ("provides-private-content", new GLib.Variant.boolean (owner.provides_private_content));
73
74 changed (info);
75
76
77=== modified file 'src/unity-scope-proxy-local.vala'
78--- src/unity-scope-proxy-local.vala 2012-06-25 09:02:44 +0000
79+++ src/unity-scope-proxy-local.vala 2012-08-29 11:40:31 +0000
80@@ -35,6 +35,10 @@
81 get { return scope.search_in_global; }
82 set {}
83 }
84+ public bool provides_private_content {
85+ get { return scope.provides_private_content; }
86+ set {}
87+ }
88 public Dee.SerializableModel results_model {
89 get { return scope.results_model; }
90 set { }
91@@ -60,6 +64,7 @@
92 {
93 scope.bind_property ("search-in-global", this, "search-in-global", BindingFlags.DEFAULT);
94 scope.sources.changed.connect (() => { this.notify_property ("sources"); });
95+ scope.bind_property ("provides-private-content", this, "provides-private-content", BindingFlags.DEFAULT);
96
97 this.notify["view-type"].connect (() =>
98 {
99@@ -72,6 +77,7 @@
100 {
101 notify_property ("search-in-global");
102 notify_property ("sources");
103+ notify_property ("provides-private-content");
104
105 return false;
106 });
107
108=== modified file 'src/unity-scope-proxy-remote.vala'
109--- src/unity-scope-proxy-remote.vala 2012-06-25 09:02:44 +0000
110+++ src/unity-scope-proxy-remote.vala 2012-08-29 11:40:31 +0000
111@@ -31,6 +31,7 @@
112
113 public OptionsFilter sources { get; set; }
114 public bool search_in_global { get; set; }
115+ public bool provides_private_content { get; set; }
116
117 public Dee.SerializableModel results_model {
118 get { return _results_model; }
119@@ -125,6 +126,7 @@
120
121 synchronized = false;
122 search_in_global = false;
123+ provides_private_content = false;
124 sources = new CheckOptionFilter ("sources", "Sources", null, true);
125 if (_results_model != null)
126 _results_model.clear ();
127@@ -289,6 +291,15 @@
128 Trace.log_object (this, "Processing changed signal for %s", dbus_path);
129 search_in_global = scope_info.search_in_global;
130
131+ if (scope_info.hints.contains ("provides-private-content"))
132+ {
133+ provides_private_content = scope_info.hints["provides-private-content"].get_boolean ();
134+ }
135+ else
136+ {
137+ provides_private_content = false;
138+ }
139+
140 if (results_model == null ||
141 _results_model.get_swarm_name () != scope_info.results_model_name)
142 {
143
144=== modified file 'src/unity-scope-proxy.vala'
145--- src/unity-scope-proxy.vala 2012-06-25 09:02:44 +0000
146+++ src/unity-scope-proxy.vala 2012-08-29 11:40:31 +0000
147@@ -31,6 +31,7 @@
148 {
149 public abstract OptionsFilter sources { get; set; }
150 public abstract bool search_in_global { get; set; }
151+ public abstract bool provides_private_content { get; set; }
152 public abstract ViewType view_type { get; set; }
153 public abstract Dee.SerializableModel results_model { get; set; }
154 public abstract Dee.SerializableModel global_results_model { get; set; }
155
156=== modified file 'src/unity-scope.vala'
157--- src/unity-scope.vala 2012-06-25 09:02:44 +0000
158+++ src/unity-scope.vala 2012-08-29 11:40:31 +0000
159@@ -35,6 +35,7 @@
160 public bool active { get; set; default = false; }
161 public bool exported { get; private set; default = false; }
162 public bool search_in_global { get; set; default = true; }
163+ public bool provides_private_content { get; set; default = false; }
164 public string dbus_path { get; construct; }
165 public OptionsFilter sources { get; internal set; }
166 public List<Filter> filters { get { return _filters; } }
167
168=== modified file 'test/vala/test-lens.vala'
169--- test/vala/test-lens.vala 2012-08-16 07:54:51 +0000
170+++ test/vala/test-lens.vala 2012-08-29 11:40:31 +0000
171@@ -58,6 +58,7 @@
172 Test.add_data_func ("/Unit/Lens/Preview/Async", test_lens_preview_async);
173 Test.add_data_func ("/Unit/Lens/Preview/Signal", test_lens_preview_signal);
174 Test.add_data_func ("/Unit/Lens/Preview/ClosedSignal", test_lens_preview_closed_signal);
175+ Test.add_data_func ("/Unit/Lens/PrivateContentFlag", test_lens_private_content_flag);
176
177 Test.run ();
178
179@@ -193,6 +194,39 @@
180 });
181 }
182
183+ private static Unity.Protocol.LensInfo? get_lens_info ()
184+ {
185+ var ml = new MainLoop ();
186+ Unity.Protocol.LensInfo? info = null;
187+
188+ try
189+ {
190+ var bus = Bus.get_sync (BusType.SESSION);
191+ var sig_id = bus.signal_subscribe (null,
192+ "com.canonical.Unity.Lens",
193+ "Changed",
194+ "/com/canonical/Unity/Lens/Test",
195+ null,
196+ 0,
197+ (conn, sender, obj_path, ifc_name, sig_name, parameters) =>
198+ {
199+ info = (Unity.Protocol.LensInfo) parameters.get_child_value (0);
200+ ml.quit ();
201+ });
202+
203+ call_lens_method ("InfoRequest", null, null);
204+
205+ run_with_timeout (ml, 5000);
206+
207+ bus.signal_unsubscribe (sig_id);
208+ }
209+ catch (Error e) {
210+ warning ("%s", e.message);
211+ }
212+
213+ return info;
214+ }
215+
216 private static void call_lens_search (string search_string,
217 Func<Variant?>? cb = null)
218 {
219@@ -1065,4 +1099,25 @@
220
221 assert (got_closed_signal == 1);
222 }
223+
224+ public static void test_lens_private_content_flag ()
225+ {
226+ SignalWrapper[] signals = null;
227+ assert (local_scope != null);
228+ assert (exported_lens != null);
229+
230+ // check default value of provides_private_content
231+ Unity.Protocol.LensInfo? info = get_lens_info ();
232+ assert (info != null);
233+ assert (info.hints.contains ("provides-private-content"));
234+ assert (info.hints["provides-private-content"].get_boolean () == false);
235+
236+ local_scope.provides_private_content = true;
237+
238+ info = get_lens_info ();
239+ assert (info != null);
240+ assert (info.hints.contains ("provides-private-content"));
241+ assert (info.hints["provides-private-content"].get_boolean () == true);
242+ }
243+
244 }

Subscribers

People subscribed via source and target branches