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_input_context_client.h" |
12 #include "chromeos/dbus/ibus/ibus_lookup_table.h" | 12 #include "chromeos/dbus/ibus/ibus_lookup_table.h" |
13 #include "chromeos/dbus/ibus/ibus_property.h" | 13 #include "chromeos/dbus/ibus/ibus_property.h" |
14 #include "chromeos/dbus/ibus/ibus_text.h" | 14 #include "chromeos/dbus/ibus/ibus_text.h" |
15 #include "dbus/bus.h" | 15 #include "dbus/bus.h" |
16 #include "dbus/exported_object.h" | 16 #include "dbus/exported_object.h" |
17 #include "dbus/message.h" | 17 #include "dbus/message.h" |
18 #include "dbus/object_path.h" | 18 #include "dbus/object_path.h" |
19 #include "dbus/object_proxy.h" | 19 #include "dbus/object_proxy.h" |
20 | 20 |
21 namespace chromeos { | 21 namespace chromeos { |
22 // TODO(nona): Remove ibus namespace after complete libibus removal. | |
23 namespace ibus { | |
24 | 22 |
25 class IBusPanelServiceImpl : public IBusPanelService { | 23 class IBusPanelServiceImpl : public IBusPanelService { |
26 public: | 24 public: |
27 explicit IBusPanelServiceImpl(dbus::Bus* bus, | 25 explicit IBusPanelServiceImpl(dbus::Bus* bus, |
28 IBusInputContextClient* input_context) | 26 IBusInputContextClient* input_context) |
29 : bus_(bus), | 27 : bus_(bus), |
30 candidate_window_handler_(NULL), | 28 candidate_window_handler_(NULL), |
31 property_handler_(NULL), | 29 property_handler_(NULL), |
32 weak_ptr_factory_(this) { | 30 weak_ptr_factory_(this) { |
33 exported_object_ = bus->GetExportedObject( | 31 exported_object_ = bus->GetExportedObject( |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 191 } |
194 | 192 |
195 private: | 193 private: |
196 // Handles UpdateLookupTable method call from ibus-daemon. | 194 // Handles UpdateLookupTable method call from ibus-daemon. |
197 void UpdateLookupTable(dbus::MethodCall* method_call, | 195 void UpdateLookupTable(dbus::MethodCall* method_call, |
198 dbus::ExportedObject::ResponseSender response_sender) { | 196 dbus::ExportedObject::ResponseSender response_sender) { |
199 if (!candidate_window_handler_) | 197 if (!candidate_window_handler_) |
200 return; | 198 return; |
201 | 199 |
202 dbus::MessageReader reader(method_call); | 200 dbus::MessageReader reader(method_call); |
203 ibus::IBusLookupTable table; | 201 IBusLookupTable table; |
204 if (!ibus::PopIBusLookupTable(&reader, &table)) { | 202 if (!PopIBusLookupTable(&reader, &table)) { |
205 LOG(WARNING) << "UpdateLookupTable called with incorrect parameters: " | 203 LOG(WARNING) << "UpdateLookupTable called with incorrect parameters: " |
206 << method_call->ToString(); | 204 << method_call->ToString(); |
207 return; | 205 return; |
208 } | 206 } |
209 bool visible = false; | 207 bool visible = false; |
210 if (!reader.PopBool(&visible)) { | 208 if (!reader.PopBool(&visible)) { |
211 LOG(WARNING) << "UpdateLookupTable called with incorrect parameters: " | 209 LOG(WARNING) << "UpdateLookupTable called with incorrect parameters: " |
212 << method_call->ToString(); | 210 << method_call->ToString(); |
213 return; | 211 return; |
214 } | 212 } |
(...skipping 15 matching lines...) Expand all Loading... |
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 (!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 } |
(...skipping 14 matching lines...) Expand all Loading... |
265 } | 263 } |
266 | 264 |
267 // Handles UpdatePreeditText method call from ibus-daemon. | 265 // Handles UpdatePreeditText method call from ibus-daemon. |
268 void UpdatePreeditText(dbus::MethodCall* method_call, | 266 void UpdatePreeditText(dbus::MethodCall* method_call, |
269 dbus::ExportedObject::ResponseSender response_sender) { | 267 dbus::ExportedObject::ResponseSender response_sender) { |
270 if (!candidate_window_handler_) | 268 if (!candidate_window_handler_) |
271 return; | 269 return; |
272 | 270 |
273 dbus::MessageReader reader(method_call); | 271 dbus::MessageReader reader(method_call); |
274 std::string text; | 272 std::string text; |
275 if (!ibus::PopStringFromIBusText(&reader, &text)) { | 273 if (!PopStringFromIBusText(&reader, &text)) { |
276 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " | 274 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " |
277 << method_call->ToString(); | 275 << method_call->ToString(); |
278 return; | 276 return; |
279 } | 277 } |
280 uint32 cursor_pos = 0; | 278 uint32 cursor_pos = 0; |
281 if (!reader.PopUint32(&cursor_pos)) { | 279 if (!reader.PopUint32(&cursor_pos)) { |
282 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " | 280 LOG(WARNING) << "UpdatePreeditText called with incorrect parameters: " |
283 << method_call->ToString(); | 281 << method_call->ToString(); |
284 return; | 282 return; |
285 } | 283 } |
(...skipping 20 matching lines...) Expand all Loading... |
306 } | 304 } |
307 | 305 |
308 // Handles RegisterProperties method call from ibus-daemon. | 306 // Handles RegisterProperties method call from ibus-daemon. |
309 void RegisterProperties( | 307 void RegisterProperties( |
310 dbus::MethodCall* method_call, | 308 dbus::MethodCall* method_call, |
311 dbus::ExportedObject::ResponseSender response_sender) { | 309 dbus::ExportedObject::ResponseSender response_sender) { |
312 if (!property_handler_) | 310 if (!property_handler_) |
313 return; | 311 return; |
314 | 312 |
315 dbus::MessageReader reader(method_call); | 313 dbus::MessageReader reader(method_call); |
316 ibus::IBusPropertyList properties; | 314 IBusPropertyList properties; |
317 if (!ibus::PopIBusPropertyList(&reader, &properties)) { | 315 if (!PopIBusPropertyList(&reader, &properties)) { |
318 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" | 316 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" |
319 << method_call->ToString(); | 317 << method_call->ToString(); |
320 return; | 318 return; |
321 } | 319 } |
322 property_handler_->RegisterProperties(properties); | 320 property_handler_->RegisterProperties(properties); |
323 | 321 |
324 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 322 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
325 response_sender.Run(response); | 323 response_sender.Run(response); |
326 } | 324 } |
327 | 325 |
328 // Handles UpdateProperty method call from ibus-daemon. | 326 // Handles UpdateProperty method call from ibus-daemon. |
329 void UpdateProperty(dbus::MethodCall* method_call, | 327 void UpdateProperty(dbus::MethodCall* method_call, |
330 dbus::ExportedObject::ResponseSender response_sender) { | 328 dbus::ExportedObject::ResponseSender response_sender) { |
331 if (!property_handler_) | 329 if (!property_handler_) |
332 return; | 330 return; |
333 | 331 |
334 dbus::MessageReader reader(method_call); | 332 dbus::MessageReader reader(method_call); |
335 ibus::IBusProperty property; | 333 IBusProperty property; |
336 if (!ibus::PopIBusProperty(&reader, &property)) { | 334 if (!PopIBusProperty(&reader, &property)) { |
337 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" | 335 DLOG(WARNING) << "RegisterProperties called with incorrect parameters:" |
338 << method_call->ToString(); | 336 << method_call->ToString(); |
339 return; | 337 return; |
340 } | 338 } |
341 property_handler_->UpdateProperty(property); | 339 property_handler_->UpdateProperty(property); |
342 | 340 |
343 dbus::Response* response = dbus::Response::FromMethodCall(method_call); | 341 dbus::Response* response = dbus::Response::FromMethodCall(method_call); |
344 response_sender.Run(response); | 342 response_sender.Run(response); |
345 } | 343 } |
346 | 344 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 DBusClientImplementationType type, | 451 DBusClientImplementationType type, |
454 dbus::Bus* bus, | 452 dbus::Bus* bus, |
455 IBusInputContextClient* input_context) { | 453 IBusInputContextClient* input_context) { |
456 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { | 454 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { |
457 return new IBusPanelServiceImpl(bus, input_context); | 455 return new IBusPanelServiceImpl(bus, input_context); |
458 } else { | 456 } else { |
459 return new IBusPanelServiceDaemonlessImpl(); | 457 return new IBusPanelServiceDaemonlessImpl(); |
460 } | 458 } |
461 } | 459 } |
462 | 460 |
463 } // namespace ibus | |
464 } // namespace chromeos | 461 } // namespace chromeos |
OLD | NEW |