Merge lp:~ted/unity/systemd-unit. into lp:unity

Proposed by Ted Gould
Status: Superseded
Proposed branch: lp:~ted/unity/systemd-unit.
Merge into: lp:unity
Diff against target: 604 lines (+360/-20)
22 files modified
debian/control (+2/-0)
debian/libunity-core-6.0-9.install (+2/-0)
debian/unity-services.install (+1/-0)
debian/unity7.conf (+1/-18)
debian/unity7.override (+1/-0)
debian/unity7.service (+11/-0)
lockscreen/LockScreenController.cpp (+4/-0)
lockscreen/LockScreenController.h (+3/-0)
plugins/unityshell/unityshell.xml.in (+2/-0)
services/CMakeLists.txt (+31/-0)
services/unity-panel-service-lockscreen.override (+1/-0)
services/unity-panel-service-lockscreen.service.in (+7/-0)
services/unity-panel-service.override (+1/-0)
services/unity-panel-service.service.in (+9/-0)
services/unity-screen-locked.target (+4/-0)
tests/test_lockscreen_controller.cpp (+5/-2)
tools/CMakeLists.txt (+24/-0)
tools/unity-compiz-profile (+25/-0)
tools/unity_active_plugins_safety_check.cpp (+83/-0)
unity-shared/CMakeLists.txt (+1/-0)
unity-shared/SystemdWrapper.cpp (+88/-0)
unity-shared/SystemdWrapper.h (+54/-0)
To merge this branch: bzr merge lp:~ted/unity/systemd-unit.
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+300584@code.launchpad.net

This proposal has been superseded by a proposal from 2016-07-20.

Commit message

Adding systemd user session units

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

There have been changes recently to upstart job to change COMPIZ_CONFIG_PROFILE depending on the gfx environment. So please sync with upstream changes on that.

