#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"
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);
'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',
],
'-fvisibility=default',
],
'conditions': [
+ ['extension_host_os == "tv"', {
+ 'sources': [
+ 'filesystem/filesystem_provider_deviced.h',
+ 'filesystem/filesystem_provider_deviced.cc',
+ ]
+ }],
['tizen == 1', {
'variables': {
'packages': [
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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 <functional>
+#include <vector>
+#include <memory>
+#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<Storage> 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<Storage> 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_
--- /dev/null
+/*
+ * 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 <gio/gio.h>
+#include <functional>
+#include <list>
+#include <map>
+#include <algorithm>
+#include <memory>
+#include <utility>
+
+#include "common/filesystem/filesystem_storage.h"
+#include "common/logger.h"
+
+namespace {
+static const char* kIface = "org.tizen.system.deviced.BlockManager";
+static const char* kPath = "/Org/Tizen/System/DeviceD/Block/Manager";
+} // namespace
+
+namespace common {
+
+struct DeviceListElem {
+ DeviceListElem()
+ : block_type(0),
+ devnode(nullptr),
+ syspath(nullptr),
+ fs_usage(nullptr),
+ fs_type(nullptr),
+ fs_version(nullptr),
+ fs_uuid_enc(nullptr),
+ readonly(0),
+ mount_point(nullptr),
+ state(0),
+ primary(false) {}
+
+ int block_type;
+ char* devnode;
+ char* syspath;
+ char* fs_usage;
+ char* fs_type;
+ char* fs_version;
+ char* fs_uuid_enc;
+ int readonly;
+ char* mount_point;
+ int state;
+ bool primary;
+};
+
+FilesystemProviderDeviced::~FilesystemProviderDeviced() {
+ LoggerD("Entered");
+ UnregisterDeviceChangeState();
+}
+
+FilesystemProviderDeviced::FilesystemProviderDeviced() :
+ dbus_(nullptr),
+ proxy_(nullptr),
+ device_changed_callback_(nullptr),
+ block_signal_subscribe_id_(0),
+ virtual_roots_provider_(FilesystemProviderStorage::Create()),
+ is_initialized_(false) {
+ LoggerD("Entered");
+
+ GError* error = nullptr;
+
+ dbus_ = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error);
+ if (error != NULL) {
+ LoggerE("Could not get dbus connection: %s", error->message);
+ } else {
+ if (!dbus_) {
+ LoggerE("Dbus handle is null");
+ } else {
+ LoggerE("Dbus connection set");
+ const gchar* unique_name = g_dbus_connection_get_unique_name(dbus_);
+ proxy_ = g_dbus_proxy_new_sync(dbus_, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ nullptr, unique_name, kPath, kIface, nullptr,
+ &error);
+ if (!proxy_ || error) {
+ LoggerE("Could not get dbus proxy. %s", error->message);
+ } else {
+ is_initialized_ = true;
+ }
+ }
+ }
+}
+
+FilesystemProviderDeviced& FilesystemProviderDeviced::Create() {
+ LoggerD("Entered");
+
+ static FilesystemProviderDeviced instance;
+
+ return instance;
+}
+
+void FilesystemProviderDeviced::BlockSignalProxy(
+ GDBusConnection* connection, const gchar* sender_name,
+ const gchar* object_path, const gchar* interface_name,
+ const gchar* signal_name, GVariant* parameters, gpointer user_data) {
+ LoggerD("Entered");
+
+ FilesystemProviderDeviced* instance =
+ static_cast<FilesystemProviderDeviced*>(user_data);
+ DeviceListElem elem;
+ g_variant_get(parameters, "(issssssisib)", &elem.block_type, &elem.devnode,
+ &elem.syspath, &elem.fs_usage, &elem.fs_type, &elem.fs_version,
+ &elem.fs_uuid_enc, &elem.readonly, &elem.mount_point,
+ &elem.state, &elem.primary);
+ instance->BlockSignalCallback(elem);
+}
+
+void FilesystemProviderDeviced::BlockSignalCallback(DeviceListElem elem) {
+ LoggerD("Entered");
+ StorageState previous_state = StorageState::kUnmounted;
+ auto it = previous_device_state_map_.find(elem.syspath);
+ if (it == previous_device_state_map_.end()) {
+ previous_device_state_map_[elem.syspath] = previous_state =
+ (elem.state ? StorageState::kMounted : StorageState::kUnmounted);
+ } else {
+ previous_state = it->second;
+ }
+ if (device_changed_callback_ != nullptr) {
+ std::shared_ptr<Storage> storage = GetStorage(elem);
+ device_changed_callback_(*storage, previous_state, storage->state_);
+ }
+}
+
+void FilesystemProviderDeviced::RegisterDeviceChangeState(
+ DeviceChangeStateFun _callback) {
+ LoggerD("Entered");
+
+ if(!is_initialized_) {
+ LoggerE("DeviceD Core api not initialized");
+ return;
+ }
+
+ if (device_changed_callback_ == nullptr) {
+ LoggerD("Registering dbus signal subscription");
+ block_signal_subscribe_id_ = g_dbus_connection_signal_subscribe(
+ dbus_, nullptr, "org.tizen.system.deviced.Block", "DeviceChanged",
+ nullptr, nullptr, G_DBUS_SIGNAL_FLAGS_NONE, BlockSignalProxy, this,
+ nullptr);
+ }
+ device_changed_callback_ = _callback;
+}
+
+void FilesystemProviderDeviced::UnregisterDeviceChangeState() {
+ LoggerD("Entered");
+
+ if(!is_initialized_) {
+ LoggerE("DeviceD Core api not initialized");
+ return;
+ }
+
+ if (0 != block_signal_subscribe_id_) {
+ LoggerD("Dbus signal handling unsubscription");
+ g_dbus_connection_signal_unsubscribe (dbus_, block_signal_subscribe_id_);
+ }
+ device_changed_callback_ = nullptr;
+}
+
+std::shared_ptr<Storage> FilesystemProviderDeviced::GetInternalStorage() {
+ return virtual_roots_provider_.GetInternalStorage();
+}
+
+std::shared_ptr<Storage> FilesystemProviderDeviced::GetStorage(const DeviceListElem& elem) {
+ LoggerD("Entered");
+ return std::make_shared<Storage>(Storage(GetIdFromUUID(elem.fs_uuid_enc), StorageType::kExternal,
+ (elem.state ? StorageState::kMounted : StorageState::kUnmounted),
+ elem.syspath, GetNameFromPath(elem.devnode)));
+}
+
+std::string FilesystemProviderDeviced::GetNameFromPath(
+ const char* const char_path) {
+ LoggerD("Entered");
+ std::string path = char_path;
+ std::string name = "removable_";
+ std::size_t last_slash_pos = path.find_last_of("/");
+ if (last_slash_pos + 1 >= path.size()) {
+ name += path;
+ LoggerW("Failed to get device name from device syspath");
+ } else {
+ name += path.substr(last_slash_pos + 1);
+ }
+ return name;
+}
+
+int FilesystemProviderDeviced::GetIdFromUUID(const char* const char_uuid) {
+ LoggerD("Entered");
+ std::string uuid = char_uuid;
+ size_t hyphen = uuid.find("-");
+ std::string clear_uuid = uuid.substr(0, hyphen) + uuid.substr(hyphen + 1);
+ return static_cast<int>(std::stoul(clear_uuid, 0, 16));
+}
+
+Storages FilesystemProviderDeviced::GetStorages() {
+ LoggerD("Entered");
+
+ if(!is_initialized_) {
+ LoggerE("DeviceD Core api not initialized");
+ return Storages();
+ }
+
+ GError* error = nullptr;
+ GVariant* variant = g_dbus_proxy_call_sync(
+ proxy_, "GetDeviceList", g_variant_new("(s)", "all"),
+ G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &error);
+ if (!variant || error) {
+ LoggerE("Failed to call GetDeviceList method - %s", error->message);
+ return Storages();
+ }
+ LoggerD("GetDeviceList called");
+ return GetStoragesFromGVariant(variant);
+}
+
+Storages FilesystemProviderDeviced::GetStoragesFromGVariant(GVariant* variant) {
+ LoggerD("Entered");
+ Storages storages;
+ GVariantIter iter;
+ GVariant* tuple = nullptr;
+ g_variant_iter_init(&iter, variant);
+ while ((tuple = g_variant_iter_next_value(&iter))) {
+ DeviceListElem elem;
+ g_variant_get(tuple, "(issssssisib)", &elem.block_type, &elem.devnode,
+ &elem.syspath, &elem.fs_usage, &elem.fs_type,
+ &elem.fs_version, &elem.fs_uuid_enc, &elem.readonly,
+ &elem.mount_point, &elem.state, &elem.primary);
+ storages.push_back(GetStorage(elem));
+ g_variant_unref(tuple);
+ }
+ return storages;
+}
+
+VirtualRoots FilesystemProviderDeviced::GetVirtualPaths() {
+ LoggerD("Entered");
+
+ if(!is_initialized_) {
+ LoggerE("DeviceD Core api not initialized");
+ return VirtualRoots();
+ }
+
+ return virtual_roots_provider_.GetVirtualPaths();
+}
+
+VirtualStorages FilesystemProviderDeviced::GetAllStorages() {
+ LoggerD("Entered");
+
+ if(!is_initialized_) {
+ LoggerE("DeviceD Core api not initialized");
+ return VirtualStorages();
+ }
+
+ std::lock_guard<std::mutex> lock(mutex_);
+ VirtualStorages vs;
+ for (auto storage : GetStorages()) {
+ vs.push_back(storage);
+ }
+
+ for (auto virtual_root : virtual_roots_provider_.GetVirtualPaths()) {
+ vs.push_back(std::make_shared<VirtualRoot>(virtual_root));
+ }
+
+ return vs;
+}
+
+} // namespace common
--- /dev/null
+/*
+ * 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_PROVIDER_DEVICED_H
+#define COMMON_FILESYSTEM_PROVIDER_DEVICED_H
+
+#include <gio/gio.h>
+
+#include <functional>
+#include <list>
+#include <string>
+#include <map>
+#include <memory>
+#include <mutex>
+
+#include "common/filesystem/filesystem_storage.h"
+#include "common/filesystem/filesystem_provider.h"
+#include "common/filesystem/filesystem_provider_storage.h"
+
+namespace common {
+
+struct DeviceListElem;
+
+class FilesystemProviderDeviced : public IFilesystemProvider {
+ public:
+
+ virtual ~FilesystemProviderDeviced();
+ virtual void RegisterDeviceChangeState(DeviceChangeStateFun _callback);
+ virtual void UnregisterDeviceChangeState();
+ virtual VirtualRoots GetVirtualPaths();
+ virtual Storages GetStorages();
+ virtual VirtualStorages GetAllStorages();
+ virtual std::shared_ptr< Storage > GetInternalStorage();
+ static FilesystemProviderDeviced& Create();
+
+ private:
+ FilesystemProviderDeviced();
+
+ static void BlockSignalProxy(GDBusConnection* connection,
+ const gchar* sender_name, const gchar* object_path,
+ const gchar* interface_name,
+ const gchar* signal_name, GVariant* parameters,
+ gpointer user_data);
+ void BlockSignalCallback(DeviceListElem elem);
+
+ static std::string GetNameFromPath(const char* const char_path);
+ static int GetIdFromUUID(const char* const char_uuid);
+ static std::shared_ptr<Storage> GetStorage(const DeviceListElem& elem);
+ static Storages GetStoragesFromGVariant(GVariant* variant);
+ GDBusConnection* dbus_;
+ GDBusProxy* proxy_;
+
+ DeviceChangeStateFun device_changed_callback_;
+ guint block_signal_subscribe_id_;
+ std::map<std::string, StorageState> previous_device_state_map_;
+ FilesystemProviderRef virtual_roots_provider_;
+ std::mutex mutex_;
+
+ bool is_initialized_;
+};
+
+} // namespace common
+
+#endif /* DEVICED_H */
const std::string kVirtualRootWgtPackage = "wgt-package";
const std::string kVirtualRootWgtPrivate = "wgt-private";
const std::string kVirtualRootWgtPrivateTmp = "wgt-private-tmp";
+const std::string kVirtualRootMedia = "internal0";
const std::map<storage_directory_e, const std::string*> kStorageDirectories = {
{ STORAGE_DIRECTORY_CAMERA, &kVirtualRootCamera }, {
StorageState TranslateCoreStorageState(
storage_state_e coreStorageState) {
+ LoggerD("Entered");
StorageState state = StorageState::kUnknown;
if (coreStorageState == STORAGE_STATE_REMOVED) {
state = StorageState::kUnmounted;
FilesystemProviderStorage* provider =
static_cast<FilesystemProviderStorage*>(user_data);
for (auto &storage : provider->GetStorages()) {
- if (storage.id_ == storage_id) {
- StorageState previous_state = storage.state_;
- storage.state_ = TranslateCoreStorageState(state);
+ if (storage->id_ == storage_id) {
+ StorageState previous_state = storage->state_;
+ storage->state_ = TranslateCoreStorageState(state);
if (provider->GetListener()) {
- provider->GetListener()(storage, previous_state, storage.state_);
+ provider->GetListener()(*storage, previous_state, storage->state_);
}
break;
}
StorageType::kInternal : StorageType::kExternal;
provider->GetStorages().push_back(
- Storage(storage_id, type_, TranslateCoreStorageState(state), path));
+ std::make_shared<Storage>(storage_id, type_, TranslateCoreStorageState(state), path));
if (type_ == StorageType::kInternal) {
+ // TODO check internal storage
+ //provider->internal_storage_ = std::make_shared<Storage>(Storage(storage_id, type_, state_, path, kVirtualRootMedia));
// if internal storage is supported, we can add also virtual paths:
// downloads, documents etc
provider->FillVirtualPaths(storage_id);
return listener_;
}
-FilesystemProviderStorage::FilesystemProviderStorage() {
+FilesystemProviderStorage::FilesystemProviderStorage() :
+ internal_storage_(nullptr) {
LoggerD("Entered");
int err = storage_foreach_device_supported(OnForeachStorage, this);
if (err != STORAGE_ERROR_NONE) {
}
FilesystemProviderStorage& FilesystemProviderStorage::Create() {
+ LoggerD("Entered");
static FilesystemProviderStorage fs;
return fs;
}
FilesystemProviderStorage::~FilesystemProviderStorage() {
+ LoggerD("Entered");
}
void FilesystemProviderStorage::FillVirtualPaths(int storage_id) {
}
Storages FilesystemProviderStorage::GetStorages() {
+ LoggerD("Entered");
return storages_;
}
VirtualRoots FilesystemProviderStorage::GetVirtualPaths() {
+ LoggerD("Entered");
return virtual_paths_;
}
return realpath;
}
+std::shared_ptr< Storage > FilesystemProviderStorage::GetInternalStorage(){
+ LoggerD("Entered");
+ return internal_storage_;
+}
+
std::string FilesystemProviderStorage::GetVirtualPath(
const std::string& real_path) const {
LoggerD("Enter");
}
VirtualStorages FilesystemProviderStorage::GetAllStorages() {
+ LoggerD("Entered");
VirtualStorages vs;
for (auto storage : storages_) {
- vs.push_back(std::make_shared < Storage > (storage));
+ vs.push_back(storage);
}
for (auto virtualRoot : virtual_paths_) {
#include <string>
#include <memory>
#include "common/filesystem/filesystem_provider_types.h"
+#include "common/filesystem/filesystem_provider.h"
namespace common {
-class FilesystemProviderStorage {
+class FilesystemProviderStorage : public IFilesystemProvider {
public:
static FilesystemProviderStorage& Create();
virtual ~FilesystemProviderStorage();
virtual Storages GetStorages();
virtual VirtualRoots GetVirtualPaths();
virtual VirtualStorages GetAllStorages();
+ virtual std::shared_ptr< Storage > GetInternalStorage();
std::string GetRealPath(const std::string& path_or_uri);
std::string GetVirtualPath(const std::string& real_path) const;
DeviceChangeStateFun listener_;
Storages storages_;
VirtualRoots virtual_paths_;
+ std::shared_ptr<Storage> internal_storage_;
};
} // namespace common
typedef std::function<
void(common::Storage, common::StorageState,
common::StorageState)> DeviceChangeStateFun;
-typedef std::vector<common::Storage> Storages;
+typedef std::vector<std::shared_ptr<common::Storage> > Storages;
typedef std::vector<common::VirtualRoot> VirtualRoots;
typedef std::vector<std::shared_ptr<common::VirtualStorage> > VirtualStorages;
-
} // namespace common
-#endif // COMMON_FILESYSTEM_FILESYSTEM_PROVIDER_TYPES_H_
\ No newline at end of file
+#endif // COMMON_FILESYSTEM_FILESYSTEM_PROVIDER_TYPES_H_
path_(path),
type_(type),
state_(state) {
+ LoggerD("Entered");
}
Storage::Storage(int id, StorageType type, StorageState state,
}
picojson::value VirtualRoot::ToJson() const {
+ LoggerD("Entered");
picojson::value v { picojson::object { } };
picojson::object& obj = v.get<picojson::object>();
}
picojson::value Storage::ToJson() const {
+ LoggerD("Entered");
picojson::value value = VirtualRoot::ToJson();
picojson::object& obj = value.get<picojson::object>();
obj["storage_id"] = picojson::value(static_cast<double>(id_));
Storage::Storage(Storage const& other)
: VirtualRoot(other) {
+ LoggerD("Entered");
this->id_ = other.id_;
}
VirtualRoot::VirtualRoot(VirtualRoot const& other) {
+ LoggerD("Entered");
this->path_ = other.path_;
this->name_ = other.name_;
this->state_ = other.state_;
}
std::string VirtualRoot::ToString(StorageType type) {
+ LoggerD("Entered");
switch (type) {
case StorageType::kInternal:
return "INTERNAL";
}
std::string VirtualRoot::ToString(StorageState state) {
+ LoggerD("Entered");
switch (state) {
case StorageState::kUnmounted:
return "REMOVED";
#include "common/tools.h"
#include "content/content_manager.h"
-#include "common/filesystem/filesystem_provider_storage.h"
+#include "common/filesystem/filesystem_provider.h"
namespace extension {
namespace content {
}
case ContentManagerScanfileCallback: {
std::string contentURI = user_data->args.get("contentURI").get<std::string>();
- std::string real_path = common::FilesystemProviderStorage::Create().GetRealPath(contentURI);
+ std::string real_path = common::FilesystemProvider::Create().GetRealPath(contentURI);
ret = ContentManager::getInstance()->scanFile(real_path);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
PlatformResult err = LogAndCreateResult(
#include "common/logger.h"
#include "common/scope_exit.h"
#include "common/tools.h"
-#include "common/filesystem/filesystem_provider_storage.h"
+#include "common/filesystem/filesystem_provider.h"
#include "content/content_filter.h"
PlatformResult ContentManager::scanDirectory(media_scan_completed_cb callback, ReplyCallbackData* cbData) {
LoggerD("Enter");
const std::string& contentDirURI = cbData->args.get("contentDirURI").get<std::string>();
- std::string real_path = common::FilesystemProviderStorage::Create().GetRealPath(contentDirURI);
+ std::string real_path = common::FilesystemProvider::Create().GetRealPath(contentDirURI);
const bool recursive = cbData->args.get("recursive").get<bool>();
int ret = media_content_scan_folder(real_path.c_str(), recursive, callback, (void*) cbData);
media_playlist_h playlist_handle = getPlaylistHandle(id);
PlaylistUniquePtr playlist_ptr(playlist_handle, destroyMediaPlaylistHandle);
- std::string real_path = common::FilesystemProviderStorage::Create().GetRealPath(thb_uri);
+ std::string real_path = common::FilesystemProvider::Create().GetRealPath(thb_uri);
const int ret_code = media_playlist_set_thumbnail_path(playlist_handle,
real_path.c_str());
if(MEDIA_CONTENT_ERROR_NONE != ret_code) {
#include "common/picojson.h"
#include "common/logger.h"
#include "common/typeutil.h"
-#include "common/filesystem/filesystem_provider_storage.h"
+#include "common/filesystem/filesystem_provider.h"
namespace extension {
namespace download {
out["callbackId"] = picojson::value(static_cast<double>(callback_id));
- out["fullPath"] = picojson::value(common::FilesystemProviderStorage::Create().GetVirtualPath(fullPath));
+ out["fullPath"] = picojson::value(common::FilesystemProvider::Create().GetVirtualPath(fullPath));
Instance::PostMessage(downCbPtr->instance, picojson::value(out).serialize().c_str());
downCbPtr->instance->download_callbacks.erase(callback_id);
if (!args.get("destination").is<picojson::null>()) {
if (args.get("destination").get<std::string>() != "") {
diPtr->destination = args.get("destination").get<std::string>();
- diPtr->destination = common::FilesystemProviderStorage::Create().GetRealPath(diPtr->destination);
+ diPtr->destination = common::FilesystemProvider::Create().GetRealPath(diPtr->destination);
}
}
picojson::object& out) {
LoggerD("enter");
- auto onSuccess = [&](const std::vector<common::Storage>& result) {
+ auto onSuccess = [&](const common::Storages& result) {
LoggerD("enter");
picojson::array storages;
storages.reserve(result.size());
- for (const auto& storage : result) {
- storages.push_back(storage.ToJson());
+ for (const auto storage : result) {
+ storages.push_back(storage->ToJson());
}
ReportSuccess(picojson::value(storages), out);
};
FilesystemManager::FilesystemManager()
: listener_(nullptr),
- fs_provider_(common::FilesystemProviderStorage::Create()) {
+ fs_provider_(common::FilesystemProvider::Create()) {
+ LoggerD("enter");
}
FilesystemManager::~FilesystemManager() {
#include <set>
#include <memory>
-#include "common/filesystem/filesystem_provider_storage.h"
-
#include "filesystem/filesystem_stat.h"
#include "filesystem/filesystem_utils.h"
#include "common/filesystem/filesystem_storage.h"
-#include "common/filesystem/filesystem_provider_storage.h"
+#include "common/filesystem/filesystem_provider.h"
namespace extension {
namespace filesystem {
FilesystemManager();
FilesystemStateChangeListener* listener_;
- common::FilesystemProviderStorage& fs_provider_;
+ common::FilesystemProvider& fs_provider_;
public:
#include "message_mms.h"
#include "short_message_manager.h"
#include "messaging_util.h"
-#include "common/filesystem/filesystem_provider_storage.h"
+#include "common/filesystem/filesystem_provider.h"
using common::ErrorCode;
using common::PlatformResult;
std::string dirPath = "/tmp/" + std::string(buf);
if ( sourcePath[0] != '/' ) {
- attPath = common::FilesystemProviderStorage::Create().GetRealPath(sourcePath);
+ attPath = common::FilesystemProvider::Create().GetRealPath(sourcePath);
} else { // Assuming that the path is a real path
attPath = sourcePath;
}
if (attach.at(i)->isFilePathSet()) {
std::string filepath = attach.at(i)->getFilePath();
LoggerD("att[%d]: org filepath: %s", i, filepath.c_str());
- filepath = common::FilesystemProviderStorage::Create().GetRealPath(filepath);
+ filepath = common::FilesystemProvider::Create().GetRealPath(filepath);
LoggerD("att[%d]: org virtual filepath: %s", i, filepath.c_str());
msg_set_str_value(tmpAtt, MSG_MMS_ATTACH_FILEPATH_STR,
#include "message_attachment.h"
#include "common/logger.h"
-#include "common/filesystem/filesystem_provider_storage.h"
+#include "common/filesystem/filesystem_provider.h"
namespace extension {
namespace messaging {
{
LoggerD("Entered");
- m_filePath = common::FilesystemProviderStorage::Create().GetRealPath(value);
+ m_filePath = common::FilesystemProvider::Create().GetRealPath(value);
m_isFilePathSet = true;
}
#include "common/converter.h"
#include "common/logger.h"
#include "common/scope_exit.h"
-#include "common/filesystem/filesystem_provider_storage.h"
+#include "common/filesystem/filesystem_provider.h"
namespace extension {
namespace notification {
break;
//CHECK GetVirtualPath ??
- out->push_back(picojson::value(common::FilesystemProviderStorage::Create().GetVirtualPath(text)));
+ out->push_back(picojson::value(common::FilesystemProvider::Create().GetVirtualPath(text)));
}
return PlatformResult(ErrorCode::NO_ERROR);
size_t thumbnails_map_size = thumbnails_map_.size();
for (auto& item : value) {
const std::string& text = JsonCast<std::string>(item);
- std::string real_path = common::FilesystemProviderStorage::Create().GetRealPath(text);
+ std::string real_path = common::FilesystemProvider::Create().GetRealPath(text);
PlatformResult status =
SetImage(noti_handle, thumbnails_map_.at(idx), real_path);
if (status.IsError())
return status;
if (value_str.length()) {
- out["iconPath"] = picojson::value(common::FilesystemProviderStorage::Create().GetVirtualPath(value_str));
+ out["iconPath"] = picojson::value(common::FilesystemProvider::Create().GetVirtualPath(value_str));
}
status = GetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_SUB, &value_str);
if (status.IsError())
return status;
if (value_str.length()) {
- out["subIconPath"] = picojson::value(common::FilesystemProviderStorage::Create().GetVirtualPath(value_str));
+ out["subIconPath"] = picojson::value(common::FilesystemProvider::Create().GetVirtualPath(value_str));
}
long number;
if (status.IsError())
return status;
if (value_str.length()) {
- out["backgroundImagePath"] = picojson::value(common::FilesystemProviderStorage::Create().GetVirtualPath(value_str));
+ out["backgroundImagePath"] = picojson::value(common::FilesystemProvider::Create().GetVirtualPath(value_str));
}
picojson::array thumbnails = picojson::array();
if (status.IsError())
return status;
if (value_str.length()) {
- out["soundPath"] = picojson::value(common::FilesystemProviderStorage::Create().GetVirtualPath(value_str));
+ out["soundPath"] = picojson::value(common::FilesystemProvider::Create().GetVirtualPath(value_str));
}
bool vibration;
picojson::value val(noti_obj);
if (val.contains("iconPath") && !IsNull(noti_obj, "iconPath")) {
const std::string& value_str = common::FromJson<std::string>(noti_obj, "iconPath");
- std::string real_path = common::FilesystemProviderStorage::Create().GetRealPath(value_str);
+ std::string real_path = common::FilesystemProvider::Create().GetRealPath(value_str);
status = SetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON, real_path);
if (status.IsError()) {
if (val.contains("subIconPath") && !IsNull(noti_obj, "subIconPath")) {
const std::string& value_str =
common::FromJson<std::string>(noti_obj, "subIconPath");
- std::string real_path = common::FilesystemProviderStorage::Create().GetRealPath(value_str);
+ std::string real_path = common::FilesystemProvider::Create().GetRealPath(value_str);
status = SetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_ICON_SUB, real_path);
if (status.IsError()) {
if (val.contains("backgroundImagePath")
&& !IsNull(noti_obj, "backgroundImagePath")) {
const std::string& value_str = common::FromJson<std::string>(noti_obj, "backgroundImagePath");
- std::string real_path = common::FilesystemProviderStorage::Create().GetRealPath(value_str);
+ std::string real_path = common::FilesystemProvider::Create().GetRealPath(value_str);
status = SetImage(noti_handle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, real_path);
if (status.IsError()) {
if (val.contains("soundPath") && !IsNull(noti_obj, "soundPath")) {
const std::string& value_str = common::FromJson<std::string>(noti_obj, "soundPath");
- std::string real_path = common::FilesystemProviderStorage::Create().GetRealPath(value_str);
+ std::string real_path = common::FilesystemProvider::Create().GetRealPath(value_str);
status = SetSoundPath(noti_handle, real_path);
if (status.IsError()) {
#include "common/logger.h"
#include "common/picojson.h"
#include "common/task-queue.h"
-#include "common/filesystem/filesystem_provider_storage.h"
+#include "common/filesystem/filesystem_provider.h"
#include "common/tools.h"
#include <system_settings.h>
auto get = [this, type, value, callback_id](const std::shared_ptr<picojson::value>& response) -> void {
LoggerD("Setting platform value");
- std::string real_path = common::FilesystemProviderStorage::Create().GetRealPath(value);
+ std::string real_path = common::FilesystemProvider::Create().GetRealPath(value);
PlatformResult status = setPlatformPropertyValue(type, real_path);
picojson::object& obj = response->get<picojson::object>();
if (status.IsSuccess()) {