mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 11:43:24 +01:00
Moves VerificationError to its own source file
This commit is contained in:
@@ -386,6 +386,7 @@
|
|||||||
D5CA0C4E280E249E00469595 /* AltStore9ToAltStore10.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = D5CA0C4D280E249E00469595 /* AltStore9ToAltStore10.xcmappingmodel */; };
|
D5CA0C4E280E249E00469595 /* AltStore9ToAltStore10.xcmappingmodel in Sources */ = {isa = PBXBuildFile; fileRef = D5CA0C4D280E249E00469595 /* AltStore9ToAltStore10.xcmappingmodel */; };
|
||||||
D5CD805D29CA2C1E00E591B0 /* HeaderContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5CD805C29CA2C1E00E591B0 /* HeaderContentViewController.swift */; };
|
D5CD805D29CA2C1E00E591B0 /* HeaderContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5CD805C29CA2C1E00E591B0 /* HeaderContentViewController.swift */; };
|
||||||
D5CD805F29CA755E00E591B0 /* SourceDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5CD805E29CA755E00E591B0 /* SourceDetailViewController.swift */; };
|
D5CD805F29CA755E00E591B0 /* SourceDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5CD805E29CA755E00E591B0 /* SourceDetailViewController.swift */; };
|
||||||
|
D5CF568C2A0D8EEC006D93E2 /* VerificationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5CF56812A0D83F9006D93E2 /* VerificationError.swift */; };
|
||||||
D5DAE0942804B0B80034D8D4 /* ScreenshotProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5DAE0932804B0B80034D8D4 /* ScreenshotProcessor.swift */; };
|
D5DAE0942804B0B80034D8D4 /* ScreenshotProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5DAE0932804B0B80034D8D4 /* ScreenshotProcessor.swift */; };
|
||||||
D5DAE0962804DF430034D8D4 /* UpdatePatronsOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5DAE0952804DF430034D8D4 /* UpdatePatronsOperation.swift */; };
|
D5DAE0962804DF430034D8D4 /* UpdatePatronsOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5DAE0952804DF430034D8D4 /* UpdatePatronsOperation.swift */; };
|
||||||
D5DB145A28F9DC5A00A8F606 /* ALTLocalizedError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5DB145828F9DC1000A8F606 /* ALTLocalizedError.swift */; };
|
D5DB145A28F9DC5A00A8F606 /* ALTLocalizedError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5DB145828F9DC1000A8F606 /* ALTLocalizedError.swift */; };
|
||||||
@@ -905,6 +906,7 @@
|
|||||||
D5CA0C4D280E249E00469595 /* AltStore9ToAltStore10.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = AltStore9ToAltStore10.xcmappingmodel; sourceTree = "<group>"; };
|
D5CA0C4D280E249E00469595 /* AltStore9ToAltStore10.xcmappingmodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcmappingmodel; path = AltStore9ToAltStore10.xcmappingmodel; sourceTree = "<group>"; };
|
||||||
D5CD805C29CA2C1E00E591B0 /* HeaderContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderContentViewController.swift; sourceTree = "<group>"; };
|
D5CD805C29CA2C1E00E591B0 /* HeaderContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderContentViewController.swift; sourceTree = "<group>"; };
|
||||||
D5CD805E29CA755E00E591B0 /* SourceDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceDetailViewController.swift; sourceTree = "<group>"; };
|
D5CD805E29CA755E00E591B0 /* SourceDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceDetailViewController.swift; sourceTree = "<group>"; };
|
||||||
|
D5CF56812A0D83F9006D93E2 /* VerificationError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerificationError.swift; sourceTree = "<group>"; };
|
||||||
D5DAE0932804B0B80034D8D4 /* ScreenshotProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenshotProcessor.swift; sourceTree = "<group>"; };
|
D5DAE0932804B0B80034D8D4 /* ScreenshotProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenshotProcessor.swift; sourceTree = "<group>"; };
|
||||||
D5DAE0952804DF430034D8D4 /* UpdatePatronsOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdatePatronsOperation.swift; sourceTree = "<group>"; };
|
D5DAE0952804DF430034D8D4 /* UpdatePatronsOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdatePatronsOperation.swift; sourceTree = "<group>"; };
|
||||||
D5DB145828F9DC1000A8F606 /* ALTLocalizedError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ALTLocalizedError.swift; sourceTree = "<group>"; };
|
D5DB145828F9DC1000A8F606 /* ALTLocalizedError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ALTLocalizedError.swift; sourceTree = "<group>"; };
|
||||||
@@ -1785,6 +1787,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
BFDB6A0C22AAFC19007EA6D6 /* OperationError.swift */,
|
BFDB6A0C22AAFC19007EA6D6 /* OperationError.swift */,
|
||||||
|
D5CF56812A0D83F9006D93E2 /* VerificationError.swift */,
|
||||||
BFDB6A0A22AAEDB7007EA6D6 /* Operation.swift */,
|
BFDB6A0A22AAEDB7007EA6D6 /* Operation.swift */,
|
||||||
BF770E5722BC3D0F002A40FE /* RefreshGroup.swift */,
|
BF770E5722BC3D0F002A40FE /* RefreshGroup.swift */,
|
||||||
BF770E5322BC044E002A40FE /* OperationContexts.swift */,
|
BF770E5322BC044E002A40FE /* OperationContexts.swift */,
|
||||||
@@ -2773,6 +2776,7 @@
|
|||||||
BF8F69C422E662D300049BA1 /* AppViewController.swift in Sources */,
|
BF8F69C422E662D300049BA1 /* AppViewController.swift in Sources */,
|
||||||
BFF0B68E23219520007A79E1 /* PatreonViewController.swift in Sources */,
|
BFF0B68E23219520007A79E1 /* PatreonViewController.swift in Sources */,
|
||||||
BFF00D302501BD7D00746320 /* Intents.intentdefinition in Sources */,
|
BFF00D302501BD7D00746320 /* Intents.intentdefinition in Sources */,
|
||||||
|
D5CF568C2A0D8EEC006D93E2 /* VerificationError.swift in Sources */,
|
||||||
D5DAE0942804B0B80034D8D4 /* ScreenshotProcessor.swift in Sources */,
|
D5DAE0942804B0B80034D8D4 /* ScreenshotProcessor.swift in Sources */,
|
||||||
BFD2476E2284B9A500981D42 /* AppDelegate.swift in Sources */,
|
BFD2476E2284B9A500981D42 /* AppDelegate.swift in Sources */,
|
||||||
BF41B806233423AE00C593A3 /* TabBarController.swift in Sources */,
|
BF41B806233423AE00C593A3 /* TabBarController.swift in Sources */,
|
||||||
|
|||||||
109
AltStore/Operations/VerificationError.swift
Normal file
109
AltStore/Operations/VerificationError.swift
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
//
|
||||||
|
// VerificationError.swift
|
||||||
|
// AltStore
|
||||||
|
//
|
||||||
|
// Created by Riley Testut on 5/11/23.
|
||||||
|
// Copyright © 2023 Riley Testut. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import AltStoreCore
|
||||||
|
import AltSign
|
||||||
|
|
||||||
|
extension VerificationError
|
||||||
|
{
|
||||||
|
enum Code: Int, ALTErrorCode, CaseIterable
|
||||||
|
{
|
||||||
|
typealias Error = VerificationError
|
||||||
|
|
||||||
|
// Legacy
|
||||||
|
// case privateEntitlements = 0
|
||||||
|
|
||||||
|
case mismatchedBundleIdentifiers = 1
|
||||||
|
case iOSVersionNotSupported = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
static func mismatchedBundleIdentifiers(sourceBundleID: String, app: ALTApplication) -> VerificationError {
|
||||||
|
VerificationError(code: .mismatchedBundleIdentifiers, app: app, sourceBundleID: sourceBundleID)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func iOSVersionNotSupported(app: AppProtocol, osVersion: OperatingSystemVersion = ProcessInfo.processInfo.operatingSystemVersion, requiredOSVersion: OperatingSystemVersion?) -> VerificationError {
|
||||||
|
VerificationError(code: .iOSVersionNotSupported, app: app, deviceOSVersion: osVersion, requiredOSVersion: requiredOSVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct VerificationError: ALTLocalizedError
|
||||||
|
{
|
||||||
|
let code: Code
|
||||||
|
|
||||||
|
var errorTitle: String?
|
||||||
|
var errorFailure: String?
|
||||||
|
|
||||||
|
@Managed var app: AppProtocol?
|
||||||
|
var sourceBundleID: String?
|
||||||
|
var deviceOSVersion: OperatingSystemVersion?
|
||||||
|
var requiredOSVersion: OperatingSystemVersion?
|
||||||
|
|
||||||
|
var errorDescription: String? {
|
||||||
|
//TODO: Make this automatic somehow with ALTLocalizedError
|
||||||
|
guard self.errorFailure == nil else { return nil }
|
||||||
|
|
||||||
|
switch self.code
|
||||||
|
{
|
||||||
|
case .iOSVersionNotSupported:
|
||||||
|
guard let deviceOSVersion else { break }
|
||||||
|
|
||||||
|
var failureReason = self.errorFailureReason
|
||||||
|
if self.app == nil
|
||||||
|
{
|
||||||
|
// failureReason does not start with app name, so make first letter lowercase.
|
||||||
|
let firstLetter = failureReason.prefix(1).lowercased()
|
||||||
|
failureReason = firstLetter + failureReason.dropFirst()
|
||||||
|
}
|
||||||
|
|
||||||
|
let localizedDescription = String(format: NSLocalizedString("This device is running iOS %@, but %@", comment: ""), deviceOSVersion.stringValue, failureReason)
|
||||||
|
return localizedDescription
|
||||||
|
|
||||||
|
default: break
|
||||||
|
}
|
||||||
|
|
||||||
|
return self.errorFailureReason
|
||||||
|
}
|
||||||
|
|
||||||
|
var errorFailureReason: String {
|
||||||
|
switch self.code
|
||||||
|
{
|
||||||
|
case .mismatchedBundleIdentifiers:
|
||||||
|
if let appBundleID = self.$app.bundleIdentifier, let bundleID = self.sourceBundleID
|
||||||
|
{
|
||||||
|
return String(format: NSLocalizedString("The bundle ID “%@” does not match the one specified by the source (“%@”).", comment: ""), appBundleID, bundleID)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NSLocalizedString("The bundle ID does not match the one specified by the source.", comment: "")
|
||||||
|
}
|
||||||
|
|
||||||
|
case .iOSVersionNotSupported:
|
||||||
|
let appName = self.$app.name ?? NSLocalizedString("The app", comment: "")
|
||||||
|
let deviceOSVersion = self.deviceOSVersion ?? ProcessInfo.processInfo.operatingSystemVersion
|
||||||
|
|
||||||
|
guard let requiredOSVersion else {
|
||||||
|
return String(format: NSLocalizedString("%@ does not support iOS %@.", comment: ""), appName, deviceOSVersion.stringValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
if deviceOSVersion > requiredOSVersion
|
||||||
|
{
|
||||||
|
// Device OS version is higher than maximum supported OS version.
|
||||||
|
|
||||||
|
let failureReason = String(format: NSLocalizedString("%@ requires iOS %@ or earlier.", comment: ""), appName, requiredOSVersion.stringValue)
|
||||||
|
return failureReason
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Device OS version is lower than minimum supported OS version.
|
||||||
|
|
||||||
|
let failureReason = String(format: NSLocalizedString("%@ requires iOS %@ or later.", comment: ""), appName, requiredOSVersion.stringValue)
|
||||||
|
return failureReason
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,100 +12,6 @@ import AltStoreCore
|
|||||||
import AltSign
|
import AltSign
|
||||||
import Roxas
|
import Roxas
|
||||||
|
|
||||||
extension VerificationError
|
|
||||||
{
|
|
||||||
enum Code: Int, ALTErrorCode, CaseIterable
|
|
||||||
{
|
|
||||||
typealias Error = VerificationError
|
|
||||||
|
|
||||||
case mismatchedBundleIdentifiers
|
|
||||||
case iOSVersionNotSupported
|
|
||||||
}
|
|
||||||
|
|
||||||
static func mismatchedBundleIdentifiers(sourceBundleID: String, app: ALTApplication) -> VerificationError { VerificationError(code: .mismatchedBundleIdentifiers, app: app, sourceBundleID: sourceBundleID) }
|
|
||||||
|
|
||||||
static func iOSVersionNotSupported(app: AppProtocol, osVersion: OperatingSystemVersion = ProcessInfo.processInfo.operatingSystemVersion, requiredOSVersion: OperatingSystemVersion?) -> VerificationError {
|
|
||||||
VerificationError(code: .iOSVersionNotSupported, app: app, deviceOSVersion: osVersion, requiredOSVersion: requiredOSVersion)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct VerificationError: ALTLocalizedError
|
|
||||||
{
|
|
||||||
let code: Code
|
|
||||||
|
|
||||||
var errorTitle: String?
|
|
||||||
var errorFailure: String?
|
|
||||||
|
|
||||||
@Managed var app: AppProtocol?
|
|
||||||
var sourceBundleID: String?
|
|
||||||
var deviceOSVersion: OperatingSystemVersion?
|
|
||||||
var requiredOSVersion: OperatingSystemVersion?
|
|
||||||
|
|
||||||
var errorDescription: String? {
|
|
||||||
//TODO: Make this automatic somehow with ALTLocalizedError
|
|
||||||
guard self.errorFailure == nil else { return nil }
|
|
||||||
|
|
||||||
switch self.code
|
|
||||||
{
|
|
||||||
case .iOSVersionNotSupported:
|
|
||||||
guard let deviceOSVersion else { break }
|
|
||||||
|
|
||||||
var failureReason = self.errorFailureReason
|
|
||||||
if self.app == nil
|
|
||||||
{
|
|
||||||
// failureReason does not start with app name, so make first letter lowercase.
|
|
||||||
let firstLetter = failureReason.prefix(1).lowercased()
|
|
||||||
failureReason = firstLetter + failureReason.dropFirst()
|
|
||||||
}
|
|
||||||
|
|
||||||
let localizedDescription = String(format: NSLocalizedString("This device is running iOS %@, but %@", comment: ""), deviceOSVersion.stringValue, failureReason)
|
|
||||||
return localizedDescription
|
|
||||||
|
|
||||||
default: break
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.errorFailureReason
|
|
||||||
}
|
|
||||||
|
|
||||||
var errorFailureReason: String {
|
|
||||||
switch self.code
|
|
||||||
{
|
|
||||||
case .mismatchedBundleIdentifiers:
|
|
||||||
if let appBundleID = self.$app.bundleIdentifier, let bundleID = self.sourceBundleID
|
|
||||||
{
|
|
||||||
return String(format: NSLocalizedString("The bundle ID “%@” does not match the one specified by the source (“%@”).", comment: ""), appBundleID, bundleID)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return NSLocalizedString("The bundle ID does not match the one specified by the source.", comment: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
case .iOSVersionNotSupported:
|
|
||||||
let appName = self.$app.name ?? NSLocalizedString("The app", comment: "")
|
|
||||||
let deviceOSVersion = self.deviceOSVersion ?? ProcessInfo.processInfo.operatingSystemVersion
|
|
||||||
|
|
||||||
guard let requiredOSVersion else {
|
|
||||||
return String(format: NSLocalizedString("%@ does not support iOS %@.", comment: ""), appName, deviceOSVersion.stringValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
if deviceOSVersion > requiredOSVersion
|
|
||||||
{
|
|
||||||
// Device OS version is higher than maximum supported OS version.
|
|
||||||
|
|
||||||
let failureReason = String(format: NSLocalizedString("%@ requires iOS %@ or earlier.", comment: ""), appName, requiredOSVersion.stringValue)
|
|
||||||
return failureReason
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Device OS version is lower than minimum supported OS version.
|
|
||||||
|
|
||||||
let failureReason = String(format: NSLocalizedString("%@ requires iOS %@ or later.", comment: ""), appName, requiredOSVersion.stringValue)
|
|
||||||
return failureReason
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc(VerifyAppOperation)
|
@objc(VerifyAppOperation)
|
||||||
class VerifyAppOperation: ResultOperation<Void>
|
class VerifyAppOperation: ResultOperation<Void>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user