• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "sms_receive_indexer.h"
17 
18 namespace OHOS {
19 namespace Telephony {
SmsReceiveIndexer()20 SmsReceiveIndexer::SmsReceiveIndexer()
21 {
22     timestamp_ = 0;
23     destPort_ = 0;
24     msgSeqId_ = 0;
25     msgRefId_ = -1;
26     msgCount_ = 1;
27     isCdma_ = false;
28     isCdmaWapPdu_ = false;
29 }
30 
SmsReceiveIndexer(const std::vector<uint8_t> & pdu,long timestamp,int16_t destPort,bool isCdma,const std::string & address,const std::string & visibleAddress,int16_t msgRefId,uint16_t msgSeqId,uint16_t msgCount,bool isCdmaWapPdu,const std::string & messageBody)31 SmsReceiveIndexer::SmsReceiveIndexer(const std::vector<uint8_t> &pdu, long timestamp, int16_t destPort,
32     bool isCdma, const std::string &address, const std::string &visibleAddress, int16_t msgRefId,
33     uint16_t msgSeqId, uint16_t msgCount, bool isCdmaWapPdu, const std::string &messageBody)
34     : pdu_(pdu), timestamp_(timestamp), destPort_(destPort), isCdma_(isCdma), isCdmaWapPdu_(isCdmaWapPdu),
35       visibleMessageBody_(messageBody), originatingAddress_(address), msgRefId_(msgRefId), msgSeqId_(msgSeqId),
36       msgCount_(msgCount), visibleAddress_(visibleAddress)
37 {}
38 
SmsReceiveIndexer(const std::vector<uint8_t> & pdu,long timestamp,int16_t destPort,bool isCdma,bool isCdmaWapPdu,const std::string & address,const std::string & visibleAddress,const std::string & messageBody)39 SmsReceiveIndexer::SmsReceiveIndexer(const std::vector<uint8_t> &pdu, long timestamp, int16_t destPort,
40     bool isCdma, bool isCdmaWapPdu, const std::string &address, const std::string &visibleAddress,
41     const std::string &messageBody)
42     : pdu_(pdu), timestamp_(timestamp), destPort_(destPort), isCdma_(isCdma), isCdmaWapPdu_(isCdmaWapPdu),
43       visibleMessageBody_(messageBody), originatingAddress_(address), visibleAddress_(visibleAddress)
44 {
45     if (isCdma_ && isCdmaWapPdu_) {
46         msgSeqId_ = 0;
47     } else {
48         msgSeqId_ = 1;
49     }
50     msgRefId_ = -1;
51     msgCount_ = 1;
52 }
53 
GetVisibleAddress() const54 std::string SmsReceiveIndexer::GetVisibleAddress() const
55 {
56     return visibleAddress_;
57 }
58 
SetVisibleAddress(const std::string & visibleAddress)59 void SmsReceiveIndexer::SetVisibleAddress(const std::string &visibleAddress)
60 {
61     visibleAddress_ = visibleAddress;
62 }
63 
GetEraseRefId() const64 std::string SmsReceiveIndexer::GetEraseRefId() const
65 {
66     return eraseRefId_;
67 }
68 
SetEraseRefId(const std::string & eraseRefId)69 void SmsReceiveIndexer::SetEraseRefId(const std::string &eraseRefId)
70 {
71     eraseRefId_ = eraseRefId;
72 }
73 
GetMsgCount() const74 uint16_t SmsReceiveIndexer::GetMsgCount() const
75 {
76     return msgCount_;
77 }
78 
SetMsgCount(uint16_t msgCount)79 void SmsReceiveIndexer::SetMsgCount(uint16_t msgCount)
80 {
81     msgCount_ = msgCount;
82 }
83 
GetMsgSeqId() const84 uint16_t SmsReceiveIndexer::GetMsgSeqId() const
85 {
86     return msgSeqId_;
87 }
88 
SetMsgSeqId(uint16_t msgSeqId)89 void SmsReceiveIndexer::SetMsgSeqId(uint16_t msgSeqId)
90 {
91     msgSeqId_ = msgSeqId;
92 }
93 
GetMsgRefId() const94 uint16_t SmsReceiveIndexer::GetMsgRefId() const
95 {
96     return msgRefId_;
97 }
98 
SetMsgRefId(uint16_t msgRefId)99 void SmsReceiveIndexer::SetMsgRefId(uint16_t msgRefId)
100 {
101     msgRefId_ = msgRefId;
102 }
103 
GetOriginatingAddress() const104 std::string SmsReceiveIndexer::GetOriginatingAddress() const
105 {
106     return originatingAddress_;
107 }
108 
SetOriginatingAddress(const std::string & address)109 void SmsReceiveIndexer::SetOriginatingAddress(const std::string &address)
110 {
111     originatingAddress_ = address;
112 }
113 
GetVisibleMessageBody() const114 std::string SmsReceiveIndexer::GetVisibleMessageBody() const
115 {
116     return visibleMessageBody_;
117 }
118 
SetVisibleMessageBody(const std::string & messageBody)119 void SmsReceiveIndexer::SetVisibleMessageBody(const std::string &messageBody)
120 {
121     visibleMessageBody_ = messageBody;
122 }
123 
GetIsCdmaWapPdu() const124 bool SmsReceiveIndexer::GetIsCdmaWapPdu() const
125 {
126     return isCdmaWapPdu_;
127 }
128 
SetIsCdmaWapPdu(bool isCdmaWapPdu)129 void SmsReceiveIndexer::SetIsCdmaWapPdu(bool isCdmaWapPdu)
130 {
131     isCdmaWapPdu_ = isCdmaWapPdu;
132 }
133 
GetIsCdma() const134 bool SmsReceiveIndexer::GetIsCdma() const
135 {
136     return isCdma_;
137 }
138 
SetIsCdma(bool isCdma)139 void SmsReceiveIndexer::SetIsCdma(bool isCdma)
140 {
141     isCdma_ = isCdma;
142 }
143 
GetDestPort() const144 int16_t SmsReceiveIndexer::GetDestPort() const
145 {
146     return destPort_;
147 }
148 
SetDestPort(int16_t destPort)149 void SmsReceiveIndexer::SetDestPort(int16_t destPort)
150 {
151     destPort_ = destPort;
152 }
153 
GetTimestamp() const154 long SmsReceiveIndexer::GetTimestamp() const
155 {
156     return timestamp_;
157 }
158 
SetTimestamp(long timestamp)159 void SmsReceiveIndexer::SetTimestamp(long timestamp)
160 {
161     timestamp_ = timestamp;
162 }
163 
GetPdu() const164 const std::vector<uint8_t>& SmsReceiveIndexer::GetPdu() const
165 {
166     return pdu_;
167 }
168 
SetPdu(const std::vector<uint8_t> & pdu)169 void SmsReceiveIndexer::SetPdu(const std::vector<uint8_t> &pdu)
170 {
171     pdu_ = pdu;
172 }
173 
SetPdu(const std::vector<uint8_t> && pdu)174 void SmsReceiveIndexer::SetPdu(const std::vector<uint8_t> &&pdu)
175 {
176     pdu_ = std::forward<const std::vector<uint8_t>>(pdu);
177 }
178 
GetIsText() const179 bool SmsReceiveIndexer::GetIsText() const
180 {
181     return (destPort_ == TEXT_PORT_NUM);
182 }
183 
GetIsWapPushMsg() const184 bool SmsReceiveIndexer::GetIsWapPushMsg() const
185 {
186     return (destPort_ == WAP_PUSH_PORT);
187 }
188 
IsSingleMsg() const189 bool SmsReceiveIndexer::IsSingleMsg() const
190 {
191     return msgCount_ == 1;
192 }
193 
GetRawUserData() const194 std::string SmsReceiveIndexer::GetRawUserData() const
195 {
196     return rawUserData_;
197 }
198 
SetRawUserData(const std::string & rawUserData)199 void SmsReceiveIndexer::SetRawUserData(const std::string &rawUserData)
200 {
201     rawUserData_ = rawUserData;
202 }
203 } // namespace Telephony
204 } // namespace OHOS