This commit is contained in:
nelle 2024-02-17 04:04:25 -07:00
parent 6b5076eea5
commit 8cc0dc57b6
4 changed files with 46 additions and 50 deletions

View file

@ -1,8 +1,7 @@
package org.bm00.DataAccessor
package org.bm00.dataAccessor
import jexer.TApplication
import jexer.demos.DemoApplication
import org.bm00.DataAccessor.windows.WelcomeWindow
import org.bm00.dataAccessor.windows.WelcomeWindow
import java.util.*
//// OS CHECKER ////
@ -11,7 +10,7 @@ enum class OS {
}
fun getOS(): OS? {
val isJexer = System.getProperty("jexer.Swing")
//val isJexer = System.getProperty("jexer.Swing")
val os = System.getProperty("os.name").lowercase(Locale.getDefault())
return when {
os.contains("win") -> {

View file

@ -1,6 +1,5 @@
package org.bm00.DataAccessor
package org.bm00.dataAccessor
import jexer.TApplication.BackendType
import java.util.*
@Throws(Exception::class)

View file

@ -1,10 +1,10 @@
package org.bm00.DataAccessor.windows
package org.bm00.dataAccessor.windows
import jexer.TAction
import jexer.TApplication
import jexer.TWindow
import jexer.layout.StretchLayoutManager
import org.bm00.DataAccessor.osName
import org.bm00.dataAccessor.osName
import java.util.*
//// OS CHECKER ////
@ -13,7 +13,7 @@ enum class OS {
}
fun getOS(): OS? {
val isJexer = System.getProperty("jexer.Swing")
System.getProperty("jexer.Swing")
val os = System.getProperty("os.name").lowercase(Locale.getDefault())
return when {
os.contains("win") -> {
@ -39,11 +39,38 @@ val osName =
}
//// OS CHECKER ////
const val windowWidth = 36
const val windowHeight = 19
const val textFieldWidth = 16
class LoginWindow private constructor(parent: TApplication, flags: Int) :
TWindow(parent, "Login", 0, 0, 36, 19, flags) {
TWindow(parent, "Login", 0, 0, windowWidth, windowHeight, flags) {
constructor(parent: TApplication) : this(parent, CENTERED)
var loginField = addPasswordField(CENTERED + 5, CENTERED - 1, 16, false, "",
var loginField = addPasswordField(CENTERED + 5, CENTERED - 1, textFieldWidth, false, "",
// enterAction - function to call a when an enter key is pressed
object : TAction() {
override fun DO() {
if (osName == "LINUX") {
loginActivityLinux()
}
else if (osName == "WINDOWS") {
loginActivityWindows()
}
else {
throw Exception ("The Operating-System you are on is not recognized, and thus this program cannot be run!")
}
}
},
// updateAction - function to call when the text is updated
object : TAction() {
override fun DO() {
return
}
}
)
var serverField = addPasswordField(CENTERED + 5, CENTERED + 3, textFieldWidth, false, "",
// enterAction - function to call when enter key is pressed
object : TAction() {
override fun DO() {
@ -64,31 +91,7 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
return
}
}
);
var serverField = addPasswordField(CENTERED + 5, CENTERED + 3, 16, false, "",
// enterAction - function to call when enter key is pressed
object : TAction() {
override fun DO() {
if (osName == "LINUX") {
loginActivityLinux()
}
else if (osName == "WINDOWS") {
loginActivityWindows()
}
else {
throw Exception ("The Operating-System you are on is not recognized, and thus this program cannot be run!")
}
}
},
// updateAction - function to call when the text is updated
object : TAction() {
override fun DO() {
return
}
}
);
)
//Called if on Linux and the login has been initiated
fun loginActivityLinux() {
@ -134,11 +137,9 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
}
init {
setLayoutManager(
StretchLayoutManager(
width - 2,
height - 2
)
layoutManager = StretchLayoutManager(
width - 2,
height - 2
)
var sharedCheck = addCheckBox( CENTERED + 4, CENTERED + 5, "Shared Folder?",false)

View file

@ -1,20 +1,17 @@
package org.bm00.DataAccessor.windows
package org.bm00.dataAccessor.windows
import jexer.TAction
import jexer.TApplication
import jexer.TWindow
import jexer.layout.StretchLayoutManager
import org.bm00.DataAccessor.main
class WelcomeWindow private constructor(parent: TApplication, flags: Int) :
TWindow(parent, "O.S.D.A.", 0, 0, 46, 10, flags) {
constructor(parent: TApplication) : this(parent, CENTERED)
init {
setLayoutManager(
StretchLayoutManager(
width - 2,
height - 2
)
layoutManager = StretchLayoutManager(
width - 2,
height - 2
)
addLabel("Welcome to", CENTERED + 13, CENTERED - 4)
addLabel("The ORG-NAME-WIP Secure Data Accessor", CENTERED, CENTERED - 3)
@ -30,7 +27,7 @@ class WelcomeWindow private constructor(parent: TApplication, flags: Int) :
addButton("Exit...", CENTERED + 28, CENTERED,
object : TAction() {
override fun DO() {
if (org.bm00.DataAccessor.osName == "LINUX") {
if (org.bm00.dataAccessor.osName == "LINUX") {
ProcessBuilder("umount", "/tmp/osda_mount")
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT)
@ -38,7 +35,7 @@ class WelcomeWindow private constructor(parent: TApplication, flags: Int) :
.waitFor()
System.exit(0)
}
else if (org.bm00.DataAccessor.osName == "WINDOWS") {
else if (org.bm00.dataAccessor.osName == "WINDOWS") {
ProcessBuilder("net", "use", "O:", "/delete")
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT)