OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_INPUT_CONTEXT_CLIENT_H_ | |
6 #define CHROMEOS_DBUS_IBUS_IBUS_INPUT_CONTEXT_CLIENT_H_ | |
7 #pragma once | |
8 | |
9 #include "base/bind.h" | |
10 #include "base/callback.h" | |
11 #include "chromeos/chromeos_export.h" | |
12 #include "chromeos/dbus/dbus_client_implementation_type.h" | |
13 #include "dbus/object_path.h" | |
14 | |
15 namespace dbus { | |
16 class Bus; | |
17 } // namespace dbus | |
18 | |
19 namespace chromeos { | |
20 | |
21 // TODO(nona): Remove ibus namespace after complete libibus removal. | |
22 namespace ibus { | |
23 class IBusText; | |
24 } // namespace | |
25 | |
26 // A class to make the actual DBus calls for IBusInputContext service. | |
27 // The ibus-daemon creates object paths on demand, so the target object path is | |
28 // not determined before calling CreateInputContext. It is good to initialize | |
29 // this class at the callback from CreateInputContext in IBusClient. This class | |
30 // is managed by DBusThreadManager as singleton instance, so we can handle only | |
31 // one input context but it is enough for ChromeOS. | |
32 class CHROMEOS_EXPORT IBusInputContextClient { | |
33 public: | |
34 typedef base::Callback<void(const ibus::IBusText& text)> CommitTextHandler; | |
35 typedef base::Callback<void(uint32 keyval, uint32 keycode, uint32 state)> | |
36 ForwardKeyEventHandler; | |
37 typedef base::Callback<void(const ibus::IBusText& text, | |
38 uint32 cursor_pos, | |
39 bool visible)> | |
40 UpdatePreeditTextHandler; | |
41 typedef base::Callback<void()> ShowPreeditTextHandler; | |
42 typedef base::Callback<void()> HidePreeditTextHandler; | |
43 typedef base::Callback<void(bool is_keyevent_used)> ProcessKeyEventCallback; | |
44 | |
45 virtual ~IBusInputContextClient(); | |
46 | |
47 // Creates object proxy and connects signals. | |
48 virtual void Initialize(dbus::Bus* bus, | |
49 const dbus::ObjectPath& object_path) = 0; | |
50 | |
51 // Resets object proxy. If you want to use InputContext again, should call | |
52 // Initialize function again. | |
53 virtual void ResetObjectProxy() = 0; | |
54 | |
55 // Returns true if connected to target input context path, otherwise return | |
56 // false. | |
57 virtual bool IsConnected() const = 0; | |
58 | |
59 // Signal handler accessors. Setting function can be called multiple times. If | |
60 // you call setting function multiple times, previous callback will be | |
61 // overwritten. | |
62 // Sets CommitText signal handler. | |
63 virtual void SetCommitTextHandler( | |
64 const CommitTextHandler& commit_text_handler) = 0; | |
65 // Sets ForwardKeyEvent signal handler. | |
66 virtual void SetForwardKeyEventHandler( | |
67 const ForwardKeyEventHandler& forward_key_event_handler) = 0; | |
68 // Sets UpdatePreeditText signal handler. | |
69 virtual void SetUpdatePreeditTextHandler( | |
70 const UpdatePreeditTextHandler& update_preedit_text_handler) = 0; | |
71 // Sets ShowPreeditText signal handler. | |
72 virtual void SetShowPreeditTextHandler( | |
73 const ShowPreeditTextHandler& show_preedit_text_handler) = 0; | |
74 // Sets HidePreeditText signal handler. | |
75 virtual void SetHidePreeditTextHandler( | |
76 const HidePreeditTextHandler& hide_preedit_text_handler) = 0; | |
77 // Unsets CommitText signal handler. | |
78 virtual void UnsetCommitTextHandler() = 0; | |
79 // Unsets FowardKeyEvent signal handler. | |
80 virtual void UnsetForwardKeyEventHandler() = 0; | |
81 // Unsets UpdatePreeditText signal handler. | |
82 virtual void UnsetUpdatePreeditTextHandler() = 0; | |
83 // Unsets ShowPreeditText signal handler. | |
84 virtual void UnsetShowPreeditTextHandler() = 0; | |
85 // Unsets HidePreeditText signal handler. | |
86 virtual void UnsetHidePreeditTextHandler() = 0; | |
87 | |
88 // Invokes SetCapabilities method call. | |
89 virtual void SetCapabilities(uint32 capability) = 0; | |
90 // Invokes FocusIn method call. | |
91 virtual void FocusIn() = 0; | |
92 // Invokes FocusOut method call. | |
93 virtual void FocusOut() = 0; | |
94 // Invokes Reset method call. | |
95 virtual void Reset() = 0; | |
96 // Invokes SetCursorLocation method call. | |
97 virtual void SetCursorLocation(int32 x, int32 y, int32 w, int32 h) = 0; | |
satorux1
2012/05/22 21:41:00
width, height
Seigo Nonaka
2012/05/22 22:10:00
Done.
| |
98 // Invokes ProcessKeyEvent method call. |callback| shold not be null-callback. | |
99 virtual void ProcessKeyEvent(uint32 keyval, | |
100 uint32 keycode, | |
101 uint32 state, | |
102 const ProcessKeyEventCallback& callback) = 0; | |
103 | |
104 // Factory function, creates a new instance and returns ownership. | |
105 // For normal usage, access the singleton via DBusThreadManager::Get(). | |
106 static CHROMEOS_EXPORT IBusInputContextClient* Create( | |
107 DBusClientImplementationType type); | |
108 | |
109 protected: | |
110 // Create() should be used instead. | |
111 IBusInputContextClient(); | |
112 | |
113 private: | |
114 DISALLOW_COPY_AND_ASSIGN(IBusInputContextClient); | |
115 }; | |
116 | |
117 } // namespace chromeos | |
118 | |
119 #endif // CHROMEOS_DBUS_IBUS_IBUS_INPUT_CONTEXT_CLIENT_H_ | |
OLD | NEW |