Refactor tizen-theme-manager 78/285078/3
authorjh9216.park <jh9216.park@samsung.com>
Tue, 6 Dec 2022 02:38:33 +0000 (21:38 -0500)
committerjh9216.park <jh9216.park@samsung.com>
Tue, 6 Dec 2022 06:32:34 +0000 (01:32 -0500)
- Use tizen-database package
- Requires: https://review.tizen.org/gerrit/#/c/platform/core/base/bundle/+/285096/

Change-Id: I22ee1624d9b1791085472ca68147cd6712b9f716
Signed-off-by: jh9216.park <jh9216.park@samsung.com>
CMakeLists.txt
packaging/tizen-theme-manager.spec
src/theme_provider/CMakeLists.txt
src/theme_provider/db_manager.cc
src/theme_provider/db_manager.h
src/theme_provider/sqlite_connection.cc [deleted file]
src/theme_provider/sqlite_connection.h [deleted file]
src/theme_provider/sqlite_statement.cc [deleted file]
src/theme_provider/sqlite_statement.h [deleted file]

index 71921a6f7776047d9e5c4138d7808194e81dbd00..00a4b3085775da28c3a75c78c18fd5fb955dd7f7 100644 (file)
@@ -8,7 +8,7 @@ SET(LIBDIR ${LIB_INSTALL_DIR})
 SET(INCLUDEDIR "\${prefix}/include")
 
 ## Compiler flags
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Werror -ffunction-sections -fdata-sections -fmerge-all-constants -fPIE -fPIC")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Werror -ffunction-sections -fdata-sections -fmerge-all-constants -fPIE -fPIC")
 
 ## Linker flags
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed,--gc-sections -pie")
@@ -41,6 +41,7 @@ PKG_CHECK_MODULES(PKGMGR_INFO_DEPS REQUIRED pkgmgr-info)
 PKG_CHECK_MODULES(PKGMGR_INSTALLER_DEPS REQUIRED pkgmgr-installer)
 PKG_CHECK_MODULES(SQLITE_DEPS REQUIRED sqlite3)
 PKG_CHECK_MODULES(GOBJECT_DEPS REQUIRED gobject-2.0)
+PKG_CHECK_MODULES(DATABASE_DEPS REQUIRED tizen-database)
 
 FIND_PACKAGE(Boost REQUIRED COMPONENTS filesystem)
 
index 93a23e0339427c22b30dd62c50425eac5e036f7d..aa74c746ec57aae13859636818015d561d18981d 100644 (file)
@@ -22,6 +22,7 @@ BuildRequires:  pkgconfig(pkgmgr-parser)
 BuildRequires:  pkgconfig(pkgmgr-info)
 BuildRequires:  pkgconfig(pkgmgr-installer)
 BuildRequires:  pkgconfig(sqlite3)
+BuildRequires:  pkgconfig(tizen-database)
 
 %if 0%{?gcov:1}
 BuildRequires:  lcov
index 5c07701876a23957e61adcaec5a3f80855a45fa1..5fac5f4a5a7e4881691944596ee9c0bc273d9032 100644 (file)
@@ -8,6 +8,7 @@ APPLY_PKG_CONFIG(${TARGET_TIZEN_THEME_PROVIDER} PUBLIC
   BUNDLE_DEPS
   DLOG_DEPS
   SQLITE_DEPS
+  DATABASE_DEPS
 )
 TARGET_LINK_LIBRARIES(${TARGET_TIZEN_THEME_PROVIDER} PRIVATE ${TARGET_TIZEN_THEME})
 
index 96e76438b98e61450b6e5d45f6068b536323e810..1ec7a9a69f1cd7ea271073f31aa455dc3de12986 100644 (file)
@@ -13,8 +13,6 @@
 #include <string>
 
 #include "theme/utils/logging.h"
