summaryrefslogtreecommitdiff
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2016-09-01 18:48:38 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2016-09-01 18:48:38 +0200
commitb750d34382895ed7effdcf07bc0056e4c5b7b20e (patch)
tree3418155dd7040eb9e0743f61e214f321a7641fd3
parent8cc48988d29e18b5e68c4378a292cf7087014307 (diff)
{Upstart,Systemd}Wrapper: use ligther proxies
(bzr r4153.9.44)
-rw-r--r--tests/test_systemd_wrapper.cpp1
-rw-r--r--unity-shared/SystemdWrapper.cpp24
-rw-r--r--unity-shared/SystemdWrapper.h1
-rw-r--r--unity-shared/UpstartWrapper.cpp9
4 files changed, 14 insertions, 21 deletions
diff --git a/tests/test_systemd_wrapper.cpp b/tests/test_systemd_wrapper.cpp
index f5feff1bd..30d5f9f76 100644
--- a/tests/test_systemd_wrapper.cpp
+++ b/tests/test_systemd_wrapper.cpp
@@ -60,7 +60,6 @@ struct TestSystemdWrapper : public Test
systemd_server_->AddObjects(SYSTEMD, "/org/freedesktop/systemd1");
Utils::WaitUntilMSec([this] { return systemd_server_->IsConnected(); });
- Utils::WaitUntilMSec([this] { return systemd_wrapper_.IsConnected(); });
}
unity::glib::DBusServer::Ptr systemd_server_;
diff --git a/unity-shared/SystemdWrapper.cpp b/unity-shared/SystemdWrapper.cpp
index 269e96016..65f33de8f 100644
--- a/unity-shared/SystemdWrapper.cpp
+++ b/unity-shared/SystemdWrapper.cpp
@@ -1,4 +1,4 @@
-// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 3 -*-
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
* Copyright © 2016 Canonical Ltd
*
@@ -44,24 +44,21 @@ private:
SystemdWrapper::Impl::Impl(bool test)
{
auto const& busname = test ? "com.canonical.Unity.Test.Systemd" : "org.freedesktop.systemd1";
- systemd_proxy_ = std::make_shared<unity::glib::DBusProxy>(busname, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager");
+ auto flags = static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS);
+ systemd_proxy_ = std::make_shared<unity::glib::DBusProxy>(busname, "/org/freedesktop/systemd1",
+ "org.freedesktop.systemd1.Manager",
+ G_BUS_TYPE_SESSION, flags);
}
void SystemdWrapper::Impl::Start(std::string const& name)
{
- if (IsConnected())
- systemd_proxy_->Call("StartUnit", g_variant_new("(ss)", name.c_str(), "replace"));
+ systemd_proxy_->Call("StartUnit", g_variant_new("(ss)", name.c_str(), "replace"));
}
void SystemdWrapper::Impl::Stop(std::string const& name)
{
- if (IsConnected())
- systemd_proxy_->Call("StopUnit", g_variant_new("(ss)", name.c_str(), "replace"));
-}
-
-bool SystemdWrapper::Impl::IsConnected()
-{
- return systemd_proxy_->IsConnected();
+ systemd_proxy_->Call("StopUnit", g_variant_new("(ss)", name.c_str(), "replace"));
}
//
@@ -89,9 +86,4 @@ void SystemdWrapper::Stop(std::string const& name)
pimpl_->Stop(name);
}
-bool SystemdWrapper::IsConnected()
-{
- return pimpl_->IsConnected();
-}
-
}
diff --git a/unity-shared/SystemdWrapper.h b/unity-shared/SystemdWrapper.h
index ddfb4a25e..0bd4ba0e7 100644
--- a/unity-shared/SystemdWrapper.h
+++ b/unity-shared/SystemdWrapper.h
@@ -35,7 +35,6 @@ public:
void Start(std::string const& name);
void Stop(std::string const& name);
- bool IsConnected();
protected:
struct TestMode {};
diff --git a/unity-shared/UpstartWrapper.cpp b/unity-shared/UpstartWrapper.cpp
index d9493ced2..daf49e7dc 100644
--- a/unity-shared/UpstartWrapper.cpp
+++ b/unity-shared/UpstartWrapper.cpp
@@ -42,14 +42,17 @@ private:
UpstartWrapper::Impl::Impl(bool test_mode)
{
+ auto flags = static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS);
+
upstart_proxy_ = std::make_shared<unity::glib::DBusProxy>(test_mode ? "com.canonical.Unity.Test.Upstart" : DBUS_SERVICE_UPSTART,
- DBUS_PATH_UPSTART, DBUS_INTERFACE_UPSTART);
+ DBUS_PATH_UPSTART, DBUS_INTERFACE_UPSTART,
+ G_BUS_TYPE_SESSION, flags);
}
void UpstartWrapper::Impl::Emit(std::string const& name)
{
- if (upstart_proxy_->IsConnected())
- upstart_proxy_->Call("EmitEvent", g_variant_new("(sasb)", name.c_str(), nullptr, 0));
+ upstart_proxy_->Call("EmitEvent", g_variant_new("(sasb)", name.c_str(), nullptr, 0));
}
//