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 CELLULAR_CALL_CONTROL_SATELLITE_H
17#define CELLULAR_CALL_CONTROL_SATELLITE_H
18
19#include "call_manager_inner_type.h"
20#include "cellular_call_connection_satellite.h"
21#include "control_base.h"
22#include "tel_ril_call_parcel.h"
23#include "satellite_call_types.h"
24
25namespace OHOS {
26namespace Telephony {
27using SatelliteConnectionMap = std::map<int32_t, CellularCallConnectionSatellite>;
28class SatelliteControl : public ControlBase {
29public:
30    /**
31     *  new SatelliteControl
32     *
33     */
34    SatelliteControl() = default;
35
36    /**
37     * ~SatelliteControl destructor
38     */
39    ~SatelliteControl();
40
41    /**
42     *  Dial Satellite
43     *
44     * @param CellularCallInfo
45     * @returns Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
46     */
47    int32_t Dial(const CellularCallInfo &callInfo, bool isEcc) override;
48
49    /**
50     * SatelliteControl HangUp
51     *
52     * release the active call
53     *
54     * @param CellularCallInfo
55     * @param CallSupplementType
56     * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
57     */
58    int32_t HangUp(const CellularCallInfo &callInfo, CallSupplementType type) override;
59
60    /**
61     * SatelliteControl Answer
62     *
63     * Answer an incoming voice call.
64     *
65     * @param CellularCallInfo
66     * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
67     */
68    int32_t Answer(const CellularCallInfo &callInfo) override;
69
70    /**
71     * SatelliteControl Reject
72     *
73     * Reject an incoming voice call
74     *
75     * @param CellularCallInfo
76     * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
77     */
78    int32_t Reject(const CellularCallInfo &callInfo) override;
79
80    /**
81     * SatelliteControl GetConnectionMap
82     *
83     * @return CsConnectionMap
84     */
85    SatelliteConnectionMap GetConnectionMap();
86
87    /**
88     * SatelliteControl ReleaseAllConnection
89     */
90    void ReleaseAllConnection();
91
92    /**
93     * SatelliteControl ReportSatelliteCallsData.
94     *
95     * @param slotId
96     * @param CallInfoList
97     * @returns Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
98     */
99    int32_t ReportSatelliteCallsData(int32_t slotId, const SatelliteCurrentCallList &callInfoList);
100
101    /**
102     * SatelliteControl ReportCallsData
103     *
104     * @returns Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
105     */
106    int32_t ReportCallsData(int32_t slotId, const CallInfoList &callInfoList) override;
107
108    int32_t ReportHangUp(const std::vector<CellularCallInfo> &infos, int32_t slotId);
109
110    /**
111     * HoldCall
112     *
113     * @param slotId
114     * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
115     */
116    int32_t HoldCall(int32_t slotId) override;
117
118    /**
119     * UnHoldCall
120     *
121     * @param slotId
122     * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
123     */
124    int32_t UnHoldCall(int32_t slotId) override;
125
126    /**
127     * SwitchCall
128     *
129     * @param slotId
130     * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
131     */
132    int32_t SwitchCall(int32_t slotId) override;
133
134    /**
135     * CombineConference
136     *
137     * 22084-400_2001 1.3.8.2	Managing an active multiParty call
138     * 3GPP TS 22.030
139     *
140     * Add another remote party
141     * @param slotId
142     * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
143     */
144    int32_t CombineConference(int32_t slotId) override;
145
146    /**
147     * HangUpAllConnection
148     *
149     * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
150     */
151    int32_t HangUpAllConnection(int32_t slotId) override;
152
153    int32_t ExecutePostDial(int32_t slotId, int64_t callId);
154
155    int32_t PostDialProceed(const CellularCallInfo &callInfo, const bool proceed);
156    /**
157     * Report being hung up data
158     *
159     * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
160     */
161    int32_t ReportHangUpInfo(int32_t slotId);
162
163private:
164    /**
165     * Report Incoming info
166     *
167     * @param SatelliteCurrentCallList
168     * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
169     */
170    int32_t ReportIncomingInfo(int32_t slotId, const SatelliteCurrentCallList &list);
171
172    /**
173     * Report update info
174     *
175     * @param SatelliteCurrentCallList
176     * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
177     */
178    int32_t ReportUpdateInfo(int32_t slotId, const SatelliteCurrentCallList &list);
179
180    /**
181     * Encapsulation CallReportInfo
182     *
183     * @param SatelliteCurrentCall
184     * @return CallReportInfo
185     */
186    CallReportInfo EncapsulationCallReportInfo(int32_t slotId, const SatelliteCurrentCall &callInfo);
187
188    /**
189     * DeleteConnection Connection send
190     *
191     * @param CallsReportInfo
192     * @param SatelliteCurrentCallList
193     */
194    void DeleteConnection(CallsReportInfo &callsResponseInfo, const SatelliteCurrentCallList &callInfoList);
195
196    /**
197     * Encapsulate Dial Common
198     *
199     * @param std::string phoneNum
200     * @param CLIRMode clirMode
201     * @returns Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
202     */
203    int32_t EncapsulateDialCommon(int32_t slotId, const std::string &phoneNum, CLIRMode &clirMode);
204
205private:
206    SatelliteConnectionMap connectionMap_; // save callConnection map
207    std::string pendingPhoneNumber_;
208    std::recursive_mutex connectionMapMutex_;
209};
210} // namespace Telephony
211} // namespace OHOS
212
213#endif // CELLULAR_CALL_CONTROL_SATELLITE_H
214