summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/ibus/ibus_component.h
blob: 065e94eaab9a5b62611dcb0a02af7d7ce5d409d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_DBUS_IBUS_IBUS_COMPONENT_H_
#define CHROMEOS_DBUS_IBUS_IBUS_COMPONENT_H_

#include <string>
#include <vector>
#include "base/basictypes.h"
#include "chromeos/chromeos_export.h"

namespace dbus {
class MessageWriter;
class MessageReader;
}  // namespace dbus

namespace chromeos {

// The IBusComponents is one of IBusObjects and it contains one or more
// IBusEngineDesc object which describes details of engine information. This
// object is in used an engine's initialization.
//
// DATA STRUCTURE OVERVIEW:
//
// IBusEngineDesc: (signature is "ssssssssusss")
// variant  struct {
//     string "IBusEngineDesc"
//     array []
//     string "_ext_ime"  // The engine name.
//     string "Mock IME"  // The long engine name.
//     string "Mock IME"  // The engine description.
//     string "en"  // The language identifier.
//     string ""  // The license name field.(not in use).
//     string "MockExtensionIME"  // The author name.
//     string ""  // The icon path (not in use).
//     string "us"  // The keyboard layout.
//     uint32 0  // The engine rank. (not in use).
//     string ""  // The hotkey to switch IME.(not in use)
//     string ""  // The symbol character of this engine (not in use).
//     string ""  // The command line to execute this engine (not in use).
// }
//
// IBusComponent: (signature is "ssssssssavav")
// variant       struct {
//     string "IBusComponent"
//     array []
//     string "org.freedesktop.IBus._extension_ime"  // The component name.
//     string "Mock IME with Extension API" // The component description.
//     string ""  // The version of component.(not in use)
//     string ""  // The license name field. (not in use).
//     string "MockExtensionIME" // The author name.
//     string ""  // The URL to home page(not in use).
//     string ""  // The executable path to component (not in use).
//     string ""  // The text domain field(not in use).
//     array []  // The observed path object array(not in use).
//     array [
//         variant  struct {
//             string "IBusEngineDesc"
//             array []
//             string "_ext_ime"
//             string "Mock IME with Extension API"
//             string "Mock IME with Extension API"
//             string "en"
//             string ""
//             string "MockExtensionIME"
//             string ""
//             string "us"
//             uint32 0
//             string ""
//             string ""
//             string ""
//         }
//     ]
// }
class IBusComponent;

// Pops a IBusComponent from |reader|.
// Returns false if an error occurs.
bool CHROMEOS_EXPORT PopIBusComponent(dbus::MessageReader* reader,
                                      IBusComponent* ibus_component);

// Appends a IBusComponent to |writer|.
void CHROMEOS_EXPORT AppendIBusComponent(const IBusComponent& ibus_component,
                                         dbus::MessageWriter* writer);

// Handles IBusComponent object which is used in dbus communication with
// ibus-daemon. The IBusComponent is one of IBusObjects and it contains array of
// IBusEngineDesc. The IBusEngineDesc is another IBusObject, but it is
// represented as member structure of IBusComponent because it is only used in
// IBusComponent.
class CHROMEOS_EXPORT IBusComponent {
 public:
  struct EngineDescription {
    EngineDescription();
    EngineDescription(const std::string& engine_id,
                      const std::string& display_name,
                      const std::string& description,
                      const std::string& language_code,
                      const std::string& author,
                      const std::string& layout);
    ~EngineDescription();
    std::string engine_id;  // The engine id.
    std::string display_name;  // The display name.
    std::string description;  // The engine description.
    std::string language_code;  // The engine's language(ex. "en").
    std::string author;  // The author of engine.
    std::string layout;  // The keyboard layout of engine.
  };

  IBusComponent();
  virtual ~IBusComponent();

  // The component name (ex. "org.freedesktop.IBus.Mozc").
  const std::string& name() const { return name_; }
  void set_name(const std::string& name) { name_ = name;}

  // The component description.
  const std::string& description() const { return description_; }
  void set_description(const std::string& description) {
    description_ = description;
  }

  // The component author (ex. "Google Inc.").
  const std::string& author() const { return author_; }
  void set_author(const std::string& author) { author_ = author; }

  // The array of engine description data.
  const std::vector<EngineDescription>& engine_description() const {
    return engine_description_;
  }
  std::vector<EngineDescription>* mutable_engine_description() {
    return &engine_description_;
  }

 private:
  std::string name_;
  std::string description_;
  std::string author_;

  std::vector<EngineDescription> engine_description_;

  DISALLOW_COPY_AND_ASSIGN(IBusComponent);
};

}  // namespace chromeos

#endif  // CHROMEOS_DBUS_IBUS_IBUS_COMPONENT_H_