SFTP init.

This commit is contained in:
Junyuan Feng
2022-02-18 13:32:50 +08:00
parent 282e61afac
commit f07d33a1d6
7 changed files with 176 additions and 93 deletions

View File

@@ -15,7 +15,7 @@ class MenuItems {
static const List<MenuItem> secondItems = [edit];
static const ssh = MenuItem(text: 'SSH', icon: Icons.link);
static const sftp = MenuItem(text: 'SFTP', icon: Icons.file_present);
static const sftp = MenuItem(text: 'SFTP', icon: Icons.insert_drive_file);
static const snippet = MenuItem(text: 'Snippet', icon: Icons.label);
static const apt = MenuItem(text: 'Apt', icon: Icons.system_security_update);
static const edit = MenuItem(text: 'Edit', icon: Icons.edit);

View File

@@ -0,0 +1,29 @@
class AbsolutePath {
String path;
String? _prePath;
AbsolutePath(this.path);
void update(String newPath) {
_prePath = path;
if (newPath == '..') {
path = path.substring(0, path.lastIndexOf('/'));
if (path == '') {
path = '/';
}
return;
}
if (newPath == '/') {
path = '/';
return;
}
path = path + (path.endsWith('/') ? '' : '/') + newPath;
}
bool undo() {
if (_prePath == null) {
return false;
}
path = _prePath!;
return true;
}
}

View File

@@ -0,0 +1,39 @@
import 'package:dartssh2/dartssh2.dart';
import 'package:toolbox/data/model/server/server_private_info.dart';
import 'package:toolbox/data/model/sftp/absolute_path.dart';
class SFTPSideViewStatus {
bool leftSelected = false;
bool rightSelected = false;
ServerPrivateInfo? leftSpi;
ServerPrivateInfo? rightSpi;
List<SftpName>? leftFiles;
List<SftpName>? rightFiles;
AbsolutePath? leftPath;
AbsolutePath? rightPath;
SftpClient? leftClient;
SftpClient? rightClient;
SFTPSideViewStatus();
ServerPrivateInfo? spi(bool left) => left ? leftSpi : rightSpi;
void setSpi(bool left, ServerPrivateInfo nSpi) =>
left ? leftSpi = nSpi : rightSpi = nSpi;
/// Whether the Left/Right Destination is selected.
bool selected(bool left) => left ? leftSelected : rightSelected;
void setSelect(bool left, bool nSelect) =>
left ? leftSelected = nSelect : rightSelected = nSelect;
List<SftpName>? files(bool left) => left ? leftFiles : rightFiles;
void setFiles(bool left, List<SftpName>? nFiles) =>
left ? leftFiles = nFiles : rightFiles = nFiles;
AbsolutePath? path(bool left) => left ? leftPath : rightPath;
void setPath(bool left, AbsolutePath? nPath) =>
left ? leftPath = nPath : rightPath = nPath;
SftpClient? client(bool left) => left ? leftClient : rightClient;
void setClient(bool left, SftpClient? nClient) =>
left ? leftClient = nClient : rightClient = nClient;
}