summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md12
-rw-r--r--src/slack-timedate.cpp21
-rw-r--r--src/slack-timedate.h1
3 files changed, 25 insertions, 9 deletions
diff --git a/README.md b/README.md
index 0749b7d..59165d4 100644
--- a/README.md
+++ b/README.md
@@ -39,8 +39,16 @@ to get the list of time zones:
```sh
dbus-send --system --print-reply --type=method_call \
--dest=org.freedesktop.timedate1 \
- /org/freedesktop/timedate1 \
- org.freedesktop.timedate1.ListTimezones
+ /org/freedesktop/timedate1 org.freedesktop.timedate1.ListTimezones
+```
+
+To get a value of a property:
+
+```sh
+dbus-send --system --print-reply \
+ --dest=org.freedesktop.timedate1 \
+ /org/freedesktop/timedate1 org.freedesktop.DBus.Properties.Get \
+ string:org.freedesktop.timedate1 string:NTP
```
## Dependencies
diff --git a/src/slack-timedate.cpp b/src/slack-timedate.cpp
index e800236..5752f79 100644
--- a/src/slack-timedate.cpp
+++ b/src/slack-timedate.cpp
@@ -85,11 +85,18 @@ static void slack_method_call (GDBusConnection *connection, const gchar *sender,
}
else if (g_strcmp0(method_name, "ListTimezones") == 0)
{
- auto return_tuple = Glib::Variant<std::vector<Glib::ustring>>::create_tuple({
- dlackware::timedate::list_timezones()
- });
-
- g_dbus_method_invocation_return_value(invocation, return_tuple.gobj());
+ try
+ {
+ auto return_tuple = Glib::Variant<std::vector<Glib::ustring>>::create_tuple({
+ dlackware::timedate::list_timezones()
+ });
+ g_dbus_method_invocation_return_value(invocation, return_tuple.gobj());
+ }
+ catch (const std::exception& exception)
+ {
+ g_dbus_method_invocation_return_error(invocation, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "List time zones: %s", exception.what());
+ }
}
}
@@ -170,8 +177,8 @@ namespace dlackware::timedate
{
void list_timezones(const std::string& prefix, std::vector<Glib::ustring>& accumulator)
{
- Glib::FileTest is_directory = Glib::FILE_TEST_IS_DIR;
- Glib::FileTest is_regular = Glib::FILE_TEST_IS_REGULAR;
+ constexpr Glib::FileTest is_directory = Glib::FILE_TEST_IS_DIR;
+ constexpr Glib::FileTest is_regular = Glib::FILE_TEST_IS_REGULAR;
auto zoneinfo_path = std::filesystem::path(zoneinfo_database) / prefix;
auto zoneinfo_directory = Glib::Dir(zoneinfo_path);
diff --git a/src/slack-timedate.h b/src/slack-timedate.h
index 61ee8d5..f833387 100644
--- a/src/slack-timedate.h
+++ b/src/slack-timedate.h
@@ -63,6 +63,7 @@ namespace dlackware::timedate
{
constexpr const char *zoneinfo_database = "/usr/share/zoneinfo";
+ void list_timezones(const std::string& prefix, std::vector<Glib::ustring>& accumulator);
Glib::Variant<std::vector<Glib::ustring>> list_timezones();
}