summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2024-06-18 11:19:44 +0200
committerEugen Wissner <belka@caraus.de>2024-06-18 11:19:44 +0200
commit9dc8fb26405938834b13971c3188f4f52bb8b90d (patch)
tree72f770ee2c49d4f6ef9e90341d0c1bd6414fc942 /src
parent7b5fe4b9d1edf5d3eecc71bb0bf50ac0f4487f7e (diff)
downloadslack-timedate-9dc8fb26405938834b13971c3188f4f52bb8b90d.tar.gz
Generate path configuration file
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/main.cpp3
-rw-r--r--src/timedate.cpp11
-rw-r--r--src/timedate.h10
4 files changed, 13 insertions, 13 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c626a41..81bf237 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -4,7 +4,7 @@ pkg_check_modules(GDBUS REQUIRED gio-2.0 dbus-1 glibmm-2.4 giomm-2.4)
add_executable(slack-timedate main.cpp
timedate.cpp timedate.h
)
-target_include_directories(slack-timedate PRIVATE ${GDBUS_INCLUDE_DIRS})
+target_include_directories(slack-timedate PRIVATE ${CMAKE_BINARY_DIR}/data ${GDBUS_INCLUDE_DIRS})
target_link_libraries(slack-timedate ${GDBUS_LIBRARIES})
install(TARGETS slack-timedate DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
diff --git a/src/main.cpp b/src/main.cpp
index bd6c0c0..f57f020 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -30,7 +30,8 @@ int main(int argc, char **argv)
Gio::init();
auto timedate1 = std::make_unique<dlackware::timedate::timedate1>();
- guint owner_id = Gio::DBus::own_name(Gio::DBus::BUS_TYPE_SYSTEM, BUS_NAME,
+ guint owner_id = Gio::DBus::own_name(Gio::DBus::BUS_TYPE_SYSTEM,
+ Glib::ustring(dlackware::timedate::bus_name.cbegin(), dlackware::timedate::bus_name.cend()),
std::bind(&dlackware::timedate::timedate1::on_bus_acquired, timedate1.get(),
std::placeholders::_1, std::placeholders::_2),
Gio::DBus::SlotNameAcquired(),
diff --git a/src/timedate.cpp b/src/timedate.cpp
index a320384..b06cbcc 100644
--- a/src/timedate.cpp
+++ b/src/timedate.cpp
@@ -120,6 +120,9 @@ static void slack_get_property(Glib::VariantBase& result, const Glib::RefPtr<Gio
namespace dlackware::timedate
{
+ constexpr const std::int32_t usec_per_sec = 1000000ULL;
+ constexpr const std::int32_t nsec_per_usec = 1000ULL;
+
timedate1::timedate1()
: interface_vtable{ &slack_method_call, &slack_get_property }
{
@@ -134,11 +137,11 @@ namespace dlackware::timedate
void timedate1::on_bus_acquired(const Glib::RefPtr<Gio::DBus::Connection>& connection, const Glib::ustring& name)
{
Glib::RefPtr<Gio::DBus::NodeInfo> introspection_data;
-
try
{
- auto introspection_xml = Glib::file_get_contents(dlackware::timedate::introspection_xml);
-
+ auto introspection_xml = Glib::file_get_contents(
+ (std::filesystem::path(DATADIR_INTERFACES) / dlackware::timedate::bus_name).concat(".xml")
+ );
introspection_data = Gio::DBus::NodeInfo::create_for_xml(introspection_xml);
}
catch (Glib::Error& slack_err)
@@ -194,7 +197,7 @@ namespace dlackware::timedate
{
return nullptr;
}
- return Glib::ustring{ zone_copied_from.get() + strlen(zoneinfo_database) + 1 };
+ return Glib::ustring{ zone_copied_from.get() + zoneinfo_database.size() + 1 };
}
void set_timezone(const Glib::ustring& zone, bool)
diff --git a/src/timedate.h b/src/timedate.h
index 82336de..49883f9 100644
--- a/src/timedate.h
+++ b/src/timedate.h
@@ -20,17 +20,13 @@
#include <dbus/dbus.h>
#include <glibmm.h>
#include <giomm.h>
-
-#define BUS_NAME "org.freedesktop.timedate1"
+#include "resources.h"
namespace dlackware::timedate
{
constexpr const char *bus_path = "/org/freedesktop/timedate1";
- constexpr const char *zoneinfo_database = "/usr/share/zoneinfo";
- constexpr const char *introspection_xml = "/usr/share/dbus-1/interfaces/org.freedesktop.timedate1.xml";
-
- constexpr const gint32 usec_per_sec = 1000000ULL;
- constexpr const gint32 nsec_per_usec = 1000ULL;
+ constexpr const std::string_view bus_name = "org.freedesktop.timedate1";
+ constexpr const std::string_view zoneinfo_database = "/usr/share/zoneinfo";
// Returns the system time zone.
Glib::ustring timezone();