2019-03-08 13:44:54 +01:00
|
|
|
/*
|
2020-08-17 16:17:20 +02:00
|
|
|
* SPDX-FileCopyrightText: 2018 Erik Duisters <e.duisters1@gmail.com>
|
2019-03-08 13:44:54 +01:00
|
|
|
*
|
2020-08-17 16:17:20 +02:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2019-03-08 13:44:54 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.kde.kdeconnect.Plugins.SftpPlugin;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
import org.apache.sshd.common.Session;
|
|
|
|
import org.apache.sshd.common.file.FileSystemFactory;
|
|
|
|
import org.apache.sshd.common.file.FileSystemView;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
class AndroidFileSystemFactory implements FileSystemFactory {
|
|
|
|
final private Context context;
|
|
|
|
final Map<String, String> roots;
|
|
|
|
|
|
|
|
AndroidFileSystemFactory(Context context) {
|
|
|
|
this.context = context;
|
|
|
|
this.roots = new HashMap<>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void initRoots(List<SftpPlugin.StorageInfo> storageInfoList) {
|
|
|
|
for (SftpPlugin.StorageInfo curStorageInfo : storageInfoList) {
|
|
|
|
if (curStorageInfo.isFileUri()) {
|
|
|
|
if (curStorageInfo.uri.getPath() != null){
|
|
|
|
roots.put(curStorageInfo.displayName, curStorageInfo.uri.getPath());
|
|
|
|
}
|
|
|
|
} else if (curStorageInfo.isContentUri()){
|
|
|
|
roots.put(curStorageInfo.displayName, curStorageInfo.uri.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FileSystemView createFileSystemView(final Session username) {
|
2023-03-05 16:15:03 +00:00
|
|
|
return new AndroidSafFileSystemView(roots, username.getUsername(), context);
|
2019-03-08 13:44:54 +01:00
|
|
|
}
|
|
|
|
}
|