From ed136d3b9a70370700595005f12794eff20bbaae Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 24 May 2024 23:01:16 +0200 Subject: Add a stub method to query the time zones --- src/slack-timedate.cpp | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'src/slack-timedate.cpp') diff --git a/src/slack-timedate.cpp b/src/slack-timedate.cpp index 3f8b2d8..cc48ce8 100644 --- a/src/slack-timedate.cpp +++ b/src/slack-timedate.cpp @@ -33,18 +33,25 @@ static void slack_method_call (GDBusConnection *connection, const gchar *sender, gint64 usec_utc; // Set time zone - if (g_strcmp0 (method_name, "SetTimezone") == 0) { + if (g_strcmp0(method_name, "SetTimezone") == 0) + { g_variant_get (parameters, "(&sb)", &timezone, &user_interaction); - if (slack_set_timezone (timezone)) g_dbus_method_invocation_return_value (invocation, - NULL); - else g_dbus_method_invocation_return_error (invocation, + if (slack_set_timezone(timezone)) + { + g_dbus_method_invocation_return_value (invocation, NULL); + } + else + { + g_dbus_method_invocation_return_error (invocation, G_IO_ERROR, G_IO_ERROR_FAILED, "Write operation failed"); - + } g_free (timezone); - } else if (g_strcmp0 (method_name, "SetTime") == 0) { + } + else if (g_strcmp0(method_name, "SetTime") == 0) + { g_variant_get (parameters, "(xbb)", &usec_utc, &relative, &user_interaction); // Set time @@ -58,18 +65,31 @@ static void slack_method_call (GDBusConnection *connection, const gchar *sender, g_dbus_method_invocation_return_error(invocation, G_IO_ERROR, G_IO_ERROR_FAILED, "Failed to set system clock"); } - } else if (g_strcmp0 (method_name, "SetNTP") == 0) { + } + else if (g_strcmp0(method_name, "SetNTP") == 0) + { g_variant_get (parameters, "(bb)", &use_ntp, &user_interaction); // Enable NTP - if (slack_set_ntp (use_ntp)) g_dbus_method_invocation_return_value (invocation, - NULL); - else g_dbus_method_invocation_return_error (invocation, + if (slack_set_ntp (use_ntp)) + { + g_dbus_method_invocation_return_value (invocation, NULL); + } + else + { + g_dbus_method_invocation_return_error (invocation, G_IO_ERROR, G_IO_ERROR_FAILED, "Error enabling NTP"); + } } - return; + else if (g_strcmp0(method_name, "ListTimezones") == 0) + { + auto return_value = Glib::Variant>::create({}); + auto return_tuple = Glib::Variant>::create_tuple({ return_value }); + + g_dbus_method_invocation_return_value(invocation, return_tuple.gobj()); + } } static GVariant *slack_get_property (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *prop_name, GError **slack_err, gpointer user_data) { -- cgit v1.2.3