Merge lp:~ted/ubuntu-app-launch/app-object-signals into lp:ubuntu-app-launch/16.04

Proposed by Ted Gould
Status: Superseded
Proposed branch: lp:~ted/ubuntu-app-launch/app-object-signals
Merge into: lp:ubuntu-app-launch/16.04
Prerequisite: lp:~ted/ubuntu-app-launch/app-object
Diff against target: 391 lines (+117/-167)
6 files modified
libubuntu-app-launch/registry-impl.cpp (+1/-3)
libubuntu-app-launch/registry-impl.h (+0/-4)
libubuntu-app-launch/registry.h (+0/-2)
tools/CMakeLists.txt (+2/-2)
tools/ubuntu-app-launch.cpp (+61/-68)
tools/ubuntu-app-watch.cpp (+53/-88)
To merge this branch: bzr merge lp:~ted/ubuntu-app-launch/app-object-signals
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+285401@code.launchpad.net

This proposal has been superseded by a proposal from 2016-05-16.

To post a comment you must log in.
230. By Ted Gould

These shouldn't have ever been there

231. By Ted Gould

Merge in code style changes

232. By Ted Gould

Apply new style to launch and watch

233. By Ted Gould

Catching up to the base branch

234. By Ted Gould

Updated to trunk

235. By Ted Gould

Make the signal access functions

236. By Ted Gould

Adding in stubs to bring out the implementation

237. By Ted Gould

Merging trunk

238. By Ted Gould

Move the signal functions into the implementation

239. By Ted Gould

Building a place to register signals

240. By Ted Gould

Code up starting and stopping, some TODOs

241. By Ted Gould

Port over app started and stopped to C++ interfaces

242. By Ted Gould

Switch to passing in the shared pointer to the registry

243. By Ted Gould

Make sure to grab a copy of the shared pointer

244. By Ted Gould

Move the greed around in our regex

245. By Ted Gould

Switching to a weak pointer

246. By Ted Gould

Make calls with the C library use the current context to not break existing code.

247. By Ted Gould

Moving over pause/resume

248. By Ted Gould

Fixing the watcher

249. By Ted Gould

Migrating over the failed signal

250. By Ted Gould

Apply formatting rules to tools

251. By Ted Gould

Print pids for pause/resume

252. By Ted Gould

Basic foundation for manager signals

253. By Ted Gould

Start to flesh out more of the resume request

254. By Ted Gould

Restructure to use more shared pointers

255. By Ted Gould

Switch the C code to using the manager interface

256. By Ted Gould

Fleshing out the focus handler

257. By Ted Gould

Add a handler for starting

258. By Ted Gould

Refactor into a shared function to do the longer dbus calls

259. By Ted Gould

Restructure so that we can call the right signal

260. By Ted Gould

Make it so that the manager observers execute on their context

261. By Ted Gould

Switch to using a global weak pointer so that it expires with the tracking of the Registry object

262. By Ted Gould

Clean up weak_ptr<> code

263. By Ted Gould

Make sure we wait to install the signals before returning

264. By Ted Gould

Put a warning in about thread safety

265. By Ted Gould

Port tests over to using a manager for focus events

266. By Ted Gould

Fixing the start and stop observer test

267. By Ted Gould

Fix the starting test

268. By Ted Gould

Failing test ported over

269. By Ted Gould

Documentation for registry functions

270. By Ted Gould

More comments

271. By Ted Gould

Variable comments

272. By Ted Gould

A comment on why this comment is there

273. By Ted Gould

Switch failure test over to using the C++ api

274. By Ted Gould

Making sure we connect the signals before returnning

275. By Ted Gould

Fix failure test environment and values to make them work as real applications

276. By Ted Gould

Apply formatting rules to failure-test.cc

277. By Ted Gould

Make gcc6 happy

278. By Ted Gould

Putting additional checks in to make sure we don't use null pointers we don't get locks on.

279. By Ted Gould

Ensure the manager thread shutsdown before the registry to avoid a deadlock

280. By Ted Gould

Merge future trunk

281. By Ted Gould

Remove some of the sing song part of the comments

282. By Ted Gould

Additional comment on lifecycle of replies

283. By Ted Gould

Zesty formatting tools diffs

284. By Ted Gould

Curly init

285. By Ted Gould

Make sure to check for a nullappid or error for g_variant_get()

286. By Ted Gould

Names of the parameters for clarity

287. By Ted Gould

Moar auto!

288. By Ted Gould

Don't specify returning void explicitly

289. By Ted Gould

Use static_cast() for void* casts

290. By Ted Gould

Don't spell well

291. By Ted Gould

Make sure to check for a valid registry

292. By Ted Gould

Comment out unused variables

293. By Ted Gould

Sometimes life would be better if it was more constant

294. By Ted Gould

Me no spell good

295. By Ted Gould

auto auto auto

296. By Ted Gould

Some 'NULL's crept in

297. By Ted Gould

More auto's with GVariants

298. By Ted Gould

Make params constant

299. By Ted Gould

Change setManager to have const& parameters

300. By Ted Gould

Fix the API so that the signal callbacks take pointers

301. By Ted Gould

Note it is on the UAL thread only

302. By Ted Gould

Save some stack data with this context

303. By Ted Gould

Formatting fix

304. By Ted Gould

Use an ensure_cmanager() helper to remove duplicate code

305. By Ted Gould

Putting all the map handling code in a couple templates

306. By Ted Gould

Pull out the request code into individual functions

307. By Ted Gould

Rename a function and add comments

308. By Ted Gould

Expand the usage of observer_delete

309. By Ted Gould

Factor out pause/resume commonality

310. By Ted Gould

I've been overrided by charles

311. By Ted Gould

Update to trunk

312. By Ted Gould

Adding virtual destructors, acc says they're fine.

313. By Ted Gould

Putting this off for gcc 5.4

314. By Ted Gould

Block off more API breaks this time

Unmerged revisions

314. By Ted Gould

Block off more API breaks this time

313. By Ted Gould

Putting this off for gcc 5.4

312. By Ted Gould

Adding virtual destructors, acc says they're fine.

311. By Ted Gould

Update to trunk

310. By Ted Gould

I've been overrided by charles

309. By Ted Gould

Factor out pause/resume commonality

308. By Ted Gould

Expand the usage of observer_delete

307. By Ted Gould

Rename a function and add comments

306. By Ted Gould

Pull out the request code into individual functions

305. By Ted Gould

