forked from MeloNX/MeloNX
Make DRM Check be a prompt
This commit is contained in:
parent
209d0f1a15
commit
f55d596688
Binary file not shown.
@ -4,37 +4,6 @@
|
||||
type = "1"
|
||||
version = "2.0">
|
||||
<Breakpoints>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "1F3099D0-0456-4AD5-8EA1-52BABAF2AA89"
|
||||
shouldBeEnabled = "No"
|
||||
nameForDebugger = "Ignore-SIGUSR"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "Yes"
|
||||
filePath = "MeloNX/MeloNXApp.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "21"
|
||||
endingLineNumber = "21"
|
||||
landmarkName = "body"
|
||||
landmarkType = "24">
|
||||
<Actions>
|
||||
<BreakpointActionProxy
|
||||
ActionExtensionID = "Xcode.BreakpointAction.DebuggerCommand">
|
||||
<ActionContent
|
||||
consoleCommand = "process handle SIGUSR1 -s false -n false">
|
||||
</ActionContent>
|
||||
</BreakpointActionProxy>
|
||||
<BreakpointActionProxy
|
||||
ActionExtensionID = "Xcode.BreakpointAction.DebuggerCommand">
|
||||
<ActionContent
|
||||
consoleCommand = "process handle SIGBUS -s false -n false">
|
||||
</ActionContent>
|
||||
</BreakpointActionProxy>
|
||||
</Actions>
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
|
@ -6,28 +6,88 @@
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
@main
|
||||
struct MeloNXApp: App {
|
||||
|
||||
@AppStorage("showeddrmcheck") var showed = false
|
||||
|
||||
init() {
|
||||
DispatchQueue.main.async {
|
||||
DispatchQueue.main.async { [self] in
|
||||
// drmcheck()
|
||||
if showed {
|
||||
drmcheck() { bool in
|
||||
if bool {
|
||||
print("Yippee")
|
||||
} else {
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
showAlert()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
if showed {
|
||||
ContentView()
|
||||
} else {
|
||||
HStack {
|
||||
Text("Loading...")
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func showAlert() {
|
||||
// Create the alert controller
|
||||
if let mainWindow = UIApplication.shared.windows.last {
|
||||
let alertController = UIAlertController(title: "Enter license", message: "Enter license key:", preferredStyle: .alert)
|
||||
|
||||
// Add a text field to the alert
|
||||
alertController.addTextField { textField in
|
||||
textField.placeholder = "Enter key here"
|
||||
}
|
||||
|
||||
// Add the "OK" action
|
||||
let okAction = UIAlertAction(title: "OK", style: .default) { _ in
|
||||
// Get the text entered in the text field
|
||||
if let textField = alertController.textFields?.first, let enteredText = textField.text {
|
||||
print("Entered text: \(enteredText)")
|
||||
UserDefaults.standard.set(enteredText, forKey: "MeloDRMID")
|
||||
drmcheck() { bool in
|
||||
if bool {
|
||||
showed = true
|
||||
} else {
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
alertController.addAction(okAction)
|
||||
|
||||
// Add a "Cancel" action
|
||||
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
|
||||
alertController.addAction(cancelAction)
|
||||
|
||||
// Present the alert
|
||||
mainWindow.rootViewController!.present(alertController, animated: true, completion: nil)
|
||||
} else {
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func drmcheck() {
|
||||
func drmcheck(completion: @escaping (Bool) -> Void) {
|
||||
if let deviceid = UIDevice.current.identifierForVendor?.uuidString, let base64device = deviceid.data(using: .utf8)?.base64EncodedString() {
|
||||
if let value = Bundle.main.infoDictionary?["MeloID"] as? String {
|
||||
if let value = UserDefaults.standard.string(forKey: "MeloDRMID") {
|
||||
if let url = URL(string: "https://mx.stossy11.com/auth/\(value)/\(base64device)") {
|
||||
print(url)
|
||||
// Create a URLSession
|
||||
let session = URLSession.shared
|
||||
|
||||
@ -41,10 +101,12 @@ func drmcheck() {
|
||||
// Check response and data
|
||||
if let response = response as? HTTPURLResponse, response.statusCode == 200 {
|
||||
print("Successfully Recieved API Data")
|
||||
completion(true)
|
||||
} else if let response = response as? HTTPURLResponse, response.statusCode == 201 {
|
||||
print("Successfully Created Auth UUID")
|
||||
completion(true)
|
||||
} else {
|
||||
exit(0)
|
||||
completion(false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,10 +114,10 @@ func drmcheck() {
|
||||
task.resume()
|
||||
}
|
||||
} else {
|
||||
exit(0)
|
||||
completion(false)
|
||||
}
|
||||
} else {
|
||||
exit(0)
|
||||
completion(false)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user