From 8cc0dc57b6e2a46204712c8cd97d8d519792bd63 Mon Sep 17 00:00:00 2001 From: limepotato Date: Sat, 17 Feb 2024 04:04:25 -0700 Subject: [PATCH] Cleanup --- .../Application.kt | 7 +- .../{DataAccessor => dataAccessor}/main.kt | 3 +- .../windows/LoginWindow.kt | 71 ++++++++++--------- .../windows/WelcomeWindow.kt | 15 ++-- 4 files changed, 46 insertions(+), 50 deletions(-) rename src/main/kotlin/org/bm00/{DataAccessor => dataAccessor}/Application.kt (88%) rename src/main/kotlin/org/bm00/{DataAccessor => dataAccessor}/main.kt (66%) rename src/main/kotlin/org/bm00/{DataAccessor => dataAccessor}/windows/LoginWindow.kt (91%) rename src/main/kotlin/org/bm00/{DataAccessor => dataAccessor}/windows/WelcomeWindow.kt (87%) diff --git a/src/main/kotlin/org/bm00/DataAccessor/Application.kt b/src/main/kotlin/org/bm00/dataAccessor/Application.kt similarity index 88% rename from src/main/kotlin/org/bm00/DataAccessor/Application.kt rename to src/main/kotlin/org/bm00/dataAccessor/Application.kt index 55e8a87..52a0f9f 100644 --- a/src/main/kotlin/org/bm00/DataAccessor/Application.kt +++ b/src/main/kotlin/org/bm00/dataAccessor/Application.kt @@ -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") -> { diff --git a/src/main/kotlin/org/bm00/DataAccessor/main.kt b/src/main/kotlin/org/bm00/dataAccessor/main.kt similarity index 66% rename from src/main/kotlin/org/bm00/DataAccessor/main.kt rename to src/main/kotlin/org/bm00/dataAccessor/main.kt index d442b4a..5259a00 100644 --- a/src/main/kotlin/org/bm00/DataAccessor/main.kt +++ b/src/main/kotlin/org/bm00/dataAccessor/main.kt @@ -1,6 +1,5 @@ -package org.bm00.DataAccessor +package org.bm00.dataAccessor -import jexer.TApplication.BackendType import java.util.* @Throws(Exception::class) diff --git a/src/main/kotlin/org/bm00/DataAccessor/windows/LoginWindow.kt b/src/main/kotlin/org/bm00/dataAccessor/windows/LoginWindow.kt similarity index 91% rename from src/main/kotlin/org/bm00/DataAccessor/windows/LoginWindow.kt rename to src/main/kotlin/org/bm00/dataAccessor/windows/LoginWindow.kt index f17aec9..4c64d58 100644 --- a/src/main/kotlin/org/bm00/DataAccessor/windows/LoginWindow.kt +++ b/src/main/kotlin/org/bm00/dataAccessor/windows/LoginWindow.kt @@ -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) diff --git a/src/main/kotlin/org/bm00/DataAccessor/windows/WelcomeWindow.kt b/src/main/kotlin/org/bm00/dataAccessor/windows/WelcomeWindow.kt similarity index 87% rename from src/main/kotlin/org/bm00/DataAccessor/windows/WelcomeWindow.kt rename to src/main/kotlin/org/bm00/dataAccessor/windows/WelcomeWindow.kt index bf83e45..611e06c 100644 --- a/src/main/kotlin/org/bm00/DataAccessor/windows/WelcomeWindow.kt +++ b/src/main/kotlin/org/bm00/dataAccessor/windows/WelcomeWindow.kt @@ -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)