| 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_CLIENT_H_ | |
| 6 #define CHROMEOS_DBUS_IBUS_IBUS_CLIENT_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback.h" | |
| 12 #include "chromeos/chromeos_export.h" | |
| 13 #include "dbus/object_path.h" | |
| 14 | |
| 15 namespace dbus { | |
| 16 class Bus; | |
| 17 } // namespace dbus | |
| 18 | |
| 19 namespace chromeos { | |
| 20 | |
| 21 class IBusComponent; | |
| 22 | |
| 23 // A class to make the actual DBus calls for IBusBus service. | |
| 24 // This class only makes calls, result/error handling should be done by | |
| 25 // callbacks. | |
| 26 class CHROMEOS_EXPORT IBusClient { | |
| 27 public: | |
| 28 enum ExitOption { | |
| 29 RESTART_IBUS_DAEMON, | |
| 30 SHUT_DOWN_IBUS_DAEMON | |
| 31 }; | |
| 32 typedef base::Callback<void(const dbus::ObjectPath&)> | |
| 33 CreateInputContextCallback; | |
| 34 typedef base::Callback<void()> RegisterComponentCallback; | |
| 35 typedef base::Callback<void()> ErrorCallback; | |
| 36 | |
| 37 virtual ~IBusClient(); | |
| 38 | |
| 39 // Requests the ibus-daemon to create new input context. If succeeded, | |
| 40 // |callback| will be called with an ObjectPath which is used in input context | |
| 41 // handling. If failed, |error_callback| is called instead. | |
| 42 virtual void CreateInputContext( | |
| 43 const std::string& client_name, | |
| 44 const CreateInputContextCallback& callback, | |
| 45 const ErrorCallback& error_callback) = 0; | |
| 46 | |
| 47 // Requests the ibus-daemon to register new engine object. If succeeded, | |
| 48 // |callback| will be called. If failed, |error_callback| is called instead. | |
| 49 virtual void RegisterComponent( | |
| 50 const IBusComponent& ibus_component, | |
| 51 const RegisterComponentCallback& callback, | |
| 52 const ErrorCallback& error_callback) = 0; | |
| 53 | |
| 54 // Requests the ibus-daemon to set global engine. If failed, |error_callback| | |
| 55 // is called. | |
| 56 virtual void SetGlobalEngine(const std::string& engine_name, | |
| 57 const ErrorCallback& error_callback) = 0; | |
| 58 | |
| 59 // Requests the ibus-daemon to exit daemon process. If |option| is | |
| 60 // RESTART_IBUS_DAEMON, ibus-daemon will be relaunched. If |option| is | |
| 61 // SHUT_DOWN_IBUS_DAEMON, ibus-daemon will not be relaunched. The | |
| 62 // |error_callback| is called if an error occurs. | |
| 63 virtual void Exit(ExitOption option, const ErrorCallback& error_callback) = 0; | |
| 64 | |
| 65 // Factory function, creates a new instance and returns ownership. | |
| 66 // For normal usage, access the singleton via DBusThreadManager::Get(). | |
| 67 static CHROMEOS_EXPORT IBusClient* Create(); | |
| 68 | |
| 69 protected: | |
| 70 // Create() should be used instead. | |
| 71 IBusClient(); | |
| 72 | |
| 73 private: | |
| 74 DISALLOW_COPY_AND_ASSIGN(IBusClient); | |
| 75 }; | |
| 76 | |
| 77 } // namespace chromeos | |
| 78 | |
| 79 #endif // CHROMEOS_DBUS_IBUS_IBUS_CLIENT_H_ | |
| OLD | NEW |