2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #ifndef CLIENT_SRC_SIGNAL_RECEIVER_H_
19 #define CLIENT_SRC_SIGNAL_RECEIVER_H_
21 #include "package-manager.h"
28 #include "PkgSignal.h"
34 namespace pkg_group = rpc_port::PkgSignal::group;
35 namespace pkg_signal = rpc_port::PkgSignal;
37 class SignalReceiver : public pkg_group::PkgSignal {
39 SignalReceiver(bool is_system);
40 virtual ~SignalReceiver();
42 void OnAsyncResult(std::string signal, int targetUid, std::string reqId,
43 std::vector<pkg_signal::PkgInfo> pkgs, std::string key,
44 std::string val) override;
46 void OnAsyncResultForResource(std::string signal, int targetUid,
47 std::string reqId, std::string pkgid, std::string status,
48 pkg_signal::ExtraData extra) override;
50 void OnAsyncResultForPkgUpgrade(std::string signal, int progress) override;
52 int AddEventHandler(std::string req_key, pkgmgr_handler event_cb, void* data);
53 int AddEventHandler(std::string req_key, pkgmgr_app_handler app_event_cb,
55 int AddEventHandler(std::string req_key,
56 pkgmgr_pkg_size_info_receive_cb event_cb, void* pc, void* data);
57 int AddEventHandler(std::string req_key, pkgmgr_res_handler event_cb,
59 int AddEventHandler(pkgmgr_pkg_upgrade_handler event_cb, void* data);
62 static int GetRequestId();
63 int AddEventHandler(std::string req_key, pkgmgr_handler event_cb,
64 pkgmgr_app_handler app_event_cb, void* data);
65 void HandleHandler(int targetUid, const std::string& reqId,
66 const std::vector<pkg_signal::PkgInfo>& pkgs, const std::string& key,
67 const std::string& val) const;
68 void HandleGlobalHandler(int targetUid, const std::string& reqId,
69 const std::vector<pkg_signal::PkgInfo>& pkgs, const std::string& key,
70 const std::string& val) const;
71 void HandleResHandler(const std::string& signal, int targetUid,
72 const std::string& reqId, const std::string& pkgid,
73 const std::string& status, pkg_signal::ExtraData& extra) const;
74 void HandleGlobalResHandler(const std::string& signal, int targetUid,
75 const std::string& reqId, const std::string& pkgid,
76 const std::string& status, pkg_signal::ExtraData& extra) const;
77 void HandleSizeInfoHandler(const std::string& reqId,
78 const std::vector<pkg_signal::PkgInfo>& pkgs,
79 const std::string& key, const std::string& val) const;
82 static inline int request_id_;
83 std::map<std::string, std::tuple<int, pkgmgr_handler, pkgmgr_app_handler,
85 std::list<std::tuple<int, pkgmgr_handler, pkgmgr_app_handler, void*>> global_handlers_;
87 std::tuple<int, pkgmgr_res_handler, void*>> res_handlers_;
88 std::list<std::tuple<int, pkgmgr_res_handler, void*>> global_res_handlers_;
90 std::tuple<int, pkgmgr_pkg_size_info_receive_cb, void*, void*>> size_info_handlers_;
91 std::list<std::tuple<int, pkgmgr_pkg_size_info_receive_cb, void*, void*>> global_size_info_handlers_;
92 std::list<std::tuple<int, pkgmgr_pkg_upgrade_handler, void*>> global_pkg_upgrade_handlers_;
98 #endif // CLIENT_SRC_CONNECTOR_H_