• 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 "map_mse_params.h"
17 
18 namespace OHOS {
19 namespace bluetooth {
20 // Tag Id
21 const uint8_t MapMseParams::PARAM_MAX_LIST_COUNT;
22 const uint8_t MapMseParams::PARAM_LIST_START_OFF_SET;
23 const uint8_t MapMseParams::PARAM_FILTER_MESSAGE_TYPE;
24 const uint8_t MapMseParams::PARAM_FILTER_PERIOD_BEGIN;
25 const uint8_t MapMseParams::PARAM_FILTER_PERIOD_END;
26 const uint8_t MapMseParams::PARAM_FILTER_READ_STATUS;
27 const uint8_t MapMseParams::PARAM_FILTER_RECIPIENT;
28 const uint8_t MapMseParams::PARAM_FILTER_ORIGINATOR;
29 const uint8_t MapMseParams::PARAM_FILTER_PRIORITY;
30 const uint8_t MapMseParams::PARAM_ATTACHMENT;
31 const uint8_t MapMseParams::PARAM_TRANSPARENT;
32 const uint8_t MapMseParams::PARAM_RETRY;
33 const uint8_t MapMseParams::PARAM_NEW_MESSAGE;
34 const uint8_t MapMseParams::PARAM_NOTIFICATION_STATUS;
35 const uint8_t MapMseParams::PARAM_MAS_INSTANCEID;
36 const uint8_t MapMseParams::PARAM_PARAMETER_MASK;
37 const uint8_t MapMseParams::PARAM_FOLDER_LISTING_SIZE;
38 const uint8_t MapMseParams::PARAM_LISTING_SIZE;
39 const uint8_t MapMseParams::PARAM_SUBJECT_LENGTH;
40 const uint8_t MapMseParams::PARAM_CHARSET;
41 const uint8_t MapMseParams::PARAM_FRACTION_REQUEST;
42 const uint8_t MapMseParams::PARAM_FRACTION_DELIVER;
43 const uint8_t MapMseParams::PARAM_STATUS_INDICATOR;
44 const uint8_t MapMseParams::PARAM_STATUS_VALUE;
45 const uint8_t MapMseParams::PARAM_MSE_TIME;
46 const uint8_t MapMseParams::PARAM_DATABASE_IDENTIFIER;
47 const uint8_t MapMseParams::PARAM_CONVERSATION_LISTING_VERSION_COUNTER;
48 const uint8_t MapMseParams::PARAM_PRESENCE_AVAILABILITY;
49 const uint8_t MapMseParams::PARAM_PRESENCE_TEXT;
50 const uint8_t MapMseParams::PARAM_LAST_ACTIVITY;
51 const uint8_t MapMseParams::PARAM_FILTER_LAST_ACTIVITY_BEGIN;
52 const uint8_t MapMseParams::PARAM_FILTER_LAST_ACTIVITY_END;
53 const uint8_t MapMseParams::PARAM_CHAT_STATE;
54 const uint8_t MapMseParams::PARAM_CONVERSATION_ID;
55 const uint8_t MapMseParams::PARAM_FOLDER_VERSION_COUNTER;
56 const uint8_t MapMseParams::PARAM_FILTER_MESSAGE_HANDLE;
57 const uint8_t MapMseParams::PARAM_NOTIFICATION_FILTER_MASK;
58 const uint8_t MapMseParams::PARAM_CONV_PARAMETER_MASK;
59 const uint8_t MapMseParams::PARAM_OWNER_UCI;
60 const uint8_t MapMseParams::PARAM_EXTENDED_DATA;
61 const uint8_t MapMseParams::PARAM_MAP_SUPPORTED_FEATURES;
62 const uint8_t MapMseParams::PARAM_MESSAGE_HANDLE;
63 const uint8_t MapMseParams::PARAM_MODIFY_TEXT;
64 // Tag Length
65 const uint8_t MapMseParams::TAG_LEN_MAX_LIST_COUNT;
66 const uint8_t MapMseParams::TAG_LEN_LIST_START_OFF_SET;
67 const uint8_t MapMseParams::TAG_LEN_FILTER_MESSAGE_TYPE;
68 const uint8_t MapMseParams::TAG_LEN_FILTER_PERIOD_BEGIN;
69 const uint8_t MapMseParams::TAG_LEN_FILTER_PERIOD_END;
70 const uint8_t MapMseParams::TAG_LEN_FILTER_READ_STATUS;
71 const uint8_t MapMseParams::TAG_LEN_FILTER_PRIORITY;
72 const uint8_t MapMseParams::TAG_LEN_ATTACHMENT;
73 const uint8_t MapMseParams::TAG_LEN_TRANSPARENT;
74 const uint8_t MapMseParams::TAG_LEN_RETRY;
75 const uint8_t MapMseParams::TAG_LEN_NEW_MESSAGE;
76 const uint8_t MapMseParams::TAG_LEN_NOTIFICATION_STATUS;
77 const uint8_t MapMseParams::TAG_LEN_MAS_INSTANCEID;
78 const uint8_t MapMseParams::TAG_LEN_PARAMETER_MASK;
79 const uint8_t MapMseParams::TAG_LEN_FOLDER_LISTING_SIZE;
80 const uint8_t MapMseParams::TAG_LEN_LISTING_SIZE;
81 const uint8_t MapMseParams::TAG_LEN_SUBJECT_LENGTH;
82 const uint8_t MapMseParams::TAG_LEN_CHARSET;
83 const uint8_t MapMseParams::TAG_LEN_FRACTION_REQUEST;
84 const uint8_t MapMseParams::TAG_LEN_FRACTION_DELIVER;
85 const uint8_t MapMseParams::TAG_LEN_STATUS_INDICATOR;
86 const uint8_t MapMseParams::TAG_LEN_STATUS_VALUE;
87 const uint8_t MapMseParams::TAG_LEN_DATABASE_IDENTIFIER;
88 const uint8_t MapMseParams::TAG_LEN_CONVERSATION_LISTING_VERSION_COUNTER;
89 const uint8_t MapMseParams::TAG_LEN_PRESENCE_AVAILABILITY;
90 const uint8_t MapMseParams::TAG_LEN_CHAT_STATE;
91 const uint8_t MapMseParams::TAG_LEN_CONVERSATION_ID;
92 const uint8_t MapMseParams::TAG_LEN_FOLDER_VERSION_COUNTER;
93 const uint8_t MapMseParams::TAG_LEN_FILTER_MESSAGE_HANDLE;
94 const uint8_t MapMseParams::TAG_LEN_NOTIFICATION_FILTER_MASK;
95 const uint8_t MapMseParams::TAG_LEN_CONV_PARAMETER_MASK;
96 const uint8_t MapMseParams::TAG_LEN_MAP_SUPPORTED_FEATURES;
97 const uint8_t MapMseParams::TAG_LEN_MESSAGE_HANDLE;
98 const uint8_t MapMseParams::TAG_LEN_MODIFY_TEXT;
MapMseParams(const ObexTlvParamters & tlvParams)99 MapMseParams::MapMseParams(const ObexTlvParamters &tlvParams)
100 {
101     ParseParameter(tlvParams.GetTlvTriplets());
102 }
103 
~MapMseParams()104 MapMseParams::~MapMseParams()
105 {}
106 
SetMaxListCount(const std::unique_ptr<TlvTriplet> & tlvTriplet)107 void MapMseParams::SetMaxListCount(const std::unique_ptr<TlvTriplet> &tlvTriplet)
108 {
109     if (tlvTriplet->GetLen() > TAG_LEN_MAX_LIST_COUNT) {
110         MSE_LOG_ERROR("MAX_LIST_COUNT: Wrong length received: %hhx expected: less than %hhx",
111             tlvTriplet->GetLen(),
112             TAG_LEN_MAX_LIST_COUNT);
113         return;
114     }
115     maxListCount_ = tlvTriplet->GetUint16();
116 }
117 
SetListStartOffSet(const std::unique_ptr<TlvTriplet> & tlvTriplet)118 void MapMseParams::SetListStartOffSet(const std::unique_ptr<TlvTriplet> &tlvTriplet)
119 {
120     if (tlvTriplet->GetLen() > TAG_LEN_LIST_START_OFF_SET) {
121         MSE_LOG_ERROR("LIST_START_OFF_SET: Wrong length received: %hhx expected: less than %hhx",
122             tlvTriplet->GetLen(),
123             TAG_LEN_LIST_START_OFF_SET);
124         return;
125     }
126     listStartOffSet_ = tlvTriplet->GetUint16();
127 }
128 
SetFilterMessageType(const std::unique_ptr<TlvTriplet> & tlvTriplet)129 void MapMseParams::SetFilterMessageType(const std::unique_ptr<TlvTriplet> &tlvTriplet)
130 {
131     if (tlvTriplet->GetLen() != TAG_LEN_FILTER_MESSAGE_TYPE) {
132         MSE_LOG_ERROR("FILTER_MESSAGE_TYPE: Wrong length received: %hhx expected: %hhx",
133             tlvTriplet->GetLen(),
134             TAG_LEN_FILTER_MESSAGE_TYPE);
135         return;
136     }
137     filterMessageType_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
138 }
139 
SetFilterOriginator(const std::unique_ptr<TlvTriplet> & tlvTriplet)140 void MapMseParams::SetFilterOriginator(const std::unique_ptr<TlvTriplet> &tlvTriplet)
141 {
142     if (tlvTriplet->GetLen() == 0x00) {
143         MSE_LOG_ERROR("FILTER_ORIGINATOR: Wrong length received: %hhx expected to be more than 0",
144             tlvTriplet->GetLen());
145         return;
146     }
147     filterOriginator_ = std::string((char *)tlvTriplet->GetVal(), tlvTriplet->GetLen());
148 }
149 
SetFilterPeriodBegin(const std::unique_ptr<TlvTriplet> & tlvTriplet)150 void MapMseParams::SetFilterPeriodBegin(const std::unique_ptr<TlvTriplet> &tlvTriplet)
151 {
152     if (tlvTriplet->GetLen() > TAG_LEN_FILTER_PERIOD_BEGIN) {
153         MSE_LOG_ERROR("FILTER_PERIOD_BEGIN: Wrong length received: %hhx expected: less than %hhx",
154             tlvTriplet->GetLen(),
155             TAG_LEN_FILTER_PERIOD_BEGIN);
156         return;
157     }
158     std::string ymdhmsStr((char *)tlvTriplet->GetVal(), tlvTriplet->GetLen());
159     filterPeriodBegin_ = ymdhmsStr;
160 }
161 
SetFilterPeriodEnd(const std::unique_ptr<TlvTriplet> & tlvTriplet)162 void MapMseParams::SetFilterPeriodEnd(const std::unique_ptr<TlvTriplet> &tlvTriplet)
163 {
164     if (tlvTriplet->GetLen() > TAG_LEN_FILTER_PERIOD_END) {
165         MSE_LOG_ERROR("END_FILTER_PERIOD_END: Wrong length received: %hhx expected: less than %hhx",
166             tlvTriplet->GetLen(),
167             TAG_LEN_FILTER_PERIOD_END);
168         return;
169     }
170     std::string ymdhmsStr((char *)tlvTriplet->GetVal(), tlvTriplet->GetLen());
171     filterPeriodEnd_ = ymdhmsStr;
172 }
173 
SetFilterReadStatus(const std::unique_ptr<TlvTriplet> & tlvTriplet)174 void MapMseParams::SetFilterReadStatus(const std::unique_ptr<TlvTriplet> &tlvTriplet)
175 {
176     if (tlvTriplet->GetLen() != TAG_LEN_FILTER_READ_STATUS) {
177         MSE_LOG_ERROR("FILTER_READ_STATUS: Wrong length received: %hhx expected: %hhx",
178             tlvTriplet->GetLen(),
179             TAG_LEN_FILTER_READ_STATUS);
180         return;
181     }
182     filterReadStatus_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
183 }
184 
SetFilterRecipient(const std::unique_ptr<TlvTriplet> & tlvTriplet)185 void MapMseParams::SetFilterRecipient(const std::unique_ptr<TlvTriplet> &tlvTriplet)
186 {
187     if (tlvTriplet->GetLen() == 0x00) {
188         MSE_LOG_ERROR("FILTER_RECIPIENT: Wrong length received: %hhx expected to be more than 0",
189             tlvTriplet->GetLen());
190         return;
191     }
192     filterRecipient_ = std::string((char *)tlvTriplet->GetVal(), tlvTriplet->GetLen());
193 }
194 
SetFilterPriority(const std::unique_ptr<TlvTriplet> & tlvTriplet)195 void MapMseParams::SetFilterPriority(const std::unique_ptr<TlvTriplet> &tlvTriplet)
196 {
197     if (tlvTriplet->GetLen() != TAG_LEN_FILTER_PRIORITY) {
198         MSE_LOG_ERROR("FILTER_PRIORITY: Wrong length received: %hhx expected: %hhx",
199             tlvTriplet->GetLen(),
200             TAG_LEN_FILTER_PRIORITY);
201         return;
202     }
203     filterPriority_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
204 }
205 
SetAttachment(const std::unique_ptr<TlvTriplet> & tlvTriplet)206 void MapMseParams::SetAttachment(const std::unique_ptr<TlvTriplet> &tlvTriplet)
207 {
208     if (tlvTriplet->GetLen() != TAG_LEN_ATTACHMENT) {
209         MSE_LOG_ERROR("ATTACHMENT: Wrong length received: %hhx expected: %hhx",
210             tlvTriplet->GetLen(),
211             TAG_LEN_ATTACHMENT);
212         return;
213     }
214     attachment_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
215 }
216 
SetTransparent(const std::unique_ptr<TlvTriplet> & tlvTriplet)217 void MapMseParams::SetTransparent(const std::unique_ptr<TlvTriplet> &tlvTriplet)
218 {
219     if (tlvTriplet->GetLen() != TAG_LEN_TRANSPARENT) {
220         MSE_LOG_ERROR("TRANSPARENT: Wrong length received: %hhx expected: %hhx",
221             tlvTriplet->GetLen(),
222             TAG_LEN_TRANSPARENT);
223         return;
224     }
225     transparent_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
226 }
227 
SetRetry(const std::unique_ptr<TlvTriplet> & tlvTriplet)228 void MapMseParams::SetRetry(const std::unique_ptr<TlvTriplet> &tlvTriplet)
229 {
230     if (tlvTriplet->GetLen() != TAG_LEN_RETRY) {
231         MSE_LOG_ERROR("RETRY: Wrong length received: %hhx expected: %hhx",
232             tlvTriplet->GetLen(),
233             TAG_LEN_RETRY);
234         return;
235     }
236     retry_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
237 }
238 
SetNotificationStatus(const std::unique_ptr<TlvTriplet> & tlvTriplet)239 void MapMseParams::SetNotificationStatus(const std::unique_ptr<TlvTriplet> &tlvTriplet)
240 {
241     if (tlvTriplet->GetLen() != TAG_LEN_NOTIFICATION_STATUS) {
242         MSE_LOG_ERROR("NOTIFICATION_STATUS: Wrong length received: %hhx expected: %hhx",
243             tlvTriplet->GetLen(),
244             TAG_LEN_NOTIFICATION_STATUS);
245         return;
246     }
247     notificationStatus_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
248 }
249 
SetMasInstanceId(const std::unique_ptr<TlvTriplet> & tlvTriplet)250 void MapMseParams::SetMasInstanceId(const std::unique_ptr<TlvTriplet> &tlvTriplet)
251 {
252     if (tlvTriplet->GetLen() != TAG_LEN_MAS_INSTANCEID) {
253         MSE_LOG_ERROR("MAS_INSTANCEID: Wrong length received: %hhx expected: %hhx",
254             tlvTriplet->GetLen(),
255             TAG_LEN_MAS_INSTANCEID);
256         return;
257     }
258     masInstanceId_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
259 }
260 
SetParameterMask(const std::unique_ptr<TlvTriplet> & tlvTriplet)261 void MapMseParams::SetParameterMask(const std::unique_ptr<TlvTriplet> &tlvTriplet)
262 {
263     if (tlvTriplet->GetLen() > TAG_LEN_PARAMETER_MASK) {
264         MSE_LOG_ERROR("PARAMETER_MASK: Wrong length received: %hhx expected: %hhx",
265             tlvTriplet->GetLen(),
266             TAG_LEN_PARAMETER_MASK);
267         return;
268     }
269     parameterMask_ = tlvTriplet->GetUint32();
270 }
271 
SetFolderListingSize(const std::unique_ptr<TlvTriplet> & tlvTriplet)272 void MapMseParams::SetFolderListingSize(const std::unique_ptr<TlvTriplet> &tlvTriplet)
273 {
274     if (tlvTriplet->GetLen() > TAG_LEN_FOLDER_LISTING_SIZE) {
275         MSE_LOG_ERROR("FOLDER_LISTING_SIZE: Wrong length received: %hhx expected: less than %hhx",
276             tlvTriplet->GetLen(),
277             TAG_LEN_FOLDER_LISTING_SIZE);
278         return;
279     }
280     folderListingSize_ = tlvTriplet->GetUint16();
281 }
282 
SetListingSize(const std::unique_ptr<TlvTriplet> & tlvTriplet)283 void MapMseParams::SetListingSize(const std::unique_ptr<TlvTriplet> &tlvTriplet)
284 {
285     if (tlvTriplet->GetLen() > TAG_LEN_LISTING_SIZE) {
286         MSE_LOG_ERROR("LISTING_SIZE: Wrong length received: %hhx expected: less than %hhx",
287             tlvTriplet->GetLen(),
288             TAG_LEN_LISTING_SIZE);
289         return;
290     }
291     listingSize_ = tlvTriplet->GetUint16();
292 }
293 
SetSubjectLength(const std::unique_ptr<TlvTriplet> & tlvTriplet)294 void MapMseParams::SetSubjectLength(const std::unique_ptr<TlvTriplet> &tlvTriplet)
295 {
296     if (tlvTriplet->GetLen() != TAG_LEN_SUBJECT_LENGTH) {
297         MSE_LOG_ERROR("SUBJECT_LENGTH: Wrong length received: %hhx expected: %hhx",
298             tlvTriplet->GetLen(),
299             TAG_LEN_SUBJECT_LENGTH);
300         return;
301     }
302     subjectLength_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
303 }
304 
SetCharset(const std::unique_ptr<TlvTriplet> & tlvTriplet)305 void MapMseParams::SetCharset(const std::unique_ptr<TlvTriplet> &tlvTriplet)
306 {
307     if (tlvTriplet->GetLen() != TAG_LEN_CHARSET) {
308         MSE_LOG_ERROR("CHARSET: Wrong length received: %hhx expected: %hhx",
309             tlvTriplet->GetLen(),
310             TAG_LEN_CHARSET);
311         return;
312     }
313     charSet_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
314 }
315 
SetFractionRequest(const std::unique_ptr<TlvTriplet> & tlvTriplet)316 void MapMseParams::SetFractionRequest(const std::unique_ptr<TlvTriplet> &tlvTriplet)
317 {
318     if (tlvTriplet->GetLen() != TAG_LEN_FRACTION_REQUEST) {
319         MSE_LOG_ERROR("FRACTION_REQUEST: Wrong length received: %hhx expected: %hhx",
320             tlvTriplet->GetLen(),
321             TAG_LEN_FRACTION_REQUEST);
322         return;
323     }
324     fractionRequest_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
325 }
326 
SetFractionDeliver(const std::unique_ptr<TlvTriplet> & tlvTriplet)327 void MapMseParams::SetFractionDeliver(const std::unique_ptr<TlvTriplet> &tlvTriplet)
328 {
329     if (tlvTriplet->GetLen() != TAG_LEN_FRACTION_DELIVER) {
330         MSE_LOG_ERROR("FRACTION_DELIVER: Wrong length received: %hhx expected: %hhx",
331             tlvTriplet->GetLen(),
332             TAG_LEN_FRACTION_DELIVER);
333         return;
334     }
335     fractionDeliver_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
336 }
337 
SetStatusIndicator(const std::unique_ptr<TlvTriplet> & tlvTriplet)338 void MapMseParams::SetStatusIndicator(const std::unique_ptr<TlvTriplet> &tlvTriplet)
339 {
340     if (tlvTriplet->GetLen() != TAG_LEN_STATUS_INDICATOR) {
341         MSE_LOG_ERROR("STATUS_INDICATOR: Wrong length received: %hhx expected: %hhx",
342             tlvTriplet->GetLen(),
343             TAG_LEN_STATUS_INDICATOR);
344         return;
345     }
346     statusIndicator_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
347 }
348 
SetStatusValue(const std::unique_ptr<TlvTriplet> & tlvTriplet)349 void MapMseParams::SetStatusValue(const std::unique_ptr<TlvTriplet> &tlvTriplet)
350 {
351     if (tlvTriplet->GetLen() != TAG_LEN_STATUS_VALUE) {
352         MSE_LOG_ERROR(
353             "STATUS_VALUE: Wrong length received: %hhx expected: %hhx", tlvTriplet->GetLen(), TAG_LEN_STATUS_VALUE);
354         return;
355     }
356     statusValue_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
357 }
358 
SetExtendedData(const std::unique_ptr<TlvTriplet> & tlvTriplet)359 void MapMseParams::SetExtendedData(const std::unique_ptr<TlvTriplet> &tlvTriplet)
360 {
361     extendedData_ = std::string((char *)tlvTriplet->GetVal(), tlvTriplet->GetLen());
362 }
363 
SetFilterLastActivityBegin(const std::unique_ptr<TlvTriplet> & tlvTriplet)364 void MapMseParams::SetFilterLastActivityBegin(const std::unique_ptr<TlvTriplet> &tlvTriplet)
365 {
366     if (tlvTriplet->GetLen() == 0x00) {
367         MSE_LOG_ERROR("FILTER_LAST_ACTIVITY_BEGIN: Wrong length received: %hhx expected to be more than 0",
368             tlvTriplet->GetLen());
369         return;
370     }
371     filterLastActivityBegin_ = std::string((char *)tlvTriplet->GetVal(), tlvTriplet->GetLen());
372 }
373 
SetFilterLastActivityEnd(const std::unique_ptr<TlvTriplet> & tlvTriplet)374 void MapMseParams::SetFilterLastActivityEnd(const std::unique_ptr<TlvTriplet> &tlvTriplet)
375 {
376     if (tlvTriplet->GetLen() == 0x00) {
377         MSE_LOG_ERROR("FILTER_LAST_ACTIVITY_END: Wrong length received: %hhx expected to be more than 0",
378             tlvTriplet->GetLen());
379         return;
380     }
381     filterLastActivityEnd_ = std::string((char *)tlvTriplet->GetVal(), tlvTriplet->GetLen());
382 }
383 
SetChatState(const std::unique_ptr<TlvTriplet> & tlvTriplet)384 void MapMseParams::SetChatState(const std::unique_ptr<TlvTriplet> &tlvTriplet)
385 {
386     if (tlvTriplet->GetLen() != TAG_LEN_CHAT_STATE) {
387         MSE_LOG_ERROR("CHAT_STATE: Wrong length received: %hhx expected: %hhx",
388             tlvTriplet->GetLen(),
389             TAG_LEN_CHAT_STATE);
390         return;
391     }
392     chatState_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
393 }
394 
SetConversationId(const std::unique_ptr<TlvTriplet> & tlvTriplet)395 void MapMseParams::SetConversationId(const std::unique_ptr<TlvTriplet> &tlvTriplet)
396 {
397     if (tlvTriplet->GetLen() > TAG_LEN_CONVERSATION_ID) {
398         MSE_LOG_ERROR("CONVERSATION_ID: Wrong length received: %hhx expected to be less than %hhx",
399             tlvTriplet->GetLen(),
400             TAG_LEN_CONVERSATION_ID);
401         return;
402     }
403     conversationId_ = std::string((char *)tlvTriplet->GetVal(), tlvTriplet->GetLen());
404 }
405 
SetNotificationFilterMask(const std::unique_ptr<TlvTriplet> & tlvTriplet)406 void MapMseParams::SetNotificationFilterMask(const std::unique_ptr<TlvTriplet> &tlvTriplet)
407 {
408     if (tlvTriplet->GetLen() != TAG_LEN_NOTIFICATION_FILTER_MASK) {
409         MSE_LOG_ERROR("NOTIFICATION_FILTER_MASK: Wrong length received: %hhx expected: %hhx",
410             tlvTriplet->GetLen(),
411             TAG_LEN_NOTIFICATION_FILTER_MASK);
412         return;
413     }
414     notificationFilterMask_ = tlvTriplet->GetUint32();
415 }
416 
SetFilterMessageHandle(const std::unique_ptr<TlvTriplet> & tlvTriplet)417 void MapMseParams::SetFilterMessageHandle(const std::unique_ptr<TlvTriplet> &tlvTriplet)
418 {
419     if (tlvTriplet->GetLen() > TAG_LEN_FILTER_MESSAGE_HANDLE) {
420         MSE_LOG_ERROR("FILTER_MESSAGE_HANDLE: Wrong length received: %hhx expected to be less than %hhx",
421             tlvTriplet->GetLen(),
422             TAG_LEN_FILTER_MESSAGE_HANDLE);
423         return;
424     }
425     filterMessageHandle_ = std::string((char *)tlvTriplet->GetVal(), tlvTriplet->GetLen());
426 }
427 
SetConvParameterMask(const std::unique_ptr<TlvTriplet> & tlvTriplet)428 void MapMseParams::SetConvParameterMask(const std::unique_ptr<TlvTriplet> &tlvTriplet)
429 {
430     if (tlvTriplet->GetLen() != TAG_LEN_CONV_PARAMETER_MASK) {
431         MSE_LOG_ERROR("CONV_PARAMETER_MASK: Wrong length received: %hhx expected: %hhx",
432             tlvTriplet->GetLen(),
433             TAG_LEN_CONV_PARAMETER_MASK);
434         return;
435     }
436     convParameterMask_ = tlvTriplet->GetUint32();
437 }
438 
SetOwnerUci(const std::unique_ptr<TlvTriplet> & tlvTriplet)439 void MapMseParams::SetOwnerUci(const std::unique_ptr<TlvTriplet> &tlvTriplet)
440 {
441     if (tlvTriplet->GetLen() == 0x00) {
442         MSE_LOG_ERROR("OWNER_UCI: Wrong length received: %hhx expected to be more than 0",
443             tlvTriplet->GetLen());
444         return;
445     }
446     ownerUci_ = std::string((char *)tlvTriplet->GetVal(), tlvTriplet->GetLen());
447 }
448 
SetModifyText(const std::unique_ptr<TlvTriplet> & tlvTriplet)449 void MapMseParams::SetModifyText(const std::unique_ptr<TlvTriplet> &tlvTriplet)
450 {
451     if (tlvTriplet->GetLen() != TAG_LEN_MODIFY_TEXT) {
452         MSE_LOG_ERROR("MODIFY_TEXT: Wrong length received: %hhx expected: %hhx",
453             tlvTriplet->GetLen(),
454             TAG_LEN_MODIFY_TEXT);
455         return;
456     }
457     modifyText_ = std::make_unique<uint8_t>(tlvTriplet->GetVal()[0]);
458 }
459 
SetMessageHandle(const std::unique_ptr<TlvTriplet> & tlvTriplet)460 void MapMseParams::SetMessageHandle(const std::unique_ptr<TlvTriplet> &tlvTriplet)
461 {
462     if (tlvTriplet->GetLen() > TAG_LEN_MESSAGE_HANDLE) {
463         MSE_LOG_ERROR("MESSAGE_HANDLE: Wrong length received: %hhx expected to be less than %hhx",
464             tlvTriplet->GetLen(),
465             TAG_LEN_MESSAGE_HANDLE);
466         return;
467     }
468     messageHandle_ = std::string((char *)tlvTriplet->GetVal(), tlvTriplet->GetLen());
469 }
470 
ParseParameter(const std::vector<std::unique_ptr<TlvTriplet>> & tlvTriplets)471 void MapMseParams::ParseParameter(const std::vector<std::unique_ptr<TlvTriplet>> &tlvTriplets)
472 {
473     for (auto &para : tlvTriplets) {
474         switch (para->GetTagId()) {
475             case PARAM_MAX_LIST_COUNT:
476                 SetMaxListCount(para);
477                 break;
478             case PARAM_LIST_START_OFF_SET:
479                 SetListStartOffSet(para);
480                 break;
481             case PARAM_FILTER_MESSAGE_TYPE:
482                 SetFilterMessageType(para);
483                 break;
484             case PARAM_FILTER_PERIOD_BEGIN:
485                 SetFilterPeriodBegin(para);
486                 break;
487             case PARAM_FILTER_PERIOD_END:
488                 SetFilterPeriodEnd(para);
489                 break;
490             case PARAM_FILTER_READ_STATUS:
491                 SetFilterReadStatus(para);
492                 break;
493             case PARAM_FILTER_RECIPIENT:
494                 SetFilterRecipient(para);
495                 break;
496             case PARAM_FILTER_ORIGINATOR:
497                 SetFilterOriginator(para);
498                 break;
499             case PARAM_FILTER_PRIORITY:
500                 SetFilterPriority(para);
501                 break;
502             case PARAM_ATTACHMENT:
503                 SetAttachment(para);
504                 break;
505             case PARAM_TRANSPARENT:
506                 SetTransparent(para);
507                 break;
508             case PARAM_RETRY:
509                 SetRetry(para);
510                 break;
511             case PARAM_NEW_MESSAGE:
512                 break;
513             case PARAM_NOTIFICATION_STATUS:
514                 SetNotificationStatus(para);
515                 break;
516             case PARAM_MAS_INSTANCEID:
517                 SetMasInstanceId(para);
518                 break;
519             case PARAM_PARAMETER_MASK:
520                 SetParameterMask(para);
521                 break;
522             case PARAM_FOLDER_LISTING_SIZE:
523                 SetFolderListingSize(para);
524                 break;
525             case PARAM_LISTING_SIZE:
526                 SetListingSize(para);
527                 break;
528             case PARAM_SUBJECT_LENGTH:
529                 SetSubjectLength(para);
530                 break;
531             case PARAM_CHARSET:
532                 SetCharset(para);
533                 break;
534             case PARAM_FRACTION_REQUEST:
535                 SetFractionRequest(para);
536                 break;
537             case PARAM_FRACTION_DELIVER:
538                 SetFractionDeliver(para);
539                 break;
540             case PARAM_STATUS_INDICATOR:
541                 SetStatusIndicator(para);
542                 break;
543             case PARAM_STATUS_VALUE:
544                 SetStatusValue(para);
545                 break;
546             case PARAM_MSE_TIME:
547                 break;
548             case PARAM_DATABASE_IDENTIFIER:
549                 break;
550             case PARAM_CONVERSATION_LISTING_VERSION_COUNTER:
551                 break;
552             case PARAM_PRESENCE_AVAILABILITY:
553                 break;
554             case PARAM_PRESENCE_TEXT:
555                 break;
556             case PARAM_LAST_ACTIVITY:
557                 break;
558             case PARAM_FILTER_LAST_ACTIVITY_BEGIN:
559                 SetFilterLastActivityBegin(para);
560                 break;
561             case PARAM_FILTER_LAST_ACTIVITY_END:
562                 SetFilterLastActivityEnd(para);
563                 break;
564             case PARAM_CHAT_STATE:
565                 SetChatState(para);
566                 break;
567             case PARAM_CONVERSATION_ID:
568                 SetConversationId(para);
569                 break;
570             case PARAM_FOLDER_VERSION_COUNTER:
571                 break;
572             case PARAM_FILTER_MESSAGE_HANDLE:
573                 SetFilterMessageHandle(para);
574                 break;
575             case PARAM_NOTIFICATION_FILTER_MASK:
576                 SetNotificationFilterMask(para);
577                 break;
578             case PARAM_CONV_PARAMETER_MASK:
579                 SetConvParameterMask(para);
580                 break;
581             case PARAM_OWNER_UCI:
582                 SetOwnerUci(para);
583                 break;
584             case PARAM_EXTENDED_DATA:
585                 SetExtendedData(para);
586                 break;
587             case PARAM_MODIFY_TEXT:
588                 SetModifyText(para);
589                 break;
590             case PARAM_MESSAGE_HANDLE:
591                 SetMessageHandle(para);
592                 break;
593             default:
594                 break;
595         }
596     }
597 }
598 }  // namespace bluetooth
599 }  // namespace OHOS
600