1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_INTERFACE_UI_REPORT_STUB_H
17 #define FOUNDATION_ACE_INTERFACE_UI_REPORT_STUB_H
18 
19 #include <iremote_object.h>
20 #include <iremote_stub.h>
21 
22 #include "ui_content_service_interface.h"
23 
24 #include "base/utils/macros.h"
25 
26 namespace OHOS::Ace {
27 class ACE_FORCE_EXPORT UiReportStub : public IRemoteStub<ReportService> {
28 public:
29     virtual int32_t OnRemoteRequest(
30         uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
31 
32     /**
33      * @description: receive proxy side communication to execute click callback
34      */
35     void ReportClickEvent(const std::string& data) override;
36 
37     /**
38      * @description: receive proxy side communication to execute switch callback
39      */
40     void ReportRouterChangeEvent(const std::string& data) override;
41 
42     /**
43      * @description: receive proxy side communication to execute component callback
44      */
45     void ReportComponentChangeEvent(const std::string& data) override;
46 
47     /**
48      * @description: receive proxy side communication to execute search callback
49      */
50     void ReportSearchEvent(const std::string& data) override;
51 
52     /**
53      * @description: register a callback when click event occurs execute
54      * @param eventCallback callback to be performed
55      */
56     void RegisterClickEventCallback(const EventCallback& eventCallback);
57 
58     /**
59      * @description: register a callback when page switch event occurs execute
60      * @param eventCallback callback to be performed
61      */
62     void RegisterRouterChangeEventCallback(const EventCallback& eventCallback);
63 
64     /**
65      * @description: register a callback when search component do search occurs execute
66      * @param eventCallback callback to be performed
67      */
68     void RegisterSearchEventCallback(const EventCallback& eventCallback);
69 
70     /**
71      * @description: register a callback when specified component change occurs execute
72      * @param eventCallback callback to be performed
73      */
74     void RegisterComponentChangeEventCallback(const EventCallback& eventCallback);
75 
76     /**
77      * @description: register a callback when get inspector tree
78      * @param eventCallback callback to be performed
79      */
80     void RegisterGetInspectorTreeCallback(const std::function<void(std::string, int32_t, bool)>& eventCallback);
81 
82     /**
83      * @description: register a callback when get inspector tree
84      * @param eventCallback callback to be performed
85      */
86     void RegisterWebUnfocusEventCallback(
87         const std::function<void(int64_t accessibilityId, const std::string& data)>& eventCallback);
88 
89     /**
90      * @description: register a callback when get base info
91      * @param eventCallback callback to be performed
92      */
93     void RegisterGetBaseInfoCallback(const EventCallback& eventCallback);
94 
95     /**
96      * @description: unregister the click callback last register
97      */
98     void UnregisterClickEventCallback();
99 
100     /**
101      * @description: unregister the search callback last register
102      */
103     void UnregisterSearchEventCallback();
104 
105     /**
106      * @description: unregister the switch callback last register
107      */
108     void UnregisterRouterChangeEventCallback();
109 
110     /**
111      * @description: unregister the component callback last register
112      */
113     void UnregisterComponentChangeEventCallback();
114 
115     /**
116      * @description: report whole inspectorTree for SA
117      */
118     void ReportInspectorTreeValue(const std::string& data, int32_t partNum, bool isLastPart) override;
119 
120     /**
121      * @description: report web unfocus value for SA
122      */
123     void ReportWebUnfocusEvent(int64_t accessibilityId, const std::string& data) override;
124 
125     /**
126      * @description: report whole inspectorTree for SA
127      */
128     void SendBaseInfo(const std::string& data) override;
129 
130 private:
131     EventCallback clickEventCallback_;
132     EventCallback searchEventCallback_;
133     EventCallback RouterChangeEventCallback_;
134     EventCallback ComponentChangeEventCallback_;
135     EventCallback sendBaseInfoCallback_;
136     std::function<void(std::string, int32_t, bool)> inspectorTreeCallback_;
137     std::function<void(int64_t accessibilityId, const std::string& data)> unfocusEvent_;
138 };
139 } // namespace OHOS::Ace
140 #endif // FOUNDATION_ACE_INTERFACE_UI_REPORT_STUB_H
141