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_PARAMETER_H 17 #define PBAP_PCE_PARAMETER_H 18 19 #include <stdint.h> 20 #include <string> 21 #include <vector> 22 23 namespace bluetooth { 24 class IPbapPullPhoneBookParam { 25 public: 26 IPbapPullPhoneBookParam(); 27 virtual ~IPbapPullPhoneBookParam(); 28 IPbapPullPhoneBookParam(const IPbapPullPhoneBookParam &other); 29 std::string ToDebugString() const; 30 bool Validate() const; 31 IPbapPullPhoneBookParam &operator=(const IPbapPullPhoneBookParam &other) = delete; 32 enum { 33 NAME = 1 << 0, 34 PROPERTY_SELECTOR = 1 << 1, 35 FORMAT = 1 << 2, 36 MAX_LIST_COUNT = 1 << 3, 37 LIST_START_OFFSET = 1 << 4, 38 RESET_NEW_MISSED_CALLS = 1 << 5, 39 VCARD_SELECTOR = 1 << 6, 40 VCARD_SELECTOROP = 1 << 7, 41 }; 42 43 public: 44 std::u16string GetName() const; 45 void SetName(const std::u16string &name); 46 uint64_t GetPropertySelector() const; 47 void SetPropertySelector(uint64_t propertySelector); 48 uint8_t GetFormat() const; 49 void SetFormat(uint8_t format); 50 uint16_t GetMaxListCount() const; 51 void SetMaxListCount(uint16_t maxListCount); 52 uint16_t GetListStartOffset() const; 53 void SetListStartOffset(uint16_t listStartOffset); 54 uint8_t GetResetNewMissedCalls() const; 55 void SetResetNewMissedCalls(uint8_t resetNewMissedCalls); 56 uint64_t GetvCardSelector() const; 57 void SetvCardSelector(uint64_t vCardSelector); 58 uint8_t GetvCardSelectorOp() const; 59 void SetvCardSelectorOp(uint8_t vCardSelectorOp); 60 uint64_t GetSpecifiedBitset() const; 61 void SetSpecifiedBitset(uint64_t specifiedBitset); 62 bool IsSpecified(int bitSpecified) const; 63 64 private: 65 std::u16string name_ = u""; 66 uint64_t propertySelector_ = 0ULL; 67 uint8_t format_ = 0; 68 uint16_t maxListCount_ = 0; 69 uint16_t listStartOffset_ = 0; 70 uint8_t resetNewMissedCalls_ = 0; 71 uint64_t vCardSelector_ = 0ULL; 72 uint8_t vCardSelectorOp_ = 0; 73 uint64_t specifiedBitset_ = 0ULL; 74 }; 75 76 class IPbapPullvCardListingParam { 77 public: 78 IPbapPullvCardListingParam(); 79 virtual ~IPbapPullvCardListingParam(); 80 IPbapPullvCardListingParam(const IPbapPullvCardListingParam &other); 81 IPbapPullvCardListingParam &operator=(const IPbapPullvCardListingParam &other) = delete; 82 std::string ToDebugString() const; 83 bool Validate() const; 84 enum { 85 NAME = 1 << 0, 86 ORDER = 1 << 1, 87 SEARCH_VALUE = 1 << 2, 88 SEARCH_PROPERTY = 1 << 3, 89 MAX_LIST_COUNT = 1 << 4, 90 LIST_START_OFFSET = 1 << 5, 91 RESET_NEW_MISSED_CALLS = 1 << 6, 92 VCARD_SELECTOR = 1 << 7, 93 VCARD_SELECTOROP = 1 << 8, 94 }; 95 96 public: 97 std::u16string GetName() const; 98 void SetName(const std::u16string &name); 99 uint8_t GetOrder() const; 100 void SetOrder(uint8_t order); 101 std::string GetSearchValue() const; 102 void SetSearchValue(const std::string &searchValue); 103 uint8_t GetSearchProperty() const; 104 void SetSearchProperty(uint8_t searchProperty); 105 uint16_t GetMaxListCount() const; 106 void SetMaxListCount(uint16_t maxListCount); 107 uint16_t GetListStartOffset() const; 108 void SetListStartOffset(uint16_t listStartOffset); 109 uint8_t GetResetNewMissedCalls() const; 110 void SetResetNewMissedCalls(uint8_t resetNewMissedCalls); 111 uint64_t GetvCardSelector() const; 112 void SetvCardSelector(uint64_t vCardSelector); 113 uint8_t GetvCardSelectorOp() const; 114 void SetvCardSelectorOp(uint8_t vCardSelectorOp); 115 uint64_t GetSpecifiedBitset() const; 116 void SetSpecifiedBitset(uint64_t specifiedBitset); 117 bool IsSpecified(int bitSpecified) const; 118 119 private: 120 std::u16string name_ = u""; 121 uint8_t order_ = 0; 122 std::string searchValue_ = ""; 123 uint8_t searchProperty_ = 0; 124 uint16_t maxListCount_ = 0; 125 uint16_t listStartOffset_ = 0; 126 uint8_t resetNewMissedCalls_ = 0; 127 uint64_t vCardSelector_ = 0ULL; 128 uint8_t vCardSelectorOp_ = 0; 129 uint64_t specifiedBitset_ = 0ULL; 130 }; 131 132 class IPbapPullvCardEntryParam { 133 public: 134 IPbapPullvCardEntryParam(); 135 virtual ~IPbapPullvCardEntryParam(); 136 IPbapPullvCardEntryParam(const IPbapPullvCardEntryParam &other); 137 IPbapPullvCardEntryParam &operator=(const IPbapPullvCardEntryParam &other) = delete; 138 std::string ToDebugString() const; 139 bool Validate() const; 140 enum { 141 NAME = 1 << 0, 142 PROPERTY_SELECTOR = 1 << 1, 143 FORMAT = 1 << 2, 144 }; 145 146 public: 147 std::u16string GetName() const; 148 void SetName(const std::u16string &name); 149 uint64_t GetPropertySelector() const; 150 void SetPropertySelector(uint64_t propertySelector); 151 uint8_t GetFormat() const; 152 void SetFormat(uint8_t format); 153 uint64_t GetSpecifiedBitset() const; 154 void SetSpecifiedBitset(uint64_t specifiedBitset); 155 bool IsSpecified(int bitSpecified) const; 156 157 private: 158 std::u16string name_ = u""; 159 uint64_t propertySelector_ = 0ULL; 160 uint8_t format_ = 0; 161 uint64_t specifiedBitset_ = 0ULL; 162 }; 163 164 /** 165 * @brief 166 * 167 * @since 1.0 168 * @version 1.0 169 */ 170 class IPbapPhoneBookData { 171 public: 172 explicit IPbapPhoneBookData(); 173 virtual ~IPbapPhoneBookData(); 174 explicit IPbapPhoneBookData(const IPbapPhoneBookData &other); 175 IPbapPhoneBookData &operator=(const IPbapPhoneBookData &other); 176 void Load(std::vector<uint8_t> &retResult); 177 uint16_t phoneBookSize_ = 0; // VCard size 178 std::vector<uint8_t> primaryFolderVersion_ {}; // VCard PrimaryFolderVersion 16 bytes 179 std::vector<uint8_t> secondaryFolderVersion_ {}; // VCard SecondaryFolderVersion 16 bytes 180 std::vector<uint8_t> databaseIdentifier_ {}; // VCard DatabaseIdentifier 16 bytes 181 std::string deviceAddr_ = ""; // device address 182 std::string vcardPath_ = ""; // vcard path 183 std::string vcardFileName_ = ""; // file name 184 uint16_t resultLoaded_ = 1; // result loaded:1 , otherwise 0 185 std::vector<uint8_t> result_ {}; // VCard bytes with utf-8 186 }; 187 } // namespace bluetooth 188 189 #endif // PBAP_PCE_PARAMETER_H 190