OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromeos/dbus/dbus_thread_manager.h" | 5 #include "chromeos/dbus/dbus_thread_manager.h" |
6 | 6 |
7 #include "base/chromeos/chromeos_version.h" | 7 #include "base/chromeos/chromeos_version.h" |
8 #include "base/environment.h" | |
8 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
9 #include "chromeos/dbus/bluetooth_adapter_client.h" | 10 #include "chromeos/dbus/bluetooth_adapter_client.h" |
10 #include "chromeos/dbus/bluetooth_device_client.h" | 11 #include "chromeos/dbus/bluetooth_device_client.h" |
11 #include "chromeos/dbus/bluetooth_input_client.h" | 12 #include "chromeos/dbus/bluetooth_input_client.h" |
12 #include "chromeos/dbus/bluetooth_manager_client.h" | 13 #include "chromeos/dbus/bluetooth_manager_client.h" |
13 #include "chromeos/dbus/bluetooth_node_client.h" | 14 #include "chromeos/dbus/bluetooth_node_client.h" |
14 #include "chromeos/dbus/cashew_client.h" | 15 #include "chromeos/dbus/cashew_client.h" |
15 #include "chromeos/dbus/cros_disks_client.h" | 16 #include "chromeos/dbus/cros_disks_client.h" |
16 #include "chromeos/dbus/cryptohome_client.h" | 17 #include "chromeos/dbus/cryptohome_client.h" |
17 #include "chromeos/dbus/dbus_client_implementation_type.h" | 18 #include "chromeos/dbus/dbus_client_implementation_type.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
46 dbus_thread_->StartWithOptions(thread_options); | 47 dbus_thread_->StartWithOptions(thread_options); |
47 | 48 |
48 // Create the connection to the system bus. | 49 // Create the connection to the system bus. |
49 dbus::Bus::Options system_bus_options; | 50 dbus::Bus::Options system_bus_options; |
50 system_bus_options.bus_type = dbus::Bus::SYSTEM; | 51 system_bus_options.bus_type = dbus::Bus::SYSTEM; |
51 system_bus_options.connection_type = dbus::Bus::PRIVATE; | 52 system_bus_options.connection_type = dbus::Bus::PRIVATE; |
52 system_bus_options.dbus_thread_message_loop_proxy = | 53 system_bus_options.dbus_thread_message_loop_proxy = |
53 dbus_thread_->message_loop_proxy(); | 54 dbus_thread_->message_loop_proxy(); |
54 system_bus_ = new dbus::Bus(system_bus_options); | 55 system_bus_ = new dbus::Bus(system_bus_options); |
55 | 56 |
57 // Create the connection to the ibus bus. | |
satorux1
2012/04/23 23:09:21
Is this the right place to connect to the ibus bus
Seigo Nonaka
2012/04/24 00:37:58
Ah yes!
Done.
On 2012/04/23 23:09:21, satorux1 w
| |
58 std::string ibus_address; | |
59 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
60 if (env->GetVar("IBUS_ADDRESS", &ibus_address)) { | |
61 dbus::Bus::Options ibus_bus_options; | |
62 ibus_bus_options.bus_type = dbus::Bus::CUSTOM_ADDRESS; | |
63 ibus_bus_options.address = ibus_address; | |
64 ibus_bus_options.connection_type = dbus::Bus::PRIVATE; | |
65 ibus_bus_options.dbus_thread_message_loop_proxy = | |
66 dbus_thread_->message_loop_proxy(); | |
67 ibus_bus_ = new dbus::Bus(ibus_bus_options); | |
68 VLOG(1) << "Connected to ibus-daemon.(address:" << ibus_address << ")"; | |
69 } else { | |
70 LOG(ERROR) << "Can not connect to ibus-daemon."; | |
71 } | |
72 | |
56 // Determine whether we use stub or real client implementations. | 73 // Determine whether we use stub or real client implementations. |
57 const DBusClientImplementationType client_type = | 74 const DBusClientImplementationType client_type = |
58 base::chromeos::IsRunningOnChromeOS() ? | 75 base::chromeos::IsRunningOnChromeOS() ? |
59 REAL_DBUS_CLIENT_IMPLEMENTATION : STUB_DBUS_CLIENT_IMPLEMENTATION; | 76 REAL_DBUS_CLIENT_IMPLEMENTATION : STUB_DBUS_CLIENT_IMPLEMENTATION; |
60 | 77 |
61 // Create the bluetooth clients. | 78 // Create the bluetooth clients. |
62 bluetooth_manager_client_.reset(BluetoothManagerClient::Create( | 79 bluetooth_manager_client_.reset(BluetoothManagerClient::Create( |
63 client_type, system_bus_.get())); | 80 client_type, system_bus_.get())); |
64 bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create( | 81 bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create( |
65 client_type, system_bus_.get(), bluetooth_manager_client_.get())); | 82 client_type, system_bus_.get(), bluetooth_manager_client_.get())); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 // Stop the D-Bus thread. | 146 // Stop the D-Bus thread. |
130 dbus_thread_->Stop(); | 147 dbus_thread_->Stop(); |
131 } | 148 } |
132 | 149 |
133 // DBusThreadManager override. | 150 // DBusThreadManager override. |
134 virtual dbus::Bus* GetSystemBus() OVERRIDE { | 151 virtual dbus::Bus* GetSystemBus() OVERRIDE { |
135 return system_bus_.get(); | 152 return system_bus_.get(); |
136 } | 153 } |
137 | 154 |
138 // DBusThreadManager override. | 155 // DBusThreadManager override. |
156 virtual dbus::Bus* GetIBusBus() OVERRIDE { | |
157 return ibus_bus_.get(); | |
158 } | |
159 | |
160 // DBusThreadManager override. | |
139 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { | 161 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { |
140 return bluetooth_adapter_client_.get(); | 162 return bluetooth_adapter_client_.get(); |
141 } | 163 } |
142 | 164 |
143 // DBusThreadManager override. | 165 // DBusThreadManager override. |
144 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { | 166 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { |
145 return bluetooth_device_client_.get(); | 167 return bluetooth_device_client_.get(); |
146 } | 168 } |
147 | 169 |
148 // DBusThreadManager override. | 170 // DBusThreadManager override. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 return speech_synthesizer_client_.get(); | 262 return speech_synthesizer_client_.get(); |
241 } | 263 } |
242 | 264 |
243 // DBusThreadManager override. | 265 // DBusThreadManager override. |
244 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { | 266 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { |
245 return update_engine_client_.get(); | 267 return update_engine_client_.get(); |
246 } | 268 } |
247 | 269 |
248 scoped_ptr<base::Thread> dbus_thread_; | 270 scoped_ptr<base::Thread> dbus_thread_; |
249 scoped_refptr<dbus::Bus> system_bus_; | 271 scoped_refptr<dbus::Bus> system_bus_; |
272 scoped_refptr<dbus::Bus> ibus_bus_; | |
250 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; | 273 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; |
251 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; | 274 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; |
252 scoped_ptr<BluetoothInputClient> bluetooth_input_client_; | 275 scoped_ptr<BluetoothInputClient> bluetooth_input_client_; |
253 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_; | 276 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_; |
254 scoped_ptr<BluetoothNodeClient> bluetooth_node_client_; | 277 scoped_ptr<BluetoothNodeClient> bluetooth_node_client_; |
255 scoped_ptr<CashewClient> cashew_client_; | 278 scoped_ptr<CashewClient> cashew_client_; |
256 scoped_ptr<CrosDisksClient> cros_disks_client_; | 279 scoped_ptr<CrosDisksClient> cros_disks_client_; |
257 scoped_ptr<CryptohomeClient> cryptohome_client_; | 280 scoped_ptr<CryptohomeClient> cryptohome_client_; |
258 scoped_ptr<DebugDaemonClient> debugdaemon_client_; | 281 scoped_ptr<DebugDaemonClient> debugdaemon_client_; |
259 scoped_ptr<FlimflamDeviceClient> flimflam_device_client_; | 282 scoped_ptr<FlimflamDeviceClient> flimflam_device_client_; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 } | 334 } |
312 | 335 |
313 // static | 336 // static |
314 DBusThreadManager* DBusThreadManager::Get() { | 337 DBusThreadManager* DBusThreadManager::Get() { |
315 CHECK(g_dbus_thread_manager) | 338 CHECK(g_dbus_thread_manager) |
316 << "DBusThreadManager::Get() called before Initialize()"; | 339 << "DBusThreadManager::Get() called before Initialize()"; |
317 return g_dbus_thread_manager; | 340 return g_dbus_thread_manager; |
318 } | 341 } |
319 | 342 |
320 } // namespace chromeos | 343 } // namespace chromeos |
OLD | NEW |