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 #include "cstdint"
19 #include "iosfwd"
20 #include "string"
21 #include "type_traits"
22 #include "vector"
23
24 namespace OHOS {
25 namespace Telephony {
SmsReceiveIndexer()26 SmsReceiveIndexer::SmsReceiveIndexer()
27 {
28 timestamp_ = 0;
29 destPort_ = 0;
30 msgSeqId_ = 0;
31 msgRefId_ = -1;
32 msgCount_ = 1;
33 isCdma_ = false;
34 isCdmaWapPdu_ = false;
35 }
36
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)37 SmsReceiveIndexer::SmsReceiveIndexer(const std::vector<uint8_t> &pdu, long timestamp, int16_t destPort,
38 bool isCdma, const std::string &address, const std::string &visibleAddress, int16_t msgRefId,
39 uint16_t msgSeqId, uint16_t msgCount, bool isCdmaWapPdu, const std::string &messageBody)
40 : pdu_(pdu), timestamp_(timestamp), destPort_(destPort), isCdma_(isCdma), isCdmaWapPdu_(isCdmaWapPdu),
41 visibleMessageBody_(messageBody), originatingAddress_(address), msgRefId_(msgRefId), msgSeqId_(msgSeqId),
42 msgCount_(msgCount), visibleAddress_(visibleAddress)
43 {}
44
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)45 SmsReceiveIndexer::SmsReceiveIndexer(const std::vector<uint8_t> &pdu, long timestamp, int16_t destPort,
46 bool isCdma, bool isCdmaWapPdu, const std::string &address, const std::string &visibleAddress,
47 const std::string &messageBody)
48 : pdu_(pdu), timestamp_(timestamp), destPort_(destPort), isCdma_(isCdma), isCdmaWapPdu_(isCdmaWapPdu),
49 visibleMessageBody_(messageBody), originatingAddress_(address), visibleAddress_(visibleAddress)
50 {
51 if (isCdma_ && isCdmaWapPdu_) {
52 msgSeqId_ = 0;
53 } else {
54 msgSeqId_ = 1;
55 }
56 msgRefId_ = -1;
57 msgCount_ = 1;
58 }
59
GetVisibleAddress() const60 std::string SmsReceiveIndexer::GetVisibleAddress() const
61 {
62 return visibleAddress_;
63 }
64
SetVisibleAddress(const std::string & visibleAddress)65 void SmsReceiveIndexer::SetVisibleAddress(const std::string &visibleAddress)
66 {
67 visibleAddress_ = visibleAddress;
68 }
69
GetEraseRefId() const70 std::string SmsReceiveIndexer::GetEraseRefId() const
71 {
72 return eraseRefId_;
73 }
74
SetEraseRefId(const std::string & eraseRefId)75 void SmsReceiveIndexer::SetEraseRefId(const std::string &eraseRefId)
76 {
77 eraseRefId_ = eraseRefId;
78 }
79
GetMsgCount() const80 uint16_t SmsReceiveIndexer::GetMsgCount() const
81 {
82 return msgCount_;
83 }
84
SetMsgCount(uint16_t msgCount)85 void SmsReceiveIndexer::SetMsgCount(uint16_t msgCount)
86 {
87 msgCount_ = msgCount;
88 }
89
GetMsgSeqId() const90 uint16_t SmsReceiveIndexer::GetMsgSeqId() const
91 {
92 return msgSeqId_;
93 }
94
SetMsgSeqId(uint16_t msgSeqId)95 void SmsReceiveIndexer::SetMsgSeqId(uint16_t msgSeqId)
96 {
97 msgSeqId_ = msgSeqId;
98 }
99
GetMsgRefId() const100 uint16_t SmsReceiveIndexer::GetMsgRefId() const
101 {
102 return msgRefId_;
103 }
104
SetMsgRefId(uint16_t msgRefId)105 void SmsReceiveIndexer::SetMsgRefId(uint16_t msgRefId)
106 {
107 msgRefId_ = static_cast<int16_t>(msgRefId);
108 }
109
GetOriginatingAddress() const110 std::string SmsReceiveIndexer::GetOriginatingAddress() const
111 {
112 return originatingAddress_;
113 }
114
SetOriginatingAddress(const std::string & address)115 void SmsReceiveIndexer::SetOriginatingAddress(const std::string &address)
116 {
117 originatingAddress_ = address;
118 }
119
GetVisibleMessageBody() const120 std::string SmsReceiveIndexer::GetVisibleMessageBody() const
121 {
122 return visibleMessageBody_;
123 }
124
SetVisibleMessageBody(const std::string & messageBody)125 void SmsReceiveIndexer::SetVisibleMessageBody(const std::string &messageBody)
126 {
127 visibleMessageBody_ = messageBody;
128 }
129
GetIsCdmaWapPdu() const130 bool SmsReceiveIndexer::GetIsCdmaWapPdu() const
131 {
132 return isCdmaWapPdu_;
133 }
134
SetIsCdmaWapPdu(bool isCdmaWapPdu)135 void SmsReceiveIndexer::SetIsCdmaWapPdu(bool isCdmaWapPdu)
136 {
137 isCdmaWapPdu_ = isCdmaWapPdu;
138 }
139
GetIsCdma() const140 bool SmsReceiveIndexer::GetIsCdma() const
141 {
142 return isCdma_;
143 }
144
SetIsCdma(bool isCdma)145 void SmsReceiveIndexer::SetIsCdma(bool isCdma)
146 {
147 isCdma_ = isCdma;
148 }
149
GetDestPort() const150 int16_t SmsReceiveIndexer::GetDestPort() const
151 {
152 return destPort_;
153 }
154
SetDestPort(int16_t destPort)155 void SmsReceiveIndexer::SetDestPort(int16_t destPort)
156 {
157 destPort_ = destPort;
158 }
159
GetTimestamp() const160 long SmsReceiveIndexer::GetTimestamp() const
161 {
162 return timestamp_;
163 }
164
SetTimestamp(long timestamp)165 void SmsReceiveIndexer::SetTimestamp(long timestamp)
166 {
167 timestamp_ = timestamp;
168 }
169
GetPdu() const170 const std::vector<uint8_t>& SmsReceiveIndexer::GetPdu() const
171 {
172 return pdu_;
173 }
174
SetPdu(const std::vector<uint8_t> & pdu)175 void SmsReceiveIndexer::SetPdu(const std::vector<uint8_t> &pdu)
176 {
177 pdu_ = pdu;
178 }
179
SetPdu(const std::vector<uint8_t> && pdu)180 void SmsReceiveIndexer::SetPdu(const std::vector<uint8_t> &&pdu)
181 {
182 pdu_ = std::forward<const std::vector<uint8_t>>(pdu);
183 }
184
GetIsText() const185 bool SmsReceiveIndexer::GetIsText() const
186 {
187 return (destPort_ == TEXT_PORT_NUM);
188 }
189
GetIsWapPushMsg() const190 bool SmsReceiveIndexer::GetIsWapPushMsg() const
191 {
192 return (destPort_ == WAP_PUSH_PORT);
193 }
194
IsSingleMsg() const195 bool SmsReceiveIndexer::IsSingleMsg() const
196 {
197 return msgCount_ == 1;
198 }
199
GetRawUserData() const200 std::string SmsReceiveIndexer::GetRawUserData() const
201 {
202 return rawUserData_;
203 }
204
SetRawUserData(const std::string & rawUserData)205 void SmsReceiveIndexer::SetRawUserData(const std::string &rawUserData)
206 {
207 rawUserData_ = rawUserData;
208 }
209 } // namespace Telephony
210 } // namespace OHOS