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_engine_service.h" | 5 #include "chromeos/dbus/ibus/ibus_engine_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" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 exported_object_->SendSignal(&signal); | 206 exported_object_->SendSignal(&signal); |
207 } | 207 } |
208 | 208 |
209 // IBusEngineService override. | 209 // IBusEngineService override. |
210 virtual void RequireSurroundingText() OVERRIDE { | 210 virtual void RequireSurroundingText() OVERRIDE { |
211 dbus::Signal signal(ibus::engine::kServiceInterface, | 211 dbus::Signal signal(ibus::engine::kServiceInterface, |
212 ibus::engine::kRequireSurroundingTextSignal); | 212 ibus::engine::kRequireSurroundingTextSignal); |
213 exported_object_->SendSignal(&signal); | 213 exported_object_->SendSignal(&signal); |
214 } | 214 } |
215 | 215 |
| 216 virtual void CommitText(const std::string& text) OVERRIDE { |
| 217 dbus::Signal signal(ibus::engine::kServiceInterface, |
| 218 ibus::engine::kCommitTextSignal); |
| 219 dbus::MessageWriter writer(&signal); |
| 220 ibus::AppendStringAsIBusText(text, &writer); |
| 221 exported_object_->SendSignal(&signal); |
| 222 } |
| 223 |
216 private: | 224 private: |
217 // Handles FocusIn method call from ibus-daemon. | 225 // Handles FocusIn method call from ibus-daemon. |
218 void FocusIn(dbus::MethodCall* method_call, | 226 void FocusIn(dbus::MethodCall* method_call, |
219 dbus::ExportedObject::ResponseSender response_sender) { | 227 dbus::ExportedObject::ResponseSender response_sender) { |
220 DCHECK(engine_handler_.get()); | 228 DCHECK(engine_handler_.get()); |
221 engine_handler_->FocusIn(); | 229 engine_handler_->FocusIn(); |
222 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 230 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
223 response_sender.Run(response); | 231 response_sender.Run(response); |
224 } | 232 } |
225 | 233 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 << method_call->ToString(); | 356 << method_call->ToString(); |
349 return; | 357 return; |
350 } | 358 } |
351 uint32 state = 0; | 359 uint32 state = 0; |
352 if (!reader.PopUint32(&state)) { | 360 if (!reader.PopUint32(&state)) { |
353 LOG(WARNING) << "ProcessKeyEvent called with incorrect parameters: " | 361 LOG(WARNING) << "ProcessKeyEvent called with incorrect parameters: " |
354 << method_call->ToString(); | 362 << method_call->ToString(); |
355 return; | 363 return; |
356 } | 364 } |
357 DCHECK(engine_handler_.get()); | 365 DCHECK(engine_handler_.get()); |
358 bool consume = engine_handler_->ProcessKeyEvent(keysym, keycode, state); | 366 engine_handler_->ProcessKeyEvent( |
359 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 367 keysym, keycode, state, |
| 368 base::Bind(&IBusEngineServiceImpl::KeyEventDone, |
| 369 weak_ptr_factory_.GetWeakPtr(), |
| 370 base::Unretained( |
| 371 dbus::Response::FromMethodCall(method_call)), |
| 372 response_sender)); |
| 373 } |
| 374 |
| 375 void KeyEventDone(dbus::Response* response, |
| 376 const dbus::ExportedObject::ResponseSender& response_sender, |
| 377 bool consume) { |
360 dbus::MessageWriter writer(response); | 378 dbus::MessageWriter writer(response); |
361 writer.AppendBool(consume); | 379 writer.AppendBool(consume); |
362 response_sender.Run(response); | 380 response_sender.Run(response); |
363 } | 381 } |
364 | 382 |
365 // Handles CandidateClicked method call from ibus-daemon. | 383 // Handles CandidateClicked method call from ibus-daemon. |
366 void CandidateClicked(dbus::MethodCall* method_call, | 384 void CandidateClicked(dbus::MethodCall* method_call, |
367 dbus::ExportedObject::ResponseSender response_sender) { | 385 dbus::ExportedObject::ResponseSender response_sender) { |
368 dbus::MessageReader reader(method_call); | 386 dbus::MessageReader reader(method_call); |
369 uint32 index = 0; | 387 uint32 index = 0; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 bool is_visible, | 475 bool is_visible, |
458 IBusEnginePreeditFocusOutMode mode) OVERRIDE {} | 476 IBusEnginePreeditFocusOutMode mode) OVERRIDE {} |
459 virtual void UpdateAuxiliaryText(const ibus::IBusText& ibus_text, | 477 virtual void UpdateAuxiliaryText(const ibus::IBusText& ibus_text, |
460 bool is_visible) OVERRIDE {} | 478 bool is_visible) OVERRIDE {} |
461 virtual void UpdateLookupTable(const ibus::IBusLookupTable& lookup_table, | 479 virtual void UpdateLookupTable(const ibus::IBusLookupTable& lookup_table, |
462 bool is_visible) OVERRIDE {} | 480 bool is_visible) OVERRIDE {} |
463 virtual void UpdateProperty(const ibus::IBusProperty& property) OVERRIDE {} | 481 virtual void UpdateProperty(const ibus::IBusProperty& property) OVERRIDE {} |
464 virtual void ForwardKeyEvent(uint32 keyval, uint32 keycode, | 482 virtual void ForwardKeyEvent(uint32 keyval, uint32 keycode, |
465 uint32 state) OVERRIDE {} | 483 uint32 state) OVERRIDE {} |
466 virtual void RequireSurroundingText() OVERRIDE {} | 484 virtual void RequireSurroundingText() OVERRIDE {} |
| 485 virtual void CommitText(const std::string& text) OVERRIDE {} |
| 486 |
467 private: | 487 private: |
468 DISALLOW_COPY_AND_ASSIGN(IBusEngineServiceStubImpl); | 488 DISALLOW_COPY_AND_ASSIGN(IBusEngineServiceStubImpl); |
469 }; | 489 }; |
470 | 490 |
471 IBusEngineService::IBusEngineService() { | 491 IBusEngineService::IBusEngineService() { |
472 } | 492 } |
473 | 493 |
474 IBusEngineService::~IBusEngineService() { | 494 IBusEngineService::~IBusEngineService() { |
475 } | 495 } |
476 | 496 |
477 // static | 497 // static |
478 IBusEngineService* IBusEngineService::Create( | 498 IBusEngineService* IBusEngineService::Create( |
479 DBusClientImplementationType type, | 499 DBusClientImplementationType type, |
480 dbus::Bus* bus, | 500 dbus::Bus* bus, |
481 const dbus::ObjectPath& object_path) { | 501 const dbus::ObjectPath& object_path) { |
482 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 502 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
483 return new IBusEngineServiceImpl(bus, object_path); | 503 return new IBusEngineServiceImpl(bus, object_path); |
484 else | 504 else |
485 return new IBusEngineServiceStubImpl(); | 505 return new IBusEngineServiceStubImpl(); |
486 } | 506 } |
487 | 507 |
488 } // namespace chromeos | 508 } // namespace chromeos |
OLD | NEW |