Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / chromeos / dbus / ibus / ibus_component.h
blob065e94eaab9a5b62611dcb0a02af7d7ce5d409d2
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.
5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_COMPONENT_H_
6 #define CHROMEOS_DBUS_IBUS_IBUS_COMPONENT_H_
8 #include <string>
9 #include <vector>
10 #include "base/basictypes.h"
11 #include "chromeos/chromeos_export.h"
13 namespace dbus {
14 class MessageWriter;
15 class MessageReader;
16 } // namespace dbus
18 namespace chromeos {
20 // The IBusComponents is one of IBusObjects and it contains one or more
21 // IBusEngineDesc object which describes details of engine information. This
22 // object is in used an engine's initialization.
24 // DATA STRUCTURE OVERVIEW:
26 // IBusEngineDesc: (signature is "ssssssssusss")
27 // variant struct {
28 // string "IBusEngineDesc"
29 // array []
30 // string "_ext_ime" // The engine name.
31 // string "Mock IME" // The long engine name.
32 // string "Mock IME" // The engine description.
33 // string "en" // The language identifier.
34 // string "" // The license name field.(not in use).
35 // string "MockExtensionIME" // The author name.
36 // string "" // The icon path (not in use).
37 // string "us" // The keyboard layout.
38 // uint32 0 // The engine rank. (not in use).
39 // string "" // The hotkey to switch IME.(not in use)
40 // string "" // The symbol character of this engine (not in use).
41 // string "" // The command line to execute this engine (not in use).
42 // }
44 // IBusComponent: (signature is "ssssssssavav")
45 // variant struct {
46 // string "IBusComponent"
47 // array []
48 // string "org.freedesktop.IBus._extension_ime" // The component name.
49 // string "Mock IME with Extension API" // The component description.
50 // string "" // The version of component.(not in use)
51 // string "" // The license name field. (not in use).
52 // string "MockExtensionIME" // The author name.
53 // string "" // The URL to home page(not in use).
54 // string "" // The executable path to component (not in use).
55 // string "" // The text domain field(not in use).
56 // array [] // The observed path object array(not in use).
57 // array [
58 // variant struct {
59 // string "IBusEngineDesc"
60 // array []
61 // string "_ext_ime"
62 // string "Mock IME with Extension API"
63 // string "Mock IME with Extension API"
64 // string "en"
65 // string ""
66 // string "MockExtensionIME"
67 // string ""
68 // string "us"
69 // uint32 0
70 // string ""
71 // string ""
72 // string ""
73 // }
74 // ]
75 // }
76 class IBusComponent;
78 // Pops a IBusComponent from |reader|.
79 // Returns false if an error occurs.
80 bool CHROMEOS_EXPORT PopIBusComponent(dbus::MessageReader* reader,
81 IBusComponent* ibus_component);
83 // Appends a IBusComponent to |writer|.
84 void CHROMEOS_EXPORT AppendIBusComponent(const IBusComponent& ibus_component,
85 dbus::MessageWriter* writer);
87 // Handles IBusComponent object which is used in dbus communication with
88 // ibus-daemon. The IBusComponent is one of IBusObjects and it contains array of
89 // IBusEngineDesc. The IBusEngineDesc is another IBusObject, but it is
90 // represented as member structure of IBusComponent because it is only used in
91 // IBusComponent.
92 class CHROMEOS_EXPORT IBusComponent {
93 public:
94 struct EngineDescription {
95 EngineDescription();
96 EngineDescription(const std::string& engine_id,
97 const std::string& display_name,
98 const std::string& description,
99 const std::string& language_code,
100 const std::string& author,
101 const std::string& layout);
102 ~EngineDescription();
103 std::string engine_id; // The engine id.
104 std::string display_name; // The display name.
105 std::string description; // The engine description.
106 std::string language_code; // The engine's language(ex. "en").
107 std::string author; // The author of engine.
108 std::string layout; // The keyboard layout of engine.
111 IBusComponent();
112 virtual ~IBusComponent();
114 // The component name (ex. "org.freedesktop.IBus.Mozc").
115 const std::string& name() const { return name_; }
116 void set_name(const std::string& name) { name_ = name;}
118 // The component description.
119 const std::string& description() const { return description_; }
120 void set_description(const std::string& description) {
121 description_ = description;
124 // The component author (ex. "Google Inc.").
125 const std::string& author() const { return author_; }
126 void set_author(const std::string& author) { author_ = author; }
128 // The array of engine description data.
129 const std::vector<EngineDescription>& engine_description() const {
130 return engine_description_;
132 std::vector<EngineDescription>* mutable_engine_description() {
133 return &engine_description_;
136 private:
137 std::string name_;
138 std::string description_;
139 std::string author_;
141 std::vector<EngineDescription> engine_description_;
143 DISALLOW_COPY_AND_ASSIGN(IBusComponent);
146 } // namespace chromeos
148 #endif // CHROMEOS_DBUS_IBUS_IBUS_COMPONENT_H_