[AltStore] Renames App to StoreApp

This commit is contained in:
Riley Testut
2019-07-31 14:07:00 -07:00
parent 39a27f932a
commit 7727a0b725
15 changed files with 82 additions and 82 deletions

View File

@@ -24,7 +24,7 @@ extension AppContentViewController
class AppContentViewController: UITableViewController class AppContentViewController: UITableViewController
{ {
var app: App! var app: StoreApp!
private lazy var screenshotsDataSource = self.makeScreenshotsDataSource() private lazy var screenshotsDataSource = self.makeScreenshotsDataSource()
private lazy var permissionsDataSource = self.makePermissionsDataSource() private lazy var permissionsDataSource = self.makePermissionsDataSource()

View File

@@ -12,7 +12,7 @@ import Roxas
class AppViewController: UIViewController class AppViewController: UIViewController
{ {
var app: App! var app: StoreApp!
private var contentViewController: AppContentViewController! private var contentViewController: AppContentViewController!
private var contentViewControllerShadowView: UIView! private var contentViewControllerShadowView: UIView!
@@ -321,7 +321,7 @@ class AppViewController: UIViewController
extension AppViewController extension AppViewController
{ {
class func makeAppViewController(app: App) -> AppViewController class func makeAppViewController(app: StoreApp) -> AppViewController
{ {
let storyboard = UIStoryboard(name: "Main", bundle: nil) let storyboard = UIStoryboard(name: "Main", bundle: nil)

View File

@@ -294,7 +294,7 @@ private extension AppDelegate
let group = AppManager.shared.refresh(filteredApps, presentingViewController: nil) let group = AppManager.shared.refresh(filteredApps, presentingViewController: nil)
group.beginInstallationHandler = { (installedApp) in group.beginInstallationHandler = { (installedApp) in
guard installedApp.bundleIdentifier == App.altstoreAppID else { return } guard installedApp.bundleIdentifier == StoreApp.altstoreAppID else { return }
// We're starting to install AltStore, which means the app is about to quit. // We're starting to install AltStore, which means the app is about to quit.
// So, we schedule a "refresh successful" local notification to be displayed after a delay, // So, we schedule a "refresh successful" local notification to be displayed after a delay,

View File

@@ -54,22 +54,22 @@ class BrowseViewController: UICollectionViewController
private extension BrowseViewController private extension BrowseViewController
{ {
func makeDataSource() -> RSTFetchedResultsCollectionViewPrefetchingDataSource<App, UIImage> func makeDataSource() -> RSTFetchedResultsCollectionViewPrefetchingDataSource<StoreApp, UIImage>
{ {
let fetchRequest = App.fetchRequest() as NSFetchRequest<App> let fetchRequest = StoreApp.fetchRequest() as NSFetchRequest<StoreApp>
fetchRequest.sortDescriptors = [NSSortDescriptor(keyPath: \App.sortIndex, ascending: true), NSSortDescriptor(keyPath: \App.name, ascending: true)] fetchRequest.sortDescriptors = [NSSortDescriptor(keyPath: \StoreApp.sortIndex, ascending: true), NSSortDescriptor(keyPath: \StoreApp.name, ascending: true)]
fetchRequest.returnsObjectsAsFaults = false fetchRequest.returnsObjectsAsFaults = false
if let source = Source.fetchAltStoreSource(in: DatabaseManager.shared.viewContext) if let source = Source.fetchAltStoreSource(in: DatabaseManager.shared.viewContext)
{ {
fetchRequest.predicate = NSPredicate(format: "%K != %@ AND %K == %@", #keyPath(App.bundleIdentifier), App.altstoreAppID, #keyPath(App.source), source) fetchRequest.predicate = NSPredicate(format: "%K != %@ AND %K == %@", #keyPath(StoreApp.bundleIdentifier), StoreApp.altstoreAppID, #keyPath(StoreApp.source), source)
} }
else else
{ {
fetchRequest.predicate = NSPredicate(format: "%K != %@", #keyPath(App.bundleIdentifier), App.altstoreAppID) fetchRequest.predicate = NSPredicate(format: "%K != %@", #keyPath(StoreApp.bundleIdentifier), StoreApp.altstoreAppID)
} }
let dataSource = RSTFetchedResultsCollectionViewPrefetchingDataSource<App, UIImage>(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext) let dataSource = RSTFetchedResultsCollectionViewPrefetchingDataSource<StoreApp, UIImage>(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext)
dataSource.cellConfigurationHandler = { (cell, app, indexPath) in dataSource.cellConfigurationHandler = { (cell, app, indexPath) in
let cell = cell as! BrowseCollectionViewCell let cell = cell as! BrowseCollectionViewCell
cell.nameLabel.text = app.name cell.nameLabel.text = app.name
@@ -145,7 +145,7 @@ private extension BrowseViewController
} }
} }
func install(_ app: App, at indexPath: IndexPath) func install(_ app: StoreApp, at indexPath: IndexPath)
{ {
let previousProgress = AppManager.shared.installationProgress(for: app) let previousProgress = AppManager.shared.installationProgress(for: app)
guard previousProgress == nil else { guard previousProgress == nil else {

View File

@@ -277,7 +277,7 @@ private extension AppManager
if let installedApp = result.value if let installedApp = result.value
{ {
if let app = app as? App, let storeApp = installedApp.managedObjectContext?.object(with: app.objectID) as? App if let app = app as? StoreApp, let storeApp = installedApp.managedObjectContext?.object(with: app.objectID) as? StoreApp
{ {
installedApp.storeApp = storeApp installedApp.storeApp = storeApp
} }

View File

@@ -13,7 +13,48 @@
</uniquenessConstraint> </uniquenessConstraint>
</uniquenessConstraints> </uniquenessConstraints>
</entity> </entity>
<entity name="App" representedClassName="App" syncable="YES"> <entity name="AppPermission" representedClassName="AppPermission" syncable="YES">
<attribute name="type" attributeType="String" syncable="YES"/>
<attribute name="usageDescription" attributeType="String" syncable="YES"/>
<relationship name="app" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="StoreApp" inverseName="permissions" inverseEntity="StoreApp" syncable="YES"/>
</entity>
<entity name="InstalledApp" representedClassName="InstalledApp" syncable="YES">
<attribute name="bundleIdentifier" attributeType="String" syncable="YES"/>
<attribute name="expirationDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="name" attributeType="String" syncable="YES"/>
<attribute name="refreshedDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="resignedBundleIdentifier" attributeType="String" syncable="YES"/>
<attribute name="version" attributeType="String" syncable="YES"/>
<relationship name="storeApp" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="StoreApp" inverseName="installedApp" inverseEntity="StoreApp" syncable="YES"/>
<uniquenessConstraints>
<uniquenessConstraint>
<constraint value="bundleIdentifier"/>
</uniquenessConstraint>
</uniquenessConstraints>
</entity>
<entity name="RefreshAttempt" representedClassName="RefreshAttempt" syncable="YES">
<attribute name="date" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="errorDescription" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="identifier" attributeType="String" syncable="YES"/>
<attribute name="isSuccess" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<uniquenessConstraints>
<uniquenessConstraint>
<constraint value="identifier"/>
</uniquenessConstraint>
</uniquenessConstraints>
</entity>
<entity name="Source" representedClassName="Source" syncable="YES">
<attribute name="identifier" attributeType="String" syncable="YES"/>
<attribute name="name" attributeType="String" syncable="YES"/>
<attribute name="sourceURL" attributeType="URI" syncable="YES"/>
<relationship name="apps" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="StoreApp" inverseName="source" inverseEntity="StoreApp" syncable="YES"/>
<uniquenessConstraints>
<uniquenessConstraint>
<constraint value="identifier"/>
</uniquenessConstraint>
</uniquenessConstraints>
</entity>
<entity name="StoreApp" representedClassName="StoreApp" syncable="YES">
<attribute name="bundleIdentifier" attributeType="String" syncable="YES"/> <attribute name="bundleIdentifier" attributeType="String" syncable="YES"/>
<attribute name="developerName" attributeType="String" syncable="YES"/> <attribute name="developerName" attributeType="String" syncable="YES"/>
<attribute name="downloadURL" attributeType="URI" syncable="YES"/> <attribute name="downloadURL" attributeType="URI" syncable="YES"/>
@@ -37,47 +78,6 @@
</uniquenessConstraint> </uniquenessConstraint>
</uniquenessConstraints> </uniquenessConstraints>
</entity> </entity>
<entity name="AppPermission" representedClassName="AppPermission" syncable="YES">
<attribute name="type" attributeType="String" syncable="YES"/>
<attribute name="usageDescription" attributeType="String" syncable="YES"/>
<relationship name="app" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="App" inverseName="permissions" inverseEntity="App" syncable="YES"/>
</entity>
<entity name="InstalledApp" representedClassName="InstalledApp" syncable="YES">
<attribute name="bundleIdentifier" attributeType="String" syncable="YES"/>
<attribute name="expirationDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="name" attributeType="String" syncable="YES"/>
<attribute name="refreshedDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="resignedBundleIdentifier" attributeType="String" syncable="YES"/>
<attribute name="version" attributeType="String" syncable="YES"/>
<relationship name="storeApp" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="App" inverseName="installedApp" inverseEntity="App" syncable="YES"/>
<uniquenessConstraints>
<uniquenessConstraint>
<constraint value="bundleIdentifier"/>
</uniquenessConstraint>
</uniquenessConstraints>
</entity>
<entity name="RefreshAttempt" representedClassName="RefreshAttempt" syncable="YES">
<attribute name="date" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
<attribute name="errorDescription" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="identifier" attributeType="String" syncable="YES"/>
<attribute name="isSuccess" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<uniquenessConstraints>
<uniquenessConstraint>
<constraint value="identifier"/>
</uniquenessConstraint>
</uniquenessConstraints>
</entity>
<entity name="Source" representedClassName="Source" syncable="YES">
<attribute name="identifier" attributeType="String" syncable="YES"/>
<attribute name="name" attributeType="String" syncable="YES"/>
<attribute name="sourceURL" attributeType="URI" syncable="YES"/>
<relationship name="apps" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="App" inverseName="source" inverseEntity="App" syncable="YES"/>
<uniquenessConstraints>
<uniquenessConstraint>
<constraint value="identifier"/>
</uniquenessConstraint>
</uniquenessConstraints>
</entity>
<entity name="Team" representedClassName="Team" syncable="YES"> <entity name="Team" representedClassName="Team" syncable="YES">
<attribute name="identifier" attributeType="String" syncable="YES"/> <attribute name="identifier" attributeType="String" syncable="YES"/>
<attribute name="isActiveTeam" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/> <attribute name="isActiveTeam" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
@@ -92,7 +92,7 @@
</entity> </entity>
<elements> <elements>
<element name="Account" positionX="-36" positionY="90" width="128" height="135"/> <element name="Account" positionX="-36" positionY="90" width="128" height="135"/>
<element name="App" positionX="-63" positionY="-18" width="128" height="300"/> <element name="StoreApp" positionX="-63" positionY="-18" width="128" height="300"/>
<element name="AppPermission" positionX="-45" positionY="90" width="128" height="90"/> <element name="AppPermission" positionX="-45" positionY="90" width="128" height="90"/>
<element name="InstalledApp" positionX="-63" positionY="0" width="128" height="150"/> <element name="InstalledApp" positionX="-63" positionY="0" width="128" height="150"/>
<element name="Source" positionX="-45" positionY="99" width="128" height="105"/> <element name="Source" positionX="-45" positionY="99" width="128" height="105"/>

View File

@@ -1,5 +1,5 @@
// //
// App.swift // StoreApp.swift
// AltStore // AltStore
// //
// Created by Riley Testut on 5/20/19. // Created by Riley Testut on 5/20/19.
@@ -12,13 +12,13 @@ import CoreData
import Roxas import Roxas
import AltSign import AltSign
extension App extension StoreApp
{ {
static let altstoreAppID = "com.rileytestut.AltStore" static let altstoreAppID = "com.rileytestut.AltStore"
} }
@objc(App) @objc(StoreApp)
class App: NSManagedObject, Decodable, Fetchable class StoreApp: NSManagedObject, Decodable, Fetchable
{ {
/* Properties */ /* Properties */
@NSManaged private(set) var name: String @NSManaged private(set) var name: String
@@ -77,7 +77,7 @@ class App: NSManagedObject, Decodable, Fetchable
{ {
guard let context = decoder.managedObjectContext else { preconditionFailure("Decoder must have non-nil NSManagedObjectContext.") } guard let context = decoder.managedObjectContext else { preconditionFailure("Decoder must have non-nil NSManagedObjectContext.") }
super.init(entity: App.entity(), insertInto: nil) super.init(entity: StoreApp.entity(), insertInto: nil)
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
self.name = try container.decode(String.self, forKey: .name) self.name = try container.decode(String.self, forKey: .name)
@@ -116,18 +116,18 @@ class App: NSManagedObject, Decodable, Fetchable
} }
} }
extension App extension StoreApp
{ {
@nonobjc class func fetchRequest() -> NSFetchRequest<App> @nonobjc class func fetchRequest() -> NSFetchRequest<StoreApp>
{ {
return NSFetchRequest<App>(entityName: "App") return NSFetchRequest<StoreApp>(entityName: "StoreApp")
} }
class func makeAltStoreApp(in context: NSManagedObjectContext) -> App class func makeAltStoreApp(in context: NSManagedObjectContext) -> StoreApp
{ {
let app = App(context: context) let app = StoreApp(context: context)
app.name = "AltStore" app.name = "AltStore"
app.bundleIdentifier = App.altstoreAppID app.bundleIdentifier = StoreApp.altstoreAppID
app.developerName = "Riley Testut" app.developerName = "Riley Testut"
app.localizedDescription = "AltStore is an alternative App Store." app.localizedDescription = "AltStore is an alternative App Store."
app.iconName = "" app.iconName = ""

View File

@@ -50,7 +50,7 @@ class AppPermission: NSManagedObject, Decodable, Fetchable
@NSManaged var usageDescription: String @NSManaged var usageDescription: String
/* Relationships */ /* Relationships */
@NSManaged private(set) var app: App! @NSManaged private(set) var app: StoreApp!
private override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?) private override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?)
{ {

View File

@@ -125,9 +125,9 @@ private extension DatabaseManager
context.performAndWait { context.performAndWait {
guard let localApp = ALTApplication(fileURL: Bundle.main.bundleURL) else { return } guard let localApp = ALTApplication(fileURL: Bundle.main.bundleURL) else { return }
let storeApp: App let storeApp: StoreApp
if let app = App.first(satisfying: NSPredicate(format: "%K == %@", #keyPath(App.bundleIdentifier), App.altstoreAppID), in: context) if let app = StoreApp.first(satisfying: NSPredicate(format: "%K == %@", #keyPath(StoreApp.bundleIdentifier), StoreApp.altstoreAppID), in: context)
{ {
storeApp = app storeApp = app
} }
@@ -135,7 +135,7 @@ private extension DatabaseManager
{ {
let source = Source.makeAltStoreSource(in: context) let source = Source.makeAltStoreSource(in: context)
storeApp = App.makeAltStoreApp(in: context) storeApp = StoreApp.makeAltStoreApp(in: context)
storeApp.version = localApp.version storeApp.version = localApp.version
storeApp.source = source storeApp.source = source
} }
@@ -148,7 +148,7 @@ private extension DatabaseManager
} }
else else
{ {
installedApp = InstalledApp(resignedApp: localApp, originalBundleIdentifier: App.altstoreAppID, context: context) installedApp = InstalledApp(resignedApp: localApp, originalBundleIdentifier: StoreApp.altstoreAppID, context: context)
installedApp.storeApp = storeApp installedApp.storeApp = storeApp
} }

View File

@@ -24,7 +24,7 @@ class InstalledApp: NSManagedObject, Fetchable
@NSManaged var expirationDate: Date @NSManaged var expirationDate: Date
/* Relationships */ /* Relationships */
@NSManaged var storeApp: App? @NSManaged var storeApp: StoreApp?
var isSideloaded: Bool { var isSideloaded: Bool {
return self.storeApp == nil return self.storeApp == nil
@@ -74,7 +74,7 @@ extension InstalledApp
class func fetchAltStore(in context: NSManagedObjectContext) -> InstalledApp? class func fetchAltStore(in context: NSManagedObjectContext) -> InstalledApp?
{ {
let predicate = NSPredicate(format: "%K == %@", #keyPath(InstalledApp.bundleIdentifier), App.altstoreAppID) let predicate = NSPredicate(format: "%K == %@", #keyPath(InstalledApp.bundleIdentifier), StoreApp.altstoreAppID)
let altStore = InstalledApp.first(satisfying: predicate, in: context) let altStore = InstalledApp.first(satisfying: predicate, in: context)
return altStore return altStore
@@ -82,7 +82,7 @@ extension InstalledApp
class func fetchAppsForRefreshingAll(in context: NSManagedObjectContext) -> [InstalledApp] class func fetchAppsForRefreshingAll(in context: NSManagedObjectContext) -> [InstalledApp]
{ {
let predicate = NSPredicate(format: "%K != %@", #keyPath(InstalledApp.bundleIdentifier), App.altstoreAppID) let predicate = NSPredicate(format: "%K != %@", #keyPath(InstalledApp.bundleIdentifier), StoreApp.altstoreAppID)
var installedApps = InstalledApp.all(satisfying: predicate, var installedApps = InstalledApp.all(satisfying: predicate,
sortedBy: [NSSortDescriptor(keyPath: \InstalledApp.expirationDate, ascending: true)], sortedBy: [NSSortDescriptor(keyPath: \InstalledApp.expirationDate, ascending: true)],
@@ -103,7 +103,7 @@ extension InstalledApp
let predicate = NSPredicate(format: "(%K < %@) AND (%K != %@)", let predicate = NSPredicate(format: "(%K < %@) AND (%K != %@)",
#keyPath(InstalledApp.refreshedDate), date as NSDate, #keyPath(InstalledApp.refreshedDate), date as NSDate,
#keyPath(InstalledApp.bundleIdentifier), App.altstoreAppID) #keyPath(InstalledApp.bundleIdentifier), StoreApp.altstoreAppID)
var installedApps = InstalledApp.all(satisfying: predicate, var installedApps = InstalledApp.all(satisfying: predicate,
sortedBy: [NSSortDescriptor(keyPath: \InstalledApp.expirationDate, ascending: true)], sortedBy: [NSSortDescriptor(keyPath: \InstalledApp.expirationDate, ascending: true)],

View File

@@ -23,7 +23,7 @@ open class MergePolicy: RSTRelationshipPreservingMergePolicy
{ {
switch conflict.databaseObject switch conflict.databaseObject
{ {
case let databaseObject as App: case let databaseObject as StoreApp:
// Delete previous permissions // Delete previous permissions
for permission in databaseObject.permissions for permission in databaseObject.permissions
{ {

View File

@@ -24,9 +24,9 @@ class Source: NSManagedObject, Fetchable, Decodable
/* Relationships */ /* Relationships */
@objc(apps) @NSManaged private(set) var _apps: NSOrderedSet @objc(apps) @NSManaged private(set) var _apps: NSOrderedSet
@nonobjc var apps: [App] { @nonobjc var apps: [StoreApp] {
get { get {
return self._apps.array as! [App] return self._apps.array as! [StoreApp]
} }
set { set {
self._apps = NSOrderedSet(array: newValue) self._apps = NSOrderedSet(array: newValue)
@@ -57,7 +57,7 @@ class Source: NSManagedObject, Fetchable, Decodable
self.identifier = try container.decode(String.self, forKey: .identifier) self.identifier = try container.decode(String.self, forKey: .identifier)
self.sourceURL = try container.decode(URL.self, forKey: .sourceURL) self.sourceURL = try container.decode(URL.self, forKey: .sourceURL)
let apps = try container.decodeIfPresent([App].self, forKey: .apps) ?? [] let apps = try container.decodeIfPresent([StoreApp].self, forKey: .apps) ?? []
for (index, app) in apps.enumerated() for (index, app) in apps.enumerated()
{ {
app.sortIndex = Int32(index) app.sortIndex = Int32(index)

View File

@@ -339,7 +339,7 @@ private extension MyAppsViewController
} }
} }
if installedApps.contains(where: { $0.bundleIdentifier == App.altstoreAppID }) if installedApps.contains(where: { $0.bundleIdentifier == StoreApp.altstoreAppID })
{ {
let alertController = UIAlertController(title: NSLocalizedString("Refresh AltStore?", comment: ""), message: NSLocalizedString("AltStore will quit when it is finished refreshing.", comment: ""), preferredStyle: .alert) let alertController = UIAlertController(title: NSLocalizedString("Refresh AltStore?", comment: ""), message: NSLocalizedString("AltStore will quit when it is finished refreshing.", comment: ""), preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: RSTSystemLocalizedString("Cancel"), style: .cancel) { (action) in alertController.addAction(UIAlertAction(title: RSTSystemLocalizedString("Cancel"), style: .cancel) { (action) in

View File

@@ -395,7 +395,7 @@ private extension ResignAppOperation
var additionalValues: [String: Any] = [Bundle.Info.urlTypes: allURLSchemes] var additionalValues: [String: Any] = [Bundle.Info.urlTypes: allURLSchemes]
if self.context.bundleIdentifier == App.altstoreAppID if self.context.bundleIdentifier == StoreApp.altstoreAppID
{ {
guard let udid = Bundle.main.object(forInfoDictionaryKey: Bundle.Info.deviceID) as? String else { throw OperationError.unknownUDID } guard let udid = Bundle.main.object(forInfoDictionaryKey: Bundle.Info.deviceID) as? String else { throw OperationError.unknownUDID }
additionalValues[Bundle.Info.deviceID] = udid additionalValues[Bundle.Info.deviceID] = udid

View File

@@ -23,7 +23,7 @@ extension ALTApplication: AppProtocol
} }
} }
extension App: AppProtocol extension StoreApp: AppProtocol
{ {
var url: URL { var url: URL {
return self.downloadURL return self.downloadURL