diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-05-24 23:01:16 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-05-24 23:01:16 +0200 |
| commit | ed136d3b9a70370700595005f12794eff20bbaae (patch) | |
| tree | 1ab74aa2c96e38372de62746e5982ebc0f072939 /src | |
| parent | 0eccfe3ef3ca602212667f339440d77c13d757b1 (diff) | |
| download | slack-timedate-ed136d3b9a70370700595005f12794eff20bbaae.tar.gz | |
Add a stub method to query the time zones
Diffstat (limited to 'src')
| -rw-r--r-- | src/slack-timedate.cpp | 42 | ||||
| -rw-r--r-- | src/slack-timedate.h | 3 |
2 files changed, 34 insertions, 11 deletions
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<std::vector<Glib::ustring>>::create({}); + auto return_tuple = Glib::Variant<std::vector<Glib::ustring>>::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) { diff --git a/src/slack-timedate.h b/src/slack-timedate.h index 7154336..72fcc2d 100644 --- a/src/slack-timedate.h +++ b/src/slack-timedate.h @@ -48,6 +48,9 @@ " <arg name=\"use_ntp\" type=\"b\" direction=\"in\"/>\n" \ " <arg name=\"user_interaction\" type=\"b\" direction=\"in\"/>\n" \ " </method>\n" \ + " <method name=\"ListTimezones\">\n" \ + " <arg name=\"timezones\" type=\"as\" direction=\"out\"/>\n" \ + " </method>" \ " </interface>\n" \ "</node>\n" |
