Add skeleton code of theme_provider
authorSangyoon Jang <jeremy.jang@samsung.com>
Wed, 8 Apr 2020 09:03:43 +0000 (18:03 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Mon, 25 May 2020 04:28:15 +0000 (13:28 +0900)
Change-Id: I999363e35057b2faf8045f4f0a3735e910a9cae5
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
17 files changed:
CMakeLists.txt
packaging/tizen-theme-manager.spec
src/CMakeLists.txt [new file with mode: 0644]
src/theme/dbus/request_handler.h [new file with mode: 0644]
src/theme/loader/theme_info.h [new file with mode: 0644]
src/theme_provider/CMakeLists.txt [new file with mode: 0644]
src/theme_provider/control_request_handler.cc [new file with mode: 0644]
src/theme_provider/control_request_handler.h [new file with mode: 0644]
src/theme_provider/db_manager.cc [new file with mode: 0644]
src/theme_provider/db_manager.h [new file with mode: 0644]
src/theme_provider/main.cc [new file with mode: 0644]
src/theme_provider/package_event_request_handler.cc [new file with mode: 0644]
src/theme_provider/package_event_request_handler.h [new file with mode: 0644]
src/theme_provider/selection_request_handler.cc [new file with mode: 0644]
src/theme_provider/selection_request_handler.h [new file with mode: 0644]
src/theme_provider/theme_info_proxy.cc [new file with mode: 0644]
src/theme_provider/theme_info_proxy.h [new file with mode: 0644]

index b32b9eb..0ff74a9 100644 (file)
@@ -3,7 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
 PROJECT(tizen-theme-manager)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "\${prefix}")
