mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
* Change error from Swift.Error to NSError
* Adds ResultOperation.localizedFailure
* Finish Riley's monster commit
3b38d725d7
May the Gods have mercy on my soul.
* Fix format strings I broke
* Include "Enable JIT" errors in Error Log
* Fix minimuxer status checking
* [skip ci] Update the no wifi message to include VPN
* Opens Error Log when tapping ToastView
* Fixes Error Log context menu covering cell content
* Fixes Error Log context menu appearing while scrolling
* Fixes incorrect Search FAQ URL
* Fix Error Log showing UIAlertController on iOS 14+
* Fix Error Log not showing UIAlertController on iOS <=13
* Fix wrong color in AuthenticationViewController
* Fix typo
* Fixes logging non-AltServerErrors as AltServerError.underlyingError
* Limits quitting other AltStore/SideStore processes to database migrations
* Skips logging cancelled errors
* Replaces StoreApp.latestVersion with latestSupportedVersion + latestAvailableVersion
We now store the latest supported version as a relationship on StoreApp, rather than the latest available version. This allows us to reference the latest supported version in predicates and sort descriptors.
However, we kept the underlying Core Data property name the same to avoid extra migration.
* Conforms OperatingSystemVersion to Comparable
* Parses AppVersion.minOSVersion/maxOSVersion from source JSON
* Supports non-NSManagedObjects for @Managed properties
This allows us to use @Managed with properties that may or may not be NSManagedObjects at runtime (e.g. protocols). If they are, Managed will keep strong reference to context like before.
* Supports optional @Managed properties
* Conforms AppVersion to AppProtocol
* Verifies min/max OS version before downloading app + asks user to download older app version if necessary
* Improves error message when file does not exist at AppVersion.downloadURL
* Removes unnecessary StoreApp convenience properties
* Removes unnecessary StoreApp convenience properties as well as fix other issues
* Remove Settings bundle, add SwiftUI view instead
Fix refresh all shortcut intent
* Update AuthenticationOperation.swift
Signed-off-by: June Park <rjp2030@outlook.com>
* Fix build issues given by develop
* Add availability check to fix CI build(?)
* If it's gonna be that way...
---------
Signed-off-by: June Park <rjp2030@outlook.com>
Co-authored-by: nythepegasus <nythepegasus84@gmail.com>
Co-authored-by: Riley Testut <riley@rileytestut.com>
Co-authored-by: ny <me@nythepegas.us>
156 lines
5.4 KiB
Swift
156 lines
5.4 KiB
Swift
//
|
|
// EnableJITOperation.swift
|
|
// EnableJITOperation
|
|
//
|
|
// Created by Riley Testut on 9/1/21.
|
|
// Copyright © 2021 Riley Testut. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import Combine
|
|
import minimuxer
|
|
import UniformTypeIdentifiers
|
|
|
|
import AltStoreCore
|
|
|
|
enum SideJITServerErrorType: Error {
|
|
case invalidURL
|
|
case errorConnecting
|
|
case deviceNotFound
|
|
case other(String)
|
|
}
|
|
|
|
@available(iOS 14, *)
|
|
protocol EnableJITContext
|
|
{
|
|
var installedApp: InstalledApp? { get }
|
|
|
|
var error: Error? { get }
|
|
}
|
|
|
|
@available(iOS 14, *)
|
|
final class EnableJITOperation<Context: EnableJITContext>: ResultOperation<Void>
|
|
{
|
|
let context: Context
|
|
|
|
private var cancellable: AnyCancellable?
|
|
|
|
init(context: Context)
|
|
{
|
|
self.context = context
|
|
}
|
|
|
|
override func main()
|
|
{
|
|
super.main()
|
|
|
|
if let error = self.context.error
|
|
{
|
|
self.finish(.failure(error))
|
|
return
|
|
}
|
|
|
|
guard let installedApp = self.context.installedApp else { return self.finish(.failure(OperationError.invalidParameters)) }
|
|
if #available(iOS 17, *) {
|
|
let sideJITenabled = UserDefaults.standard.sidejitenable
|
|
let SideJITIP = UserDefaults.standard.textInputSideJITServerurl ?? ""
|
|
|
|
if sideJITenabled {
|
|
installedApp.managedObjectContext?.perform {
|
|
EnableJITSideJITServer(serverurl: SideJITIP, installedapp: installedApp) { result in
|
|
switch result {
|
|
case .failure(let error):
|
|
switch error {
|
|
case .invalidURL, .errorConnecting:
|
|
self.finish(.failure(OperationError.unableToConnectSideJIT))
|
|
case .deviceNotFound:
|
|
self.finish(.failure(OperationError.unableToRespondSideJITDevice))
|
|
case .other(let message):
|
|
if let startRange = message.range(of: "<p>"),
|
|
let endRange = message.range(of: "</p>", range: startRange.upperBound..<message.endIndex) {
|
|
let pContent = message[startRange.upperBound..<endRange.lowerBound]
|
|
self.finish(.failure(OperationError.SideJITIssue(error: String(pContent))))
|
|
print(message + " + " + String(pContent))
|
|
} else {
|
|
print(message)
|
|
self.finish(.failure(OperationError.SideJITIssue(error: message)))
|
|
}
|
|
}
|
|
case .success():
|
|
self.finish(.success(()))
|
|
print("Thank you for using this, it was made by Stossy11 and tested by trolley or sniper1239408")
|
|
}
|
|
}
|
|
return
|
|
}
|
|
}
|
|
} else {
|
|
installedApp.managedObjectContext?.perform {
|
|
var retries = 3
|
|
while (retries > 0){
|
|
do {
|
|
try debug_app(installedApp.resignedBundleIdentifier)
|
|
self.finish(.success(()))
|
|
retries = 0
|
|
} catch {
|
|
retries -= 1
|
|
if (retries <= 0){
|
|
self.finish(.failure(error))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@available(iOS 17, *)
|
|
func EnableJITSideJITServer(serverurl: String, installedapp: InstalledApp, completion: @escaping (Result<Void, SideJITServerErrorType>) -> Void) {
|
|
guard let udid = fetch_udid()?.toString() else {
|
|
completion(.failure(.other("Unable to get UDID")))
|
|
return
|
|
}
|
|
|
|
var SJSURL = serverurl
|
|
|
|
if (UserDefaults.standard.textInputSideJITServerurl ?? "").isEmpty {
|
|
SJSURL = "http://sidejitserver._http._tcp.local:8080"
|
|
}
|
|
|
|
if !SJSURL.hasPrefix("http") {
|
|
completion(.failure(.invalidURL))
|
|
return
|
|
}
|
|
|
|
let fullurl = SJSURL + "/\(udid)/" + installedapp.resignedBundleIdentifier
|
|
|
|
let url = URL(string: fullurl)!
|
|
|
|
let task = URLSession.shared.dataTask(with: url) {(data, response, error) in
|
|
if let error = error {
|
|
completion(.failure(.errorConnecting))
|
|
return
|
|
}
|
|
|
|
guard let data = data, let datastring = String(data: data, encoding: .utf8) else { return }
|
|
|
|
if datastring == "Enabled JIT for '\(installedapp.name)'!" {
|
|
let content = UNMutableNotificationContent()
|
|
content.title = "JIT Successfully Enabled"
|
|
content.subtitle = "JIT Enabled For \(installedapp.name)"
|
|
content.sound = UNNotificationSound.default
|
|
|
|
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.1, repeats: false)
|
|
let request = UNNotificationRequest(identifier: "EnabledJIT", content: content, trigger: nil)
|
|
|
|
UNUserNotificationCenter.current().add(request)
|
|
completion(.success(()))
|
|
} else {
|
|
let errorType: SideJITServerErrorType = datastring == "Could not find device!" ? .deviceNotFound : .other(datastring)
|
|
completion(.failure(errorType))
|
|
}
|
|
}
|
|
|
|
task.resume()
|
|
}
|