summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2021-02-02 23:04:25 +0100
committerJoel Klinghed <the_jk@spawned.biz>2021-02-02 23:05:21 +0100
commit44c3db01709da5a5fa5fff663ee46a4e820bda5d (patch)
tree8d0527bb2e6fde658c6aafea87fceeaec64c30e5
parent7b133253b380321e6435c4dd4125769ca4d7d9d2 (diff)
Be explicit in types used in dbus
Cast to uint32_t for total and int64_t for epoch to be libc++ and environment agnostic.
-rw-r--r--src/timer_state.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/timer_state.cc b/src/timer_state.cc
index b7b4309..7700f80 100644
--- a/src/timer_state.cc
+++ b/src/timer_state.cc
@@ -81,7 +81,7 @@ public:
try {
proxy_ = sdbus::createProxy(*conn_.get(), kServiceName, kObjectPath);
proxy_->uponSignal("started").onInterface(kInterfaceName)
- .call([this](uint32_t total, time_t epoch){
+ .call([this](uint32_t total, int64_t epoch){
signal_started(std::chrono::minutes(total),
std::chrono::system_clock::from_time_t(epoch));
});
@@ -139,7 +139,7 @@ private:
auto reply = proxy_->callMethod(std::move(method));
bool active;
uint32_t total;
- time_t epoch;
+ int64_t epoch;
reply >> active;
reply >> total;
reply >> epoch;
@@ -169,7 +169,8 @@ public:
try {
object_->emitSignal("started").onInterface(kInterfaceName).withArguments(
- total_.count(), std::chrono::system_clock::to_time_t(start_));
+ static_cast<uint32_t>(total_.count()),
+ static_cast<int64_t>(std::chrono::system_clock::to_time_t(start_)));
} catch (sdbus::Error const& err) {
std::cerr << "Failed to emit started: " << err.what() << std::endl;
}
@@ -186,7 +187,7 @@ public:
try {
object_->emitSignal("stopped").onInterface(kInterfaceName).withArguments(
- total_.count());
+ static_cast<uint32_t>(total_.count()));
} catch (sdbus::Error const& err) {
std::cerr << "Failed to emit started: " << err.what() << std::endl;
}
@@ -225,7 +226,7 @@ public:
std::bind(&TimerStateServer::get_state, this, std::placeholders::_1);
object->registerMethod(kInterfaceName, "get_state", "", "bux", call_fun);
object->registerSignal("started").onInterface(kInterfaceName)
- .withParameters<uint32_t, time_t>();
+ .withParameters<uint32_t, int64_t>();
object->registerSignal("stopped").onInterface(kInterfaceName)
.withParameters<uint32_t>();
object->registerSignal("reset").onInterface(kInterfaceName);
@@ -253,9 +254,10 @@ private:
reply << active_;
reply << static_cast<uint32_t>(total_.count());
if (active_) {
- reply << std::chrono::system_clock::to_time_t(start_);
+ reply << static_cast<int64_t>(
+ std::chrono::system_clock::to_time_t(start_));
} else {
- reply << static_cast<time_t>(0);
+ reply << static_cast<int64_t>(0);
}
reply.send();
} catch (sdbus::Error const& err) {