We now mount fs!

This commit is contained in:
nelle 2024-02-16 19:58:02 -07:00
parent 72b0ff1fe7
commit 37b9cac605

View file

@ -9,7 +9,7 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
TWindow(parent, "Login", 0, 0, 36, 19, flags) { TWindow(parent, "Login", 0, 0, 36, 19, flags) {
constructor(parent: TApplication) : this(parent, CENTERED) constructor(parent: TApplication) : this(parent, CENTERED)
var loginField = addField(CENTERED + 5, CENTERED - 1, 16, false, "", var loginField = addPasswordField(CENTERED + 5, CENTERED - 1, 16, false, "",
// enterAction - function to call when enter key is pressed // enterAction - function to call when enter key is pressed
object : TAction() { object : TAction() {
override fun DO() { override fun DO() {
@ -24,22 +24,7 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
} }
); );
var passField = addPasswordField(CENTERED + 5, CENTERED + 3, 16, false, "", var serverField = addPasswordField(CENTERED + 5, CENTERED + 3, 16, false, "",
// enterAction - function to call when enter key is pressed
object : TAction() {
override fun DO() {
loginActivity()
}
},
// updateAction - function to call when the text is updated
object : TAction() {
override fun DO() {
return
}
}
);
var serverField = addField(CENTERED + 5, CENTERED + 7, 16, false, "",
// enterAction - function to call when enter key is pressed // enterAction - function to call when enter key is pressed
object : TAction() { object : TAction() {
override fun DO() { override fun DO() {
@ -56,18 +41,28 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
fun loginActivity() { fun loginActivity() {
var usernameDetail = loginField.text var usernameDetail = loginField.text
var passwordDetail = passField.text //TODO: Hash this ples
var serverDetail = serverField.text var serverDetail = serverField.text
var remoteCommand = "echo hello" //TODO: For windows, instead of ssh pass?? https://github.com/PowerShell/Win32-OpenSSH/issues/1943
//TODO: For windows, instead of ssh pass?? https://github.com/PowerShell/Win32-OpenSSH/issues/1943 and https://github.com/winfsp/sshfs-win for sshfs? // and https://github.com/winfsp/sshfs-win for sshfs?
val loginProcess = ProcessBuilder( // and https://microsoft.github.io/Git-Credential-Manager-for-Windows/Docs/Askpass.html for askpass????
"sshpass", "-p", "$passwordDetail", "ssh", "$usernameDetail@$serverDetail", remoteCommand) //openssh-askpass as well
.redirectOutput(ProcessBuilder.Redirect.INHERIT) val createMntPnt =
.redirectError(ProcessBuilder.Redirect.INHERIT) ProcessBuilder("mkdir", "/tmp/osda_mount")
.start() .redirectOutput(ProcessBuilder.Redirect.INHERIT)
.waitFor() .redirectError(ProcessBuilder.Redirect.INHERIT)
.start()
.waitFor()
val remoteMount =
ProcessBuilder(
"sshfs",
"$usernameDetail@$serverDetail:/home/$usernameDetail",
"/tmp/osda_mount",
"-v"
)
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT)
.start().waitFor()
} }
init { init {
setLayoutManager( setLayoutManager(
StretchLayoutManager( StretchLayoutManager(
@ -76,15 +71,7 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
) )
) )
addButton("Back...", CENTERED + 8, CENTERED + 11, addButton("Login", CENTERED + 9, CENTERED + 6,
object : TAction() {
override fun DO() {
TODO("Instead of full program exit, make it close the login window")
}
}
)
addButton("Login", CENTERED + 9, CENTERED + 9,
object : TAction() { object : TAction() {
override fun DO() { override fun DO() {
loginActivity() loginActivity()
@ -92,13 +79,18 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
} }
) )
//Password addButton("Back...", CENTERED + 8, CENTERED + 8,
addLabel("Password", CENTERED + 9, CENTERED + 1) object : TAction() {
override fun DO() {
TODO("Instead of full program exit, make it close the login window")
}
}
)
//Login //Login
addLabel("Username", CENTERED + 9, CENTERED - 3) addLabel("Username", CENTERED + 9, CENTERED - 3)
// Server // Server
addLabel("Server", CENTERED + 10, CENTERED + 5) addLabel("Server", CENTERED + 10, CENTERED + 1)
} }
} }