Merge lp:~ted/ubuntu-app-launch/app-object-signals into lp:ubuntu-app-launch/16.04
- app-object-signals
- Merge into trunk.16.04
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 | ||||
Related bugs: |
|
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.
Commit message
Description of the change
- 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
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 | 38 | _dbus.reset(); | 38 | _dbus.reset(); |
6 | 39 | }) | 39 | }) |
7 | 40 | , _registry(registry) | 40 | , _registry(registry) |
9 | 41 | // _manager(nullptr) | 41 | , _manager(nullptr) |
10 | 42 | { | 42 | { |
11 | 43 | auto cancel = thread.getCancellable(); | 43 | auto cancel = thread.getCancellable(); |
12 | 44 | _dbus = thread.executeOnThread<std::shared_ptr<GDBusConnection>>( | 44 | _dbus = thread.executeOnThread<std::shared_ptr<GDBusConnection>>( |
13 | @@ -195,7 +195,6 @@ | |||
14 | 195 | }); | 195 | }); |
15 | 196 | } | 196 | } |
16 | 197 | 197 | ||
17 | 198 | #if 0 | ||
18 | 199 | void | 198 | void |
19 | 200 | Registry::Impl::setManager (Registry::Manager* manager) | 199 | Registry::Impl::setManager (Registry::Manager* manager) |
20 | 201 | { | 200 | { |
21 | @@ -212,7 +211,6 @@ | |||
22 | 212 | { | 211 | { |
23 | 213 | _manager = nullptr; | 212 | _manager = nullptr; |
24 | 214 | } | 213 | } |
25 | 215 | #endif | ||
26 | 216 | 214 | ||
27 | 217 | }; // namespace AppLaunch | 215 | }; // namespace AppLaunch |
28 | 218 | }; // namespace Ubuntu | 216 | }; // namespace Ubuntu |
29 | 219 | 217 | ||
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 | 44 | std::list<AppID::Package> getClickPackages(); | 44 | std::list<AppID::Package> getClickPackages(); |
35 | 45 | std::string getClickDir(const std::string& package); | 45 | std::string getClickDir(const std::string& package); |
36 | 46 | 46 | ||
37 | 47 | #if 0 | ||
38 | 48 | void setManager (Registry::Manager* manager); | 47 | void setManager (Registry::Manager* manager); |
39 | 49 | void clearManager (); | 48 | void clearManager (); |
40 | 50 | #endif | ||
41 | 51 | 49 | ||
42 | 52 | GLib::ContextThread thread; | 50 | GLib::ContextThread thread; |
43 | 53 | 51 | ||
44 | 54 | private: | 52 | private: |
45 | 55 | Registry* _registry; | 53 | Registry* _registry; |
46 | 56 | #if 0 | ||
47 | 57 | Registry::Manager* _manager; | 54 | Registry::Manager* _manager; |
48 | 58 | #endif | ||
49 | 59 | 55 | ||
50 | 60 | std::shared_ptr<ClickDB> _clickDB; | 56 | std::shared_ptr<ClickDB> _clickDB; |
51 | 61 | std::shared_ptr<ClickUser> _clickUser; | 57 | std::shared_ptr<ClickUser> _clickUser; |
52 | 62 | 58 | ||
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 | 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()); |
58 | 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()); |
59 | 51 | 51 | ||
60 | 52 | #if 0 /* TODO -- In next MR */ | ||
61 | 53 | /* Signals to discover what is happening to apps */ | 52 | /* Signals to discover what is happening to apps */ |
62 | 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; |
63 | 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; |
64 | @@ -70,7 +69,6 @@ | |||
65 | 70 | 69 | ||
66 | 71 | void setManager (Manager* manager); | 70 | void setManager (Manager* manager); |
67 | 72 | void clearManager (); | 71 | void clearManager (); |
68 | 73 | #endif | ||
69 | 74 | 72 | ||
70 | 75 | /* Helper Lists */ | 73 | /* Helper Lists */ |
71 | 76 | static std::list<std::shared_ptr<Helper>> runningHelpers(Helper::Type type, | 74 | static std::list<std::shared_ptr<Helper>> runningHelpers(Helper::Type type, |
72 | 77 | 75 | ||
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 | 21 | # ubuntu-app-launch | 21 | # ubuntu-app-launch |
78 | 22 | ######################## | 22 | ######################## |
79 | 23 | 23 | ||
81 | 24 | add_executable(ubuntu-app-launch ubuntu-app-launch.c) | 24 | add_executable(ubuntu-app-launch ubuntu-app-launch.cpp) |
82 | 25 | set_target_properties(ubuntu-app-launch PROPERTIES OUTPUT_NAME "ubuntu-app-launch") | 25 | set_target_properties(ubuntu-app-launch PROPERTIES OUTPUT_NAME "ubuntu-app-launch") |
83 | 26 | target_link_libraries(ubuntu-app-launch ubuntu-launcher) | 26 | target_link_libraries(ubuntu-app-launch ubuntu-launcher) |
84 | 27 | install(TARGETS ubuntu-app-launch RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") | 27 | install(TARGETS ubuntu-app-launch RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") |
85 | @@ -30,7 +30,7 @@ | |||
86 | 30 | # ubuntu-app-watch | 30 | # ubuntu-app-watch |
87 | 31 | ######################## | 31 | ######################## |
88 | 32 | 32 | ||
90 | 33 | add_executable(ubuntu-app-watch ubuntu-app-watch.c) | 33 | add_executable(ubuntu-app-watch ubuntu-app-watch.cpp) |
91 | 34 | set_target_properties(ubuntu-app-watch PROPERTIES OUTPUT_NAME "ubuntu-app-watch") | 34 | set_target_properties(ubuntu-app-watch PROPERTIES OUTPUT_NAME "ubuntu-app-watch") |
92 | 35 | target_link_libraries(ubuntu-app-watch ubuntu-launcher) | 35 | target_link_libraries(ubuntu-app-watch ubuntu-launcher) |
93 | 36 | install(TARGETS ubuntu-app-watch RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") | 36 | install(TARGETS ubuntu-app-watch RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") |
94 | 37 | 37 | ||
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 | 1 | /* | 1 | /* |
101 | 2 | * Copyright 2013 Canonical Ltd. | 2 | * Copyright © 2016 Canonical Ltd. |
102 | 3 | * | 3 | * |
103 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
104 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
105 | @@ -17,71 +17,64 @@ | |||
106 | 17 | * Ted Gould <ted.gould@canonical.com> | 17 | * Ted Gould <ted.gould@canonical.com> |
107 | 18 | */ | 18 | */ |
108 | 19 | 19 | ||
176 | 20 | #include <glib.h> | 20 | #include <iostream> |
177 | 21 | #include "libubuntu-app-launch/ubuntu-app-launch.h" | 21 | #include <future> |
178 | 22 | 22 | #include <csignal> | |
179 | 23 | const gchar * global_appid = NULL; | 23 | #include "libubuntu-app-launch/application.h" |
180 | 24 | int retval = 0; | 24 | #include "libubuntu-app-launch/registry.h" |
181 | 25 | 25 | ||
182 | 26 | static void | 26 | Ubuntu::AppLaunch::AppID global_appid; |
183 | 27 | good_observer (const gchar * appid, gpointer user_data) | 27 | std::promise<int> retval; |
184 | 28 | { | 28 | |
185 | 29 | if (g_strcmp0(appid, global_appid) != 0) { | 29 | int main(int argc, char* argv[]) |
186 | 30 | return; | 30 | { |
187 | 31 | } | 31 | if (argc < 2) |
188 | 32 | 32 | { | |
189 | 33 | g_debug("Application '%s' running", appid); | 33 | std::cerr << "Usage: " << argv[0] << " <app id> [uris]" << std::endl; |
190 | 34 | g_main_loop_quit((GMainLoop *)user_data); | 34 | return 1; |
191 | 35 | } | 35 | } |
192 | 36 | 36 | ||
193 | 37 | static void | 37 | global_appid = Ubuntu::AppLaunch::AppID::parse(argv[1]); |
194 | 38 | bad_observer (const gchar * appid, UbuntuAppLaunchAppFailed failure_type, gpointer user_data) | 38 | |
195 | 39 | { | 39 | std::vector<Ubuntu::AppLaunch::Application::URL> urls; |
196 | 40 | if (g_strcmp0(appid, global_appid) != 0) { | 40 | for (int i = 2; i < argc; i++) |
197 | 41 | return; | 41 | { |
198 | 42 | } | 42 | urls.push_back(Ubuntu::AppLaunch::Application::URL::from_raw(argv[i])); |
199 | 43 | 43 | } | |
200 | 44 | g_debug("Application '%s' failed: %s", appid, failure_type == UBUNTU_APP_LAUNCH_APP_FAILED_CRASH ? "crash" : "startup failure"); | 44 | |
201 | 45 | retval = -1; | 45 | auto registry = std::make_shared<Ubuntu::AppLaunch::Registry>(); |
202 | 46 | g_main_loop_quit((GMainLoop *)user_data); | 46 | |
203 | 47 | } | 47 | registry->appStarted.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app, |
204 | 48 | 48 | std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance) | |
205 | 49 | int | 49 | { |
206 | 50 | main (int argc, gchar * argv[]) { | 50 | if (app->appId() != global_appid) |
207 | 51 | if (argc < 2) { | 51 | { |
208 | 52 | g_printerr("Usage: %s <app id> [uris]\n", argv[0]); | 52 | return; |
209 | 53 | return 1; | 53 | } |
210 | 54 | } | 54 | |
211 | 55 | 55 | std::cout << "Started: " << (std::string)app->appId() << std::endl; | |
212 | 56 | global_appid = argv[1]; | 56 | retval.set_value(0); |
213 | 57 | GMainLoop * mainloop = g_main_loop_new(NULL, FALSE); | 57 | }); |
214 | 58 | 58 | ||
215 | 59 | gchar ** uris = NULL; | 59 | registry->appFailed.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app, |
216 | 60 | if (argc > 2) { | 60 | std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance, |
217 | 61 | int i; | 61 | Ubuntu::AppLaunch::Registry::FailureType type) |
218 | 62 | 62 | { | |
219 | 63 | uris = g_new0(gchar *, argc - 1); | 63 | if (app->appId() != global_appid) |
220 | 64 | 64 | { | |
221 | 65 | for (i = 2; i < argc; i++) { | 65 | return; |
222 | 66 | uris[i - 2] = argv[i]; | 66 | } |
223 | 67 | } | 67 | |
224 | 68 | } | 68 | std::cout << "Failed: " << (std::string)app->appId() << std::endl; |
225 | 69 | 69 | retval.set_value(-1); | |
226 | 70 | ubuntu_app_launch_observer_add_app_started(good_observer, mainloop); | 70 | }); |
227 | 71 | ubuntu_app_launch_observer_add_app_focus(good_observer, mainloop); | 71 | |
228 | 72 | 72 | auto app = Ubuntu::AppLaunch::Application::create(global_appid, registry); | |
229 | 73 | ubuntu_app_launch_observer_add_app_failed(bad_observer, mainloop); | 73 | app->launch(urls); |
230 | 74 | 74 | ||
231 | 75 | ubuntu_app_launch_start_application(global_appid, (const gchar * const *)uris); | 75 | std::signal(SIGTERM, [](int signal) -> void |
232 | 76 | 76 | { | |
233 | 77 | g_main_loop_run(mainloop); | 77 | retval.set_value(0); |
234 | 78 | 78 | }); | |
235 | 79 | ubuntu_app_launch_observer_delete_app_started(good_observer, mainloop); | 79 | return retval.get_future().get(); |
169 | 80 | ubuntu_app_launch_observer_delete_app_focus(good_observer, mainloop); | ||
170 | 81 | ubuntu_app_launch_observer_delete_app_failed(bad_observer, mainloop); | ||
171 | 82 | |||
172 | 83 | g_main_loop_unref(mainloop); | ||
173 | 84 | g_free(uris); | ||
174 | 85 | |||
175 | 86 | return retval; | ||
236 | 87 | } | 80 | } |
237 | 88 | 81 | ||
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 | 1 | /* | 1 | /* |
244 | 2 | * Copyright 2013 Canonical Ltd. | 2 | * Copyright © 2015 Canonical Ltd. |
245 | 3 | * | 3 | * |
246 | 4 | * This program is free software: you can redistribute it and/or modify it | 4 | * This program is free software: you can redistribute it and/or modify it |
247 | 5 | * under the terms of the GNU General Public License version 3, as published | 5 | * under the terms of the GNU General Public License version 3, as published |
248 | @@ -17,91 +17,56 @@ | |||
249 | 17 | * Ted Gould <ted.gould@canonical.com> | 17 | * Ted Gould <ted.gould@canonical.com> |
250 | 18 | */ | 18 | */ |
251 | 19 | 19 | ||
339 | 20 | #include "libubuntu-app-launch/ubuntu-app-launch.h" | 20 | #include "libubuntu-app-launch/registry.h" |
340 | 21 | 21 | #include <csignal> | |
341 | 22 | void | 22 | #include <future> |
342 | 23 | starting (const gchar * appid, gpointer user_data) | 23 | |
343 | 24 | { | 24 | std::promise<int> retval; |
344 | 25 | g_print("Starting %s\n", appid); | 25 | |
345 | 26 | return; | 26 | int main(int argc, char* argv[]) |
346 | 27 | } | 27 | { |
347 | 28 | 28 | Ubuntu::AppLaunch::Registry registry; | |
348 | 29 | void | 29 | |
349 | 30 | started (const gchar * appid, gpointer user_data) | 30 | registry.appStarted.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app, |
350 | 31 | { | 31 | std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance) |
351 | 32 | g_print("Started %s\n", appid); | 32 | { |
352 | 33 | return; | 33 | std::cout << "Started: " << (std::string)app->appId() << std::endl; |
353 | 34 | } | 34 | }); |
354 | 35 | 35 | registry.appStopped.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app, | |
355 | 36 | void | 36 | std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance) |
356 | 37 | stopped (const gchar * appid, gpointer user_data) | 37 | { |
357 | 38 | { | 38 | std::cout << "Stopped: " << (std::string)app->appId() << std::endl; |
358 | 39 | g_print("Stop %s\n", appid); | 39 | }); |
359 | 40 | return; | 40 | registry.appPaused.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app, |
360 | 41 | } | 41 | std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance) |
361 | 42 | 42 | { | |
362 | 43 | void | 43 | std::cout << "Paused: " << (std::string)app->appId() << std::endl; |
363 | 44 | resumed (const gchar * appid, GPid * pids, gpointer user_data) | 44 | }); |
364 | 45 | { | 45 | registry.appResumed.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app, |
365 | 46 | g_print("Resumed %s\n", appid); | 46 | std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance) |
366 | 47 | return; | 47 | { |
367 | 48 | } | 48 | std::cout << "Resumed: " << (std::string)app->appId() << std::endl; |
368 | 49 | 49 | }); | |
369 | 50 | void | 50 | registry.appFailed.connect([](std::shared_ptr<Ubuntu::AppLaunch::Application> app, |
370 | 51 | paused (const gchar * appid, GPid * pids, gpointer user_data) | 51 | std::shared_ptr<Ubuntu::AppLaunch::Application::Instance> instance, |
371 | 52 | { | 52 | Ubuntu::AppLaunch::Registry::FailureType type) |
372 | 53 | g_print("Paused %s\n", appid); | 53 | { |
373 | 54 | return; | 54 | std::cout << "Failed: " << (std::string)app->appId(); |
374 | 55 | } | 55 | switch (type) |
375 | 56 | 56 | { | |
376 | 57 | void | 57 | case Ubuntu::AppLaunch::Registry::FailureType::CRASH: |
377 | 58 | focus (const gchar * appid, gpointer user_data) | 58 | std::cout << " (crash)"; |
378 | 59 | { | 59 | break; |
379 | 60 | g_print("Focus %s\n", appid); | 60 | case Ubuntu::AppLaunch::Registry::FailureType::START_FAILURE: |
380 | 61 | return; | 61 | std::cout << " (start failure)"; |
381 | 62 | } | 62 | break; |
382 | 63 | 63 | } | |
383 | 64 | void | 64 | std::cout << std::endl; |
384 | 65 | fail (const gchar * appid, UbuntuAppLaunchAppFailed failhow, gpointer user_data) | 65 | }); |
385 | 66 | { | 66 | |
386 | 67 | const gchar * failstr = "unknown"; | 67 | std::signal(SIGTERM, [](int signal) -> void |
387 | 68 | switch (failhow) { | 68 | { |
388 | 69 | case UBUNTU_APP_LAUNCH_APP_FAILED_CRASH: | 69 | retval.set_value(0); |
389 | 70 | failstr = "crashed"; | 70 | }); |
390 | 71 | break; | 71 | return retval.get_future().get(); |
304 | 72 | case UBUNTU_APP_LAUNCH_APP_FAILED_START_FAILURE: | ||
305 | 73 | failstr = "startup"; | ||
306 | 74 | break; | ||
307 | 75 | } | ||
308 | 76 | |||
309 | 77 | g_print("Fail %s (%s)\n", appid, failstr); | ||
310 | 78 | return; | ||
311 | 79 | } | ||
312 | 80 | |||
313 | 81 | |||
314 | 82 | int | ||
315 | 83 | main (int argc, gchar * argv[]) | ||
316 | 84 | { | ||
317 | 85 | ubuntu_app_launch_observer_add_app_starting(starting, NULL); | ||
318 | 86 | ubuntu_app_launch_observer_add_app_started(started, NULL); | ||
319 | 87 | ubuntu_app_launch_observer_add_app_stop(stopped, NULL); | ||
320 | 88 | ubuntu_app_launch_observer_add_app_focus(focus, NULL); | ||
321 | 89 | ubuntu_app_launch_observer_add_app_resumed(resumed, NULL); | ||
322 | 90 | ubuntu_app_launch_observer_add_app_paused(paused, NULL); | ||
323 | 91 | ubuntu_app_launch_observer_add_app_failed(fail, NULL); | ||
324 | 92 | |||
325 | 93 | GMainLoop * mainloop = g_main_loop_new(NULL, FALSE); | ||
326 | 94 | g_main_loop_run(mainloop); | ||
327 | 95 | |||
328 | 96 | ubuntu_app_launch_observer_delete_app_starting(starting, NULL); | ||
329 | 97 | ubuntu_app_launch_observer_delete_app_started(started, NULL); | ||
330 | 98 | ubuntu_app_launch_observer_delete_app_stop(stopped, NULL); | ||
331 | 99 | ubuntu_app_launch_observer_delete_app_focus(focus, NULL); | ||
332 | 100 | ubuntu_app_launch_observer_delete_app_resumed(resumed, NULL); | ||
333 | 101 | ubuntu_app_launch_observer_delete_app_paused(paused, NULL); | ||
334 | 102 | ubuntu_app_launch_observer_delete_app_failed(fail, NULL); | ||
335 | 103 | |||
336 | 104 | g_main_loop_unref(mainloop); | ||
337 | 105 | |||
338 | 106 | return 0; | ||
391 | 107 | } | 72 | } |