| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 << method_call->ToString(); | 204 << method_call->ToString(); |
| 205 return; | 205 return; |
| 206 } | 206 } |
| 207 bool visible = false; | 207 bool visible = false; |
| 208 if (!reader.PopBool(&visible)) { | 208 if (!reader.PopBool(&visible)) { |
| 209 LOG(WARNING) << "UpdateLookupTable called with incorrect parameters: " | 209 LOG(WARNING) << "UpdateLookupTable called with incorrect parameters: " |
| 210 << method_call->ToString(); | 210 << method_call->ToString(); |
| 211 return; | 211 return; |
| 212 } | 212 } |
| 213 candidate_window_handler_->UpdateLookupTable(table, visible); | 213 candidate_window_handler_->UpdateLookupTable(table, visible); |
| 214 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 214 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 215 response_sender.Run(response); | |
| 216 } | 215 } |
| 217 | 216 |
| 218 // Handles HideLookupTable method call from ibus-daemon. | 217 // Handles HideLookupTable method call from ibus-daemon. |
| 219 void HideLookupTable(dbus::MethodCall* method_call, | 218 void HideLookupTable(dbus::MethodCall* method_call, |
| 220 dbus::ExportedObject::ResponseSender response_sender) { | 219 dbus::ExportedObject::ResponseSender response_sender) { |
| 221 if (!candidate_window_handler_) | 220 if (!candidate_window_handler_) |
| 222 return; | 221 return; |
| 223 | 222 |
| 224 candidate_window_handler_->HideLookupTable(); | 223 candidate_window_handler_->HideLookupTable(); |
| 225 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 224 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 226 response_sender.Run(response); | |
| 227 } | 225 } |
| 228 | 226 |
| 229 // Handles UpdateAuxiliaryText method call from ibus-daemon. | 227 // Handles UpdateAuxiliaryText method call from ibus-daemon. |
| 230 void UpdateAuxiliaryText( | 228 void UpdateAuxiliaryText( |
| 231 dbus::MethodCall* method_call, | 229 dbus::MethodCall* method_call, |
| 232 dbus::ExportedObject::ResponseSender response_sender) { | 230 dbus::ExportedObject::ResponseSender response_sender) { |
| 233 if (!candidate_window_handler_) | 231 if (!candidate_window_handler_) |
| 234 return; | 232 return; |
| 235 | 233 |
| 236 dbus::MessageReader reader(method_call); | 234 dbus::MessageReader reader(method_call); |
| 237 std::string text; | 235 std::string text; |
| 238 if (!PopStringFromIBusText(&reader, &text)) { | 236 if (!PopStringFromIBusText(&reader, &text)) { |
| 239 LOG(WARNING) << "UpdateAuxiliaryText called with incorrect parameters: " | 237 LOG(WARNING) << "UpdateAuxiliaryText called with incorrect parameters: " |
| 240 << method_call->ToString(); | 238 << method_call->ToString(); |
| 241 return; | 239 return; |
| 242 } | 240 } |
| 243 bool visible = false; | 241 bool visible = false; |
| 244 if (!reader.PopBool(&visible)) { | 242 if (!reader.PopBool(&visible)) { |
| 245 LOG(WARNING) << "UpdateAuxiliaryText called with incorrect parameters: " | 243 LOG(WARNING) << "UpdateAuxiliaryText called with incorrect parameters: " |
| 246 << method_call->ToString(); | 244 << method_call->ToString(); |
| 247 return; | 245 return; |
| 248 } | 246 } |
| 249 candidate_window_handler_->UpdateAuxiliaryText(text, visible); | 247 candidate_window_handler_->UpdateAuxiliaryText(text, visible); |
| 250 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 248 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 251 response_sender.Run(response); | |
| 252 } | 249 } |
| 253 | 250 |
| 254 // Handles HideAuxiliaryText method call from ibus-daemon. | 251 // Handles HideAuxiliaryText method call from ibus-daemon. |
| 255 void HideAuxiliaryText(dbus::MethodCall* method_call, | 252 void HideAuxiliaryText(dbus::MethodCall* method_call, |
| 256 dbus::ExportedObject::ResponseSender response_sender) { | 253 dbus::ExportedObject::ResponseSender response_sender) { |
| 257 if (!candidate_window_handler_) | 254 if (!candidate_window_handler_) |
| 258 return; | 255 return; |
| 259 | 256 |
| 260 candidate_window_handler_->HideAuxiliaryText(); | 257 candidate_window_handler_->HideAuxiliaryText(); |
| 261 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 258 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 262 response_sender.Run(response); | |
| 263 } | 259 } |
| 264 | 260 |
| 265 // Handles UpdatePreeditText method call from ibus-daemon. | 261 // Handles UpdatePreeditText method call from ibus-daemon. |
| 266 void UpdatePreeditText(dbus::MethodCall* method_call, | 262 void UpdatePreeditText(dbus::MethodCall* method_call, |
| 267 dbus::ExportedObject::ResponseSender response_sender) { | 263 dbus::ExportedObject::ResponseSender response_sender) { |
| 268 if (!candidate_window_handler_) | 264 if (!candidate_window_handler_) |
| 269 return; | 265 return; |
| 270 | 266 |
| 271 dbus::MessageReader reader(method_call); | 267 dbus::MessageReader reader(method_call); |
| 272 std::string text; | 268 std::string text; |
| 273 if (!PopStringFromIBusText(&reader, &text)) { | 269 if (!PopStringFromIBusText(&reader, &text)) { |
| 274 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " | 270 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " |
| 275 << method_call->ToString(); | 271 << method_call->ToString(); |
| 276 return; | 272 return; |
| 277 } | 273 } |
| 278 uint32 cursor_pos = 0; | 274 uint32 cursor_pos = 0; |
| 279 if (!reader.PopUint32(&cursor_pos)) { | 275 if (!reader.PopUint32(&cursor_pos)) { |
| 280 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " | 276 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " |
| 281 << method_call->ToString(); | 277 << method_call->ToString(); |
| 282 return; | 278 return; |
| 283 } | 279 } |
| 284 bool visible = false; | 280 bool visible = false; |
| 285 if (!reader.PopBool(&visible)) { | 281 if (!reader.PopBool(&visible)) { |
| 286 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " | 282 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " |
| 287 << method_call->ToString(); | 283 << method_call->ToString(); |
| 288 return; | 284 return; |
| 289 } | 285 } |
| 290 candidate_window_handler_->UpdatePreeditText(text, cursor_pos, visible); | 286 candidate_window_handler_->UpdatePreeditText(text, cursor_pos, visible); |
| 291 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 287 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 292 response_sender.Run(response); | |
| 293 } | 288 } |
| 294 | 289 |
| 295 // Handles HidePreeditText method call from ibus-daemon. | 290 // Handles HidePreeditText method call from ibus-daemon. |
| 296 void HidePreeditText(dbus::MethodCall* method_call, | 291 void HidePreeditText(dbus::MethodCall* method_call, |
| 297 dbus::ExportedObject::ResponseSender response_sender) { | 292 dbus::ExportedObject::ResponseSender response_sender) { |
| 298 if (!candidate_window_handler_) | 293 if (!candidate_window_handler_) |
| 299 return; | 294 return; |
| 300 | 295 |
| 301 candidate_window_handler_->HidePreeditText(); | 296 candidate_window_handler_->HidePreeditText(); |
| 302 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 297 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 303 response_sender.Run(response); | |
| 304 } | 298 } |
| 305 | 299 |
| 306 // Handles RegisterProperties method call from ibus-daemon. | 300 // Handles RegisterProperties method call from ibus-daemon. |
| 307 void RegisterProperties( | 301 void RegisterProperties( |
| 308 dbus::MethodCall* method_call, | 302 dbus::MethodCall* method_call, |
| 309 dbus::ExportedObject::ResponseSender response_sender) { | 303 dbus::ExportedObject::ResponseSender response_sender) { |
| 310 if (!property_handler_) | 304 if (!property_handler_) |
| 311 return; | 305 return; |
| 312 | 306 |
| 313 dbus::MessageReader reader(method_call); | 307 dbus::MessageReader reader(method_call); |
| 314 IBusPropertyList properties; | 308 IBusPropertyList properties; |
| 315 if (!PopIBusPropertyList(&reader, &properties)) { | 309 if (!PopIBusPropertyList(&reader, &properties)) { |
| 316 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" | 310 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" |
| 317 << method_call->ToString(); | 311 << method_call->ToString(); |
| 318 return; | 312 return; |
| 319 } | 313 } |
| 320 property_handler_->RegisterProperties(properties); | 314 property_handler_->RegisterProperties(properties); |
| 321 | 315 |
| 322 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 316 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 323 response_sender.Run(response); | |
| 324 } | 317 } |
| 325 | 318 |
| 326 // Handles UpdateProperty method call from ibus-daemon. | 319 // Handles UpdateProperty method call from ibus-daemon. |
| 327 void UpdateProperty(dbus::MethodCall* method_call, | 320 void UpdateProperty(dbus::MethodCall* method_call, |
| 328 dbus::ExportedObject::ResponseSender response_sender) { | 321 dbus::ExportedObject::ResponseSender response_sender) { |
| 329 if (!property_handler_) | 322 if (!property_handler_) |
| 330 return; | 323 return; |
| 331 | 324 |
| 332 dbus::MessageReader reader(method_call); | 325 dbus::MessageReader reader(method_call); |
| 333 IBusProperty property; | 326 IBusProperty property; |
| 334 if (!PopIBusProperty(&reader, &property)) { | 327 if (!PopIBusProperty(&reader, &property)) { |
| 335 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" | 328 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" |
| 336 << method_call->ToString(); | 329 << method_call->ToString(); |
| 337 return; | 330 return; |
| 338 } | 331 } |
| 339 property_handler_->UpdateProperty(property); | 332 property_handler_->UpdateProperty(property); |
| 340 | 333 |
| 341 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 334 response_sender.Run(dbus::Response::FromMethodCall(method_call)); |
| 342 response_sender.Run(response); | |
| 343 } | 335 } |
| 344 | 336 |
| 345 void SetCursorLocation(const ibus::Rect& cursor_location, | 337 void SetCursorLocation(const ibus::Rect& cursor_location, |
| 346 const ibus::Rect& composition_head) { | 338 const ibus::Rect& composition_head) { |
| 347 if (candidate_window_handler_) | 339 if (candidate_window_handler_) |
| 348 candidate_window_handler_->SetCursorLocation(cursor_location, | 340 candidate_window_handler_->SetCursorLocation(cursor_location, |
| 349 composition_head); | 341 composition_head); |
| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 dbus::Bus* bus, | 443 dbus::Bus* bus, |
| 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 chromeos | 452 } // namespace chromeos |
| OLD | NEW |