1 /* 2 * Copyright (c) 2024 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 TELEPHONY_CALL_UTILS_H 17 #define TELEPHONY_CALL_UTILS_H 18 19 #include <cstdint> 20 #include <string> 21 22 namespace OHOS { 23 namespace Telephony { MallocCString(const std::string & origin)24 inline char* MallocCString(const std::string& origin) 25 { 26 if (origin.empty()) { 27 return nullptr; 28 } 29 auto lenth = origin.length() + 1; 30 char* res = static_cast<char*>(malloc(sizeof(char) * lenth)); 31 if (res == nullptr) { 32 return nullptr; 33 } 34 return std::char_traits<char>::copy(res, origin.c_str(), lenth); 35 } 36 37 struct DialCallOptions { 38 int32_t accountId; 39 int32_t videoState; 40 int32_t dialScene; 41 int32_t dialType; 42 }; 43 44 enum CJErrorCode { 45 /** 46 * The input parameter value is out of range. 47 */ 48 CJ_ERROR_TELEPHONY_ARGUMENT_ERROR = 8300001, 49 50 /** 51 * Operation failed. Cannot connect to service. 52 */ 53 CJ_ERROR_TELEPHONY_SERVICE_ERROR = 8300002, 54 55 /** 56 * System internal error. 57 */ 58 CJ_ERROR_TELEPHONY_SYSTEM_ERROR = 8300003, 59 60 /** 61 * Do not have sim card. 62 */ 63 CJ_ERROR_TELEPHONY_NO_SIM_CARD = 8300004, 64 65 /** 66 * Airplane mode is on. 67 */ 68 CJ_ERROR_TELEPHONY_AIRPLANE_MODE_ON = 8300005, 69 70 /** 71 * Network not in service. 72 */ 73 CJ_ERROR_TELEPHONY_NETWORK_NOT_IN_SERVICE = 8300006, 74 75 /** 76 * Unknown error code. 77 */ 78 CJ_ERROR_TELEPHONY_UNKNOW_ERROR = 8300999, 79 80 /** 81 * SIM card is not activated. 82 */ 83 CJ_ERROR_SIM_CARD_IS_NOT_ACTIVE = 8301001, 84 85 /** 86 * SIM card operation error. 87 */ 88 CJ_ERROR_SIM_CARD_OPERATION_ERROR = 8301002, 89 90 /** 91 * Operator config error. 92 */ 93 CJ_ERROR_OPERATOR_CONFIG_ERROR = 8301003, 94 95 /** 96 * Permission verification failed, usually the result returned by VerifyAccessToken. 97 */ 98 CJ_ERROR_TELEPHONY_PERMISSION_DENIED = 201, 99 100 /** 101 * Permission verification failed, application which is not a system application uses system API. 102 */ 103 CJ_ERROR_ILLEGAL_USE_OF_SYSTEM_API = 202, 104 }; 105 } 106 } 107 #endif