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 INTERFACE_PROFILE_PBAP_PSE_H 17 #define INTERFACE_PROFILE_PBAP_PSE_H 18 19 #include "interface_profile.h" 20 21 namespace OHOS { 22 namespace bluetooth { 23 /** 24 * @brief obsever for pbap server 25 * when pbap server occur event, call these 26 */ 27 class IPbapPseObserver { 28 public: 29 /** 30 * @brief ConnectionState Changed 31 * 32 * @param device bluetooth address 33 * @param state changed status 34 * @since 6 35 */ 36 virtual void OnServiceConnectionStateChanged(const RawAddress &device, int state) = 0; 37 38 /** 39 * @brief connect permission confirm call back 40 * @details when connect incoming, device is unknown call it 41 * @param device remote device 42 * @return void 43 * @since 6 44 */ 45 virtual void OnServicePermission(const RawAddress &remoteAddr) = 0; 46 47 /** 48 * @brief connect password input call back 49 * @details when connect password input call it 50 * @param device remote device 51 * @param description description bytes 52 * @param charset description bytes's chartset 53 * @param fullAccess fullAccess 54 * @since 6 55 */ 56 virtual void OnServicePasswordRequired(const RawAddress &remoteAddr, const std::vector<uint8_t> &description, 57 uint8_t charset, bool fullAccess = true) = 0; 58 59 /** 60 * @brief deconstructor 61 * @details deconstructor 62 * @return 63 * @since 6 64 */ ~IPbapPseObserver()65 virtual ~IPbapPseObserver(){}; 66 }; 67 68 /** 69 * @brief pbap pce service 70 * pbap pce service 71 */ 72 class IProfilePbapPse : public IProfile { 73 public: 74 /** 75 * @brief register observer 76 * @details register observer for the service of phone book serve 77 * @param observer the ref that point to a PbapPseObserver 78 * @return void 79 * @since 6 80 */ 81 virtual void RegisterObserver(IPbapPseObserver &observer) = 0; 82 83 /** 84 * @brief deregister observer 85 * @details deregister observer for the service of phone book serve 86 * @param observer the ref that point to a PbapPseObserver 87 * @return void 88 * @since 6 89 */ 90 virtual void DeregisterObserver(IPbapPseObserver &observer) = 0; 91 92 /** 93 * @brief get the remote devices 94 * @details get the remote device with the specified states 95 * @param states states 96 * @return std::vector remote devices 97 * @since 6 98 */ 99 virtual std::vector<RawAddress> GetDevicesByStates(const std::vector<int> &states) const = 0; 100 101 /** 102 * @brief get the state of device 103 * @details get the state with the specified remote device 104 * @param device remote device 105 * @return int @c not -1 state of the specified remote device 106 * @c -1 device is not exist 107 * @since 6 108 */ 109 virtual int GetDeviceState(const RawAddress &device) const = 0; 110 111 /** 112 * @brief Set the connection policy of the specified device. 113 * 114 * @param device Reference to the remote bluetooth device. 115 * @param strategy Reference to the connection policy, 116 * @c UNKNOWN : the connection policy for unkown state. 117 * @c ALLOWED : the connection policy for allowed state. 118 * @c FORBIDDEN : the connection policy for forbidden state. 119 * @return Returns true if the operation is successful;returns false if the operation fails. 120 * @since 6 121 */ 122 virtual int SetConnectionStrategy(const RawAddress &device, int strategy) = 0; 123 124 /** 125 * @brief Get the connection policy of the specified device. 126 * 127 * @param device Reference to the remote bluetooth device. 128 * @return Returns the connection police of the specified bluetooth address. 129 * @since 6 130 */ 131 virtual int GetConnectionStrategy(const RawAddress &device) const = 0; 132 133 /** 134 * @brief Grant device's connect Permission. please call after OnServicePermission event. 135 * 136 * @param device device 137 * @param allow allow 138 * @param save save 139 * @since 6 140 */ 141 virtual void GrantPermission(const RawAddress &device, bool allow, bool save = false) = 0; 142 143 /** 144 * @brief Set device's password. please call after OnServicePasswordRequired event. 145 * 146 * @param device device 147 * @param password device's password 148 * @param userId device's userId 149 * @return int @c 0 ok 150 * @c -1 fail 151 * @since 6 152 */ 153 virtual int SetDevicePassword( 154 const RawAddress &device, const std::string &password, const std::string userId = "") = 0; 155 }; 156 } // namespace bluetooth 157 } // namespace OHOS 158 #endif // INTERFACE_PROFILE_PBAP_PSE_H