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 NAPI_CELLULAR_DATA_H 17 #define NAPI_CELLULAR_DATA_H 18 19 #include <stdint.h> 20 21 #include "base_context.h" 22 #include "cellular_data_types.h" 23 #include "telephony_napi_common_error.h" 24 #include "telephony_types.h" 25 26 namespace OHOS { 27 namespace Telephony { 28 struct AsyncContext : BaseContext { 29 int32_t slotId = 0; 30 int32_t result = ERROR_SERVICE_UNAVAILABLE; 31 }; 32 33 struct AsyncSetPreferApnContext : BaseContext { 34 int32_t apnId = 0; 35 int32_t result = ERROR_SERVICE_UNAVAILABLE; 36 }; 37 38 struct PermissionPara { 39 std::string func = ""; 40 std::string permission = ""; 41 }; 42 43 template<typename T> 44 struct AsyncContext1 { 45 BaseContext context; 46 int32_t slotId = ERROR_DEFAULT; 47 T callbackVal; 48 std::mutex callbackMutex; 49 std::condition_variable cv; 50 bool isCallbackEnd = false; 51 bool isSendRequest = false; 52 }; 53 54 struct AsyncQueryApnInfo { 55 AsyncContext1<napi_value> asyncContext; 56 ApnInfo queryApnPara; 57 std::vector<uint32_t> apnIdList {}; 58 }; 59 60 struct AsyncQueryAllApnInfo { 61 AsyncContext1<napi_value> asyncContext; 62 std::vector<ApnInfo> allApnInfoList {}; 63 }; 64 65 struct AsyncGetActiveApnName { 66 AsyncContext1<napi_value> asyncContext; 67 std::string apnName; 68 }; 69 } // namespace Telephony 70 } // namespace OHOS 71 #endif // NAPI_CELLULAR_DATA_H 72