1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chromeos/dbus/fake_bluetooth_agent_service_provider.h"
6
7 #include "chromeos/dbus/dbus_thread_manager.h"
8 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h"
9 #include "dbus/object_path.h"
10
11 namespace chromeos {
12
FakeBluetoothAgentServiceProvider(const dbus::ObjectPath & object_path,Delegate * delegate)13 FakeBluetoothAgentServiceProvider::FakeBluetoothAgentServiceProvider(
14 const dbus::ObjectPath& object_path,
15 Delegate* delegate)
16 : object_path_(object_path),
17 delegate_(delegate) {
18 VLOG(1) << "Creating Bluetooth Agent: " << object_path_.value();
19
20 FakeBluetoothAgentManagerClient* fake_bluetooth_agent_manager_client =
21 static_cast<FakeBluetoothAgentManagerClient*>(
22 DBusThreadManager::Get()->GetBluetoothAgentManagerClient());
23 fake_bluetooth_agent_manager_client->RegisterAgentServiceProvider(this);
24 }
25
~FakeBluetoothAgentServiceProvider()26 FakeBluetoothAgentServiceProvider::~FakeBluetoothAgentServiceProvider() {
27 VLOG(1) << "Cleaning up Bluetooth Agent: " << object_path_.value();
28
29 FakeBluetoothAgentManagerClient* fake_bluetooth_agent_manager_client =
30 static_cast<FakeBluetoothAgentManagerClient*>(
31 DBusThreadManager::Get()->GetBluetoothAgentManagerClient());
32 fake_bluetooth_agent_manager_client->UnregisterAgentServiceProvider(this);
33 }
34
Release()35 void FakeBluetoothAgentServiceProvider::Release() {
36 VLOG(1) << object_path_.value() << ": Release";
37 delegate_->Released();
38 }
39
RequestPinCode(const dbus::ObjectPath & device_path,const Delegate::PinCodeCallback & callback)40 void FakeBluetoothAgentServiceProvider::RequestPinCode(
41 const dbus::ObjectPath& device_path,
42 const Delegate::PinCodeCallback& callback) {
43 VLOG(1) << object_path_.value() << ": RequestPinCode for "
44 << device_path.value();
45 delegate_->RequestPinCode(device_path, callback);
46 }
47
DisplayPinCode(const dbus::ObjectPath & device_path,const std::string & pincode)48 void FakeBluetoothAgentServiceProvider::DisplayPinCode(
49 const dbus::ObjectPath& device_path,
50 const std::string& pincode) {
51 VLOG(1) << object_path_.value() << ": DisplayPincode " << pincode << " for "
52 << device_path.value();
53 delegate_->DisplayPinCode(device_path, pincode);
54 }
55
RequestPasskey(const dbus::ObjectPath & device_path,const Delegate::PasskeyCallback & callback)56 void FakeBluetoothAgentServiceProvider::RequestPasskey(
57 const dbus::ObjectPath& device_path,
58 const Delegate::PasskeyCallback& callback) {
59 VLOG(1) << object_path_.value() << ": RequestPasskey for "
60 << device_path.value();
61 delegate_->RequestPasskey(device_path, callback);
62 }
63
DisplayPasskey(const dbus::ObjectPath & device_path,uint32 passkey,int16 entered)64 void FakeBluetoothAgentServiceProvider::DisplayPasskey(
65 const dbus::ObjectPath& device_path,
66 uint32 passkey, int16 entered) {
67 VLOG(1) << object_path_.value() << ": DisplayPasskey " << passkey
68 << " (" << entered << " entered) for "<< device_path.value();
69 delegate_->DisplayPasskey(device_path, passkey, entered);
70 }
71
RequestConfirmation(const dbus::ObjectPath & device_path,uint32 passkey,const Delegate::ConfirmationCallback & callback)72 void FakeBluetoothAgentServiceProvider::RequestConfirmation(
73 const dbus::ObjectPath& device_path,
74 uint32 passkey,
75 const Delegate::ConfirmationCallback& callback) {
76 VLOG(1) << object_path_.value() << ": RequestConfirmation " << passkey
77 << " for "<< device_path.value();
78 delegate_->RequestConfirmation(device_path, passkey, callback);
79 }
80
RequestAuthorization(const dbus::ObjectPath & device_path,const Delegate::ConfirmationCallback & callback)81 void FakeBluetoothAgentServiceProvider::RequestAuthorization(
82 const dbus::ObjectPath& device_path,
83 const Delegate::ConfirmationCallback& callback) {
84 VLOG(1) << object_path_.value() << ": RequestAuthorization for "
85 << device_path.value();
86 delegate_->RequestAuthorization(device_path, callback);
87 }
88
AuthorizeService(const dbus::ObjectPath & device_path,const std::string & uuid,const Delegate::ConfirmationCallback & callback)89 void FakeBluetoothAgentServiceProvider::AuthorizeService(
90 const dbus::ObjectPath& device_path,
91 const std::string& uuid,
92 const Delegate::ConfirmationCallback& callback) {
93 VLOG(1) << object_path_.value() << ": AuthorizeService " << uuid << " for "
94 << device_path.value();
95 delegate_->AuthorizeService(device_path, uuid, callback);
96 }
97
Cancel()98 void FakeBluetoothAgentServiceProvider::Cancel() {
99 VLOG(1) << object_path_.value() << ": Cancel";
100 delegate_->Cancel();
101 }
102
103 } // namespace chromeos
104