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");
virtual Storages GetStorages() = 0;
virtual VirtualRoots GetVirtualPaths() = 0;
virtual VirtualStorages GetAllStorages() = 0;
- virtual std::shared_ptr<Storage> GetInternalStorage() = 0;
};
typedef IFilesystemProvider& FilesystemProviderRef;
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;
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>(GetIdFromUUID(elem.fs_uuid_enc),
Storages FilesystemProviderDeviced::GetStorages() {
LoggerD("Entered");
-
if(!is_initialized_) {
LoggerE("DeviceD Core api not initialized");
return Storages();
LoggerE("Failed to call GetDeviceList method - %s", message.c_str());
return Storages();
}
- return GetStoragesFromGVariant(variant);
+ // internal storages are gathered with storage api
+ Storages internal = virtual_roots_provider_.GetStorages();
+ // external storages are gathered using deviced implementation
+ Storages result = GetStoragesFromGVariant(variant);
+
+ // merging internal and external results together, but internal on the beginning
+ result.insert(result.begin(), internal.begin(), internal.end());
+ return result;
}
Storages FilesystemProviderDeviced::GetStoragesFromGVariant(GVariant* variant) {
virtual VirtualRoots GetVirtualPaths();
virtual Storages GetStorages();
virtual VirtualStorages GetAllStorages();
- virtual std::shared_ptr< Storage > GetInternalStorage();
static FilesystemProviderDeviced& Create();
private:
FilesystemProviderStorage* provider =
static_cast<FilesystemProviderStorage*>(user_data);
- int err = storage_set_state_changed_cb(storage_id, OnStorageChange, provider);
- if (STORAGE_ERROR_NONE != err) {
- LoggerW("Failed to add listener");
- }
-
- StorageType type_ =
- type == STORAGE_TYPE_INTERNAL ?
- StorageType::kInternal : StorageType::kMmc;
-
- provider->AddStorage(
- 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
+ // handling only internal storages (external are handled with deviced api)
+ if (STORAGE_TYPE_INTERNAL == type) {
+ provider->AddStorage(
+ std::make_shared<Storage>(storage_id, StorageType::kInternal, TranslateCoreStorageState(state), path));
provider->FillVirtualPaths(storage_id);
}
return true;
return listener_;
}
-FilesystemProviderStorage::FilesystemProviderStorage() :
- internal_storage_(nullptr) {
+FilesystemProviderStorage::FilesystemProviderStorage() {
LoggerD("Entered");
int err = storage_foreach_device_supported(OnForeachStorage, this);
if (err != STORAGE_ERROR_NONE) {
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");
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
static std::string FromStorageTypeToStringType(common::StorageType type) {
switch(type) {
+ case common::StorageType::kInternal:
+ return kTypeInternal;
case common::StorageType::kUsbDevice:
return kTypeUsbDevice;
case common::StorageType::kUsbHost:
picojson::value result = picojson::value(picojson::array());
picojson::array& array = result.get<picojson::array>();
- // handling internal storage
- array.push_back(picojson::value(picojson::object()));
- picojson::object& internal_obj = array.back().get<picojson::object>();
-
- if (statfs(kStorageInternalPath.c_str(), &fs) < 0) {
- return LogAndCreateResult(
- ErrorCode::UNKNOWN_ERR, "There are no storage units detected");
- }
- CreateStorageInfo(kTypeInternal, fs, &internal_obj);
- manager_.SetAvailableCapacityInternal(fs.f_bavail);
-
- // handling external storages
+ // handling storages from provider
common::FilesystemProvider& provider(common::FilesystemProvider::Create());
auto storages = provider.GetStorages();
LoggerD("Storages found %d", storages.size());
array.push_back(picojson::value(picojson::object()));
picojson::object& external_obj = array.back().get<picojson::object>();
CreateStorageInfo(FromStorageTypeToStringType(storage->type()), fs, &external_obj);
-#ifdef TIZEN_TV
- // TODO some tracking of available capacity of usb storages should be applied
-#else
- // Only one storage would be tracked, if more than one SD card would be supported on device
- // different mechanism should be applied
- manager_.SetAvailableCapacityMmc(fs.f_bavail);
-#endif
+
+ //TODO change implementation to support all types of storages and not limited number
+ if (common::StorageType::kInternal == storage->type()) {
+ manager_.SetAvailableCapacityInternal(fs.f_bavail);
+ } else if (common::StorageType::kMmc == storage->type()) {
+ manager_.SetAvailableCapacityMmc(fs.f_bavail);
+ }
}
}