Add skeleton codes for ThemeInfoLoader
authorInkyun Kil <inkyun.kil@samsung.com>
Tue, 14 Apr 2020 01:13:34 +0000 (10:13 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Mon, 25 May 2020 04:28:15 +0000 (13:28 +0900)
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
src/theme/CMakeLists.txt
src/theme/dbus/request_broker.h [new file with mode: 0644]
src/theme/dbus/request_filter.h [new file with mode: 0644]
src/theme/loader/theme_event.h [new file with mode: 0644]
src/theme/loader/theme_info.cc [new file with mode: 0644]
src/theme/loader/theme_info.h
src/theme/loader/theme_info_loader.h [new file with mode: 0644]
src/theme_plugin/theme_info_builder.cc
src/theme_plugin/theme_parser.cc
src/theme_provider/theme_info_proxy.cc
src/theme_provider/theme_info_proxy.h

index ceccf12..5e68b95 100644 (file)
@@ -1,5 +1,11 @@
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/loader THEME_LOADER_SRCS)
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/utils THEME_UTILS_SRCS)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/loader/)
+
 ADD_LIBRARY(${TARGET_TIZEN_THEME} SHARED
+  ${THEME_LOADER_SRCS}
   ${THEME_UTILS_SRCS}
 )
 TARGET_INCLUDE_DIRECTORIES(${TARGET_TIZEN_THEME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../")
diff --git a/src/theme/dbus/request_broker.h b/src/theme/dbus/request_broker.h
new file mode 100644 (file)
index 0000000..de68a63
--- /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_DBUS_REQUEST_BROKER_H_
+#define THEME_DBUS_REQUEST_BROKER_H_
+
+#include <gio/gio.h>
+
+#include "request_filter.h"
+
+namespace ttm {
+
+class RequestBroker {
+ public:
+  static RequestBroker& GetInst();
+  GDBusConnection* GetConnection();
+
+  int RegisterRequestFilter(const RequestFilter& filter);
+  tizen_base::Bundle& SendData(Command cmd, const tizen_base::Bundle&);
+  void SendDataAsync(Command cmd, const tize_base::Bundle&);
+
+ private:
+  DBusConnectionManager();
+  ~DBusConnectionManager();
+  GDBusConnection* connection_ = nullptr;
+  std::List<std::shared_ptr<RequestFilter>> filters_;
+};
+}  // namespace ttm
+
+#endif  // THEME_DBUS_REQUEST_BROKER_H_
diff --git a/src/theme/dbus/request_filter.h b/src/theme/dbus/request_filter.h
new file mode 100644 (file)
index 0000000..6d26104
--- /dev/null
@@ -0,0 +1,26 @@
+// 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 "request_handler.h"
+
+namespace ttm {
+
+class RequestFilter {
+ public:
+  RequestFilter(Command cmd, std::shared_ptr<IRequestHandler> handler)
+      : cmd_(cmd), handler_(handler) { }
+  bool IsOneway();
+  Command GetCmd();
+  const IRequestHandler& GetHandler();
+ private:
+  Command cmd_;
+  std::shared_ptr<IRequestHandler> handler_;
+};
+
+}  // namespace ttm
+
+#endif  // THEME_DBUS_REQUEST_HANDLER_H_
diff --git a/src/theme/loader/theme_event.h b/src/theme/loader/theme_event.h
new file mode 100644 (file)
index 0000000..2c9ceef
--- /dev/null
@@ -0,0 +1,20 @@
+// 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_EVENT_H_
+#define THEME_LOADER_THEME_EVENT_H_
+
+#include "theme_info.h"
+
+namespace ttm {
+
+class IThemeEvent {
+ public:
+  virtual void OnThemeLoaded(const ThemeInfo,
+      const tizen_base::Bundle& args) = 0;
+};
+
+}  // namespace ttm
+
+#endif  // THEME_LOADER_THEME_EVENT_H_
diff --git a/src/theme/loader/theme_info.cc b/src/theme/loader/theme_info.cc
new file mode 100644 (file)
index 0000000..ae4b974
--- /dev/null
@@ -0,0 +1,70 @@
+// 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 <string>
+
+#include "theme_info.h"
+
+namespace ttm {
+
+class ThemeInfo;
+
+std::string ThemeInfo::GetId() {
+  return id_;
+}
+
+std::string ThemeInfo::GetVesion() {
+  return version_;
+}
+
+std::string ThemeInfo::GetToolVersion() {
+  return tool_version_;
+}
+
+std::string ThemeInfo::GetTitle() {
+  return title_;
+}
+
+std::string ThemeInfo::GetResolution() {
+  return resolution_;
+}
+
+std::string ThemeInfo::GetPreview() {
+  return preview_;
+}
+
+std::string ThemeInfo::GetDescription() {
+  return description_;
+}
+
+std::string ThemeInfo::GetString(std::string& key) {
+  return id_;
+}
+
+std::vector<std::string> ThemeInfo::GetStringArray(std::string& key) {
+  std::vector<std::string> v;
+  return v;
+}
+
+int ThemeInfo::GetInt(std::string& key) {
+  return 0;
+}
+
+float ThemeInfo::GetFloat(std::string& key) {
+  return 1.0;
+}
+
+bool ThemeInfo::GetBool(std::string& key) {
+  return true;
+}
+
+int ThemeInfo::Serialize(tizen_base::Bundle& bundle) {
+  return 0;
+}
+
+int ThemeInfo::Deserialize(const tizen_base::Bundle& bundle) {
+  return 0;
+}
+
+}  // namespace ttm
index e3fbb50..2c0f537 100644 (file)
@@ -5,9 +5,46 @@
 #ifndef THEME_LOADER_THEME_INFO_H_
 #define THEME_LOADER_THEME_INFO_H_
 
+#include <string>
+#include <vector>
+
+#include <bundle_cpp.h>
+
 namespace ttm {
 
 class ThemeInfo {
+ public:
+  ThemeInfo(std::string id, std::string version, std::string tool_version,
+    std::string title, std::string resolution, std::string preview,
+    std::string description)
+      : id_(id), version_(version), tool_version_(tool_version),
+        title_(title), resolution_(resolution), preview_(preview),
+        description_(description) { }
+
+  std::string GetId();
+  std::string GetVesion();
+  std::string GetToolVersion();
+  std::string GetTitle();
+  std::string GetResolution();
+  std::string GetPreview();
+  std::string GetDescription();
+  std::string GetString(std::string& key);
+  std::vector<std::string> GetStringArray(std::string& key);
+  int GetInt(std::string& key);
+  float GetFloat(std::string& key);
+  bool GetBool(std::string& key);
+
+  int Serialize(tizen_base::Bundle& bundle);
+  int Deserialize(const tizen_base::Bundle& bundle);
+
+ private:
+  std::string id_;
+  std::string version_;
+  std::string tool_version_;
+  std::string title_;
+  std::string resolution_;
+  std::string preview_;
+  std::string description_;
 };
 
 }  // namespace ttm
diff --git a/src/theme/loader/theme_info_loader.h b/src/theme/loader/theme_info_loader.h
new file mode 100644 (file)
index 0000000..525ded6
--- /dev/null
@@ -0,0 +1,33 @@
+// 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_LOADER_H_
+#define THEME_LOADER_THEME_INFO_LOADER_H_
+
+#include "theme/dbus/request_handler.h"
+
+namespace ttm {
+
+class ThemeInfoLoader : public IRequestHandler {
+ public:
+  explicit ThemeInfoLoader(std::shared_ptr<ThemeInfoProxy> cache)
+      : IRequestHandler(), cache_(cache) { }
+  tizen_base::Bundle OnRequest(Command cmd,
+    const tizen_base::Bundle& args) override;
+
+  std::string AddEvent(IThemeEvent& ev);
+  int RemoveEvent(const std::string& id);
+
+  std::string[] QueryThemeId();
+  void SetCurrent(const std::string& id);
+  std::shared_ptr<ThemeInfo> LoadCurrent() const;
+  std::shared_ptr<ThemeInfo> Load(const std::string& id) const;
+ private:
+  std::shared_ptr<ThemeInfo> cache_;
+  std::List<IThemeEvent> listeners_;
+};
+
+}  // namespace ttm
+
+#endif  // THEME_LOADER_THEME_INFO_LOADER_H_
index 6b20a95..60b2408 100644 (file)
@@ -43,7 +43,8 @@ ThemeInfoBuilder& ThemeInfoBuilder::PutExtraArray(std::string key, std::string v
 }\r
 \r
 ThemeInfo ThemeInfoBuilder::Build() {\r
-    return {};\r
+  ThemeInfo info("id", "0.1", "0.1", "title", "resolution", "preview", "desc");\r
+  return info;\r
 }\r
 \r
 }  // namespace ttm
\ No newline at end of file
index 37b3635..c33484e 100644 (file)
@@ -8,7 +8,7 @@
 namespace ttm {\r
 \r
 ThemeInfo ThemeParser::Inflate(std::string json) {\r
-    ThemeInfo info;\r
+    ThemeInfo info("id", "0.1", "0.1", "title", "resolution", "preview", "desc");\r
     return info;\r
 }\r
 \r
index ee8e7a3..89fce2c 100644 (file)
@@ -12,16 +12,16 @@ namespace ttm {
 
 class ThemeInfo;
 
-ThemeInfo LoadTheme(const std::string& id) {
-  return {};
+std::shared_ptr<ThemeInfo> LoadTheme(const std::string& id) {
+  return nullptr;
 }
 
 bool SaveTheme(const ThemeInfo& info) {
   return true;
 }
 
-ThemeInfo GetLoadedTheme() {
-  return {};
+std::shared_ptr<ThemeInfo> GetLoadedTheme() {
+  return nullptr;
 }
 
 bool SetCurrentTheme(const std::string& id) {
index 6157367..bfadd0d 100644 (file)
@@ -16,9 +16,9 @@ class ThemeInfo;
 
 class ThemeInfoProxy : public IThemePackageEvent {
  public:
-  ThemeInfo LoadTheme(const std::string& id);
+  std::shared_ptr<ThemeInfo> LoadTheme(const std::string& id);
   bool SaveTheme(const ThemeInfo& info);
-  ThemeInfo GetLoadedTheme();
+  std::shared_ptr<ThemeInfo> GetLoadedTheme();
   bool SetCurrentTheme(const std::string& id);
   void OnThemePackageChanged(const std::string& id) override;
 };