Merge lp:~ted/ubuntu-app-launch/signal-instances into lp:ubuntu-app-launch

Proposed by Ted Gould
Status: Merged
Approved by: Marcus Tomlinson
Approved revision: 280
Merged at revision: 278
Proposed branch: lp:~ted/ubuntu-app-launch/signal-instances
Merge into: lp:ubuntu-app-launch
Prerequisite: lp:~ted/ubuntu-app-launch/jobs-signals
Diff against target: 732 lines (+149/-86)
21 files modified
application-failed.c (+9/-2)
data/com.canonical.UbuntuAppLaunch.xml (+8/-0)
helpers.c (+2/-2)
helpers.h (+1/-0)
libubuntu-app-launch/application-impl-base.h (+2/-0)
libubuntu-app-launch/application-impl-click.cpp (+5/-0)
libubuntu-app-launch/application-impl-click.h (+2/-0)
libubuntu-app-launch/application-impl-legacy.cpp (+5/-0)
libubuntu-app-launch/application-impl-legacy.h (+2/-0)
libubuntu-app-launch/application-impl-libertine.cpp (+5/-0)
libubuntu-app-launch/application-impl-libertine.h (+2/-0)
libubuntu-app-launch/application-impl-snap.cpp (+5/-0)
libubuntu-app-launch/application-impl-snap.h (+2/-0)
libubuntu-app-launch/jobs-base.cpp (+14/-6)
libubuntu-app-launch/jobs-base.h (+1/-0)
libubuntu-app-launch/jobs-upstart.cpp (+15/-12)
libubuntu-app-launch/second-exec-core.c (+6/-3)
libubuntu-app-launch/second-exec-core.h (+1/-1)
tests/helper-handshake-test.cc (+4/-4)
tests/libual-cpp-test.cc (+31/-29)
tests/libual-test.cc (+27/-27)
To merge this branch: bzr merge lp:~ted/ubuntu-app-launch/signal-instances
Reviewer Review Type Date Requested Status
Marcus Tomlinson (community) Approve
unity-api-1-bot continuous-integration Needs Fixing
Review via email: mp+310588@code.launchpad.net

Commit message

Make the signals support finding the instance of the application

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
277. By Ted Gould

Jobs signals fix

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
278. By Ted Gould

Fix tests

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:278
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/147/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/1325/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1332
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1109
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1109/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1109/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1109/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1109
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1109/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1109
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1109/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1109
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1109/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/147/rebuild

review: Needs Fixing (continuous-integration)
279. By Ted Gould

Merge updates from the jobs-signal branch

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:279
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/160/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/1353/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1360
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1138
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1138/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1138
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1138/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1138
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1138/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1138/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1138
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1138/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1138
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1138/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/160/rebuild

review: Needs Fixing (continuous-integration)
280. By Ted Gould

