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 OHOS_NAPI_SIM_H
17 #define OHOS_NAPI_SIM_H
18 
19 #include <array>
20 #include <string>
21 #include <vector>
22 #include "base_context.h"
23 #include "sim_state_type.h"
24 #include "telephony_napi_common_error.h"
25 #include "telephony_types.h"
26 
27 namespace OHOS {
28 namespace Telephony {
29 
30 template<typename T>
31 struct AsyncContext {
32     BaseContext context;
33     int32_t slotId = ERROR_DEFAULT;
34     T callbackVal;
35 };
36 
37 struct AsyncContext2 {
38     AsyncContext<bool> asyncContext;
39     std::array<char, ARRAY_SIZE> inputStr {};
40 };
41 
42 struct AsyncContextPIN {
43     AsyncContext<napi_value> asyncContext;
44     int32_t result = ERROR_DEFAULT;
45     int32_t remain = ERROR_DEFAULT;
46     int32_t pinEnable = ERROR_DEFAULT;
47     std::string inStr1 {};
48     std::string inStr2 {};
49 };
50 
51 struct AsyncIccAccountInfo {
52     AsyncContext<napi_value> asyncContext;
53     std::vector<IccAccountInfo> vecInfo {};
54 };
55 
56 struct ConfigInfo {
57     std::string field {};
58     std::string value {};
59 };
60 
61 struct AsyncOperatorConfig {
62     AsyncContext<napi_value> asyncContext;
63     std::vector<ConfigInfo> configValue {};
64 };
65 
66 struct TelNumbersInfo {
67     int32_t recordNumber = ERROR_NONE;
68     std::array<char, ARRAY_SIZE> alphaTag {};
69     std::array<char, ARRAY_SIZE> number {};
70     std::array<char, ARRAY_SIZE> pin2 {};
71 };
72 
73 template<typename T>
74 struct AsyncDiallingNumbers {
75     AsyncContext<T> asyncContext;
76     int32_t type = ERROR_DEFAULT;
77     std::vector<TelNumbersInfo> infoVec {};
78 };
79 
80 struct AsyncVoiceMail {
81     AsyncContext<bool> asyncContext;
82     std::array<char, ARRAY_SIZE> mailName {};
83     std::array<char, ARRAY_SIZE> mailNumber {};
84 };
85 
86 struct AsyncGetLockState {
87     AsyncContext<int32_t> asyncContext;
88     int32_t lockType = ERROR_DEFAULT;
89 };
90 
91 struct AsyncDefaultSlotId {
92     AsyncContext<int32_t> asyncContext;
93 };
94 
95 struct AsyncDefaultSimId {
96     AsyncContext<int32_t> asyncContext;
97 };
98 
99 struct AsyncStkCallSetupResult {
100     AsyncContext<int32_t> asyncContext;
101 };
102 
103 struct AsyncDsdsInfo {
104     AsyncContext<int32_t> asyncContext;
105 };
106 
107 struct AsyncSimAuthInfo {
108     AsyncContext<napi_value> asyncContext;
109     int32_t authType = ERROR_DEFAULT;
110     std::string authData {};
111     SimAuthenticationResponse responseResult;
112 };
113 } // namespace Telephony
114 } // namespace OHOS
115 #endif // OHOS_NAPI_SIM_H
116