• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 NATIVE_COMMON_TYPE_H
17 #define NATIVE_COMMON_TYPE_H
18 
19 #include "call_manager_inner_type.h"
20 #include "napi/native_api.h"
21 #include "napi/native_node_api.h"
22 #include "pac_map.h"
23 #include "telephony_errors.h"
24 
25 namespace OHOS {
26 namespace Telephony {
27 const int16_t BOOL_VALUE_IS_TRUE = 1;
28 const int16_t NATIVE_VERSION = 1;
29 const int16_t NATIVE_FLAGS = 0;
30 const int16_t ZERO_VALUE = 0;
31 const int16_t ONLY_ONE_VALUE = 1;
32 const int16_t TWO_VALUE_LIMIT = 2;
33 const int16_t VALUE_MAXIMUM_LIMIT = 3;
34 const int16_t THREE_VALUE_MAXIMUM_LIMIT = 3;
35 const int16_t FOUR_VALUE_MAXIMUM_LIMIT = 4;
36 const int16_t FIVE_VALUE_MAXIMUM_LIMIT = 5;
37 const int16_t ARRAY_INDEX_FIRST = 0;
38 const int16_t ARRAY_INDEX_SECOND = 1;
39 const int16_t ARRAY_INDEX_THIRD = 2;
40 const int16_t ARRAY_INDEX_FOURTH = 3;
41 const int16_t DATA_LENGTH_ONE = 1;
42 const int16_t DATA_LENGTH_TWO = 2;
43 const int16_t DTMF_DEFAULT_OFF = 10;
44 const int16_t PHONE_NUMBER_MAXIMUM_LIMIT = 255;
45 const int16_t MESSAGE_CONTENT_MAXIMUM_LIMIT = 160;
46 const int16_t NAPI_MAX_TIMEOUT_SECOND = 10;
47 const int16_t UNKNOWN_EVENT = 0;
48 
49 struct AsyncContext {
~AsyncContextAsyncContext50     virtual ~AsyncContext() {}
51     napi_env env = nullptr;
52     napi_async_work work = nullptr;
53     napi_deferred deferred = nullptr;
54     napi_ref callbackRef = nullptr;
55     int32_t callId = 0;
56     int32_t resolved = TELEPHONY_ERROR;
57     char number[kMaxNumberLen + 1] = { 0 };
58     size_t numberLen = 0;
59     napi_value value[VALUE_MAXIMUM_LIMIT] = { 0 };
60     size_t valueLen = 0;
61     int32_t errorCode = TELEPHONY_SUCCESS;
62     int32_t eventId = UNKNOWN_EVENT;
63 };
64 
65 struct DialAsyncContext : AsyncContext {
66     int32_t accountId = 0;
67     int32_t videoState = 0;
68     int32_t dialScene = 0;
69     int32_t dialType = 0;
70 };
71 
72 struct AnswerAsyncContext : AsyncContext {
73     int32_t videoState = 0;
74 };
75 
76 struct BoolResultAsyncContext : AsyncContext {
77     int32_t slotId = 0;
78     bool enabled = false;
79 };
80 
81 struct IntResultAsyncContext : AsyncContext {
82     int32_t result = 0;
83 };
84 
85 struct RejectAsyncContext : AsyncContext {
86     bool isSendSms = false;
87     std::string messageContent = "";
88 };
89 
90 struct ListAsyncContext : AsyncContext {
91     std::vector<std::u16string> listResult {};
92 };
93 
94 struct SupplementAsyncContext : AsyncContext {
95     int32_t slotId = 0;
96     int32_t type = 0;
97     int32_t mode = 0;
98     std::string content = "";
99     bool flag = false;
100     napi_ref thisVar = nullptr;
101 };
102 
103 struct ImsSwitchAsyncContext : AsyncContext {
104     int32_t slotId = 0;
105     bool enabled = false;
106 };
107 
108 struct VoNRSwitchAsyncContext : AsyncContext {
109     int32_t slotId = 0;
110     int32_t state = 0;
111 };
112 
113 struct CallRestrictionAsyncContext : AsyncContext {
114     int32_t slotId = 0;
115     CallRestrictionInfo info;
116     napi_ref thisVar = nullptr;
117 };
118 
119 struct CallBarringPasswordAsyncContext : AsyncContext {
120     int32_t slotId = 0;
121     char oldPassword[kMaxNumberLen + 1] = { 0 };
122     char newPassword[kMaxNumberLen + 1] = { 0 };
123     napi_ref thisVar = nullptr;
124 };
125 
126 struct CallTransferAsyncContext : AsyncContext {
127     int32_t slotId = 0;
128     CallTransferInfo info;
129     napi_ref thisVar = nullptr;
130 };
131 
132 struct UtilsAsyncContext : AsyncContext {
133     int32_t slotId = 0;
134     bool enabled = false;
135     std::u16string formatNumber = u"";
136     std::string code = "";
137 };
138 
139 struct EventCallback {
EventCallbackEventCallback140     EventCallback() : env(nullptr), thisVar(nullptr), callbackRef(nullptr), deferred(nullptr),
141                       callbackBeginTime_(0) {}
142     napi_env env = nullptr;
143     napi_ref thisVar = nullptr;
144     napi_ref callbackRef = nullptr;
145     napi_deferred deferred = nullptr;
146     time_t callbackBeginTime_;
147 };
148 
149 struct AudioAsyncContext : AsyncContext {
150     bool isMute = false;
151     std::string address = "";
152     int32_t deviceType = 0;
153 };
154 
155 struct VideoAsyncContext : AsyncContext {
156     double zoomRatio = 0;
157     int32_t rotation = 0;
158     int32_t callingUid = 0;
159     int32_t callingPid = 0;
160     std::string cameraId = "";
161     std::string surfaceId = "";
162     std::string picturePath = "";
163     std::u16string callingPackage = u"";
164     char path[kMaxNumberLen + 1] = { 0 };
165 };
166 
167 struct OttCallAsyncContext : AsyncContext {
168     std::vector<OttCallDetailsInfo> ottVec {};
169 };
170 
171 struct OttEventAsyncContext : AsyncContext {
172     OttCallEventInfo eventInfo;
173 };
174 
175 struct PostDialAsyncContext : AsyncContext {
176     bool proceed = false;
177 };
178 
179 struct VoIPCallStateAsyncContext : AsyncContext {
180     int32_t state = 0;
181 };
182 
183 enum CallWaitingStatus {
184     CALL_WAITING_DISABLE = 0,
185     CALL_WAITING_ENABLE,
186 };
187 
188 enum RestrictionStatus {
189     RESTRICTION_DISABLE = 0,
190     RESTRICTION_ENABLE,
191 };
192 
193 enum TransferStatus {
194     TRANSFER_DISABLE = 0,
195     TRANSFER_ENABLE = 1,
196 };
197 
198 struct CallStateWorker {
199     CallAttributeInfo info;
200     EventCallback callback;
201 };
202 
203 struct CallEventWorker {
204     CallEventInfo info;
205     EventCallback callback;
206 };
207 
208 struct CallSupplementWorker {
209     AppExecFwk::PacMap info;
210     EventCallback callback;
211 };
212 
213 struct CallDisconnectedCauseWorker {
214     DisconnectedDetails details;
215     EventCallback callback;
216 };
217 
218 struct CallOttWorker {
219     OttCallRequestId requestId;
220     AppExecFwk::PacMap info;
221     EventCallback callback;
222 };
223 
224 struct MmiCodeWorker {
225     MmiCodeInfo info;
226     EventCallback callback;
227 };
228 
229 struct AudioDeviceWork {
230     AudioDeviceInfo info;
231     EventCallback callback;
232 };
233 
234 struct PostDialDelayWorker {
235     std::string postDialStr;
236     EventCallback callback;
237 };
238 
239 struct ImsCallModeInfoWorker {
240     CallMediaModeInfo callModeInfo;
241     EventCallback callback;
242 };
243 
244 struct CallSessionEventWorker {
245     CallSessionEvent sessionEvent;
246     EventCallback callback;
247 };
248 
249 struct PeerDimensionsWorker {
250     PeerDimensionsDetail peerDimensionsDetail;
251     EventCallback callback;
252 };
253 
254 struct CallDataUsageWorker {
255     int64_t callDataUsage;
256     EventCallback callback;
257 };
258 
259 struct CameraCapbilitiesWorker {
260     CameraCapabilities cameraCapabilities;
261     EventCallback callback;
262 };
263 } // namespace Telephony
264 } // namespace OHOS
265 
266 #endif // NAPI_CALL_MANAGER_TYPES_H
267