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_IME_IBUS_BRIDGE_H_ 6 #define CHROMEOS_IME_IBUS_BRIDGE_H_ 7 8 #include <string> 9 #include "base/basictypes.h" 10 #include "chromeos/chromeos_export.h" 11 #include "chromeos/dbus/ibus/ibus_engine_factory_service.h" 12 13 namespace chromeos { 14 class IBusInputContextHandlerInterface; 15 class IBusEngineHandlerInterface; 16 class IBusPanelCandidateWindowHandlerInterface; 17 class IBusPanelPropertyHandlerInterface; 18 19 // IBusBridge provides access of each IME related handler. This class is used 20 // for IME implementation without ibus-daemon. The legacy ibus IME communicates 21 // their engine with dbus protocol, but new implementation doesn't. Instead of 22 // dbus communcation, new implementation calls target service(e.g. PanelService 23 // or EngineService) directly by using this class. 24 class IBusBridge { 25 public: 26 virtual ~IBusBridge(); 27 28 // Allocates the global instance. Must be called before any calls to Get(). 29 static CHROMEOS_EXPORT void Initialize(); 30 31 // Releases the global instance. 32 static CHROMEOS_EXPORT void Shutdown(); 33 34 // Returns IBusBridge global instance. Initialize() must be called first. 35 static CHROMEOS_EXPORT IBusBridge* Get(); 36 37 // Returns current InputContextHandler. This function returns NULL if input 38 // context is not ready to use. 39 virtual IBusInputContextHandlerInterface* GetInputContextHandler() const = 0; 40 41 // Updates current InputContextHandler. If there is no active input context, 42 // pass NULL for |handler|. Caller must release |handler|. 43 virtual void SetInputContextHandler( 44 IBusInputContextHandlerInterface* handler) = 0; 45 46 // Returns current EngineHandler. This function returns NULL if current engine 47 // is not ready to use. 48 virtual IBusEngineHandlerInterface* GetEngineHandler() const = 0; 49 50 // Updates current EngineHandler. If there is no active engine service, pass 51 // NULL for |handler|. Caller must release |handler|. 52 virtual void SetEngineHandler(IBusEngineHandlerInterface* handler) = 0; 53 54 // Returns current CandidateWindowHandler. This function returns NULL if 55 // current candidate window is not ready to use. 56 virtual IBusPanelCandidateWindowHandlerInterface* 57 GetCandidateWindowHandler() const = 0; 58 59 // Updates current CandidatWindowHandler. If there is no active candidate 60 // window service, pass NULL for |handler|. Caller must release |handler|. 61 virtual void SetCandidateWindowHandler( 62 IBusPanelCandidateWindowHandlerInterface* handler) = 0; 63 64 // Returns current PropertyHandler. This function returns NULL if panel window 65 // is not ready to use. 66 virtual IBusPanelPropertyHandlerInterface* GetPropertyHandler() const = 0; 67 68 // Updates current PropertyHandler. If there is no active property service, 69 // pass NULL for |handler|. Caller must release |handler|. 70 virtual void SetPropertyHandler( 71 IBusPanelPropertyHandlerInterface* handler) = 0; 72 73 // Sets create engine handler for |engine_id|. |engine_id| must not be empty 74 // and |handler| must not be null. 75 virtual void SetCreateEngineHandler( 76 const std::string& engine_id, 77 const IBusEngineFactoryService::CreateEngineHandler& handler) = 0; 78 79 // Unsets create engine handler for |engine_id|. |engine_id| must not be 80 // empty. 81 virtual void UnsetCreateEngineHandler(const std::string& engine_id) = 0; 82 83 // Creates engine. Do not call this function before SetCreateEngineHandler 84 // call with |engine_id|. 85 virtual void CreateEngine(const std::string& engine_id) = 0; 86 87 protected: 88 IBusBridge(); 89 90 private: 91 DISALLOW_COPY_AND_ASSIGN(IBusBridge); 92 }; 93 94 } // namespace chromeos 95 96 #endif // CHROMEOS_IME_IBUS_BRIDGE_H_ 97