1/*
2 * Copyright (C) 2023 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 VOIP_CALL_MANAGER_PROXY_H
17#define VOIP_CALL_MANAGER_PROXY_H
18
19#include <cfloat>
20#include <cstdio>
21#include <string>
22#include <vector>
23
24#include "i_voip_call_manager_service.h"
25#include "iremote_broker.h"
26#include "iremote_proxy.h"
27#include "pac_map.h"
28
29namespace OHOS {
30namespace Telephony {
31class VoipCallManagerProxy : public IRemoteProxy<IVoipCallManagerService> {
32public:
33    /**
34     * VoipCallManagerProxy
35     *
36     * @param impl
37     */
38    explicit VoipCallManagerProxy(const sptr<IRemoteObject> &impl);
39    virtual ~VoipCallManagerProxy() = default;
40
41    /**
42     * @brief thrid-party applications report a incoming call.
43     *
44     * @param extras[in], extras date.
45     * @return Returns 0 on success, others on failure.
46     */
47    int32_t ReportIncomingCall(
48        AppExecFwk::PacMap &extras, std::vector<uint8_t> &userProfile, ErrorReason &reason) override;
49    /**
50     * @brief thrid-party applications report incoming call failed causes.
51     *
52     * @param extras[in], extras date.
53     * @return Returns 0 on success, others on failure.
54     */
55    int32_t ReportIncomingCallError(AppExecFwk::PacMap &extras) override;
56    /**
57     * @brief thrid-party applications report call state change.
58     *
59     * @param callId[in], The call id
60     * @param VoipCallState[in], The voip call state
61     * @param VoipCallType[in], The voip call type
62     * @return Returns 0 on success, others on failure.
63     */
64    int32_t ReportCallStateChange(std::string callId, const VoipCallState &state, const VoipCallType &type) override;
65    /**
66     * @brief thrid-party applications report a outgoing call.
67     *
68     * @param extras[in], extras date.
69     * @return Returns 0 on success, others on failure.
70     */
71    int32_t ReportOutgoingCall(
72        AppExecFwk::PacMap &extras, std::vector<uint8_t> &userProfile, ErrorReason &reason) override;
73
74    /**
75     * RegisterCallBack
76     *
77     * @brief Register callback
78     * @param callback[in], callback function pointer
79     * @return Returns 0 on success, others on failure.
80     */
81    int32_t RegisterCallBack(const sptr<IVoipCallManagerCallback> &callback) override;
82    /**
83     * UnRegisterCallBack
84     *
85     * @brief unregister callback
86     * @return Returns 0 on success, others on failure.
87     */
88    int32_t UnRegisterCallBack() override;
89
90    /**
91     * @brief pushSA report a incoming call.
92     *
93     * @param callId[in], The call id
94     * @param bundleName[in], The bundleName
95     * @param processMode[in], The processMode
96     * @param uid[in], The uid
97     * @return Returns 0 on success, others on failure.
98     */
99    int32_t ReportVoipIncomingCall(
100        std::string callId, std::string bundleName, std::string processMode, int32_t uid) override;
101    /**
102     * @brief pushSA report call extensionId.
103     *
104     * @param callId[in], The call id
105     * @param bundleName[in], The bundleName
106     * @param extensionId[in], The extensionId
107     * @param uid[in], The uid
108     * @return Returns 0 on success, others on failure.
109     */
110    int32_t ReportVoipCallExtensionId(
111        std::string callId, std::string bundleName, std::string extensionId, int32_t uid) override;
112
113    /**
114     * @brief hang up a call
115     *
116     * @param events[in], The VoipCallEventInfo
117     * @return Returns TELEPHONY_SUCCESS on success, others on failure.
118     */
119    int32_t HangUp(const VoipCallEventInfo &events) override;
120
121    /**
122     * @brief reject a call
123     *
124     * @param events[in], The VoipCallEventInfo
125     * @return Returns TELEPHONY_SUCCESS on success, others on failure.
126     */
127    int32_t Reject(const VoipCallEventInfo &events) override;
128
129    /**
130     * @brief answer a call
131     *
132     * @param events[in], The VoipCallEventInfo
133     * @param videoState[in], The videoState
134     * @return Returns TELEPHONY_SUCCESS on success, others on failure.
135     */
136    int32_t Answer(const VoipCallEventInfo &events, int32_t videoState) override;
137
138    /**
139     * @brief Unload voip SA
140     *
141     * @return Returns TELEPHONY_SUCCESS on success, others on failure.
142     */
143    int32_t UnloadVoipSa() override;
144
145    /**
146     * @brief Register CallManager CallBack ptr
147     *
148     * @param callback callback ptr
149     * @return Returns TELEPHONY_SUCCESS on success, others on failure.
150     */
151    int32_t RegisterCallManagerCallBack(const sptr<ICallStatusCallback> &callback) override;
152    /**
153     * @brief UnRegister CallManager CallBack ptr
154     *
155     * @return Returns TELEPHONY_SUCCESS on success, others on failure.
156     */
157    int32_t UnRegisterCallManagerCallBack() override;
158
159    /**
160     * @brief Send Call ui event
161     *
162     * @param voipCallId[in], The VoipCallId
163     * @param callAudioEvent[in], The call audio event
164     * @return Returns TELEPHONY_SUCCESS on success, others on failure.
165     */
166    int32_t SendCallUiEvent(std::string voipCallId, const CallAudioEvent &callAudioEvent) override;
167
168    /**
169     * @brief thrid-party applications report call audio event change
170     *
171     * @param voipCallId[in], The VoipCallId
172     * @param callAudioEvent[in], The call audio event
173     * @return Returns TELEPHONY_SUCCESS on success, others on failure.
174     */
175    int32_t ReportCallAudioEventChange(std::string voipCallId, const CallAudioEvent &callAudioEvent) override;
176
177private:
178    static inline BrokerDelegator<VoipCallManagerProxy> delegator_;
179};
180
181} // namespace Telephony
182} // namespace OHOS
183
184#endif
185