1 /*
2  * Copyright (C) 2021 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_CONNECTION_IMS_H
17 #define CELLULAR_CALL_CONNECTION_IMS_H
18 
19 #include "base_connection.h"
20 #include "module_service_utils.h"
21 #include "ims_call_interface.h"
22 
23 namespace OHOS {
24 namespace Telephony {
25 class CellularCallConnectionIMS : public BaseConnection {
26 public:
27     /**
28      * Constructor
29      */
30     CellularCallConnectionIMS() = default;
31 
32     /**
33      * Destructor
34      */
35     ~CellularCallConnectionIMS() = default;
36 
37     /**
38      * Dial Request
39      *
40      * @param slotId
41      * @param ImsDialInfoStruct
42      * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
43      */
44     int32_t DialRequest(int32_t slotId, const ImsDialInfoStruct &dialRequest);
45 
46     /**
47      * HangUp Request
48      *
49      * @param slotId
50      * @param phoneNum
51      * @param index
52      * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
53      */
54     int32_t HangUpRequest(int32_t slotId, const std::string &phoneNum, int32_t index);
55 
56     /**
57      * Answer Request
58      *
59      * @param slotId
60      * @param phoneNum
61      * @param videoState
62      * @param index
63      * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
64      */
65     int32_t AnswerRequest(int32_t slotId, const std::string &phoneNum, int32_t videoState, int32_t index);
66 
67     /**
68      * Reject Request
69      *
70      * @param slotId
71      * @param phoneNum
72      * @param index
73      * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
74      */
75     int32_t RejectRequest(int32_t slotId, const std::string &phoneNum, int32_t index);
76 
77     /**
78      * HoldCall Request
79      *
80      * @param slotId
81      * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
82      */
83     int32_t HoldCallRequest(int32_t slotId);
84 
85     /**
86      * UnHoldCall Request
87      *
88      * @param slotId
89      * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
90      */
91     int32_t UnHoldCallRequest(int32_t slotId);
92 
93     /**
94      * SwitchCall Request
95      *
96      * @param slotId
97      * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
98      */
99     int32_t SwitchCallRequest(int32_t slotId);
100 
101     /**
102      * CombineConference Request
103      *
104      * @param slotId
105      * @param voiceCall
106      * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
107      */
108     int32_t CombineConferenceRequest(int32_t slotId, int32_t voiceCall);
109 
110     /**
111      * InviteToConference Request
112      *
113      * @param slotId
114      * @param numberList
115      * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
116      */
117     int32_t InviteToConferenceRequest(int32_t slotId, const std::vector<std::string> &numberList);
118 
119     /**
120      * KickOutFromConference Request
121      *
122      * @param slotId
123      * @param index
124      * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
125      */
126     int32_t KickOutFromConferenceRequest(int32_t slotId, int32_t index);
127 
128     /**
129      * CallSupplement Request
130      *
131      * @param slotId
132      * @param CallSupplementType
133      * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
134      */
135     int32_t CallSupplementRequest(int32_t slotId, CallSupplementType type);
136 
137     /**
138      * StartRtt Request
139      *
140      * @param slotId
141      * @param msg
142      * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
143      */
144     int32_t StartRttRequest(int32_t slotId, const std::string &msg);
145 
146     /**
147      * StopRtt Request
148      *
149      * @param slotId
150      * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
151      */
152     int32_t StopRttRequest(int32_t slotId);
153 
154     /**
155      * GetImsCallsData Request
156      *
157      * @param slotId
158      * @param lastCallsDataFlag
159      * @return Error Code: Returns TELEPHONY_NO_ERROR on success, others on failure.
160      */
161     int32_t GetImsCallsDataRequest(int32_t slotId, int64_t lastCallsDataFlag);
162 
163     /**
164      * Send Dtmf Request
165      *
166      * @param slotId
167      * @param char cDtmfCode
168      * @param index
169      * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
170      */
171     int32_t SendDtmfRequest(int32_t slotId, char cDtmfCode, int32_t index) const;
172 
173     /**
174      * Start Dtmf Request
175      *
176      * @param slotId
177      * @param char cDtmfCode
178      * @param index
179      * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
180      */
181     int32_t StartDtmfRequest(int32_t slotId, char cDtmfCode, int32_t index) const;
182 
183     /**
184      * Stop Dtmf Request
185      *
186      * @param slotId
187      * @param index
188      * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
189      */
190     int32_t StopDtmfRequest(int32_t slotId, int32_t index) const;
191 
192     /**
193      * Get Call Fail Reason Request
194      *
195      * @param slotId
196      * @return Error Code: Returns TELEPHONY_SUCCESS on success, others on failure.
197      */
198     int32_t GetCallFailReasonRequest(int32_t slotId) const;
199 
200     void SetHoldToDialInfo(std::string holdToDialNum, CLIRMode holdToDialClirMode, int32_t holdToDialVideoState,
201         bool isEmergency);
202 
203     bool IsNeedToDial();
204 
205     void SetDialFlag(bool isNeedToDial);
206 
207     ImsDialInfoStruct GetHoldToDialInfo();
208 
209     bool IsPendingHold();
210 
211 private:
212     virtual int32_t ProcessPostDialCallChar(int32_t slotId, char c) override;
213 
214 private:
215     ModuleServiceUtils moduleUtils_;
216     bool isNeedToDial_ = false;
217     ImsDialInfoStruct holdToDialInfo_;
218 };
219 } // namespace Telephony
220 } // namespace OHOS
221 
222 #endif // CELLULAR_CALL_CONNECTION_IMS_H