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_DECODE_H
17 #define GSM_USER_DATA_DECODE_H
18 
19 #include "gsm_user_data_pdu.h"
20 
21 namespace OHOS {
22 namespace Telephony {
23 class GsmUserDataDecode {
24 public:
25     explicit GsmUserDataDecode(std::shared_ptr<GsmUserDataPdu> data);
26     ~GsmUserDataDecode();
27     bool DecodeGsmPdu(SmsReadBuffer &buffer, bool bHeaderInd, struct SmsUDPackage *pUserData, struct SmsTpud *pTPUD);
28     bool DecodeGsmHeadPdu(SmsReadBuffer &buffer, bool bHeaderInd, struct SmsUDPackage *pUserData, struct SmsTpud *pTPUD,
29         uint8_t &udl, uint8_t &fillBits);
30     bool DecodeGsmBodyPdu(SmsReadBuffer &buffer, bool bHeaderInd, struct SmsUDPackage *pUserData, struct SmsTpud *pTPUD,
31         uint8_t &udl, uint8_t fillBits);
32     bool Decode8bitPdu(SmsReadBuffer &buffer, bool bHeaderInd, struct SmsUDPackage *pUserData, struct SmsTpud *pTPUD);
33     bool DecodeUcs2Pdu(SmsReadBuffer &buffer, bool bHeaderInd, struct SmsUDPackage *pUserData, struct SmsTpud *pTPUD);
34 
35 private:
36     bool DecodeGsmHeadPduPartData(
37         SmsReadBuffer &buffer, bool bHeaderInd, struct SmsUDPackage *userData, uint8_t &udl, uint8_t &fillBits);
38     bool Decode8bitPduPartData(SmsReadBuffer &buffer, bool bHeaderInd, struct SmsUDPackage *userData,
39         struct SmsTpud *pTPUD, uint16_t current, uint8_t udl);
40     bool DecodeUcs2PduPartData(
41         SmsReadBuffer &buffer, bool bHeaderInd, struct SmsUDPackage *userData, uint16_t current, uint8_t udl);
42 
43 private:
44     std::shared_ptr<GsmUserDataPdu> userData_ = nullptr;
45 };
46 } // namespace Telephony
47 } // namespace OHOS
48 #endif