Also, please rebase on lp:~azzar1/unity/unity-active-plugins--safety-check, which will need to be ported too

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2016-03-21 15:38:17 +0000
3+++ debian/control 2016-07-20 15:08:18 +0000
4@@ -52,6 +52,7 @@
5 python3 (>= 3.4),
6 python-setuptools,
7 quilt,
8+ systemd,
9 xserver-xorg-video-dummy,
10 xsltproc,
11 Standards-Version: 3.9.5
12@@ -127,6 +128,7 @@
13 Architecture: all
14 Multi-Arch: foreign
15 Depends: ${misc:Depends},
16+ indicator-common,
17 Replaces: libunity-core-6.0-9 (<< 7.3.0),
18 Breaks: libunity-core-6.0-9 (<< 7.3.0),
19 Description: Interface designed for efficiency of space and interaction.
20
21=== modified file 'debian/libunity-core-6.0-9.install'
22--- debian/libunity-core-6.0-9.install 2016-02-09 01:26:22 +0000
23+++ debian/libunity-core-6.0-9.install 2016-07-20 15:08:18 +0000
24@@ -6,4 +6,6 @@
25 debian/unity-crashdb.conf etc/apport/crashdb.conf.d/
26 debian/source_unity.py usr/share/apport/package-hooks
27 debian/unity7.conf usr/share/upstart/sessions
28+debian/unity7.service usr/lib/systemd/user
29+debian/unity7.override usr/share/upstart/systemd-session/upstart
30 tools/convert-files/* usr/lib/compiz/migration/
31
32=== modified file 'debian/unity-services.install'
33--- debian/unity-services.install 2016-02-09 01:26:22 +0000
34+++ debian/unity-services.install 2016-07-20 15:08:18 +0000
35@@ -1,3 +1,4 @@
36 usr/lib/*/unity/*service
37 usr/share/upstart
38+usr/lib/systemd
39 usr/share/man/*/unity-panel-service.1
40
41=== modified file 'debian/unity7.conf'
42--- debian/unity7.conf 2016-07-05 01:26:04 +0000
43+++ debian/unity7.conf 2016-07-20 15:08:18 +0000
44@@ -4,24 +4,7 @@
45 start on xsession SESSION=ubuntu and started unity-settings-daemon
46 stop on desktop-end
47
48-pre-start script
49- # If gnome-session is going to start compiz,
50- # we don't want to be the ones doing it.
51-
52- if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
53- echo "GNOME Session is starting Compiz"
54- stop ; exit 0
55- fi
56-
57- compiz_profile="ubuntu"
58-
59- if ! /usr/lib/nux/unity_support_test -p; then
60- compiz_profile="ubuntu-lowgfx"
61- fi
62-
63- echo "Using compiz profile '$compiz_profile'"
64- initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
65-end script
66+pre-start exec /usr/lib/unity/unity-compiz-profile
67
68 respawn
69 exec compiz
70
71=== added file 'debian/unity7.override'
72--- debian/unity7.override 1970-01-01 00:00:00 +0000
73+++ debian/unity7.override 2016-07-20 15:08:18 +0000
74@@ -0,0 +1,1 @@
75+manual
76
77=== added file 'debian/unity7.service'
78--- debian/unity7.service 1970-01-01 00:00:00 +0000
79+++ debian/unity7.service 2016-07-20 15:08:18 +0000
80@@ -0,0 +1,11 @@
81+[Unit]
82+Description=Unity Shell v7
83+Requires=unity-settings-daemon.service unity-panel-service.service bamfdaemon.service
84+Wants=unity-gtk-module.service
85+After=unity-settings-daemon.service
86+PartOf=graphical-session.target
87+
88+[Service]
89+ExecStart=/usr/bin/compiz
90+ExecStart.Pre=/usr/lib/unity/unity-compiz-profile
91+Restart=on-failure
92
93=== modified file 'lockscreen/LockScreenController.cpp'
94--- lockscreen/LockScreenController.cpp 2016-07-04 12:45:06 +0000
95+++ lockscreen/LockScreenController.cpp 2016-07-20 15:08:18 +0000
96@@ -56,6 +56,7 @@
97 Controller::Controller(DBusManager::Ptr const& dbus_manager,
98 session::Manager::Ptr const& session_manager,
99 key::Grabber::Ptr const& key_grabber,
100+ SystemdWrapper::Ptr const& systemd_wrapper,
101 UpstartWrapper::Ptr const& upstart_wrapper,
102 ShieldFactoryInterface::Ptr const& shield_factory,
103 bool test_mode)
104@@ -63,6 +64,7 @@
105 , dbus_manager_(dbus_manager)
106 , session_manager_(session_manager)
107 , key_grabber_(key_grabber)
108+ , systemd_wrapper_(systemd_wrapper)
109 , upstart_wrapper_(upstart_wrapper)
110 , shield_factory_(shield_factory)
111 , suspend_inhibitor_manager_(std::make_shared<SuspendInhibitorManager>())
112@@ -129,6 +131,7 @@
113 shields_.clear();
114
115 upstart_wrapper_->Emit("desktop-unlock");
116+ systemd_wrapper_->Stop("unity-screen-locked.target");
117 accelerator_controller_.reset();
118 indicators_.reset();
119 }
120@@ -464,6 +467,7 @@
121 {
122 indicators_ = std::make_shared<indicator::LockScreenDBusIndicators>();
123 upstart_wrapper_->Emit("desktop-lock");
124+ systemd_wrapper_->Stop("unity-screen-locked.target");
125
126 accelerator_controller_ = std::make_shared<AcceleratorController>(key_grabber_);
127 auto activate_key = WindowManager::Default().activate_indicators_key();
128
129=== modified file 'lockscreen/LockScreenController.h'
130--- lockscreen/LockScreenController.h 2016-06-21 01:28:26 +0000
131+++ lockscreen/LockScreenController.h 2016-07-20 15:08:18 +0000
132@@ -31,6 +31,7 @@
133 #include "ScreenSaverDBusManager.h"
134 #include "unity-shared/BackgroundEffectHelper.h"
135 #include "unity-shared/KeyGrabber.h"
136+#include "unity-shared/SystemdWrapper.h"
137 #include "unity-shared/UpstartWrapper.h"
138
139 namespace unity
140@@ -46,6 +47,7 @@
141 typedef std::shared_ptr<Controller> Ptr;
142
143 Controller(DBusManager::Ptr const&, session::Manager::Ptr const&, key::Grabber::Ptr const&,
144+ SystemdWrapper::Ptr const& systemd_wrapper = std::make_shared<SystemdWrapper>(),
145 UpstartWrapper::Ptr const& upstart_wrapper = std::make_shared<UpstartWrapper>(),
146 ShieldFactoryInterface::Ptr const& shield_factory = std::make_shared<ShieldFactory>(),
147 bool test_mode = false);
148@@ -88,6 +90,7 @@
149 key::Grabber::Ptr key_grabber_;
150 indicator::Indicators::Ptr indicators_;
151 AcceleratorController::Ptr accelerator_controller_;
152+ SystemdWrapper::Ptr systemd_wrapper_;
153 UpstartWrapper::Ptr upstart_wrapper_;
154 ShieldFactoryInterface::Ptr shield_factory_;
155 SuspendInhibitorManager::Ptr suspend_inhibitor_manager_;
156
157=== modified file 'plugins/unityshell/unityshell.xml.in'
158--- plugins/unityshell/unityshell.xml.in 2016-04-05 13:23:27 +0000
159+++ plugins/unityshell/unityshell.xml.in 2016-07-20 15:08:18 +0000
160@@ -39,6 +39,8 @@
161 <plugin>compiztoolbox</plugin>
162 <plugin>scale</plugin>
163 <plugin>expo</plugin>
164+ <plugin>move</plugin>
165+ <plugin>resize</plugin>
166 </requirement>
167 <conflict>
168 <plugin>decor</plugin>
169
170=== modified file 'services/CMakeLists.txt'
171--- services/CMakeLists.txt 2016-02-09 01:26:22 +0000
172+++ services/CMakeLists.txt 2016-07-20 15:08:18 +0000
173@@ -58,3 +58,34 @@
174
175 configure_file(unity-panel-service-lockscreen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf)
176 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.conf DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
177+
178+##
179+## Systemd Unit Files
180+##
181+
182+# where to install
183+# Uncomment when we drop Vivid
184+# pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)
185+set (SYSTEMD_USER_DIR "/usr/lib/systemd/user")
186+message (STATUS "${SYSTEMD_USER_DIR} is the systemd user unit file install dir")
187+
188+configure_file (unity-panel-service.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service")
189+configure_file (unity-panel-service-lockscreen.service.in "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service")
190+
191+install( FILES
192+ "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service.service"
193+ "${CMAKE_CURRENT_BINARY_DIR}/unity-panel-service-lockscreen.service"
194+ "${CMAKE_CURRENT_BINARY_DIR}/unity-screen-locked.target"
195+ DESTINATION "${SYSTEMD_USER_DIR}")
196+
197+##
198+## Upstart systemd override Job File
199+##
200+
201+set (UPSTART_SYSTEMD_OVERRIDE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/upstart/systemd-session/upstart")
202+message (STATUS "${UPSTART_SYSTEMD_OVERRIDE_DIR} is the Upstart override Job File for systemd dir")
203+
204+install (FILES
205+ unity-panel-service.override
206+ unity-panel-service-lockscreen.override
207+ DESTINATION "${UPSTART_SYSTEMD_OVERRIDE_DIR}")
208
209=== added file 'services/unity-panel-service-lockscreen.override'
210--- services/unity-panel-service-lockscreen.override 1970-01-01 00:00:00 +0000
211+++ services/unity-panel-service-lockscreen.override 2016-07-20 15:08:18 +0000
212@@ -0,0 +1,1 @@
213+manual
214
215=== added file 'services/unity-panel-service-lockscreen.service.in'
216--- services/unity-panel-service-lockscreen.service.in 1970-01-01 00:00:00 +0000
217+++ services/unity-panel-service-lockscreen.service.in 2016-07-20 15:08:18 +0000
218@@ -0,0 +1,7 @@
219+[Unit]
220+Description=Backing Service for the Unity Panel in Lockscreen mode
221+PartOf=unity-screen-locked.target
222+
223+[Service]
224+ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service --lockscreen-mode
225+Restart=on-failure
226
227=== added file 'services/unity-panel-service.override'
228--- services/unity-panel-service.override 1970-01-01 00:00:00 +0000
229+++ services/unity-panel-service.override 2016-07-20 15:08:18 +0000
230@@ -0,0 +1,1 @@
231+manual
232
233=== added file 'services/unity-panel-service.service.in'
234--- services/unity-panel-service.service.in 1970-01-01 00:00:00 +0000
235+++ services/unity-panel-service.service.in 2016-07-20 15:08:18 +0000
236@@ -0,0 +1,9 @@
237+[Unit]
238+Description=Backing Service for the Unity Panel
239+After=unity7.service
240+PartOf=graphical-session.target
241+BindsTo=indicators-pre.target
242+
243+[Service]
244+ExecStart=${CMAKE_INSTALL_FULL_LIBDIR}/unity/unity-panel-service
245+Restart=on-failure
246
247=== added file 'services/unity-screen-locked.target'
248--- services/unity-screen-locked.target 1970-01-01 00:00:00 +0000
249+++ services/unity-screen-locked.target 2016-07-20 15:08:18 +0000
250@@ -0,0 +1,4 @@
251+[Unit]
252+Description=A target that, when running, represents the screen being locked
253+Wants=ubuntu-panel-service-lock.service
254+PartOf=graphical-session.target
255
256=== modified file 'tests/test_lockscreen_controller.cpp'
257--- tests/test_lockscreen_controller.cpp 2016-06-21 14:40:26 +0000
258+++ tests/test_lockscreen_controller.cpp 2016-07-20 15:08:18 +0000
259@@ -83,9 +83,10 @@
260 , session_manager(std::make_shared<NiceMock<session::MockManager>>())
261 , key_grabber(std::make_shared<key::MockGrabber::Nice>())
262 , dbus_manager(std::make_shared<DBusManager>(session_manager))
263+ , systemd_wrapper(std::make_shared<SystemdWrapper>())
264 , upstart_wrapper(std::make_shared<UpstartWrapper>())
265 , shield_factory(std::make_shared<ShieldFactoryMock>())
266- , controller(dbus_manager, session_manager, key_grabber, upstart_wrapper, shield_factory)
267+ , controller(dbus_manager, session_manager, key_grabber, systemd_wrapper, upstart_wrapper, shield_factory)
268 {}
269
270 struct ControllerWrap : Controller
271@@ -93,9 +94,10 @@
272 ControllerWrap(DBusManager::Ptr const& dbus_manager,
273 session::Manager::Ptr const& session_manager,
274 key::Grabber::Ptr const& key_grabber,
275+ SystemdWrapper::Ptr const& systemd_wrapper,
276 UpstartWrapper::Ptr const& upstart_wrapper,
277 ShieldFactoryInterface::Ptr const& shield_factory)
278- : Controller(dbus_manager, session_manager, key_grabber, upstart_wrapper, shield_factory, /* test_mode */ true)
279+ : Controller(dbus_manager, session_manager, key_grabber, systemd_wrapper, upstart_wrapper, shield_factory, /* test_mode */ true)
280 {}
281
282 using Controller::shields_;
283@@ -112,6 +114,7 @@
284 session::MockManager::Ptr session_manager;
285 key::MockGrabber::Ptr key_grabber;
286 DBusManager::Ptr dbus_manager;
287+ unity::SystemdWrapper::Ptr systemd_wrapper;
288 unity::UpstartWrapper::Ptr upstart_wrapper;
289
290 ShieldFactoryMock::Ptr shield_factory;
291
292=== modified file 'tools/CMakeLists.txt'
293--- tools/CMakeLists.txt 2016-02-09 01:26:22 +0000
294+++ tools/CMakeLists.txt 2016-07-20 15:08:18 +0000
295@@ -6,3 +6,27 @@
296 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/unity.cmake ${CMAKE_BINARY_DIR}/bin/unity)
297 install(FILES ${CMAKE_BINARY_DIR}/bin/unity PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
298 GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION ${CMAKE_INSTALL_BINDIR})
299+
300+#
301+# unity-active-plugins-safety-check
302+#
303+pkg_check_modules(UAPSC_DEPS REQUIRED libcompizconfig)
304+
305+set(CFLAGS
306+ ${UAPSC_DEPS_CFLAGS}
307+ ${UAPSC_DEPS_CFLAGS_OTHER}
308+ )
309+
310+string (REPLACE ";" " " CFLAGS "${CFLAGS}")
311+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CFLAGS}")
312+
313+set(LIBS ${UAPSC_DEPS_LIBRARIES})
314+
315+set(LIB_PATHS ${UAPSC_DEPS_LIBRARY_DIRS})
316+link_directories(${LIB_PATHS})
317+
318+add_executable(unity-active-plugins-safety-check unity_active_plugins_safety_check.cpp)
319+target_link_libraries(unity-active-plugins-safety-check ${LIBS})
320+install(TARGETS unity-active-plugins-safety-check DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/)
321+
322+install(FILES unity-compiz-profile DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity/)
323
324=== added file 'tools/unity-compiz-profile'
325--- tools/unity-compiz-profile 1970-01-01 00:00:00 +0000
326+++ tools/unity-compiz-profile 2016-07-20 15:08:18 +0000
327@@ -0,0 +1,25 @@
328+#!/bin/bash
329+
330+set -e
331+
332+# If gnome-session is going to start compiz,
333+# we don't want to be the ones doing it.
334+
335+if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
336+ echo "GNOME Session is starting Compiz"
337+ stop ; exit 0
338+fi
339+
340+compiz_profile="ubuntu"
341+
342+if ! /usr/lib/nux/unity_support_test -p; then
343+ compiz_profile="ubuntu-lowgfx"
344+fi
345+
346+echo "Using compiz profile '$compiz_profile'"
347+
348+initctl set-env -g COMPIZ_CONFIG_PROFILE="$compiz_profile"
349+systemctl set-environment --user COMPIZ_CONFIG_PROFILE="$compiz_profile"
350+
351+export COMPIZ_CONFIG_PROFILE="$compiz_profile"
352+exec /usr/lib/unity/unity-active-plugins-safety-check
353
354=== added file 'tools/unity_active_plugins_safety_check.cpp'
355--- tools/unity_active_plugins_safety_check.cpp 1970-01-01 00:00:00 +0000
356+++ tools/unity_active_plugins_safety_check.cpp 2016-07-20 15:08:18 +0000
357@@ -0,0 +1,83 @@
358+/*
359+ * Copyright (C) 2016 Canonical Ltd
360+ *
361+ * This program is free software: you can redistribute it and/or modify
362+ * it under the terms of the GNU General Public License version 3 as
363+ * published by the Free Software Foundation.
364+ *
365+ * This program is distributed in the hope that it will be useful,
366+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
367+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
368+ * GNU General Public License for more details.
369+ *
370+ * You should have received a copy of the GNU General Public License
371+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
372+ *
373+ * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
374+ */
375+
376+#include <ccs.h>
377+#include <gio/gio.h>
378+
379+#include <iostream>
380+#include <string>
381+
382+extern const CCSInterfaceTable ccsDefaultInterfaceTable;
383+
384+void PluginSetActiveWithDeps(CCSContext* context, std::string const& plugin_name)
385+{
386+ if (plugin_name.empty())
387+ return;
388+
389+ auto plugin = ccsFindPlugin(context, plugin_name.c_str());
390+
391+ if (!plugin)
392+ return;
393+
394+ auto reqs = ccsPluginGetRequiresPlugins(plugin);
395+ for (auto req = reqs; req; req = req->next)
396+ {
397+ if (req->data && req->data->value)
398+ {
399+ std::string name = req->data->value;
400+ PluginSetActiveWithDeps(context, name.c_str());
401+ }
402+ }
403+
404+ if (!ccsPluginIsActive(context, plugin_name.c_str())) {
405+ std::cout << "Setting plugin '" << plugin_name << "' to active" << std::endl;
406+ ccsPluginSetActive(plugin, true);
407+ }
408+
409+ auto conflicts = ccsPluginGetConflictPlugins(plugin);
410+ for (auto con = conflicts; con; con = con->next)
411+ {
412+ if (con->data && con->data->value)
413+ {
414+ std::string name = con->data->value;
415+ auto plugin = ccsFindPlugin(context, name.c_str());
416+
417+ if (ccsPluginIsActive(context, name.c_str()))
418+ {
419+ std::cout << "Setting plugin '" << name << "' to non-active" << std::endl;
420+ ccsPluginSetActive(plugin, false);
421+ }
422+ }
423+ }
424+}
425+
426+int main()
427+{
428+ auto context = ccsContextNew (0, &ccsDefaultInterfaceTable);
429+
430+ if (!context)
431+ return -1;
432+
433+ PluginSetActiveWithDeps(context, "unityshell");
434+
435+ ccsWriteChangedSettings(context);
436+ g_settings_sync();
437+ ccsFreeContext(context);
438+
439+ return 0;
440+}
441
442=== modified file 'unity-shared/CMakeLists.txt'
443--- unity-shared/CMakeLists.txt 2016-02-25 15:59:41 +0000
444+++ unity-shared/CMakeLists.txt 2016-07-20 15:08:18 +0000
445@@ -59,6 +59,7 @@
446 SearchBarSpinner.cpp
447 SpreadFilter.cpp
448 StaticCairoText.cpp
449+ SystemdWrapper.cpp
450 TextureCache.cpp
451 TextInput.cpp
452 TextureThumbnailProvider.cpp
453
454=== added file 'unity-shared/SystemdWrapper.cpp'
455--- unity-shared/SystemdWrapper.cpp 1970-01-01 00:00:00 +0000
456+++ unity-shared/SystemdWrapper.cpp 2016-07-20 15:08:18 +0000
457@@ -0,0 +1,88 @@
458+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 3 -*-
459+/*
460+* Copyright © 2016 Canonical Ltd
461+*
462+* This program is free software: you can redistribute it and/or modify
463+* it under the terms of the GNU General Public License version 3 as
464+* published by the Free Software Foundation.
465+*
466+* This program is distributed in the hope that it will be useful,
467+* but WITHOUT ANY WARRANTY; without even the implied warranty of
468+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
469+* GNU General Public License for more details.
470+*
471+* You should have received a copy of the GNU General Public License
472+* along with this program. If not, see <http://www.gnu.org/licenses/>.
473+*
474+* Authored by: Ted Gould <ted@canonical.com>
475+*/
476+
477+#include "SystemdWrapper.h"
478+
479+#include <UnityCore/GLibDBusProxy.h>
480+
481+namespace unity
482+{
483+
484+//
485+// Start private implementation
486+//
487+
488+class SystemdWrapper::Impl
489+{
490+public:
491+ Impl();
492+
493+ void Start(std::string const& name);
494+ void Stop(std::string const& name);
495+
496+private:
497+ glib::DBusProxy::Ptr systemd_proxy_;
498+};
499+
500+SystemdWrapper::Impl::Impl()
501+{
502+ std::string busname = "org.freedesktop.systemd1";
503+ if (g_getenv("UNITY_TEST_SYSTEMD)")) {
504+ busname = "com.canonical.Unity.Test.Systemd";
505+ }
506+
507+ systemd_proxy_ = std::make_shared<unity::glib::DBusProxy>(busname, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager");
508+}
509+
510+void SystemdWrapper::Impl::Start(std::string const& name)
511+{
512+ systemd_proxy_->Call("StartUnit", g_variant_new("(ss)", name.c_str(), "replace"));
513+}
514+
515+void SystemdWrapper::Impl::Stop(std::string const& name)
516+{
517+ systemd_proxy_->Call("StopUnit", g_variant_new("(ss)", name.c_str(), "replace"));
518+}
519+
520+//
521+// End private implementation
522+//
523+
524+SystemdWrapper::SystemdWrapper()
525+ : pimpl_(new Impl)
526+{}
527+
528+SystemdWrapper::SystemdWrapper(SystemdWrapper::TestMode const& tm)
529+ : pimpl_(new Impl)
530+{}
531+
532+SystemdWrapper::~SystemdWrapper()
533+{}
534+
535+void SystemdWrapper::Start(std::string const& name)
536+{
537+ pimpl_->Start(name);
538+}
539+
540+void SystemdWrapper::Stop(std::string const& name)
541+{
542+ pimpl_->Stop(name);
543+}
544+
545+}
546
547=== added file 'unity-shared/SystemdWrapper.h'
548--- unity-shared/SystemdWrapper.h 1970-01-01 00:00:00 +0000
549+++ unity-shared/SystemdWrapper.h 2016-07-20 15:08:18 +0000
550@@ -0,0 +1,54 @@
551+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
552+/*
553+* Copyright © 2016 Canonical Ltd
554+*
555+* This program is free software: you can redistribute it and/or modify
556+* it under the terms of the GNU General Public License version 3 as
557+* published by the Free Software Foundation.
558+*
559+* This program is distributed in the hope that it will be useful,
560+* but WITHOUT ANY WARRANTY; without even the implied warranty of
561+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
562+* GNU General Public License for more details.
563+*
564+* You should have received a copy of the GNU General Public License
565+* along with this program. If not, see <http://www.gnu.org/licenses/>.
566+*
567+* Authored by: Ted Gould <ted@canonical.com>
568+*/
569+
570+#ifndef UNITY_SYSTEMD_WRAPPER
571+#define UNITY_SYSTEMD_WRAPPER
572+
573+#include <memory>
574+
575+namespace unity
576+{
577+
578+class SystemdWrapper
579+{
580+public:
581+ typedef std::shared_ptr<SystemdWrapper> Ptr;
582+
583+ SystemdWrapper();
584+ ~SystemdWrapper();
585+
586+ void Start(std::string const& name);
587+ void Stop(std::string const& name);
588+
589+protected:
590+ struct TestMode {};
591+ SystemdWrapper(TestMode const&);
592+
593+private:
594+ // Noncopyable
595+ SystemdWrapper(SystemdWrapper const&) = delete;
596+ SystemdWrapper& operator=(SystemdWrapper const&) = delete;
597+
598+ class Impl;
599+ std::unique_ptr<Impl> pimpl_;
600+};
601+
602+}
603+
604+#endif