mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Fixed default protocol not being loaded
This commit is contained in:
@@ -33,6 +33,7 @@ Released on FIXME: ??
|
|||||||
- Bugfix:
|
- Bugfix:
|
||||||
- Fixed wrong text wrap in log box
|
- Fixed wrong text wrap in log box
|
||||||
- Fixed error message not being shown after an upload failure
|
- Fixed error message not being shown after an upload failure
|
||||||
|
- Fixed default protocol not being loaded from config
|
||||||
- [Issue 23](https://github.com/veeso/termscp/issues/23): Remove created file if transfer failed or was abrupted
|
- [Issue 23](https://github.com/veeso/termscp/issues/23): Remove created file if transfer failed or was abrupted
|
||||||
- Dependencies:
|
- Dependencies:
|
||||||
- Added `tui-realm 0.2.2`
|
- Added `tui-realm 0.2.2`
|
||||||
|
|||||||
@@ -258,12 +258,7 @@ impl AuthActivity {
|
|||||||
}
|
}
|
||||||
if let Some(props) = self.view.get_props(super::COMPONENT_RADIO_PROTOCOL) {
|
if let Some(props) = self.view.get_props(super::COMPONENT_RADIO_PROTOCOL) {
|
||||||
let props = RadioPropsBuilder::from(props)
|
let props = RadioPropsBuilder::from(props)
|
||||||
.with_value(match protocol {
|
.with_value(Self::protocol_enum_to_opt(protocol))
|
||||||
FileTransferProtocol::Sftp => 0,
|
|
||||||
FileTransferProtocol::Scp => 1,
|
|
||||||
FileTransferProtocol::Ftp(false) => 2,
|
|
||||||
FileTransferProtocol::Ftp(true) => 3,
|
|
||||||
})
|
|
||||||
.build();
|
.build();
|
||||||
self.view.update(super::COMPONENT_RADIO_PROTOCOL, props);
|
self.view.update(super::COMPONENT_RADIO_PROTOCOL, props);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,17 @@ impl AuthActivity {
|
|||||||
.build(),
|
.build(),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
// Get default protocol
|
||||||
|
let default_protocol: FileTransferProtocol =
|
||||||
|
match self.context.as_ref().unwrap().config_client.as_ref() {
|
||||||
|
Some(cli) => cli.get_default_protocol(),
|
||||||
|
None => FileTransferProtocol::Sftp,
|
||||||
|
};
|
||||||
|
// Calc default port
|
||||||
|
let default_port: String = String::from(match default_protocol {
|
||||||
|
FileTransferProtocol::Ftp(_) => "21",
|
||||||
|
FileTransferProtocol::Sftp | FileTransferProtocol::Scp => "22",
|
||||||
|
});
|
||||||
// Port
|
// Port
|
||||||
self.view.mount(
|
self.view.mount(
|
||||||
super::COMPONENT_INPUT_PORT,
|
super::COMPONENT_INPUT_PORT,
|
||||||
@@ -120,7 +131,7 @@ impl AuthActivity {
|
|||||||
.with_label(String::from("Port number"))
|
.with_label(String::from("Port number"))
|
||||||
.with_input(InputType::Number)
|
.with_input(InputType::Number)
|
||||||
.with_input_len(5)
|
.with_input_len(5)
|
||||||
.with_value(String::from("22"))
|
.with_value(default_port)
|
||||||
.build(),
|
.build(),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
@@ -141,6 +152,7 @@ impl AuthActivity {
|
|||||||
String::from("FTPS"),
|
String::from("FTPS"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
.with_value(Self::protocol_enum_to_opt(default_protocol))
|
||||||
.build(),
|
.build(),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
@@ -714,12 +726,7 @@ impl AuthActivity {
|
|||||||
};
|
};
|
||||||
let protocol: FileTransferProtocol =
|
let protocol: FileTransferProtocol =
|
||||||
match self.view.get_state(super::COMPONENT_RADIO_PROTOCOL) {
|
match self.view.get_state(super::COMPONENT_RADIO_PROTOCOL) {
|
||||||
Some(Payload::One(Value::Usize(p))) => match p {
|
Some(Payload::One(Value::Usize(p))) => Self::protocol_opt_to_enum(p),
|
||||||
1 => FileTransferProtocol::Scp,
|
|
||||||
2 => FileTransferProtocol::Ftp(false),
|
|
||||||
3 => FileTransferProtocol::Ftp(true),
|
|
||||||
_ => FileTransferProtocol::Sftp,
|
|
||||||
},
|
|
||||||
_ => FileTransferProtocol::Sftp,
|
_ => FileTransferProtocol::Sftp,
|
||||||
};
|
};
|
||||||
let username: String = match self.view.get_state(super::COMPONENT_INPUT_USERNAME) {
|
let username: String = match self.view.get_state(super::COMPONENT_INPUT_USERNAME) {
|
||||||
@@ -732,4 +739,30 @@ impl AuthActivity {
|
|||||||
};
|
};
|
||||||
(addr, port, protocol, username, password)
|
(addr, port, protocol, username, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- utils
|
||||||
|
|
||||||
|
/// ### protocol_opt_to_enum
|
||||||
|
///
|
||||||
|
/// Convert radio index for protocol into a `FileTransferProtocol`
|
||||||
|
pub(crate) fn protocol_opt_to_enum(protocol: usize) -> FileTransferProtocol {
|
||||||
|
match protocol {
|
||||||
|
1 => FileTransferProtocol::Scp,
|
||||||
|
2 => FileTransferProtocol::Ftp(false),
|
||||||
|
3 => FileTransferProtocol::Ftp(true),
|
||||||
|
_ => FileTransferProtocol::Sftp,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ### protocol_enum_to_opt
|
||||||
|
///
|
||||||
|
/// Convert `FileTransferProtocol` enum into radio group index
|
||||||
|
pub(crate) fn protocol_enum_to_opt(protocol: FileTransferProtocol) -> usize {
|
||||||
|
match protocol {
|
||||||
|
FileTransferProtocol::Sftp => 0,
|
||||||
|
FileTransferProtocol::Scp => 1,
|
||||||
|
FileTransferProtocol::Ftp(false) => 2,
|
||||||
|
FileTransferProtocol::Ftp(true) => 3,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user