wivrnctl: disable enroll when duration is 0

This commit is contained in:
Patrick Nicolas
2024-11-26 23:59:35 +01:00
parent 4972810880
commit 15068a57dc
+18 -9
View File
@@ -72,17 +72,26 @@ void stop_server()
void enroll(int duration)
{
auto pin_msg = call_method(get_user_bus(),
"EnrollHeadset",
"i",
duration * 60);
if (duration == 0)
{
call_method(get_user_bus(),
"DisableEnrollHeadset",
"");
}
else
{
auto pin_msg = call_method(get_user_bus(),
"EnrollHeadset",
"i",
duration * 60);
const char * pin;
int ret = sd_bus_message_read(pin_msg.get(), "s", &pin);
if (ret < 0)
throw std::system_error(-ret, std::system_category(), "Failed to read PIN");
const char * pin;
int ret = sd_bus_message_read(pin_msg.get(), "s", &pin);
if (ret < 0)
throw std::system_error(-ret, std::system_category(), "Failed to read PIN");
std::cout << "PIN: " << pin << std::endl;
std::cout << "PIN: " << pin << std::endl;
}
}
int main(int argc, char ** argv)