mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
refactor anisette manager to own file
Signed-off-by: Joseph Mattello <mail@joemattiello.com>
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
B3C395F9284F362400DA9E2F /* AppCenterCrashes in Frameworks */ = {isa = PBXBuildFile; productRef = B3C395F8284F362400DA9E2F /* AppCenterCrashes */; };
|
||||
B3C395FC284F3B2400DA9E2F /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = B3C395FB284F3B2400DA9E2F /* Sparkle */; };
|
||||
B3C395FF284F3C0900DA9E2F /* STPrivilegedTask in Frameworks */ = {isa = PBXBuildFile; productRef = B3C395FE284F3C0900DA9E2F /* STPrivilegedTask */; };
|
||||
B3EE16B62925E27D00B3B1F5 /* AnisetteManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3EE16B52925E27D00B3B1F5 /* AnisetteManager.swift */; };
|
||||
BF02419622F2199300129732 /* RefreshAttemptsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF02419522F2199300129732 /* RefreshAttemptsViewController.swift */; };
|
||||
BF0241AA22F29CCD00129732 /* UserDefaults+AltServer.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF0241A922F29CCD00129732 /* UserDefaults+AltServer.swift */; };
|
||||
BF08858322DE795100DE9F1E /* MyAppsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF08858222DE795100DE9F1E /* MyAppsViewController.swift */; };
|
||||
@@ -578,6 +579,7 @@
|
||||
B3C3960D284F4E4B00DA9E2F /* AltWidgetExtension.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AltWidgetExtension.xcconfig; sourceTree = "<group>"; };
|
||||
B3C3960E284F4F9100DA9E2F /* AltStoreCore.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AltStoreCore.xcconfig; sourceTree = "<group>"; };
|
||||
B3C3960F284F53E900DA9E2F /* AltBackup.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AltBackup.xcconfig; sourceTree = "<group>"; };
|
||||
B3EE16B52925E27D00B3B1F5 /* AnisetteManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnisetteManager.swift; sourceTree = "<group>"; };
|
||||
BF02419522F2199300129732 /* RefreshAttemptsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshAttemptsViewController.swift; sourceTree = "<group>"; };
|
||||
BF0241A922F29CCD00129732 /* UserDefaults+AltServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserDefaults+AltServer.swift"; sourceTree = "<group>"; };
|
||||
BF08858222DE795100DE9F1E /* MyAppsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyAppsViewController.swift; sourceTree = "<group>"; };
|
||||
@@ -1834,6 +1836,7 @@
|
||||
BFF0B68F23219C6D007A79E1 /* PatreonComponents.swift */,
|
||||
BFF0B6912321A305007A79E1 /* AboutPatreonHeaderView.xib */,
|
||||
BFF0B695232242D3007A79E1 /* LicensesViewController.swift */,
|
||||
B3EE16B52925E27D00B3B1F5 /* AnisetteManager.swift */,
|
||||
);
|
||||
path = Settings;
|
||||
sourceTree = "<group>";
|
||||
@@ -2746,6 +2749,7 @@
|
||||
BF44EEFC246B4550002A52F2 /* RemoveAppOperation.swift in Sources */,
|
||||
BF3D64B022E8D4B800E9056B /* AppContentViewControllerCells.swift in Sources */,
|
||||
BFC57A6E2416FC5D00EB891E /* InstalledAppsCollectionHeaderView.swift in Sources */,
|
||||
B3EE16B62925E27D00B3B1F5 /* AnisetteManager.swift in Sources */,
|
||||
BF88F97224F8727D00BB75DF /* AppManagerErrors.swift in Sources */,
|
||||
B39F16152918D7DA002E9404 /* Consts+Proxy.swift in Sources */,
|
||||
BF6C8FAE2429597900125131 /* BannerCollectionViewCell.swift in Sources */,
|
||||
|
||||
@@ -13,34 +13,6 @@ import minimuxer
|
||||
|
||||
import AltStoreCore
|
||||
import UniformTypeIdentifiers
|
||||
import OSLog
|
||||
|
||||
public struct AnisetteManager {
|
||||
|
||||
/// User defined URL from Settings/UserDefaults
|
||||
static var userURL: String? {
|
||||
guard let urlString = UserDefaults.shared.customAnisetteURL else { return nil }
|
||||
// Test it's a valid URL
|
||||
guard URL(string: urlString) != nil else {
|
||||
ELOG("UserDefaults has invalid `customAnisetteURL`")
|
||||
assertionFailure("UserDefaults has invalid `customAnisetteURL`")
|
||||
return nil
|
||||
}
|
||||
return urlString
|
||||
}
|
||||
static var defaultURL: String {
|
||||
guard let url = Bundle.main.object(forInfoDictionaryKey: "ALTAnisetteURL") as? String else {
|
||||
assertionFailure("Info.plist has invalid `ALTAnisetteURL`")
|
||||
abort()
|
||||
}
|
||||
return url
|
||||
}
|
||||
static var currentURLString: String { userURL ?? defaultURL }
|
||||
// Force unwrap is safe here since we check validity before hand -- @JoeMatt
|
||||
|
||||
/// User url or default from plist if none specified
|
||||
static var currentURL: URL { URL(string: currentURLString)! }
|
||||
}
|
||||
|
||||
class LaunchViewController: RSTLaunchViewController, UIDocumentPickerDelegate
|
||||
{
|
||||
|
||||
36
AltStore/Settings/AnisetteManager.swift
Normal file
36
AltStore/Settings/AnisetteManager.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// AnisetteManager.swift
|
||||
// SideStore
|
||||
//
|
||||
// Created by Joseph Mattiello on 11/16/22.
|
||||
// Copyright © 2022 SideStore. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct AnisetteManager {
|
||||
|
||||
/// User defined URL from Settings/UserDefaults
|
||||
static var userURL: String? {
|
||||
guard let urlString = UserDefaults.shared.customAnisetteURL, !urlString.isEmpty else { return nil }
|
||||
// Test it's a valid URL
|
||||
guard URL(string: urlString) != nil else {
|
||||
ELOG("UserDefaults has invalid `customAnisetteURL`")
|
||||
assertionFailure("UserDefaults has invalid `customAnisetteURL`")
|
||||
return nil
|
||||
}
|
||||
return urlString
|
||||
}
|
||||
static var defaultURL: String {
|
||||
guard let url = Bundle.main.object(forInfoDictionaryKey: "ALTAnisetteURL") as? String else {
|
||||
assertionFailure("Info.plist has invalid `ALTAnisetteURL`")
|
||||
abort()
|
||||
}
|
||||
return url
|
||||
}
|
||||
static var currentURLString: String { userURL ?? defaultURL }
|
||||
// Force unwrap is safe here since we check validity before hand -- @JoeMatt
|
||||
|
||||
/// User url or default from plist if none specified
|
||||
static var currentURL: URL { URL(string: currentURLString)! }
|
||||
}
|
||||
Reference in New Issue
Block a user