Putting all the map handling code in a couple templates

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntu-app-launch/registry-impl.cpp'
2--- libubuntu-app-launch/registry-impl.cpp 2016-02-08 22:18:14 +0000
3+++ libubuntu-app-launch/registry-impl.cpp 2016-02-08 22:18:15 +0000
4@@ -38,7 +38,7 @@
5 _dbus.reset();
6 })
7 , _registry(registry)
8-// _manager(nullptr)
9+ , _manager(nullptr)
10 {
11 auto cancel = thread.getCancellable();
12 _dbus = thread.executeOnThread<std::shared_ptr<GDBusConnection>>(
13@@ -195,7 +195,6 @@
14 });
15 }
16
17-#if 0
18 void
19 Registry::Impl::setManager (Registry::Manager* manager)
20 {
21@@ -212,7 +211,6 @@
22 {
23 _manager = nullptr;
24 }
25-#endif
26
27 }; // namespace AppLaunch
28 }; // namespace Ubuntu
29
30=== modified file 'libubuntu-app-launch/registry-impl.h'
31--- libubuntu-app-launch/registry-impl.h 2016-02-08 22:18:14 +0000
32+++ libubuntu-app-launch/registry-impl.h 2016-02-08 22:18:15 +0000
33@@ -44,18 +44,14 @@
34 std::list<AppID::Package> getClickPackages();
35 std::string getClickDir(const std::string& package);
36
37-#if 0
38 void setManager (Registry::Manager* manager);
39 void clearManager ();
40-#endif
41
42 GLib::ContextThread thread;
43
44 private:
45 Registry* _registry;
46-#if 0
47 Registry::Manager* _manager;
48-#endif
49
50 std::shared_ptr<ClickDB> _clickDB;
51 std::shared_ptr<ClickUser> _clickUser;
52
53=== modified file 'libubuntu-app-launch/registry.h'
54--- libubuntu-app-launch/registry.h 2016-02-08 22:18:14 +0000
55+++ libubuntu-app-launch/registry.h 2016-02-08 22:18:15 +0000
56@@ -49,7 +49,6 @@
57 static std::list<std::shared_ptr<Application>> runningApps(std::shared_ptr<Registry> registry = getDefault());
58 static std::list<std::shared_ptr<Application>> installedApps(std::shared_ptr<Registry> registry = getDefault());
59
60-#if 0 /* TODO -- In next MR */
61 /* Signals to discover what is happening to apps */
62 core::Signal<std::shared_ptr<Application>, std::shared_ptr<Application::Instance>> appStarted;
63 core::Signal<std::shared_ptr<Application>, std::shared_ptr<Application::Instance>> appStopped;
64@@ -70,7 +69,6 @@
65
66 void setManager (Manager* manager);
67 void clearManager ();
68-#endif
69
70 /* Helper Lists */
71 static std::list<std::shared_ptr<Helper>> runningHelpers(Helper::Type type,
72
73=== modified file 'tools/CMakeLists.txt'
74--- tools/CMakeLists.txt 2016-02-08 22:18:14 +0000
75+++ tools/CMakeLists.txt 2016-02-08 22:18:15 +0000
76@@ -21,7 +21,7 @@
77 # ubuntu-app-launch
78 ########################
79
80-add_executable(ubuntu-app-launch ubuntu-app-launch.c)
81+add_executable(ubuntu-app-launch ubuntu-app-launch.cpp)
82 set_target_properties(ubuntu-app-launch PROPERTIES OUTPUT_NAME "ubuntu-app-launch")
83 target_link_libraries(ubuntu-app-launch ubuntu-launcher)
84 install(TARGETS ubuntu-app-launch RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
85@@ -30,7 +30,7 @@
86 # ubuntu-app-watch
87 ########################
88
89-add_executable(ubuntu-app-watch ubuntu-app-watch.c)
90+add_executable(ubuntu-app-watch ubuntu-app-watch.cpp)
91 set_target_properties(ubuntu-app-watch PROPERTIES OUTPUT_NAME "ubuntu-app-watch")
92 target_link_libraries(ubuntu-app-watch ubuntu-launcher)
93 install(TARGETS ubuntu-app-watch RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
94
95=== renamed file 'tools/ubuntu-app-launch.c' => 'tools/ubuntu-app-launch.cpp'
96--- tools/ubuntu-app-launch.c 2014-04-30 16:34:06 +0000
97+++ tools/ubuntu-app-launch.cpp 2016-02-08 22:18:15 +0000
98@@ -1,5 +1,5 @@
99 /*
100- * Copyright 2013 Canonical Ltd.
101+ * Copyright © 2016 Canonical Ltd.
102 *
103 * This program is free software: you can redistribute it and/or modify it
104 * under the terms of the GNU General Public License version 3, as published
105@@ -17,71 +17,64 @@
106 * Ted Gould <ted.gould@canonical.com>
107 */
108
109-#include <glib.h>
110-#include "libubuntu-app-launch/ubuntu-app-launch.h"
111-
112-const gchar * global_appid = NULL;
113-int retval = 0;
114-
115-static void
116-good_observer (const gchar * appid, gpointer user_data)
117-{
118- if (g_strcmp0(appid, global_appid) != 0) {
119- return;
120- }
121-
122- g_debug("Application '%s' running", appid);
123- g_main_loop_quit((GMainLoop *)user_data);
124-}
125-
126-static void
127-bad_observer (const gchar * appid, UbuntuAppLaunchAppFailed failure_type, gpointer user_data)
128-{
129- if (g_strcmp0(appid, global_appid) != 0) {
130- return;
131- }
132-
133- g_debug("Application '%s' failed: %s", appid, failure_type == UBUNTU_APP_LAUNCH_APP_FAILED_CRASH ? "crash" : "startup failure");
134- retval = -1;
135- g_main_loop_quit((GMainLoop *)user_data);
136-}
137-
138-int
139-main (int argc, gchar * argv[]) {
140- if (argc < 2) {
141- g_printerr("Usage: %s <app id> [uris]\n", argv[0]);
142- return 1;
143- }
144-
145- global_appid = argv[1];
146- GMainLoop * mainloop = g_main_loop_new(NULL, FALSE);
147-
148- gchar ** uris = NULL;
149- if (argc > 2) {
150- int i;
151-
152- uris = g_new0(gchar *, argc - 1);
153-
154- for (i = 2; i < argc; i++) {
155- uris[i - 2] = argv[i];
156- }
157- }
158-
159- ubuntu_app_launch_observer_add_app_started(good_observer, mainloop);
160- ubuntu_app_launch_observer_add_app_focus(good_observer, mainloop);
161-
162- ubuntu_app_launch_observer_add_app_failed(bad_observer, mainloop);
163-
164- ubuntu_app_launch_start_application(global_appid, (const gchar * const *)uris);
165-
166- g_main_loop_run(mainloop);
167-
168- ubuntu_app_launch_observer_delete_app_started(good_observer, mainloop);
169- ubuntu_app_launch_observer_delete_app_focus(good_observer, mainloop);
170- ubuntu_app_launch_observer_delete_app_failed(bad_observer, mainloop);
171-
172- g_main_loop_unref(mainloop);
173- g_free(uris);
174-
175- return retval;
176+#include <iostream>
177+#include <future>
178+#include <csignal>
179+#include "libubuntu-app-launch/application.h"
180+#include "libubuntu-app-launch/registry.h"
181+
182+Ubuntu::AppLaunch::AppID global_appid;
183+std::promise<int> retval;
184+
185+int main(int argc, char* argv[])
186+{
187+ if (argc < 2)
188+ {
189+ std::cerr << "Usage: " << argv[0] << " <app id> [uris]" << std::endl;
190+ return 1;
191+ }
192+
193+ global_appid = Ubuntu::AppLaunch::AppID::parse(argv[1]);
194+
195+ std::vector<Ubuntu::AppLaunch::Application::URL> urls;
196+ for (int i = 2; i < argc; i++)
197+ {
198+ urls.push_back(Ubuntu::AppLaunch::Application::URL::from_raw(argv[i]));
199+ }
200+
201+ auto registry = std::make_shared<Ubuntu::AppLaunch::Registry>();
202+
203+ registry->appStarted.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
204+ std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance)
205+ {
206+ if (app->appId() != global_appid)
207+ {
208+ return;
209+ }
210+
211+ std::cout << "Started: " << (std::string)app->appId() << std::endl;
212+ retval.set_value(0);
213+ });
214+
215+ registry->appFailed.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
216+ std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance,
217+ Ubuntu::AppLaunch::Registry::FailureType type)
218+ {
219+ if (app->appId() != global_appid)
220+ {
221+ return;
222+ }
223+
224+ std::cout << "Failed: " << (std::string)app->appId() << std::endl;
225+ retval.set_value(-1);
226+ });
227+
228+ auto app = Ubuntu::AppLaunch::Application::create(global_appid, registry);
229+ app->launch(urls);
230+
231+ std::signal(SIGTERM, [](int signal) -> void
232+ {
233+ retval.set_value(0);
234+ });
235+ return retval.get_future().get();
236 }
237
238=== renamed file 'tools/ubuntu-app-watch.c' => 'tools/ubuntu-app-watch.cpp'
239--- tools/ubuntu-app-watch.c 2015-02-25 22:50:24 +0000
240+++ tools/ubuntu-app-watch.cpp 2016-02-08 22:18:15 +0000
241@@ -1,5 +1,5 @@
242 /*
243- * Copyright 2013 Canonical Ltd.
244+ * Copyright © 2015 Canonical Ltd.
245 *
246 * This program is free software: you can redistribute it and/or modify it
247 * under the terms of the GNU General Public License version 3, as published
248@@ -17,91 +17,56 @@
249 * Ted Gould <ted.gould@canonical.com>
250 */
251
252-#include "libubuntu-app-launch/ubuntu-app-launch.h"
253-
254-void
255-starting (const gchar * appid, gpointer user_data)
256-{
257- g_print("Starting %s\n", appid);
258- return;
259-}
260-
261-void
262-started (const gchar * appid, gpointer user_data)
263-{
264- g_print("Started %s\n", appid);
265- return;
266-}
267-
268-void
269-stopped (const gchar * appid, gpointer user_data)
270-{
271- g_print("Stop %s\n", appid);
272- return;
273-}
274-
275-void
276-resumed (const gchar * appid, GPid * pids, gpointer user_data)
277-{
278- g_print("Resumed %s\n", appid);
279- return;
280-}
281-
282-void
283-paused (const gchar * appid, GPid * pids, gpointer user_data)
284-{
285- g_print("Paused %s\n", appid);
286- return;
287-}
288-
289-void
290-focus (const gchar * appid, gpointer user_data)
291-{
292- g_print("Focus %s\n", appid);
293- return;
294-}
295-
296-void
297-fail (const gchar * appid, UbuntuAppLaunchAppFailed failhow, gpointer user_data)
298-{
299- const gchar * failstr = "unknown";
300- switch (failhow) {
301- case UBUNTU_APP_LAUNCH_APP_FAILED_CRASH:
302- failstr = "crashed";
303- break;
304- case UBUNTU_APP_LAUNCH_APP_FAILED_START_FAILURE:
305- failstr = "startup";
306- break;
307- }
308-
309- g_print("Fail %s (%s)\n", appid, failstr);
310- return;
311-}
312-
313-
314-int
315-main (int argc, gchar * argv[])
316-{
317- ubuntu_app_launch_observer_add_app_starting(starting, NULL);
318- ubuntu_app_launch_observer_add_app_started(started, NULL);
319- ubuntu_app_launch_observer_add_app_stop(stopped, NULL);
320- ubuntu_app_launch_observer_add_app_focus(focus, NULL);
321- ubuntu_app_launch_observer_add_app_resumed(resumed, NULL);
322- ubuntu_app_launch_observer_add_app_paused(paused, NULL);
323- ubuntu_app_launch_observer_add_app_failed(fail, NULL);
324-
325- GMainLoop * mainloop = g_main_loop_new(NULL, FALSE);
326- g_main_loop_run(mainloop);
327-
328- ubuntu_app_launch_observer_delete_app_starting(starting, NULL);
329- ubuntu_app_launch_observer_delete_app_started(started, NULL);
330- ubuntu_app_launch_observer_delete_app_stop(stopped, NULL);
331- ubuntu_app_launch_observer_delete_app_focus(focus, NULL);
332- ubuntu_app_launch_observer_delete_app_resumed(resumed, NULL);
333- ubuntu_app_launch_observer_delete_app_paused(paused, NULL);
334- ubuntu_app_launch_observer_delete_app_failed(fail, NULL);
335-
336- g_main_loop_unref(mainloop);
337-
338- return 0;
339+#include "libubuntu-app-launch/registry.h"
340+#include <csignal>
341+#include <future>
342+
343+std::promise<int> retval;
344+
345+int main(int argc, char* argv[])
346+{
347+ Ubuntu::AppLaunch::Registry registry;
348+
349+ registry.appStarted.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
350+ std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance)
351+ {
352+ std::cout << "Started: " << (std::string)app->appId() << std::endl;
353+ });
354+ registry.appStopped.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
355+ std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance)
356+ {
357+ std::cout << "Stopped: " << (std::string)app->appId() << std::endl;
358+ });
359+ registry.appPaused.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
360+ std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance)
361+ {
362+ std::cout << "Paused: " << (std::string)app->appId() << std::endl;
363+ });
364+ registry.appResumed.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
365+ std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance)
366+ {
367+ std::cout << "Resumed: " << (std::string)app->appId() << std::endl;
368+ });
369+ registry.appFailed.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
370+ std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance,
371+ Ubuntu::AppLaunch::Registry::FailureType type)
372+ {
373+ std::cout << "Failed: " << (std::string)app->appId();
374+ switch (type)
375+ {
376+ case Ubuntu::AppLaunch::Registry::FailureType::CRASH:
377+ std::cout << " (crash)";
378+ break;
379+ case Ubuntu::AppLaunch::Registry::FailureType::START_FAILURE:
380+ std::cout << " (start failure)";
381+ break;
382+ }
383+ std::cout << std::endl;
384+ });
385+
386+ std::signal(SIGTERM, [](int signal) -> void
387+ {
388+ retval.set_value(0);
389+ });
390+ return retval.get_future().get();
391 }

Subscribers

People subscribed via source and target branches