Show error message when pairing file is missing (#118)

* Show alert on startup error

* Call super to load normal view
This commit is contained in:
Jackson Coxson
2022-11-13 17:40:33 -08:00
committed by GitHub
parent 84e2faf8a8
commit eb23e5365f
2 changed files with 17 additions and 15 deletions

View File

@@ -42,14 +42,21 @@ class LaunchViewController: RSTLaunchViewController
self.destinationViewController = self.storyboard!.instantiateViewController(withIdentifier: "tabBarController") as! TabBarController
}
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
start_em_proxy(bind_addr: Consts.Proxy.serverURL)
guard let pf = fetchPairingFile() else {
displayError("ALTPairingFile not found.")
displayError("Device pairing file not found.")
return
}
set_usbmuxd_socket()
start_minimuxer(pairing_file: pf)
let res = start_minimuxer(pairing_file: pf)
if res != 0 {
displayError("minimuxer failed to start. Incorrect arguments were passed.")
}
auto_mount_dev_image()
}
@@ -77,17 +84,12 @@ class LaunchViewController: RSTLaunchViewController
}
func displayError(_ msg: String) {
let label = UILabel()
label.text = msg
label.textColor = .refreshRed
label.sizeToFit()
self.view.addSubview(label)
NSLayoutConstraint.activate([
label.centerXAnchor.constraint(equalTo: view.centerXAnchor),
label.centerYAnchor.constraint(equalTo: view.centerYAnchor)
])
print(msg)
// Create a new alert
let dialogMessage = UIAlertController(title: "Error launching SideStore", message: msg, preferredStyle: .alert)
// Present alert to user
self.present(dialogMessage, animated: true, completion: nil)
}
}

View File

@@ -12,12 +12,12 @@ public enum Uhoh: Error {
case Bad(code: Int32)
}
public func start_minimuxer(pairing_file: String) {
public func start_minimuxer(pairing_file: String) -> Int32 {
let pf = NSString(string: pairing_file)
let pf_pointer = UnsafeMutablePointer<CChar>(mutating: pf.utf8String)
let u = NSString(string: getDocumentsDirectory().absoluteString)
let u_ptr = UnsafeMutablePointer<CChar>(mutating: u.utf8String)
minimuxer_c_start(pf_pointer, u_ptr)
return minimuxer_c_start(pf_pointer, u_ptr)
}
public func set_usbmuxd_socket() {