Merge lp:~stolowski/libunity/pass-activation-hints into lp:libunity

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 310
Merged at revision: 305
Proposed branch: lp:~stolowski/libunity/pass-activation-hints
Merge into: lp:libunity
Diff against target: 223 lines (+99/-20)
6 files modified
configure.ac (+1/-1)
debian/changelog (+7/-0)
debian/libunity9.symbols (+2/-0)
src/unity-aggregator-scope-private.vala (+6/-0)
src/unity-result-activation.vala (+1/-0)
test/vala/test-scope.vala (+82/-19)
To merge this branch: bzr merge lp:~stolowski/libunity/pass-activation-hints
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michal Hruby (community) Approve
Review via email: mp+192524@code.launchpad.net

Commit message

Pass hints to AggregatorScope activation handler so that it can access action id if it's a preview action activation. Properly set uri in the activation reply if goto_uri is set.

Description of the change

Pass hints to AggregatorScope activation handler so that it can access action id if it's a preview action activation. Properly set uri in the activation reply if goto_uri is set.

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

Fixed symbols file.

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

Looks great, and since it's less than 1000 lines I don't need to nitpick on anything :)

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 'configure.ac'
2--- configure.ac 2013-09-27 14:37:41 +0000
3+++ configure.ac 2013-10-24 15:19:18 +0000
4@@ -1,5 +1,5 @@
5 # When releasing also remember to update the soname as instructed below
6-AC_INIT(libunity, 7.1.2)
7+AC_INIT(libunity, 7.1.3)
8
9 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
10 AM_CONFIG_HEADER(config.h)
11
12=== modified file 'debian/changelog'
13--- debian/changelog 2013-10-22 17:36:19 +0000
14+++ debian/changelog 2013-10-24 15:19:18 +0000
15@@ -1,3 +1,10 @@
16+libunity (7.1.3-0ubuntu1) UNRELEASED; urgency=low
17+
18+ * Pass hints to activation handler and properly handle goto_uri in AggregatorScope. (LP:
19+ #1243623)
20+
21+ -- Pawel Stolowski <pawel.stolowski@ubuntu.com> Thu, 24 Oct 2013 13:33:18 +0200
22+
23 libunity (7.1.2+13.10.20131010-0ubuntu2) saucy; urgency=low
24
25 * Declare a Breaks: against unity-common (<< 7.1.2) to help apt calculate
26
27=== modified file 'debian/libunity9.symbols'
28--- debian/libunity9.symbols 2013-10-01 03:48:37 +0000
29+++ debian/libunity9.symbols 2013-10-24 15:19:18 +0000
30@@ -89,12 +89,14 @@
31 unity_aggregator_activation_construct@Base 7.0.0daily13.05.31ubuntu.unity.next
32 unity_aggregator_activation_get_action_type@Base 7.0.0daily13.05.31ubuntu.unity.next
33 unity_aggregator_activation_get_channel_id@Base 7.0.0daily13.05.31ubuntu.unity.next
34+ unity_aggregator_activation_get_hints@Base 0replaceme
35 unity_aggregator_activation_get_scope_id@Base 7.0.0daily13.05.31ubuntu.unity.next
36 unity_aggregator_activation_get_scope_result@Base 7.0.0daily13.05.31ubuntu.unity.next
37 unity_aggregator_activation_get_type@Base 7.0.0daily13.05.31ubuntu.unity.next
38 unity_aggregator_activation_new@Base 7.0.0daily13.05.31ubuntu.unity.next
39 unity_aggregator_activation_set_action_type@Base 7.0.0daily13.05.31ubuntu.unity.next
40 unity_aggregator_activation_set_channel_id@Base 7.0.0daily13.05.31ubuntu.unity.next
41+ unity_aggregator_activation_set_hints@Base 0replaceme
42 unity_aggregator_activation_set_scope_id@Base 7.0.0daily13.05.31ubuntu.unity.next
43 unity_aggregator_activation_set_scope_result@Base 7.0.0daily13.05.31ubuntu.unity.next
44 unity_aggregator_scope_activate@Base 7.0.0daily13.05.31ubuntu.unity.next
45
46=== modified file 'src/unity-aggregator-scope-private.vala'
47--- src/unity-aggregator-scope-private.vala 2013-09-24 08:57:39 +0000
48+++ src/unity-aggregator-scope-private.vala 2013-10-24 15:19:18 +0000
49@@ -964,12 +964,18 @@
50 var result_arr_cpy = result_arr;
51 var activation_obj = new AggregatorActivation (channel_id, scope_id,
52 action_type, scope_result);
53+ activation_obj.hints = hints;
54
55 var response = yield owner.activate (activation_obj);
56 if (response != null)
57 {
58 var raw = ActivationReplyRaw ();
59 raw.uri = scope_result.uri;
60+ if (response.goto_uri != null)
61+ {
62+ var stripped = response.goto_uri.strip ();
63+ if (stripped != "") raw.uri = stripped;
64+ }
65 raw.handled = response.handled;
66 raw.hints = response.get_hints ();
67
68
69=== modified file 'src/unity-result-activation.vala'
70--- src/unity-result-activation.vala 2013-08-26 08:30:16 +0000
71+++ src/unity-result-activation.vala 2013-10-24 15:19:18 +0000
72@@ -98,6 +98,7 @@
73 public string scope_id { get; set; }
74 public uint action_type { get; set; }
75 public ScopeResult? scope_result { get; set; }
76+ public HashTable<string, Variant> hints { get; internal set; }
77
78 public AggregatorActivation (string channel_id, string scope_id,
79 uint action_type, ScopeResult? result)
80
81=== modified file 'test/vala/test-scope.vala'
82--- test/vala/test-scope.vala 2013-08-19 12:00:49 +0000
83+++ test/vala/test-scope.vala 2013-10-24 15:19:18 +0000
84@@ -144,6 +144,8 @@
85 Fixture.create<MasterScopeTester> (MasterScopeTester.test_progress_source_property));
86 Test.add_data_func ("/Unit/AggregatorScope/CategoryOrderSignal",
87 Fixture.create<AggregatorScopeTester> (AggregatorScopeTester.test_scope_category_order_signal));
88+ Test.add_data_func ("/Unit/AggregatorScope/Activation",
89+ Fixture.create<AggregatorScopeTester> (AggregatorScopeTester.test_scope_activation_handler));
90 Test.add_data_func ("/Unity/ScopeLoader/LoadScope",
91 Fixture.create<ScopeLoaderTester> (ScopeLoaderTester.test_load_scope));
92 Test.add_data_func ("/Unity/ScopeLoader/LoadGroup",
93@@ -637,29 +639,40 @@
94 return reply_dict;
95 }
96
97+ public static ActivationReplyRaw? activate (
98+ ScopeProxy proxy, string channel_id,
99+ Unity.Protocol.ActionType action_type,
100+ Unity.ScopeResult result,
101+ HashTable<string, Variant> hints)
102+ {
103+ var ml = new MainLoop ();
104+ var result_arr = scope_result_to_variant (result);
105+ Unity.Protocol.ActivationReplyRaw? activation_reply = null;
106+ proxy.activate.begin (channel_id, result_arr,
107+ action_type,
108+ hints,
109+ null,
110+ (obj, res) =>
111+ {
112+ try
113+ {
114+ activation_reply = proxy.activate.end (res);
115+ }
116+ catch (Error err) { warning ("%s", err.message); }
117+ ml.quit ();
118+ });
119+
120+ assert (run_with_timeout (ml));
121+ return activation_reply;
122+ }
123+
124 public static ActivationReplyRaw? activate_result (
125 ScopeProxy proxy, string channel_id, Unity.ScopeResult result,
126 TestScope? target_scope = null)
127 {
128- var ml = new MainLoop ();
129- var result_arr = scope_result_to_variant (result);
130- Unity.Protocol.ActivationReplyRaw? activation_reply = null;
131- proxy.activate.begin (channel_id, result_arr,
132- Unity.Protocol.ActionType.ACTIVATE_RESULT,
133- new HashTable<string, Variant> (null, null),
134- null,
135- (obj, res) =>
136- {
137- try
138- {
139- activation_reply = proxy.activate.end (res);
140- }
141- catch (Error err) { warning ("%s", err.message); }
142- ml.quit ();
143- });
144-
145- assert (run_with_timeout (ml));
146- return activation_reply;
147+ return activate (proxy, channel_id, Unity.Protocol.ActionType.ACTIVATE_RESULT,
148+ result,
149+ new HashTable<string, Variant> (null, null));
150 }
151
152 public static HashTable<string, Variant> preview_result (
153@@ -2215,6 +2228,8 @@
154 {
155 class AggScope: Unity.AggregatorScope
156 {
157+ public signal Unity.ActivationResponse? activation_response_hook (Unity.AggregatorActivation activation);
158+
159 public AggScope (string dbus_path, string id)
160 {
161 Object (dbus_path: dbus_path, id: id, is_master: true, merge_mode: Unity.AggregatorScope.MergeMode.OWNER_SCOPE);
162@@ -2241,6 +2256,11 @@
163 return 0;
164 }
165
166+ public override async Unity.ActivationResponse? activate (Unity.AggregatorActivation activation)
167+ {
168+ return activation_response_hook (activation);
169+ }
170+
171 public override async void search (Unity.AggregatedScopeSearch scope_search)
172 {
173 var order = new uint32[] {1,0};
174@@ -2297,6 +2317,49 @@
175 assert (reply_dict != null);
176 assert (got_order_changed == true);
177 }
178+
179+ public void test_scope_activation_handler ()
180+ {
181+ Unity.AggregatorActivation? got_activate = null;
182+
183+ assert (proxy != null);
184+
185+ var channel_id = ScopeTester.open_channel (proxy, ChannelType.DEFAULT, null);
186+ assert (channel_id != null);
187+
188+ Unity.ScopeResult result = Unity.ScopeResult ();
189+ result.uri = "file:///foo";
190+ result.icon_hint = "";
191+ result.category = 0;
192+ result.result_type = Unity.ResultType.DEFAULT;
193+ result.mimetype = "inode/folder";
194+ result.title = "Title";
195+ result.comment = "";
196+ result.dnd_uri = "file:///";
197+ result.metadata = new HashTable<string, Variant> (str_hash, str_equal);
198+ result.metadata["scope-id"] = new Variant.string ("foo.scope");
199+ result.metadata["content"] = new HashTable<string, Variant> (str_hash, str_equal);
200+
201+ var hints = new HashTable<string, Variant>(str_hash, str_equal);
202+ hints[Unity.Internal.ACTIVATE_PREVIEW_ACTION_HINT] = new Variant.string ("id1");
203+ hints["foo"] = new Variant.string ("bar");
204+
205+ agg_scope.activation_response_hook.connect ((aggactivation) => {
206+ got_activate = aggactivation;
207+ return new Unity.ActivationResponse (Unity.HandledType.NOT_HANDLED, "http://ubuntu.com");
208+ });
209+
210+ ActivationReplyRaw? activation_reply = ScopeTester.activate (proxy, channel_id, Unity.Protocol.ActionType.PREVIEW_ACTION, result, hints);
211+
212+ assert (got_activate != null);
213+ assert (activation_reply != null);
214+ assert (activation_reply.handled == Unity.HandledType.NOT_HANDLED);
215+ assert (activation_reply.uri == "http://ubuntu.com");
216+ assert (got_activate.channel_id == channel_id);
217+ assert (got_activate.hints != null);
218+ assert (got_activate.hints[Unity.Internal.ACTIVATE_PREVIEW_ACTION_HINT].get_string () == "id1");
219+ assert (got_activate.hints["foo"].get_string () == "bar");
220+ }
221 }
222
223 class TestScopeLoader: Unity.ScopeLoader

Subscribers

People subscribed via source and target branches