+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}/../")
--- /dev/null
+// 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_
--- /dev/null
+// 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_
--- /dev/null
+// 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_
--- /dev/null
+// 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
#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
--- /dev/null
+// 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_
}\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
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
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) {
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;
};