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 constexpr size_t ARRAY_SIZE = 64; 30 constexpr size_t kMaxNumberLen = 100; 31 32 template<typename T> 33 struct AsyncContext { 34 BaseContext context; 35 int32_t slotId = ERROR_DEFAULT; 36 T callbackVal; 37 }; 38 39 struct AsyncContext2 { 40 AsyncContext<bool> asyncContext; 41 std::array<char, ARRAY_SIZE> inputStr {}; 42 }; 43 44 struct AsyncContextPIN { 45 AsyncContext<napi_value> asyncContext; 46 int32_t result = ERROR_DEFAULT; 47 int32_t remain = ERROR_DEFAULT; 48 int32_t pinEnable = ERROR_DEFAULT; 49 std::string inStr1 {}; 50 std::string inStr2 {}; 51 }; 52 53 struct AsyncIccAccountInfo { 54 AsyncContext<napi_value> asyncContext; 55 std::vector<IccAccountInfo> vecInfo; 56 }; 57 58 struct ConfigInfo { 59 std::string field {}; 60 std::string value {}; 61 }; 62 63 struct AsyncOperatorConfig { 64 AsyncContext<napi_value> asyncContext; 65 std::vector<ConfigInfo> configValue {}; 66 }; 67 68 struct TelNumbersInfo { 69 int32_t recordNumber = ERROR_NONE; 70 std::array<char, ARRAY_SIZE> alphaTag {}; 71 std::array<char, ARRAY_SIZE> number {}; 72 std::array<char, ARRAY_SIZE> pin2 {}; 73 }; 74 75 template<typename T> 76 struct AsyncDiallingNumbers { 77 AsyncContext<T> asyncContext; 78 int32_t type = ERROR_DEFAULT; 79 std::vector<TelNumbersInfo> infoVec; 80 }; 81 82 struct AsyncVoiceMail { 83 AsyncContext<bool> asyncContext; 84 std::array<char, ARRAY_SIZE> mailName {}; 85 std::array<char, ARRAY_SIZE> mailNumber {}; 86 }; 87 88 struct AsyncGetLockState { 89 AsyncContext<int32_t> asyncContext; 90 int32_t lockType = ERROR_DEFAULT; 91 }; 92 93 struct AsyncDefaultSlotId { 94 AsyncContext<int32_t> asyncContext; 95 }; 96 97 struct AsyncStkCallSetupResult { 98 AsyncContext<int32_t> asyncContext; 99 }; 100 } // namespace Telephony 101 } // namespace OHOS 102 #endif // OHOS_NAPI_SIM_H 103