#include "device/bluetooth/floss/floss_socket_manager.h"
#include "base/containers/contains.h"
#include "base/types/expected.h"
namespace floss {
namespace {
void HandleExported(const std::string& method_name,
const std::string& interface_name,
const std::string& object_path,
bool success) { … }
constexpr char kListeningPropId[] = …;
constexpr char kListeningPropSockType[] = …;
constexpr char kListeningPropFlags[] = …;
constexpr char kListeningPropPsm[] = …;
constexpr char kListeningPropChannel[] = …;
constexpr char kListeningPropName[] = …;
constexpr char kListeningPropUuid[] = …;
constexpr char kConnectingPropId[] = …;
constexpr char kConnectingPropRemoteDevice[] = …;
constexpr char kConnectingPropSockType[] = …;
constexpr char kConnectingPropFlags[] = …;
constexpr char kConnectingPropFd[] = …;
constexpr char kConnectingPropPort[] = …;
constexpr char kConnectingPropUuid[] = …;
constexpr char kConnectingPropMaxRxSize[] = …;
constexpr char kConnectingPropMaxTxSize[] = …;
constexpr char kResultPropStatus[] = …;
constexpr char kResultPropId[] = …;
}
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
FlossSocketManager::SocketType* type) { … }
template <>
void FlossDBusClient::WriteDBusParam(
dbus::MessageWriter* writer,
const FlossSocketManager::SocketType& type) { … }
template <>
bool FlossDBusClient::ReadDBusParam(
dbus::MessageReader* reader,
FlossSocketManager::FlossListeningSocket* socket) { … }
template bool
FlossDBusClient::ReadDBusParam<FlossSocketManager::FlossListeningSocket>(
dbus::MessageReader* reader,
std::optional<FlossSocketManager::FlossListeningSocket>* socket);
template <>
void FlossDBusClient::WriteDBusParam(
dbus::MessageWriter* writer,
const FlossSocketManager::FlossListeningSocket& socket) { … }
template <>
bool FlossDBusClient::ReadDBusParam(dbus::MessageReader* reader,
FlossSocketManager::FlossSocket* socket) { … }
template bool FlossDBusClient::ReadDBusParam<FlossSocketManager::FlossSocket>(
dbus::MessageReader* reader,
std::optional<FlossSocketManager::FlossSocket>* socket);
template <>
void FlossDBusClient::WriteDBusParam(
dbus::MessageWriter* writer,
const FlossSocketManager::FlossSocket& socket) { … }
template <>
bool FlossDBusClient::ReadDBusParam(
dbus::MessageReader* reader,
FlossSocketManager::SocketResult* socket_result) { … }
template <>
void FlossDBusClient::WriteDBusParam(
dbus::MessageWriter* writer,
const FlossSocketManager::SocketResult& socket_result) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const FlossSocketManager::SocketType*) { … }
template <>
const DBusTypeInfo& GetDBusTypeInfo(const FlossSocketManager::FlossSocket*) { … }
int FlossSocketManager::GetRawFlossFlagsFromBluetoothFlags(bool encrypt,
bool auth,
bool auth_mitm,
bool auth_16_digit,
bool no_sdp) { … }
FlossSocketManager::FlossListeningSocket::FlossListeningSocket() = default;
FlossSocketManager::FlossListeningSocket::FlossListeningSocket(
const FlossListeningSocket&) = default;
FlossSocketManager::FlossListeningSocket::~FlossListeningSocket() = default;
FlossSocketManager::FlossSocket::FlossSocket() = default;
FlossSocketManager::FlossSocket::FlossSocket(FlossSocket&&) = default;
FlossSocketManager::FlossSocket::~FlossSocket() = default;
const char FlossSocketManager::kErrorInvalidCallback[] = …;
const char FlossSocketManager::kExportedCallbacksPath[] = …"/org/chromium/bluetooth/socket_manager/callback/lacros";
#else
"/org/chromium/bluetooth/socket_manager/callback";
#endif
std::unique_ptr<FlossSocketManager> FlossSocketManager::Create() { … }
FlossSocketManager::FlossSocketManager() = default;
FlossSocketManager::~FlossSocketManager() { … }
void FlossSocketManager::ListenUsingL2cap(
const Security security_level,
ResponseCallback<BtifStatus> callback,
ConnectionStateChanged ready_cb,
ConnectionAccepted new_connection_cb) { … }
void FlossSocketManager::ListenUsingL2capLe(
const Security security_level,
ResponseCallback<BtifStatus> callback,
ConnectionStateChanged ready_cb,
ConnectionAccepted new_connection_cb) { … }
void FlossSocketManager::ListenUsingRfcommAlt(
const std::optional<std::string> name,
const std::optional<device::BluetoothUUID> application_uuid,
const std::optional<int> channel,
const std::optional<int> flags,
ResponseCallback<BtifStatus> callback,
ConnectionStateChanged ready_cb,
ConnectionAccepted new_connection_cb) { … }
void FlossSocketManager::ListenUsingRfcomm(
const std::string& name,
const device::BluetoothUUID& uuid,
const Security security_level,
ResponseCallback<BtifStatus> callback,
ConnectionStateChanged ready_cb,
ConnectionAccepted new_connection_cb) { … }
void FlossSocketManager::ConnectUsingL2cap(const FlossDeviceId& remote_device,
const int psm,
const Security security_level,
ConnectionCompleted callback) { … }
void FlossSocketManager::ConnectUsingL2capLe(const FlossDeviceId& remote_device,
const int psm,
const Security security_level,
ConnectionCompleted callback) { … }
void FlossSocketManager::ConnectUsingRfcomm(const FlossDeviceId& remote_device,
const device::BluetoothUUID& uuid,
const Security security_level,
ConnectionCompleted callback) { … }
void FlossSocketManager::Accept(const SocketId id,
std::optional<uint32_t> timeout_ms,
ResponseCallback<BtifStatus> callback) { … }
void FlossSocketManager::Close(const SocketId id,
ResponseCallback<BtifStatus> callback) { … }
void FlossSocketManager::Init(dbus::Bus* bus,
const std::string& service_name,
const int adapter_index,
base::Version version,
base::OnceClosure on_ready) { … }
void FlossSocketManager::CompleteRegisterCallback(
dbus::Response* response,
dbus::ErrorResponse* error_response) { … }
void FlossSocketManager::CompleteUnregisterCallback(DBusResult<bool> result) { … }
void FlossSocketManager::CompleteListen(ResponseCallback<BtifStatus> callback,
ConnectionStateChanged ready_cb,
ConnectionAccepted new_connection_cb,
DBusResult<SocketResult> result) { … }
void FlossSocketManager::CompleteConnect(ConnectionCompleted callback,
DBusResult<SocketResult> result) { … }
void FlossSocketManager::OnIncomingSocketReady(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossSocketManager::OnIncomingSocketClosed(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossSocketManager::OnHandleIncomingConnection(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
void FlossSocketManager::OnOutgoingConnectionResult(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender) { … }
template void FlossDBusClient::DefaultResponseWithCallback(
ResponseCallback<FlossSocketManager::SocketResult> callback,
dbus::Response* response,
dbus::ErrorResponse* error_response);
}