1 /* 2 * Copyright (c) 2025 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 #ifndef SMS_UTILS_H 16 #define SMS_UTILS_H 17 18 #include <cstdint> 19 20 #include "cj_common_ffi.h" 21 22 namespace OHOS { 23 namespace Telephony { 24 const int32_t MESSAGE_PARAMETER_NOT_MATCH = 0; 25 const int32_t TEXT_MESSAGE_PARAMETER_MATCH = 1; 26 const int32_t RAW_DATA_MESSAGE_PARAMETER_MATCH = 2; 27 extern "C" { 28 struct CJShortMessage { 29 bool hasReplyPath; 30 bool isReplaceMessage; 31 bool isSmsStatusReportMessage; 32 int32_t messageClass; 33 CArrI32 pdu; 34 int32_t protocolId; 35 char* scAddress; 36 int64_t scTimestamp; 37 int32_t status; 38 char* visibleMessageBody; 39 char* visibleRawAddress; 40 int32_t errCode; 41 }; 42 43 struct CJSendMessageOptions { 44 int32_t messageType = MESSAGE_PARAMETER_NOT_MATCH; 45 bool isPersist = true; 46 int32_t slotId; 47 char* destinationHost; 48 char* serviceCenter; 49 uint16_t destinationPort = 0; 50 int64_t sendCallback; 51 int64_t deliveryCallback; 52 char* textContent; 53 CArrUI8 rawDataContent; 54 }; 55 } 56 char* MallocCString(const std::string& origin); 57 int32_t NativeSendMessage(CJSendMessageOptions& options); 58 int32_t ConverErrorCodeForCj(int32_t errorCode); 59 int32_t ConverErrorCodeWithPermissionForCj(int32_t errorCode); 60 } // namespace Telephony 61 } // namespace OHOS 62 63 #endif 64