diff options
author | komatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-13 13:26:59 +0000 |
---|---|---|
committer | komatsu@chromium.org <komatsu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-13 13:26:59 +0000 |
commit | 0363ddc9035c050c5d7b7bf6329b786d6a073b51 (patch) | |
tree | ab0a751d8580e1ee4038d4f4dacf9715d48542ac /chromeos/dbus | |
parent | fd2b4b55054b720ddb1c5f1be63efc13f1e7620c (diff) | |
download | chromium_src-0363ddc9035c050c5d7b7bf6329b786d6a073b51.zip chromium_src-0363ddc9035c050c5d7b7bf6329b786d6a073b51.tar.gz chromium_src-0363ddc9035c050c5d7b7bf6329b786d6a073b51.tar.bz2 |
Delete IBusComponent.
IBusComponent is no longer necessary.
BUG=317506
Review URL: https://codereview.chromium.org/68503002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234812 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus')
-rw-r--r-- | chromeos/dbus/ibus/ibus_component.cc | 247 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_component.h | 146 | ||||
-rw-r--r-- | chromeos/dbus/ibus/ibus_component_unittest.cc | 79 |
3 files changed, 0 insertions, 472 deletions
diff --git a/chromeos/dbus/ibus/ibus_component.cc b/chromeos/dbus/ibus/ibus_component.cc deleted file mode 100644 index ea8854c..0000000 --- a/chromeos/dbus/ibus/ibus_component.cc +++ /dev/null @@ -1,247 +0,0 @@ -// 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. - -#include "chromeos/dbus/ibus/ibus_component.h" - -#include "base/logging.h" -#include "chromeos/dbus/ibus/ibus_object.h" -#include "dbus/message.h" - -namespace chromeos { - -namespace { - -bool PopIBusEngineDesc(dbus::MessageReader* reader, - IBusComponent::EngineDescription* engine_desc) { - IBusObjectReader ibus_object_reader("IBusEngineDesc", reader); - if (!ibus_object_reader.Init()) - return false; - if (!ibus_object_reader.PopString(&engine_desc->engine_id)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 1st argument should be string."; - return false; - } - if (!ibus_object_reader.PopString(&engine_desc->display_name)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 2nd argument should be string."; - return false; - } - if (!ibus_object_reader.PopString(&engine_desc->description)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 3rd argument should be string."; - return false; - } - if (!ibus_object_reader.PopString(&engine_desc->language_code)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 4th argument should be string."; - return false; - } - std::string unused_string_field; - if (!ibus_object_reader.PopString(&unused_string_field)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 5th argument should be string."; - return false; - } - if (!ibus_object_reader.PopString(&engine_desc->author)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 6th argument should be string."; - return false; - } - if (!ibus_object_reader.PopString(&unused_string_field)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 7th argument should be string."; - return false; - } - if (!ibus_object_reader.PopString(&unused_string_field)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 8th argument should be string."; - return false; - } - uint32 unused_uint_field = 0; - if (!ibus_object_reader.PopUint32(&unused_uint_field)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 9th argument should be unsigned integer."; - return false; - } - if (!ibus_object_reader.PopString(&unused_string_field)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 10th argument should be string."; - return false; - } - if (!ibus_object_reader.PopString(&unused_string_field)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 11th argument should be string."; - return false; - } - if (!ibus_object_reader.PopString(&unused_string_field)) { - LOG(ERROR) << "Invalid variant structure[IBusEngineDesc]: " - << "The 12th argument should be string."; - return false; - } - return true; -} - -void AppendIBusEngineDesc(const IBusComponent::EngineDescription& engine_desc, - dbus::MessageWriter* writer) { - IBusObjectWriter ibus_object_writer("IBusEngineDesc", - "ssssssssusss", - writer); - ibus_object_writer.CloseHeader(); - ibus_object_writer.AppendString(engine_desc.engine_id); - ibus_object_writer.AppendString(engine_desc.display_name); - ibus_object_writer.AppendString(engine_desc.description); - ibus_object_writer.AppendString(engine_desc.language_code); - ibus_object_writer.AppendString(""); // The license field is not used. - ibus_object_writer.AppendString(engine_desc.author); - ibus_object_writer.AppendString(""); // The icon path field is not used. - ibus_object_writer.AppendString(""); // The layout field is not used. - ibus_object_writer.AppendUint32(0); // The engine rank is not used. - ibus_object_writer.AppendString(""); // The hotkey field is not used. - ibus_object_writer.AppendString(""); // The symbol field is not used. - ibus_object_writer.AppendString(""); // The command line field is not used. - ibus_object_writer.CloseAll(); -} - -} // namespace - -bool CHROMEOS_EXPORT PopIBusComponent(dbus::MessageReader* reader, - IBusComponent* ibus_component) { - IBusObjectReader ibus_object_reader("IBusComponent", reader); - if (!ibus_object_reader.Init()) - return false; - std::string name; - if (!ibus_object_reader.PopString(&name)) { - LOG(ERROR) << "Invalid variant structure[IBusComponent]: " - << "The 1st argument should be string."; - return false; - } - ibus_component->set_name(name); - - std::string description; - if (!ibus_object_reader.PopString(&description)) { - LOG(ERROR) << "Invalid variant structure[IBusComponent]: " - << "The 2nd argument should be string."; - return false; - } - ibus_component->set_description(description); - - std::string unused_string_field; - if (!ibus_object_reader.PopString(&unused_string_field)) { - LOG(ERROR) << "Invalid variant structure[IBusComponent]: " - << "The 3rd argument should be string."; - return false; - } - if (!ibus_object_reader.PopString(&unused_string_field)) { - LOG(ERROR) << "Invalid variant structure[IBusComponent]: " - << "The 4th argument should be string."; - return false; - } - - std::string author; - if (!ibus_object_reader.PopString(&author)) { - LOG(ERROR) << "Invalid variant structure[IBusComponent]: " - << "The 5th argument should be string."; - return false; - } - ibus_component->set_author(author); - - if (!ibus_object_reader.PopString(&unused_string_field)) { - LOG(ERROR) << "Invalid variant structure[IBusComponent]: " - << "The 6th argument should be string."; - return false; - } - if (!ibus_object_reader.PopString(&unused_string_field)) { - LOG(ERROR) << "Invalid variant structure[IBusComponent]: " - << "The 7th argument should be string."; - return false; - } - if (!ibus_object_reader.PopString(&unused_string_field)) { - LOG(ERROR) << "Invalid variant structure[IBusComponent]: " - << "The 8th argument should be string."; - return false; - } - dbus::MessageReader observer_reader(NULL); - if (!ibus_object_reader.PopArray(&observer_reader)) { - LOG(ERROR) << "Invalid variant structure[IBusComponent]: " - << "The 9th argument should be array of variant."; - return false; - } - - dbus::MessageReader engine_array_reader(NULL); - if (!ibus_object_reader.PopArray(&engine_array_reader)) { - LOG(ERROR) << "Invalid variant structure[IBusComponent]: " - << "The 10th argument should be array of IBusEngineDesc"; - return false; - } - std::vector<IBusComponent::EngineDescription>* engine_description = - ibus_component->mutable_engine_description(); - engine_description->clear(); - while (engine_array_reader.HasMoreData()) { - IBusComponent::EngineDescription engine_description_entry; - if (!PopIBusEngineDesc(&engine_array_reader, &engine_description_entry)) { - LOG(ERROR) << "Invalid variant structure[IBusComponent]: " - << "The 11th argument should be array of IBusEngineDesc"; - return false; - } - engine_description->push_back(engine_description_entry); - } - return true; -} - -void CHROMEOS_EXPORT AppendIBusComponent(const IBusComponent& ibus_component, - dbus::MessageWriter* writer) { - IBusObjectWriter ibus_object_writer("IBusComponent", "ssssssssavav", writer); - ibus_object_writer.CloseHeader(); - ibus_object_writer.AppendString(ibus_component.name()); - ibus_object_writer.AppendString(ibus_component.description()); - ibus_object_writer.AppendString(""); // The version string is not used. - ibus_object_writer.AppendString(""); // The license field is not used. - ibus_object_writer.AppendString(ibus_component.author()); - ibus_object_writer.AppendString(""); // The URL field is not used. - ibus_object_writer.AppendString(""); // The exec path field is not used. - ibus_object_writer.AppendString(""); // The text domain field is not used. - // The observed object field is not used. - dbus::MessageWriter empty_array_writer(NULL); - ibus_object_writer.OpenArray("v", &empty_array_writer); - ibus_object_writer.CloseContainer(&empty_array_writer); - - dbus::MessageWriter engine_descs_writer(NULL); - const std::vector<IBusComponent::EngineDescription> engine_description = - ibus_component.engine_description(); - ibus_object_writer.OpenArray("v", &engine_descs_writer); - for (size_t i = 0; i < engine_description.size(); ++i) { - AppendIBusEngineDesc(engine_description[i], &engine_descs_writer); - } - ibus_object_writer.CloseContainer(&engine_descs_writer); - ibus_object_writer.CloseAll(); -} - -/////////////////////////////////////////////////////////////////////////////// -// IBusComponent -IBusComponent::IBusComponent() { -} - -IBusComponent::~IBusComponent() { -} - -IBusComponent::EngineDescription::EngineDescription() { -} - -IBusComponent::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) - : engine_id(engine_id), - display_name(display_name), - description(description), - language_code(language_code), - author(author) { -} - -IBusComponent::EngineDescription::~EngineDescription() { -} - -} // namespace chromeos diff --git a/chromeos/dbus/ibus/ibus_component.h b/chromeos/dbus/ibus/ibus_component.h deleted file mode 100644 index 776929b..0000000 --- a/chromeos/dbus/ibus/ibus_component.h +++ /dev/null @@ -1,146 +0,0 @@ -// 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); - ~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. - }; - - 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_ diff --git a/chromeos/dbus/ibus/ibus_component_unittest.cc b/chromeos/dbus/ibus/ibus_component_unittest.cc deleted file mode 100644 index 4b6f2fa..0000000 --- a/chromeos/dbus/ibus/ibus_component_unittest.cc +++ /dev/null @@ -1,79 +0,0 @@ -// 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. -#include "chromeos/dbus/ibus/ibus_component.h" - -#include <string> - -#include "base/memory/scoped_ptr.h" -#include "dbus/message.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace chromeos { - -TEST(IBusComponentTest, WriteReadIBusComponentTest) { - const std::string kName = "Component Name"; - const std::string kDescription = "Component Description"; - const std::string kAuthor = "Component Author"; - - const std::string kEngineId1 = "Engine Id 1"; - const std::string kEngineDisplayName1 = "Engine Display Name 1"; - const std::string kEngineDescription1 = "Engine Description 1"; - const std::string kEngineLanguageCode1 = "en"; - const std::string kEngineAuthor1 = "Engine Author 1"; - const IBusComponent::EngineDescription engine_desc1(kEngineId1, - kEngineDisplayName1, - kEngineDescription1, - kEngineLanguageCode1, - kEngineAuthor1); - - const std::string kEngineId2 = "Engine Id 2"; - const std::string kEngineDisplayName2 = "Engine Display Name 2"; - const std::string kEngineDescription2 = "Engine Description 2"; - const std::string kEngineLanguageCode2 = "ja"; - const std::string kEngineAuthor2 = "Engine Author 2"; - const IBusComponent::EngineDescription engine_desc2(kEngineId2, - kEngineDisplayName2, - kEngineDescription2, - kEngineLanguageCode2, - kEngineAuthor2); - - // Create a IBusComponent. - IBusComponent ibus_component; - ibus_component.set_name(kName); - ibus_component.set_description(kDescription); - ibus_component.set_author(kAuthor); - ibus_component.mutable_engine_description()->push_back(engine_desc1); - ibus_component.mutable_engine_description()->push_back(engine_desc2); - - // Write a IBusComponent. - scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); - dbus::MessageWriter writer(response.get()); - AppendIBusComponent(ibus_component, &writer); - - // Read a IBusComponent. - IBusComponent target_component; - dbus::MessageReader reader(response.get()); - PopIBusComponent(&reader, &target_component); - - // Check a result. - EXPECT_EQ(kName, target_component.name()); - EXPECT_EQ(kDescription, target_component.description()); - EXPECT_EQ(kAuthor, target_component.author()); - - const std::vector<IBusComponent::EngineDescription>& engine_descriptions = - ibus_component.engine_description(); - EXPECT_EQ(kEngineId1, engine_descriptions[0].engine_id); - EXPECT_EQ(kEngineDisplayName1, engine_descriptions[0].display_name); - EXPECT_EQ(kEngineDescription1, engine_descriptions[0].description); - EXPECT_EQ(kEngineLanguageCode1, engine_descriptions[0].language_code); - EXPECT_EQ(kEngineAuthor1, engine_descriptions[0].author); - - EXPECT_EQ(kEngineId2, engine_descriptions[1].engine_id); - EXPECT_EQ(kEngineDisplayName2, engine_descriptions[1].display_name); - EXPECT_EQ(kEngineDescription2, engine_descriptions[1].description); - EXPECT_EQ(kEngineLanguageCode2, engine_descriptions[1].language_code); - EXPECT_EQ(kEngineAuthor2, engine_descriptions[1].author); -} - -} // namespace chromeos |