-#include "theme_provider/sqlite_connection.h"
-#include "theme_provider/sqlite_statement.h"
 
 namespace {
 
@@ -100,13 +98,13 @@ bool SetOwnership(const std::string& path, uid_t uid, gid_t gid) {
 namespace ttm {
 namespace provider {
 
-DbManager::DbManager(const std::string& db_path) {
-  conn_ = std::make_shared<SQLiteConnection>(db_path, false);
-  if (!conn_->Execute(kCreateThemeTableQuery))
+DbManager::DbManager(const std::string& db_path)
+    : conn_(db_path, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) {
+  if (!static_cast<bool>(conn_.Exec({ kCreateThemeTableQuery })))
     LOG(ERROR) << "Failed to create theme table";
-  if (!conn_->Execute(kCreateIndexQuery))
+  if (!static_cast<bool>(conn_.Exec({ kCreateIndexQuery })))
     LOG(ERROR) << "Failed to create unique index for theme table";
-  if (!conn_->Execute(kCreateThemeSettingTableQuery))
+  if (!static_cast<bool>(conn_.Exec({ kCreateThemeSettingTableQuery })))
     LOG(ERROR) << "Failed to create theme_setting table";
 
   // if current process running as root, this is image creation
@@ -123,37 +121,23 @@ DbManager::~DbManager() {
 }
 
 bool DbManager::Insert(const tizen_base::Bundle& info) {
-  std::unique_ptr<SQLiteStatement> stmt = conn_->PrepareStatement(kInsertQuery);
-  if (!stmt) {
-    LOG(ERROR) << "Failed to prepare statement";
-    return false;
-  }
-
-  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")))
-    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->BindString(idx++, info.GetString("is_default")))
-    return false;
   auto raw = const_cast<tizen_base::Bundle&>(info).ToRaw();
   std::vector<unsigned char> v(raw.first.get(), raw.first.get() + raw.second);
-  if (!stmt->BindBlob(idx++, v))
-    return false;
-
-  if (stmt->Step() != SQLiteStatement::StepResult::DONE) {
+  auto q = tizen_base::Database::Sql(kInsertQuery)
+      .SetEmptyStringAsNull(true)
+      .Bind(info.GetString("id"))
+      .Bind(info.GetString("pkgid"))
+      .Bind(info.GetString("/version"))
+      .Bind(info.GetString("/tool_version"))
+      .Bind(info.GetString("/title"))
+      .Bind(info.GetString("/description"))
+      .Bind(info.GetString("/preview"))
+      .Bind(info.GetString("/resolution"))
+      .Bind(info.GetString("is_default"))
+      .Bind(std::move(v));
+
+  auto r = conn_.Exec(q);
+  if (!static_cast<bool>(r)) {
     LOG(ERROR) << "Failed to insert ThemeInfo into DB";
     return false;
   }
@@ -162,33 +146,21 @@ bool DbManager::Insert(const tizen_base::Bundle& info) {
 }
 
 bool DbManager::Update(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;
   auto raw = const_cast<tizen_base::Bundle&>(info).ToRaw();
   std::vector<unsigned char> v(raw.first.get(), raw.first.get() + raw.second);
-  if (!stmt->BindBlob(idx++, v))
-    return false;
-  if (!stmt->BindString(idx++, info.GetString("id")))
-    return false;
-
-  if (stmt->Step() != SQLiteStatement::StepResult::DONE) {
+  auto q = tizen_base::Database::Sql(kUpdateQuery)
+      .SetEmptyStringAsNull(true)
+      .Bind(info.GetString("version"))
+      .Bind(info.GetString("tool_version"))
+      .Bind(info.GetString("title"))
+      .Bind(info.GetString("description"))
+      .Bind(info.GetString("preview"))
+      .Bind(info.GetString("resolution"))
+      .Bind(std::move(v))
+      .Bind(info.GetString("id"));
+
+  auto r = conn_.Exec(q);
+  if (!static_cast<bool>(r)) {
     LOG(ERROR) << "Failed to update ThemeInfo into DB";
     return false;
   }
@@ -200,16 +172,11 @@ bool DbManager::Update(const tizen_base::Bundle& info) {
 }
 
 bool DbManager::Delete(const std::string& id) {
-  std::unique_ptr<SQLiteStatement> stmt = conn_->PrepareStatement(kDeleteQuery);
-  if (!stmt) {
-    LOG(ERROR) << "Failed to prepare statement";
-    return false;
-  }
+  auto q = tizen_base::Database::Sql(kDeleteQuery)
+      .Bind(id);
 
-  if (!stmt->BindString(1, id))
-    return false;
-
-  if (stmt->Step() != SQLiteStatement::StepResult::DONE) {
+  auto r = conn_.Exec(q);
+  if (!static_cast<bool>(r)) {
     LOG(ERROR) << "Failed to delete ThemeInfo of " << id;
     return false;
   }
@@ -218,97 +185,91 @@ bool DbManager::Delete(const std::string& id) {
 }
 
 tizen_base::Bundle DbManager::Select(const std::string& id) {
-  std::unique_ptr<SQLiteStatement> stmt = conn_->PrepareStatement(kSelectQuery);
-  if (!stmt) {
-    LOG(ERROR) << "Failed to prepare statement";
+  auto q = tizen_base::Database::Sql(kSelectQuery)
+      .Bind(id);
+
+  auto r = conn_.Exec(q);
+  if (!static_cast<bool>(r)) {
+    LOG(ERROR) << "Failed to select ThemeInfo of " << id;
     return {};
   }
 
-  if (!stmt->BindString(1, id))
+  auto rec = r.GetFirstRecord();
+  if (!rec)
     return {};
 
-  if (stmt->Step() != SQLiteStatement::StepResult::ROW) {
-    LOG(ERROR) << "Failed to select ThemeInfo of " << id;
+  std::optional<std::vector<unsigned char>> v = rec->Get(0);
+  if (!v)
     return {};
-  }
 
-  int idx = 0;
-  std::vector<unsigned char> v = stmt->GetColumnBlob(idx++);
-  std::string raw(reinterpret_cast<char const*>(v.data()), v.size());
+  std::string raw(reinterpret_cast<char const*>(v->data()), v->size());
   tizen_base::Bundle b(raw);
 
   return b;
 }
 
 tizen_base::Bundle DbManager::SelectDefault() {
-  std::unique_ptr<SQLiteStatement> stmt =
-      conn_->PrepareStatement(kSelectDefaultQuery);
-  if (!stmt) {
-    LOG(ERROR) << "Failed to prepare statement";
+  auto r = conn_.Exec({ kSelectDefaultQuery });
+  if (!static_cast<bool>(r)) {
+    LOG(ERROR) << "Failed to select default ThemeInfo";
     return {};
   }
 
-  if (stmt->Step() != SQLiteStatement::StepResult::ROW) {
-    LOG(ERROR) << "Failed to select default ThemeInfo";
+  auto rec = r.GetFirstRecord();
+  if (!rec)
     return {};
-  }
 
-  int idx = 0;
-  std::vector<unsigned char> v = stmt->GetColumnBlob(idx++);
-  std::string raw(reinterpret_cast<char const*>(v.data()), v.size());
+  std::optional<std::vector<unsigned char>> v = rec->Get(0);
+  if (!v)
+    return {};
+
+  std::string raw(reinterpret_cast<char const*>(v->data()), v->size());
   tizen_base::Bundle b(raw);
 
   return b;
 }
 
 tizen_base::Bundle DbManager::SelectCurrent() {
-  std::unique_ptr<SQLiteStatement> stmt =
-      conn_->PrepareStatement(kSelectCurrentQuery);
-  if (!stmt) {
-    LOG(ERROR) << "Failed to prepare statement";
+  auto r = conn_.Exec({ kSelectCurrentQuery });
+  if (!static_cast<bool>(r)) {
+    LOG(ERROR) << "Failed to select default ThemeInfo";
     return {};
   }
 
-  if (stmt->Step() != SQLiteStatement::StepResult::ROW) {
-    LOG(ERROR) << "Failed to select default ThemeInfo";
+  auto rec = r.GetFirstRecord();
+  if (!rec)
     return {};
-  }
 
-  int idx = 0;
-  std::vector<unsigned char> v = stmt->GetColumnBlob(idx++);
-  std::string raw(reinterpret_cast<char const*>(v.data()), v.size());
+  std::optional<std::vector<unsigned char>> v = rec->Get(0);
+  if (!v)
+    return {};
+
+  std::string raw(reinterpret_cast<char const*>(v->data()), v->size());
   tizen_base::Bundle b(raw);
 
   return b;
 }
 
 std::vector<std::string> DbManager::SelectIds() {
-  std::unique_ptr<SQLiteStatement> stmt =
-      conn_->PrepareStatement(kSelectIdsQuery);
-  if (!stmt) {
+  auto r = conn_.Exec({ kSelectIdsQuery });
+  if (!static_cast<bool>(r)) {
     LOG(ERROR) << "Failed to prepare statement";
     return {};
   }
 
   std::vector<std::string> ids;
-  while (stmt->Step() == SQLiteStatement::StepResult::ROW)
-    ids.emplace_back(stmt->GetColumnString(0));
+  for (const auto& i : r)
+    ids.emplace_back(static_cast<std::string>(i.Get(0)));
 
   return ids;
 }
 
 bool DbManager::UpdateCurrentId(const std::string& id) {
-  std::unique_ptr<SQLiteStatement> stmt =
-      conn_->PrepareStatement(kSetThemeQuery);
-  if (!stmt) {
-    LOG(ERROR) << "Failed to prepare statement";
-    return false;
-  }
-
-  if (!stmt->BindString(1, id))
-    return false;
+  auto q = tizen_base::Database::Sql(kSetThemeQuery)
+      .Bind(id);
 
-  if (stmt->Step() != SQLiteStatement::StepResult::DONE) {
+  auto r = conn_.Exec(q);
+  if (!static_cast<bool>(r)) {
     LOG(ERROR) << "Failed to set current theme as " << id;
     return false;
   }
index ee49e10a4590c553c8462072f3124098fe66a4f6..ef2c96954a3410329b0fe00cb289f02de0911900 100644 (file)
@@ -7,12 +7,11 @@
 
 #include <bundle_cpp.h>
 
+#include <database.hpp>
 #include <memory>
 #include <string>
 #include <vector>
 
-#include "theme_provider/sqlite_connection.h"
-
 namespace ttm {
 namespace provider {
 
@@ -37,7 +36,7 @@ class DbManager {
   void AddPackageEventListener(IThemePackageEvent* listener);
 
  private:
-  std::shared_ptr<SQLiteConnection> conn_;
+  tizen_base::Database conn_;
   std::vector<IThemePackageEvent*> listeners_;
 };
 
diff --git a/src/theme_provider/sqlite_connection.cc b/src/theme_provider/sqlite_connection.cc
deleted file mode 100644 (file)
index 8f046d9..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#include "theme_provider/sqlite_connection.h"
-
-#include <sqlite3.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <string>
-#include <utility>
-
-#include "theme/utils/logging.h"
-#include "theme_provider/sqlite_statement.h"
-
-namespace ttm {
-namespace provider {
-
-SQLiteConnection::SQLiteConnection(std::string path, bool readonly)
-    : path_(std::move(path)), db_(nullptr) {
-  if (!Connect(readonly))
-    LOG(ERROR) << "Failed to connect db";
-}
-
-SQLiteConnection::~SQLiteConnection() {
-  Disconnect();
-}
-
-bool SQLiteConnection::Connect(bool readonly) {
-  int flags;
-  if (readonly)
-    flags = SQLITE_OPEN_READONLY;
-  else
-    flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
-
-  sqlite3* db;
-  int r = sqlite3_open_v2(path_.c_str(), &db, flags, nullptr);
-  if (r != SQLITE_OK) {
-    LOG(ERROR) << "Failed to open sqlite3 db("
-               << path_ << "). Error code: " << r;
-    SetErrorCode(r);
-    sqlite3_close_v2(db);
-    return false;
-  }
-  r = sqlite3_exec(db, "PRAGMA foreign_keys=ON", nullptr, nullptr, nullptr);
-  if (r != SQLITE_OK)
-    LOG(ERROR) << "Failed to enable foreign key support: " << r;
-  db_ = db;
-  return true;
-}
-
-bool SQLiteConnection::Disconnect() {
-  if (db_) {
-    sqlite3_close_v2(db_);
-    db_ = nullptr;
-  }
-  return true;
-}
-
-void SQLiteConnection::SetErrorCode(int error_code) {
-  error_code_ = error_code;
-}
-
-int SQLiteConnection::GetErrorCode() {
-  return error_code_;
-}
-
-bool SQLiteConnection::Execute(const std::string& command) {
-  if (!db_) {
-    LOG(ERROR) << "Invalid SQLite connection";
-    return false;
-  }
-
-  int r = sqlite3_exec(db_, command.c_str(), nullptr, nullptr, nullptr);
-  if (r != SQLITE_OK) {
-    LOG(ERROR) << "Execute command(" << command << ") failed: "
-               << GetErrorMessage();
-    SetErrorCode(r);
-    return false;
-  }
-  return true;
-}
-
-std::string SQLiteConnection::GetErrorMessage() const {
-  return sqlite3_errmsg(db_);
-}
-
-std::unique_ptr<SQLiteStatement> SQLiteConnection::PrepareStatement(
-    const std::string& query) {
-  if (!db_) {
-    LOG(ERROR) << "Invalid SQLite connection";
-    return {};
-  }
-
-  sqlite3_stmt* stmt;
-  int r = sqlite3_prepare_v2(db_, query.c_str(), query.length(), &stmt,
-      nullptr);
-  if (r != SQLITE_OK) {
-    LOG(ERROR) << "sqlite3_prepare_v2() failed: " << GetErrorMessage();
-    return {};
-  }
-  return std::make_unique<SQLiteStatement>(shared_from_this(), stmt);
-}
-
-bool SQLiteConnection::IsValid() {
-  if (db_)
-    return true;
-  return false;
-}
-
-}  // namespace provider
-}  // namespace ttm
diff --git a/src/theme_provider/sqlite_connection.h b/src/theme_provider/sqlite_connection.h
deleted file mode 100644 (file)
index 4fa2146..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef THEME_PROVIDER_SQLITE_CONNECTION_H_
-#define THEME_PROVIDER_SQLITE_CONNECTION_H_
-
-#include <sqlite3.h>
-
-#include <memory>
-#include <string>
-
-namespace ttm {
-namespace provider {
-
-class SQLiteStatement;
-
-class SQLiteConnection : public std::enable_shared_from_this<SQLiteConnection> {
- public:
-  explicit SQLiteConnection(std::string path, bool readonly);
-  ~SQLiteConnection();
-
-  // non-copyable
-  SQLiteConnection(const SQLiteConnection&) = delete;
-  SQLiteConnection& operator=(const SQLiteConnection&) = delete;
-
-  void SetErrorCode(int error_code);
-  int GetErrorCode();
-  bool Execute(const std::string& command);
-
-  std::unique_ptr<SQLiteStatement> PrepareStatement(const std::string& query);
-
-  bool IsValid();
-
- private:
-  bool Connect(bool readonly);
-  bool Disconnect();
-  std::string GetErrorMessage() const;
-
-  std::string path_;
-  sqlite3* db_;
-  int error_code_;
-};
-
-}  // namespace provider
-}  // namespace ttm
-
-#endif  // THEME_PROVIDER_SQLITE_CONNECTION_H_
diff --git a/src/theme_provider/sqlite_statement.cc b/src/theme_provider/sqlite_statement.cc
deleted file mode 100644 (file)
index f83b660..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#include "theme_provider/sqlite_statement.h"
-
-#include <sqlite3.h>
-
-#include <string>
-#include <vector>
-
-#include "theme/utils/logging.h"
-#include "theme_provider/sqlite_connection.h"
-
-namespace ttm {
-namespace provider {
-
-SQLiteStatement::SQLiteStatement(std::shared_ptr<SQLiteConnection> sql_conn,
-    sqlite3_stmt* stmt) : sql_conn_(sql_conn), stmt_(stmt) {}
-
-SQLiteStatement::~SQLiteStatement() {
-  int r = sqlite3_finalize(stmt_);
-  if (r != SQLITE_OK)
-    LOG(ERROR) << "sqlite3_finalize() failed: " << GetErrorMessage();
-}
-
-SQLiteStatement::StepResult SQLiteStatement::Step() {
-  int r = sqlite3_step(stmt_);
-  if (r != SQLITE_ROW && r != SQLITE_DONE) {
-    LOG(ERROR) << "sqlite3_step() failed: " << GetErrorMessage();
-    sql_conn_->SetErrorCode(r);
-    return SQLiteStatement::StepResult::ERROR;
-  }
-  SQLiteStatement::StepResult res;
-  if (r == SQLITE_ROW) {
-    res = SQLiteStatement::StepResult::ROW;
-  } else if (r == SQLITE_DONE) {
-    res = SQLiteStatement::StepResult::DONE;
-  } else {
-    LOG(ERROR) << "Unexpected sqlite3 result code: " << r;
-    res = SQLiteStatement::StepResult::ERROR;
-  }
-  return res;
-}
-
-bool SQLiteStatement::BindNull(int pos) {
-  int r = sqlite3_bind_null(stmt_, pos);
-  if (r != SQLITE_OK) {
-    LOG(ERROR) << "sqlite3_bind_null() failed: " << GetErrorMessage();
-    sql_conn_->SetErrorCode(r);
-    return false;
-  }
-  return true;
-}
-
-bool SQLiteStatement::BindString(int pos, const std::string& val) {
-  if (val.empty())
-    return BindNull(pos);
-
-  int r = sqlite3_bind_text(stmt_, pos, val.c_str(), -1, SQLITE_TRANSIENT);
-  if (r != SQLITE_OK) {
-    LOG(ERROR) << "sqlite3_bind_text() failed: " << GetErrorMessage();
-    sql_conn_->SetErrorCode(r);
-    return false;
-  }
-  return true;
-}
-
-bool SQLiteStatement::BindBlob(int pos, const std::vector<unsigned char>& val) {
-  int r = sqlite3_bind_blob(stmt_, pos, val.data(), val.size(),
-      SQLITE_TRANSIENT);
-  if (r != SQLITE_OK) {
-    LOG(ERROR) << "sqlite3_bind_blob() failed: " << GetErrorMessage();
-    sql_conn_->SetErrorCode(r);
-    return false;
-  }
-  return true;
-}
-
-std::string SQLiteStatement::GetColumnString(int pos) const {
-  const char* val = reinterpret_cast<const char*>(
-      sqlite3_column_text(stmt_, pos));
-  if (!val)
-    return {};
-  return std::string(val);
-}
-
-std::vector<unsigned char> SQLiteStatement::GetColumnBlob(int pos) const {
-  const unsigned char* val = reinterpret_cast<const unsigned char*>(
-      sqlite3_column_blob(stmt_, pos));
-  if (!val)
-    return {};
-  int len = sqlite3_column_bytes(stmt_, pos);
-  if (len < 0) {
-    LOG(ERROR) << "sqlite3_column_bytes() failed: " << GetErrorMessage();
-    return {};
-  }
-  return std::vector<unsigned char>(val, val + len);
-}
-
-std::string SQLiteStatement::GetErrorMessage() const {
-  return sqlite3_errmsg(sqlite3_db_handle(stmt_));
-}
-
-}  // namespace provider
-}  // namespace ttm
diff --git a/src/theme_provider/sqlite_statement.h b/src/theme_provider/sqlite_statement.h
deleted file mode 100644 (file)
index e1a7229..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef THEME_PROVIDER_SQLITE_STATEMENT_H_
-#define THEME_PROVIDER_SQLITE_STATEMENT_H_
-
-#include <sqlite3.h>
-
-#include <memory>
-#include <string>
-#include <vector>
-
-namespace ttm {
-namespace provider {
-
-class SQLiteConnection;
-
-class SQLiteStatement {
- public:
-  explicit SQLiteStatement(std::shared_ptr<SQLiteConnection> sql_conn,
-      sqlite3_stmt* stmt);
-  virtual ~SQLiteStatement();
-
-  // non-copyable
-  SQLiteStatement(const SQLiteStatement&) = delete;
-  SQLiteStatement& operator=(const SQLiteStatement&) = delete;
-
-  enum class StepResult : int { DONE, ROW, ERROR, };
-  StepResult Step();
-
-  bool BindNull(int pos);
-  bool BindString(int pos, const std::string& val);
-  bool BindBlob(int pos, const std::vector<unsigned char>& val);
-
-  std::string GetColumnString(int pos) const;
-  std::vector<unsigned char> GetColumnBlob(int pos) const;
-
- private:
-  std::string GetErrorMessage() const;
-
-  std::shared_ptr<SQLiteConnection> sql_conn_;
-  sqlite3_stmt* stmt_;
-};
-
-}  // namespace provider
-}  // namespace ttm
-
-#endif  // THEME_PROVIDER_SQLITE_STATEMENT_H_