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
=== modified file 'libubuntu-app-launch/registry-impl.cpp'
--- libubuntu-app-launch/registry-impl.cpp 2016-02-08 22:18:14 +0000
+++ libubuntu-app-launch/registry-impl.cpp 2016-02-08 22:18:15 +0000
@@ -38,7 +38,7 @@
38 _dbus.reset();38 _dbus.reset();
39 })39 })
40 , _registry(registry)40 , _registry(registry)
41// _manager(nullptr)41 , _manager(nullptr)
42{42{
43 auto cancel = thread.getCancellable();43 auto cancel = thread.getCancellable();
44 _dbus = thread.executeOnThread<std::shared_ptr<GDBusConnection>>(44 _dbus = thread.executeOnThread<std::shared_ptr<GDBusConnection>>(
@@ -195,7 +195,6 @@
195 });195 });
196}196}
197197
198#if 0
199void198void
200Registry::Impl::setManager (Registry::Manager* manager)199Registry::Impl::setManager (Registry::Manager* manager)
201{200{
@@ -212,7 +211,6 @@
212{211{
213 _manager = nullptr;212 _manager = nullptr;
214}213}
215#endif
216214
217}; // namespace AppLaunch215}; // namespace AppLaunch
218}; // namespace Ubuntu216}; // namespace Ubuntu
219217
=== modified file 'libubuntu-app-launch/registry-impl.h'
--- libubuntu-app-launch/registry-impl.h 2016-02-08 22:18:14 +0000
+++ libubuntu-app-launch/registry-impl.h 2016-02-08 22:18:15 +0000
@@ -44,18 +44,14 @@
44 std::list<AppID::Package> getClickPackages();44 std::list<AppID::Package> getClickPackages();
45 std::string getClickDir(const std::string& package);45 std::string getClickDir(const std::string& package);
4646
47#if 0
48 void setManager (Registry::Manager* manager);47 void setManager (Registry::Manager* manager);
49 void clearManager ();48 void clearManager ();
50#endif
5149
52 GLib::ContextThread thread;50 GLib::ContextThread thread;
5351
54private:52private:
55 Registry* _registry;53 Registry* _registry;
56#if 0
57 Registry::Manager* _manager;54 Registry::Manager* _manager;
58#endif
5955
60 std::shared_ptr<ClickDB> _clickDB;56 std::shared_ptr<ClickDB> _clickDB;
61 std::shared_ptr<ClickUser> _clickUser;57 std::shared_ptr<ClickUser> _clickUser;
6258
=== modified file 'libubuntu-app-launch/registry.h'
--- libubuntu-app-launch/registry.h 2016-02-08 22:18:14 +0000
+++ libubuntu-app-launch/registry.h 2016-02-08 22:18:15 +0000
@@ -49,7 +49,6 @@
49 static std::list<std::shared_ptr<Application>> runningApps(std::shared_ptr<Registry> registry = getDefault());49 static std::list<std::shared_ptr<Application>> runningApps(std::shared_ptr<Registry> registry = getDefault());
50 static std::list<std::shared_ptr<Application>> installedApps(std::shared_ptr<Registry> registry = getDefault());50 static std::list<std::shared_ptr<Application>> installedApps(std::shared_ptr<Registry> registry = getDefault());
5151
52#if 0 /* TODO -- In next MR */
53 /* Signals to discover what is happening to apps */52 /* Signals to discover what is happening to apps */
54 core::Signal<std::shared_ptr<Application>, std::shared_ptr<Application::Instance>> appStarted;53 core::Signal<std::shared_ptr<Application>, std::shared_ptr<Application::Instance>> appStarted;
55 core::Signal<std::shared_ptr<Application>, std::shared_ptr<Application::Instance>> appStopped;54 core::Signal<std::shared_ptr<Application>, std::shared_ptr<Application::Instance>> appStopped;
@@ -70,7 +69,6 @@
7069
71 void setManager (Manager* manager);70 void setManager (Manager* manager);
72 void clearManager ();71 void clearManager ();
73#endif
7472
75 /* Helper Lists */73 /* Helper Lists */
76 static std::list<std::shared_ptr<Helper>> runningHelpers(Helper::Type type,74 static std::list<std::shared_ptr<Helper>> runningHelpers(Helper::Type type,
7775
=== modified file 'tools/CMakeLists.txt'
--- tools/CMakeLists.txt 2016-02-08 22:18:14 +0000
+++ tools/CMakeLists.txt 2016-02-08 22:18:15 +0000
@@ -21,7 +21,7 @@
21# ubuntu-app-launch21# ubuntu-app-launch
22########################22########################
2323
24add_executable(ubuntu-app-launch ubuntu-app-launch.c)24add_executable(ubuntu-app-launch ubuntu-app-launch.cpp)
25set_target_properties(ubuntu-app-launch PROPERTIES OUTPUT_NAME "ubuntu-app-launch")25set_target_properties(ubuntu-app-launch PROPERTIES OUTPUT_NAME "ubuntu-app-launch")
26target_link_libraries(ubuntu-app-launch ubuntu-launcher)26target_link_libraries(ubuntu-app-launch ubuntu-launcher)
27install(TARGETS ubuntu-app-launch RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")27install(TARGETS ubuntu-app-launch RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
@@ -30,7 +30,7 @@
30# ubuntu-app-watch30# ubuntu-app-watch
31########################31########################
3232
33add_executable(ubuntu-app-watch ubuntu-app-watch.c)33add_executable(ubuntu-app-watch ubuntu-app-watch.cpp)
34set_target_properties(ubuntu-app-watch PROPERTIES OUTPUT_NAME "ubuntu-app-watch")34set_target_properties(ubuntu-app-watch PROPERTIES OUTPUT_NAME "ubuntu-app-watch")
35target_link_libraries(ubuntu-app-watch ubuntu-launcher)35target_link_libraries(ubuntu-app-watch ubuntu-launcher)
36install(TARGETS ubuntu-app-watch RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")36install(TARGETS ubuntu-app-watch RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
3737
=== renamed file 'tools/ubuntu-app-launch.c' => 'tools/ubuntu-app-launch.cpp'
--- tools/ubuntu-app-launch.c 2014-04-30 16:34:06 +0000
+++ tools/ubuntu-app-launch.cpp 2016-02-08 22:18:15 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2013 Canonical Ltd.2 * Copyright © 2016 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published5 * under the terms of the GNU General Public License version 3, as published
@@ -17,71 +17,64 @@
17 * Ted Gould <ted.gould@canonical.com>17 * Ted Gould <ted.gould@canonical.com>
18 */18 */
1919
20#include <glib.h>20#include <iostream>
21#include "libubuntu-app-launch/ubuntu-app-launch.h"21#include <future>
2222#include <csignal>
23const gchar * global_appid = NULL;23#include "libubuntu-app-launch/application.h"
24int retval = 0;24#include "libubuntu-app-launch/registry.h"
2525
26static void26Ubuntu::AppLaunch::AppID global_appid;
27good_observer (const gchar * appid, gpointer user_data)27std::promise<int> retval;
28{28
29 if (g_strcmp0(appid, global_appid) != 0) {29int main(int argc, char* argv[])
30 return;30{
31 }31 if (argc < 2)
3232 {
33 g_debug("Application '%s' running", appid);33 std::cerr << "Usage: " << argv[0] << " <app id> [uris]" << std::endl;
34 g_main_loop_quit((GMainLoop *)user_data);34 return 1;
35}35 }
3636
37static void37 global_appid = Ubuntu::AppLaunch::AppID::parse(argv[1]);
38bad_observer (const gchar * appid, UbuntuAppLaunchAppFailed failure_type, gpointer user_data)38
39{39 std::vector<Ubuntu::AppLaunch::Application::URL> urls;
40 if (g_strcmp0(appid, global_appid) != 0) {40 for (int i = 2; i < argc; i++)
41 return;41 {
42 }42 urls.push_back(Ubuntu::AppLaunch::Application::URL::from_raw(argv[i]));
4343 }
44 g_debug("Application '%s' failed: %s", appid, failure_type == UBUNTU_APP_LAUNCH_APP_FAILED_CRASH ? "crash" : "startup failure");44
45 retval = -1;45 auto registry = std::make_shared<Ubuntu::AppLaunch::Registry>();
46 g_main_loop_quit((GMainLoop *)user_data);46
47}47 registry->appStarted.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
4848 std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance)
49int49 {
50main (int argc, gchar * argv[]) {50 if (app->appId() != global_appid)
51 if (argc < 2) {51 {
52 g_printerr("Usage: %s <app id> [uris]\n", argv[0]);52 return;
53 return 1;53 }
54 }54
5555 std::cout << "Started: " << (std::string)app->appId() << std::endl;
56 global_appid = argv[1];56 retval.set_value(0);
57 GMainLoop * mainloop = g_main_loop_new(NULL, FALSE);57 });
5858
59 gchar ** uris = NULL;59 registry->appFailed.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
60 if (argc > 2) {60 std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance,
61 int i;61 Ubuntu::AppLaunch::Registry::FailureType type)
6262 {
63 uris = g_new0(gchar *, argc - 1);63 if (app->appId() != global_appid)
6464 {
65 for (i = 2; i < argc; i++) {65 return;
66 uris[i - 2] = argv[i];66 }
67 }67
68 }68 std::cout << "Failed: " << (std::string)app->appId() << std::endl;
6969 retval.set_value(-1);
70 ubuntu_app_launch_observer_add_app_started(good_observer, mainloop);70 });
71 ubuntu_app_launch_observer_add_app_focus(good_observer, mainloop);71
7272 auto app = Ubuntu::AppLaunch::Application::create(global_appid, registry);
73 ubuntu_app_launch_observer_add_app_failed(bad_observer, mainloop);73 app->launch(urls);
7474
75 ubuntu_app_launch_start_application(global_appid, (const gchar * const *)uris);75 std::signal(SIGTERM, [](int signal) -> void
7676 {
77 g_main_loop_run(mainloop);77 retval.set_value(0);
7878 });
79 ubuntu_app_launch_observer_delete_app_started(good_observer, mainloop);79 return retval.get_future().get();
80 ubuntu_app_launch_observer_delete_app_focus(good_observer, mainloop);
81 ubuntu_app_launch_observer_delete_app_failed(bad_observer, mainloop);
82
83 g_main_loop_unref(mainloop);
84 g_free(uris);
85
86 return retval;
87}80}
8881
=== renamed file 'tools/ubuntu-app-watch.c' => 'tools/ubuntu-app-watch.cpp'
--- tools/ubuntu-app-watch.c 2015-02-25 22:50:24 +0000
+++ tools/ubuntu-app-watch.cpp 2016-02-08 22:18:15 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2013 Canonical Ltd.2 * Copyright © 2015 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published5 * under the terms of the GNU General Public License version 3, as published
@@ -17,91 +17,56 @@
17 * Ted Gould <ted.gould@canonical.com>17 * Ted Gould <ted.gould@canonical.com>
18 */18 */
1919
20#include "libubuntu-app-launch/ubuntu-app-launch.h"20#include "libubuntu-app-launch/registry.h"
2121#include <csignal>
22void22#include <future>
23starting (const gchar * appid, gpointer user_data)23
24{24std::promise<int> retval;
25 g_print("Starting %s\n", appid);25
26 return;26int main(int argc, char* argv[])
27}27{
2828 Ubuntu::AppLaunch::Registry registry;
29void29
30started (const gchar * appid, gpointer user_data)30 registry.appStarted.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
31{31 std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance)
32 g_print("Started %s\n", appid);32 {
33 return;33 std::cout << "Started: " << (std::string)app->appId() << std::endl;
34}34 });
3535 registry.appStopped.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
36void36 std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance)
37stopped (const gchar * appid, gpointer user_data)37 {
38{38 std::cout << "Stopped: " << (std::string)app->appId() << std::endl;
39 g_print("Stop %s\n", appid);39 });
40 return;40 registry.appPaused.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
41}41 std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance)
4242 {
43void43 std::cout << "Paused: " << (std::string)app->appId() << std::endl;
44resumed (const gchar * appid, GPid * pids, gpointer user_data)44 });
45{45 registry.appResumed.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
46 g_print("Resumed %s\n", appid);46 std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance)
47 return;47 {
48}48 std::cout << "Resumed: " << (std::string)app->appId() << std::endl;
4949 });
50void50 registry.appFailed.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app,
51paused (const gchar * appid, GPid * pids, gpointer user_data)51 std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance,
52{52 Ubuntu::AppLaunch::Registry::FailureType type)
53 g_print("Paused %s\n", appid);53 {
54 return;54 std::cout << "Failed: " << (std::string)app->appId();
55}55 switch (type)
5656 {
57void57 case Ubuntu::AppLaunch::Registry::FailureType::CRASH:
58focus (const gchar * appid, gpointer user_data)58 std::cout << " (crash)";
59{59 break;
60 g_print("Focus %s\n", appid);60 case Ubuntu::AppLaunch::Registry::FailureType::START_FAILURE:
61 return;61 std::cout << " (start failure)";
62}62 break;
6363 }
64void64 std::cout << std::endl;
65fail (const gchar * appid, UbuntuAppLaunchAppFailed failhow, gpointer user_data)65 });
66{66
67 const gchar * failstr = "unknown";67 std::signal(SIGTERM, [](int signal) -> void
68 switch (failhow) {68 {
69 case UBUNTU_APP_LAUNCH_APP_FAILED_CRASH:69 retval.set_value(0);
70 failstr = "crashed";70 });
71 break;71 return retval.get_future().get();
72 case UBUNTU_APP_LAUNCH_APP_FAILED_START_FAILURE:
73 failstr = "startup";
74 break;
75 }
76
77 g_print("Fail %s (%s)\n", appid, failstr);
78 return;
79}
80
81
82int
83main (int argc, gchar * argv[])
84{
85 ubuntu_app_launch_observer_add_app_starting(starting, NULL);
86 ubuntu_app_launch_observer_add_app_started(started, NULL);
87 ubuntu_app_launch_observer_add_app_stop(stopped, NULL);
88 ubuntu_app_launch_observer_add_app_focus(focus, NULL);
89 ubuntu_app_launch_observer_add_app_resumed(resumed, NULL);
90 ubuntu_app_launch_observer_add_app_paused(paused, NULL);
91 ubuntu_app_launch_observer_add_app_failed(fail, NULL);
92
93 GMainLoop * mainloop = g_main_loop_new(NULL, FALSE);
94 g_main_loop_run(mainloop);
95
96 ubuntu_app_launch_observer_delete_app_starting(starting, NULL);
97 ubuntu_app_launch_observer_delete_app_started(started, NULL);
98 ubuntu_app_launch_observer_delete_app_stop(stopped, NULL);
99 ubuntu_app_launch_observer_delete_app_focus(focus, NULL);
100 ubuntu_app_launch_observer_delete_app_resumed(resumed, NULL);
101 ubuntu_app_launch_observer_delete_app_paused(paused, NULL);
102 ubuntu_app_launch_observer_delete_app_failed(fail, NULL);
103
104 g_main_loop_unref(mainloop);
105
106 return 0;
107}72}

Subscribers

People subscribed via source and target branches