"INSERT INTO theme (id, version, tool_version, title, description,"
" preview, resolution, details) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
+const char kUpdateQuery[] =
+ "UPDATE theme SET version = ?, tool_version = ?, title = ?,"
+ " description = ?, preview = ?, resolution = ?, details = ? "
+ "WHERE id = ?";
const char kDeleteQuery[] =
"DELETE FROM theme WHERE id = ?";
const char kSelectQuery[] =
return true;
}
+bool DbManager::Update(const std::string& id, const tizen_base::Bundle& info) {
+ std::unique_ptr<SQLiteStatement> stmt = conn_.PrepareStatement(kUpdateQuery);
+ if (!stmt) {
+ LOG(ERROR) << "Failed to prepare statement";
+ return false;
+ }
+
+ int idx = 1;
+ if (!stmt->BindString(idx++, info.GetString("version")))
+ return false;
+ if (!stmt->BindString(idx++, info.GetString("tool_version")))
+ return false;
+ if (!stmt->BindString(idx++, info.GetString("title")))
+ return false;
+ if (!stmt->BindString(idx++, info.GetString("description")))
+ return false;
+ if (!stmt->BindString(idx++, info.GetString("preview")))
+ return false;
+ if (!stmt->BindString(idx++, info.GetString("resolution")))
+ return false;
+ if (!stmt->BindBlob(idx++, info.GetByte("details")))
+ return false;
+ if (!stmt->BindString(idx++, info.GetString("id")))
+ return false;
+
+ if (stmt->Step() != SQLiteStatement::StepResult::DONE) {
+ LOG(ERROR) << "Failed to update ThemeInfo into DB";
+ return false;
+ }
+
+ for (const auto& listener : listeners_)
+ listener->OnThemePackageChanged(info.GetString("id"));
+
+ return true;
+}
+
bool DbManager::Delete(const std::string& id) {
std::unique_ptr<SQLiteStatement> stmt = conn_.PrepareStatement(kDeleteQuery);
if (!stmt) {
#include "theme_provider/theme_info_proxy.h"
+#include <memory>
#include <string>
#include "theme/loader/theme_info.h"
namespace ttm {
namespace provider {
-class ThemeInfo;
-
-std::shared_ptr<ThemeInfo> LoadTheme(const std::string& id) {
- return nullptr;
+std::shared_ptr<loader::ThemeInfo> ThemeInfoProxy::LoadTheme(
+ const std::string& id) {
+ return std::make_shared<loader::ThemeInfo>(db_manager_.Select(id));
}
-bool SaveTheme(const ThemeInfo& info) {
- return true;
+bool ThemeInfoProxy::SaveTheme(const loader::ThemeInfo& info) {
+ return db_manager_.Insert(info.GetId(), info.Serialize());
}
-std::shared_ptr<ThemeInfo> GetLoadedTheme() {
+std::shared_ptr<loader::ThemeInfo> ThemeInfoProxy::GetLoadedTheme() {
return nullptr;
}
-bool SetCurrentTheme(const std::string& id) {
+bool ThemeInfoProxy::SetCurrentTheme(const std::string& id) {
return true;
}
-void OnThemePackageChanged(const std::string& id) {
+void ThemeInfoProxy::OnThemePackageChanged(const std::string& id) {
}
} // namespace provider
namespace ttm {
namespace provider {
-class ThemeInfo;
-
class ThemeInfoProxy : public IThemePackageEvent {
public:
- std::shared_ptr<ThemeInfo> LoadTheme(const std::string& id);
- bool SaveTheme(const ThemeInfo& info);
- std::shared_ptr<ThemeInfo> GetLoadedTheme();
+ std::shared_ptr<loader::ThemeInfo> LoadTheme(const std::string& id);
+ bool SaveTheme(const loader::ThemeInfo& info);
+ std::shared_ptr<loader::ThemeInfo> GetLoadedTheme();
bool SetCurrentTheme(const std::string& id);
void OnThemePackageChanged(const std::string& id) override;
+
+ private:
+ DbManager db_manager_;
};
} // namespace provider