1/* 2 * Copyright (C) 2021-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#include "sms_send_indexer.h" 17 18namespace OHOS { 19namespace Telephony { 20using namespace std; 21SmsSendIndexer::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 28SmsSendIndexer::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 35SmsSendIndexer::~SmsSendIndexer() {} 36 37void SmsSendIndexer::SetEncodeSmca(const std::vector<uint8_t> &smca) 38{ 39 smca_ = smca; 40} 41 42void SmsSendIndexer::SetEncodeSmca(const std::vector<uint8_t> &&smca) 43{ 44 smca_ = std::forward<const std::vector<uint8_t>>(smca); 45} 46 47const std::vector<uint8_t>& SmsSendIndexer::GetEncodeSmca() const 48{ 49 return smca_; 50} 51 52void SmsSendIndexer::SetEncodePdu(const std::vector<uint8_t> &pdu) 53{ 54 pdu_ = pdu; 55} 56 57void SmsSendIndexer::SetImsSmsForCdma(const bool isImsSms) 58{ 59 isCdmaIms_ = isImsSms; 60} 61 62void SmsSendIndexer::SetEncodePdu(const std::vector<uint8_t> &&pdu) 63{ 64 pdu_ = std::forward<const std::vector<uint8_t>>(pdu); 65} 66 67const std::vector<uint8_t>& SmsSendIndexer::GetEncodePdu() const 68{ 69 return pdu_; 70} 71 72const bool &SmsSendIndexer::IsImsSmsForCdma() const 73{ 74 return isCdmaIms_; 75} 76 77bool SmsSendIndexer::GetIsFailure() const 78{ 79 return isFailure_; 80} 81 82void SmsSendIndexer::SetIsFailure(bool isFailure) 83{ 84 isFailure_ = isFailure; 85} 86 87bool SmsSendIndexer::GetHasMore() const 88{ 89 return hasMore_; 90} 91 92void SmsSendIndexer::SetHasMore(bool hasMore) 93{ 94 hasMore_ = hasMore; 95} 96 97int64_t SmsSendIndexer::GetTimeStamp() const 98{ 99 return timeStamp_; 100} 101 102void SmsSendIndexer::SetTimeStamp(int64_t timeStamp) 103{ 104 timeStamp_ = timeStamp; 105} 106 107void SmsSendIndexer::SetNetWorkType(NetWorkType netWorkType) 108{ 109 netWorkType_ = netWorkType; 110} 111 112NetWorkType SmsSendIndexer::GetNetWorkType() const 113{ 114 return netWorkType_; 115} 116 117std::shared_ptr<bool> SmsSendIndexer::GetHasCellFailed() const 118{ 119 return hasCellFailed_; 120} 121 122void SmsSendIndexer::SetHasCellFailed(const std::shared_ptr<bool> &hasCellFailed) 123{ 124 hasCellFailed_ = hasCellFailed; 125} 126 127uint8_t SmsSendIndexer::GetUnSentCellCount() const 128{ 129 return unSentCellCount_; 130} 131 132void SmsSendIndexer::SetUnSentCellCount(const uint8_t unSentCellCount) 133{ 134 unSentCellCount_ = unSentCellCount; 135} 136 137uint8_t SmsSendIndexer::GetCsResendCount() const 138{ 139 return csResendCount_; 140} 141 142void SmsSendIndexer::SetCsResendCount(uint8_t csResendCount) 143{ 144 csResendCount_ = csResendCount; 145} 146 147std::string SmsSendIndexer::GetText() const 148{ 149 return text_; 150} 151 152void SmsSendIndexer::SetText(const std::string &text) 153{ 154 text_ = text; 155} 156 157sptr<IDeliveryShortMessageCallback> SmsSendIndexer::GetDeliveryCallback() const 158{ 159 return deliveryCallback_; 160} 161 162void SmsSendIndexer::SetDeliveryCallback(const sptr<IDeliveryShortMessageCallback> &deliveryCallback) 163{ 164 deliveryCallback_ = deliveryCallback; 165} 166 167sptr<ISendShortMessageCallback> SmsSendIndexer::GetSendCallback() const 168{ 169 return sendCallback_; 170} 171 172void SmsSendIndexer::SetSendCallback(const sptr<ISendShortMessageCallback> &sendCallback) 173{ 174 sendCallback_ = sendCallback; 175} 176 177int32_t SmsSendIndexer::GetDestPort() const 178{ 179 return destPort_; 180} 181 182void SmsSendIndexer::SetDestPort(int32_t destPort) 183{ 184 destPort_ = destPort; 185} 186 187std::string SmsSendIndexer::GetDestAddr() const 188{ 189 return destAddr_; 190} 191 192void SmsSendIndexer::SetDestAddr(const std::string &destAddr) 193{ 194 destAddr_ = destAddr; 195} 196 197std::string SmsSendIndexer::GetSmcaAddr() const 198{ 199 return scAddr_; 200} 201 202void SmsSendIndexer::SetSmcaAddr(const std::string &scAddr) 203{ 204 scAddr_ = scAddr; 205} 206 207bool SmsSendIndexer::GetIsText() const 208{ 209 return isText_; 210} 211 212uint8_t SmsSendIndexer::GetErrorCode() const 213{ 214 return errorCode_; 215} 216 217void SmsSendIndexer::SetErrorCode(uint8_t errorCode) 218{ 219 errorCode_ = errorCode; 220} 221 222const std::vector<uint8_t>& SmsSendIndexer::GetData() const 223{ 224 return data_; 225} 226 227void SmsSendIndexer::SetData(const std::vector<uint8_t> &data) 228{ 229 data_ = data; 230} 231 232void SmsSendIndexer::SetData(const std::vector<uint8_t> &&data) 233{ 234 data_ = std::forward<const std::vector<uint8_t>>(data); 235} 236 237const std::vector<uint8_t>& SmsSendIndexer::GetAckPdu() const 238{ 239 return ackPdu_; 240} 241 242void SmsSendIndexer::SetAckPdu(const std::vector<uint8_t> &ackPdu) 243{ 244 ackPdu_ = ackPdu; 245} 246 247void SmsSendIndexer::SetAckPdu(const std::vector<uint8_t> &&ackPdu) 248{ 249 ackPdu_ = std::forward<const std::vector<uint8_t>>(ackPdu); 250} 251 252uint8_t SmsSendIndexer::GetMsgRefId() const 253{ 254 return msgRefId_; 255} 256 257void SmsSendIndexer::SetMsgRefId(uint8_t msgRefId) 258{ 259 msgRefId_ = msgRefId; 260} 261 262int64_t SmsSendIndexer::GetMsgRefId64Bit() const 263{ 264 return msgRefId64Bit_; 265} 266 267void SmsSendIndexer::SetMsgRefId64Bit(int64_t msgRefId64Bit) 268{ 269 msgRefId64Bit_ = msgRefId64Bit; 270} 271 272uint8_t SmsSendIndexer::GetPsResendCount() const 273{ 274 return psResendCount_; 275} 276 277void SmsSendIndexer::SetPsResendCount(uint8_t psResendCount) 278{ 279 psResendCount_ = psResendCount; 280} 281 282void 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 293void SmsSendIndexer::SetDcs(enum DataCodingScheme dcs) 294{ 295 dcs_ = dcs; 296} 297 298enum DataCodingScheme SmsSendIndexer::GetDcs() const 299{ 300 return dcs_; 301} 302 303bool SmsSendIndexer::GetIsConcat() const 304{ 305 return isConcat_; 306} 307 308void SmsSendIndexer::SetIsConcat(bool concat) 309{ 310 isConcat_ = concat; 311} 312 313void SmsSendIndexer::SetSmsConcat(const SmsConcat &smsConcat) 314{ 315 smsConcat_ = smsConcat; 316} 317 318SmsConcat SmsSendIndexer::GetSmsConcat() const 319{ 320 return smsConcat_; 321} 322 323uint8_t SmsSendIndexer::GetLangId() const 324{ 325 return langId_; 326} 327 328void SmsSendIndexer::SetLangId(uint8_t langId) 329{ 330 langId_ = langId; 331} 332 333uint16_t SmsSendIndexer::GetMsgId() const 334{ 335 return msgId_; 336} 337 338void SmsSendIndexer::SetMsgId(uint16_t msgId) 339{ 340 msgId_ = msgId; 341} 342 343uint16_t SmsSendIndexer::GetDataBaseId() const 344{ 345 return dataBaseId_; 346} 347 348void SmsSendIndexer::SetDataBaseId(uint16_t databaseId) 349{ 350 dataBaseId_ = databaseId; 351} 352 353bool SmsSendIndexer::GetIsMmsApp() const 354{ 355 return isMmsApp_; 356} 357 358void SmsSendIndexer::SetIsMmsApp(bool isMmsApp) 359{ 360 isMmsApp_ = isMmsApp; 361} 362} // namespace Telephony 363} // namespace OHOS