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_send_indexer.h"
17
18 namespace OHOS {
19 namespace Telephony {
20 using namespace std;
SmsSendIndexer(const string & desAddr,const string & scAddr,const string & text,const sptr<ISendShortMessageCallback> & sendCallback,const sptr<IDeliveryShortMessageCallback> & deliveryCallback)21 SmsSendIndexer::SmsSendIndexer(const string &desAddr, const string &scAddr, const string &text,
22 const sptr<ISendShortMessageCallback> &sendCallback,
23 const sptr<IDeliveryShortMessageCallback> &deliveryCallback)
24 : text_(text), scAddr_(scAddr), destAddr_(desAddr), sendCallback_(sendCallback),
25 deliveryCallback_(deliveryCallback), isText_(true)
26 {}
27
SmsSendIndexer(const string & desAddr,const string & scAddr,int32_t port,const uint8_t * data,uint32_t dataLen,const sptr<ISendShortMessageCallback> & sendCallback,const sptr<IDeliveryShortMessageCallback> & deliveryCallback)28 SmsSendIndexer::SmsSendIndexer(const string &desAddr, const string &scAddr, int32_t port, const uint8_t *data,
29 uint32_t dataLen, const sptr<ISendShortMessageCallback> &sendCallback,
30 const sptr<IDeliveryShortMessageCallback> &deliveryCallback)
31 : data_(std::vector<uint8_t>(data, data + dataLen)), scAddr_(scAddr), destAddr_(desAddr), destPort_(port),
32 sendCallback_(sendCallback), deliveryCallback_(deliveryCallback), isText_(false)
33 {}
34
~SmsSendIndexer()35 SmsSendIndexer::~SmsSendIndexer() {}
36
SetEncodeSmca(const std::vector<uint8_t> & smca)37 void SmsSendIndexer::SetEncodeSmca(const std::vector<uint8_t> &smca)
38 {
39 smca_ = smca;
40 }
41
SetEncodeSmca(const std::vector<uint8_t> && smca)42 void SmsSendIndexer::SetEncodeSmca(const std::vector<uint8_t> &&smca)
43 {
44 smca_ = std::forward<const std::vector<uint8_t>>(smca);
45 }
46
GetEncodeSmca() const47 const std::vector<uint8_t>& SmsSendIndexer::GetEncodeSmca() const
48 {
49 return smca_;
50 }
51
SetEncodePdu(const std::vector<uint8_t> & pdu)52 void SmsSendIndexer::SetEncodePdu(const std::vector<uint8_t> &pdu)
53 {
54 pdu_ = pdu;
55 }
56
SetImsSmsForCdma(const bool isImsSms)57 void SmsSendIndexer::SetImsSmsForCdma(const bool isImsSms)
58 {
59 isCdmaIms_ = isImsSms;
60 }
61
SetEncodePdu(const std::vector<uint8_t> && pdu)62 void SmsSendIndexer::SetEncodePdu(const std::vector<uint8_t> &&pdu)
63 {
64 pdu_ = std::forward<const std::vector<uint8_t>>(pdu);
65 }
66
GetEncodePdu() const67 const std::vector<uint8_t>& SmsSendIndexer::GetEncodePdu() const
68 {
69 return pdu_;
70 }
71
IsImsSmsForCdma() const72 const bool &SmsSendIndexer::IsImsSmsForCdma() const
73 {
74 return isCdmaIms_;
75 }
76
GetIsFailure() const77 bool SmsSendIndexer::GetIsFailure() const
78 {
79 return isFailure_;
80 }
81
SetIsFailure(bool isFailure)82 void SmsSendIndexer::SetIsFailure(bool isFailure)
83 {
84 isFailure_ = isFailure;
85 }
86
GetHasMore() const87 bool SmsSendIndexer::GetHasMore() const
88 {
89 return hasMore_;
90 }
91
SetHasMore(bool hasMore)92 void SmsSendIndexer::SetHasMore(bool hasMore)
93 {
94 hasMore_ = hasMore;
95 }
96
GetTimeStamp() const97 long SmsSendIndexer::GetTimeStamp() const
98 {
99 return timeStamp_;
100 }
101
SetTimeStamp(long timeStamp)102 void SmsSendIndexer::SetTimeStamp(long timeStamp)
103 {
104 timeStamp_ = timeStamp;
105 }
106
SetNetWorkType(NetWorkType netWorkType)107 void SmsSendIndexer::SetNetWorkType(NetWorkType netWorkType)
108 {
109 netWorkType_ = netWorkType;
110 }
111
GetNetWorkType() const112 NetWorkType SmsSendIndexer::GetNetWorkType() const
113 {
114 return netWorkType_;
115 }
116
GetHasCellFailed() const117 std::shared_ptr<bool> SmsSendIndexer::GetHasCellFailed() const
118 {
119 return hasCellFailed_;
120 }
121
SetHasCellFailed(const std::shared_ptr<bool> & hasCellFailed)122 void SmsSendIndexer::SetHasCellFailed(const std::shared_ptr<bool> &hasCellFailed)
123 {
124 hasCellFailed_ = hasCellFailed;
125 }
126
GetUnSentCellCount() const127 std::shared_ptr<uint8_t> SmsSendIndexer::GetUnSentCellCount() const
128 {
129 return unSentCellCount_;
130 }
131
SetUnSentCellCount(const std::shared_ptr<uint8_t> & unSentCellCount)132 void SmsSendIndexer::SetUnSentCellCount(const std::shared_ptr<uint8_t> &unSentCellCount)
133 {
134 unSentCellCount_ = unSentCellCount;
135 }
136
GetCsResendCount() const137 uint8_t SmsSendIndexer::GetCsResendCount() const
138 {
139 return csResendCount_;
140 }
141
SetCsResendCount(uint8_t csResendCount)142 void SmsSendIndexer::SetCsResendCount(uint8_t csResendCount)
143 {
144 csResendCount_ = csResendCount;
145 }
146
GetText() const147 std::string SmsSendIndexer::GetText() const
148 {
149 return text_;
150 }
151
SetText(const std::string & text)152 void SmsSendIndexer::SetText(const std::string &text)
153 {
154 text_ = text;
155 }
156
GetDeliveryCallback() const157 sptr<IDeliveryShortMessageCallback> SmsSendIndexer::GetDeliveryCallback() const
158 {
159 return deliveryCallback_;
160 }
161
SetDeliveryCallback(const sptr<IDeliveryShortMessageCallback> & deliveryCallback)162 void SmsSendIndexer::SetDeliveryCallback(const sptr<IDeliveryShortMessageCallback> &deliveryCallback)
163 {
164 deliveryCallback_ = deliveryCallback;
165 }
166
GetSendCallback() const167 sptr<ISendShortMessageCallback> SmsSendIndexer::GetSendCallback() const
168 {
169 return sendCallback_;
170 }
171
SetSendCallback(const sptr<ISendShortMessageCallback> & sendCallback)172 void SmsSendIndexer::SetSendCallback(const sptr<ISendShortMessageCallback> &sendCallback)
173 {
174 sendCallback_ = sendCallback;
175 }
176
GetDestPort() const177 int32_t SmsSendIndexer::GetDestPort() const
178 {
179 return destPort_;
180 }
181
SetDestPort(int32_t destPort)182 void SmsSendIndexer::SetDestPort(int32_t destPort)
183 {
184 destPort_ = destPort;
185 }
186
GetDestAddr() const187 std::string SmsSendIndexer::GetDestAddr() const
188 {
189 return destAddr_;
190 }
191
SetDestAddr(const std::string & destAddr)192 void SmsSendIndexer::SetDestAddr(const std::string &destAddr)
193 {
194 destAddr_ = destAddr;
195 }
196
GetSmcaAddr() const197 std::string SmsSendIndexer::GetSmcaAddr() const
198 {
199 return scAddr_;
200 }
201
SetSmcaAddr(const std::string & scAddr)202 void SmsSendIndexer::SetSmcaAddr(const std::string &scAddr)
203 {
204 scAddr_ = scAddr;
205 }
206
GetIsText() const207 bool SmsSendIndexer::GetIsText() const
208 {
209 return isText_;
210 }
211
GetErrorCode() const212 uint8_t SmsSendIndexer::GetErrorCode() const
213 {
214 return errorCode_;
215 }
216
SetErrorCode(uint8_t errorCode)217 void SmsSendIndexer::SetErrorCode(uint8_t errorCode)
218 {
219 errorCode_ = errorCode;
220 }
221
GetData() const222 const std::vector<uint8_t>& SmsSendIndexer::GetData() const
223 {
224 return data_;
225 }
226
SetData(const std::vector<uint8_t> & data)227 void SmsSendIndexer::SetData(const std::vector<uint8_t> &data)
228 {
229 data_ = data;
230 }
231
SetData(const std::vector<uint8_t> && data)232 void SmsSendIndexer::SetData(const std::vector<uint8_t> &&data)
233 {
234 data_ = std::forward<const std::vector<uint8_t>>(data);
235 }
236
GetAckPdu() const237 const std::vector<uint8_t>& SmsSendIndexer::GetAckPdu() const
238 {
239 return ackPdu_;
240 }
241
SetAckPdu(const std::vector<uint8_t> & ackPdu)242 void SmsSendIndexer::SetAckPdu(const std::vector<uint8_t> &ackPdu)
243 {
244 ackPdu_ = ackPdu;
245 }
246
SetAckPdu(const std::vector<uint8_t> && ackPdu)247 void SmsSendIndexer::SetAckPdu(const std::vector<uint8_t> &&ackPdu)
248 {
249 ackPdu_ = std::forward<const std::vector<uint8_t>>(ackPdu);
250 }
251
GetMsgRefId() const252 uint8_t SmsSendIndexer::GetMsgRefId() const
253 {
254 return msgRefId_;
255 }
256
SetMsgRefId(uint8_t msgRefId)257 void SmsSendIndexer::SetMsgRefId(uint8_t msgRefId)
258 {
259 msgRefId_ = msgRefId;
260 }
261
GetMsgRefId64Bit() const262 int64_t SmsSendIndexer::GetMsgRefId64Bit() const
263 {
264 return msgRefId64Bit_;
265 }
266
SetMsgRefId64Bit(int64_t msgRefId64Bit)267 void SmsSendIndexer::SetMsgRefId64Bit(int64_t msgRefId64Bit)
268 {
269 msgRefId64Bit_ = msgRefId64Bit;
270 }
271
GetPsResendCount() const272 uint8_t SmsSendIndexer::GetPsResendCount() const
273 {
274 return psResendCount_;
275 }
276
SetPsResendCount(uint8_t psResendCount)277 void SmsSendIndexer::SetPsResendCount(uint8_t psResendCount)
278 {
279 psResendCount_ = psResendCount;
280 }
281
UpdatePduForResend()282 void SmsSendIndexer::UpdatePduForResend()
283 {
284 if (pdu_.size() < 0x02) {
285 return;
286 }
287 if (((0x01 & pdu_[0]) == 0x01)) {
288 pdu_[0] |= 0x04; // TP-RD
289 pdu_[1] = msgRefId_; // TP-MR
290 }
291 }
292
SetDcs(enum SmsCodingScheme dcs)293 void SmsSendIndexer::SetDcs(enum SmsCodingScheme dcs)
294 {
295 dcs_ = dcs;
296 }
297
GetDcs() const298 enum SmsCodingScheme SmsSendIndexer::GetDcs() const
299 {
300 return dcs_;
301 }
302
GetIsConcat() const303 bool SmsSendIndexer::GetIsConcat() const
304 {
305 return isConcat_;
306 }
307
SetIsConcat(bool concat)308 void SmsSendIndexer::SetIsConcat(bool concat)
309 {
310 isConcat_ = concat;
311 }
312
SetSmsConcat(const SmsConcat & smsConcat)313 void SmsSendIndexer::SetSmsConcat(const SmsConcat &smsConcat)
314 {
315 smsConcat_ = smsConcat;
316 }
317
GetSmsConcat() const318 SmsConcat SmsSendIndexer::GetSmsConcat() const
319 {
320 return smsConcat_;
321 }
322
GetLangId() const323 uint8_t SmsSendIndexer::GetLangId() const
324 {
325 return langId_;
326 }
327
SetLangId(uint8_t langId)328 void SmsSendIndexer::SetLangId(uint8_t langId)
329 {
330 langId_ = langId;
331 }
332
GetMsgId() const333 uint16_t SmsSendIndexer::GetMsgId() const
334 {
335 return msgId_;
336 }
337
SetMsgId(uint16_t msgId)338 void SmsSendIndexer::SetMsgId(uint16_t msgId)
339 {
340 msgId_ = msgId;
341 }
342 } // namespace Telephony
343 } // namespace OHOS