• 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 PBAP_PCE_APP_PARAMS_H
17 #define PBAP_PCE_APP_PARAMS_H
18 
19 #include <cstdint>
20 #include <map>
21 #include <memory>
22 #include <vector>
23 #include "../obex/obex_headers.h"
24 
25 namespace OHOS {
26 namespace bluetooth {
27 /**
28  * @brief Pbap Pce App Params
29  * wrap Pbap Pce App Params
30  */
31 class PbapPceAppParams {
32 public:
33     PbapPceAppParams() = default;
34     virtual ~PbapPceAppParams() = default;
35     bool Init(const ObexTlvParamters &obexTlvParamters);
36     void AddToObexHeader(ObexHeader &hdr) const;
37     static bool CheckParams(const ObexTlvParamters &obexTlvParamters);
38 
39     static const uint8_t ORDER = 0x01;
40     static const uint8_t SEARCH_VALUE = 0x02;
41     static const uint8_t SEARCH_PROPERTY = 0x03;
42     static const uint8_t MAX_LIST_COUNT = 0x04;
43     static const uint8_t LIST_START_OFFSET = 0x05;
44     static const uint8_t PROPERTY_SELECTOR = 0x06;
45     static const uint8_t FORMAT = 0x07;
46     static const uint8_t PHONEBOOK_SIZE = 0x08;
47     static const uint8_t NEW_MISSED_CALLS = 0x09;
48     static const uint8_t PRIMARY_FOLDER_VERSION = 0x0A;
49     static const uint8_t SECONDARY_FOLDER_VERSION = 0x0B;
50     static const uint8_t VCARD_SELECTOR = 0x0C;
51     static const uint8_t DATABASE_IDENTIFIER = 0x0D;
52     static const uint8_t VCARD_SELECTOR_OPERATOR = 0x0E;
53     static const uint8_t RESET_NEW_MISSED_CALLS = 0x0F;
54     static const uint8_t PBAP_SUPPORTED_FEATURES = 0x10;
55 
56     const uint8_t *GetOrder() const;
57     const std::vector<uint8_t> &GetSearchValueUtf8() const;
58     const uint8_t *GetSearchProperty() const;
59     const uint16_t *GetMaxListCount() const;
60     const uint16_t *GetListStartOffset() const;
61     const uint64_t *GetPropertySelector() const;
62     const uint8_t *GetFormat() const;
63     const uint16_t *GetPhonebookSize() const;
64     const uint8_t *GetNewMissedCalls() const;
65     const std::vector<uint8_t> &GetPrimaryFolderVersion() const;
66     const std::vector<uint8_t> &GetSecondaryFolderVersion() const;
67     const uint64_t *GetVcardSelector() const;
68     const std::vector<uint8_t> &GetDatabaseIdentifier() const;
69     const uint8_t *GetVcardSelectorOperator() const;
70     const uint8_t *GetResetNewMissedCalls() const;
71     const uint32_t *GetPbapSupportedFeatures() const;
72 
73     void SetOrder(uint8_t val);
74     void SetSearchValueUtf8(const std::vector<uint8_t> &val);
75     void SetSearchProperty(uint8_t val);
76     void SetMaxListCount(uint16_t val);
77     void SetListStartOffset(uint16_t val);
78     void SetPropertySelector(uint64_t val);
79     void SetFormat(uint8_t val);
80     void SetPhonebookSize(uint16_t val);
81     void SetNewMissedCalls(uint8_t val);
82     void SetPrimaryFolderVersion(const std::vector<uint8_t> &val);
83     void SetSecondaryFolderVersion(const std::vector<uint8_t> &val);
84     void SetVcardSelector(uint64_t val);
85     void SetDatabaseIdentifier(const std::vector<uint8_t> &val);
86     void SetVcardSelectorOperator(uint8_t val);
87     void SetResetNewMissedCalls(uint8_t val);
88     void SetPbapSupportedFeatures(uint32_t val);
89 
90 private:
91     static const std::map<uint8_t, int> LENS_MAP;
92 
93     void SetOrderTlv(const ObexTlvParamters &obexTlvParamters);
94     void SetSearchValueUtf8Tlv(const ObexTlvParamters &obexTlvParamters);
95     void SetSearchPropertyTlv(const ObexTlvParamters &obexTlvParamters);
96     void SetMaxListCountTlv(const ObexTlvParamters &obexTlvParamters);
97     void SetListStartOffsetTlv(const ObexTlvParamters &obexTlvParamters);
98     void SetPropertySelectorTlv(const ObexTlvParamters &obexTlvParamters);
99     void SetFormatTlv(const ObexTlvParamters &obexTlvParamters);
100     void SetPhonebookSizeTlv(const ObexTlvParamters &obexTlvParamters);
101     void SetNewMissedCallsTlv(const ObexTlvParamters &obexTlvParamters);
102     void SetPrimaryFolderVersionTlv(const ObexTlvParamters &obexTlvParamters);
103     void SetSecondaryFolderVersionTlv(const ObexTlvParamters &obexTlvParamters);
104     void SetVcardSelectorTlv(const ObexTlvParamters &obexTlvParamters);
105     void SetDatabaseIdentifierTlv(const ObexTlvParamters &obexTlvParamters);
106     void SetVcardSelectorOperatorTlv(const ObexTlvParamters &obexTlvParamters);
107     void SetResetNewMissedCallsTlv(const ObexTlvParamters &obexTlvParamters);
108     void SetPbapSupportedFeaturesTlv(const ObexTlvParamters &obexTlvParamters);
109 
110     void AddTlvOrder(ObexTlvParamters &obexTlvParamters) const;
111     void AddTlvSearchValueUtf8(ObexTlvParamters &obexTlvParamters) const;
112     void AddTlvSearchProperty(ObexTlvParamters &obexTlvParamters) const;
113     void AddTlvMaxListCount(ObexTlvParamters &obexTlvParamters) const;
114     void AddTlvListStartOffAddTlv(ObexTlvParamters &obexTlvParamters) const;
115     void AddTlvPropertySelector(ObexTlvParamters &obexTlvParamters) const;
116     void AddTlvFormat(ObexTlvParamters &obexTlvParamters) const;
117     void AddTlvPhonebookSize(ObexTlvParamters &obexTlvParamters) const;
118     void AddTlvNewMissedCalls(ObexTlvParamters &obexTlvParamters) const;
119     void AddTlvPrimaryFolderVersion(ObexTlvParamters &obexTlvParamters) const;
120     void AddTlvSecondaryFolderVersion(ObexTlvParamters &obexTlvParamters) const;
121     void AddTlvVcardSelector(ObexTlvParamters &obexTlvParamters) const;
122     void AddTlvDatabaseIdentifier(ObexTlvParamters &obexTlvParamters) const;
123     void AddTlvVcardSelectorOperator(ObexTlvParamters &obexTlvParamters) const;
124     void AddTlvReAddTlvNewMissedCalls(ObexTlvParamters &obexTlvParamters) const;
125     void AddTlvPbapSupportedFeatures(ObexTlvParamters &obexTlvParamters) const;
126     std::unique_ptr<uint8_t> order_ = nullptr;
127     std::vector<uint8_t> searchValueUtf8_ {};
128     std::unique_ptr<uint8_t> searchProperty_ = nullptr;
129     std::unique_ptr<uint16_t> maxListCount_ = nullptr;
130     std::unique_ptr<uint16_t> listStartOffset_ = nullptr;
131     std::unique_ptr<uint64_t> propertySelector_ = nullptr;
132     std::unique_ptr<uint8_t> format_ = nullptr;
133     std::unique_ptr<uint16_t> phonebookSize_ = nullptr;
134     std::unique_ptr<uint8_t> newMissedCalls_ = nullptr;
135     std::vector<uint8_t> primaryFolderVer_ {};    // 16 bytes
136     std::vector<uint8_t> secondaryFolderVer_ {};  // 16 bytes
137     std::unique_ptr<uint64_t> vcardSelector_ = nullptr;
138     std::vector<uint8_t> databaseIdentifier_ {};  // 16 bytes
139     std::unique_ptr<uint8_t> vcardSelectorOp_ = nullptr;
140     std::unique_ptr<uint8_t> resetNewMissedCalls_ = nullptr;
141     std::unique_ptr<uint32_t> pbapSupportedFeatures_ = nullptr;
142 };
143 }  // namespace bluetooth
144 }  // namespace OHOS
145 #endif  // PBAP_PCE_APP_PARAMS_H
146