Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: chromeos/dbus/ibus/ibus_text.cc

Issue 11363033: Extends IBusText to handle mozc's extended field. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/ibus/ibus_text.cc
diff --git a/chromeos/dbus/ibus/ibus_text.cc b/chromeos/dbus/ibus/ibus_text.cc
index 8f0044d2dbef7a6e0cd143ead86f9e4497689e7a..a80973274b604100dceb97d4a6f124809018e65a 100644
--- a/chromeos/dbus/ibus/ibus_text.cc
+++ b/chromeos/dbus/ibus/ibus_text.cc
@@ -30,6 +30,7 @@ bool PopIBusAttribute(dbus::MessageReader* reader, IBusAttribute* attribute) {
IBusObjectReader ibus_object_reader("IBusAttribute", reader);
if (!ibus_object_reader.Init())
return false;
+
if (!ibus_object_reader.PopUint32(&attribute->type) ||
!ibus_object_reader.PopUint32(&attribute->value) ||
!ibus_object_reader.PopUint32(&attribute->start_index) ||
@@ -102,9 +103,52 @@ void CHROMEOS_EXPORT AppendStringAsIBusText(const std::string& text,
bool PopIBusText(dbus::MessageReader* reader, IBusText* ibus_text) {
IBusObjectReader ibus_text_reader("IBusText", reader);
- if (!ibus_text_reader.Init())
+
+ dbus::MessageReader attachment_reader(NULL);
+ if (!ibus_text_reader.InitWithAttachmentReader(&attachment_reader))
return false;
+ while (attachment_reader.HasMoreData()) {
+ dbus::MessageReader dictionary_reader(NULL);
+ if (!attachment_reader.PopDictEntry(&dictionary_reader)) {
+ LOG(ERROR) << "Invalid attachment structure: "
+ << "The attachment field is array of dictionary entry.";
+ return false;
+ }
+
+ std::string key;
+ if (!dictionary_reader.PopString(&key)) {
+ LOG(ERROR) << "Invalid attachement structure: "
+ << "The 1st dictionary entry should be string.";
+ return false;
+ }
+
+ dbus::MessageReader variant_reader(NULL);
+ if (!dictionary_reader.PopVariant(&variant_reader)) {
+ LOG(ERROR) << "Invalid attachment structure: "
+ << "The 2nd dictionary entry shuold be variant.";
+ return false;
+ }
+
+ dbus::MessageReader sub_variant_reader(NULL);
+ if (!variant_reader.PopVariant(&sub_variant_reader)) {
+ LOG(ERROR) << "Invalid attachment structure: "
+ << "The 2nd variant entry should contain variant.";
+ return false;
+ }
+
+ std::string value;
+ if (!sub_variant_reader.PopString(&value))
+ continue; // Ignore other attachment values.
+
+ if (key == "annotation")
+ ibus_text->set_annotation(value);
+ else if (key == "description")
+ ibus_text->set_description(value);
+ else
+ continue; // Ignore other fields.
+ }
+
std::string text;
if (!ibus_text_reader.PopString(&text)) {
LOG(ERROR) << "Invalid variant structure[IBusText]: "
@@ -178,33 +222,5 @@ IBusText::IBusText()
IBusText::~IBusText() {
}
-std::string IBusText::text() const {
- return text_;
-}
-
-void IBusText::set_text(const std::string& text) {
- text_.assign(text);
-}
-
-std::vector<IBusText::UnderlineAttribute>*
- IBusText::mutable_underline_attributes() {
- return &underline_attributes_;
-}
-
-const std::vector<IBusText::UnderlineAttribute>&
- IBusText::underline_attributes() const {
- return underline_attributes_;
-}
-
-std::vector<IBusText::SelectionAttribute>*
- IBusText::mutable_selection_attributes() {
- return &selection_attributes_;
-}
-
-const std::vector<IBusText::SelectionAttribute>&
- IBusText::selection_attributes() const {
- return selection_attributes_;
-}
-
} // namespace ibus
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698