From: Piotr Kosko
Date: Mon, 4 Jan 2016 13:24:36 +0000 (+0100)
Subject: [Common] Added FilesystemProvider interface for different profiles
X-Git-Tag: submit/tizen/20160113.110151^2~1^2
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8bfafc9f00a7e4b44ceba5cf1198cff41287f4e9;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[Common] Added FilesystemProvider interface for different profiles
Change-Id: Iccb3d1985be54f9c8f2bd6ea1c4a2ebaac1a3ba9
Signed-off-by: Piotr Kosko
---
diff --git a/src/archive/archive_instance.cc b/src/archive/archive_instance.cc
index 30ec005e..97f3f395 100755
--- a/src/archive/archive_instance.cc
+++ b/src/archive/archive_instance.cc
@@ -24,7 +24,7 @@
#include "common/current_application.h"
#include "common/picojson.h"
#include "common/logger.h"
-#include "common/filesystem/filesystem_provider_storage.h"
+#include "common/filesystem/filesystem_provider.h"
#include "common/tools.h"
#include "archive_callback_data.h"
#include "archive_manager.h"
@@ -620,7 +620,7 @@ void ArchiveInstance::FetchVirtualRoots(const picojson::value& args, picojson::o
LoggerD("Entered");
picojson::array roots;
- for (const auto& root : common::FilesystemProviderStorage::Create().GetVirtualPaths() ) {
+ for (const auto& root : common::FilesystemProvider::Create().GetVirtualPaths() ) {
roots.push_back(root.ToJson());
}
ReportSuccess(picojson::value(roots), out);
diff --git a/src/common/common.gyp b/src/common/common.gyp
index bba10751..e93b7cbd 100644
--- a/src/common/common.gyp
+++ b/src/common/common.gyp
@@ -49,6 +49,8 @@
'filesystem/filesystem_storage_types.h',
'filesystem/filesystem_storage.h',
'filesystem/filesystem_storage.cc',
+ 'filesystem/filesystem_provider.h',
+ 'filesystem/filesystem_provider.cc',
'filesystem/filesystem_provider_storage.h',
'filesystem/filesystem_provider_storage.cc',
],
@@ -56,6 +58,12 @@
'-fvisibility=default',
],
'conditions': [
+ ['extension_host_os == "tv"', {
+ 'sources': [
+ 'filesystem/filesystem_provider_deviced.h',
+ 'filesystem/filesystem_provider_deviced.cc',
+ ]
+ }],
['tizen == 1', {
'variables': {
'packages': [
diff --git a/src/common/filesystem/filesystem_provider.cc b/src/common/filesystem/filesystem_provider.cc
new file mode 100644
index 00000000..f2a69e7e
--- /dev/null
+++ b/src/common/filesystem/filesystem_provider.cc
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "common/filesystem/filesystem_provider.h"
+#ifdef TIZEN_TV
+#include "common/filesystem/filesystem_provider_deviced.h"
+#endif
+#include "common/filesystem/filesystem_provider_storage.h"
+
+namespace common {
+
+IFilesystemProvider::IFilesystemProvider() {
+ LoggerD("enter");
+
+}
+
+IFilesystemProvider::~IFilesystemProvider() {
+ LoggerD("enter");
+}
+
+
+FilesystemProvider::FilesystemProvider() :
+#ifdef TIZEN_TV
+ provider_ (FilesystemProviderDeviced::Create())
+#else
+ provider_ (FilesystemProviderStorage::Create())
+#endif
+{
+}
+
+FilesystemProvider& FilesystemProvider::Create() {
+ LoggerD("Entered");
+ static FilesystemProvider instance;
+ return instance;
+}
+
+FilesystemProvider::~FilesystemProvider() {
+ LoggerD("Entered");
+}
+
+void FilesystemProvider::RegisterDeviceChangeState(
+ DeviceChangeStateFun callback) {
+ LoggerD("Entered");
+ provider_.RegisterDeviceChangeState(callback);
+}
+
+void FilesystemProvider::UnregisterDeviceChangeState() {
+ LoggerD("Entered");
+ provider_.UnregisterDeviceChangeState();
+}
+
+Storages FilesystemProvider::GetStorages() {
+ LoggerD("Entered");
+ return provider_.GetStorages();
+}
+
+VirtualRoots FilesystemProvider::GetVirtualPaths() {
+ LoggerD("Entered");
+ return provider_.GetVirtualPaths();
+}
+
+VirtualStorages FilesystemProvider::GetAllStorages() {
+ LoggerD("Entered");
+ return provider_.GetAllStorages();
+}
+
+std::shared_ptr< Storage > FilesystemProvider::GetInternalStorage(){
+ LoggerD("Entered");
+ return provider_.GetInternalStorage();
+}
+
+std::string FilesystemProvider::GetRealPath(
+ const std::string& path_or_uri) {
+ LoggerD("Entered");
+ return FilesystemProviderStorage::Create().GetRealPath(path_or_uri);
+}
+
+std::string FilesystemProvider::GetVirtualPath(
+ const std::string& real_path) const {
+ LoggerD("Entered");
+ return FilesystemProviderStorage::Create().GetVirtualPath(real_path);
+}
+
+} // namespace common
diff --git a/src/common/filesystem/filesystem_provider.h b/src/common/filesystem/filesystem_provider.h
new file mode 100644
index 00000000..69030d51
--- /dev/null
+++ b/src/common/filesystem/filesystem_provider.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COMMON_FILESYSTEM_FILESYSTEM_PROVIDER_H_
+#define COMMON_FILESYSTEM_FILESYSTEM_PROVIDER_H_
+
+#include
+#include
+#include
+#include "common/filesystem/filesystem_storage.h"
+#include "common/filesystem/filesystem_provider_types.h"
+
+namespace common {
+
+class IFilesystemProvider {
+ public:
+ IFilesystemProvider();
+ virtual ~IFilesystemProvider();
+
+ virtual void RegisterDeviceChangeState(DeviceChangeStateFun _callback) = 0;
+ virtual void UnregisterDeviceChangeState() = 0;
+
+ virtual Storages GetStorages() = 0;
+ virtual VirtualRoots GetVirtualPaths() = 0;
+ virtual VirtualStorages GetAllStorages() = 0;
+ virtual std::shared_ptr GetInternalStorage() = 0;
+};
+
+typedef IFilesystemProvider& FilesystemProviderRef;
+
+class FilesystemProvider {
+ public:
+ static FilesystemProvider& Create();
+ virtual ~FilesystemProvider();
+
+ void RegisterDeviceChangeState(DeviceChangeStateFun _callback);
+ void UnregisterDeviceChangeState();
+
+ Storages GetStorages();
+ VirtualRoots GetVirtualPaths();
+ VirtualStorages GetAllStorages();
+ std::shared_ptr GetInternalStorage();
+
+ std::string GetRealPath(const std::string& path_or_uri);
+ std::string GetVirtualPath(const std::string& real_path) const;
+ private:
+ FilesystemProvider();
+ FilesystemProvider(const FilesystemProvider&) = delete;
+ FilesystemProvider& operator=(const FilesystemProvider&) = delete;
+ FilesystemProvider(FilesystemProvider&&) = delete;
+ FilesystemProvider& operator=(FilesystemProvider&&) = delete;
+ FilesystemProviderRef provider_;
+};
+
+} // namespace common
+
+#endif // COMMON_FILESYSTEM_FILESYSTEM_PROVIDER_H_
diff --git a/src/common/filesystem/filesystem_provider_deviced.cc b/src/common/filesystem/filesystem_provider_deviced.cc
new file mode 100644
index 00000000..ac08abc1
--- /dev/null
+++ b/src/common/filesystem/filesystem_provider_deviced.cc
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "common/filesystem/filesystem_provider_deviced.h"
+
+#include
+#include
+#include
+#include