Merge lp:~pete-woods/ubuntu-app-launch/format-after-managed-memory into lp:ubuntu-app-launch

Proposed by Pete Woods
Status: Merged
Approved by: Ted Gould
Approved revision: 390
Merged at revision: 306
Proposed branch: lp:~pete-woods/ubuntu-app-launch/format-after-managed-memory
Merge into: lp:ubuntu-app-launch
Prerequisite: lp:~pete-woods/ubuntu-app-launch/use-more-managed-memory
Diff against target: 1005 lines (+414/-395)
7 files modified
libubuntu-app-launch/application-icon-finder.cpp (+0/-1)
libubuntu-app-launch/helper.cpp (+41/-38)
libubuntu-app-launch/jobs-base.cpp (+147/-139)
libubuntu-app-launch/jobs-base.h (+13/-7)
libubuntu-app-launch/jobs-systemd.cpp (+207/-204)
libubuntu-app-launch/registry-impl.cpp (+3/-4)
libubuntu-app-launch/registry.h (+3/-2)
To merge this branch: bzr merge lp:~pete-woods/ubuntu-app-launch/format-after-managed-memory
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
unity-api-1-bot continuous-integration Needs Fixing
Review via email: mp+320327@code.launchpad.net

Commit message

Run make format target following managed memory branch

Description of the change

Run make format target following managed memory branch

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)
389. By Pete Woods

Remove mistakenly added include

390. By Pete Woods

Run make format following managed memory branch

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

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

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

