| 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" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 << method_call->ToString(); | 206 << method_call->ToString(); |
| 207 return; | 207 return; |
| 208 } | 208 } |
| 209 bool visible = false; | 209 bool visible = false; |
| 210 if (!reader.PopBool(&visible)) { | 210 if (!reader.PopBool(&visible)) { |
| 211 LOG(WARNING) << "UpdateLookupTable called with incorrect parameters: " | 211 LOG(WARNING) << "UpdateLookupTable called with incorrect parameters: " |
| 212 << method_call->ToString(); | 212 << method_call->ToString(); |
| 213 return; | 213 return; |
| 214 } | 214 } |
| 215 candidate_window_handler_->UpdateLookupTable(table, visible); | 215 candidate_window_handler_->UpdateLookupTable(table, visible); |
| 216 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 216 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 217 response_sender.Run(response); | |
| 218 } | 217 } |
| 219 | 218 |
| 220 // Handles HideLookupTable method call from ibus-daemon. | 219 // Handles HideLookupTable method call from ibus-daemon. |
| 221 void HideLookupTable(dbus::MethodCall* method_call, | 220 void HideLookupTable(dbus::MethodCall* method_call, |
| 222 dbus::ExportedObject::ResponseSender response_sender) { | 221 dbus::ExportedObject::ResponseSender response_sender) { |
| 223 if (!candidate_window_handler_) | 222 if (!candidate_window_handler_) |
| 224 return; | 223 return; |
| 225 | 224 |
| 226 candidate_window_handler_->HideLookupTable(); | 225 candidate_window_handler_->HideLookupTable(); |
| 227 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 226 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 228 response_sender.Run(response); | |
| 229 } | 227 } |
| 230 | 228 |
| 231 // Handles UpdateAuxiliaryText method call from ibus-daemon. | 229 // Handles UpdateAuxiliaryText method call from ibus-daemon. |
| 232 void UpdateAuxiliaryText( | 230 void UpdateAuxiliaryText( |
| 233 dbus::MethodCall* method_call, | 231 dbus::MethodCall* method_call, |
| 234 dbus::ExportedObject::ResponseSender response_sender) { | 232 dbus::ExportedObject::ResponseSender response_sender) { |
| 235 if (!candidate_window_handler_) | 233 if (!candidate_window_handler_) |
| 236 return; | 234 return; |
| 237 | 235 |
| 238 dbus::MessageReader reader(method_call); | 236 dbus::MessageReader reader(method_call); |
| 239 std::string text; | 237 std::string text; |
| 240 if (!ibus::PopStringFromIBusText(&reader, &text)) { | 238 if (!ibus::PopStringFromIBusText(&reader, &text)) { |
| 241 LOG(WARNING) << "UpdateAuxiliaryText called with incorrect parameters: " | 239 LOG(WARNING) << "UpdateAuxiliaryText called with incorrect parameters: " |
| 242 << method_call->ToString(); | 240 << method_call->ToString(); |
| 243 return; | 241 return; |
| 244 } | 242 } |
| 245 bool visible = false; | 243 bool visible = false; |
| 246 if (!reader.PopBool(&visible)) { | 244 if (!reader.PopBool(&visible)) { |
| 247 LOG(WARNING) << "UpdateAuxiliaryText called with incorrect parameters: " | 245 LOG(WARNING) << "UpdateAuxiliaryText called with incorrect parameters: " |
| 248 << method_call->ToString(); | 246 << method_call->ToString(); |
| 249 return; | 247 return; |
| 250 } | 248 } |
| 251 candidate_window_handler_->UpdateAuxiliaryText(text, visible); | 249 candidate_window_handler_->UpdateAuxiliaryText(text, visible); |
| 252 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 250 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 253 response_sender.Run(response); | |
| 254 } | 251 } |
| 255 | 252 |
| 256 // Handles HideAuxiliaryText method call from ibus-daemon. | 253 // Handles HideAuxiliaryText method call from ibus-daemon. |
| 257 void HideAuxiliaryText(dbus::MethodCall* method_call, | 254 void HideAuxiliaryText(dbus::MethodCall* method_call, |
| 258 dbus::ExportedObject::ResponseSender response_sender) { | 255 dbus::ExportedObject::ResponseSender response_sender) { |
| 259 if (!candidate_window_handler_) | 256 if (!candidate_window_handler_) |
| 260 return; | 257 return; |
| 261 | 258 |
| 262 candidate_window_handler_->HideAuxiliaryText(); | 259 candidate_window_handler_->HideAuxiliaryText(); |
| 263 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 260 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 264 response_sender.Run(response); | |
| 265 } | 261 } |
| 266 | 262 |
| 267 // Handles UpdatePreeditText method call from ibus-daemon. | 263 // Handles UpdatePreeditText method call from ibus-daemon. |
| 268 void UpdatePreeditText(dbus::MethodCall* method_call, | 264 void UpdatePreeditText(dbus::MethodCall* method_call, |
| 269 dbus::ExportedObject::ResponseSender response_sender) { | 265 dbus::ExportedObject::ResponseSender response_sender) { |
| 270 if (!candidate_window_handler_) | 266 if (!candidate_window_handler_) |
| 271 return; | 267 return; |
| 272 | 268 |
| 273 dbus::MessageReader reader(method_call); | 269 dbus::MessageReader reader(method_call); |
| 274 std::string text; | 270 std::string text; |
| 275 if (!ibus::PopStringFromIBusText(&reader, &text)) { | 271 if (!ibus::PopStringFromIBusText(&reader, &text)) { |
| 276 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " | 272 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " |
| 277 << method_call->ToString(); | 273 << method_call->ToString(); |
| 278 return; | 274 return; |
| 279 } | 275 } |
| 280 uint32 cursor_pos = 0; | 276 uint32 cursor_pos = 0; |
| 281 if (!reader.PopUint32(&cursor_pos)) { | 277 if (!reader.PopUint32(&cursor_pos)) { |
| 282 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " | 278 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " |
| 283 << method_call->ToString(); | 279 << method_call->ToString(); |
| 284 return; | 280 return; |
| 285 } | 281 } |
| 286 bool visible = false; | 282 bool visible = false; |
| 287 if (!reader.PopBool(&visible)) { | 283 if (!reader.PopBool(&visible)) { |
| 288 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " | 284 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " |
| 289 << method_call->ToString(); | 285 << method_call->ToString(); |
| 290 return; | 286 return; |
| 291 } | 287 } |
| 292 candidate_window_handler_->UpdatePreeditText(text, cursor_pos, visible); | 288 candidate_window_handler_->UpdatePreeditText(text, cursor_pos, visible); |
| 293 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 289 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 294 response_sender.Run(response); | |
| 295 } | 290 } |
| 296 | 291 |
| 297 // Handles HidePreeditText method call from ibus-daemon. | 292 // Handles HidePreeditText method call from ibus-daemon. |
| 298 void HidePreeditText(dbus::MethodCall* method_call, | 293 void HidePreeditText(dbus::MethodCall* method_call, |
| 299 dbus::ExportedObject::ResponseSender response_sender) { | 294 dbus::ExportedObject::ResponseSender response_sender) { |
| 300 if (!candidate_window_handler_) | 295 if (!candidate_window_handler_) |
| 301 return; | 296 return; |
| 302 | 297 |
| 303 candidate_window_handler_->HidePreeditText(); | 298 candidate_window_handler_->HidePreeditText(); |
| 304 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 299 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 305 response_sender.Run(response); | |
| 306 } | 300 } |
| 307 | 301 |
| 308 // Handles RegisterProperties method call from ibus-daemon. | 302 // Handles RegisterProperties method call from ibus-daemon. |
| 309 void RegisterProperties( | 303 void RegisterProperties( |
| 310 dbus::MethodCall* method_call, | 304 dbus::MethodCall* method_call, |
| 311 dbus::ExportedObject::ResponseSender response_sender) { | 305 dbus::ExportedObject::ResponseSender response_sender) { |
| 312 if (!property_handler_) | 306 if (!property_handler_) |
| 313 return; | 307 return; |
| 314 | 308 |
| 315 dbus::MessageReader reader(method_call); | 309 dbus::MessageReader reader(method_call); |
| 316 ibus::IBusPropertyList properties; | 310 ibus::IBusPropertyList properties; |
| 317 if (!ibus::PopIBusPropertyList(&reader, &properties)) { | 311 if (!ibus::PopIBusPropertyList(&reader, &properties)) { |
| 318 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" | 312 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" |
| 319 << method_call->ToString(); | 313 << method_call->ToString(); |
| 320 return; | 314 return; |
| 321 } | 315 } |
| 322 property_handler_->RegisterProperties(properties); | 316 property_handler_->RegisterProperties(properties); |
| 323 | 317 |
| 324 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 318 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 325 response_sender.Run(response); | |
| 326 } | 319 } |
| 327 | 320 |
| 328 // Handles UpdateProperty method call from ibus-daemon. | 321 // Handles UpdateProperty method call from ibus-daemon. |
| 329 void UpdateProperty(dbus::MethodCall* method_call, | 322 void UpdateProperty(dbus::MethodCall* method_call, |
| 330 dbus::ExportedObject::ResponseSender response_sender) { | 323 dbus::ExportedObject::ResponseSender response_sender) { |
| 331 if (!property_handler_) | 324 if (!property_handler_) |
| 332 return; | 325 return; |
| 333 | 326 |
| 334 dbus::MessageReader reader(method_call); | 327 dbus::MessageReader reader(method_call); |
| 335 ibus::IBusProperty property; | 328 ibus::IBusProperty property; |
| 336 if (!ibus::PopIBusProperty(&reader, &property)) { | 329 if (!ibus::PopIBusProperty(&reader, &property)) { |
| 337 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" | 330 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" |
| 338 << method_call->ToString(); | 331 << method_call->ToString(); |
| 339 return; | 332 return; |
| 340 } | 333 } |
| 341 property_handler_->UpdateProperty(property); | 334 property_handler_->UpdateProperty(property); |
| 342 | 335 |
| 343 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 336 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 344 response_sender.Run(response); | |
| 345 } | 337 } |
| 346 | 338 |
| 347 void SetCursorLocation(const ibus::Rect& cursor_location, | 339 void SetCursorLocation(const ibus::Rect& cursor_location, |
| 348 const ibus::Rect& composition_head) { | 340 const ibus::Rect& composition_head) { |
| 349 // TODO(nona): implement this function. | 341 // TODO(nona): implement this function. |
| 350 } | 342 } |
| 351 | 343 |
| 352 // Handles FocusIn, FocusOut, StateChanged method calls from IBus, and ignores | 344 // Handles FocusIn, FocusOut, StateChanged method calls from IBus, and ignores |
| 353 // them. | 345 // them. |
| 354 void NoOperation(dbus::MethodCall* method_call, | 346 void NoOperation(dbus::MethodCall* method_call, |
| 355 dbus::ExportedObject::ResponseSender response_sender) { | 347 dbus::ExportedObject::ResponseSender response_sender) { |
| 356 if (!property_handler_) | 348 if (!property_handler_) |
| 357 return; | 349 return; |
| 358 | 350 |
| 359 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 351 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 360 response_sender.Run(response); | |
| 361 } | 352 } |
| 362 | 353 |
| 363 // Called when the method call is exported. | 354 // Called when the method call is exported. |
| 364 void OnMethodExported(const std::string& interface_name, | 355 void OnMethodExported(const std::string& interface_name, |
| 365 const std::string& method_name, | 356 const std::string& method_name, |
| 366 bool success) { | 357 bool success) { |
| 367 LOG_IF(WARNING, !success) << "Failed to export " | 358 LOG_IF(WARNING, !success) << "Failed to export " |
| 368 << interface_name << "." << method_name; | 359 << interface_name << "." << method_name; |
| 369 } | 360 } |
| 370 | 361 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 IBusInputContextClient* input_context) { | 444 IBusInputContextClient* input_context) { |
| 454 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { | 445 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { |
| 455 return new IBusPanelServiceImpl(bus, input_context); | 446 return new IBusPanelServiceImpl(bus, input_context); |
| 456 } else { | 447 } else { |
| 457 return new IBusPanelServiceDaemonlessImpl(); | 448 return new IBusPanelServiceDaemonlessImpl(); |
| 458 } | 449 } |
| 459 } | 450 } |
| 460 | 451 |
| 461 } // namespace ibus | 452 } // namespace ibus |
| 462 } // namespace chromeos | 453 } // namespace chromeos |
| OLD | NEW |