• 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 /**
17  * @addtogroup Bluetooth
18  * @{
19  *
20  * @brief Defines map client service request data analyse object.
21  *
22  */
23 
24 /**
25  * @file map_mce_data_analyse.h
26  *
27  * @brief map client service request data analyse header file .
28  *
29  */
30 
31 #ifndef MAP_MCE_DATA_ANALYSE_H
32 #define MAP_MCE_DATA_ANALYSE_H
33 
34 #include <cstdint>
35 #include <list>
36 #include <map>
37 #include <sstream>
38 #include <string>
39 #include <vector>
40 #include "interface_profile_map_mce.h"
41 #include "map_mce_xml.h"
42 
43 namespace OHOS {
44 namespace bluetooth {
45 enum MceAnalyseEnumType {
46     MCE_RECIPIENT_LEVEL1 = 1,
47     MCE_RECIPIENT_LEVEL2 = 2,
48     MCE_RECIPIENT_LEVEL3 = 3
49 };
50 /**
51  * @brief split string
52  */
53 class MceSplitString {
54 public:
55     /**
56      * @brief Construct a new Mce Split String object
57      * @param  target   target string
58      * @param  filter   split filter
59      */
60     MceSplitString(const std::string &target, const std::string &filter);
61     /**
62      * @brief Destroy the Mce Split String object
63      */
64     ~MceSplitString();
65     /**
66      * @brief next word
67      * @return std::string string of next word
68      */
69     std::string NextWord();
70 
71 private:
72     // count number
73     int count_ = 0;
74     // max of count
75     int maxCount_ = 0;
76     // target string
77     std::string targetString_ = "";
78     // filter string
79     std::string filterString_ = "";
80 };
81 /**
82  * @brief mce combine node
83  */
84 class MceCombineNode {
85 public:
86     /**
87      * @brief Construct a new Mce Combine Node object
88      */
89     MceCombineNode();
90     /**
91      * @brief Destroy the Mce Combine Node object
92      */
93     ~MceCombineNode();
94     /**
95      * @brief Node Begin process
96      * @param  nodeName         node name string
97      */
98     void NodeBegin(std::string nodeName);
99     /**
100      * @brief node end process
101      */
102     void NodeEnd();
103     /**
104      * @brief  add app parameter String
105      * @param  param    parameter
106      * @param  value    string value
107      */
108     void AddParamStr(const std::string &param, const std::string &value);
109     /**
110      * @brief  add text string
111      * @param  text      text string
112      */
113     void AddText(const std::string &text);
114     /**
115      * @brief Get the Combine String object
116      * @return std::string
117      */
118     std::string GetCombineString() const;
119 
120 private:
121     // not name list
122     std::list<std::string> nodeNameList_ {};
123     // string stream
124     std::ostringstream stream_ {};
125 };
126 /**
127  * @brief mce bmessage node
128  */
129 class MceBMessageNode {
130 public:
131     /**
132      * @brief Construct a new Mce B Message Node object
133      */
134     MceBMessageNode();
135     /**
136      * @brief Construct a new Mce B Message Node object
137      * @param  list             string list
138      * @param  name             node name
139      */
140     MceBMessageNode(const std::list<std::string> &list, const std::string &name);
141     /**
142      * @brief Destroy the Mce B Message Node object
143      */
144     ~MceBMessageNode();
145     /**
146      * @brief  Mce Construct Node
147      * @param  list             string list
148      * @param  name             node name
149      */
150     void MceConstructNode(const std::list<std::string> &list, const std::string &name);
151     /**
152      * @brief Get the Next Child object
153      * @return MceBMessageNode
154      */
155     MceBMessageNode GetNextChild();
156     /**
157      * @brief Get the Node Name object
158      * @return std::string
159      */
160     std::string GetNodeName() const;
161     /**
162      * @brief Get the Node Value object
163      * @return std::string
164      */
165     std::string GetNodeValue() const;
166     /**
167      * @brief Get the Parameter Value object
168      * @param  param            parameter
169      * @return std::string
170      */
171     std::string GetParamValue(std::string param) const;
172     /**
173      * @brief Get the Parameter Value List object
174      * @param  param            parameter
175      * @return std::vector<std::string>
176      */
177     std::vector<std::string> GetParamValueList(std::string param) const;
178     /**
179      * @brief Get the Size object
180      * @return int
181      */
182     int GetSize() const;
183 
184 private:
185     // node name
186     std::string name_ = "";
187     // node value
188     std::string value_ = "";
189     // string list
190     std::list<std::string> wordList_ {};
191 };
192 /**
193  * @brief Mce Bmessage Parameter Make String Object
194  */
195 class MceBmessageParamMakeStringObject {
196 public:
197     /**
198      * @brief Construct a new Mce Bmessage param Make String Object object
199      * @param  param            Parameter
200      */
201     explicit MceBmessageParamMakeStringObject(const IProfileBMessageStruct &param);
202     /**
203      * @brief Destroy the Mce Bmessage param Make String Object object
204      */
205     ~MceBmessageParamMakeStringObject();
206     /**
207      * @brief Get the String Object object
208      * @return std::string
209      */
210     std::string GetStringObject() const;
211 
212 private:
213     /**
214      * @brief Make BMessage Property
215      */
216     void MakeBMessageProperty();
217     /**
218      * @brief Make Recipient Level1
219      */
220     void MakeRecipientLevel1();
221     /**
222      * @brief Make Recipient Level2
223      */
224     void MakeRecipientLevel2();
225     /**
226      * @brief Make Recipient Level3
227      */
228     void MakeRecipientLevel3();
229     /**
230      * @brief Make Message Body Property
231      */
232     void MakeMsgBodyProperty();
233     /**
234      * @brief Make Message Body Text
235      */
236     void MakeMsgBodyText();
237     /**
238      * @brief  Make Vcard
239      * @param  vcard             vcard list
240      */
241     void MakeVcard(std::vector<IProfileMapVcard> vcard);
242     // string object
243     std::string stringObject_ = "";
244     // message parameter
245     IProfileBMessageStruct msgParam_ {};
246     // combine node
247     MceCombineNode combineNode_ {};
248 };
249 /**
250  * @brief Mce Bmessage Parameter Analyser
251  */
252 class MceBmessageParamAnalyser {
253 public:
254     /**
255      * @brief Construct a new Mce Bmessage param Analyser object
256      * @param  object           string object
257      */
258     explicit MceBmessageParamAnalyser(const std::string &object);
259     /**
260      * @brief Destroy the Mce Bmessage param Analyser object
261      */
262     ~MceBmessageParamAnalyser();
263     /**
264      * @brief Get the Msg Struct object
265      * @return IProfileBMessageStruct
266      */
267     IProfileBMessageStruct GetMsgStruct() const;
268     /**
269      * @brief Get the First Child Node object
270      * @return MceBMessageNode
271      */
272     MceBMessageNode GetFirstChildNode();
273     /**
274      * @brief Get the Size object
275      * @return int
276      */
277     int GetSize() const;
278     /**
279      * @brief Start Analyse Process
280      */
281     void StartAnalyse();
282     /**
283      * @brief Get the Msg Text object
284      * @return std::string
285      */
286     std::string GetMsgText();
287 
288 private:
289     /**
290      * @brief make word list
291      */
292     void MakeWordList();
293     /**
294      * @brief  PickUp BMessage Property
295      * @param  node             message node
296      */
297     void PickUpBMessageProperty(const MceBMessageNode &node);
298     /**
299      * @brief  PickUp BMessage Property Originator
300      * @param  node             message node
301      */
302     void PickUpBMessagePropertyOriginator(const MceBMessageNode &node);
303     /**
304      * @brief  PickUp Recipient Level1
305      * @param  node             message node
306      * @return MceBMessageNode
307      */
308     MceBMessageNode PickUpRecipientLevel1(MceBMessageNode &node);
309     /**
310      * @brief  PickUp Recipient Level2
311      * @param  node             message node
312      * @return MceBMessageNode
313      */
314     MceBMessageNode PickUpRecipientLevel2(MceBMessageNode &node);
315     /**
316      * @brief  PickUp Recipient Level3
317      * @param  node             message node
318      */
319     void PickUpRecipientLevel3(MceBMessageNode &node);
320     /**
321      * @brief PickUp Message Body Property
322      */
323     void PickUpMsgBodyProperty();
324     /**
325      * @brief PickUp Message Body Text
326      */
327     void PickUpMsgBodyText();
328     // message string object
329     std::string msgStr_ = "";
330     // word string list
331     std::list<std::string> wordList_ {};
332     // bmessage parameter
333     IProfileBMessageStruct bMsgParamStruct_ {};
334     // message node
335     MceBMessageNode msgNode_ {};
336 };
337 /**
338  * @brief Mce Types Conversation Listing
339  */
340 class MceTypesConversationListing {
341 public:
342     /**
343      * @brief  Build Object Data
344      * @param  stringParam      string parameter
345      * @param  stringObject     string object
346      * @return int
347      */
348     int BuildObjectData(const IProfileConversationListingParamStruct &stringParam, const std::string &stringObject);
349     /**
350      * @brief Get the List object
351      * @return std::vector<IProfileConversation>
352      */
353     std::vector<IProfileConversation> GetList() const;
354     /**
355      * @brief Get the param object
356      * @return IProfileConversationListingParamStruct
357      */
358     IProfileConversationListingParamStruct GetParam() const;
359     /**
360      * @brief Get the String Object object
361      * @return std::string
362      */
363     std::string GetStringObject() const;
364 
365 private:
366     /**
367      * @brief  PickUp Participant
368      * @param  data             Participant data
369      * @param  node             xml node
370      */
371     static void PickUpParticipant(IProfileParticipant &data, const MceXmlNode &node);
372     /**
373      * @brief  PickUp Conversation
374      * @param  data             Conversation data
375      * @param  node             xml node
376      */
377     static void PickUpConversation(IProfileConversation &data, const MceXmlNode &node);
378     // conversation list
379     std::vector<IProfileConversation> conversationList_ {};
380     // conversationListing Parameter
381     IProfileConversationListingParamStruct conversationListingParam_ {};
382     // conversationListing Object
383     std::string conversationListingObject_ = "";
384 };
385 /**
386  * @brief Mce Types MessagesListing
387  */
388 class MceTypesMessagesListing {
389 public:
390     /**
391      * @brief  Build Object Data
392      * @param  stringParam      parameter
393      * @param  stringObject     string object
394      * @return int
395      */
396     int BuildObjectData(const IProfileMessagesListingParamStruct &stringParam, const std::string &stringObject);
397     /**
398      * @brief Get the List object
399      * @return std::vector<IProfileMessageOutline>
400      */
401     std::vector<IProfileMessageOutline> GetList() const;
402     /**
403      * @brief Get the param object
404      * @return IProfileMessagesListingParamStruct
405      */
406     IProfileMessagesListingParamStruct GetParam() const;
407     /**
408      * @brief Get the String Object object
409      * @return std::string
410      */
411     std::string GetStringObject() const;
412 
413 private:
414     // message list
415     std::vector<IProfileMessageOutline> messageList_ {};
416     // message list parameter
417     IProfileMessagesListingParamStruct messagesListingParam_ {};
418     // message listing object
419     std::string MessagesListingObject_ = "";
420     /**
421      * @brief  Pickup Outline Parameter
422      * @param  outline          outline Parameter
423      * @param  node             xml node
424      */
425     static void PickupOutlineParam(IProfileMessageOutline &msgOutline, const MceXmlNode &msgNode);
426 };
427 /**
428  * @brief Mce Types BMessage
429  */
430 class MceTypesBMessage {
431 public:
432     /**
433      * @brief  Build Object Data
434      * @param  stringObject     string object
435      * @return int
436      */
437     int BuildObjectData(const std::string &stringObject);
438     /**
439      * @brief Set the Fraction Deliver object
440      * @param  value            FractionDeliver Type
441      * @return int
442      */
443     int SetFractionDeliver(MapFractionDeliverType value);
444     /**
445      * @brief Get the Fraction Deliver object
446      * @return MapFractionDeliverType
447      */
448     MapFractionDeliverType GetFractionDeliver() const;
449     /**
450      * @brief  Get BMessage Data
451      * @return IProfileBMessageStruct
452      */
453     IProfileBMessageStruct GetBMessageData() const;
454     /**
455      * @brief Get the Bmessage Object object
456      * @return std::string
457      */
458     std::string GetBmessageObject() const;
459 
460 private:
461     // Fraction Deliver
462     MapFractionDeliverType FractionDeliver = MapFractionDeliverType::INVALID;
463     // Bmessage string object
464     std::string bMessageObject_ = "";
465     // Bmessage Struct data
466     IProfileBMessageStruct bMessageData_ {};
467 };
468 /**
469  * @brief mce event report object
470  */
471 class MceTypesEventReport {
472 public:
473     /**
474      * @brief  Build Object Data
475      * @param  masInstanceId    masInstance Id
476      * @param  stringObject     string Object
477      * @return int
478      */
479     int BuildObjectData(const uint8_t &masInstanceId, const std::string &stringObject);
480     /**
481      * @brief Get the param object
482      * @return IProfileMapEventReport
483      */
484     IProfileMapEventReport GetParam() const;
485     /**
486      * @brief Get the String Object object
487      * @return std::string
488      */
489     std::string GetStringObject() const;
490 
491 private:
492     // event report
493     IProfileMapEventReport eventReportParam_ {};
494 };
495 /**
496  * @brief FolderListing Object
497  */
498 class MceTypesFolderListing {
499 public:
500     /**
501      * @brief  Build Object Data
502      * @param  stringObject     string Object
503      * @return int
504      */
505     int BuildObjectData(const std::string &stringObject);
506     /**
507      * @brief Get the List object
508      * @return std::vector<std::string>
509      */
510     std::vector<std::string> GetList() const;
511     /**
512      * @brief Get the Version object
513      * @return std::string
514      */
515     std::string GetVersion() const;
516 
517 private:
518     // folder listing version
519     std::string version_ = "";
520     // folder name list
521     std::vector<std::string> folderNameList_ {};
522 };
523 /**
524  * @brief Utility of Convert Format
525  */
526 class MceUtilityConvertFormat {
527 public:
528     /**
529      * @brief  Convert String To Message Type
530      * @param  str              string object
531      * @return MapMessageType
532      */
533     static MapMessageType ConvertStringToMessageType(const std::string &str);
534     /**
535      * @brief  Convert String To Message Direction
536      * @param  str              string object
537      * @return MapMsgDirection
538      */
539     static MapMsgDirection ConvertStringToMsgDirection(const std::string &str);
540     /**
541      * @brief  Convert String To Message Delivery Status
542      * @param  str              string object
543      * @return MapMsgDeliveryStatus
544      */
545     static MapMsgDeliveryStatus ConvertStringToMsgDeliveryStatus(const std::string &str);
546     /**
547      * @brief  Convert String To Message Reception Status
548      * @param  str              string object
549      * @return MapMsgReceptionStatus
550      */
551     static MapMsgReceptionStatus ConvertStringToMsgReceptionStatus(const std::string &str);
552     /**
553      * @brief  Convert Yes/No String To MapMessageStatus
554      * @param  str              string object
555      * @return MapMessageStatus
556      */
557     static MapMessageStatus ConvertYesNoStringToMapMessageStatus(const std::string &str);
558     /**
559      * @brief  Convert String To MessageStatus
560      * @param  str              string object
561      * @return MapMessageStatus
562      */
563     static MapMessageStatus ConvertStringToMapMessageStatus(const std::string &str);
564     /**
565      * @brief  Convert String To  MapBoolType
566      * @param  str              string object
567      * @return MapBoolType
568      */
569     static MapBoolType ConvertStringToMapBoolType(const std::string &str);
570 };
571 }  // namespace bluetooth
572 }  // namespace OHOS
573 
574 #endif  // MAP_MCE_DATA_ANALYSE_H
575