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_PSE_HEADER_MSG_H 17 #define PBAP_PSE_HEADER_MSG_H 18 19 #include <cstring> 20 #include "../obex/obex_headers.h" 21 #include "../obex/obex_session.h" 22 #include "../obex/obex_transport.h" 23 #include "btstack.h" 24 25 namespace OHOS { 26 namespace bluetooth { 27 enum PbapPseMessage { 28 PSE_DEVICE_CONNECT_INCOMING = 0x1001, // when connect is incoming 29 PSE_INCOMING_ACCEPT, // when incoming connect is accept 30 PSE_INCOMING_REJECT, // when incoming connect is reject 31 PSE_PASSWORD_INPUT, // when device password is inputted by user 32 PSE_WAITING_CONNECTED_TO_DISCONNECT, // when devices that were accepted but not connected, disable start 33 PSE_REQ_OBEX_CONNECT, // when obex connect request received from client 34 PSE_DEVICE_CONNECTED, // when device is connected 35 PSE_REQ_OBEX_GET, // when obex get request received from client 36 PSE_REQ_OBEX_SETPATH, // when obex setpath request received from client 37 PSE_API_DISCONNECT, // when disconnect request from api 38 PSE_REQ_OBEX_DISCONNECT, // when obex disconnect request received from client 39 PSE_DEVICE_TRANSPORT_ERROR, // when device transport error 40 PSE_DEVICE_DISCONNECTED, // when device is disconnected 41 PSE_SHUTDOWN_COMPLETED // when service shutdown completed 42 }; 43 44 class PbapPsePasswordInputMsg { 45 public: PbapPsePasswordInputMsg(const std::string & password,const std::string & userId)46 PbapPsePasswordInputMsg(const std::string &password, const std::string &userId) 47 : password_(password), userId_(userId) 48 {} PbapPsePasswordInputMsg(const std::string & password)49 explicit PbapPsePasswordInputMsg(const std::string &password) : password_(password), userId_("") 50 {} 51 virtual ~PbapPsePasswordInputMsg() = default; GetPassword()52 const std::string &GetPassword() const 53 { 54 return password_; 55 } GetUserId()56 const std::string &GetUserId() const 57 { 58 return userId_; 59 } 60 61 private: 62 std::string password_ = ""; 63 std::string userId_ = ""; 64 }; 65 66 /** 67 * @brief pbap pse message 68 * pbap pse message 69 */ 70 class PbapPseObexMessage { 71 public: 72 /** 73 * @brief constructor 74 * @details constructor 75 * @param obexSession obex Session 76 * @param ObexHeader obex header 77 */ PbapPseObexMessage(ObexServerSession & obexSession,const ObexHeader & header)78 PbapPseObexMessage(ObexServerSession &obexSession, const ObexHeader &header) 79 : obexSession_(obexSession), header_(header) 80 {} 81 virtual ~PbapPseObexMessage() = default; 82 /** 83 * @brief Get Obex Session 84 * @details Get Obex Session 85 * @return ObexServerSession 86 */ GetObexSession()87 ObexServerSession &GetObexSession() const 88 { 89 return obexSession_; 90 } 91 /** 92 * @brief Get Obex header 93 * @details Get Obex header 94 * @return ObexHeader 95 */ GetObexHeader()96 const ObexHeader &GetObexHeader() const 97 { 98 return header_; 99 } 100 101 private: 102 ObexServerSession &obexSession_; 103 const ObexHeader &header_; 104 }; 105 } // namespace bluetooth 106 } // namespace OHOS 107 #endif // PBAP_PSE_HEADER_MSG_H 108