aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/datetime/dbus-shared.h14
-rw-r--r--src/exporter.cpp8
-rw-r--r--src/snap.cpp25
-rw-r--r--tests/test-exporter.cpp6
4 files changed, 32 insertions, 21 deletions
diff --git a/include/datetime/dbus-shared.h b/include/datetime/dbus-shared.h
index c5ff6ab..4b71ce5 100644
--- a/include/datetime/dbus-shared.h
+++ b/include/datetime/dbus-shared.h
@@ -18,8 +18,18 @@
* Charles Kerr <charles.kerr@canonical.com>
*/
+#ifndef _DBUS_SHARED_H_
+#define _DBUS_SHARED_H_
-#define BUS_NAME "com.canonical.indicator.datetime"
+#define BUS_DATETIME_NAME "com.canonical.indicator.datetime"
+#define BUS_DATETIME_PATH "/com/canonical/indicator/datetime"
-#define BUS_PATH "/com/canonical/indicator/datetime"
+#define BUS_SCREEN_NAME "com.canonical.Unity.Screen"
+#define BUS_SCREEN_PATH "/com/canonical/Unity/Screen"
+#define BUS_SCREEN_INTERFACE "com.canonical.Unity.Screen"
+#define BUS_POWERD_NAME "com.canonical.powerd"
+#define BUS_POWERD_PATH "/com/canonical/powerd"
+#define BUS_POWERD_INTERFACE "com.canonical.powerd"
+
+#endif /* _DBUS_SHARED_H_ */
diff --git a/src/exporter.cpp b/src/exporter.cpp
index e2b60f2..88aee2f 100644
--- a/src/exporter.cpp
+++ b/src/exporter.cpp
@@ -72,7 +72,7 @@ public:
m_actions = actions;
m_menus = menus;
m_own_id = g_bus_own_name(G_BUS_TYPE_SESSION,
- BUS_NAME,
+ BUS_DATETIME_NAME,
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT,
on_bus_acquired,
nullptr,
@@ -166,12 +166,12 @@ private:
GError * error = nullptr;
g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(m_alarm_props),
m_bus,
- BUS_PATH"/AlarmProperties",
+ BUS_DATETIME_PATH"/AlarmProperties",
&error);
// export the actions
const auto id = g_dbus_connection_export_action_group(m_bus,
- BUS_PATH,
+ BUS_DATETIME_PATH,
m_actions->action_group(),
&error);
if (id)
@@ -187,7 +187,7 @@ private:
// export the menus
for(auto& menu : m_menus)
{
- const auto path = std::string(BUS_PATH) + "/" + menu->name();
+ const auto path = std::string(BUS_DATETIME_PATH) + "/" + menu->name();
const auto id = g_dbus_connection_export_menu_model(m_bus, path.c_str(), menu->menu_model(), &error);
if (id)
{
diff --git a/src/snap.cpp b/src/snap.cpp
index 5971c68..566dfae 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -18,6 +18,7 @@
*/
#include <datetime/appointment.h>
+#include <datetime/dbus-shared.h>
#include <datetime/formatter.h>
#include <datetime/snap.h>
@@ -403,9 +404,9 @@ private:
// ask powerd to keep the system awake
static constexpr int32_t POWERD_SYS_STATE_ACTIVE = 1;
g_dbus_connection_call (system_bus,
- "com.canonical.powerd",
- "/com/canonical/powerd",
- "com.canonical.powerd",
+ BUS_POWERD_NAME,
+ BUS_POWERD_PATH,
+ BUS_POWERD_INTERFACE,
"requestSysState",
g_variant_new("(si)", APP_NAME, POWERD_SYS_STATE_ACTIVE),
G_VARIANT_TYPE("(s)"),
@@ -417,9 +418,9 @@ private:
// ask unity-system-compositor to turn on the screen
g_dbus_connection_call (system_bus,
- "com.canonical.Unity.Screen",
- "/com/canonical/Unity/Screen",
- "com.canonical.Unity.Screen",
+ BUS_SCREEN_NAME,
+ BUS_SCREEN_PATH,
+ BUS_SCREEN_INTERFACE,
"keepDisplayOn",
nullptr,
G_VARIANT_TYPE("(i)"),
@@ -496,9 +497,9 @@ private:
if (m_awake_cookie != nullptr)
{
g_dbus_connection_call (m_system_bus,
- "com.canonical.powerd",
- "/com/canonical/powerd",
- "com.canonical.powerd",
+ BUS_POWERD_NAME,
+ BUS_POWERD_PATH,
+ BUS_POWERD_INTERFACE,
"clearSysState",
g_variant_new("(s)", m_awake_cookie),
nullptr,
@@ -519,9 +520,9 @@ private:
if (m_screen_cookie != NO_SCREEN_COOKIE)
{
g_dbus_connection_call (m_system_bus,
- "com.canonical.Unity.Screen",
- "/com/canonical/Unity/Screen",
- "com.canonical.Unity.Screen",
+ BUS_SCREEN_NAME,
+ BUS_SCREEN_PATH,
+ BUS_SCREEN_INTERFACE,
"removeDisplayOnRequest",
g_variant_new("(i)", m_screen_cookie),
nullptr,
diff --git a/tests/test-exporter.cpp b/tests/test-exporter.cpp
index e947740..2e3411a 100644
--- a/tests/test-exporter.cpp
+++ b/tests/test-exporter.cpp
@@ -90,7 +90,7 @@ TEST_F(ExporterFixture, Publish)
wait_msec();
auto connection = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, nullptr);
- auto exported = g_dbus_action_group_get (connection, BUS_NAME, BUS_PATH);
+ auto exported = g_dbus_action_group_get (connection, BUS_DATETIME_NAME, BUS_DATETIME_PATH);
auto names_strv = g_action_group_list_actions(G_ACTION_GROUP(exported));
// wait for the exported ActionGroup to be populated
@@ -171,8 +171,8 @@ TEST_F(ExporterFixture, AlarmProperties)
DatetimeAlarmProperties* proxy = nullptr;
datetime_alarm_properties_proxy_new_for_bus(G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
- BUS_NAME,
- BUS_PATH"/AlarmProperties",
+ BUS_DATETIME_NAME,
+ BUS_DATETIME_PATH"/AlarmProperties",
nullptr,
on_proxy_ready,
&proxy);