| 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/ibus/ibus_panel_service.h" | 5 #include "chromeos/dbus/ibus/ibus_panel_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "chromeos/dbus/ibus/ibus_constants.h" | 10 #include "chromeos/dbus/ibus/ibus_constants.h" |
| 11 #include "chromeos/dbus/ibus/ibus_input_context_client.h" |
| 11 #include "chromeos/dbus/ibus/ibus_lookup_table.h" | 12 #include "chromeos/dbus/ibus/ibus_lookup_table.h" |
| 12 #include "chromeos/dbus/ibus/ibus_property.h" | 13 #include "chromeos/dbus/ibus/ibus_property.h" |
| 13 #include "chromeos/dbus/ibus/ibus_text.h" | 14 #include "chromeos/dbus/ibus/ibus_text.h" |
| 14 #include "dbus/bus.h" | 15 #include "dbus/bus.h" |
| 15 #include "dbus/exported_object.h" | 16 #include "dbus/exported_object.h" |
| 16 #include "dbus/message.h" | 17 #include "dbus/message.h" |
| 17 #include "dbus/object_path.h" | 18 #include "dbus/object_path.h" |
| 18 #include "dbus/object_proxy.h" | 19 #include "dbus/object_proxy.h" |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace chromeos { |
| 21 // TODO(nona): Remove ibus namespace after complete libibus removal. | 22 // TODO(nona): Remove ibus namespace after complete libibus removal. |
| 22 namespace ibus { | 23 namespace ibus { |
| 23 | 24 |
| 24 class IBusPanelServiceImpl : public IBusPanelService { | 25 class IBusPanelServiceImpl : public IBusPanelService { |
| 25 public: | 26 public: |
| 26 explicit IBusPanelServiceImpl(dbus::Bus* bus) | 27 explicit IBusPanelServiceImpl(dbus::Bus* bus, |
| 28 IBusInputContextClient* input_context) |
| 27 : bus_(bus), | 29 : bus_(bus), |
| 28 candidate_window_handler_(NULL), | 30 candidate_window_handler_(NULL), |
| 29 property_handler_(NULL), | 31 property_handler_(NULL), |
| 30 weak_ptr_factory_(this) { | 32 weak_ptr_factory_(this) { |
| 31 exported_object_ = bus->GetExportedObject( | 33 exported_object_ = bus->GetExportedObject( |
| 32 dbus::ObjectPath(ibus::panel::kServicePath)); | 34 dbus::ObjectPath(ibus::panel::kServicePath)); |
| 33 | 35 |
| 34 exported_object_->ExportMethod( | 36 exported_object_->ExportMethod( |
| 35 ibus::panel::kServiceInterface, | 37 ibus::panel::kServiceInterface, |
| 36 ibus::panel::kUpdateLookupTableMethod, | 38 ibus::panel::kUpdateLookupTableMethod, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 base::Bind(&IBusPanelServiceImpl::NoOperation, | 119 base::Bind(&IBusPanelServiceImpl::NoOperation, |
| 118 weak_ptr_factory_.GetWeakPtr()), | 120 weak_ptr_factory_.GetWeakPtr()), |
| 119 base::Bind(&IBusPanelServiceImpl::OnMethodExported, | 121 base::Bind(&IBusPanelServiceImpl::OnMethodExported, |
| 120 weak_ptr_factory_.GetWeakPtr())); | 122 weak_ptr_factory_.GetWeakPtr())); |
| 121 | 123 |
| 122 // Request well known name to ibus-daemon. | 124 // Request well known name to ibus-daemon. |
| 123 bus->RequestOwnership( | 125 bus->RequestOwnership( |
| 124 ibus::panel::kServiceName, | 126 ibus::panel::kServiceName, |
| 125 base::Bind(&IBusPanelServiceImpl::OnRequestOwnership, | 127 base::Bind(&IBusPanelServiceImpl::OnRequestOwnership, |
| 126 weak_ptr_factory_.GetWeakPtr())); | 128 weak_ptr_factory_.GetWeakPtr())); |
| 129 |
| 130 input_context->SetSetCursorLocationHandler( |
| 131 base::Bind(&IBusPanelServiceImpl::SetCursorLocation, |
| 132 weak_ptr_factory_.GetWeakPtr())); |
| 127 } | 133 } |
| 128 | 134 |
| 129 virtual ~IBusPanelServiceImpl() { | 135 virtual ~IBusPanelServiceImpl() { |
| 130 bus_->UnregisterExportedObject( | 136 bus_->UnregisterExportedObject( |
| 131 dbus::ObjectPath(ibus::panel::kServicePath)); | 137 dbus::ObjectPath(ibus::panel::kServicePath)); |
| 132 } | 138 } |
| 133 | 139 |
| 134 // IBusPanelService override. | 140 // IBusPanelService override. |
| 135 virtual void SetUpCandidateWindowHandler( | 141 virtual void SetUpCandidateWindowHandler( |
| 136 IBusPanelCandidateWindowHandlerInterface* handler) { | 142 IBusPanelCandidateWindowHandlerInterface* handler) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" | 337 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" |
| 332 << method_call->ToString(); | 338 << method_call->ToString(); |
| 333 return; | 339 return; |
| 334 } | 340 } |
| 335 property_handler_->UpdateProperty(property); | 341 property_handler_->UpdateProperty(property); |
| 336 | 342 |
| 337 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 343 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
| 338 response_sender.Run(response); | 344 response_sender.Run(response); |
| 339 } | 345 } |
| 340 | 346 |
| 347 void SetCursorLocation(const ibus::Rect& cursor_location, |
| 348 const ibus::Rect& composition_head) { |
| 349 // TODO(nona): implement this function. |
| 350 } |
| 351 |
| 341 // Handles FocusIn, FocusOut, StateChanged method calls from IBus, and ignores | 352 // Handles FocusIn, FocusOut, StateChanged method calls from IBus, and ignores |
| 342 // them. | 353 // them. |
| 343 void NoOperation(dbus::MethodCall* method_call, | 354 void NoOperation(dbus::MethodCall* method_call, |
| 344 dbus::ExportedObject::ResponseSender response_sender) { | 355 dbus::ExportedObject::ResponseSender response_sender) { |
| 345 if (!property_handler_) | 356 if (!property_handler_) |
| 346 return; | 357 return; |
| 347 | 358 |
| 348 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 359 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
| 349 response_sender.Run(response); | 360 response_sender.Run(response); |
| 350 } | 361 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 DISALLOW_COPY_AND_ASSIGN(IBusPanelServiceDaemonlessImpl); | 440 DISALLOW_COPY_AND_ASSIGN(IBusPanelServiceDaemonlessImpl); |
| 430 }; | 441 }; |
| 431 | 442 |
| 432 IBusPanelService::IBusPanelService() { | 443 IBusPanelService::IBusPanelService() { |
| 433 } | 444 } |
| 434 | 445 |
| 435 IBusPanelService::~IBusPanelService() { | 446 IBusPanelService::~IBusPanelService() { |
| 436 } | 447 } |
| 437 | 448 |
| 438 // static | 449 // static |
| 439 IBusPanelService* IBusPanelService::Create(DBusClientImplementationType type, | 450 IBusPanelService* IBusPanelService::Create( |
| 440 dbus::Bus* bus) { | 451 DBusClientImplementationType type, |
| 452 dbus::Bus* bus, |
| 453 IBusInputContextClient* input_context) { |
| 441 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { | 454 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { |
| 442 return new IBusPanelServiceImpl(bus); | 455 return new IBusPanelServiceImpl(bus, input_context); |
| 443 } else { | 456 } else { |
| 444 return new IBusPanelServiceDaemonlessImpl(); | 457 return new IBusPanelServiceDaemonlessImpl(); |
| 445 } | 458 } |
| 446 } | 459 } |
| 447 | 460 |
| 448 } // namespace ibus | 461 } // namespace ibus |
| 449 } // namespace chromeos | 462 } // namespace chromeos |
| OLD | NEW |