namespace common_installer {
-PluginInfo::PluginInfo(int flag, const std::string& type,
+PluginInfo::PluginInfo(const std::string& type,
const std::string& name,
const boost::filesystem::path& path)
- : flag_(flag),
- type_(std::move(type)),
+ : type_(std::move(type)),
name_(std::move(name)),
path_(std::move(path)) {}
-int PluginInfo::flag() const { return flag_; }
-
const std::string& PluginInfo::type() const { return type_; }
const std::string& PluginInfo::name() const { return name_; }
return std::regex_search(type, re_valid);
}
-bool PluginsListParser::ValidFlag(const std::string& flag) {
- if (flag.empty()) {
- LOG(ERROR) << "Flag is empty (valid function)";
- return false;
- }
-
- std::regex re_valid(R"(0x[01248]+)");
- return std::regex_match(flag, re_valid);
-}
-
bool PluginsListParser::ValidName(const std::string& name) {
if (name.empty()) {
LOG(ERROR) << "Name is empty (valid function)";
return match[1];
}
-std::string PluginsListParser::ExtractFlag(const std::string& flag) {
- std::regex re_extract(R"(flag\s*\=\s*\"(.*)\")");
- return ExtractRaw(flag, re_extract);
-}
-
std::string PluginsListParser::ExtractName(const std::string& type) {
std::regex re_extract(R"(name\s*\=\s*\"(.*)\")");
return ExtractRaw(type, re_extract);
const std::vector<std::string>& lines) {
plugin_info_list_.clear();
- std::vector<int> flag_container;
-
for (const std::string& line : lines) {
std::vector<std::string> parts;
if (!SplitPluginLine(line, &parts)) {
return false;
}
- std::string flag = ExtractFlag(parts.at(Flag));
std::string type = ExtractType(parts.at(Type));
std::string name = ExtractName(parts.at(Name));
std::string path = ExtractPath(parts.at(Path));
-
- if (!ValidFlag(flag)) {
- LOG(ERROR) << "Invalid flag: " << flag;
+ if (!ValidName(name)) {
+ LOG(ERROR) << "Invalid name: " << name;
return false;
}
- const int kConvertStringBase = 16;
- int _flag = std::strtoul(flag.c_str(), nullptr, kConvertStringBase);
-
- // flag should be unique
- if (std::find(flag_container.begin(), flag_container.end(), _flag) !=
- flag_container.end()) {
- LOG(ERROR) << "Flag isn't unique, flag: " << _flag;
+ // name should be unique
+ if (std::find_if(plugin_info_list_.begin(), plugin_info_list_.end(),
+ [&name](std::shared_ptr<PluginInfo>& plugin) {
+ return plugin->name() == name;
+ }) != plugin_info_list_.end()) {
+ LOG(ERROR) << "Name isn't unique, name: " << name;
return false;
- } else {
- flag_container.push_back(_flag);
}
if (!ValidType(type)) {
return false;
}
- if (!ValidName(name)) {
- LOG(ERROR) << "Invalid name: " << name;
- return false;
- }
-
if (!ValidPath(path)) {
LOG(ERROR) << "Invalid path: " << path;
return false;
boost::filesystem::path _path = boost::filesystem::path(path);
plugin_info_list_.push_back(
- std::make_shared<PluginInfo>(_flag, type, name, _path));
+ std::make_shared<PluginInfo>(type, name, _path));
}
return true;
bool PluginsListParser::SplitPluginLine(const std::string& line,
std::vector<std::string>* parts) {
- static const char kPartsInLine = 4;
+ static const char kPartsInLine = 3;
std::vector<std::string> _parts;
boost::algorithm::split(_parts, line, boost::algorithm::is_any_of(";"));
/** this class include information about plugin */
class PluginInfo {
public:
- PluginInfo(int flag, const std::string& type, const std::string& name,
+ PluginInfo(const std::string& type, const std::string& name,
const boost::filesystem::path& path);
- int flag() const;
const std::string& type() const;
const std::string& name() const;
const boost::filesystem::path& path() const;
private:
- int flag_;
std::string type_;
std::string name_;
boost::filesystem::path path_;
const PluginList& PluginInfoList() const;
private:
- enum Column { Flag, Type, Name, Path };
+ enum Column { Type, Name, Path };
bool ReadLinesFromFile(std::vector<std::string>* lines);
bool ParsePluginsRawData(const std::vector<std::string>& lines);
std::vector<std::string>* parts);
std::string ExtractRaw(const std::string& data, const std::regex& re_extract);
- std::string ExtractFlag(const std::string& flag);
std::string ExtractType(const std::string& type);
std::string ExtractName(const std::string& name);
std::string ExtractPath(const std::string& path);
- bool ValidFlag(const std::string& flag);
bool ValidType(const std::string& type);
bool ValidName(const std::string& name);
bool ValidPath(const std::string& path);
-flag="0x00000001";type="tag";name="shortcut-list";path="/etc/package-manager/parserlib/libshortcut-list.so"
-flag="0x00000002";type="tag";name="account";path="/etc/package-manager/parserlib/libaccount.so"
-flag="0x00000004";type="tag";name="notifications";path="/etc/package-manager/parserlib/libnotifications.so"
-flag="0x00000008";type="tag";name="privileges";path="/etc/package-manager/parserlib/libprivileges.so"
-flag="0x00000010";type="tag";name="ime";path="/etc/package-manager/parserlib/libime.so"
-flag="0x00000020";type="category";name="http://tizen.org/category/downloadable_font";path="/etc/package-manager/parserlib/category/libdownloadable_font.so"
-flag="0x00000040";type="metadata";name="http://developer.samsung.com/tizen/metadata/sticker";path="/etc/package-manager/parserlib/metadata/libsticker.so"
-flag="0x00000080";type="metadata";name="http://developer.samsung.com/tizen/metadata/ttsengine";path="/etc/package-manager/parserlib/metadata/libttsengine.so"
-flag="0x00000100";type="metadata";name="http://developer.samsung.com/tizen/metadata/downloadable_filters";path="/etc/package-manager/parserlib/metadata/libdownloadable_filters.so"
-flag="0x00000200";type="metadata";name="http://developer.samsung.com/tizen/metadata/dictionary";path="/etc/package-manager/parserlib/metadata/libdictionary.so"
-flag="0x00000400";type="category";name="http://tizen.org/category/antivirus";path="/etc/package-manager/parserlib/category/libantivirus.so"
-flag="0x00000800";type="metadata";name="http://developer.samsung.com/tizen/metadata/profile";path="/etc/package-manager/parserlib/metadata/libtheme.so"
-flag="0x00001000";type="category";name="http://tizen.org/category/tts";path="/etc/package-manager/parserlib/category/libsamsung_tts.so"
-flag="0x00002000";type="tag";name="livebox";path="/etc/package-manager/parserlib/liblivebox.so"
-flag="0x00004000";type="tag";name="watch-application";path="/etc/package-manager/parserlib/libwatch-application.so"
-flag="0x00008000";type="tag";name="widget-application";path="/etc/package-manager/parserlib/libwidget-application.so"
-flag="0x00010000";type="metadata";name="http://tizen.org/metadata/nfc_cardemulation";path="/usr/etc/package-manager/parserlib/metadata/libcardemulation_plugin.so"
-flag="0x00020000";type="metadata";name="http://developer.samsung.com/tizen/metadata/useese";path="/usr/etc/package-manager/parserlib/metadata/libuseese_plugin.so"
-flag="0x00040000";type="tag";name="app-context";path="/etc/package-manager/parserlib/libapp-context.so"
-flag="0x00080000";type="metadata";name="http://tizen.org/metadata/stt-engine";path="/etc/package-manager/parserlib/metadata/libstt-engine-parser.so"
-flag="0x00100000";type="metadata";name="http://tizen.org/metadata/tts-engine";path="/etc/package-manager/parserlib/metadata/libtts-engine-parser.so"
-flag="0x00200000";type="metadata";name="http://tizen.org/metadata/aliasappid";path="/etc/package-manager/parserlib/metadata/libaul-parser.so"
-flag="0x00400000";type="metadata";name="http://tizen.org/metadata/allowedappid";path="/etc/package-manager/parserlib/metadata/libaul-parser.so"
-flag="0x00800000";type="category";name="http://tizen.org/category/ime";path="/etc/package-manager/parserlib/category/libimeparser.so"
-flag="0x01000000";type="metadata";name="http://tizen.org/metadata/prefer_dotnet_aot";path="/etc/package-manager/parserlib/metadata/libprefer_dotnet_aot_plugin.so"
-flag="0x02000000";type="category";name="http://tizen.org/category/tzdata";path="/etc/package-manager/parserlib/category/libtzdata-update-parser.so"
-flag="0x04000000";type="tag";name="activity";path="/etc/package-manager/parserlib/libactivity-parser.so"
-flag="0x08000000";type="tag";name="upgrade-policy";path="/etc/package-manager/parserlib/libapp-upgrade-parser.so"
+type="tag";name="shortcut-list";path="/etc/package-manager/parserlib/libshortcut-list.so"
+type="tag";name="account";path="/etc/package-manager/parserlib/libaccount.so"
+type="tag";name="notifications";path="/etc/package-manager/parserlib/libnotifications.so"
+type="tag";name="privileges";path="/etc/package-manager/parserlib/libprivileges.so"
+type="tag";name="ime";path="/etc/package-manager/parserlib/libime.so"
+type="category";name="http://tizen.org/category/downloadable_font";path="/etc/package-manager/parserlib/category/libdownloadable_font.so"
+type="metadata";name="http://developer.samsung.com/tizen/metadata/sticker";path="/etc/package-manager/parserlib/metadata/libsticker.so"
+type="metadata";name="http://developer.samsung.com/tizen/metadata/ttsengine";path="/etc/package-manager/parserlib/metadata/libttsengine.so"
+type="metadata";name="http://developer.samsung.com/tizen/metadata/downloadable_filters";path="/etc/package-manager/parserlib/metadata/libdownloadable_filters.so"
+type="metadata";name="http://developer.samsung.com/tizen/metadata/dictionary";path="/etc/package-manager/parserlib/metadata/libdictionary.so"
+type="category";name="http://tizen.org/category/antivirus";path="/etc/package-manager/parserlib/category/libantivirus.so"
+type="metadata";name="http://developer.samsung.com/tizen/metadata/profile";path="/etc/package-manager/parserlib/metadata/libtheme.so"
+type="category";name="http://tizen.org/category/tts";path="/etc/package-manager/parserlib/category/libsamsung_tts.so"
+type="tag";name="livebox";path="/etc/package-manager/parserlib/liblivebox.so"
+type="tag";name="watch-application";path="/etc/package-manager/parserlib/libwatch-application.so"
+type="tag";name="widget-application";path="/etc/package-manager/parserlib/libwidget-application.so"
+type="metadata";name="http://tizen.org/metadata/nfc_cardemulation";path="/usr/etc/package-manager/parserlib/metadata/libcardemulation_plugin.so"
+type="metadata";name="http://developer.samsung.com/tizen/metadata/useese";path="/usr/etc/package-manager/parserlib/metadata/libuseese_plugin.so"
+type="tag";name="app-context";path="/etc/package-manager/parserlib/libapp-context.so"
+type="metadata";name="http://tizen.org/metadata/stt-engine";path="/etc/package-manager/parserlib/metadata/libstt-engine-parser.so"
+type="metadata";name="http://tizen.org/metadata/tts-engine";path="/etc/package-manager/parserlib/metadata/libtts-engine-parser.so"
+type="metadata";name="http://tizen.org/metadata/aliasappid";path="/etc/package-manager/parserlib/metadata/libaul-parser.so"
+type="metadata";name="http://tizen.org/metadata/allowedappid";path="/etc/package-manager/parserlib/metadata/libaul-parser.so"
+type="category";name="http://tizen.org/category/ime";path="/etc/package-manager/parserlib/category/libimeparser.so"
+type="metadata";name="http://tizen.org/metadata/prefer_dotnet_aot";path="/etc/package-manager/parserlib/metadata/libprefer_dotnet_aot_plugin.so"
+type="category";name="http://tizen.org/category/tzdata";path="/etc/package-manager/parserlib/category/libtzdata-update-parser.so"
+type="tag";name="activity";path="/etc/package-manager/parserlib/libactivity-parser.so"
+type="tag";name="upgrade-policy";path="/etc/package-manager/parserlib/libapp-upgrade-parser.so"
ASSERT_TRUE(parser.Parse());
auto list = parser.PluginInfoList();
ASSERT_EQ(list.size(), 3);
- ASSERT_EQ(list[0]->flag(), 1);
ASSERT_EQ(list[0]->type(), "tag");
ASSERT_EQ(list[0]->name(), "test");
ASSERT_EQ(list[0]->path(), kTestTagPlugin.string());
- ASSERT_EQ(list[1]->flag(), 2);
ASSERT_EQ(list[1]->type(), "category");
ASSERT_EQ(list[1]->name(), "http://tizen.org/category/test_category");
ASSERT_EQ(list[1]->path(), kTestCategoryPlugin.string());
- ASSERT_EQ(list[2]->flag(), 4);
ASSERT_EQ(list[2]->type(), "metadata");
ASSERT_EQ(list[2]->name(),
"http://developer.samsung.com/tizen/metadata/test_metadata");
TEST_F(PluginTest, PluginFactory_CreatingPlugins) {
PluginFactory factory;
- PluginInfo tag_info(1, "tag", "test", kTestTagPlugin.string());
+ PluginInfo tag_info("tag", "test", kTestTagPlugin.string());
ASSERT_TRUE(!!factory.CreatePluginByPluginInfo(tag_info));
- PluginInfo category_info(2, "category", "category",
+ PluginInfo category_info("category", "category",
kTestCategoryPlugin.string());
ASSERT_TRUE(!!factory.CreatePluginByPluginInfo(category_info));
- PluginInfo metadata_info(3, "metadata", "metadata",
+ PluginInfo metadata_info("metadata", "metadata",
kTestMetadataPlugin.string());
ASSERT_TRUE(!!factory.CreatePluginByPluginInfo(metadata_info));
- PluginInfo missing_info(1, "tag", "test",
+ PluginInfo missing_info("tag", "test",
"/usr/lib/libmynonexistingplugin.so");
ASSERT_FALSE(!!factory.CreatePluginByPluginInfo(missing_info));
- PluginInfo new_info(1, "newtype", "test", kTestTagPlugin.string());
+ PluginInfo new_info("newtype", "test", kTestTagPlugin.string());
ASSERT_FALSE(!!factory.CreatePluginByPluginInfo(new_info));
}
-flag="0x00000001";type="tag";name="test";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-tag-plugin.so"
-flag="0x00000002";type="category";;;;;;name="http://tizen.org/category/test_category";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-category-plugin.so"
-flag="0x00000004";type="metadata";name="http://developer.samsung.com/tizen/metadata/test_metadata";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-metadata-plugin.so"
+type="tag";name="test";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-tag-plugin.so"
+type="category";;;;;;name="http://tizen.org/category/test_category";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-category-plugin.so"
+type="metadata";name="http://developer.samsung.com/tizen/metadata/test_metadata";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-metadata-plugin.so"
-flag="0x00000001";type="tag";name="test";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-tag-plugin.so"
-flag="0x00000002";type="category";name="http://tizen.org/category/test_category";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-category-plugin.so"
-flag="0x00000004";type="metadata";name="http://developer.samsung.com/tizen/metadata/test_metadata";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-metadata-plugin.so"
+type="tag";name="test";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-tag-plugin.so"
+type="category";name="http://tizen.org/category/test_category";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-category-plugin.so"
+type="metadata";name="http://developer.samsung.com/tizen/metadata/test_metadata";path="/usr/share/app-installers-ut/test_samples/plugins/libtest-metadata-plugin.so"