This commit is contained in:
parent
c6036e4d2d
commit
263d91efb5
12
README.md
12
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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user