Update to trunk

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:280
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/171/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/1453/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1460
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1239/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1239/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1239
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1239/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1239
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1239/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1239/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1239
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1239/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/171/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Looks good. I've done a bit of manual testing of UAL in the unity8 desktop session as well, and looks like things are coming together really nicely.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'application-failed.c'
2--- application-failed.c 2016-08-17 15:45:28 +0000
3+++ application-failed.c 2017-01-19 03:24:11 +0000
4@@ -35,9 +35,10 @@
5 }
6
7 gchar * appid = g_strdup(instance);
8+ gchar * lasthyphenstanding = NULL;
9 if (g_strcmp0(job, "application-legacy") == 0
10 || g_strcmp0(job, "application-snap") == 0) {
11- gchar * lasthyphenstanding = g_strrstr(appid, "-");
12+ lasthyphenstanding = g_strrstr(appid, "-");
13 if (lasthyphenstanding != NULL) {
14 lasthyphenstanding[0] = '\0';
15 } else {
16@@ -45,6 +46,12 @@
17 }
18 }
19
20+ if (lasthyphenstanding == NULL) {
21+ lasthyphenstanding = "";
22+ } else {
23+ lasthyphenstanding++;
24+ }
25+
26 GDBusConnection * bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
27 g_return_val_if_fail(bus != NULL, -1);
28
29@@ -54,7 +61,7 @@
30 "/", /* path */
31 "com.canonical.UbuntuAppLaunch",
32 "ApplicationFailed",
33- g_variant_new("(ss)", appid, crashed ? "crash" : "start-failure"),
34+ g_variant_new("(sss)", appid, lasthyphenstanding, crashed ? "crash" : "start-failure"),
35 &error);
36
37 g_debug("Emitting failed event '%s' for app '%s'", crashed ? "crash" : "start-failure", appid);
38
39=== modified file 'data/com.canonical.UbuntuAppLaunch.xml'
40--- data/com.canonical.UbuntuAppLaunch.xml 2015-03-04 14:26:35 +0000
41+++ data/com.canonical.UbuntuAppLaunch.xml 2017-01-19 03:24:11 +0000
42@@ -3,29 +3,37 @@
43 <interface name="com.canonical.UpstartAppLaunch">
44 <signal name="UnityResumeRequest">
45 <arg type="s" name="appid" />
46+ <arg type="s" name="instance" />
47 </signal>
48 <signal name="UnityResumeResponse">
49 <arg type="s" name="appid" />
50+ <arg type="s" name="instance" />
51 </signal>
52 <signal name="UnityFocusRequest">
53 <arg type="s" name="appid" />
54+ <arg type="s" name="instance" />
55 </signal>
56 <signal name="UnityStartingBroadcast">
57 <arg type="s" name="appid" />
58+ <arg type="s" name="instance" />
59 </signal>
60 <signal name="UnityStartingSignal">
61 <arg type="s" name="appid" />
62+ <arg type="s" name="instance" />
63 </signal>
64 <signal name="ApplicationFailed">
65 <arg type="s" name="appid" />
66+ <arg type="s" name="instance" />
67 <arg type="s" name="stage" />
68 </signal>
69 <signal name="ApplicationPaused">
70 <arg type="s" name="appid" />
71+ <arg type="s" name="instance" />
72 <arg type="at" name="pids" />
73 </signal>
74 <signal name="ApplicationResumed">
75 <arg type="s" name="appid" />
76+ <arg type="s" name="instance" />
77 <arg type="at" name="pids" />
78 </signal>
79 </interface>
80
81=== modified file 'helpers.c'
82--- helpers.c 2016-09-06 16:13:19 +0000
83+++ helpers.c 2017-01-19 03:24:11 +0000
84@@ -503,7 +503,7 @@
85 }
86
87 handshake_t *
88-starting_handshake_start (const gchar * app_id, int timeout_s)
89+starting_handshake_start (const gchar * app_id, const gchar * instance_id, int timeout_s)
90 {
91 GError * error = NULL;
92 handshake_t * handshake = g_new0(handshake_t, 1);
93@@ -537,7 +537,7 @@
94 "/", /* path */
95 "com.canonical.UbuntuAppLaunch", /* interface */
96 "UnityStartingBroadcast", /* signal */
97- g_variant_new("(s)", app_id),
98+ g_variant_new("(ss)", app_id, instance_id),
99 &error);
100
101 /* Really, Unity? */
102
103=== modified file 'helpers.h'
104--- helpers.h 2016-09-06 16:13:19 +0000
105+++ helpers.h 2017-01-19 03:24:11 +0000
106@@ -48,6 +48,7 @@
107
108 typedef struct _handshake_t handshake_t;
109 handshake_t * starting_handshake_start (const gchar * app_id,
110+ const gchar * instance_id,
111 int timeout_s);
112 void starting_handshake_wait (handshake_t * handshake);
113
114
115=== modified file 'libubuntu-app-launch/application-impl-base.h'
116--- libubuntu-app-launch/application-impl-base.h 2017-01-19 03:24:10 +0000
117+++ libubuntu-app-launch/application-impl-base.h 2017-01-19 03:24:11 +0000
118@@ -43,6 +43,8 @@
119
120 bool hasInstances() override;
121
122+ virtual std::shared_ptr<Application::Instance> findInstance(const std::string& instanceid) = 0;
123+
124 protected:
125 /** Pointer to the registry so we can ask it for things */
126 std::shared_ptr<Registry> _registry;
127
128=== modified file 'libubuntu-app-launch/application-impl-click.cpp'
129--- libubuntu-app-launch/application-impl-click.cpp 2017-01-19 03:24:10 +0000
130+++ libubuntu-app-launch/application-impl-click.cpp 2017-01-19 03:24:11 +0000
131@@ -359,6 +359,11 @@
132 envfunc);
133 }
134
135+std::shared_ptr<Application::Instance> Click::findInstance(const std::string& instanceid)
136+{
137+ return _registry->impl->jobs->existing(appId(), "application-click", instanceid, std::vector<Application::URL>{});
138+}
139+
140 } // namespace app_impls
141 } // namespace app_launch
142 } // namespace ubuntu
143
144=== modified file 'libubuntu-app-launch/application-impl-click.h'
145--- libubuntu-app-launch/application-impl-click.h 2016-08-24 21:01:35 +0000
146+++ libubuntu-app-launch/application-impl-click.h 2017-01-19 03:24:11 +0000
147@@ -76,6 +76,8 @@
148 const AppID::AppName& appname,
149 const std::shared_ptr<Registry>& registry);
150
151+ virtual std::shared_ptr<Application::Instance> findInstance(const std::string& instanceid) override;
152+
153 private:
154 AppID _appid;
155
156
157=== modified file 'libubuntu-app-launch/application-impl-legacy.cpp'
158--- libubuntu-app-launch/application-impl-legacy.cpp 2017-01-19 03:24:10 +0000
159+++ libubuntu-app-launch/application-impl-legacy.cpp 2017-01-19 03:24:11 +0000
160@@ -387,6 +387,11 @@
161 envfunc);
162 }
163
164+std::shared_ptr<Application::Instance> Legacy::findInstance(const std::string& instanceid)
165+{
166+ return _registry->impl->jobs->existing(appId(), "application-legacy", instanceid, std::vector<Application::URL>{});
167+}
168+
169 } // namespace app_impls
170 } // namespace app_launch
171 } // namespace ubuntu
172
173=== modified file 'libubuntu-app-launch/application-impl-legacy.h'
174--- libubuntu-app-launch/application-impl-legacy.h 2016-09-23 21:54:33 +0000
175+++ libubuntu-app-launch/application-impl-legacy.h 2017-01-19 03:24:11 +0000
176@@ -77,6 +77,8 @@
177 const AppID::AppName& appname,
178 const std::shared_ptr<Registry>& registry);
179
180+ virtual std::shared_ptr<Application::Instance> findInstance(const std::string& instanceid) override;
181+
182 private:
183 AppID::AppName _appname;
184 std::string _basedir;
185
186=== modified file 'libubuntu-app-launch/application-impl-libertine.cpp'
187--- libubuntu-app-launch/application-impl-libertine.cpp 2017-01-19 03:24:10 +0000
188+++ libubuntu-app-launch/application-impl-libertine.cpp 2017-01-19 03:24:11 +0000
189@@ -329,6 +329,11 @@
190 envfunc);
191 }
192
193+std::shared_ptr<Application::Instance> Libertine::findInstance(const std::string& instanceid)
194+{
195+ return _registry->impl->jobs->existing(appId(), "application-legacy", instanceid, std::vector<Application::URL>{});
196+}
197+
198 } // namespace app_impls
199 } // namespace app_launch
200 } // namespace ubuntu
201
202=== modified file 'libubuntu-app-launch/application-impl-libertine.h'
203--- libubuntu-app-launch/application-impl-libertine.h 2016-09-13 00:59:08 +0000
204+++ libubuntu-app-launch/application-impl-libertine.h 2017-01-19 03:24:11 +0000
205@@ -81,6 +81,8 @@
206 const AppID::AppName& appname,
207 const std::shared_ptr<Registry>& registry);
208
209+ virtual std::shared_ptr<Application::Instance> findInstance(const std::string& instanceid) override;
210+
211 private:
212 AppID::Package _container;
213 AppID::AppName _appname;
214
215=== modified file 'libubuntu-app-launch/application-impl-snap.cpp'
216--- libubuntu-app-launch/application-impl-snap.cpp 2017-01-19 03:24:10 +0000
217+++ libubuntu-app-launch/application-impl-snap.cpp 2017-01-19 03:24:11 +0000
218@@ -483,6 +483,11 @@
219 envfunc);
220 }
221
222+std::shared_ptr<Application::Instance> Snap::findInstance(const std::string& instanceid)
223+{
224+ return _registry->impl->jobs->existing(appId(), "application-snap", instanceid, std::vector<Application::URL>{});
225+}
226+
227 } // namespace app_impls
228 } // namespace app_launch
229 } // namespace ubuntu
230
231=== modified file 'libubuntu-app-launch/application-impl-snap.h'
232--- libubuntu-app-launch/application-impl-snap.h 2016-08-25 16:58:04 +0000
233+++ libubuntu-app-launch/application-impl-snap.h 2017-01-19 03:24:11 +0000
234@@ -75,6 +75,8 @@
235 const AppID::AppName& appname,
236 const std::shared_ptr<Registry>& registry);
237
238+ virtual std::shared_ptr<Application::Instance> findInstance(const std::string& instanceid) override;
239+
240 private:
241 /** AppID of the Snap. Should be the name of the snap package.
242 The name of the command. And then the revision. */
243
244=== modified file 'libubuntu-app-launch/jobs-base.cpp'
245--- libubuntu-app-launch/jobs-base.cpp 2017-01-19 03:24:10 +0000
246+++ libubuntu-app-launch/jobs-base.cpp 2017-01-19 03:24:11 +0000
247@@ -22,6 +22,7 @@
248 #include <cstring>
249 #include <numeric>
250
251+#include "application-impl-base.h"
252 #include "jobs-base.h"
253 #include "jobs-upstart.h"
254 #include "registry-impl.h"
255@@ -83,7 +84,8 @@
256 {
257 std::vector<pid_t> pids;
258 GVariant* vappid = g_variant_get_child_value(params.get(), 0);
259- GVariant* vpids = g_variant_get_child_value(params.get(), 1);
260+ GVariant* vinstid = g_variant_get_child_value(params.get(), 1);
261+ GVariant* vpids = g_variant_get_child_value(params.get(), 2);
262 guint64 pid;
263 GVariantIter thispid;
264 g_variant_iter_init(&thispid, vpids);
265@@ -94,13 +96,16 @@
266 }
267
268 auto cappid = g_variant_get_string(vappid, NULL);
269+ auto cinstid = g_variant_get_string(vinstid, NULL);
270+
271 auto appid = ubuntu::app_launch::AppID::find(reg, cappid);
272 auto app = Application::create(appid, reg);
273+ auto inst = std::dynamic_pointer_cast<app_impls::Base>(app)->findInstance(cinstid);
274
275- /* TODO: Instance */
276- signal(app, {}, pids);
277+ signal(app, inst, pids);
278
279 g_variant_unref(vappid);
280+ g_variant_unref(vinstid);
281 g_variant_unref(vpids);
282
283 return;
284@@ -213,7 +218,8 @@
285 std::shared_ptr<Application::Instance> instance;
286
287 const gchar* cappid = nullptr;
288- g_variant_get(params.get(), "(&s)", &cappid);
289+ const gchar* cinstid = nullptr;
290+ g_variant_get(params.get(), "(&s&s)", &cappid, &cinstid);
291
292 auto appid = ubuntu::app_launch::AppID::find(reg, cappid);
293 app = ubuntu::app_launch::Application::create(appid, reg);
294@@ -449,7 +455,7 @@
295 oomValueToPid(pid, oomval);
296 });
297
298- pidListToDbus(registry_, appId_, pids, "ApplicationPaused");
299+ pidListToDbus(registry_, appId_, instance_, pids, "ApplicationPaused");
300 }
301
302 /** Resumes this application by sending SIGCONT to all the PIDs in the
303@@ -466,7 +472,7 @@
304 oomValueToPid(pid, oomval);
305 });
306
307- pidListToDbus(registry_, appId_, pids, "ApplicationResumed");
308+ pidListToDbus(registry_, appId_, instance_, pids, "ApplicationResumed");
309 }
310
311 /** Go through the list of PIDs calling a function and handling
312@@ -504,6 +510,7 @@
313 */
314 void Base::pidListToDbus(const std::shared_ptr<Registry>& reg,
315 const AppID& appid,
316+ const std::string& instanceid,
317 const std::vector<pid_t>& pids,
318 const std::string& signal)
319 {
320@@ -534,6 +541,7 @@
321 GVariantBuilder params;
322 g_variant_builder_init(&params, G_VARIANT_TYPE_TUPLE);
323 g_variant_builder_add_value(&params, g_variant_new_string(std::string(appid).c_str()));
324+ g_variant_builder_add_value(&params, g_variant_new_string(instanceid.c_str()));
325 g_variant_builder_add_value(&params, vpids.get());
326
327 GError* error = nullptr;
328
329=== modified file 'libubuntu-app-launch/jobs-base.h'
330--- libubuntu-app-launch/jobs-base.h 2017-01-19 03:24:10 +0000
331+++ libubuntu-app-launch/jobs-base.h 2017-01-19 03:24:11 +0000
332@@ -69,6 +69,7 @@
333 std::vector<pid_t> forAllPids(std::function<void(pid_t)> eachPid);
334 static void pidListToDbus(const std::shared_ptr<Registry>& reg,
335 const AppID& appid,
336+ const std::string& instanceid,
337 const std::vector<pid_t>& pids,
338 const std::string& signal);
339 static void signalToPid(pid_t pid, int signal);
340
341=== modified file 'libubuntu-app-launch/jobs-upstart.cpp'
342--- libubuntu-app-launch/jobs-upstart.cpp 2017-01-19 03:24:10 +0000
343+++ libubuntu-app-launch/jobs-upstart.cpp 2017-01-19 03:24:11 +0000
344@@ -27,6 +27,7 @@
345 #include <cgmanager/cgmanager.h>
346 #include <upstart.h>
347
348+#include "application-impl-base.h"
349 #include "helpers.h"
350 #include "registry-impl.h"
351 #include "second-exec-core.h"
352@@ -380,6 +381,7 @@
353 data->ptr->registry_->impl->thread.getCancellable().get(), /* cancellable */
354 data->ptr->primaryPid(), /* primary pid */
355 std::string(data->ptr->appId_).c_str(), /* appid */
356+ std::string(data->ptr->instance_).c_str(), /* instance */
357 urls.get()); /* urls */
358 }
359
360@@ -439,9 +441,10 @@
361
362 auto registry = registry_;
363 auto appid = appId_;
364+ auto instance = instance_;
365 auto jobpath = upstartJobPath();
366
367- registry->impl->thread.executeOnThread([registry, appid, jobpath] {
368+ registry->impl->thread.executeOnThread([registry, appid, instance, jobpath] {
369 auto pids = forAllPids(registry, appid, jobpath, [](pid_t pid) {
370 auto oomval = oom::paused();
371 g_debug("Pausing PID: %d (%d)", pid, int(oomval));
372@@ -449,7 +452,7 @@
373 oomValueToPid(pid, oomval);
374 });
375
376- pidListToDbus(registry, appid, pids, "ApplicationPaused");
377+ pidListToDbus(registry, appid, instance, pids, "ApplicationPaused");
378 });
379
380 registry_->impl->zgSendEvent(appId_, ZEITGEIST_ZG_LEAVE_EVENT);
381@@ -463,9 +466,10 @@
382
383 auto registry = registry_;
384 auto appid = appId_;
385+ auto instance = instance_;
386 auto jobpath = upstartJobPath();
387
388- registry->impl->thread.executeOnThread([registry, appid, jobpath] {
389+ registry->impl->thread.executeOnThread([registry, appid, instance, jobpath] {
390 auto pids = forAllPids(registry, appid, jobpath, [](pid_t pid) {
391 auto oomval = oom::focused();
392 g_debug("Resuming PID: %d (%d)", pid, int(oomval));
393@@ -473,7 +477,7 @@
394 oomValueToPid(pid, oomval);
395 });
396
397- pidListToDbus(registry, appid, pids, "ApplicationResumed");
398+ pidListToDbus(registry, appid, instance, pids, "ApplicationResumed");
399 });
400
401 registry_->impl->zgSendEvent(appId_, ZEITGEIST_ZG_ACCESS_EVENT);
402@@ -555,7 +559,7 @@
403 timeout = 0;
404 }
405
406- auto handshake = starting_handshake_start(appIdStr.c_str(), timeout);
407+ auto handshake = starting_handshake_start(appIdStr.c_str(), instance.c_str(), timeout);
408 if (handshake == nullptr)
409 {
410 g_warning("Unable to setup starting handshake");
411@@ -749,10 +753,9 @@
412
413 auto appid = AppID::find(reg, sappid);
414 auto app = Application::create(appid, reg);
415-
416- // TODO: Figure otu creating instances
417-
418- signal(app, {});
419+ auto inst = std::dynamic_pointer_cast<app_impls::Base>(app)->findInstance(instance);
420+
421+ signal(app, inst);
422 }
423
424 /** Grab the signal object for application startup. If we're not already listing for
425@@ -878,10 +881,11 @@
426 }
427
428 const gchar* sappid = nullptr;
429+ const gchar* sinstid = nullptr;
430 const gchar* typestr = nullptr;
431
432 Registry::FailureType type = Registry::FailureType::CRASH;
433- g_variant_get(params, "(&s&s)", &sappid, &typestr);
434+ g_variant_get(params, "(&s&s&s)", &sappid, &sinstid, &typestr);
435
436 if (g_strcmp0("crash", typestr) == 0)
437 {
438@@ -898,8 +902,7 @@
439
440 auto appid = AppID::find(reg, sappid);
441 auto app = Application::create(appid, reg);
442-
443- /* TODO: Instance issues */
444+ auto inst = std::dynamic_pointer_cast<app_impls::Base>(app)->findInstance(sinstid);
445
446 auto upstart = std::dynamic_pointer_cast<Upstart>(reg->impl->jobs);
447 upstart->sig_appFailed(app, {}, type);
448
449=== modified file 'libubuntu-app-launch/second-exec-core.c'
450--- libubuntu-app-launch/second-exec-core.c 2016-08-03 21:19:02 +0000
451+++ libubuntu-app-launch/second-exec-core.c 2017-01-19 03:24:11 +0000
452@@ -29,6 +29,7 @@
453 typedef struct {
454 GDBusConnection * bus;
455 gchar * appid;
456+ gchar * instanceid;
457 gchar ** input_uris;
458 GPid app_pid;
459 guint connections_open;
460@@ -355,7 +356,7 @@
461 }
462
463 gboolean
464-second_exec (GDBusConnection * session, GCancellable * cancel, GPid pid, const gchar * app_id, gchar ** appuris)
465+second_exec (GDBusConnection * session, GCancellable * cancel, GPid pid, const gchar * app_id, const gchar * instance_id, gchar ** appuris)
466 {
467 ual_tracepoint(second_exec_start, app_id);
468 GError * error = NULL;
469@@ -363,6 +364,7 @@
470 /* Setup our continuation data */
471 second_exec_t * data = g_new0(second_exec_t, 1);
472 data->appid = g_strdup(app_id);
473+ data->instanceid = g_strdup(instance_id);
474 data->input_uris = g_strdupv(appuris);
475 data->bus = g_object_ref(session);
476 data->app_pid = pid;
477@@ -387,7 +389,7 @@
478 "/", /* path */
479 "com.canonical.UbuntuAppLaunch", /* interface */
480 "UnityResumeRequest", /* signal */
481- g_variant_new("(s)", app_id),
482+ g_variant_new("(ss)", app_id, instance_id),
483 &error);
484
485 /* Now we start a race, we try to get to the point of knowing who
486@@ -435,7 +437,7 @@
487 "/", /* path */
488 "com.canonical.UbuntuAppLaunch", /* interface */
489 "UnityFocusRequest", /* signal */
490- g_variant_new("(s)", data->appid),
491+ g_variant_new("(ss)", data->appid, data->instanceid),
492 &error);
493
494 if (error != NULL) {
495@@ -467,6 +469,7 @@
496 if (data->app_data != NULL)
497 g_variant_unref(data->app_data);
498 g_free(data->appid);
499+ g_free(data->instanceid);
500 g_strfreev(data->input_uris);
501 g_free(data->dbus_path);
502 g_free(data);
503
504=== modified file 'libubuntu-app-launch/second-exec-core.h'
505--- libubuntu-app-launch/second-exec-core.h 2016-08-03 21:19:02 +0000
506+++ libubuntu-app-launch/second-exec-core.h 2017-01-19 03:24:11 +0000
507@@ -22,7 +22,7 @@
508
509 G_BEGIN_DECLS
510
511-gboolean second_exec (GDBusConnection * con, GCancellable * cancel, GPid pid, const gchar * app_id, gchar ** appuris);
512+gboolean second_exec (GDBusConnection * con, GCancellable * cancel, GPid pid, const gchar * app_id, const gchar * instance_id, gchar ** appuris);
513
514 G_END_DECLS
515
516
517=== modified file 'tests/helper-handshake-test.cc'
518--- tests/helper-handshake-test.cc 2016-09-02 14:02:18 +0000
519+++ tests/helper-handshake-test.cc 2017-01-19 03:24:11 +0000
520@@ -51,7 +51,7 @@
521 GDBusMessage * FilterFunc (GDBusConnection * conn, GDBusMessage * message, gboolean incomming) {
522 if (g_strcmp0(g_dbus_message_get_member(message), "UnityStartingBroadcast") == 0) {
523 GVariant * body = g_dbus_message_get_body(message);
524- GVariant * correct_body = g_variant_new("(s)", "fooapp");
525+ GVariant * correct_body = g_variant_new("(ss)", "fooapp", "instance");
526 g_variant_ref_sink(correct_body);
527
528 [body, correct_body]() {
529@@ -77,7 +77,7 @@
530 GDBusConnection * con = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
531 guint filter = g_dbus_connection_add_filter(con, filter_func, this, NULL);
532
533- handshake_t * handshake = starting_handshake_start("fooapp", 1);
534+ handshake_t * handshake = starting_handshake_start("fooapp", "instance", 1);
535
536 g_main_loop_run(mainloop);
537
538@@ -88,7 +88,7 @@
539 "/", /* path */
540 "com.canonical.UbuntuAppLaunch", /* interface */
541 "UnityStartingSignal", /* signal */
542- g_variant_new("(s)", "fooapp"), /* params, the same */
543+ g_variant_new("(ss)", "fooapp", "instance"), /* params, the same */
544 NULL);
545
546 starting_handshake_wait(handshake);
547@@ -109,7 +109,7 @@
548 TEST_F(HelperHandshakeTest, HandshakeTimeout)
549 {
550 bool timeout_reached = false;
551- handshake_t * handshake = starting_handshake_start("fooapp", 1);
552+ handshake_t * handshake = starting_handshake_start("fooapp", "instance", 1);
553
554 guint outertimeout = g_timeout_add_seconds(2, two_second_reached, &timeout_reached);
555
556
557=== modified file 'tests/libual-cpp-test.cc'
558--- tests/libual-cpp-test.cc 2017-01-19 03:24:10 +0000
559+++ tests/libual-cpp-test.cc 2017-01-19 03:24:11 +0000
560@@ -1002,12 +1002,13 @@
561 &starting_count, NULL);
562
563 /* Emit a signal */
564- g_dbus_connection_emit_signal(session, NULL, /* destination */
565- "/", /* path */
566- "com.canonical.UbuntuAppLaunch", /* interface */
567- "UnityStartingBroadcast", /* signal */
568- g_variant_new("(s)", "com.test.good_application_1.2.3"), /* params, the same */
569- NULL);
570+ g_dbus_connection_emit_signal(
571+ session, NULL, /* destination */
572+ "/", /* path */
573+ "com.canonical.UbuntuAppLaunch", /* interface */
574+ "UnityStartingBroadcast", /* signal */
575+ g_variant_new("(ss)", "com.test.good_application_1.2.3", "goodinstance"), /* params, the same */
576+ NULL);
577
578 /* Make sure we run our observer */
579 EXPECT_EVENTUALLY_EQ(ubuntu::app_launch::AppID(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"),
580@@ -1078,12 +1079,13 @@
581 int i;
582 for (i = 0; i < 5; i++)
583 {
584- g_dbus_connection_emit_signal(session, NULL, /* destination */
585- "/", /* path */
586- "com.canonical.UbuntuAppLaunch", /* interface */
587- "UnityResumeResponse", /* signal */
588- g_variant_new("(s)", "com.test.good_application_1.2.3"), /* params, the same */
589- NULL);
590+ g_dbus_connection_emit_signal(
591+ session, NULL, /* destination */
592+ "/", /* path */
593+ "com.canonical.UbuntuAppLaunch", /* interface */
594+ "UnityResumeResponse", /* signal */
595+ g_variant_new("(ss)", "com.test.good_application_1.2.3", "goodinstance"), /* params, the same */
596+ NULL);
597
598 pause(50); /* Ensure all the events come through */
599 }
600@@ -1247,11 +1249,11 @@
601 GDBusConnection* session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
602
603 g_dbus_connection_emit_signal(
604- session, NULL, /* destination */
605- "/", /* path */
606- "com.canonical.UbuntuAppLaunch", /* interface */
607- "ApplicationFailed", /* signal */
608- g_variant_new("(ss)", "com.test.good_application_1.2.3", "crash"), /* params, the same */
609+ session, NULL, /* destination */
610+ "/", /* path */
611+ "com.canonical.UbuntuAppLaunch", /* interface */
612+ "ApplicationFailed", /* signal */
613+ g_variant_new("(sss)", "com.test.good_application_1.2.3", "goodinstance", "crash"), /* params, the same */
614 NULL);
615
616 EXPECT_EVENTUALLY_EQ(ubuntu::app_launch::AppID::parse("com.test.good_application_1.2.3"), lastFailedApp);
617@@ -1260,24 +1262,24 @@
618 lastFailedApp = ubuntu::app_launch::AppID();
619
620 g_dbus_connection_emit_signal(
621- session, NULL, /* destination */
622- "/", /* path */
623- "com.canonical.UbuntuAppLaunch", /* interface */
624- "ApplicationFailed", /* signal */
625- g_variant_new("(ss)", "com.test.good_application_1.2.3", "blahblah"), /* params, the same */
626+ session, NULL, /* destination */
627+ "/", /* path */
628+ "com.canonical.UbuntuAppLaunch", /* interface */
629+ "ApplicationFailed", /* signal */
630+ g_variant_new("(sss)", "com.test.good_application_1.2.3", "goodinstance", "blahblah"), /* params, the same */
631 NULL);
632
633 EXPECT_EVENTUALLY_EQ(ubuntu::app_launch::AppID::parse("com.test.good_application_1.2.3"), lastFailedApp);
634
635 lastFailedApp = ubuntu::app_launch::AppID();
636
637- g_dbus_connection_emit_signal(
638- session, NULL, /* destination */
639- "/", /* path */
640- "com.canonical.UbuntuAppLaunch", /* interface */
641- "ApplicationFailed", /* signal */
642- g_variant_new("(ss)", "com.test.good_application_1.2.3", "start-failure"), /* params, the same */
643- NULL);
644+ g_dbus_connection_emit_signal(session, NULL, /* destination */
645+ "/", /* path */
646+ "com.canonical.UbuntuAppLaunch", /* interface */
647+ "ApplicationFailed", /* signal */
648+ g_variant_new("(sss)", "com.test.good_application_1.2.3", "goodinstance",
649+ "start-failure"), /* params, the same */
650+ NULL);
651
652 EXPECT_EVENTUALLY_EQ(ubuntu::app_launch::Registry::FailureType::START_FAILURE, lastFailedType);
653
654
655=== modified file 'tests/libual-test.cc'
656--- tests/libual-test.cc 2016-09-14 15:29:35 +0000
657+++ tests/libual-test.cc 2017-01-19 03:24:11 +0000
658@@ -752,7 +752,7 @@
659 "/", /* path */
660 "com.canonical.UbuntuAppLaunch", /* interface */
661 "UnityStartingBroadcast", /* signal */
662- g_variant_new("(s)", "com.test.good_application_1.2.3"), /* params, the same */
663+ g_variant_new("(ss)", "com.test.good_application_1.2.3", "goodinstance"), /* params, the same */
664 NULL);
665
666 EXPECT_EVENTUALLY_EQ("com.test.good_application_1.2.3", last_observer);
667@@ -817,7 +817,7 @@
668 "/", /* path */
669 "com.canonical.UbuntuAppLaunch", /* interface */
670 "UnityResumeResponse", /* signal */
671- g_variant_new("(s)", "com.test.good_application_1.2.3"), /* params, the same */
672+ g_variant_new("(ss)", "com.test.good_application_1.2.3", "goodinstance"), /* params, the same */
673 NULL);
674
675 pause(50); /* Ensure all the events come through */
676@@ -974,31 +974,31 @@
677 "/", /* path */
678 "com.canonical.UbuntuAppLaunch", /* interface */
679 "ApplicationFailed", /* signal */
680- g_variant_new("(ss)", "com.test.good_application_1.2.3", "crash"), /* params, the same */
681- NULL);
682-
683- EXPECT_EVENTUALLY_EQ("com.test.good_application_1.2.3", last_observer);
684-
685- last_observer.clear();
686-
687- g_dbus_connection_emit_signal(session,
688- NULL, /* destination */
689- "/", /* path */
690- "com.canonical.UbuntuAppLaunch", /* interface */
691- "ApplicationFailed", /* signal */
692- g_variant_new("(ss)", "com.test.good_application_1.2.3", "blahblah"), /* params, the same */
693- NULL);
694-
695- EXPECT_EVENTUALLY_EQ("com.test.good_application_1.2.3", last_observer);
696-
697- last_observer.clear();
698-
699- g_dbus_connection_emit_signal(session,
700- NULL, /* destination */
701- "/", /* path */
702- "com.canonical.UbuntuAppLaunch", /* interface */
703- "ApplicationFailed", /* signal */
704- g_variant_new("(ss)", "com.test.good_application_1.2.3", "start-failure"), /* params, the same */
705+ g_variant_new("(sss)", "com.test.good_application_1.2.3", "goodinstance", "crash"), /* params, the same */
706+ NULL);
707+
708+ EXPECT_EVENTUALLY_EQ("com.test.good_application_1.2.3", last_observer);
709+
710+ last_observer.clear();
711+
712+ g_dbus_connection_emit_signal(session,
713+ NULL, /* destination */
714+ "/", /* path */
715+ "com.canonical.UbuntuAppLaunch", /* interface */
716+ "ApplicationFailed", /* signal */
717+ g_variant_new("(sss)", "com.test.good_application_1.2.3", "goodinstance", "blahblah"), /* params, the same */
718+ NULL);
719+
720+ EXPECT_EVENTUALLY_EQ("com.test.good_application_1.2.3", last_observer);
721+
722+ last_observer.clear();
723+
724+ g_dbus_connection_emit_signal(session,
725+ NULL, /* destination */
726+ "/", /* path */
727+ "com.canonical.UbuntuAppLaunch", /* interface */
728+ "ApplicationFailed", /* signal */
729+ g_variant_new("(sss)", "com.test.good_application_1.2.3", "goodinstance", "start-failure"), /* params, the same */
730 NULL);
731
732 EXPECT_EVENTUALLY_EQ(true, last_observer.empty());

Subscribers

People subscribed via source and target branches