• 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 #ifndef MAP_MSE_PARAMS_H
17 #define MAP_MSE_PARAMS_H
18 
19 #include <cstdint>
20 #include <cstring>
21 #include <memory>
22 #include <vector>
23 #include "../obex/obex_server.h"
24 #include "../obex/obex_utils.h"
25 #include "log.h"
26 #include "map_mse_types.h"
27 
28 /**
29  * @brief bluetooth namespace
30  *
31  */
32 namespace OHOS {
33 namespace bluetooth {
34 /**
35  * @brief Application Parameters class
36  *
37  */
38 struct MapMseParams {
39 public:
40     // Tag Id
41     static const uint8_t PARAM_MAX_LIST_COUNT = 0x01;
42     static const uint8_t PARAM_LIST_START_OFF_SET = 0x02;
43     static const uint8_t PARAM_FILTER_MESSAGE_TYPE = 0x03;
44     static const uint8_t PARAM_FILTER_PERIOD_BEGIN = 0x04;
45     static const uint8_t PARAM_FILTER_PERIOD_END = 0x05;
46     static const uint8_t PARAM_FILTER_READ_STATUS = 0x06;
47     static const uint8_t PARAM_FILTER_RECIPIENT = 0x07;
48     static const uint8_t PARAM_FILTER_ORIGINATOR = 0x08;
49     static const uint8_t PARAM_FILTER_PRIORITY = 0x09;
50     static const uint8_t PARAM_ATTACHMENT = 0x0A;
51     static const uint8_t PARAM_TRANSPARENT = 0x0B;
52     static const uint8_t PARAM_RETRY = 0x0C;
53     static const uint8_t PARAM_NEW_MESSAGE = 0x0D;
54     static const uint8_t PARAM_NOTIFICATION_STATUS = 0x0E;
55     static const uint8_t PARAM_MAS_INSTANCEID = 0x0F;
56     static const uint8_t PARAM_PARAMETER_MASK = 0x10;
57     static const uint8_t PARAM_FOLDER_LISTING_SIZE = 0x11;
58     static const uint8_t PARAM_LISTING_SIZE = 0x12;
59     static const uint8_t PARAM_SUBJECT_LENGTH = 0x13;
60     static const uint8_t PARAM_CHARSET = 0x14;
61     static const uint8_t PARAM_FRACTION_REQUEST = 0x15;
62     static const uint8_t PARAM_FRACTION_DELIVER = 0x16;
63     static const uint8_t PARAM_STATUS_INDICATOR = 0x17;
64     static const uint8_t PARAM_STATUS_VALUE = 0x18;
65     static const uint8_t PARAM_MSE_TIME = 0x19;
66     static const uint8_t PARAM_DATABASE_IDENTIFIER = 0x1A;
67     static const uint8_t PARAM_CONVERSATION_LISTING_VERSION_COUNTER = 0x1B;
68     static const uint8_t PARAM_PRESENCE_AVAILABILITY = 0x1C;
69     static const uint8_t PARAM_PRESENCE_TEXT = 0x1D;
70     static const uint8_t PARAM_LAST_ACTIVITY = 0x1E;
71     static const uint8_t PARAM_FILTER_LAST_ACTIVITY_BEGIN = 0x1F;
72     static const uint8_t PARAM_FILTER_LAST_ACTIVITY_END = 0x20;
73     static const uint8_t PARAM_CHAT_STATE = 0x21;
74     static const uint8_t PARAM_CONVERSATION_ID = 0x22;
75     static const uint8_t PARAM_FOLDER_VERSION_COUNTER = 0x23;
76     static const uint8_t PARAM_FILTER_MESSAGE_HANDLE = 0x24;
77     static const uint8_t PARAM_NOTIFICATION_FILTER_MASK = 0x25;
78     static const uint8_t PARAM_CONV_PARAMETER_MASK = 0x26;
79     static const uint8_t PARAM_OWNER_UCI = 0x27;
80     static const uint8_t PARAM_EXTENDED_DATA = 0x28;
81     static const uint8_t PARAM_MAP_SUPPORTED_FEATURES = 0x29;
82     static const uint8_t PARAM_MESSAGE_HANDLE = 0x2A;
83     static const uint8_t PARAM_MODIFY_TEXT = 0x2B;
84     // Tag Length
85     static const uint8_t TAG_LEN_MAX_LIST_COUNT = 0x02;
86     static const uint8_t TAG_LEN_LIST_START_OFF_SET = 0x02;
87     static const uint8_t TAG_LEN_FILTER_MESSAGE_TYPE = 0x01;
88     static const uint8_t TAG_LEN_FILTER_PERIOD_BEGIN = 0x10;
89     static const uint8_t TAG_LEN_FILTER_PERIOD_END = 0x10;
90     static const uint8_t TAG_LEN_FILTER_READ_STATUS = 0x01;
91     static const uint8_t TAG_LEN_FILTER_PRIORITY = 0x01;
92     static const uint8_t TAG_LEN_ATTACHMENT = 0x01;
93     static const uint8_t TAG_LEN_TRANSPARENT = 0x01;
94     static const uint8_t TAG_LEN_RETRY = 0x01;
95     static const uint8_t TAG_LEN_NEW_MESSAGE = 0x01;
96     static const uint8_t TAG_LEN_NOTIFICATION_STATUS = 0x01;
97     static const uint8_t TAG_LEN_MAS_INSTANCEID = 0x01;
98     static const uint8_t TAG_LEN_PARAMETER_MASK = 0x04;
99     static const uint8_t TAG_LEN_FOLDER_LISTING_SIZE = 0x02;
100     static const uint8_t TAG_LEN_LISTING_SIZE = 0x02;
101     static const uint8_t TAG_LEN_SUBJECT_LENGTH = 0x01;
102     static const uint8_t TAG_LEN_CHARSET = 0x01;
103     static const uint8_t TAG_LEN_FRACTION_REQUEST = 0x01;
104     static const uint8_t TAG_LEN_FRACTION_DELIVER = 0x01;
105     static const uint8_t TAG_LEN_STATUS_INDICATOR = 0x01;
106     static const uint8_t TAG_LEN_STATUS_VALUE = 0x01;
107     static const uint8_t TAG_LEN_DATABASE_IDENTIFIER = 0x80;
108     static const uint8_t TAG_LEN_CONVERSATION_LISTING_VERSION_COUNTER = 0x80;
109     static const uint8_t TAG_LEN_PRESENCE_AVAILABILITY = 0x01;
110     static const uint8_t TAG_LEN_CHAT_STATE = 0x01;
111     static const uint8_t TAG_LEN_CONVERSATION_ID = 0x80;
112     static const uint8_t TAG_LEN_FOLDER_VERSION_COUNTER = 0x80;
113     static const uint8_t TAG_LEN_FILTER_MESSAGE_HANDLE = 0x40;
114     static const uint8_t TAG_LEN_NOTIFICATION_FILTER_MASK = 0x04;
115     static const uint8_t TAG_LEN_CONV_PARAMETER_MASK = 0x04;
116     static const uint8_t TAG_LEN_MAP_SUPPORTED_FEATURES = 0x04;
117     static const uint8_t TAG_LEN_MESSAGE_HANDLE = 0x40;
118     static const uint8_t TAG_LEN_MODIFY_TEXT = 0x01;
119     /**
120      * @brief Construct a new Mse App Parameter:: Mse App Parameter object
121      *
122      * @param tlvTriplets Reference to the App Parameter value
123      */
124     explicit MapMseParams(const ObexTlvParamters &tlvParams);
125 
126     MapMseParams() = default;
127 
128     /**
129      * @brief Destroy the Mse App Parameter:: Mse App Parameter object
130      *
131      */
132     virtual ~MapMseParams();
133 
134     std::unique_ptr<uint8_t> transparent_ = nullptr;
135     std::unique_ptr<uint8_t> retry_ = nullptr;
136     std::string messageHandle_ = "";
137     std::unique_ptr<uint8_t> modifyText_ = nullptr;
138     uint16_t maxListCount_ = 0x400;
139     uint16_t listStartOffSet_ = 0x0;
140     std::unique_ptr<uint8_t> subjectLength_ = nullptr;
141     long parameterMask_ = -1;
142     uint16_t folderListingSize_ = 0;
143     uint16_t listingSize_ = 0;
144     std::unique_ptr<uint8_t> filterMessageType_ = nullptr;
145     std::string filterPeriodBegin_ = "";
146     std::string filterPeriodEnd_ = "";
147     std::unique_ptr<uint8_t> filterReadStatus_ = nullptr;
148     std::string filterRecipient_ = "";
149     std::string filterOriginator_ = "";
150     std::unique_ptr<uint8_t> filterPriority_ = nullptr;
151     std::string conversationId_ = "";
152     std::string filterMessageHandle_ = "";
153     std::unique_ptr<uint8_t> attachment_ = nullptr;
154     std::unique_ptr<uint8_t> charSet_ = nullptr;
155     std::unique_ptr<uint8_t> fractionRequest_ = nullptr;
156     std::unique_ptr<uint8_t> fractionDeliver_ = nullptr;
157     std::string filterLastActivityBegin_ = "";
158     std::string filterLastActivityEnd_ = "";
159     long convParameterMask_ = -1;
160     std::unique_ptr<uint8_t> presenceAvailability_ = nullptr;
161     std::string presenceText_ = "";
162     std::string lastActivity_ = "";
163     std::unique_ptr<uint8_t> chatState_ = nullptr;
164     std::unique_ptr<uint8_t> notificationStatus_ = nullptr;
165     std::unique_ptr<uint8_t> masInstanceId_ = nullptr;
166     std::unique_ptr<uint8_t> statusIndicator_ = nullptr;
167     std::unique_ptr<uint8_t> statusValue_ = nullptr;
168     std::string extendedData_ = "";
169     long notificationFilterMask_ = -1;
170     std::string ownerUci_ = "";
171 
172 private:
173     /**
174      * @brief Parse an application parameter
175      *
176      * @param tlvTriplets Reference to the application parameters
177      */
178     void ParseParameter(const std::vector<std::unique_ptr<TlvTriplet>> &tlvTriplets);
179 
180     /**
181      * @brief Transparent setting
182      *
183      * @param tlvTriplets Reference to the Transparent value
184      */
185     void SetTransparent(const std::unique_ptr<TlvTriplet> &tlvTriplet);
186 
187     /**
188      * @brief SetListStartOffSet setting
189      *
190      * @param tlvTriplet Reference to the SetListStartOffSet value
191      */
192     void SetListStartOffSet(const std::unique_ptr<TlvTriplet> &tlvTriplet);
193 
194     /**
195      * @brief set the Retry object
196      *
197      * @param tlvTriplet Reference to the Retry value
198      */
199     void SetRetry(const std::unique_ptr<TlvTriplet> &tlvTriplet);
200 
201     /**
202      * @brief Set the Message Handle object
203      *
204      * @param tlvTriplet Reference to the Message Handle Value
205      */
206     void SetMessageHandle(const std::unique_ptr<TlvTriplet> &tlvTriplet);
207 
208     /**
209      * @brief Set the Modify Text object
210      *
211      * @param tlvTriplet Reference to the Modify Text Value
212      */
213     void SetModifyText(const std::unique_ptr<TlvTriplet> &tlvTriplet);
214 
215     /**
216      * @brief Set the Max List Count object
217      *
218      * @param tlvTriplet Reference to  Max List Count Value
219      */
220     void SetMaxListCount(const std::unique_ptr<TlvTriplet> &tlvTriplet);
221 
222     /**
223      * @brief Set the Subject Length object
224      *
225      * @param tlvTriplet Reference to the Subject Length value
226      */
227     void SetSubjectLength(const std::unique_ptr<TlvTriplet> &tlvTriplet);
228 
229     /**
230      * @brief set the Parameter Mask object
231      *
232      * @param tlvTriplet Reference to the Parameter Mask value
233      */
234     void SetParameterMask(const std::unique_ptr<TlvTriplet> &tlvTriplet);
235 
236     /**
237      * @brief set the Folder Listing Size object
238      *
239      * @param tlvTriplet Reference to the Folder Listing Size value
240      */
241     void SetFolderListingSize(const std::unique_ptr<TlvTriplet> &tlvTriplet);
242 
243     /**
244      * @brief set the Listing Size object
245      *
246      * @param tlvTriplet Reference to the Listing Size value
247      */
248     void SetListingSize(const std::unique_ptr<TlvTriplet> &tlvTriplet);
249 
250     /**
251      * @brief SetFilterMessageType setting
252      *
253      * @param tlvTriplet Reference to the SetListStartOffSet value
254      */
255     void SetFilterMessageType(const std::unique_ptr<TlvTriplet> &tlvTriplet);
256 
257     /**
258      * @brief Set the Filter Period Begin object
259      *
260      * @param tlvTriplet Reference to the SetFilterOriginator value
261      */
262     void SetFilterPeriodBegin(const std::unique_ptr<TlvTriplet> &tlvTriplet);
263 
264     /**
265      * @brief Set the Filter Period End object
266      *
267      * @param tlvTriplet Reference to the SetFilterPeriodEnd value
268      */
269     void SetFilterPeriodEnd(const std::unique_ptr<TlvTriplet> &tlvTriplet);
270 
271     /**
272      * @brief Set the Filter Read Status object
273      *
274      * @param tlvTriplet Reference to the SetFilterPeriodEnd value
275      */
276     void SetFilterReadStatus(const std::unique_ptr<TlvTriplet> &tlvTriplet);
277 
278     /**
279      * @brief Set the Filter Recipient object
280      *
281      * @param tlvTriplet  Reference to the SetFilterRecipient 32_t parameterMask_;
282     std::unique_ptr<uint8_t> filterMessageType_;value
283      */
284     void SetFilterRecipient(const std::unique_ptr<TlvTriplet> &tlvTriplet);
285 
286     /**
287      * @brief Set the Filter Originator object
288      *
289      * @param tlvTriplet Reference to the SetFilterOriginator value
290      */
291     void SetFilterOriginator(const std::unique_ptr<TlvTriplet> &tlvTriplet);
292 
293     /**
294      * @brief set the Filter Priority object
295      *
296      * @param tlvTriplet  Reference to the Filter Priority value
297      */
298     void SetFilterPriority(const std::unique_ptr<TlvTriplet> &tlvTriplet);
299 
300     /**
301      * @brief Set the Conversation Id object
302      *
303      * @param tlvTriplet Reference to the Conversation Id Value
304      */
305     void SetConversationId(const std::unique_ptr<TlvTriplet> &tlvTriplet);
306 
307     /**
308      * @brief set the Filter Message Handle object
309      *
310      * @param tlvTriplet Reference to the Filter Message Handle Value
311      */
312     void SetFilterMessageHandle(const std::unique_ptr<TlvTriplet> &tlvTriplet);
313 
314     /**
315      * @brief set the Attachment object
316      *
317      * @param tlvTriplet Reference to the Attachment value
318      */
319     void SetAttachment(const std::unique_ptr<TlvTriplet> &tlvTriplet);
320 
321     /**
322      * @brief set the Charset object
323      *
324      * @param tlvTriplet Reference to the Charset value
325      */
326     void SetCharset(const std::unique_ptr<TlvTriplet> &tlvTriplet);
327 
328     /**
329      * @brief set the Fraction Request object
330      *
331      * @param tlvTriplet Reference to the Fraction Request value
332      */
333     void SetFractionRequest(const std::unique_ptr<TlvTriplet> &tlvTriplet);
334 
335     /**
336      * @brief set the Fraction Deliver object
337      *
338      * @param tlvTriplet Reference to the Fraction Deliver value
339      */
340     void SetFractionDeliver(const std::unique_ptr<TlvTriplet> &tlvTriplet);
341 
342     /**
343      * @brief Set the Filter Last Activity Begin object
344      *
345      * @param tlvTriplet Reference to the Filter Last Activity Begin Value
346      */
347     void SetFilterLastActivityBegin(const std::unique_ptr<TlvTriplet> &tlvTriplet);
348 
349     /**
350      * @brief Set Filter Last Activity End object
351      *
352      * @param tlvTriplet Reference to the Filter Last Activity End Value
353      */
354     void SetFilterLastActivityEnd(const std::unique_ptr<TlvTriplet> &tlvTriplet);
355 
356     /**
357      * @brief set the Conv Parameter Mask object
358      *
359      * @param tlvTriplet Reference to the Conv Parameter Mask Value
360      */
361     void SetConvParameterMask(const std::unique_ptr<TlvTriplet> &tlvTriplet);
362 
363     /**
364      * @brief Set the Chat State object
365      *
366      * @param tlvTriplet Reference to the Chat State Value
367      */
368     void SetChatState(const std::unique_ptr<TlvTriplet> &tlvTriplet);
369 
370     /**
371      * @brief set the Notification Status object
372      *
373      * @param tlvTriplet Reference to the Notification Status value
374      */
375     void SetNotificationStatus(const std::unique_ptr<TlvTriplet> &tlvTriplet);
376 
377     /**
378      * @brief set the MapMseInstance Id object
379      *
380      * @param tlvTriplet Reference to the MapMseInstance Id value
381      */
382     void SetMasInstanceId(const std::unique_ptr<TlvTriplet> &tlvTriplet);
383 
384     /**
385      * @brief set the Status Indicator object
386      *
387      * @param tlvTriplet Reference to the Status Indicator value
388      */
389     void SetStatusIndicator(const std::unique_ptr<TlvTriplet> &tlvTriplet);
390 
391     /**
392      * @brief set the Status Value object
393      *
394      * @param tlvTriplet Reference to the Status Value
395      */
396     void SetStatusValue(const std::unique_ptr<TlvTriplet> &tlvTriplet);
397 
398     /**
399      * @brief set the Extended Data
400      *
401      * @param tlvTriplet Reference to the Extended Data value
402      */
403     void SetExtendedData(const std::unique_ptr<TlvTriplet> &tlvTriplet);
404 
405     /**
406      * @brief Set the Notification Filter Mask object
407      *
408      * @param tlvTriplet Reference to the Notification Filter Mask Value
409      */
410     void SetNotificationFilterMask(const std::unique_ptr<TlvTriplet> &tlvTriplet);
411 
412     /**
413      * @brief Set the Owner Uci object
414      *
415      * @param tlvTriplet Reference to the Owner Uci Value
416      */
417     void SetOwnerUci(const std::unique_ptr<TlvTriplet> &tlvTriplet);
418 };
419 }  // namespace bluetooth
420 }  // namespace OHOS
421 #endif  // MAP_MSE_PARAMS_H