Removed docs headers

This commit is contained in:
veeso
2021-12-11 10:19:29 +01:00
committed by Christian Visintin
parent 2e0322bc0e
commit 027545f14c
52 changed files with 0 additions and 966 deletions

View File

@@ -35,8 +35,6 @@ use crate::system::environment;
use std::path::PathBuf;
impl AuthActivity {
/// ### del_bookmark
///
/// Delete bookmark
pub(super) fn del_bookmark(&mut self, idx: usize) {
if let Some(bookmarks_cli) = self.bookmarks_client.as_mut() {
@@ -52,8 +50,6 @@ impl AuthActivity {
}
}
/// ### load_bookmark
///
/// Load selected bookmark (at index) to input fields
pub(super) fn load_bookmark(&mut self, idx: usize) {
if let Some(bookmarks_cli) = self.bookmarks_client.as_ref() {
@@ -67,8 +63,6 @@ impl AuthActivity {
}
}
/// ### save_bookmark
///
/// Save current input fields as a bookmark
pub(super) fn save_bookmark(&mut self, name: String, save_password: bool) {
let params = match self.collect_host_params() {
@@ -89,8 +83,6 @@ impl AuthActivity {
self.sort_bookmarks();
}
}
/// ### del_recent
///
/// Delete recent
pub(super) fn del_recent(&mut self, idx: usize) {
if let Some(client) = self.bookmarks_client.as_mut() {
@@ -105,8 +97,6 @@ impl AuthActivity {
}
}
/// ### load_recent
///
/// Load selected recent (at index) to input fields
pub(super) fn load_recent(&mut self, idx: usize) {
if let Some(client) = self.bookmarks_client.as_ref() {
@@ -120,8 +110,6 @@ impl AuthActivity {
}
}
/// ### save_recent
///
/// Save current input fields as a "recent"
pub(super) fn save_recent(&mut self) {
let params = match self.collect_host_params() {
@@ -138,8 +126,6 @@ impl AuthActivity {
}
}
/// ### write_bookmarks
///
/// Write bookmarks to file
fn write_bookmarks(&mut self) {
if let Some(bookmarks_cli) = self.bookmarks_client.as_ref() {
@@ -149,8 +135,6 @@ impl AuthActivity {
}
}
/// ### init_bookmarks_client
///
/// Initialize bookmarks client
pub(super) fn init_bookmarks_client(&mut self) {
// Get config dir
@@ -210,8 +194,6 @@ impl AuthActivity {
// -- privates
/// ### sort_bookmarks
///
/// Sort bookmarks in list
fn sort_bookmarks(&mut self) {
// Conver to lowercase when sorting
@@ -219,16 +201,12 @@ impl AuthActivity {
.sort_by(|a, b| a.to_lowercase().as_str().cmp(b.to_lowercase().as_str()));
}
/// ### sort_recents
///
/// Sort recents in list
fn sort_recents(&mut self) {
// Reverse order
self.recents_list.sort_by(|a, b| b.cmp(a));
}
/// ### load_bookmark_into_gui
///
/// Load bookmark data into the gui components
fn load_bookmark_into_gui(&mut self, bookmark: FileTransferParams) {
// Load parameters into components

View File

@@ -57,8 +57,6 @@ impl ProtocolRadio {
}
}
/// ### protocol_opt_to_enum
///
/// Convert radio index for protocol into a `FileTransferProtocol`
fn protocol_opt_to_enum(protocol: usize) -> FileTransferProtocol {
match protocol {
@@ -70,8 +68,6 @@ impl ProtocolRadio {
}
}
/// ### protocol_enum_to_opt
///
/// Convert `FileTransferProtocol` enum into radio group index
fn protocol_enum_to_opt(protocol: FileTransferProtocol) -> usize {
match protocol {

View File

@@ -31,8 +31,6 @@ use crate::system::auto_update::{Release, Update, UpdateStatus};
use crate::system::notifications::Notification;
impl AuthActivity {
/// ### get_default_port_for_protocol
///
/// Get the default port for protocol
pub(super) fn get_default_port_for_protocol(protocol: FileTransferProtocol) -> u16 {
match protocol {
@@ -42,15 +40,11 @@ impl AuthActivity {
}
}
/// ### is_port_standard
///
/// Returns whether the port is standard or not
pub(super) fn is_port_standard(port: u16) -> bool {
port < 1024
}
/// ### check_minimum_window_size
///
/// Check minimum window size window
pub(super) fn check_minimum_window_size(&mut self, height: u16) {
if height < 25 {
@@ -61,8 +55,6 @@ impl AuthActivity {
}
}
/// ### collect_host_params
///
/// Collect host params as `FileTransferParams`
pub(super) fn collect_host_params(&self) -> Result<FileTransferParams, &'static str> {
match self.protocol {
@@ -71,8 +63,6 @@ impl AuthActivity {
}
}
/// ### collect_generic_host_params
///
/// Get input values from fields or return an error if fields are invalid to work as generic
pub(super) fn collect_generic_host_params(
&self,
@@ -105,8 +95,6 @@ impl AuthActivity {
})
}
/// ### collect_s3_host_params
///
/// Get input values from fields or return an error if fields are invalid to work as aws s3
pub(super) fn collect_s3_host_params(&self) -> Result<FileTransferParams, &'static str> {
let (bucket, region, profile): (String, String, Option<String>) =
@@ -126,8 +114,6 @@ impl AuthActivity {
// -- update install
/// ### check_for_updates
///
/// If enabled in configuration, check for updates from Github
pub(super) fn check_for_updates(&mut self) {
debug!("Check for updates...");
@@ -171,8 +157,6 @@ impl AuthActivity {
}
}
/// ### install_update
///
/// Install latest termscp version via GUI
pub(super) fn install_update(&mut self) {
// Umount release notes

View File

@@ -127,8 +127,6 @@ pub enum Msg {
None,
}
/// ## InputMask
///
/// Auth form input mask
#[derive(Eq, PartialEq)]
enum InputMask {
@@ -160,8 +158,6 @@ pub struct AuthActivity {
}
impl AuthActivity {
/// ### new
///
/// Instantiates a new AuthActivity
pub fn new(ticks: Duration) -> AuthActivity {
AuthActivity {
@@ -180,36 +176,26 @@ impl AuthActivity {
}
}
/// ### context
///
/// Returns a reference to context
fn context(&self) -> &Context {
self.context.as_ref().unwrap()
}
/// ### context_mut
///
/// Returns a mutable reference to context
fn context_mut(&mut self) -> &mut Context {
self.context.as_mut().unwrap()
}
/// ### config
///
/// Returns config client reference
fn config(&self) -> &ConfigClient {
self.context().config()
}
/// ### theme
///
/// Returns a reference to theme
fn theme(&self) -> &Theme {
self.context().theme_provider().theme()
}
/// ### input_mask
///
/// Get current input mask to show
fn input_mask(&self) -> InputMask {
match self.protocol {
@@ -222,8 +208,6 @@ impl AuthActivity {
}
impl Activity for AuthActivity {
/// ### on_create
///
/// `on_create` is the function which must be called to initialize the activity.
/// `on_create` must initialize all the data structures used by the activity
/// Context is taken from activity manager and will be released only when activity is destroyed
@@ -259,8 +243,6 @@ impl Activity for AuthActivity {
info!("Activity initialized");
}
/// ### on_draw
///
/// `on_draw` is the function which draws the graphical interface.
/// This function must be called at each tick to refresh the interface
fn on_draw(&mut self) {
@@ -288,8 +270,6 @@ impl Activity for AuthActivity {
}
}
/// ### will_umount
///
/// `will_umount` is the method which must be able to report to the activity manager, whether
/// the activity should be terminated or not.
/// If not, the call will return `None`, otherwise return`Some(ExitReason)`
@@ -297,8 +277,6 @@ impl Activity for AuthActivity {
self.exit_reason.as_ref()
}
/// ### on_destroy
///
/// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity.
/// This function must be called once before terminating the activity.
/// This function finally releases the context

View File

@@ -37,8 +37,6 @@ use tuirealm::tui::widgets::Clear;
use tuirealm::{State, StateValue, Sub, SubClause, SubEventClause};
impl AuthActivity {
/// ### init
///
/// Initialize view, mounting all startup components inside the view
pub(super) fn init(&mut self) {
let key_color = self.theme().misc_keys;
@@ -104,8 +102,6 @@ impl AuthActivity {
assert!(self.app.active(&Id::Protocol).is_ok());
}
/// ### view
///
/// Display view on canvas
pub(super) fn view(&mut self) {
self.redraw = false;
@@ -276,8 +272,6 @@ impl AuthActivity {
// -- partials
/// ### view_bookmarks
///
/// Make text span from bookmarks
pub(super) fn view_bookmarks(&mut self) {
let bookmarks: Vec<String> = self
@@ -305,8 +299,6 @@ impl AuthActivity {
.is_ok());
}
/// ### view_recent_connections
///
/// View recent connections
pub(super) fn view_recent_connections(&mut self) {
let bookmarks: Vec<String> = self
@@ -335,8 +327,6 @@ impl AuthActivity {
// -- mount
/// ### mount_error
///
/// Mount error box
pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) {
let err_color = self.theme().misc_error_dialog;
@@ -351,15 +341,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::ErrorPopup).is_ok());
}
/// ### umount_error
///
/// Umount error message
pub(super) fn umount_error(&mut self) {
let _ = self.app.umount(&Id::ErrorPopup);
}
/// ### mount_info
///
/// Mount info box
pub(super) fn mount_info<S: AsRef<str>>(&mut self, text: S) {
let color = self.theme().misc_info_dialog;
@@ -374,15 +360,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::InfoPopup).is_ok());
}
/// ### umount_info
///
/// Umount info message
pub(super) fn umount_info(&mut self) {
let _ = self.app.umount(&Id::InfoPopup);
}
/// ### mount_error
///
/// Mount wait box
pub(super) fn mount_wait(&mut self, text: &str) {
let wait_color = self.theme().misc_info_dialog;
@@ -397,15 +379,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::WaitPopup).is_ok());
}
/// ### umount_wait
///
/// Umount wait message
pub(super) fn umount_wait(&mut self) {
let _ = self.app.umount(&Id::WaitPopup);
}
/// ### mount_size_err
///
/// Mount size error
pub(super) fn mount_size_err(&mut self) {
// Mount
@@ -421,15 +399,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::WindowSizeError).is_ok());
}
/// ### umount_size_err
///
/// Umount error size error
pub(super) fn umount_size_err(&mut self) {
let _ = self.app.umount(&Id::WindowSizeError);
}
/// ### mount_quit
///
/// Mount quit popup
pub(super) fn mount_quit(&mut self) {
// Protocol
@@ -445,15 +419,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::QuitPopup).is_ok());
}
/// ### umount_quit
///
/// Umount quit popup
pub(super) fn umount_quit(&mut self) {
let _ = self.app.umount(&Id::QuitPopup);
}
/// ### mount_bookmark_del_dialog
///
/// Mount bookmark delete dialog
pub(super) fn mount_bookmark_del_dialog(&mut self) {
let warn_color = self.theme().misc_warn_dialog;
@@ -468,15 +438,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::DeleteBookmarkPopup).is_ok());
}
/// ### umount_bookmark_del_dialog
///
/// umount delete bookmark dialog
pub(super) fn umount_bookmark_del_dialog(&mut self) {
let _ = self.app.umount(&Id::DeleteBookmarkPopup);
}
/// ### mount_bookmark_del_dialog
///
/// Mount recent delete dialog
pub(super) fn mount_recent_del_dialog(&mut self) {
let warn_color = self.theme().misc_warn_dialog;
@@ -491,15 +457,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::DeleteRecentPopup).is_ok());
}
/// ### umount_recent_del_dialog
///
/// umount delete recent dialog
pub(super) fn umount_recent_del_dialog(&mut self) {
let _ = self.app.umount(&Id::DeleteRecentPopup);
}
/// ### mount_bookmark_save_dialog
///
/// Mount bookmark save dialog
pub(super) fn mount_bookmark_save_dialog(&mut self) {
let save_color = self.theme().misc_save_dialog;
@@ -524,16 +486,12 @@ impl AuthActivity {
assert!(self.app.active(&Id::BookmarkName).is_ok());
}
/// ### umount_bookmark_save_dialog
///
/// Umount bookmark save dialog
pub(super) fn umount_bookmark_save_dialog(&mut self) {
let _ = self.app.umount(&Id::BookmarkName);
let _ = self.app.umount(&Id::BookmarkSavePassword);
}
/// ### mount_keybindings
///
/// Mount keybindings
pub(super) fn mount_keybindings(&mut self) {
let key_color = self.theme().misc_keys;
@@ -549,15 +507,11 @@ impl AuthActivity {
assert!(self.app.active(&Id::Keybindings).is_ok());
}
/// ### umount_help
///
/// Umount help
pub(super) fn umount_help(&mut self) {
let _ = self.app.umount(&Id::Keybindings);
}
/// ### mount_release_notes
///
/// mount release notes text area
pub(super) fn mount_release_notes(&mut self) {
if let Some(ctx) = self.context.as_ref() {
@@ -585,8 +539,6 @@ impl AuthActivity {
}
}
/// ### umount_release_notes
///
/// Umount release notes text area
pub(super) fn umount_release_notes(&mut self) {
let _ = self.app.umount(&Id::NewVersionChangelog);
@@ -691,8 +643,6 @@ impl AuthActivity {
// -- query
/// ### get_generic_params
///
/// Collect input values from view
pub(super) fn get_generic_params_input(&self) -> (String, u16, String, String) {
let addr: String = self.get_input_addr();
@@ -702,8 +652,6 @@ impl AuthActivity {
(addr, port, username, password)
}
/// ### get_s3_params_input
///
/// Collect s3 input values from view
pub(super) fn get_s3_params_input(&self) -> (String, String, Option<String>) {
let bucket: String = self.get_input_s3_bucket();
@@ -764,8 +712,6 @@ impl AuthActivity {
}
}
/// ### get_new_bookmark
///
/// Get new bookmark params
pub(super) fn get_new_bookmark(&self) -> (String, bool) {
let name = match self.app.state(&Id::BookmarkName) {
@@ -784,8 +730,6 @@ impl AuthActivity {
// -- len
/// ### input_mask_size
///
/// Returns the input mask size based on current input mask
pub(super) fn input_mask_size(&self) -> u16 {
match self.input_mask() {
@@ -796,16 +740,12 @@ impl AuthActivity {
// -- fmt
/// ### fmt_bookmark
///
/// Format bookmark to display on ui
fn fmt_bookmark(name: &str, b: FileTransferParams) -> String {
let addr: String = Self::fmt_recent(b);
format!("{} ({})", name, addr)
}
/// ### fmt_recent
///
/// Format recent connection to display on ui
fn fmt_recent(b: FileTransferParams) -> String {
let protocol: String = b.protocol.to_string().to_lowercase();
@@ -881,8 +821,6 @@ impl AuthActivity {
.is_ok());
}
/// ### no_popup_mounted_clause
///
/// Returns a sub clause which requires that no popup is mounted in order to be satisfied
fn no_popup_mounted_clause() -> SubClause<Id> {
SubClause::And(

View File

@@ -32,8 +32,6 @@ use remotefs::Directory;
use std::path::PathBuf;
impl FileTransferActivity {
/// ### action_enter_local_dir
///
/// Enter a directory on local host from entry
/// Return true whether the directory changed
pub(crate) fn action_enter_local_dir(&mut self, dir: Directory, block_sync: bool) -> bool {
@@ -44,8 +42,6 @@ impl FileTransferActivity {
true
}
/// ### action_enter_remote_dir
///
/// Enter a directory on local host from entry
/// Return true whether the directory changed
pub(crate) fn action_enter_remote_dir(&mut self, dir: Directory, block_sync: bool) -> bool {
@@ -56,8 +52,6 @@ impl FileTransferActivity {
true
}
/// ### action_change_local_dir
///
/// Change local directory reading value from input
pub(crate) fn action_change_local_dir(&mut self, input: String, block_sync: bool) {
let dir_path: PathBuf = self.local_to_abs_path(PathBuf::from(input.as_str()).as_path());
@@ -68,8 +62,6 @@ impl FileTransferActivity {
}
}
/// ### action_change_remote_dir
///
/// Change remote directory reading value from input
pub(crate) fn action_change_remote_dir(&mut self, input: String, block_sync: bool) {
let dir_path: PathBuf = self.remote_to_abs_path(PathBuf::from(input.as_str()).as_path());
@@ -80,8 +72,6 @@ impl FileTransferActivity {
}
}
/// ### action_go_to_previous_local_dir
///
/// Go to previous directory from localhost
pub(crate) fn action_go_to_previous_local_dir(&mut self, block_sync: bool) {
if let Some(d) = self.local_mut().popd() {
@@ -93,8 +83,6 @@ impl FileTransferActivity {
}
}
/// ### action_go_to_previous_remote_dir
///
/// Go to previous directory from remote host
pub(crate) fn action_go_to_previous_remote_dir(&mut self, block_sync: bool) {
if let Some(d) = self.remote_mut().popd() {
@@ -106,8 +94,6 @@ impl FileTransferActivity {
}
}
/// ### action_go_to_local_upper_dir
///
/// Go to upper directory on local host
pub(crate) fn action_go_to_local_upper_dir(&mut self, block_sync: bool) {
// Get pwd

View File

@@ -32,8 +32,6 @@ use remotefs::{Entry, RemoteErrorType};
use std::path::{Path, PathBuf};
impl FileTransferActivity {
/// ### action_local_copy
///
/// Copy file on local
pub(crate) fn action_local_copy(&mut self, input: String) {
match self.get_local_selected_entries() {
@@ -59,8 +57,6 @@ impl FileTransferActivity {
}
}
/// ### action_remote_copy
///
/// Copy file on remote
pub(crate) fn action_remote_copy(&mut self, input: String) {
match self.get_remote_selected_entries() {
@@ -140,8 +136,6 @@ impl FileTransferActivity {
}
}
/// ### tricky_copy
///
/// Tricky copy will be used whenever copy command is not available on remote host
pub(super) fn tricky_copy(&mut self, entry: Entry, dest: &Path) -> Result<(), String> {
// NOTE: VERY IMPORTANT; wait block must be umounted or something really bad will happen

View File

@@ -84,8 +84,6 @@ impl FileTransferActivity {
self.reload_remote_dir();
}
/// ### edit_local_file
///
/// Edit a file on localhost
fn edit_local_file(&mut self, path: &Path) -> Result<(), String> {
// Read first 2048 bytes or less from file to check if it is textual
@@ -147,8 +145,6 @@ impl FileTransferActivity {
Ok(())
}
/// ### edit_remote_file
///
/// Edit file on remote host
fn edit_remote_file(&mut self, file: File) -> Result<(), String> {
// Create temp file

View File

@@ -75,8 +75,6 @@ impl From<Vec<&Entry>> for SelectedEntry {
}
impl FileTransferActivity {
/// ### get_local_selected_entries
///
/// Get local file entry
pub(crate) fn get_local_selected_entries(&self) -> SelectedEntry {
match self.get_selected_index(&Id::ExplorerLocal) {
@@ -93,8 +91,6 @@ impl FileTransferActivity {
}
}
/// ### get_remote_selected_entries
///
/// Get remote file entry
pub(crate) fn get_remote_selected_entries(&self) -> SelectedEntry {
match self.get_selected_index(&Id::ExplorerRemote) {
@@ -111,8 +107,6 @@ impl FileTransferActivity {
}
}
/// ### get_remote_selected_entries
///
/// Get remote file entry
pub(crate) fn get_found_selected_entries(&self) -> SelectedEntry {
match self.get_selected_index(&Id::ExplorerFind) {

View File

@@ -31,8 +31,6 @@ use super::{Entry, FileTransferActivity, LogLevel, SelectedEntry, TransferPayloa
use std::path::{Path, PathBuf};
impl FileTransferActivity {
/// ### action_open_local
///
/// Open local file
pub(crate) fn action_open_local(&mut self) {
let entries: Vec<Entry> = match self.get_local_selected_entries() {
@@ -45,8 +43,6 @@ impl FileTransferActivity {
.for_each(|x| self.action_open_local_file(x, None));
}
/// ### action_open_remote
///
/// Open local file
pub(crate) fn action_open_remote(&mut self) {
let entries: Vec<Entry> = match self.get_remote_selected_entries() {
@@ -59,15 +55,11 @@ impl FileTransferActivity {
.for_each(|x| self.action_open_remote_file(x, None));
}
/// ### action_open_local_file
///
/// Perform open lopcal file
pub(crate) fn action_open_local_file(&mut self, entry: &Entry, open_with: Option<&str>) {
self.open_path_with(entry.path(), open_with);
}
/// ### action_open_local
///
/// Open remote file. The file is first downloaded to a temporary directory on localhost
pub(crate) fn action_open_remote_file(&mut self, entry: &Entry, open_with: Option<&str>) {
// Download file
@@ -107,8 +99,6 @@ impl FileTransferActivity {
}
}
/// ### action_local_open_with
///
/// Open selected file with provided application
pub(crate) fn action_local_open_with(&mut self, with: &str) {
let entries: Vec<Entry> = match self.get_local_selected_entries() {
@@ -122,8 +112,6 @@ impl FileTransferActivity {
.for_each(|x| self.action_open_local_file(x, Some(with)));
}
/// ### action_remote_open_with
///
/// Open selected file with provided application
pub(crate) fn action_remote_open_with(&mut self, with: &str) {
let entries: Vec<Entry> = match self.get_remote_selected_entries() {
@@ -137,8 +125,6 @@ impl FileTransferActivity {
.for_each(|x| self.action_open_remote_file(x, Some(with)));
}
/// ### open_path_with
///
/// Common function which opens a path with default or specified program.
fn open_path_with(&mut self, p: &Path, with: Option<&str>) {
// Open file

View File

@@ -131,8 +131,6 @@ impl FileTransferActivity {
}
}
/// ### tricky_move
///
/// Tricky move will be used whenever copy command is not available on remote host.
/// It basically uses the tricky_copy function, then it just deletes the previous entry (`entry`)
fn tricky_move(&mut self, entry: &Entry, dest: &Path) {

View File

@@ -49,8 +49,6 @@ impl FileTransferActivity {
self.remote_recv_file(TransferOpts::default());
}
/// ### action_finalize_pending_transfer
///
/// Finalize "pending" transfer.
/// The pending transfer is created after a transfer which required a user action to be completed first.
/// The name of the file to transfer, is contained in the storage at `STORAGE_PENDING_TRANSFER`.
@@ -228,8 +226,6 @@ impl FileTransferActivity {
}
}
/// ### set_pending_transfer
///
/// Set pending transfer into storage
pub(crate) fn set_pending_transfer(&mut self, file_name: &str) {
self.mount_radio_replace(file_name);
@@ -239,8 +235,6 @@ impl FileTransferActivity {
.set_string(STORAGE_PENDING_TRANSFER, file_name.to_string());
}
/// ### set_pending_transfer_many
///
/// Set pending transfer for many files into storage and mount radio
pub(crate) fn set_pending_transfer_many(&mut self, files: Vec<&Entry>, dest_path: &str) {
let file_names: Vec<&str> = files.iter().map(|x| x.name()).collect();
@@ -250,8 +244,6 @@ impl FileTransferActivity {
.set_string(STORAGE_PENDING_TRANSFER, dest_path.to_string());
}
/// ### file_to_check
///
/// Get file to check for path
pub(crate) fn file_to_check(e: &Entry, alt: Option<&String>) -> PathBuf {
match alt {

View File

@@ -36,8 +36,6 @@ enum SubmitAction {
}
impl FileTransferActivity {
/// ### action_submit_local
///
/// Decides which action to perform on submit for local explorer
/// Return true whether the directory changed
pub(crate) fn action_submit_local(&mut self, entry: Entry) -> bool {
@@ -78,8 +76,6 @@ impl FileTransferActivity {
}
}
/// ### action_submit_remote
///
/// Decides which action to perform on submit for remote explorer
/// Return true whether the directory changed
pub(crate) fn action_submit_remote(&mut self, entry: Entry) -> bool {

View File

@@ -222,8 +222,6 @@ impl Component<Msg, NoUserEvent> for Log {
// -- states
/// ## OwnStates
///
/// OwnStates contains states for this component
#[derive(Clone, Default)]
struct OwnStates {
@@ -232,22 +230,16 @@ struct OwnStates {
}
impl OwnStates {
/// ### set_list_len
///
/// Set list length
pub fn set_list_len(&mut self, len: usize) {
self.list_len = len;
}
/// ### get_list_index
///
/// Return current value for list index
pub fn get_list_index(&self) -> usize {
self.list_index
}
/// ### incr_list_index
///
/// Incremenet list index
pub fn incr_list_index(&mut self) {
// Check if index is at last element
@@ -256,8 +248,6 @@ impl OwnStates {
}
}
/// ### decr_list_index
///
/// Decrement list index
pub fn decr_list_index(&mut self) {
// Check if index is bigger than 0
@@ -266,8 +256,6 @@ impl OwnStates {
}
}
/// ### list_index_at_last
///
/// Set list index at last item
pub fn list_index_at_last(&mut self) {
self.list_index = match self.list_len {
@@ -276,8 +264,6 @@ impl OwnStates {
};
}
/// ### reset_list_index
///
/// Reset list index to last element
pub fn reset_list_index(&mut self) {
self.list_index = 0; // Last element is always 0

View File

@@ -36,8 +36,6 @@ use tuirealm::{MockComponent, Props, State, StateValue};
pub const FILE_LIST_CMD_SELECT_ALL: &str = "A";
/// ## OwnStates
///
/// OwnStates contains states for this component
#[derive(Clone, Default)]
struct OwnStates {
@@ -46,23 +44,17 @@ struct OwnStates {
}
impl OwnStates {
/// ### init_list_states
///
/// Initialize list states
pub fn init_list_states(&mut self, len: usize) {
self.selected = Vec::with_capacity(len);
self.fix_list_index();
}
/// ### list_index
///
/// Return current value for list index
pub fn list_index(&self) -> usize {
self.list_index
}
/// ### incr_list_index
///
/// Incremenet list index.
/// If `can_rewind` is `true` the index rewinds when boundary is reached
pub fn incr_list_index(&mut self, can_rewind: bool) {
@@ -74,8 +66,6 @@ impl OwnStates {
}
}
/// ### decr_list_index
///
/// Decrement list index
/// If `can_rewind` is `true` the index rewinds when boundary is reached
pub fn decr_list_index(&mut self, can_rewind: bool) {
@@ -98,36 +88,26 @@ impl OwnStates {
};
}
/// ### list_len
///
/// Returns the length of the file list, which is actually the capacity of the selection vector
pub fn list_len(&self) -> usize {
self.selected.capacity()
}
/// ### is_selected
///
/// Returns whether the file with index `entry` is selected
pub fn is_selected(&self, entry: usize) -> bool {
self.selected.contains(&entry)
}
/// ### is_selection_empty
///
/// Returns whether the selection is currently empty
pub fn is_selection_empty(&self) -> bool {
self.selected.is_empty()
}
/// ### get_selection
///
/// Returns current file selection
pub fn get_selection(&self) -> Vec<usize> {
self.selected.clone()
}
/// ### fix_list_index
///
/// Keep index if possible, otherwise set to lenght - 1
fn fix_list_index(&mut self) {
if self.list_index >= self.list_len() && self.list_len() > 0 {
@@ -139,8 +119,6 @@ impl OwnStates {
// -- select manipulation
/// ### toggle_file
///
/// Select or deselect file with provided entry index
pub fn toggle_file(&mut self, entry: usize) {
match self.is_selected(entry) {
@@ -149,8 +127,6 @@ impl OwnStates {
}
}
/// ### select_all
///
/// Select all files
pub fn select_all(&mut self) {
for i in 0..self.list_len() {
@@ -158,8 +134,6 @@ impl OwnStates {
}
}
/// ### select
///
/// Select provided index if not selected yet
fn select(&mut self, entry: usize) {
if !self.is_selected(entry) {
@@ -167,8 +141,6 @@ impl OwnStates {
}
}
/// ### deselect
///
/// Remove element file with associated index
fn deselect(&mut self, entry: usize) {
if self.is_selected(entry) {

View File

@@ -31,8 +31,6 @@ use crate::system::config_client::ConfigClient;
use remotefs::Entry;
use std::path::Path;
/// ## FileExplorerTab
///
/// File explorer tab
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum FileExplorerTab {
@@ -42,8 +40,6 @@ pub enum FileExplorerTab {
FindRemote, // Find result tab
}
/// ## FoundExplorerTab
///
/// Describes the explorer tab type
#[derive(Copy, Clone, Debug)]
pub enum FoundExplorerTab {
@@ -51,8 +47,6 @@ pub enum FoundExplorerTab {
Remote,
}
/// ## Browser
///
/// Browser contains the browser options
pub struct Browser {
local: FileExplorer, // Local File explorer state
@@ -63,8 +57,6 @@ pub struct Browser {
}
impl Browser {
/// ### new
///
/// Build a new `Browser` struct
pub fn new(cli: &ConfigClient) -> Self {
Self {
@@ -110,8 +102,6 @@ impl Browser {
self.found = None;
}
/// ### found_tab
///
/// Returns found tab if any
pub fn found_tab(&self) -> Option<FoundExplorerTab> {
self.found.as_ref().map(|x| x.0)
@@ -121,22 +111,16 @@ impl Browser {
self.tab
}
/// ### change_tab
///
/// Update tab value
pub fn change_tab(&mut self, tab: FileExplorerTab) {
self.tab = tab;
}
/// ### toggle_sync_browsing
///
/// Invert the current state for the sync browsing
pub fn toggle_sync_browsing(&mut self) {
self.sync_browsing = !self.sync_browsing;
}
/// ### build_local_explorer
///
/// Build a file explorer with local host setup
pub fn build_local_explorer(cli: &ConfigClient) -> FileExplorer {
let mut builder = Self::build_explorer(cli);
@@ -144,8 +128,6 @@ impl Browser {
builder.build()
}
/// ### build_remote_explorer
///
/// Build a file explorer with remote host setup
pub fn build_remote_explorer(cli: &ConfigClient) -> FileExplorer {
let mut builder = Self::build_explorer(cli);
@@ -153,8 +135,6 @@ impl Browser {
builder.build()
}
/// ### build_explorer
///
/// Build explorer reading configuration from `ConfigClient`
fn build_explorer(cli: &ConfigClient) -> FileExplorerBuilder {
let mut builder: FileExplorerBuilder = FileExplorerBuilder::new();
@@ -167,8 +147,6 @@ impl Browser {
builder
}
/// ### build_found_explorer
///
/// Build explorer reading from `ConfigClient`, for found result (has some differences)
fn build_found_explorer(wrkdir: &Path) -> FileExplorer {
FileExplorerBuilder::new()

View File

@@ -56,8 +56,6 @@ impl Default for TransferStates {
}
impl TransferStates {
/// ### new
///
/// Instantiates a new transfer states
pub fn new() -> TransferStates {
TransferStates {
@@ -67,29 +65,21 @@ impl TransferStates {
}
}
/// ### reset
///
/// Re-intiialize transfer states
pub fn reset(&mut self) {
self.aborted = false;
}
/// ### abort
///
/// Set aborted to true
pub fn abort(&mut self) {
self.aborted = true;
}
/// ### aborted
///
/// Returns whether transfer has been aborted
pub fn aborted(&self) -> bool {
self.aborted
}
/// ### full_size
///
/// Returns the size of the entire transfer
pub fn full_size(&self) -> usize {
self.full.total
@@ -128,8 +118,6 @@ impl fmt::Display for ProgressStates {
}
impl ProgressStates {
/// ### init
///
/// Initialize a new Progress State
pub fn init(&mut self, sz: usize) {
self.started = Instant::now();
@@ -137,16 +125,12 @@ impl ProgressStates {
self.written = 0;
}
/// ### update_progress
///
/// Update progress state
pub fn update_progress(&mut self, delta: usize) -> f64 {
self.written += delta;
self.calc_progress_percentage()
}
/// ### calc_progress
///
/// Calculate progress in a range between 0.0 to 1.0
pub fn calc_progress(&self) -> f64 {
// Prevent dividing by 0
@@ -160,22 +144,16 @@ impl ProgressStates {
}
}
/// ### started
///
/// Get started
pub fn started(&self) -> Instant {
self.started
}
/// ### calc_progress_percentage
///
/// Calculate the current transfer progress as percentage
fn calc_progress_percentage(&self) -> f64 {
self.calc_progress() * 100.0
}
/// ### calc_bytes_per_second
///
/// Generic function to calculate bytes per second using elapsed time since transfer started and the bytes written
/// and the total amount of bytes to write
pub fn calc_bytes_per_second(&self) -> u64 {
@@ -191,8 +169,6 @@ impl ProgressStates {
}
}
/// ### calc_eta
///
/// Calculate ETA for current transfer as seconds
fn calc_eta(&self) -> u64 {
let elapsed_secs: u64 = self.started.elapsed().as_secs();
@@ -206,8 +182,6 @@ impl ProgressStates {
// -- Options
/// ## TransferOpts
///
/// Defines the transfer options for transfer actions
pub struct TransferOpts {
/// Save file as
@@ -226,16 +200,12 @@ impl Default for TransferOpts {
}
impl TransferOpts {
/// ### save_as
///
/// Define the name of the file to be saved
pub fn save_as<S: AsRef<str>>(mut self, n: Option<S>) -> Self {
self.save_as = n.map(|x| x.as_ref().to_string());
self
}
/// ### check_replace
///
/// Set whether to check if the file being transferred will "replace" an existing one
pub fn check_replace(mut self, opt: bool) -> Self {
self.check_replace = opt;

View File

@@ -43,8 +43,6 @@ use tuirealm::{PollStrategy, Update};
const LOG_CAPACITY: usize = 256;
impl FileTransferActivity {
/// ### tick
///
/// Call `Application::tick()` and process messages in `Update`
pub(super) fn tick(&mut self) {
match self.app.tick(PollStrategy::UpTo(3)) {
@@ -65,8 +63,6 @@ impl FileTransferActivity {
}
}
/// ### log
///
/// Add message to log events
pub(super) fn log(&mut self, level: LogLevel, msg: String) {
// Log to file
@@ -87,8 +83,6 @@ impl FileTransferActivity {
self.update_logbox();
}
/// ### log_and_alert
///
/// Add message to log events and also display it as an alert
pub(super) fn log_and_alert(&mut self, level: LogLevel, msg: String) {
self.mount_error(msg.as_str());
@@ -97,8 +91,6 @@ impl FileTransferActivity {
self.update_logbox();
}
/// ### init_config_client
///
/// Initialize configuration client if possible.
/// This function doesn't return errors.
pub(super) fn init_config_client() -> ConfigClient {
@@ -119,29 +111,21 @@ impl FileTransferActivity {
}
}
/// ### setup_text_editor
///
/// Set text editor to use
pub(super) fn setup_text_editor(&self) {
env::set_var("EDITOR", self.config().get_text_editor());
}
/// ### local_to_abs_path
///
/// Convert a path to absolute according to local explorer
pub(super) fn local_to_abs_path(&self, path: &Path) -> PathBuf {
path::absolutize(self.local().wrkdir.as_path(), path)
}
/// ### remote_to_abs_path
///
/// Convert a path to absolute according to remote explorer
pub(super) fn remote_to_abs_path(&self, path: &Path) -> PathBuf {
path::absolutize(self.remote().wrkdir.as_path(), path)
}
/// ### get_remote_hostname
///
/// Get remote hostname
pub(super) fn get_remote_hostname(&self) -> String {
let ft_params = self.context().ft_params().unwrap();
@@ -151,8 +135,6 @@ impl FileTransferActivity {
}
}
/// ### get_connection_msg
///
/// Get connection message to show to client
pub(super) fn get_connection_msg(params: &ProtocolParams) -> String {
match params {
@@ -173,8 +155,6 @@ impl FileTransferActivity {
}
}
/// ### notify_transfer_completed
///
/// Send notification regarding transfer completed
/// The notification is sent only when these conditions are satisfied:
///
@@ -188,8 +168,6 @@ impl FileTransferActivity {
}
}
/// ### notify_transfer_error
///
/// Send notification regarding transfer error
/// The notification is sent only when these conditions are satisfied:
///
@@ -233,8 +211,6 @@ impl FileTransferActivity {
}
}
/// ### update_local_filelist
///
/// Update local file list
pub(super) fn update_local_filelist(&mut self) {
// Get width
@@ -280,8 +256,6 @@ impl FileTransferActivity {
.is_ok());
}
/// ### update_remote_filelist
///
/// Update remote file list
pub(super) fn update_remote_filelist(&mut self) {
let width: usize = self
@@ -323,8 +297,6 @@ impl FileTransferActivity {
.is_ok());
}
/// ### update_logbox
///
/// Update log box
pub(super) fn update_logbox(&mut self) {
let mut table: TableBuilder = TableBuilder::default();
@@ -418,8 +390,6 @@ impl FileTransferActivity {
.is_ok());
}
/// ### finalize_find
///
/// Finalize find process
pub(super) fn finalize_find(&mut self) {
// Set found to none

View File

@@ -171,8 +171,6 @@ enum UiMsg {
ToggleSyncBrowsing,
}
/// ## LogLevel
///
/// Log level type
enum LogLevel {
Error,
@@ -180,8 +178,6 @@ enum LogLevel {
Info,
}
/// ## LogRecord
///
/// Log record entry
struct LogRecord {
pub time: DateTime<Local>,
@@ -190,8 +186,6 @@ struct LogRecord {
}
impl LogRecord {
/// ### new
///
/// Instantiates a new LogRecord
pub fn new(level: LogLevel, msg: String) -> LogRecord {
LogRecord {
@@ -202,8 +196,6 @@ impl LogRecord {
}
}
/// ## FileTransferActivity
///
/// FileTransferActivity is the data holder for the file transfer activity
pub struct FileTransferActivity {
/// Exit reason
@@ -228,8 +220,6 @@ pub struct FileTransferActivity {
}
impl FileTransferActivity {
/// ### new
///
/// Instantiates a new FileTransferActivity
pub fn new(host: Localhost, params: &FileTransferParams, ticks: Duration) -> Self {
// Get config client
@@ -279,8 +269,6 @@ impl FileTransferActivity {
self.browser.found_mut()
}
/// ### get_cache_tmp_name
///
/// Get file name for a file in cache
fn get_cache_tmp_name(&self, name: &str, file_type: Option<&str>) -> Option<String> {
self.cache.as_ref().map(|_| {
@@ -299,29 +287,21 @@ impl FileTransferActivity {
})
}
/// ### context
///
/// Returns a reference to context
fn context(&self) -> &Context {
self.context.as_ref().unwrap()
}
/// ### context_mut
///
/// Returns a mutable reference to context
fn context_mut(&mut self) -> &mut Context {
self.context.as_mut().unwrap()
}
/// ### config
///
/// Returns config client reference
fn config(&self) -> &ConfigClient {
self.context().config()
}
/// ### theme
///
/// Get a reference to `Theme`
fn theme(&self) -> &Theme {
self.context().theme_provider().theme()
@@ -335,8 +315,6 @@ impl FileTransferActivity {
*/
impl Activity for FileTransferActivity {
/// ### on_create
///
/// `on_create` is the function which must be called to initialize the activity.
/// `on_create` must initialize all the data structures used by the activity
fn on_create(&mut self, context: Context) {
@@ -368,8 +346,6 @@ impl Activity for FileTransferActivity {
info!("Created FileTransferActivity");
}
/// ### on_draw
///
/// `on_draw` is the function which draws the graphical interface.
/// This function must be called at each tick to refresh the interface
fn on_draw(&mut self) {
@@ -398,8 +374,6 @@ impl Activity for FileTransferActivity {
}
}
/// ### will_umount
///
/// `will_umount` is the method which must be able to report to the activity manager, whether
/// the activity should be terminated or not.
/// If not, the call will return `None`, otherwise return`Some(ExitReason)`
@@ -407,8 +381,6 @@ impl Activity for FileTransferActivity {
self.exit_reason.as_ref()
}
/// ### on_destroy
///
/// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity.
/// This function must be called once before terminating the activity.
fn on_destroy(&mut self) -> Option<Context> {

View File

@@ -40,8 +40,6 @@ use std::path::{Path, PathBuf};
use std::time::Instant;
use thiserror::Error;
/// ## TransferErrorReason
///
/// Describes the reason that caused an error during a file transfer
#[derive(Error, Debug)]
enum TransferErrorReason {
@@ -59,8 +57,6 @@ enum TransferErrorReason {
FileTransferError(RemoteError),
}
/// ## TransferPayload
///
/// Represents the entity to send or receive during a transfer.
/// - File: describes an individual `File` to send
/// - Any: Can be any kind of `Entry`, but just one
@@ -73,8 +69,6 @@ pub(super) enum TransferPayload {
}
impl FileTransferActivity {
/// ### connect
///
/// Connect to remote
pub(super) fn connect(&mut self) {
let ft_params = self.context().ft_params().unwrap().clone();
@@ -116,8 +110,6 @@ impl FileTransferActivity {
}
}
/// ### disconnect
///
/// disconnect from remote
pub(super) fn disconnect(&mut self) {
let msg: String = format!("Disconnecting from {}", self.get_remote_hostname());
@@ -129,16 +121,12 @@ impl FileTransferActivity {
self.exit_reason = Some(super::ExitReason::Disconnect);
}
/// ### disconnect_and_quit
///
/// disconnect from remote and then quit
pub(super) fn disconnect_and_quit(&mut self) {
self.disconnect();
self.exit_reason = Some(super::ExitReason::Quit);
}
/// ### reload_remote_dir
///
/// Reload remote directory entries and update browser
pub(super) fn reload_remote_dir(&mut self) {
// Get current entries
@@ -149,8 +137,6 @@ impl FileTransferActivity {
}
}
/// ### reload_local_dir
///
/// Reload local directory entries and update browser
pub(super) fn reload_local_dir(&mut self) {
let wrkdir: PathBuf = self.host.pwd();
@@ -158,8 +144,6 @@ impl FileTransferActivity {
self.local_mut().wrkdir = wrkdir;
}
/// ### local_scan
///
/// Scan current local directory
fn local_scan(&mut self, path: &Path) {
match self.host.scan_dir(path) {
@@ -176,8 +160,6 @@ impl FileTransferActivity {
}
}
/// ### remote_scan
///
/// Scan current remote directory
fn remote_scan(&mut self, path: &Path) {
match self.client.list_dir(path) {
@@ -194,8 +176,6 @@ impl FileTransferActivity {
}
}
/// ### filetransfer_send
///
/// Send fs entry to remote.
/// If dst_name is Some, entry will be saved with a different name.
/// If entry is a directory, this applies to directory only
@@ -229,8 +209,6 @@ impl FileTransferActivity {
result
}
/// ### filetransfer_send_file
///
/// Send one file to remote at specified path.
fn filetransfer_send_file(
&mut self,
@@ -261,8 +239,6 @@ impl FileTransferActivity {
result.map_err(|x| x.to_string())
}
/// ### filetransfer_send_any
///
/// Send a `TransferPayload` of type `Any`
fn filetransfer_send_any(
&mut self,
@@ -284,8 +260,6 @@ impl FileTransferActivity {
result
}
/// ### filetransfer_send_many
///
/// Send many entries to remote
fn filetransfer_send_many(
&mut self,
@@ -448,8 +422,6 @@ impl FileTransferActivity {
result
}
/// ### filetransfer_send_file
///
/// Send local file and write it to remote path
fn filetransfer_send_one(
&mut self,
@@ -479,8 +451,6 @@ impl FileTransferActivity {
}
}
/// ### filetransfer_send_one_with_stream
///
/// Send file to remote using stream
fn filetransfer_send_one_with_stream(
&mut self,
@@ -580,8 +550,6 @@ impl FileTransferActivity {
Ok(())
}
/// ### filetransfer_send_one_wno_stream
///
/// Send an `File` to remote without using streams.
fn filetransfer_send_one_wno_stream(
&mut self,
@@ -631,8 +599,6 @@ impl FileTransferActivity {
Ok(())
}
/// ### filetransfer_recv
///
/// Recv fs entry from remote.
/// If dst_name is Some, entry will be saved with a different name.
/// If entry is a directory, this applies to directory only
@@ -661,8 +627,6 @@ impl FileTransferActivity {
result
}
/// ### filetransfer_recv_any
///
/// Recv fs entry from remote.
/// If dst_name is Some, entry will be saved with a different name.
/// If entry is a directory, this applies to directory only
@@ -686,8 +650,6 @@ impl FileTransferActivity {
result
}
/// ### filetransfer_recv_file
///
/// Receive a single file from remote.
fn filetransfer_recv_file(&mut self, entry: &File, local_path: &Path) -> Result<(), String> {
// Reset states
@@ -705,8 +667,6 @@ impl FileTransferActivity {
result.map_err(|x| x.to_string())
}
/// ### filetransfer_send_many
///
/// Send many entries to remote
fn filetransfer_recv_many(
&mut self,
@@ -887,8 +847,6 @@ impl FileTransferActivity {
result
}
/// ### filetransfer_recv_one
///
/// Receive file from remote and write it to local path
fn filetransfer_recv_one(
&mut self,
@@ -914,8 +872,6 @@ impl FileTransferActivity {
}
}
/// ### filetransfer_recv_one_with_stream
///
/// Receive an `Entry` from remote using stream
fn filetransfer_recv_one_with_stream(
&mut self,
@@ -1023,8 +979,6 @@ impl FileTransferActivity {
Ok(())
}
/// ### filetransfer_recv_one_with_stream
///
/// Receive an `Entry` from remote without using stream
fn filetransfer_recv_one_wno_stream(
&mut self,
@@ -1086,8 +1040,6 @@ impl FileTransferActivity {
Ok(())
}
/// ### local_changedir
///
/// Change directory for local
pub(super) fn local_changedir(&mut self, path: &Path, push: bool) {
// Get current directory
@@ -1143,8 +1095,6 @@ impl FileTransferActivity {
}
}
/// ### download_file_as_temp
///
/// Download provided file as a temporary file
pub(super) fn download_file_as_temp(&mut self, file: &File) -> Result<PathBuf, String> {
let tmpfile: PathBuf = match self.cache.as_ref() {
@@ -1176,8 +1126,6 @@ impl FileTransferActivity {
// -- transfer sizes
/// ### get_total_transfer_size_local
///
/// Get total size of transfer for localhost
fn get_total_transfer_size_local(&mut self, entry: &Entry) -> usize {
match entry {
@@ -1201,8 +1149,6 @@ impl FileTransferActivity {
}
}
/// ### get_total_transfer_size_remote
///
/// Get total size of transfer for remote host
fn get_total_transfer_size_remote(&mut self, entry: &Entry) -> usize {
match entry {

View File

@@ -43,8 +43,6 @@ use tuirealm::{Sub, SubClause, SubEventClause};
impl FileTransferActivity {
// -- init
/// ### init
///
/// Initialize file transfer activity's view
pub(super) fn init(&mut self) {
// Mount local file explorer
@@ -106,8 +104,6 @@ impl FileTransferActivity {
// -- view
/// ### view
///
/// View gui
pub(super) fn view(&mut self) {
self.redraw = false;
@@ -303,8 +299,6 @@ impl FileTransferActivity {
// -- partials
/// ### mount_info
///
/// Mount info box
pub(super) fn mount_info<S: AsRef<str>>(&mut self, text: S) {
// Mount
@@ -320,8 +314,6 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::ErrorPopup).is_ok());
}
/// ### mount_error
///
/// Mount error box
pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) {
// Mount
@@ -337,8 +329,6 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::ErrorPopup).is_ok());
}
/// ### umount_error
///
/// Umount error message
pub(super) fn umount_error(&mut self) {
let _ = self.app.umount(&Id::ErrorPopup);
@@ -358,8 +348,6 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::FatalPopup).is_ok());
}
/// ### umount_fatal
///
/// Umount fatal error message
pub(super) fn umount_fatal(&mut self) {
let _ = self.app.umount(&Id::FatalPopup);
@@ -387,8 +375,6 @@ impl FileTransferActivity {
let _ = self.app.umount(&Id::WaitPopup);
}
/// ### mount_quit
///
/// Mount quit popup
pub(super) fn mount_quit(&mut self) {
// Protocol
@@ -404,15 +390,11 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::QuitPopup).is_ok());
}
/// ### umount_quit
///
/// Umount quit popup
pub(super) fn umount_quit(&mut self) {
let _ = self.app.umount(&Id::QuitPopup);
}
/// ### mount_disconnect
///
/// Mount disconnect popup
pub(super) fn mount_disconnect(&mut self) {
// Protocol
@@ -428,8 +410,6 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::DisconnectPopup).is_ok());
}
/// ### umount_disconnect
///
/// Umount disconnect popup
pub(super) fn umount_disconnect(&mut self) {
let _ = self.app.umount(&Id::DisconnectPopup);
@@ -735,8 +715,6 @@ impl FileTransferActivity {
assert!(self.app.active(&Id::ReplacePopup).is_ok());
}
/// ### is_radio_replace_extended
///
/// Returns whether radio replace is in "extended" mode (for many files)
pub(super) fn is_radio_replace_extended(&self) -> bool {
self.app.mounted(&Id::ReplacingFilesListPopup)
@@ -799,8 +777,6 @@ impl FileTransferActivity {
.is_ok());
}
/// ### mount_help
///
/// Mount help
pub(super) fn mount_help(&mut self) {
let key_color = self.theme().misc_keys;
@@ -852,8 +828,6 @@ impl FileTransferActivity {
.is_ok());
}
/// ### no_popup_mounted_clause
///
/// Returns a sub clause which requires that no popup is mounted in order to be satisfied
fn no_popup_mounted_clause() -> SubClause<Id> {
SubClause::And(

View File

@@ -45,28 +45,20 @@ pub enum ExitReason {
// -- Activity trait
pub trait Activity {
/// ### on_create
///
/// `on_create` is the function which must be called to initialize the activity.
/// `on_create` must initialize all the data structures used by the activity
/// Context is taken from activity manager and will be released only when activity is destroyed
fn on_create(&mut self, context: Context);
/// ### on_draw
///
/// `on_draw` is the function which draws the graphical interface.
/// This function must be called at each tick to refresh the interface
fn on_draw(&mut self);
/// ### will_umount
///
/// `will_umount` is the method which must be able to report to the activity manager, whether
/// the activity should be terminated or not.
/// If not, the call will return `None`, otherwise return`Some(ExitReason)`
fn will_umount(&self) -> Option<&ExitReason>;
/// ### on_destroy
///
/// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity.
/// This function must be called once before terminating the activity.
/// This function finally releases the context

View File

@@ -35,8 +35,6 @@ use tuirealm::tui::style::Color;
use tuirealm::{State, StateValue};
impl SetupActivity {
/// ### action_on_esc
///
/// On <ESC>, if there are changes in the configuration, the quit dialog must be shown, otherwise
/// we can exit without any problem
pub(super) fn action_on_esc(&mut self) {
@@ -47,8 +45,6 @@ impl SetupActivity {
}
}
/// ### action_save_all
///
/// Save all configurations. If current tab can load values, they will be loaded, otherwise they'll just be saved.
/// Once all the configuration has been changed, set config_changed to false
pub(super) fn action_save_all(&mut self) -> Result<(), String> {
@@ -59,8 +55,6 @@ impl SetupActivity {
Ok(())
}
/// ### action_save_config
///
/// Save configuration
fn action_save_config(&mut self) -> Result<(), String> {
// Collect input values if in setup form
@@ -70,8 +64,6 @@ impl SetupActivity {
self.save_config()
}
/// ### action_save_theme
///
/// Save configuration
fn action_save_theme(&mut self) -> Result<(), String> {
// Collect input values if in theme form
@@ -83,8 +75,6 @@ impl SetupActivity {
self.save_theme()
}
/// ### action_change_tab
///
/// Change view tab and load input values in order not to lose them
pub(super) fn action_change_tab(&mut self, new_tab: ViewLayout) -> Result<(), String> {
// load values for current tab first
@@ -100,8 +90,6 @@ impl SetupActivity {
Ok(())
}
/// ### action_reset_config
///
/// Reset configuration input fields
pub(super) fn action_reset_config(&mut self) -> Result<(), String> {
match self.reset_config_changes() {
@@ -113,8 +101,6 @@ impl SetupActivity {
}
}
/// ### action_reset_theme
///
/// Reset configuration input fields
pub(super) fn action_reset_theme(&mut self) -> Result<(), String> {
match self.reset_theme_changes() {
@@ -126,8 +112,6 @@ impl SetupActivity {
}
}
/// ### action_delete_ssh_key
///
/// delete of a ssh key
pub(super) fn action_delete_ssh_key(&mut self) {
// Get key
@@ -160,8 +144,6 @@ impl SetupActivity {
}
}
/// ### action_new_ssh_key
///
/// Create a new ssh key
pub(super) fn action_new_ssh_key(&mut self) {
// get parameters
@@ -228,8 +210,6 @@ impl SetupActivity {
}
}
/// ### set_color
///
/// Given a component and a color, save the color into the theme
pub(super) fn action_save_color(&mut self, component: IdTheme, color: Color) {
let theme: &mut Theme = self.theme_mut();
@@ -319,8 +299,6 @@ impl SetupActivity {
}
}
/// ### collect_styles
///
/// Collect values from input and put them into the theme.
/// If a component has an invalid color, returns Err(component_id)
fn collect_styles(&mut self) -> Result<(), Id> {
@@ -440,8 +418,6 @@ impl SetupActivity {
Ok(())
}
/// ### get_color
///
/// Get color from component
fn get_color(&self, component: &Id) -> Result<Color, ()> {
match self.app.state(component) {

View File

@@ -32,8 +32,6 @@ use super::SetupActivity;
use std::env;
impl SetupActivity {
/// ### save_config
///
/// Save configuration
pub(super) fn save_config(&mut self) -> Result<(), String> {
match self.config().write_config() {
@@ -42,8 +40,6 @@ impl SetupActivity {
}
}
/// ### reset_config_changes
///
/// Reset configuration changes; pratically read config from file, overwriting any change made
/// since last write action
pub(super) fn reset_config_changes(&mut self) -> Result<(), String> {
@@ -52,8 +48,6 @@ impl SetupActivity {
.map_err(|e| format!("Could not reload configuration: {}", e))
}
/// ### save_theme
///
/// Save theme to file
pub(super) fn save_theme(&mut self) -> Result<(), String> {
self.theme_provider()
@@ -61,8 +55,6 @@ impl SetupActivity {
.map_err(|e| format!("Could not save theme: {}", e))
}
/// ### reset_theme_changes
///
/// Reset changes committed to theme
pub(super) fn reset_theme_changes(&mut self) -> Result<(), String> {
self.theme_provider()
@@ -70,8 +62,6 @@ impl SetupActivity {
.map_err(|e| format!("Could not restore theme: {}", e))
}
/// ### delete_ssh_key
///
/// Delete ssh key from config cli
pub(super) fn delete_ssh_key(&mut self, host: &str, username: &str) -> Result<(), String> {
match self.config_mut().del_ssh_key(host, username) {
@@ -83,8 +73,6 @@ impl SetupActivity {
}
}
/// ### edit_ssh_key
///
/// Edit selected ssh key
pub(super) fn edit_ssh_key(&mut self, idx: usize) -> Result<(), String> {
match self.context.as_mut() {
@@ -142,8 +130,6 @@ impl SetupActivity {
}
}
/// ### add_ssh_key
///
/// Add provided ssh key to config client
pub(super) fn add_ssh_key(
&mut self,

View File

@@ -256,8 +256,6 @@ pub enum ViewLayout {
Theme,
}
/// ## SetupActivity
///
/// Setup activity states holder
pub struct SetupActivity {
app: Application<Id, Msg, NoUserEvent>,
@@ -282,15 +280,11 @@ impl SetupActivity {
}
}
/// ### context
///
/// Returns a reference to context
fn context(&self) -> &Context {
self.context.as_ref().unwrap()
}
/// ### context_mut
///
/// Returns a mutable reference to context
fn context_mut(&mut self) -> &mut Context {
self.context.as_mut().unwrap()
@@ -316,8 +310,6 @@ impl SetupActivity {
self.context_mut().theme_provider_mut()
}
/// ### config_changed
///
/// Returns whether config has changed
fn config_changed(&self) -> bool {
self.context()
@@ -326,8 +318,6 @@ impl SetupActivity {
.unwrap_or(false)
}
/// ### set_config_changed
///
/// Set value for config changed key into the store
fn set_config_changed(&mut self, changed: bool) {
self.context_mut()
@@ -337,8 +327,6 @@ impl SetupActivity {
}
impl Activity for SetupActivity {
/// ### on_create
///
/// `on_create` is the function which must be called to initialize the activity.
/// `on_create` must initialize all the data structures used by the activity
/// Context is taken from activity manager and will be released only when activity is destroyed
@@ -363,8 +351,6 @@ impl Activity for SetupActivity {
}
}
/// ### on_draw
///
/// `on_draw` is the function which draws the graphical interface.
/// This function must be called at each tick to refresh the interface
fn on_draw(&mut self) {
@@ -394,8 +380,6 @@ impl Activity for SetupActivity {
}
}
/// ### will_umount
///
/// `will_umount` is the method which must be able to report to the activity manager, whether
/// the activity should be terminated or not.
/// If not, the call will return `None`, otherwise return`Some(ExitReason)`
@@ -403,8 +387,6 @@ impl Activity for SetupActivity {
self.exit_reason.as_ref()
}
/// ### on_destroy
///
/// `on_destroy` is the function which cleans up runtime variables and data before terminating the activity.
/// This function must be called once before terminating the activity.
/// This function finally releases the context

View File

@@ -36,8 +36,6 @@ use super::{
use tuirealm::Update;
impl Update<Msg> for SetupActivity {
/// ### update
///
/// Update auth activity model based on msg
/// The function exits when returns None
fn update(&mut self, msg: Option<Msg>) -> Option<Msg> {

View File

@@ -54,8 +54,6 @@ impl SetupActivity {
}
}
/// ### view
///
/// View gui
pub(super) fn view(&mut self) {
self.redraw = false;
@@ -68,8 +66,6 @@ impl SetupActivity {
// -- mount
/// ### mount_error
///
/// Mount error box
pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) {
assert!(self
@@ -83,15 +79,11 @@ impl SetupActivity {
assert!(self.app.active(&Id::Common(IdCommon::ErrorPopup)).is_ok());
}
/// ### umount_error
///
/// Umount error message
pub(super) fn umount_error(&mut self) {
let _ = self.app.umount(&Id::Common(IdCommon::ErrorPopup));
}
/// ### mount_quit
///
/// Mount quit popup
pub(super) fn mount_quit(&mut self) {
assert!(self
@@ -105,15 +97,11 @@ impl SetupActivity {
assert!(self.app.active(&Id::Common(IdCommon::QuitPopup)).is_ok());
}
/// ### umount_quit
///
/// Umount quit
pub(super) fn umount_quit(&mut self) {
let _ = self.app.umount(&Id::Common(IdCommon::QuitPopup));
}
/// ### mount_save_popup
///
/// Mount save popup
pub(super) fn mount_save_popup(&mut self) {
assert!(self
@@ -127,15 +115,11 @@ impl SetupActivity {
assert!(self.app.active(&Id::Common(IdCommon::SavePopup)).is_ok());
}
/// ### umount_quit
///
/// Umount quit
pub(super) fn umount_save_popup(&mut self) {
let _ = self.app.umount(&Id::Common(IdCommon::SavePopup));
}
/// ### mount_help
///
/// Mount help
pub(super) fn mount_help(&mut self) {
assert!(self
@@ -149,8 +133,6 @@ impl SetupActivity {
assert!(self.app.active(&Id::Common(IdCommon::Keybindings)).is_ok());
}
/// ### umount_help
///
/// Umount help
pub(super) fn umount_help(&mut self) {
let _ = self.app.umount(&Id::Common(IdCommon::Keybindings));
@@ -180,8 +162,6 @@ impl SetupActivity {
}
}
/// ### new_app
///
/// Clean app up and remount common components and global listener
fn new_app(&mut self, layout: ViewLayout) {
self.app.umount_all();
@@ -189,8 +169,6 @@ impl SetupActivity {
self.mount_commons(layout);
}
/// ### mount_commons
///
/// Mount common components
fn mount_commons(&mut self, layout: ViewLayout) {
// Radio tab
@@ -213,8 +191,6 @@ impl SetupActivity {
.is_ok());
}
/// ### mount_global_listener
///
/// Mount global listener
fn mount_global_listener(&mut self) {
assert!(self
@@ -263,8 +239,6 @@ impl SetupActivity {
.is_ok());
}
/// ### no_popup_mounted_clause
///
/// Returns a sub clause which requires that no popup is mounted in order to be satisfied
fn no_popup_mounted_clause() -> SubClause<Id> {
SubClause::And(

View File

@@ -40,8 +40,6 @@ use tuirealm::{State, StateValue};
impl SetupActivity {
// -- view
/// ### init_setup
///
/// Initialize setup view
pub(super) fn init_setup(&mut self) {
// Init view (and mount commons)
@@ -153,8 +151,6 @@ impl SetupActivity {
self.context = Some(ctx);
}
/// ### load_input_values
///
/// Load values from configuration into input fields
pub(crate) fn load_input_values(&mut self) {
// Text editor
@@ -267,8 +263,6 @@ impl SetupActivity {
.is_ok());
}
/// ### collect_input_values
///
/// Collect values from input and put them into the configuration
pub(crate) fn collect_input_values(&mut self) {
if let Ok(State::One(StateValue::String(editor))) =

View File

@@ -37,8 +37,6 @@ use tuirealm::tui::widgets::Clear;
impl SetupActivity {
// -- view
/// ### init_ssh_keys
///
/// Initialize ssh keys view
pub(super) fn init_ssh_keys(&mut self) {
// Init view (and mount commons)
@@ -99,8 +97,6 @@ impl SetupActivity {
// -- mount
/// ### mount_del_ssh_key
///
/// Mount delete ssh key component
pub(crate) fn mount_del_ssh_key(&mut self) {
assert!(self
@@ -114,15 +110,11 @@ impl SetupActivity {
assert!(self.app.active(&Id::Ssh(IdSsh::DelSshKeyPopup)).is_ok());
}
/// ### umount_del_ssh_key
///
/// Umount delete ssh key
pub(crate) fn umount_del_ssh_key(&mut self) {
let _ = self.app.umount(&Id::Ssh(IdSsh::DelSshKeyPopup));
}
/// ### mount_new_ssh_key
///
/// Mount new ssh key prompt
pub(crate) fn mount_new_ssh_key(&mut self) {
assert!(self
@@ -144,16 +136,12 @@ impl SetupActivity {
assert!(self.app.active(&Id::Ssh(IdSsh::SshHost)).is_ok());
}
/// ### umount_new_ssh_key
///
/// Umount new ssh key prompt
pub(crate) fn umount_new_ssh_key(&mut self) {
let _ = self.app.umount(&Id::Ssh(IdSsh::SshUsername));
let _ = self.app.umount(&Id::Ssh(IdSsh::SshHost));
}
/// ### reload_ssh_keys
///
/// Reload ssh keys
pub(crate) fn reload_ssh_keys(&mut self) {
let keys: Vec<String> = self

View File

@@ -35,8 +35,6 @@ use tuirealm::tui::layout::{Constraint, Direction, Layout};
impl SetupActivity {
// -- view
/// ### init_theme
///
/// Initialize thene view
pub(super) fn init_theme(&mut self) {
// Init view (and mount commons)
@@ -298,8 +296,6 @@ impl SetupActivity {
.is_ok());
}
/// ### load_styles
///
/// Load values from theme into input fields
pub(crate) fn load_styles(&mut self) {
let theme: Theme = self.theme().clone();

View File

@@ -33,8 +33,6 @@ use crate::system::theme_provider::ThemeProvider;
use tuirealm::terminal::TerminalBridge;
/// ## Context
///
/// Context holds data structures shared by the activities
pub struct Context {
ft_params: Option<FileTransferParams>,
@@ -46,8 +44,6 @@ pub struct Context {
}
impl Context {
/// ### new
///
/// Instantiates a new Context
pub fn new(
config_client: ConfigClient,
@@ -106,15 +102,11 @@ impl Context {
// -- error
/// ### set_error
///
/// Set context error
pub fn set_error(&mut self, err: String) {
self.error = Some(err);
}
/// ### error
///
/// Get error message and remove it from the context
pub fn error(&mut self) -> Option<String> {
self.error.take()

View File

@@ -31,8 +31,6 @@ use std::collections::HashMap;
// -- store state
/// ## StoreState
///
/// Store state describes a value in the store
#[allow(dead_code)]
enum StoreState {
@@ -46,8 +44,6 @@ enum StoreState {
// -- store
/// ## Store
///
/// Store represent the context store
/// The store is a key-value hash map. Each key must be unique
/// To each key a `StoreState` is assigned
@@ -57,8 +53,6 @@ pub(crate) struct Store {
#[allow(dead_code)]
impl Store {
/// ### init
///
/// Initialize a new Store
pub fn init() -> Self {
Store {
@@ -68,8 +62,6 @@ impl Store {
// -- getters
/// ### get_string
///
/// Get string from store
pub fn get_string(&self, key: &str) -> Option<&str> {
match self.store.get(key) {
@@ -78,8 +70,6 @@ impl Store {
}
}
/// ### get_signed
///
/// Get signed from store
pub fn get_signed(&self, key: &str) -> Option<isize> {
match self.store.get(key) {
@@ -88,8 +78,6 @@ impl Store {
}
}
/// ### get_unsigned
///
/// Get unsigned from store
pub fn get_unsigned(&self, key: &str) -> Option<usize> {
match self.store.get(key) {
@@ -98,8 +86,6 @@ impl Store {
}
}
/// ### get_float
///
/// get float from store
pub fn get_float(&self, key: &str) -> Option<f64> {
match self.store.get(key) {
@@ -108,8 +94,6 @@ impl Store {
}
}
/// ### get_boolean
///
/// get boolean from store
pub fn get_boolean(&self, key: &str) -> Option<bool> {
match self.store.get(key) {
@@ -118,8 +102,6 @@ impl Store {
}
}
/// ### isset
///
/// Check if a state is set in the store
pub fn isset(&self, key: &str) -> bool {
self.store.get(key).is_some()
@@ -127,44 +109,32 @@ impl Store {
// -- setters
/// ### set_string
///
/// Set string into the store
pub fn set_string(&mut self, key: &str, val: String) {
self.store.insert(key.to_string(), StoreState::Str(val));
}
/// ### set_signed
///
/// Set signed number
pub fn set_signed(&mut self, key: &str, val: isize) {
self.store.insert(key.to_string(), StoreState::Signed(val));
}
/// ### set_signed
///
/// Set unsigned number
pub fn set_unsigned(&mut self, key: &str, val: usize) {
self.store
.insert(key.to_string(), StoreState::Unsigned(val));
}
/// ### set_float
///
/// Set floating point number
pub fn set_float(&mut self, key: &str, val: f64) {
self.store.insert(key.to_string(), StoreState::Float(val));
}
/// ### set_boolean
///
/// Set boolean
pub fn set_boolean(&mut self, key: &str, val: bool) {
self.store.insert(key.to_string(), StoreState::Boolean(val));
}
/// ### set
///
/// Set a key as a flag; has no value
pub fn set(&mut self, key: &str) {
self.store.insert(key.to_string(), StoreState::Flag);
@@ -172,8 +142,6 @@ impl Store {
// -- Consumers
/// ### take_string
///
/// Take string from store
pub fn take_string(&mut self, key: &str) -> Option<String> {
match self.store.remove(key) {
@@ -182,8 +150,6 @@ impl Store {
}
}
/// ### take_signed
///
/// Take signed from store
pub fn take_signed(&mut self, key: &str) -> Option<isize> {
match self.store.remove(key) {
@@ -192,8 +158,6 @@ impl Store {
}
}
/// ### take_unsigned
///
/// Take unsigned from store
pub fn take_unsigned(&mut self, key: &str) -> Option<usize> {
match self.store.remove(key) {
@@ -202,8 +166,6 @@ impl Store {
}
}
/// ### get_float
///
/// Take float from store
pub fn take_float(&mut self, key: &str) -> Option<f64> {
match self.store.remove(key) {
@@ -212,8 +174,6 @@ impl Store {
}
}
/// ### get_boolean
///
/// Take boolean from store
pub fn take_boolean(&mut self, key: &str) -> Option<bool> {
match self.store.remove(key) {