From: yeji01.kim Date: Tue, 16 Jan 2018 10:44:01 +0000 (+0900) Subject: Apply the changes of ScopedGMainLoop X-Git-Tag: submit/tizen_4.0/20180119.042851^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c5a6376cd76d497485dbf0a0b05207d84681ce9c;p=platform%2Fcore%2Fsecurity%2Fdevice-policy-client.git Apply the changes of ScopedGMainLoop Change-Id: I4561998d82558dc858946a01209fb6891967f1e3 Signed-off-by: yeji01.kim Signed-off-by: sangwan.kwon --- diff --git a/libs/policy-client.cpp b/libs/policy-client.cpp index 7d39ec2..67f336c 100644 --- a/libs/policy-client.cpp +++ b/libs/policy-client.cpp @@ -54,16 +54,20 @@ int DevicePolicyClient::subscribeSignal(const std::string& name, if (!getMaintenanceMode()) return 0; + int ret = -1; try { - auto dispatch = [name, handler, data](dbus::Variant variant) { - char *state = NULL; - variant.get("(s)", &state); - - handler(name.c_str(), state, data); - }; - - dbus::signal::Receiver receiver(SIGNAL_OBJECT_PATH, SIGNAL_EVENT_INTERFACE); - return receiver.subscribe(name, dispatch); + mainloop->dispatch([&]() { + auto task = [name, handler, data](dbus::Variant variant) { + char *state = NULL; + variant.get("(s)", &state); + + handler(name.c_str(), state, data); + }; + + dbus::signal::Receiver receiver(SIGNAL_OBJECT_PATH, SIGNAL_EVENT_INTERFACE); + ret = receiver.subscribe(name, std::move(task)); + }); + return ret; } catch (runtime::Exception& e) { ERROR(e.what()); return -1; @@ -76,8 +80,11 @@ int DevicePolicyClient::unsubscribeSignal(int id) noexcept return 0; try { - dbus::signal::Receiver receiver(SIGNAL_OBJECT_PATH, SIGNAL_EVENT_INTERFACE); - receiver.unsubscribe(id); + mainloop->dispatch([&]() { + dbus::signal::Receiver receiver(SIGNAL_OBJECT_PATH, SIGNAL_EVENT_INTERFACE); + receiver.unsubscribe(id); + }); + return 0; } catch (runtime::Exception& e) { ERROR(e.what());