From 190050915e8a6f83feeeb7795cc17d97b9160bde Mon Sep 17 00:00:00 2001 From: limepotato Date: Mon, 19 Feb 2024 01:31:27 -0700 Subject: [PATCH] Allow user to set remote directory --- .../kotRemote/jexerWindow/LoginWindow.kt | 27 +++++++++++++------ .../kotRemote/jexerWindow/WelcomeWindow.kt | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/xyz/limepot/kotRemote/jexerWindow/LoginWindow.kt b/src/main/kotlin/xyz/limepot/kotRemote/jexerWindow/LoginWindow.kt index 992c4ba..196c3da 100644 --- a/src/main/kotlin/xyz/limepot/kotRemote/jexerWindow/LoginWindow.kt +++ b/src/main/kotlin/xyz/limepot/kotRemote/jexerWindow/LoginWindow.kt @@ -91,8 +91,19 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) : //Called if on Linux and the login has been initiated fun loginActivityLinux() { - var usernameDetail = loginField.text - var serverDetail = serverField.text + val usernameDetail = loginField.text + val serverDetail = serverField.text + val remoteDir = inputBox("Remote Directory", "What directory on the server would you like to mount?") + val remoteDirDetail = remoteDir.text + /* Have to figure out a way to unmount this. + val localDir = if (remoteDir.isOk) { + inputBox("Local Directory", "What directory on the local machine would you like to mount to?") + } + else { + return + } + val localDirDetail = localDir.text + */ // Create directory using bash ProcessBuilder("mkdir", "/tmp/kotRemote_mount") .redirectOutput(ProcessBuilder.Redirect.INHERIT) @@ -102,7 +113,7 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) : // mount remote directory via sshfs ProcessBuilder( "sshfs", - "$usernameDetail@$serverDetail:/home/$usernameDetail", + "$usernameDetail@$serverDetail:$remoteDirDetail", "/tmp/kotRemote_mount" ) .redirectOutput(ProcessBuilder.Redirect.INHERIT) @@ -113,18 +124,18 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) : //Called if on Windows and the login has been initiated fun loginActivityWindows() { - var usernameDetail = loginField.text - var serverDetail = serverField.text + val usernameDetail = loginField.text + val serverDetail = serverField.text // Due to the way sshfs-win works, we will additionally ask the user for a password - var passwordBox = inputBox("Password", "Please enter your remote password") - var passwordDetail = passwordBox.text + val passwordBox = inputBox("Password", "Please enter your remote password") + val passwordDetail = passwordBox.text // use the windows network mount command to mount via sshfs-win ProcessBuilder( "net", "use", "O:", "\\\\sshfs\\$usernameDetail@$serverDetail:/home/$usernameDetail", - "$passwordDetail" + passwordDetail ) .redirectOutput(ProcessBuilder.Redirect.INHERIT) .redirectError(ProcessBuilder.Redirect.INHERIT) diff --git a/src/main/kotlin/xyz/limepot/kotRemote/jexerWindow/WelcomeWindow.kt b/src/main/kotlin/xyz/limepot/kotRemote/jexerWindow/WelcomeWindow.kt index 109ab9a..6773ad1 100644 --- a/src/main/kotlin/xyz/limepot/kotRemote/jexerWindow/WelcomeWindow.kt +++ b/src/main/kotlin/xyz/limepot/kotRemote/jexerWindow/WelcomeWindow.kt @@ -22,7 +22,7 @@ class WelcomeWindow private constructor(parent: TApplication, flags: Int) : ) // Close program, after detecting OS and unmounting the filesystem if necessary. - addButton("Exit...", CENTERED + 28, CENTERED - 2, + val exitButton = addButton("Exit...", CENTERED + 28, CENTERED - 2, object : TAction() { override fun DO() { if (xyz.limepot.kotRemote.osName == "LINUX") {