diff options
-rw-r--r-- | client/src/api_stub.cc | 16 | ||||
-rw-r--r-- | client/src/signal_receiver.cc | 11 | ||||
-rw-r--r-- | client/src/signal_receiver.hh | 1 |
3 files changed, 26 insertions, 2 deletions
diff --git a/client/src/api_stub.cc b/client/src/api_stub.cc index b60ae41..20dc44d 100644 --- a/client/src/api_stub.cc +++ b/client/src/api_stub.cc @@ -1215,8 +1215,20 @@ API int pkgmgr_client_listen_app_status(pkgmgr_client *pc, } API int pkgmgr_client_remove_listen_status(pkgmgr_client *pc) { - //TODO - return PKGMGR_R_OK; + if (pc == nullptr) { + _E("invalid parameter"); + return PKGMGR_R_EINVAL; + } + + auto* con = static_cast<Connector*>(pc); + try { + const auto& receiver = con->GetSignalReceiver(); + receiver->RemoveEventHandler(); + return PKGMGR_R_OK; + } catch (...) { + _E("Exception occured"); + return PKGMGR_R_ERROR; + } } API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type, diff --git a/client/src/signal_receiver.cc b/client/src/signal_receiver.cc index b4761f0..fc669e8 100644 --- a/client/src/signal_receiver.cc +++ b/client/src/signal_receiver.cc @@ -257,6 +257,17 @@ void SignalReceiver::SetStatusType(int status_type) { } +void SignalReceiver::RemoveEventHandler() { + handlers_.clear(); + global_handlers_.clear(); + res_handlers_.clear(); + global_res_handlers_.clear(); + size_info_handlers_.clear(); + global_size_info_handlers_.clear(); + global_pkg_upgrade_handlers_.clear(); +} + + int SignalReceiver::GetRequestId() { return ++request_id_; } diff --git a/client/src/signal_receiver.hh b/client/src/signal_receiver.hh index 18a4572..65db908 100644 --- a/client/src/signal_receiver.hh +++ b/client/src/signal_receiver.hh @@ -58,6 +58,7 @@ class SignalReceiver : public pkg_group::PkgSignal { void* data); int AddEventHandler(pkgmgr_pkg_upgrade_handler event_cb, void* data); void SetStatusType(int status_type); + void RemoveEventHandler(); private: static int GetRequestId(); |