return bundle_.GetString("id");
}
+std::string ThemeInfo::GetPkgid() const {
+ return bundle_.GetString("pkgid");
+}
+
std::string ThemeInfo::GetVersion() const {
return bundle_.GetString("version");
}
explicit ThemeInfo(const tizen_base::Bundle& bundle);
std::string GetId() const;
+ std::string GetPkgid() const;
std::string GetVersion() const;
std::string GetToolVersion() const;
std::string GetTitle() const;
} // namespace
-bool InstallTheme(const std::string& id, const std::string& path) {
+bool InstallTheme(const std::string& id, const std::string& pkgid,
+ const std::string& path) {
ttm::plugin::ThemeParser parser(path);
if (!parser.Commit(ttm::plugin::ThemeParser::ThemeOperation::ADD,
- parser.Inflate(id)))
+ parser.Inflate(id, pkgid)))
return false;
return true;
}
for (__metadata_t* md : GListRange<__metadata_t*>(metadata)) {
if (!strcmp(md->key, kThemeMetadataKey)) {
- if (!InstallTheme(appid, (root_path + md->value)))
+ if (!InstallTheme(appid, pkgid, (root_path + md->value)))
return -1;
}
}
return 0;
}
-bool UpgradeTheme(const std::string& id, const std::string& path) {
+bool UpgradeTheme(const std::string& id, const std::string& pkgid,
+ const std::string& path) {
ttm::plugin::ThemeParser parser(path);
if (!parser.Commit(ttm::plugin::ThemeParser::ThemeOperation::UPDATE,
- parser.Inflate(id)))
+ parser.Inflate(id, pkgid)))
return false;
return true;
}
for (__metadata_t* md : GListRange<__metadata_t*>(metadata)) {
if (!strcmp(md->key, kThemeMetadataKey)) {
- if (!UpgradeTheme(appid, (root_path + md->value)))
+ if (!UpgradeTheme(appid, pkgid, (root_path + md->value)))
return -1;
}
}
return 0;
}
-bool UninstallTheme(const std::string& id, const std::string& path) {
+bool UninstallTheme(const std::string& id, const std::string& pkgid,
+ const std::string& path) {
ttm::plugin::ThemeParser parser(path);
if (!parser.Commit(ttm::plugin::ThemeParser::ThemeOperation::REMOVE,
- parser.Inflate(id)))
+ parser.Inflate(id, pkgid)))
return false;
return true;
}
for (__metadata_t* md : GListRange<__metadata_t*>(metadata)) {
if (!strcmp(md->key, kThemeMetadataKey)) {
- if (!UninstallTheme(appid, (root_path + md->value)))
+ if (!UninstallTheme(appid, pkgid, (root_path + md->value)))
return -1;
}
}
namespace ttm {
namespace plugin {
-loader::ThemeInfo ThemeParser::Inflate(const std::string id) {
+loader::ThemeInfo ThemeParser::Inflate(const std::string id,
+ const std::string pkgid) {
Json::CharReaderBuilder rbuilder;
rbuilder["collectComments"] = false;
// FIXME: this parser should parse more theme information.
ThemeInfoBuilder builder("testid");
- builder.PutString("version", root["version"].asString()).
+ builder.PutString("pkgid", pkgid).
+ PutString("version", root["version"].asString()).
PutString("tool_version", root["tool_version"].asString()).
PutString("title", root["header"]["title"].asString()).
PutString("description", root["header"]["description"].asString());
};
explicit ThemeParser(const std::string& path) : path_(path) {}
- loader::ThemeInfo Inflate(const std::string id);
+ loader::ThemeInfo Inflate(const std::string id, const std::string pkgid);
int Commit(ThemeOperation operation, const loader::ThemeInfo& theme);
private:
const char kCreateThemeTableQuery[] =
"CREATE TABLE IF NOT EXISTS theme (\n"
" id TEXT,\n"
+ " pkgid TEXT,\n"
" version TEXT,\n"
" tool_version TEXT,\n"
" title TEXT,\n"
" details BLOB,\n"
" PRIMARY KEY (id))";
const char kInsertQuery[] =
- "INSERT INTO theme (id, version, tool_version, title, description,"
+ "INSERT INTO theme (id, pkgid, version, tool_version, title, description,"
" preview, resolution, details) "
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
const char kUpdateQuery[] =
"UPDATE theme SET version = ?, tool_version = ?, title = ?,"
" description = ?, preview = ?, resolution = ?, details = ? "
const char kDeleteQuery[] =
"DELETE FROM theme WHERE id = ?";
const char kSelectQuery[] =
- "SELECT id, version, tool_version, title, description, preview, resolution,"
- " details FROM theme WHERE id = ?";
+ "SELECT id, pkgid, version, tool_version, title, description, preview, "
+ " resolution, details FROM theme WHERE id = ?";
const char kSelectIdsQuery[] = "SELECT id FROM theme";
const char kCreateThemeSettingTableQuery[] =
"CREATE TABLE IF NOT EXISTS theme_setting (\n"
int idx = 1;
if (!stmt->BindString(idx++, info.GetString("id")))
return false;
+ if (!stmt->BindString(idx++, info.GetString("pkgid")))
+ return false;
if (!stmt->BindString(idx++, info.GetString("version")))
return false;
if (!stmt->BindString(idx++, info.GetString("tool_version")))
int idx = 0;
tizen_base::Bundle b = tizen_base::Bundle();
b.Add("id", stmt->GetColumnString(idx++));
+ b.Add("pkgid", stmt->GetColumnString(idx++));
b.Add("version", stmt->GetColumnString(idx++));
b.Add("tool_version", stmt->GetColumnString(idx++));
b.Add("title", stmt->GetColumnString(idx++));
virtual void SetUp() {
b_.Add("id", "testid");
+ b_.Add("pkgid", "testpkgid");
b_.Add("version", "1.0");
b_.Add("tool_version", "1.1");
b_.Add("title", "Test");
EXPECT_EQ(info.GetId(), "testid");
}
+TEST_F(ThemeInfoTest, ThemeInfo_GetPkgid) {
+ ThemeInfo info(b_);
+
+ EXPECT_EQ(info.GetPkgid(), "testpkgid");
+}
+
TEST_F(ThemeInfoTest, ThemeInfo_GetVersion) {
ThemeInfo info(b_);
tizen_base::Bundle b = info.Serialize();
EXPECT_EQ(b.GetString("id"), "testid");
+ EXPECT_EQ(b.GetString("pkgid"), "testpkgid");
EXPECT_EQ(b.GetString("version"), "1.0");
EXPECT_EQ(b.GetString("tool_version"), "1.1");
EXPECT_EQ(b.GetString("title"), "Test");
TEST_F(ThemeParserTest, Inflate) {
ttm::plugin::ThemeParser parser("test_samples/test_theme.json");
- auto info = parser.Inflate("testid");
+ auto info = parser.Inflate("testid", "testpkgid");
EXPECT_EQ(info.GetId(), "testid");
+ EXPECT_EQ(info.GetPkgid(), "testpkgid");
EXPECT_EQ(info.GetVersion(), "1.0.0");
EXPECT_EQ(info.GetToolVersion(), "1.00.38.820793");
EXPECT_EQ(info.GetTitle(), "GOGO Theme");