1 /* 2 * Copyright (C) 2023 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 GSM_USER_DATA_ENCODE_H 17 #define GSM_USER_DATA_ENCODE_H 18 19 #include "gsm_user_data_pdu.h" 20 21 namespace OHOS { 22 namespace Telephony { 23 class GsmUserDataEncode { 24 public: 25 explicit GsmUserDataEncode(std::shared_ptr<GsmUserDataPdu> data); 26 ~GsmUserDataEncode(); 27 bool EncodeGsmPdu(SmsWriteBuffer &buffer, const struct SmsUDPackage *pUserData); 28 bool Encode8bitPdu(SmsWriteBuffer &buffer, const struct SmsUDPackage *pUserData, std::string &destAddr); 29 bool EncodeUcs2Pdu(SmsWriteBuffer &buffer, const struct SmsUDPackage *pUserData); 30 31 private: 32 bool EncodeGsmHeadPdu(SmsWriteBuffer &buffer, const struct SmsUDPackage *pUserData, uint8_t &fillBits); 33 bool EncodeGsmBodyPdu(SmsWriteBuffer &buffer, const struct SmsUDPackage *pUserData, uint8_t fillBits); 34 bool Encode8bitHeadPdu(SmsWriteBuffer &buffer, const struct SmsUDPackage *pUserData, std::string &destAddr); 35 bool Encode8bitBodyPdu(SmsWriteBuffer &buffer, const struct SmsUDPackage *pUserData); 36 bool EncodeUcs2HeadPdu(SmsWriteBuffer &buffer, const struct SmsUDPackage *pUserData); 37 bool EncodeUcs2BodyPdu(SmsWriteBuffer &buffer, const struct SmsUDPackage *pUserData); 38 39 private: 40 std::shared_ptr<GsmUserDataPdu> userData_ = nullptr; 41 }; 42 } // namespace Telephony 43 } // namespace OHOS 44 #endif