review: Needs Fixing (continuous-integration)
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntu-app-launch/application-icon-finder.cpp'
2--- libubuntu-app-launch/application-icon-finder.cpp 2017-03-20 12:28:28 +0000
3+++ libubuntu-app-launch/application-icon-finder.cpp 2017-03-20 12:28:28 +0000
4@@ -220,7 +220,6 @@
5
6 auto newDirs = addSubdirectoryByType(themefile, directories[i], themePath);
7 subdirs.splice(subdirs.end(), newDirs);
8-
9 }
10 return subdirs;
11 }
12
13=== modified file 'libubuntu-app-launch/helper.cpp'
14--- libubuntu-app-launch/helper.cpp 2017-03-20 12:28:28 +0000
15+++ libubuntu-app-launch/helper.cpp 2017-03-20 12:28:28 +0000
16@@ -21,8 +21,8 @@
17 #include <list>
18 #include <numeric>
19
20+#include <unity/util/GObjectMemory.h>
21 #include <unity/util/GlibMemory.h>
22-#include <unity/util/GObjectMemory.h>
23 #include <unity/util/ResourcePtr.h>
24
25 #include "helper-impl.h"
26@@ -220,7 +220,7 @@
27 {
28 public:
29 std::shared_ptr<Registry> reg_;
30- ResourcePtr<int, void(*)(int)> mirfd;
31+ ResourcePtr<int, void (*)(int)> mirfd;
32 std::shared_ptr<proxySocketDemangler> skel;
33 ManagedSignalConnection<proxySocketDemangler> handle;
34 std::string path;
35@@ -229,7 +229,11 @@
36
37 MirFDProxy(MirPromptSession* session, const AppID& appid, const std::shared_ptr<Registry>& reg)
38 : reg_(reg)
39- , mirfd(0, [](int fp){if (fp != 0) close(fp);})
40+ , mirfd(0,
41+ [](int fp) {
42+ if (fp != 0)
43+ close(fp);
44+ })
45 , handle(SignalUnsubscriber<proxySocketDemangler>{})
46 , name(g_dbus_connection_get_unique_name(reg->impl->_dbus.get()))
47 {
48@@ -264,45 +268,44 @@
49 }
50
51 /* Setup the DBus interface */
52- std::tie(skel, handle, path) =
53- reg->impl->thread.executeOnThread<std::tuple<std::shared_ptr<proxySocketDemangler>, ManagedSignalConnection<proxySocketDemangler>, std::string>>(
54- [this, appid, reg]() {
55- auto skel = share_gobject(proxy_socket_demangler_skeleton_new());
56- auto handle = managedSignalConnection<proxySocketDemangler>(g_signal_connect(G_OBJECT(skel.get()), "handle-get-mir-socket",
57- G_CALLBACK(staticProxyCb), this), skel);
58-
59- /* Find a path to export on */
60- auto dbusAppid = dbusSafe(std::string{appid});
61- std::string path;
62-
63- while (path.empty())
64- {
65- GError* error = nullptr;
66- std::string tryname =
67- "/com/canonical/UbuntuAppLaunch/" + dbusAppid + "/" + std::to_string(rand());
68-
69- g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(skel.get()), reg->impl->_dbus.get(),
70- tryname.c_str(), &error);
71-
72- if (error == nullptr)
73- {
74- path = tryname;
75- }
76- else
77- {
78- if (!g_error_matches(error, G_DBUS_ERROR, G_DBUS_ERROR_OBJECT_PATH_IN_USE))
79- {
80- std::string message =
81- "Unable to export Mir trusted proxy: " + std::string{error->message};
82- g_clear_error(&error);
83- throw std::runtime_error{message};
84- }
85+ std::tie(skel, handle, path) = reg->impl->thread.executeOnThread<std::tuple<
86+ std::shared_ptr<proxySocketDemangler>, ManagedSignalConnection<proxySocketDemangler>, std::string>>(
87+ [this, appid, reg]() {
88+ auto skel = share_gobject(proxy_socket_demangler_skeleton_new());
89+ auto handle = managedSignalConnection<proxySocketDemangler>(
90+ g_signal_connect(G_OBJECT(skel.get()), "handle-get-mir-socket", G_CALLBACK(staticProxyCb), this),
91+ skel);
92+
93+ /* Find a path to export on */
94+ auto dbusAppid = dbusSafe(std::string{appid});
95+ std::string path;
96+
97+ while (path.empty())
98+ {
99+ GError* error = nullptr;
100+ std::string tryname = "/com/canonical/UbuntuAppLaunch/" + dbusAppid + "/" + std::to_string(rand());
101+
102+ g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(skel.get()), reg->impl->_dbus.get(),
103+ tryname.c_str(), &error);
104+
105+ if (error == nullptr)
106+ {
107+ path = tryname;
108+ }
109+ else
110+ {
111+ if (!g_error_matches(error, G_DBUS_ERROR, G_DBUS_ERROR_OBJECT_PATH_IN_USE))
112+ {
113+ std::string message = "Unable to export Mir trusted proxy: " + std::string{error->message};
114 g_clear_error(&error);
115+ throw std::runtime_error{message};
116 }
117+ g_clear_error(&error);
118 }
119+ }
120
121- return std::make_tuple(skel, std::move(handle), path);
122- });
123+ return std::make_tuple(skel, std::move(handle), path);
124+ });
125 }
126
127 ~MirFDProxy()
128
129=== modified file 'libubuntu-app-launch/jobs-base.cpp'
130--- libubuntu-app-launch/jobs-base.cpp 2017-03-20 12:28:28 +0000
131+++ libubuntu-app-launch/jobs-base.cpp 2017-03-20 12:28:28 +0000
132@@ -21,8 +21,8 @@
133 #include <cerrno>
134 #include <cstring>
135 #include <numeric>
136+#include <unity/util/GObjectMemory.h>
137 #include <unity/util/GlibMemory.h>
138-#include <unity/util/GObjectMemory.h>
139 #include <unity/util/ResourcePtr.h>
140
141 #include "application-impl-base.h"
142@@ -212,35 +212,35 @@
143 reg->impl->thread.executeOnThread<bool>([this, reg]() {
144 upstartEventData* data = new upstartEventData{reg};
145
146- handle_appPaused = managedDBusSignalConnection(g_dbus_connection_signal_subscribe(
147- reg->impl->_dbus.get(), /* bus */
148- nullptr, /* sender */
149- "com.canonical.UbuntuAppLaunch", /* interface */
150- "ApplicationPaused", /* signal */
151- "/", /* path */
152- nullptr, /* arg0 */
153- G_DBUS_SIGNAL_FLAGS_NONE,
154- [](GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant* params,
155- gpointer user_data) -> void {
156- auto data = reinterpret_cast<upstartEventData*>(user_data);
157- auto reg = data->weakReg.lock();
158-
159- if (!reg)
160- {
161- g_warning("Registry object invalid!");
162- return;
163- }
164-
165- auto sparams = share_glib(g_variant_ref(params));
166- auto manager = std::dynamic_pointer_cast<Base>(reg->impl->jobs);
167- manager->pauseEventEmitted(manager->sig_appPaused, sparams, reg);
168- }, /* callback */
169- data, /* user data */
170- [](gpointer user_data) {
171- auto data = reinterpret_cast<upstartEventData*>(user_data);
172- delete data;
173- }), /* user data destroy */
174- reg->impl->_dbus);
175+ handle_appPaused = managedDBusSignalConnection(
176+ g_dbus_connection_signal_subscribe(reg->impl->_dbus.get(), /* bus */
177+ nullptr, /* sender */
178+ "com.canonical.UbuntuAppLaunch", /* interface */
179+ "ApplicationPaused", /* signal */
180+ "/", /* path */
181+ nullptr, /* arg0 */
182+ G_DBUS_SIGNAL_FLAGS_NONE,
183+ [](GDBusConnection*, const gchar*, const gchar*, const gchar*,
184+ const gchar*, GVariant* params, gpointer user_data) -> void {
185+ auto data = reinterpret_cast<upstartEventData*>(user_data);
186+ auto reg = data->weakReg.lock();
187+
188+ if (!reg)
189+ {
190+ g_warning("Registry object invalid!");
191+ return;
192+ }
193+
194+ auto sparams = share_glib(g_variant_ref(params));
195+ auto manager = std::dynamic_pointer_cast<Base>(reg->impl->jobs);
196+ manager->pauseEventEmitted(manager->sig_appPaused, sparams, reg);
197+ }, /* callback */
198+ data, /* user data */
199+ [](gpointer user_data) {
200+ auto data = reinterpret_cast<upstartEventData*>(user_data);
201+ delete data;
202+ }), /* user data destroy */
203+ reg->impl->_dbus);
204
205 return true;
206 });
207@@ -262,35 +262,36 @@
208 reg->impl->thread.executeOnThread<bool>([this, reg]() {
209 upstartEventData* data = new upstartEventData{reg};
210
211- handle_appResumed = managedDBusSignalConnection(g_dbus_connection_signal_subscribe(
212- reg->impl->_dbus.get(), /* bus */
213- nullptr, /* sender */
214- "com.canonical.UbuntuAppLaunch", /* interface */
215- "ApplicationResumed", /* signal */
216- "/", /* path */
217- nullptr, /* arg0 */
218- G_DBUS_SIGNAL_FLAGS_NONE,
219- [](GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant* params,
220- gpointer user_data) -> void {
221- auto data = reinterpret_cast<upstartEventData*>(user_data);
222- auto reg = data->weakReg.lock();
223-
224- if (!reg)
225- {
226- g_warning("Registry object invalid!");
227- return;
228- }
229-
230- auto sparams = share_glib(g_variant_ref(params));
231- auto manager = std::dynamic_pointer_cast<Base>(reg->impl->jobs);
232- manager->pauseEventEmitted(manager->sig_appResumed, sparams, reg);
233- }, /* callback */
234- data, /* user data */
235- [](gpointer user_data) {
236- auto data = reinterpret_cast<upstartEventData*>(user_data);
237- delete data;
238- }), /* user data destroy */
239- reg->impl->_dbus);
240+ handle_appResumed = managedDBusSignalConnection(
241+ g_dbus_connection_signal_subscribe(reg->impl->_dbus.get(), /* bus */
242+ nullptr, /* sender */
243+ "com.canonical.UbuntuAppLaunch", /* interface */
244+ "ApplicationResumed", /* signal */
245+ "/", /* path */
246+ nullptr, /* arg0 */
247+ G_DBUS_SIGNAL_FLAGS_NONE,
248+ [](GDBusConnection*, const gchar*, const gchar*, const gchar*,
249+ const gchar*, GVariant* params, gpointer user_data) -> void {
250+ auto data = reinterpret_cast<upstartEventData*>(user_data);
251+ auto reg = data->weakReg.lock();
252+
253+ if (!reg)
254+ {
255+ g_warning("Registry object invalid!");
256+ return;
257+ }
258+
259+ auto sparams = share_glib(g_variant_ref(params));
260+ auto manager = std::dynamic_pointer_cast<Base>(reg->impl->jobs);
261+ manager->pauseEventEmitted(manager->sig_appResumed, sparams,
262+ reg);
263+ }, /* callback */
264+ data, /* user data */
265+ [](gpointer user_data) {
266+ auto data = reinterpret_cast<upstartEventData*>(user_data);
267+ delete data;
268+ }), /* user data destroy */
269+ reg->impl->_dbus);
270
271 return true;
272 });
273@@ -545,68 +546,74 @@
274 }
275
276 if (!reg->impl->thread.executeOnThread<bool>([this, reg]() {
277- handle_managerSignalFocus = managedDBusSignalConnection(managerSignalHelper(
278- reg, "UnityFocusRequest",
279- [](const std::shared_ptr<Registry>& reg, const std::shared_ptr<Application>& app,
280- const std::shared_ptr<Application::Instance>& instance,
281- const std::shared_ptr<GDBusConnection>& conn, const std::string& sender,
282- const std::shared_ptr<GVariant>& params) {
283- /* Nothing to do today */
284- std::dynamic_pointer_cast<Base>(reg->impl->jobs)
285- ->manager_->focusRequest(app, instance, [](bool response) {
286- /* NOTE: We have no clue what thread this is gonna be
287- executed on, but since we're just talking to the GDBus
288- thread it isn't an issue today. Be careful in changing
289- this code. */
290- });
291- }), reg->impl->_dbus);
292- handle_managerSignalStarting = managedDBusSignalConnection(managerSignalHelper(
293- reg, "UnityStartingBroadcast",
294- [](const std::shared_ptr<Registry>& reg, const std::shared_ptr<Application>& app,
295- const std::shared_ptr<Application::Instance>& instance,
296- const std::shared_ptr<GDBusConnection>& conn, const std::string& sender,
297- const std::shared_ptr<GVariant>& params) {
298+ handle_managerSignalFocus = managedDBusSignalConnection(
299+ managerSignalHelper(
300+ reg, "UnityFocusRequest",
301+ [](const std::shared_ptr<Registry>& reg, const std::shared_ptr<Application>& app,
302+ const std::shared_ptr<Application::Instance>& instance,
303+ const std::shared_ptr<GDBusConnection>& conn, const std::string& sender,
304+ const std::shared_ptr<GVariant>& params) {
305+ /* Nothing to do today */
306+ std::dynamic_pointer_cast<Base>(reg->impl->jobs)
307+ ->manager_->focusRequest(app, instance, [](bool response) {
308+ /* NOTE: We have no clue what thread this is gonna be
309+ executed on, but since we're just talking to the GDBus
310+ thread it isn't an issue today. Be careful in changing
311+ this code. */
312+ });
313+ }),
314+ reg->impl->_dbus);
315+ handle_managerSignalStarting = managedDBusSignalConnection(
316+ managerSignalHelper(
317+ reg, "UnityStartingBroadcast",
318+ [](const std::shared_ptr<Registry>& reg, const std::shared_ptr<Application>& app,
319+ const std::shared_ptr<Application::Instance>& instance,
320+ const std::shared_ptr<GDBusConnection>& conn, const std::string& sender,
321+ const std::shared_ptr<GVariant>& params) {
322
323- std::dynamic_pointer_cast<Base>(reg->impl->jobs)
324- ->manager_->startingRequest(app, instance, [conn, sender, params](bool response) {
325- /* NOTE: We have no clue what thread this is gonna be
326- executed on, but since we're just talking to the GDBus
327- thread it isn't an issue today. Be careful in changing
328- this code. */
329- if (response)
330- {
331- g_dbus_connection_emit_signal(conn.get(), sender.c_str(), /* destination */
332- "/", /* path */
333- "com.canonical.UbuntuAppLaunch", /* interface */
334- "UnityStartingSignal", /* signal */
335- params.get(), /* params, the same */
336- nullptr); /* error */
337- }
338- });
339- }), reg->impl->_dbus);
340- handle_managerSignalResume = managedDBusSignalConnection(managerSignalHelper(
341- reg, "UnityResumeRequest",
342- [](const std::shared_ptr<Registry>& reg, const std::shared_ptr<Application>& app,
343- const std::shared_ptr<Application::Instance>& instance,
344- const std::shared_ptr<GDBusConnection>& conn, const std::string& sender,
345- const std::shared_ptr<GVariant>& params) {
346- std::dynamic_pointer_cast<Base>(reg->impl->jobs)
347- ->manager_->resumeRequest(app, instance, [conn, sender, params](bool response) {
348- /* NOTE: We have no clue what thread this is gonna be
349- executed on, but since we're just talking to the GDBus
350- thread it isn't an issue today. Be careful in changing
351- this code. */
352- if (response)
353- {
354- g_dbus_connection_emit_signal(conn.get(), sender.c_str(), /* destination */
355- "/", /* path */
356- "com.canonical.UbuntuAppLaunch", /* interface */
357- "UnityResumeResponse", /* signal */
358- params.get(), /* params, the same */
359- nullptr); /* error */
360- }
361- });
362- }), reg->impl->_dbus);
363+ std::dynamic_pointer_cast<Base>(reg->impl->jobs)
364+ ->manager_->startingRequest(app, instance, [conn, sender, params](bool response) {
365+ /* NOTE: We have no clue what thread this is gonna be
366+ executed on, but since we're just talking to the GDBus
367+ thread it isn't an issue today. Be careful in changing
368+ this code. */
369+ if (response)
370+ {
371+ g_dbus_connection_emit_signal(conn.get(), sender.c_str(), /* destination */
372+ "/", /* path */
373+ "com.canonical.UbuntuAppLaunch", /* interface */
374+ "UnityStartingSignal", /* signal */
375+ params.get(), /* params, the same */
376+ nullptr); /* error */
377+ }
378+ });
379+ }),
380+ reg->impl->_dbus);
381+ handle_managerSignalResume = managedDBusSignalConnection(
382+ managerSignalHelper(
383+ reg, "UnityResumeRequest",
384+ [](const std::shared_ptr<Registry>& reg, const std::shared_ptr<Application>& app,
385+ const std::shared_ptr<Application::Instance>& instance,
386+ const std::shared_ptr<GDBusConnection>& conn, const std::string& sender,
387+ const std::shared_ptr<GVariant>& params) {
388+ std::dynamic_pointer_cast<Base>(reg->impl->jobs)
389+ ->manager_->resumeRequest(app, instance, [conn, sender, params](bool response) {
390+ /* NOTE: We have no clue what thread this is gonna be
391+ executed on, but since we're just talking to the GDBus
392+ thread it isn't an issue today. Be careful in changing
393+ this code. */
394+ if (response)
395+ {
396+ g_dbus_connection_emit_signal(conn.get(), sender.c_str(), /* destination */
397+ "/", /* path */
398+ "com.canonical.UbuntuAppLaunch", /* interface */
399+ "UnityResumeResponse", /* signal */
400+ params.get(), /* params, the same */
401+ nullptr); /* error */
402+ }
403+ });
404+ }),
405+ reg->impl->_dbus);
406
407 return true;
408 }))
409@@ -953,7 +960,8 @@
410 procpath = envvar;
411 }
412
413- auto gpath = unique_gchar(g_build_filename(procpath.c_str(), std::to_string(pid).c_str(), "oom_score_adj", nullptr));
414+ auto gpath =
415+ unique_gchar(g_build_filename(procpath.c_str(), std::to_string(pid).c_str(), "oom_score_adj", nullptr));
416 return std::string(gpath.get());
417 }
418
419@@ -967,8 +975,7 @@
420 {
421 auto oomstr = std::to_string(static_cast<std::int32_t>(oomvalue));
422 auto path = pidToOomPath(pid);
423- ResourcePtr<FILE*, void(*)(FILE*)> adj(fopen(path.c_str(), "w"), [](FILE* fp)
424- {
425+ ResourcePtr<FILE*, void (*)(FILE*)> adj(fopen(path.c_str(), "w"), [](FILE* fp) {
426 if (fp != nullptr)
427 {
428 fclose(fp);
429@@ -1029,21 +1036,22 @@
430 std::array<const char*, 4> args = {OOM_HELPER, pidstr.c_str(), oomstr.c_str(), nullptr};
431
432 g_debug("Excuting OOM Helper (pid: %d, score: %d): %s", int(pid), int(oomvalue),
433- std::accumulate(args.begin(), args.end(), std::string{}, [](const std::string& instr,
434- const char* output) -> std::string {
435- if (instr.empty())
436- {
437- return output;
438- }
439- else if (output != nullptr)
440- {
441- return instr + " " + std::string(output);
442- }
443- else
444- {
445- return instr;
446- }
447- }).c_str());
448+ std::accumulate(args.begin(), args.end(), std::string{},
449+ [](const std::string& instr, const char* output) -> std::string {
450+ if (instr.empty())
451+ {
452+ return output;
453+ }
454+ else if (output != nullptr)
455+ {
456+ return instr + " " + std::string(output);
457+ }
458+ else
459+ {
460+ return instr;
461+ }
462+ })
463+ .c_str());
464
465 g_spawn_async(nullptr, /* working dir */
466 (char**)(args.data()), /* args */
467@@ -1082,7 +1090,7 @@
468 g_array_append_val(array, str);
469 }
470
471- return unique_gcharv((gchar**) g_array_free(array, FALSE));
472+ return unique_gcharv((gchar**)g_array_free(array, FALSE));
473 }
474
475 } // namespace instance
476
477=== modified file 'libubuntu-app-launch/jobs-base.h'
478--- libubuntu-app-launch/jobs-base.h 2017-03-20 12:28:28 +0000
479+++ libubuntu-app-launch/jobs-base.h 2017-03-20 12:28:28 +0000
480@@ -153,8 +153,9 @@
481 Helper::Type type);
482 virtual core::Signal<const std::shared_ptr<Helper>&, const std::shared_ptr<Helper::Instance>&>& helperStopped(
483 Helper::Type type);
484- virtual core::
485- Signal<const std::shared_ptr<Helper>&, const std::shared_ptr<Helper::Instance>&, Registry::FailureType>&
486+ virtual core::Signal<const std::shared_ptr<Helper>&,
487+ const std::shared_ptr<Helper::Instance>&,
488+ Registry::FailureType>&
489 helperFailed(Helper::Type type);
490 /* Job signals from implementations */
491 virtual core::Signal<const std::string&, const std::string&, const std::string&>& jobStarted() = 0;
492@@ -212,11 +213,16 @@
493 Registry::FailureType>>>
494 sig_helpersFailed;
495
496- ManagedDBusSignalConnection handle_managerSignalFocus{DBusSignalUnsubscriber{}}; /**< GDBus signal watcher handle for app focused signal */
497- ManagedDBusSignalConnection handle_managerSignalResume{DBusSignalUnsubscriber{}}; /**< GDBus signal watcher handle for app resumed signal */
498- ManagedDBusSignalConnection handle_managerSignalStarting{DBusSignalUnsubscriber{}}; /**< GDBus signal watcher handle for app starting signal */
499- ManagedDBusSignalConnection handle_appPaused{DBusSignalUnsubscriber{}}; /**< GDBus signal watcher handle for app paused signal */
500- ManagedDBusSignalConnection handle_appResumed{DBusSignalUnsubscriber{}}; /**< GDBus signal watcher handle for app resumed signal */
501+ ManagedDBusSignalConnection handle_managerSignalFocus{
502+ DBusSignalUnsubscriber{}}; /**< GDBus signal watcher handle for app focused signal */
503+ ManagedDBusSignalConnection handle_managerSignalResume{
504+ DBusSignalUnsubscriber{}}; /**< GDBus signal watcher handle for app resumed signal */
505+ ManagedDBusSignalConnection handle_managerSignalStarting{
506+ DBusSignalUnsubscriber{}}; /**< GDBus signal watcher handle for app starting signal */
507+ ManagedDBusSignalConnection handle_appPaused{
508+ DBusSignalUnsubscriber{}}; /**< GDBus signal watcher handle for app paused signal */
509+ ManagedDBusSignalConnection handle_appResumed{
510+ DBusSignalUnsubscriber{}}; /**< GDBus signal watcher handle for app resumed signal */
511
512 std::once_flag flag_managerSignals; /**< Variable to track to see if signal handlers are installed for the manager
513 signals of focused, resumed and starting */
514
515=== modified file 'libubuntu-app-launch/jobs-systemd.cpp'
516--- libubuntu-app-launch/jobs-systemd.cpp 2017-03-20 12:28:28 +0000
517+++ libubuntu-app-launch/jobs-systemd.cpp 2017-03-20 12:28:28 +0000
518@@ -193,107 +193,109 @@
519 nullptr);
520
521 /* Setup Unit add/remove signals */
522- handle_unitNew = managedDBusSignalConnection(g_dbus_connection_signal_subscribe(
523- bus.get(), /* bus */
524- nullptr, /* sender */
525- SYSTEMD_DBUS_IFACE_MANAGER, /* interface */
526- "UnitNew", /* signal */
527- SYSTEMD_DBUS_PATH_MANAGER, /* path */
528- nullptr, /* arg0 */
529- G_DBUS_SIGNAL_FLAGS_NONE,
530- [](GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant* params,
531- gpointer user_data) -> void {
532- auto pthis = static_cast<SystemD*>(user_data);
533-
534- if (!g_variant_check_format_string(params, "(so)", FALSE))
535- {
536- g_warning("Got 'UnitNew' signal with unknown parameter type: %s",
537- g_variant_get_type_string(params));
538- return;
539- }
540-
541- const gchar* unitname{nullptr};
542- const gchar* unitpath{nullptr};
543-
544- g_variant_get(params, "(&s&o)", &unitname, &unitpath);
545-
546- if (unitname == nullptr || unitpath == nullptr)
547- {
548- g_warning("Got 'UnitNew' signal with funky params %p, %p", unitname, unitpath);
549- return;
550- }
551-
552- try
553- {
554- pthis->parseUnit(unitname);
555- }
556- catch (std::runtime_error& e)
557- {
558- /* Not for UAL */
559- g_debug("Unable to parse unit: %s", unitname);
560- return;
561- }
562-
563- try
564- {
565- auto info = pthis->unitNew(unitname, unitpath, pthis->userbus_);
566- pthis->sig_jobStarted(info.job, info.appid, info.inst);
567- }
568- catch (std::runtime_error& e)
569- {
570- g_warning("%s", e.what());
571- }
572- }, /* callback */
573- this, /* user data */
574- nullptr), /* user data destroy */
575- bus);
576-
577- handle_unitRemoved = managedDBusSignalConnection(g_dbus_connection_signal_subscribe(
578- bus.get(), /* bus */
579- nullptr, /* sender */
580- SYSTEMD_DBUS_IFACE_MANAGER, /* interface */
581- "UnitRemoved", /* signal */
582- SYSTEMD_DBUS_PATH_MANAGER, /* path */
583- nullptr, /* arg0 */
584- G_DBUS_SIGNAL_FLAGS_NONE,
585- [](GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant* params,
586- gpointer user_data) -> void {
587- auto pthis = static_cast<SystemD*>(user_data);
588-
589- if (!g_variant_check_format_string(params, "(so)", FALSE))
590- {
591- g_warning("Got 'UnitRemoved' signal with unknown parameter type: %s",
592- g_variant_get_type_string(params));
593- return;
594- }
595-
596- const gchar* unitname{nullptr};
597- const gchar* unitpath{nullptr};
598-
599- g_variant_get(params, "(&s&o)", &unitname, &unitpath);
600-
601- if (unitname == nullptr || unitpath == nullptr)
602- {
603- g_warning("Got 'UnitRemoved' signal with funky params %p, %p", unitname, unitpath);
604- return;
605- }
606-
607- try
608- {
609- pthis->parseUnit(unitname);
610- }
611- catch (std::runtime_error& e)
612- {
613- /* Not for UAL */
614- g_debug("Unable to parse unit: %s", unitname);
615- return;
616- }
617-
618- pthis->unitRemoved(unitname, unitpath);
619- }, /* callback */
620- this, /* user data */
621- nullptr), /* user data destroy */
622- bus);
623+ handle_unitNew = managedDBusSignalConnection(
624+ g_dbus_connection_signal_subscribe(bus.get(), /* bus */
625+ nullptr, /* sender */
626+ SYSTEMD_DBUS_IFACE_MANAGER, /* interface */
627+ "UnitNew", /* signal */
628+ SYSTEMD_DBUS_PATH_MANAGER, /* path */
629+ nullptr, /* arg0 */
630+ G_DBUS_SIGNAL_FLAGS_NONE,
631+ [](GDBusConnection*, const gchar*, const gchar*, const gchar*,
632+ const gchar*, GVariant* params, gpointer user_data) -> void {
633+ auto pthis = static_cast<SystemD*>(user_data);
634+
635+ if (!g_variant_check_format_string(params, "(so)", FALSE))
636+ {
637+ g_warning("Got 'UnitNew' signal with unknown parameter type: %s",
638+ g_variant_get_type_string(params));
639+ return;
640+ }
641+
642+ const gchar* unitname{nullptr};
643+ const gchar* unitpath{nullptr};
644+
645+ g_variant_get(params, "(&s&o)", &unitname, &unitpath);
646+
647+ if (unitname == nullptr || unitpath == nullptr)
648+ {
649+ g_warning("Got 'UnitNew' signal with funky params %p, %p",
650+ unitname, unitpath);
651+ return;
652+ }
653+
654+ try
655+ {
656+ pthis->parseUnit(unitname);
657+ }
658+ catch (std::runtime_error& e)
659+ {
660+ /* Not for UAL */
661+ g_debug("Unable to parse unit: %s", unitname);
662+ return;
663+ }
664+
665+ try
666+ {
667+ auto info = pthis->unitNew(unitname, unitpath, pthis->userbus_);
668+ pthis->sig_jobStarted(info.job, info.appid, info.inst);
669+ }
670+ catch (std::runtime_error& e)
671+ {
672+ g_warning("%s", e.what());
673+ }
674+ }, /* callback */
675+ this, /* user data */
676+ nullptr), /* user data destroy */
677+ bus);
678+
679+ handle_unitRemoved = managedDBusSignalConnection(
680+ g_dbus_connection_signal_subscribe(
681+ bus.get(), /* bus */
682+ nullptr, /* sender */
683+ SYSTEMD_DBUS_IFACE_MANAGER, /* interface */
684+ "UnitRemoved", /* signal */
685+ SYSTEMD_DBUS_PATH_MANAGER, /* path */
686+ nullptr, /* arg0 */
687+ G_DBUS_SIGNAL_FLAGS_NONE,
688+ [](GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*, GVariant* params,
689+ gpointer user_data) -> void {
690+ auto pthis = static_cast<SystemD*>(user_data);
691+
692+ if (!g_variant_check_format_string(params, "(so)", FALSE))
693+ {
694+ g_warning("Got 'UnitRemoved' signal with unknown parameter type: %s",
695+ g_variant_get_type_string(params));
696+ return;
697+ }
698+
699+ const gchar* unitname{nullptr};
700+ const gchar* unitpath{nullptr};
701+
702+ g_variant_get(params, "(&s&o)", &unitname, &unitpath);
703+
704+ if (unitname == nullptr || unitpath == nullptr)
705+ {
706+ g_warning("Got 'UnitRemoved' signal with funky params %p, %p", unitname, unitpath);
707+ return;
708+ }
709+
710+ try
711+ {
712+ pthis->parseUnit(unitname);
713+ }
714+ catch (std::runtime_error& e)
715+ {
716+ /* Not for UAL */
717+ g_debug("Unable to parse unit: %s", unitname);
718+ return;
719+ }
720+
721+ pthis->unitRemoved(unitname, unitpath);
722+ }, /* callback */
723+ this, /* user data */
724+ nullptr), /* user data destroy */
725+ bus);
726
727 getInitialUnits(bus, cancel);
728
729@@ -314,17 +316,17 @@
730 {
731 GError* error = nullptr;
732
733- auto callt = unique_glib(g_dbus_connection_call_sync(bus.get(), /* user bus */
734- SYSTEMD_DBUS_ADDRESS, /* bus name */
735- SYSTEMD_DBUS_PATH_MANAGER, /* path */
736- SYSTEMD_DBUS_IFACE_MANAGER, /* interface */
737- "ListUnits", /* method */
738- nullptr, /* params */
739- G_VARIANT_TYPE("(a(ssssssouso))"), /* ret type */
740- G_DBUS_CALL_FLAGS_NONE, /* flags */
741- -1, /* timeout */
742- cancel.get(), /* cancellable */
743- &error));
744+ auto callt = unique_glib(g_dbus_connection_call_sync(bus.get(), /* user bus */
745+ SYSTEMD_DBUS_ADDRESS, /* bus name */
746+ SYSTEMD_DBUS_PATH_MANAGER, /* path */
747+ SYSTEMD_DBUS_IFACE_MANAGER, /* interface */
748+ "ListUnits", /* method */
749+ nullptr, /* params */
750+ G_VARIANT_TYPE("(a(ssssssouso))"), /* ret type */
751+ G_DBUS_CALL_FLAGS_NONE, /* flags */
752+ -1, /* timeout */
753+ cancel.get(), /* cancellable */
754+ &error));
755
756 if (error != nullptr)
757 {
758@@ -349,8 +351,8 @@
759 const gchar* jobType;
760 const gchar* jobPath;
761 auto iter = unique_glib(g_variant_iter_new(call.get()));
762- while (g_variant_iter_loop(iter.get(), "(&s&s&s&s&s&s&ou&s&o)", &id, &description, &loadState, &activeState, &subState,
763- &following, &path, &jobId, &jobType, &jobPath))
764+ while (g_variant_iter_loop(iter.get(), "(&s&s&s&s&s&s&ou&s&o)", &id, &description, &loadState, &activeState,
765+ &subState, &following, &path, &jobId, &jobType, &jobPath))
766 {
767 g_debug("List Units: %s", id);
768 try
769@@ -976,17 +978,17 @@
770 throw std::runtime_error{"Unable to get SystemD unit path for '" + name + "': Registry out of scope"};
771 }
772
773- auto call = unique_glib(g_dbus_connection_call_sync(bus.get(), /* user bus */
774- SYSTEMD_DBUS_ADDRESS, /* bus name */
775- SYSTEMD_DBUS_PATH_MANAGER, /* path */
776- SYSTEMD_DBUS_IFACE_MANAGER, /* interface */
777- "GetUnit", /* method */
778- g_variant_new("(s)", name.c_str()), /* params */
779- G_VARIANT_TYPE("(o)"), /* ret type */
780- G_DBUS_CALL_FLAGS_NONE, /* flags */
781- -1, /* timeout */
782- reg->impl->thread.getCancellable().get(), /* cancellable */
783- &error));
784+ auto call = unique_glib(g_dbus_connection_call_sync(bus.get(), /* user bus */
785+ SYSTEMD_DBUS_ADDRESS, /* bus name */
786+ SYSTEMD_DBUS_PATH_MANAGER, /* path */
787+ SYSTEMD_DBUS_IFACE_MANAGER, /* interface */
788+ "GetUnit", /* method */
789+ g_variant_new("(s)", name.c_str()), /* params */
790+ G_VARIANT_TYPE("(o)"), /* ret type */
791+ G_DBUS_CALL_FLAGS_NONE, /* flags */
792+ -1, /* timeout */
793+ reg->impl->thread.getCancellable().get(), /* cancellable */
794+ &error));
795
796 if (error != nullptr)
797 {
798@@ -1239,85 +1241,86 @@
799 reg->impl->thread.executeOnThread<bool>([this, reg]() {
800 auto data = new FailedData{reg};
801
802- handle_appFailed = managedDBusSignalConnection(g_dbus_connection_signal_subscribe(
803- userbus_.get(), /* bus */
804- SYSTEMD_DBUS_ADDRESS, /* sender */
805- "org.freedesktop.DBus.Properties", /* interface */
806- "PropertiesChanged", /* signal */
807- nullptr, /* path */
808- SYSTEMD_DBUS_IFACE_SERVICE, /* arg0 */
809- G_DBUS_SIGNAL_FLAGS_NONE,
810- [](GDBusConnection*, const gchar*, const gchar* path, const gchar*, const gchar*, GVariant* params,
811- gpointer user_data) -> void {
812- auto data = static_cast<FailedData*>(user_data);
813- auto reg = data->registry.lock();
814-
815- if (!reg)
816- {
817- g_warning("Registry object invalid!");
818- return;
819- }
820-
821- auto manager = std::dynamic_pointer_cast<SystemD>(reg->impl->jobs);
822-
823- /* Check to see if this is a path we care about */
824- bool pathfound{false};
825- UnitInfo unitinfo;
826- for (const auto& unit : manager->unitPaths)
827- {
828- if (unit.second->unitpath == path)
829- {
830- pathfound = true;
831- unitinfo = unit.first;
832- break;
833- }
834- }
835- if (!pathfound)
836- {
837- return;
838- }
839-
840- /* Now see if it is a property we care about */
841- auto vdict = unique_glib(g_variant_get_child_value(params, 1));
842- GVariantDict dict;
843- g_variant_dict_init(&dict, vdict.get());
844-
845- if (g_variant_dict_contains(&dict, "Result") == FALSE)
846- {
847- /* We don't care about anything else */
848- g_variant_dict_clear(&dict);
849- return;
850- }
851-
852- /* Check to see if it just was successful */
853- const gchar* value{nullptr};
854- g_variant_dict_lookup(&dict, "Result", "&s", &value);
855-
856- if (g_strcmp0(value, "success") == 0)
857- {
858- g_variant_dict_clear(&dict);
859- return;
860- }
861- g_variant_dict_clear(&dict);
862-
863- /* Reset the failure bit on the unit */
864- manager->resetUnit(unitinfo);
865-
866- /* Oh, we might want to do something now */
867- auto reason{Registry::FailureType::CRASH};
868- if (g_strcmp0(value, "exit-code") == 0)
869- {
870- reason = Registry::FailureType::START_FAILURE;
871- }
872-
873- manager->sig_jobFailed(unitinfo.job, unitinfo.appid, unitinfo.inst, reason);
874- }, /* callback */
875- data, /* user data */
876- [](gpointer user_data) {
877- auto data = static_cast<FailedData*>(user_data);
878- delete data;
879- }), /* user data destroy */
880- userbus_);
881+ handle_appFailed = managedDBusSignalConnection(
882+ g_dbus_connection_signal_subscribe(
883+ userbus_.get(), /* bus */
884+ SYSTEMD_DBUS_ADDRESS, /* sender */
885+ "org.freedesktop.DBus.Properties", /* interface */
886+ "PropertiesChanged", /* signal */
887+ nullptr, /* path */
888+ SYSTEMD_DBUS_IFACE_SERVICE, /* arg0 */
889+ G_DBUS_SIGNAL_FLAGS_NONE,
890+ [](GDBusConnection*, const gchar*, const gchar* path, const gchar*, const gchar*, GVariant* params,
891+ gpointer user_data) -> void {
892+ auto data = static_cast<FailedData*>(user_data);
893+ auto reg = data->registry.lock();
894+
895+ if (!reg)
896+ {
897+ g_warning("Registry object invalid!");
898+ return;
899+ }
900+
901+ auto manager = std::dynamic_pointer_cast<SystemD>(reg->impl->jobs);
902+
903+ /* Check to see if this is a path we care about */
904+ bool pathfound{false};
905+ UnitInfo unitinfo;
906+ for (const auto& unit : manager->unitPaths)
907+ {
908+ if (unit.second->unitpath == path)
909+ {
910+ pathfound = true;
911+ unitinfo = unit.first;
912+ break;
913+ }
914+ }
915+ if (!pathfound)
916+ {
917+ return;
918+ }
919+
920+ /* Now see if it is a property we care about */
921+ auto vdict = unique_glib(g_variant_get_child_value(params, 1));
922+ GVariantDict dict;
923+ g_variant_dict_init(&dict, vdict.get());
924+
925+ if (g_variant_dict_contains(&dict, "Result") == FALSE)
926+ {
927+ /* We don't care about anything else */
928+ g_variant_dict_clear(&dict);
929+ return;
930+ }
931+
932+ /* Check to see if it just was successful */
933+ const gchar* value{nullptr};
934+ g_variant_dict_lookup(&dict, "Result", "&s", &value);
935+
936+ if (g_strcmp0(value, "success") == 0)
937+ {
938+ g_variant_dict_clear(&dict);
939+ return;
940+ }
941+ g_variant_dict_clear(&dict);
942+
943+ /* Reset the failure bit on the unit */
944+ manager->resetUnit(unitinfo);
945+
946+ /* Oh, we might want to do something now */
947+ auto reason{Registry::FailureType::CRASH};
948+ if (g_strcmp0(value, "exit-code") == 0)
949+ {
950+ reason = Registry::FailureType::START_FAILURE;
951+ }
952+
953+ manager->sig_jobFailed(unitinfo.job, unitinfo.appid, unitinfo.inst, reason);
954+ }, /* callback */
955+ data, /* user data */
956+ [](gpointer user_data) {
957+ auto data = static_cast<FailedData*>(user_data);
958+ delete data;
959+ }), /* user data destroy */
960+ userbus_);
961
962 return true;
963 });
964
965=== modified file 'libubuntu-app-launch/registry-impl.cpp'
966--- libubuntu-app-launch/registry-impl.cpp 2017-03-20 12:28:28 +0000
967+++ libubuntu-app-launch/registry-impl.cpp 2017-03-20 12:28:28 +0000
968@@ -21,8 +21,8 @@
969 #include "application-icon-finder.h"
970 #include "application-impl-base.h"
971 #include <regex>
972+#include <unity/util/GObjectMemory.h>
973 #include <unity/util/GlibMemory.h>
974-#include <unity/util/GObjectMemory.h>
975
976 using namespace unity::util;
977
978@@ -186,9 +186,8 @@
979 for (const auto& app : apps)
980 {
981 infoWatchers_.emplace_back(
982- std::make_pair(app, app->infoChanged().connect([this](const std::shared_ptr<Application>& app) {
983- sig_appInfoUpdated(app);
984- })));
985+ std::make_pair(app, app->infoChanged().connect(
986+ [this](const std::shared_ptr<Application>& app) { sig_appInfoUpdated(app); })));
987 }
988 });
989 return sig_appInfoUpdated;
990
991=== modified file 'libubuntu-app-launch/registry.h'
992--- libubuntu-app-launch/registry.h 2017-03-20 12:28:28 +0000
993+++ libubuntu-app-launch/registry.h 2017-03-20 12:28:28 +0000
994@@ -99,8 +99,9 @@
995
996 \param reg Registry to get the handler from
997 */
998- static core::
999- Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&, FailureType>&
1000+ static core::Signal<const std::shared_ptr<Application>&,
1001+ const std::shared_ptr<Application::Instance>&,
1002+ FailureType>&
1003 appFailed(const std::shared_ptr<Registry>& reg = getDefault());
1004
1005 /** Get the signal object that is signaled when an application has been

Subscribers

People subscribed via source and target branches