+SET(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
 SET(LIBDIR ${LIB_INSTALL_DIR})
 SET(INCLUDEDIR "\${prefix}/include")
 
@@ -16,7 +16,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed,--gc-sections -pie")
 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
 
 ## Targets
-SET(TARGET_TIZEN_THEME_MANAGER "tizen-theme-manager")
+SET(TARGET_TIZEN_THEME_PROVIDER "tizen-theme-provider")
 
 INCLUDE(FindPkgConfig)
 INCLUDE(ApplyPkgConfig)
@@ -24,3 +24,6 @@ INCLUDE(ApplyPkgConfig)
 ADD_DEFINITIONS("-DPROJECT_TAG=\"TIZEN_THEME_MANAGER\"")
 
 ## Find all needed packages once
+PKG_CHECK_MODULES(BUNDLE_DEPS REQUIRED bundle)
+
+ADD_SUBDIRECTORY(src)
index 61cf6f4..ac21a8e 100644 (file)
@@ -7,6 +7,7 @@ License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1001: %{name}.manifest
 BuildRequires:  cmake
+BuildRequires:  pkgconfig(bundle)
 
 %description
 Tizen Theme Manager
@@ -33,3 +34,4 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %manifest %{name}.manifest
 %license LICENSE
 %defattr(-,root,root,-)
+%{_bindir}/*
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..704d2f7
--- /dev/null
@@ -0,0 +1 @@
+ADD_SUBDIRECTORY(theme_provider)
diff --git a/src/theme/dbus/request_handler.h b/src/theme/dbus/request_handler.h
new file mode 100644 (file)
index 0000000..b00db32
--- /dev/null
@@ -0,0 +1,23 @@
+// 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_DBUS_REQUEST_HANDLER_H_
+#define THEME_DBUS_REQUEST_HANDLER_H_
+
+#include <bundle_cpp.h>
+
+namespace ttm {
+
+enum class Command : int {
+};
+
+class IRequestHandler {
+ public:
+  virtual tizen_base::Bundle OnRequest(Command cmd,
+      const tizen_base::Bundle& args) = 0;
+};
+
+}  // namespace ttm
+
+#endif  // THEME_DBUS_REQUEST_HANDLER_H_
diff --git a/src/theme/loader/theme_info.h b/src/theme/loader/theme_info.h
new file mode 100644 (file)
index 0000000..e3fbb50
--- /dev/null
@@ -0,0 +1,15 @@
+// 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_LOADER_THEME_INFO_H_
+#define THEME_LOADER_THEME_INFO_H_
+
+namespace ttm {
+
+class ThemeInfo {
+};
+
+}  // namespace ttm
+
+#endif  // THEME_LOADER_THEME_INFO_H_
diff --git a/src/theme_provider/CMakeLists.txt b/src/theme_provider/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8121cdb
--- /dev/null
@@ -0,0 +1,15 @@
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} THEME_PROVIDER_SRCS)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
+
+ADD_EXECUTABLE(${TARGET_TIZEN_THEME_PROVIDER}
+  ${THEME_PROVIDER_SRCS}
+)
+
+APPLY_PKG_CONFIG(${TARGET_TIZEN_THEME_PROVIDER} PUBLIC
+  BUNDLE_DEPS
+)
+
+SET_TARGET_PROPERTIES(${TARGET_TIZEN_THEME_PROVIDER} PROPERTIES COMPILE_FLAGS "-fPIE")
+SET_TARGET_PROPERTIES(${TARGET_TIZEN_THEME_PROVIDER} PROPERTIES LINK_FLAGS "-pie")
+
+INSTALL(TARGETS ${TARGET_TIZEN_THEME_PROVIDER} DESTINATION ${BINDIR})
diff --git a/src/theme_provider/control_request_handler.cc b/src/theme_provider/control_request_handler.cc
new file mode 100644 (file)
index 0000000..9bbd96d
--- /dev/null
@@ -0,0 +1,16 @@
+// 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/control_request_handler.h"
+
+#include <bundle_cpp.h>
+
+namespace ttm {
+
+tizen_base::Bundle ControlRequestHandler::OnRequest(Command cmd,
+    const tizen_base::Bundle& args) {
+  return {};
+}
+
+}  // namespace ttm
diff --git a/src/theme_provider/control_request_handler.h b/src/theme_provider/control_request_handler.h
new file mode 100644 (file)
index 0000000..c8ddd2b
--- /dev/null
@@ -0,0 +1,31 @@
+// 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_CONTROL_REQUEST_HANDLER_H_
+#define THEME_PROVIDER_CONTROL_REQUEST_HANDLER_H_
+
+#include <bundle_cpp.h>
+
+#include <memory>
+#include <string>
+
+#include "theme/dbus/request_handler.h"
+
+namespace ttm {
+
+class ThemeInfoProxy;
+
+class ControlRequestHandler : public IRequestHandler {
+ public:
+  explicit ControlRequestHandler(std::shared_ptr<ThemeInfoProxy> proxy)
+      : IRequestHandler(), proxy_(proxy) { }
+  tizen_base::Bundle OnRequest(Command cmd, const tizen_base::Bundle& args);
+
+ private:
+  std::shared_ptr<ThemeInfoProxy> proxy_;
+};
+
+}  // namespace ttm
+
+#endif  // THEME_PROVIDER_CONTROL_REQUEST_HANDLER_H_
diff --git a/src/theme_provider/db_manager.cc b/src/theme_provider/db_manager.cc
new file mode 100644 (file)
index 0000000..53f054a
--- /dev/null
@@ -0,0 +1,35 @@
+// 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/db_manager.h"
+
+#include <bundle_cpp.h>
+
+#include <string>
+
+namespace ttm {
+
+bool DbManager::Insert(const std::string& id, const tizen_base::Bundle& info) {
+  return true;
+}
+
+bool DbManager::Delete(const std::string& id) {
+  return true;
+}
+
+tizen_base::Bundle DbManager::Select(const std::string& id) {
+  return {};
+}
+
+bool DbManager::UpdateCurrentId(const std::string& id) {
+  return true;
+}
+
+void DbManager::AddPackageEventListener(
+    std::shared_ptr<IThemePackageEvent> listener) {
+  listeners_.emplace_back(listener);
+}
+
+
+}  // namespace ttm
diff --git a/src/theme_provider/db_manager.h b/src/theme_provider/db_manager.h
new file mode 100644 (file)
index 0000000..784811c
--- /dev/null
@@ -0,0 +1,35 @@
+// 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_DB_MANAGER_H_
+#define THEME_PROVIDER_DB_MANAGER_H_
+
+#include <bundle_cpp.h>
+
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace ttm {
+
+class IThemePackageEvent {
+ public:
+  virtual void OnThemePackageChanged(const std::string& id) = 0;
+};
+
+class DbManager {
+ public:
+  bool Insert(const std::string& id, const tizen_base::Bundle& info);
+  bool Delete(const std::string& id);
+  tizen_base::Bundle Select(const std::string& id);
+  bool UpdateCurrentId(const std::string& id);
+  void AddPackageEventListener(std::shared_ptr<IThemePackageEvent> listener);
+
+ private:
+  std::vector<std::shared_ptr<IThemePackageEvent>> listeners_;
+};
+
+}  // namespace ttm
+
+#endif  // THEME_PROVIDER_DB_MANAGER_H_
diff --git a/src/theme_provider/main.cc b/src/theme_provider/main.cc
new file mode 100644 (file)
index 0000000..3d675ab
--- /dev/null
@@ -0,0 +1,7 @@
+// 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.
+
+int main(int argc, char** argv) {
+  return 0;
+}
diff --git a/src/theme_provider/package_event_request_handler.cc b/src/theme_provider/package_event_request_handler.cc
new file mode 100644 (file)
index 0000000..2cc2d2c
--- /dev/null
@@ -0,0 +1,16 @@
+// 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/package_event_request_handler.h"
+
+#include <bundle_cpp.h>
+
+namespace ttm {
+
+tizen_base::Bundle PackageEventRequestHandler::OnRequest(Command cmd,
+    const tizen_base::Bundle& args) {
+  return {};
+}
+
+}  // namespace ttm
diff --git a/src/theme_provider/package_event_request_handler.h b/src/theme_provider/package_event_request_handler.h
new file mode 100644 (file)
index 0000000..207d87f
--- /dev/null
@@ -0,0 +1,31 @@
+// 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_PACKAGE_EVENT_REQUEST_HANDLER_H_
+#define THEME_PROVIDER_PACKAGE_EVENT_REQUEST_HANDLER_H_
+
+#include <bundle_cpp.h>
+
+#include <memory>
+#include <string>
+
+#include "theme/dbus/request_handler.h"
+
+namespace ttm {
+
+class ThemeInfoProxy;
+
+class PackageEventRequestHandler : public IRequestHandler {
+ public:
+  explicit PackageEventRequestHandler(std::shared_ptr<ThemeInfoProxy> proxy)
+      : IRequestHandler(), proxy_(proxy) { }
+  tizen_base::Bundle OnRequest(Command cmd, const tizen_base::Bundle& args);
+
+ private:
+  std::shared_ptr<ThemeInfoProxy> proxy_;
+};
+
+}  // namespace ttm
+
+#endif  // THEME_PROVIDER_PACKAGE_EVENT_REQUEST_HANDLER_H_
diff --git a/src/theme_provider/selection_request_handler.cc b/src/theme_provider/selection_request_handler.cc
new file mode 100644 (file)
index 0000000..751eb8f
--- /dev/null
@@ -0,0 +1,16 @@
+// 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/selection_request_handler.h"
+
+#include <bundle_cpp.h>
+
+namespace ttm {
+
+tizen_base::Bundle SelectionRequestHandler::OnRequest(Command cmd,
+    const tizen_base::Bundle& args) {
+  return {};
+}
+
+}  // namespace ttm
diff --git a/src/theme_provider/selection_request_handler.h b/src/theme_provider/selection_request_handler.h
new file mode 100644 (file)
index 0000000..29d80d0
--- /dev/null
@@ -0,0 +1,31 @@
+// 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_SELECTION_REQUEST_HANDLER_H_
+#define THEME_PROVIDER_SELECTION_REQUEST_HANDLER_H_
+
+#include <bundle_cpp.h>
+
+#include <memory>
+#include <string>
+
+#include "theme/dbus/request_handler.h"
+
+namespace ttm {
+
+class ThemeInfoProxy;
+
+class SelectionRequestHandler : public IRequestHandler {
+ public:
+  explicit SelectionRequestHandler(std::shared_ptr<ThemeInfoProxy> proxy)
+      : IRequestHandler(), proxy_(proxy) { }
+  tizen_base::Bundle OnRequest(Command cmd, const tizen_base::Bundle& args);
+
+ private:
+  std::shared_ptr<ThemeInfoProxy> proxy_;
+};
+
+}  // namespace ttm
+
+#endif  // THEME_PROVIDER_SELECTION_REQUEST_HANDLER_H_
diff --git a/src/theme_provider/theme_info_proxy.cc b/src/theme_provider/theme_info_proxy.cc
new file mode 100644 (file)
index 0000000..ee8e7a3
--- /dev/null
@@ -0,0 +1,34 @@
+// 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/theme_info_proxy.h"
+
+#include <string>
+
+#include "theme/loader/theme_info.h"
+
+namespace ttm {
+
+class ThemeInfo;
+
+ThemeInfo LoadTheme(const std::string& id) {
+  return {};
+}
+
+bool SaveTheme(const ThemeInfo& info) {
+  return true;
+}
+
+ThemeInfo GetLoadedTheme() {
+  return {};
+}
+
+bool SetCurrentTheme(const std::string& id) {
+  return true;
+}
+
+void OnThemePackageChanged(const std::string& id) {
+}
+
+}  // namespace ttm
diff --git a/src/theme_provider/theme_info_proxy.h b/src/theme_provider/theme_info_proxy.h
new file mode 100644 (file)
index 0000000..6157367
--- /dev/null
@@ -0,0 +1,28 @@
+// 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_THEME_INFO_PROXY_H_
+#define THEME_PROVIDER_THEME_INFO_PROXY_H_
+
+#include <string>
+
+#include "theme/loader/theme_info.h"
+#include "theme_provider/db_manager.h"
+
+namespace ttm {
+
+class ThemeInfo;
+
+class ThemeInfoProxy : public IThemePackageEvent {
+ public:
+  ThemeInfo LoadTheme(const std::string& id);
+  bool SaveTheme(const ThemeInfo& info);
+  ThemeInfo GetLoadedTheme();
+  bool SetCurrentTheme(const std::string& id);
+  void OnThemePackageChanged(const std::string& id) override;
+};
+
+}  // namespace ttm
+
+#endif  // THEME_PROVIDER_THEME_INFO_PROXY_H_