Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Stuart Breckenridge 2019-06-20 07:10:09 +08:00
commit f19b4ee780
231 changed files with 4173 additions and 455 deletions

View File

@ -6,6 +6,22 @@
<description>Most recent NetNewsWire changes with links to updates.</description>
<language>en</language>
<item>
<title>NetNewsWire 5.0a4</title>
<description><![CDATA[
<p>Sidebar: fixed a bug where a drag-and-drop that triggers an error could make the app unresponsive.</p>
<p>Timeline: fixed sorting when two items have the same publication date. Added additional criteria so the sort is stable and predictable.</p>
<p>Timeline: small avatars (16 x 16 favicons, for instance) are now centered on a gray background. Looks a bit better.</p>
<p>Added How to Support NetNewsWire help menu item.</p>
<p>AppleScript: read/unread and starred status are now read/write via scripts.</p>
<p>Updated to the latest Sparkle — the thing that does these in-app version upgrades — which has better support Dark Mode. Also, it might fix a bug where Check for Updates… is sometimes not available when it should be. (Maybe.)</p>
<p><b>Status note:</b> At this point we have no known bugs to fix before 5.0 beta. No crashing bugs. All that remains is documentation. So, please keep looking for bugs! :)</p>
]]></description>
<pubDate>Sat, 15 Jun 2019 19:000:00 -0700</pubDate>
<enclosure url="https://ranchero.com/downloads/NetNewsWire5.0a4.zip" sparkle:version="2237" sparkle:shortVersionString="5.0a4" length="5147527" type="application/zip" />
<sparkle:minimumSystemVersion>10.14.4</sparkle:minimumSystemVersion>
</item>
<item>
<title>NetNewsWire 5.0a3</title>
<description><![CDATA[

View File

@ -33,6 +33,7 @@ public enum AccountType: Int {
case feedbin = 17
case feedWrangler = 18
case newsBlur = 19
case readerAPI = 20
// TODO: more
}
@ -125,6 +126,17 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
}
public var endpointURL: URL? {
get {
return metadata.endpointURL
}
set {
if newValue != metadata.endpointURL {
metadata.endpointURL = newValue
}
}
}
private var fetchingAllUnreadCounts = false
var isUnreadCountsInitialized = false
@ -172,8 +184,12 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
}
public var usesTags: Bool {
return delegate.usesTags
public var isTagBasedSystem: Bool {
return delegate.isTagBasedSystem
}
public var isOPMLImportSupported: Bool {
return delegate.isOPMLImportSupported
}
var refreshInProgress = false {
@ -194,8 +210,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
return delegate.refreshProgress
}
var supportsSubFolders: Bool {
return delegate.supportsSubFolders
var isSubfoldersSupported: Bool {
return delegate.isSubfoldersSupported
}
init?(dataFolder: String, type: AccountType, accountID: String, transport: Transport? = nil) {
@ -205,6 +221,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
self.delegate = LocalAccountDelegate()
case .feedbin:
self.delegate = FeedbinAccountDelegate(dataFolder: dataFolder, transport: transport)
case .readerAPI:
self.delegate = ReaderAPIAccountDelegate(dataFolder: dataFolder, transport: transport)
default:
fatalError("Only Local and Feedbin accounts are supported")
}
@ -232,6 +250,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
defaultName = "FeedWrangler"
case .newsBlur:
defaultName = "NewsBlur"
case .readerAPI:
defaultName = "Reader API"
}
NotificationCenter.default.addObserver(self, selector: #selector(downloadProgressDidChange(_:)), name: .DownloadProgressDidChange, object: nil)
@ -263,8 +283,10 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
switch credentials {
case .basic(let username, _):
self.username = username
default:
return
case .readerAPIBasicLogin(let username, _):
self.username = username
case .readerAPIAuthLogin(let username, _):
self.username = username
}
try CredentialsManager.storeCredentials(credentials, server: server)
@ -288,12 +310,29 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
self.username = nil
}
public static func validateCredentials(transport: Transport = URLSession.webserviceTransport(), type: AccountType, credentials: Credentials, completion: @escaping (Result<Bool, Error>) -> Void) {
public func retrieveReaderAPIAuthCredentials() throws -> Credentials? {
guard let username = self.username, let server = delegate.server else {
return nil
}
return try CredentialsManager.retrieveReaderAPIAuthCredentials(server: server, username: username)
}
public func removeReaderAPIAuthCredentials() throws {
guard let username = self.username, let server = delegate.server else {
return
}
try CredentialsManager.removeReaderAPIAuthCredentials(server: server, username: username)
self.username = nil
}
public static func validateCredentials(transport: Transport = URLSession.webserviceTransport(), type: AccountType, credentials: Credentials, endpoint: URL? = nil, completion: @escaping (Result<Credentials?, Error>) -> Void) {
switch type {
case .onMyMac:
LocalAccountDelegate.validateCredentials(transport: transport, credentials: credentials, completion: completion)
case .feedbin:
FeedbinAccountDelegate.validateCredentials(transport: transport, credentials: credentials, completion: completion)
case .readerAPI:
ReaderAPIAccountDelegate.validateCredentials(transport: transport, credentials: credentials, endpoint: endpoint, completion: completion)
default:
break
}
@ -313,7 +352,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
public func importOPML(_ opmlFile: URL, completion: @escaping (Result<Void, Error>) -> Void) {
guard !delegate.opmlImportInProgress else {
guard !delegate.isOPMLImportInProgress else {
completion(.failure(AccountError.opmlImportInProgress))
return
}

View File

@ -35,6 +35,13 @@
51E490362288C37100C791F0 /* FeedbinDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E490352288C37100C791F0 /* FeedbinDate.swift */; };
51E59599228C77BC00FCC42B /* FeedbinUnreadEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E59598228C77BC00FCC42B /* FeedbinUnreadEntry.swift */; };
51E5959B228C781500FCC42B /* FeedbinStarredEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51E5959A228C781500FCC42B /* FeedbinStarredEntry.swift */; };
552032F8229D5D5A009559E0 /* ReaderAPIEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032ED229D5D5A009559E0 /* ReaderAPIEntry.swift */; };
552032F9229D5D5A009559E0 /* ReaderAPISubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032EE229D5D5A009559E0 /* ReaderAPISubscription.swift */; };
552032FB229D5D5A009559E0 /* ReaderAPITag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032F0229D5D5A009559E0 /* ReaderAPITag.swift */; };
552032FC229D5D5A009559E0 /* ReaderAPIUnreadEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032F1229D5D5A009559E0 /* ReaderAPIUnreadEntry.swift */; };
552032FD229D5D5A009559E0 /* ReaderAPITagging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032F2229D5D5A009559E0 /* ReaderAPITagging.swift */; };
552032FE229D5D5A009559E0 /* ReaderAPIAccountDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032F3229D5D5A009559E0 /* ReaderAPIAccountDelegate.swift */; };
55203300229D5D5A009559E0 /* ReaderAPICaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032F5229D5D5A009559E0 /* ReaderAPICaller.swift */; };
841973FE1F6DD1BC006346C4 /* RSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 841973EF1F6DD19E006346C4 /* RSCore.framework */; };
841973FF1F6DD1C5006346C4 /* RSParser.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 841973FA1F6DD1AC006346C4 /* RSParser.framework */; };
841974011F6DD1EC006346C4 /* Folder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841974001F6DD1EC006346C4 /* Folder.swift */; };
@ -136,6 +143,13 @@
51E490352288C37100C791F0 /* FeedbinDate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbinDate.swift; sourceTree = "<group>"; };
51E59598228C77BC00FCC42B /* FeedbinUnreadEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbinUnreadEntry.swift; sourceTree = "<group>"; };
51E5959A228C781500FCC42B /* FeedbinStarredEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbinStarredEntry.swift; sourceTree = "<group>"; };
552032ED229D5D5A009559E0 /* ReaderAPIEntry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReaderAPIEntry.swift; sourceTree = "<group>"; };
552032EE229D5D5A009559E0 /* ReaderAPISubscription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReaderAPISubscription.swift; sourceTree = "<group>"; };
552032F0229D5D5A009559E0 /* ReaderAPITag.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReaderAPITag.swift; sourceTree = "<group>"; };
552032F1229D5D5A009559E0 /* ReaderAPIUnreadEntry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReaderAPIUnreadEntry.swift; sourceTree = "<group>"; };
552032F2229D5D5A009559E0 /* ReaderAPITagging.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReaderAPITagging.swift; sourceTree = "<group>"; };
552032F3229D5D5A009559E0 /* ReaderAPIAccountDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReaderAPIAccountDelegate.swift; sourceTree = "<group>"; };
552032F5229D5D5A009559E0 /* ReaderAPICaller.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReaderAPICaller.swift; sourceTree = "<group>"; };
841973E81F6DD19E006346C4 /* RSCore.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSCore.xcodeproj; path = ../RSCore/RSCore.xcodeproj; sourceTree = "<group>"; };
841973F41F6DD1AC006346C4 /* RSParser.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSParser.xcodeproj; path = ../RSParser/RSParser.xcodeproj; sourceTree = "<group>"; };
841974001F6DD1EC006346C4 /* Folder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Folder.swift; sourceTree = "<group>"; };
@ -222,6 +236,20 @@
path = JSON;
sourceTree = "<group>";
};
552032EA229D5D5A009559E0 /* ReaderAPI */ = {
isa = PBXGroup;
children = (
552032ED229D5D5A009559E0 /* ReaderAPIEntry.swift */,
552032EE229D5D5A009559E0 /* ReaderAPISubscription.swift */,
552032F0229D5D5A009559E0 /* ReaderAPITag.swift */,
552032F1229D5D5A009559E0 /* ReaderAPIUnreadEntry.swift */,
552032F2229D5D5A009559E0 /* ReaderAPITagging.swift */,
552032F3229D5D5A009559E0 /* ReaderAPIAccountDelegate.swift */,
552032F5229D5D5A009559E0 /* ReaderAPICaller.swift */,
);
path = ReaderAPI;
sourceTree = "<group>";
};
841973E91F6DD19E006346C4 /* Products */ = {
isa = PBXGroup;
children = (
@ -302,6 +330,7 @@
5165D71F22835E9800D9D53D /* FeedFinder */,
8419742B1F6DDE84006346C4 /* LocalAccount */,
84245C7D1FDDD2580074AFBB /* Feedbin */,
552032EA229D5D5A009559E0 /* ReaderAPI */,
848935031F62484F00CEBD24 /* AccountTests */,
848934F71F62484F00CEBD24 /* Products */,
8469F80F1F6DC3C10084783E /* Frameworks */,
@ -515,11 +544,13 @@
buildActionMask = 2147483647;
files = (
84C8B3F41F89DE430053CCA6 /* DataExtensions.swift in Sources */,
552032F9229D5D5A009559E0 /* ReaderAPISubscription.swift in Sources */,
84C3654A1F899F3B001EC85C /* CombinedRefreshProgress.swift in Sources */,
8469F81C1F6DD15E0084783E /* Account.swift in Sources */,
5144EA4E227B829A00D19003 /* FeedbinAccountDelegate.swift in Sources */,
51E5959B228C781500FCC42B /* FeedbinStarredEntry.swift in Sources */,
846E77451F6EF9B900A165E2 /* Container.swift in Sources */,
552032FD229D5D5A009559E0 /* ReaderAPITagging.swift in Sources */,
84F73CF1202788D90000BCEF /* ArticleFetcher.swift in Sources */,
841974251F6DDCE4006346C4 /* AccountDelegate.swift in Sources */,
5165D73122837F3400D9D53D /* InitialFeedDownloader.swift in Sources */,
@ -533,10 +564,15 @@
84B99C9F1FAE8D3200ECDEDB /* ContainerPath.swift in Sources */,
5133231122810EB200C30F19 /* FeedbinIcon.swift in Sources */,
846E77501F6EF9C400A165E2 /* LocalAccountRefresher.swift in Sources */,
55203300229D5D5A009559E0 /* ReaderAPICaller.swift in Sources */,
51E3EB41229AF61B00645299 /* AccountError.swift in Sources */,
51E59599228C77BC00FCC42B /* FeedbinUnreadEntry.swift in Sources */,
552032F8229D5D5A009559E0 /* ReaderAPIEntry.swift in Sources */,
552032FB229D5D5A009559E0 /* ReaderAPITag.swift in Sources */,
5165D72822835F7800D9D53D /* FeedFinder.swift in Sources */,
51D58755227F53BE00900287 /* FeedbinTag.swift in Sources */,
552032FE229D5D5A009559E0 /* ReaderAPIAccountDelegate.swift in Sources */,
552032FC229D5D5A009559E0 /* ReaderAPIUnreadEntry.swift in Sources */,
84D09623217418DC00D77525 /* FeedbinTagging.swift in Sources */,
84CAD7161FDF2E22000F0755 /* FeedbinEntry.swift in Sources */,
5165D72A22835F7D00D9D53D /* HTMLFeedFinder.swift in Sources */,

View File

@ -13,9 +13,10 @@ import RSWeb
protocol AccountDelegate {
// Local account does not; some synced accounts might.
var supportsSubFolders: Bool { get }
var usesTags: Bool { get }
var opmlImportInProgress: Bool { get }
var isSubfoldersSupported: Bool { get }
var isTagBasedSystem: Bool { get }
var isOPMLImportSupported: Bool { get }
var isOPMLImportInProgress: Bool { get }
var server: String? { get }
var credentials: Credentials? { get set }
@ -47,6 +48,6 @@ protocol AccountDelegate {
// Called at the end of accounts init method.
func accountDidInitialize(_ account: Account)
static func validateCredentials(transport: Transport, credentials: Credentials, completion: @escaping (Result<Bool, Error>) -> Void)
static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL?, completion: @escaping (Result<Credentials?, Error>) -> Void)
}

View File

@ -172,7 +172,7 @@ public final class AccountManager: UnreadCountProvider {
}
}
group.notify(queue: DispatchQueue.main) {
group.notify(queue: DispatchQueue.global(qos: .background)) {
completion?()
}
}

View File

@ -21,6 +21,7 @@ final class AccountMetadata: Codable {
case username
case conditionalGetInfo
case lastArticleFetch
case endpointURL
}
var name: String? {
@ -62,6 +63,14 @@ final class AccountMetadata: Codable {
}
}
}
var endpointURL: URL? {
didSet {
if endpointURL != oldValue {
valueDidChange(.endpointURL)
}
}
}
weak var delegate: AccountMetadataDelegate?

View File

@ -42,7 +42,7 @@ final class FeedbinAPICaller: NSObject {
self.transport = transport
}
func validateCredentials(completion: @escaping (Result<Bool, Error>) -> Void) {
func validateCredentials(completion: @escaping (Result<Credentials?, Error>) -> Void) {
let callURL = feedbinBaseURL.appendingPathComponent("authentication.json")
let request = URLRequest(url: callURL, credentials: credentials)
@ -50,12 +50,12 @@ final class FeedbinAPICaller: NSObject {
transport.send(request: request) { result in
switch result {
case .success:
completion(.success(true))
completion(.success(self.credentials))
case .failure(let error):
switch error {
case TransportError.httpError(let status):
if status == 401 {
completion(.success(false))
completion(.success(self.credentials))
} else {
completion(.failure(error))
}

View File

@ -6,12 +6,6 @@
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
//
#if os(macOS)
import AppKit
#else
import UIKit
import RSCore
#endif
import Articles
import RSCore
import RSParser
@ -30,10 +24,11 @@ final class FeedbinAccountDelegate: AccountDelegate {
private let caller: FeedbinAPICaller
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Feedbin")
let supportsSubFolders = false
let usesTags = true
let isSubfoldersSupported = false
let isTagBasedSystem = true
let isOPMLImportSupported = true
let server: String? = "api.feedbin.com"
var opmlImportInProgress = false
var isOPMLImportInProgress = false
var credentials: Credentials? {
didSet {
@ -207,7 +202,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
}
os_log(.debug, log: log, "Begin importing OPML...")
opmlImportInProgress = true
isOPMLImportInProgress = true
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.importOPML(opmlData: opmlData) { result in
@ -216,7 +211,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
if importResult.complete {
os_log(.debug, log: self.log, "Import OPML done.")
self.refreshProgress.completeTask()
self.opmlImportInProgress = false
self.isOPMLImportInProgress = false
DispatchQueue.main.async {
completion(.success(()))
}
@ -226,7 +221,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
case .failure(let error):
os_log(.debug, log: self.log, "Import OPML failed.")
self.refreshProgress.completeTask()
self.opmlImportInProgress = false
self.isOPMLImportInProgress = false
DispatchQueue.main.async {
let wrappedError = AccountError.wrappedError(error: error, account: account)
completion(.failure(wrappedError))
@ -251,7 +246,9 @@ final class FeedbinAccountDelegate: AccountDelegate {
return
}
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.renameTag(oldName: folder.name ?? "", newName: name) { result in
self.refreshProgress.completeTask()
switch result {
case .success:
DispatchQueue.main.async {
@ -285,7 +282,9 @@ final class FeedbinAccountDelegate: AccountDelegate {
if let feedTaggingID = feed.folderRelationship?[folder.name ?? ""] {
group.enter()
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.deleteTagging(taggingID: feedTaggingID) { result in
self.refreshProgress.completeTask()
group.leave()
switch result {
case .success:
@ -302,7 +301,9 @@ final class FeedbinAccountDelegate: AccountDelegate {
if let subscriptionID = feed.subscriptionID {
group.enter()
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.deleteSubscription(subscriptionID: subscriptionID) { result in
self.refreshProgress.completeTask()
group.leave()
switch result {
case .success:
@ -329,7 +330,9 @@ final class FeedbinAccountDelegate: AccountDelegate {
func createFeed(for account: Account, url: String, name: String?, container: Container, completion: @escaping (Result<Feed, Error>) -> Void) {
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.createSubscription(url: url) { result in
self.refreshProgress.completeTask()
switch result {
case .success(let subResult):
switch subResult {
@ -365,7 +368,9 @@ final class FeedbinAccountDelegate: AccountDelegate {
return
}
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.renameSubscription(subscriptionID: subscriptionID, newName: name) { result in
self.refreshProgress.completeTask()
switch result {
case .success:
DispatchQueue.main.async {
@ -408,7 +413,9 @@ final class FeedbinAccountDelegate: AccountDelegate {
func addFeed(for account: Account, with feed: Feed, to container: Container, completion: @escaping (Result<Void, Error>) -> Void) {
if let folder = container as? Folder, let feedID = Int(feed.feedID) {
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.createTagging(feedID: feedID, name: folder.name ?? "") { result in
self.refreshProgress.completeTask()
switch result {
case .success(let taggingID):
DispatchQueue.main.async {
@ -507,7 +514,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
accountMetadata = account.metadata
}
static func validateCredentials(transport: Transport, credentials: Credentials, completion: @escaping (Result<Bool, Error>) -> Void) {
static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL? = nil, completion: @escaping (Result<Credentials?, Error>) -> Void) {
let caller = FeedbinAPICaller(transport: transport)
caller.credentials = credentials
@ -557,7 +564,7 @@ private extension FeedbinAccountDelegate {
os_log(.debug, log: self.log, "Checking status of OPML import successfully completed.")
timer.invalidate()
self.refreshProgress.completeTask()
self.opmlImportInProgress = false
self.isOPMLImportInProgress = false
DispatchQueue.main.async {
completion(.success(()))
}
@ -566,7 +573,7 @@ private extension FeedbinAccountDelegate {
os_log(.debug, log: self.log, "Import OPML check failed.")
timer.invalidate()
self.refreshProgress.completeTask()
self.opmlImportInProgress = false
self.isOPMLImportInProgress = false
DispatchQueue.main.async {
completion(.failure(error))
}
@ -935,9 +942,13 @@ private extension FeedbinAccountDelegate {
}
func initialFeedDownload( account: Account, feed: Feed, completion: @escaping (Result<Feed, Error>) -> Void) {
// refreshArticles is being reused and will clear one of the tasks for us
refreshProgress.addToNumberOfTasksAndRemaining(4)
// Download the initial articles
self.caller.retrieveEntries(feedID: feed.feedID) { result in
self.refreshProgress.completeTask()
switch result {
case .success(let (entries, page)):
@ -945,7 +956,9 @@ private extension FeedbinAccountDelegate {
self.processEntries(account: account, entries: entries) {
self.refreshArticles(account, page: page) {
self.refreshArticleStatus(for: account) {
self.refreshProgress.completeTask()
self.refreshMissingArticles(account) {
self.refreshProgress.completeTask()
DispatchQueue.main.async {
completion(.success(feed))
}
@ -1191,7 +1204,9 @@ private extension FeedbinAccountDelegate {
func deleteTagging(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {
if let folder = container as? Folder, let feedTaggingID = feed.folderRelationship?[folder.name ?? ""] {
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.deleteTagging(taggingID: feedTaggingID) { result in
self.refreshProgress.completeTask()
switch result {
case .success:
DispatchQueue.main.async {
@ -1224,7 +1239,9 @@ private extension FeedbinAccountDelegate {
return
}
refreshProgress.addToNumberOfTasksAndRemaining(1)
caller.deleteSubscription(subscriptionID: subscriptionID) { result in
self.refreshProgress.completeTask()
switch result {
case .success:
DispatchQueue.main.async {

View File

@ -18,9 +18,10 @@ public enum LocalAccountDelegateError: String, Error {
final class LocalAccountDelegate: AccountDelegate {
let supportsSubFolders = false
let usesTags = false
let opmlImportInProgress = false
let isSubfoldersSupported = false
let isTagBasedSystem = false
let isOPMLImportSupported = true
let isOPMLImportInProgress = false
let server: String? = nil
var credentials: Credentials?
@ -92,19 +93,23 @@ final class LocalAccountDelegate: AccountDelegate {
completion(.failure(LocalAccountDelegateError.invalidParameter))
return
}
refreshProgress.addToNumberOfTasksAndRemaining(1)
FeedFinder.find(url: url) { result in
switch result {
case .success(let feedSpecifiers):
guard let bestFeedSpecifier = FeedSpecifier.bestFeed(in: feedSpecifiers),
let url = URL(string: bestFeedSpecifier.urlString) else {
self.refreshProgress.completeTask()
completion(.failure(AccountError.createErrorNotFound))
return
}
if account.hasFeed(withURL: bestFeedSpecifier.urlString) {
self.refreshProgress.completeTask()
completion(.failure(AccountError.createErrorAlreadySubscribed))
return
}
@ -113,6 +118,8 @@ final class LocalAccountDelegate: AccountDelegate {
InitialFeedDownloader.download(url) { parsedFeed in
self.refreshProgress.completeTask()
if let parsedFeed = parsedFeed {
account.update(feed, with: parsedFeed, {})
}
@ -125,6 +132,7 @@ final class LocalAccountDelegate: AccountDelegate {
}
case .failure:
self.refreshProgress.completeTask()
completion(.failure(AccountError.createErrorNotFound))
}
@ -188,8 +196,8 @@ final class LocalAccountDelegate: AccountDelegate {
func accountDidInitialize(_ account: Account) {
}
static func validateCredentials(transport: Transport, credentials: Credentials, completion: (Result<Bool, Error>) -> Void) {
return completion(.success(false))
static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL? = nil, completion: (Result<Credentials?, Error>) -> Void) {
return completion(.success(nil))
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,947 @@
//
// ReaderAPICaller.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
//
import Foundation
import RSWeb
enum CreateReaderAPISubscriptionResult {
case created(ReaderAPISubscription)
case alreadySubscribed
case notFound
}
final class ReaderAPICaller: NSObject {
struct ConditionalGetKeys {
static let subscriptions = "subscriptions"
static let tags = "tags"
static let taggings = "taggings"
static let icons = "icons"
static let unreadEntries = "unreadEntries"
static let starredEntries = "starredEntries"
}
enum ReaderState: String {
case read = "user/-/state/com.google/read"
case starred = "user/-/state/com.google/starred"
}
enum ReaderStreams: String {
case readingList = "user/-/state/com.google/reading-list"
}
enum ReaderAPIEndpoints: String {
case login = "/accounts/ClientLogin"
case token = "/reader/api/0/token"
case disableTag = "/reader/api/0/disable-tag"
case renameTag = "/reader/api/0/rename-tag"
case tagList = "/reader/api/0/tag/list"
case subscriptionList = "/reader/api/0/subscription/list"
case subscriptionEdit = "/reader/api/0/subscription/edit"
case subscriptionAdd = "/reader/api/0/subscription/quickadd"
case contents = "/reader/api/0/stream/items/contents"
case itemIds = "/reader/api/0/stream/items/ids"
case editTag = "/reader/api/0/edit-tag"
}
private var transport: Transport!
var credentials: Credentials?
private var accessToken: String?
weak var accountMetadata: AccountMetadata?
var server: String? {
get {
return APIBaseURL?.host
}
}
private var APIBaseURL: URL? {
get {
guard let accountMetadata = accountMetadata else {
return nil
}
return accountMetadata.endpointURL
}
}
init(transport: Transport) {
super.init()
self.transport = transport
}
func validateCredentials(endpoint: URL, completion: @escaping (Result<Credentials?, Error>) -> Void) {
guard let credentials = credentials else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
guard case .readerAPIBasicLogin(let username, _) = credentials else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
let request = URLRequest(url: endpoint.appendingPathComponent(ReaderAPIEndpoints.login.rawValue), credentials: credentials)
transport.send(request: request) { result in
switch result {
case .success(let (_, data)):
guard let resultData = data else {
completion(.failure(TransportError.noData))
break
}
// Convert the return data to UTF8 and then parse out the Auth token
guard let rawData = String(data: resultData, encoding: .utf8) else {
completion(.failure(TransportError.noData))
break
}
var authData: [String: String] = [:]
rawData.split(separator: "\n").forEach({ (line: Substring) in
let items = line.split(separator: "=").map{String($0)}
authData[items[0]] = items[1]
})
guard let authString = authData["Auth"] else {
completion(.failure(CredentialsError.incompleteCredentials))
break
}
// Save Auth Token for later use
self.credentials = .readerAPIAuthLogin(username: username, apiKey: authString)
completion(.success(self.credentials))
case .failure(let error):
completion(.failure(error))
}
}
}
func requestAuthorizationToken(endpoint: URL, completion: @escaping (Result<String, Error>) -> Void) {
// If we have a token already, use it
if let accessToken = accessToken {
completion(.success(accessToken))
return
}
// Otherwise request one.
guard let credentials = credentials else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
let request = URLRequest(url: endpoint.appendingPathComponent(ReaderAPIEndpoints.token.rawValue), credentials: credentials)
transport.send(request: request) { result in
switch result {
case .success(let (_, data)):
guard let resultData = data else {
completion(.failure(TransportError.noData))
break
}
// Convert the return data to UTF8 and then parse out the Auth token
guard let accessToken = String(data: resultData, encoding: .utf8) else {
completion(.failure(TransportError.noData))
break
}
self.accessToken = accessToken
completion(.success(accessToken))
case .failure(let error):
completion(.failure(error))
}
}
}
func retrieveTags(completion: @escaping (Result<[ReaderAPITag]?, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
// Add query string for getting JSON (probably should break this out as I will be doing it a lot)
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.tagList.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
components.queryItems = [
URLQueryItem(name: "output", value: "json")
]
guard let callURL = components.url else {
completion(.failure(TransportError.noURL))
return
}
let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.tags]
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet)
transport.send(request: request, resultType: ReaderAPITagContainer.self) { result in
switch result {
case .success(let (response, wrapper)):
self.storeConditionalGet(key: ConditionalGetKeys.tags, headers: response.allHeaderFields)
completion(.success(wrapper?.tags))
case .failure(let error):
completion(.failure(error))
}
}
}
func renameTag(oldName: String, newName: String, completion: @escaping (Result<Void, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.renameTag.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
let oldTagName = "user/-/label/\(oldName)"
let newTagName = "user/-/label/\(newName)"
let postData = "T=\(token)&s=\(oldTagName)&dest=\(newTagName)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in
switch result {
case .success:
completion(.success(()))
break
case .failure(let error):
completion(.failure(error))
break
}
})
case .failure(let error):
completion(.failure(error))
}
}
}
func deleteTag(name: String, completion: @escaping (Result<Void, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.disableTag.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
let tagName = "user/-/label/\(name)"
let postData = "T=\(token)&s=\(tagName)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in
switch result {
case .success:
completion(.success(()))
break
case .failure(let error):
completion(.failure(error))
break
}
})
case .failure(let error):
completion(.failure(error))
}
}
}
func retrieveSubscriptions(completion: @escaping (Result<[ReaderAPISubscription]?, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
// Add query string for getting JSON (probably should break this out as I will be doing it a lot)
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionList.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
components.queryItems = [
URLQueryItem(name: "output", value: "json")
]
guard let callURL = components.url else {
completion(.failure(TransportError.noURL))
return
}
let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.subscriptions]
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet)
transport.send(request: request, resultType: ReaderAPISubscriptionContainer.self) { result in
switch result {
case .success(let (response, container)):
self.storeConditionalGet(key: ConditionalGetKeys.subscriptions, headers: response.allHeaderFields)
completion(.success(container?.subscriptions))
case .failure(let error):
completion(.failure(error))
}
}
}
func createSubscription(url: String, completion: @escaping (Result<CreateReaderAPISubscriptionResult, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionAdd.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
components.queryItems = [
URLQueryItem(name: "quickadd", value: url)
]
guard let callURL = components.url else {
completion(.failure(TransportError.noURL))
return
}
var request = URLRequest(url: callURL, credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
let postData = "T=\(token)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, data: postData!, resultType: ReaderAPIQuickAddResult.self, completion: { (result) in
switch result {
case .success(let (_, subResult)):
switch subResult?.numResults {
case 0:
completion(.success(.alreadySubscribed))
default:
// We have a feed ID but need to get feed information
guard let streamId = subResult?.streamId else {
completion(.failure(AccountError.createErrorNotFound))
return
}
// There is no call to get a single subscription entry, so we get them all,
// look up the one we just subscribed to and return that
self.retrieveSubscriptions(completion: { (result) in
switch result {
case .success(let subscriptions):
guard let subscriptions = subscriptions else {
completion(.failure(AccountError.createErrorNotFound))
return
}
let newStreamId = "feed/\(streamId)"
guard let subscription = subscriptions.first(where: { (sub) -> Bool in
sub.feedID == newStreamId
}) else {
completion(.failure(AccountError.createErrorNotFound))
return
}
completion(.success(.created(subscription)))
case .failure(let error):
completion(.failure(error))
}
})
}
case .failure(let error):
completion(.failure(error))
}
})
case .failure(let error):
completion(.failure(error))
}
}
}
func renameSubscription(subscriptionID: String, newName: String, completion: @escaping (Result<Void, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
let postData = "T=\(token)&s=\(subscriptionID)&ac=edit&t=\(newName)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in
switch result {
case .success:
completion(.success(()))
break
case .failure(let error):
completion(.failure(error))
break
}
})
case .failure(let error):
completion(.failure(error))
}
}
}
func deleteSubscription(subscriptionID: String, completion: @escaping (Result<Void, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
let postData = "T=\(token)&s=\(subscriptionID)&ac=unsubscribe".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in
switch result {
case .success:
completion(.success(()))
break
case .failure(let error):
completion(.failure(error))
break
}
})
case .failure(let error):
completion(.failure(error))
}
}
}
func createTagging(subscriptionID: String, tagName: String, completion: @escaping (Result<Void, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
let tagName = "user/-/label/\(tagName)"
let postData = "T=\(token)&s=\(subscriptionID)&ac=edit&a=\(tagName)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in
switch result {
case .success:
completion(.success(()))
break
case .failure(let error):
completion(.failure(error))
break
}
})
case .failure(let error):
completion(.failure(error))
}
}
}
func deleteTagging(subscriptionID: String, tagName: String, completion: @escaping (Result<Void, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
let tagName = "user/-/label/\(tagName)"
let postData = "T=\(token)&s=\(subscriptionID)&ac=edit&r=\(tagName)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in
switch result {
case .success:
completion(.success(()))
break
case .failure(let error):
completion(.failure(error))
break
}
})
case .failure(let error):
completion(.failure(error))
}
}
}
func retrieveEntries(articleIDs: [String], completion: @escaping (Result<([ReaderAPIEntry]?), Error>) -> Void) {
guard !articleIDs.isEmpty else {
completion(.success(([ReaderAPIEntry]())))
return
}
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
// Do POST asking for data about all the new articles
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.contents.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
// Get ids from above into hex representation of value
let idsToFetch = articleIDs.map({ (reference) -> String in
return "i=\(reference)"
}).joined(separator:"&")
let postData = "T=\(token)&output=json&\(idsToFetch)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, data: postData!, resultType: ReaderAPIEntryWrapper.self, completion: { (result) in
switch result {
case .success(let (_, entryWrapper)):
guard let entryWrapper = entryWrapper else {
completion(.failure(ReaderAPIAccountDelegateError.invalidResponse))
return
}
completion(.success((entryWrapper.entries)))
case .failure(let error):
completion(.failure(error))
}
})
case .failure(let error):
completion(.failure(error))
}
}
}
func retrieveEntries(feedID: String, completion: @escaping (Result<([ReaderAPIEntry]?, String?), Error>) -> Void) {
let since = Calendar.current.date(byAdding: .month, value: -3, to: Date()) ?? Date()
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
// Add query string for getting JSON (probably should break this out as I will be doing it a lot)
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
components.queryItems = [
URLQueryItem(name: "s", value: feedID),
URLQueryItem(name: "ot", value: String(since.timeIntervalSince1970)),
URLQueryItem(name: "output", value: "json")
]
guard let callURL = components.url else {
completion(.failure(TransportError.noURL))
return
}
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: nil)
transport.send(request: request, resultType: ReaderAPIReferenceWrapper.self) { result in
switch result {
case .success(let (_, unreadEntries)):
guard let itemRefs = unreadEntries?.itemRefs else {
completion(.success(([], nil)))
return
}
let itemIds = itemRefs.map { (reference) -> String in
// Convert the IDs to the (stupid) Google Hex Format
let idValue = Int(reference.itemId)!
return String(idValue, radix: 16, uppercase: false)
}
self.retrieveEntries(articleIDs: itemIds) { (results) in
switch results {
case .success(let entries):
completion(.success((entries,nil)))
case .failure(let error):
completion(.failure(error))
}
}
case .failure(let error):
completion(.failure(error))
}
}
}
func retrieveEntries(completion: @escaping (Result<([ReaderAPIEntry]?, String?, Int?), Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
let since: Date = {
if let lastArticleFetch = self.accountMetadata?.lastArticleFetch {
return lastArticleFetch
} else {
return Calendar.current.date(byAdding: .month, value: -3, to: Date()) ?? Date()
}
}()
let sinceString = since.timeIntervalSince1970
// Add query string for getting JSON (probably should break this out as I will be doing it a lot)
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
components.queryItems = [
URLQueryItem(name: "o", value: String(sinceString)),
URLQueryItem(name: "n", value: "10000"),
URLQueryItem(name: "output", value: "json"),
URLQueryItem(name: "xt", value: ReaderState.read.rawValue),
URLQueryItem(name: "s", value: ReaderStreams.readingList.rawValue)
]
guard let callURL = components.url else {
completion(.failure(TransportError.noURL))
return
}
let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.unreadEntries]
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet)
self.transport.send(request: request, resultType: ReaderAPIReferenceWrapper.self) { result in
switch result {
case .success(let (_, entries)):
guard let entries = entries else {
completion(.failure(ReaderAPIAccountDelegateError.invalidResponse))
return
}
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
// Do POST asking for data about all the new articles
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.contents.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
// Get ids from above into hex representation of value
let idsToFetch = entries.itemRefs.map({ (reference) -> String in
let idValue = Int(reference.itemId)!
let idHexString = String(idValue, radix: 16, uppercase: false)
return "i=\(idHexString)"
}).joined(separator:"&")
let postData = "T=\(token)&output=json&\(idsToFetch)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, data: postData!, resultType: ReaderAPIEntryWrapper.self, completion: { (result) in
switch result {
case .success(let (response, entryWrapper)):
guard let entryWrapper = entryWrapper else {
completion(.failure(ReaderAPIAccountDelegateError.invalidResponse))
return
}
let dateInfo = HTTPDateInfo(urlResponse: response)
self.accountMetadata?.lastArticleFetch = dateInfo?.date
completion(.success((entryWrapper.entries, nil, nil)))
case .failure(let error):
completion(.failure(error))
}
})
case .failure(let error):
completion(.failure(error))
}
}
case .failure(let error):
self.accountMetadata?.lastArticleFetch = nil
completion(.failure(error))
}
}
}
func retrieveEntries(page: String, completion: @escaping (Result<([ReaderAPIEntry]?, String?), Error>) -> Void) {
guard let url = URL(string: page), var callComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else {
completion(.success((nil, nil)))
return
}
callComponents.queryItems?.append(URLQueryItem(name: "mode", value: "extended"))
let request = URLRequest(url: callComponents.url!, credentials: credentials)
transport.send(request: request, resultType: [ReaderAPIEntry].self) { result in
switch result {
case .success(let (response, entries)):
let pagingInfo = HTTPLinkPagingInfo(urlResponse: response)
completion(.success((entries, pagingInfo.nextPage)))
case .failure(let error):
self.accountMetadata?.lastArticleFetch = nil
completion(.failure(error))
}
}
}
func retrieveUnreadEntries(completion: @escaping (Result<[Int]?, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
// Add query string for getting JSON (probably should break this out as I will be doing it a lot)
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
components.queryItems = [
URLQueryItem(name: "s", value: ReaderStreams.readingList.rawValue),
URLQueryItem(name: "n", value: "10000"),
URLQueryItem(name: "xt", value: ReaderState.read.rawValue),
URLQueryItem(name: "output", value: "json")
]
guard let callURL = components.url else {
completion(.failure(TransportError.noURL))
return
}
let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.unreadEntries]
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet)
transport.send(request: request, resultType: ReaderAPIReferenceWrapper.self) { result in
switch result {
case .success(let (response, unreadEntries)):
guard let itemRefs = unreadEntries?.itemRefs else {
completion(.success([]))
return
}
let itemIds = itemRefs.map{ Int($0.itemId)! }
self.storeConditionalGet(key: ConditionalGetKeys.unreadEntries, headers: response.allHeaderFields)
completion(.success(itemIds))
case .failure(let error):
completion(.failure(error))
}
}
}
func updateStateToEntries(entries: [Int], state: ReaderState, add: Bool, completion: @escaping (Result<Void, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
// Do POST asking for data about all the new articles
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.editTag.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
// Get ids from above into hex representation of value
let idsToFetch = entries.map({ (idValue) -> String in
let idHexString = String(format: "%.16llx", idValue)
return "i=\(idHexString)"
}).joined(separator:"&")
let actionIndicator = add ? "a" : "r"
let postData = "T=\(token)&\(idsToFetch)&\(actionIndicator)=\(state.rawValue)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in
switch result {
case .success:
completion(.success(()))
case .failure(let error):
completion(.failure(error))
}
})
case .failure(let error):
completion(.failure(error))
}
}
}
func createUnreadEntries(entries: [Int], completion: @escaping (Result<Void, Error>) -> Void) {
updateStateToEntries(entries: entries, state: .read, add: false, completion: completion)
}
func deleteUnreadEntries(entries: [Int], completion: @escaping (Result<Void, Error>) -> Void) {
updateStateToEntries(entries: entries, state: .read, add: true, completion: completion)
}
func createStarredEntries(entries: [Int], completion: @escaping (Result<Void, Error>) -> Void) {
updateStateToEntries(entries: entries, state: .starred, add: true, completion: completion)
}
func deleteStarredEntries(entries: [Int], completion: @escaping (Result<Void, Error>) -> Void) {
updateStateToEntries(entries: entries, state: .starred, add: false, completion: completion)
}
func retrieveStarredEntries(completion: @escaping (Result<[Int]?, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
components.queryItems = [
URLQueryItem(name: "s", value: "user/-/state/com.google/starred"),
URLQueryItem(name: "n", value: "10000"),
URLQueryItem(name: "output", value: "json")
]
guard let callURL = components.url else {
completion(.failure(TransportError.noURL))
return
}
let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.starredEntries]
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet)
transport.send(request: request, resultType: ReaderAPIReferenceWrapper.self) { result in
switch result {
case .success(let (response, unreadEntries)):
guard let itemRefs = unreadEntries?.itemRefs else {
completion(.success([]))
return
}
let itemIds = itemRefs.map{ Int($0.itemId)! }
self.storeConditionalGet(key: ConditionalGetKeys.starredEntries, headers: response.allHeaderFields)
completion(.success(itemIds))
case .failure(let error):
completion(.failure(error))
}
}
}
}
// MARK: Private
extension ReaderAPICaller {
func storeConditionalGet(key: String, headers: [AnyHashable : Any]) {
if var conditionalGet = accountMetadata?.conditionalGetInfo {
conditionalGet[key] = HTTPConditionalGetInfo(headers: headers)
accountMetadata?.conditionalGetInfo = conditionalGet
}
}
}

View File

@ -0,0 +1,128 @@
//
// ReaderAPIArticle.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
//
import Foundation
import RSParser
import RSCore
struct ReaderAPIEntryWrapper: Codable {
let id: String
let updated: Int
let entries: [ReaderAPIEntry]
enum CodingKeys: String, CodingKey {
case id = "id"
case updated = "updated"
case entries = "items"
}
}
/* {
"id": "tag:google.com,2005:reader/item/00058a3b5197197b",
"crawlTimeMsec": "1559362260113",
"timestampUsec": "1559362260113787",
"published": 1554845280,
"title": "",
"summary": {
"content": "\n<p>Found an old screenshot of NetNewsWire 1.0 for iPhone!</p>\n\n<p><img src=\"https://nnw.ranchero.com/uploads/2019/c07c0574b1.jpg\" alt=\"Netnewswire 1.0 for iPhone screenshot showing the list of feeds.\" title=\"NewsGator got renamed to Sitrion, years later, and then renamed again as Limeade.\" border=\"0\" width=\"260\" height=\"320\"></p>\n"
},
"alternate": [
{
"href": "https://nnw.ranchero.com/2019/04/09/found-an-old.html"
}
],
"categories": [
"user/-/state/com.google/reading-list",
"user/-/label/Uncategorized"
],
"origin": {
"streamId": "feed/130",
"title": "NetNewsWire"
}
}
*/
struct ReaderAPIEntry: Codable {
let articleID: String
let title: String?
let publishedTimestamp: Double?
let crawledTimestamp: String?
let timestampUsec: String?
let summary: ReaderAPIArticleSummary
let alternates: [ReaderAPIAlternateLocation]
let categories: [String]
let origin: ReaderAPIEntryOrigin
enum CodingKeys: String, CodingKey {
case articleID = "id"
case title = "title"
case summary = "summary"
case alternates = "alternate"
case categories = "categories"
case publishedTimestamp = "published"
case crawledTimestamp = "crawlTimeMsec"
case origin = "origin"
case timestampUsec = "timestampUsec"
}
func parseDatePublished() -> Date? {
guard let unixTime = publishedTimestamp else {
return nil
}
return Date(timeIntervalSince1970: unixTime)
}
func uniqueID() -> String {
// Should look something like "tag:google.com,2005:reader/item/00058b10ce338909"
// REGEX feels heavy, I should be able to just split on / and take the last element
guard let idPart = articleID.components(separatedBy: "/").last else {
return articleID
}
// Convert hex representation back to integer and then a string representation
guard let idNumber = Int(idPart, radix: 16) else {
return articleID
}
return String(idNumber, radix: 10, uppercase: false)
}
}
struct ReaderAPIArticleSummary: Codable {
let content: String?
enum CodingKeys: String, CodingKey {
case content = "content"
}
}
struct ReaderAPIAlternateLocation: Codable {
let url: String?
enum CodingKeys: String, CodingKey {
case url = "href"
}
}
struct ReaderAPIEntryOrigin: Codable {
let streamId: String?
let title: String?
enum CodingKeys: String, CodingKey {
case streamId = "streamId"
case title = "title"
}
}

View File

@ -0,0 +1,104 @@
//
// ReaderAPIFeed.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
//
import Foundation
import RSCore
import RSParser
/*
{
"numResults":0,
"error": "Already subscribed! https://inessential.com/xml/rss.xml
}
*/
struct ReaderAPIQuickAddResult: Codable {
let numResults: Int
let error: String?
let streamId: String?
enum CodingKeys: String, CodingKey {
case numResults = "numResults"
case error = "error"
case streamId = "streamId"
}
}
struct ReaderAPISubscriptionContainer: Codable {
let subscriptions: [ReaderAPISubscription]
enum CodingKeys: String, CodingKey {
case subscriptions = "subscriptions"
}
}
/*
{
"id": "feed/1",
"title": "Questionable Content",
"categories": [
{
"id": "user/-/label/Comics",
"label": "Comics"
}
],
"url": "http://www.questionablecontent.net/QCRSS.xml",
"htmlUrl": "http://www.questionablecontent.net",
"iconUrl": "https://rss.confusticate.com/f.php?24decabc"
}
*/
struct ReaderAPISubscription: Codable {
let feedID: String
let name: String?
let categories: [ReaderAPICategory]
let url: String
let homePageURL: String?
let iconURL: String?
enum CodingKeys: String, CodingKey {
case feedID = "id"
case name = "title"
case categories = "categories"
case url = "url"
case homePageURL = "htmlUrl"
case iconURL = "iconUrl"
}
}
struct ReaderAPICategory: Codable {
let categoryId: String
let categoryLabel: String
enum CodingKeys: String, CodingKey {
case categoryId = "id"
case categoryLabel = "label"
}
}
struct ReaderAPICreateSubscription: Codable {
let feedURL: String
enum CodingKeys: String, CodingKey {
case feedURL = "feed_url"
}
}
struct ReaderAPISubscriptionChoice: Codable {
let name: String?
let url: String
enum CodingKeys: String, CodingKey {
case name = "title"
case url = "feed_url"
}
}

View File

@ -0,0 +1,29 @@
//
// ReaderAPICompatibleTag.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
//
import Foundation
struct ReaderAPITagContainer: Codable {
let tags: [ReaderAPITag]
enum CodingKeys: String, CodingKey {
case tags = "tags"
}
}
struct ReaderAPITag: Codable {
let tagID: String
let type: String?
enum CodingKeys: String, CodingKey {
case tagID = "id"
case type = "type"
}
}

View File

@ -0,0 +1,35 @@
//
// ReaderAPICompatibleTagging.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
// Copyright © 2018 Ranchero Software, LLC. All rights reserved.
//
import Foundation
struct ReaderAPITagging: Codable {
let taggingID: Int
let feedID: Int
let name: String
enum CodingKeys: String, CodingKey {
case taggingID = "id"
case feedID = "feed_id"
case name = "name"
}
}
struct ReaderAPICreateTagging: Codable {
let feedID: Int
let name: String
enum CodingKeys: String, CodingKey {
case feedID = "feed_id"
case name = "name"
}
}

View File

@ -0,0 +1,27 @@
//
// ReaderAPIUnreadEntry.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
//
import Foundation
struct ReaderAPIReferenceWrapper: Codable {
let itemRefs: [ReaderAPIReference]
enum CodingKeys: String, CodingKey {
case itemRefs = "itemRefs"
}
}
struct ReaderAPIReference: Codable {
let itemId: String
enum CodingKeys: String, CodingKey {
case itemId = "id"
}
}

View File

@ -0,0 +1,43 @@
//
// SPUDownloadData.h
// Sparkle
//
// Created by Mayur Pawashe on 8/10/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
NS_ASSUME_NONNULL_BEGIN
/*!
* A class for containing downloaded data along with some information about it.
*/
SU_EXPORT @interface SPUDownloadData : NSObject <NSSecureCoding>
- (instancetype)initWithData:(NSData *)data textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType;
/*!
* The raw data that was downloaded.
*/
@property (nonatomic, readonly) NSData *data;
/*!
* The IANA charset encoding name if available. Eg: "utf-8"
*/
@property (nonatomic, readonly, nullable, copy) NSString *textEncodingName;
/*!
* The MIME type if available. Eg: "text/plain"
*/
@property (nonatomic, readonly, nullable, copy) NSString *MIMEType;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,25 @@
//
// SPUDownloader.h
// Downloader
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SPUDownloaderProtocol.h"
@protocol SPUDownloaderDelegate;
// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection.
@interface SPUDownloader : NSObject <SPUDownloaderProtocol>
// Due to XPC remote object reasons, this delegate is strongly referenced
// Invoke cleanup when done with this instance
- (instancetype)initWithDelegate:(id <SPUDownloaderDelegate>)delegate;
@end

View File

@ -0,0 +1,38 @@
//
// SPUDownloaderDelegate.h
// Sparkle
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
NS_ASSUME_NONNULL_BEGIN
@class SPUDownloadData;
@protocol SPUDownloaderDelegate <NSObject>
// This is only invoked for persistent downloads
- (void)downloaderDidSetDestinationName:(NSString *)destinationName temporaryDirectory:(NSString *)temporaryDirectory;
// Under rare cases, this may be called more than once, in which case the current progress should be reset back to 0
// This is only invoked for persistent downloads
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)expectedContentLength;
// This is only invoked for persistent downloads
- (void)downloaderDidReceiveDataOfLength:(uint64_t)length;
// downloadData is nil if this is a persisent download, otherwise it's non-nil if it's a temporary download
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable)downloadData;
- (void)downloaderDidFailWithError:(NSError *)error;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,13 @@
//
// SPUDownloaderDeprecated.h
// Sparkle
//
// Created by Deadpikle on 12/20/17.
// Copyright © 2017 Sparkle Project. All rights reserved.
//
#import "SPUDownloader.h"
@interface SPUDownloaderDeprecated : SPUDownloader <SPUDownloaderProtocol>
@end

View File

@ -0,0 +1,34 @@
//
// SPUDownloaderProtocol.h
// PersistentDownloader
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
NS_ASSUME_NONNULL_BEGIN
@class SPUURLRequest;
// The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service.
@protocol SPUDownloaderProtocol
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename;
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request;
- (void)downloadDidFinish;
- (void)cleanup;
- (void)cancel;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,20 @@
//
// SPUDownloaderSession.h
// Sparkle
//
// Created by Deadpikle on 12/20/17.
// Copyright © 2017 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SPUDownloader.h"
#import "SPUDownloaderProtocol.h"
NS_CLASS_AVAILABLE(NSURLSESSION_AVAILABLE, 7_0)
@interface SPUDownloaderSession : SPUDownloader <SPUDownloaderProtocol>
@end

View File

@ -0,0 +1,35 @@
//
// SPUURLRequest.h
// Sparkle
//
// Created by Mayur Pawashe on 5/19/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
NS_ASSUME_NONNULL_BEGIN
// A class that wraps NSURLRequest and implements NSSecureCoding
// This class exists because NSURLRequest did not support NSSecureCoding in macOS 10.8
// I have not verified if NSURLRequest in 10.9 implements NSSecureCoding or not
@interface SPUURLRequest : NSObject <NSSecureCoding>
// Creates a new URL request
// Only these properties are currently tracked:
// * URL
// * Cache policy
// * Timeout interval
// * HTTP header fields
// * networkServiceType
+ (instancetype)URLRequestWithRequest:(NSURLRequest *)request;
@property (nonatomic, readonly) NSURLRequest *request;
@end
NS_ASSUME_NONNULL_END

View File

@ -9,19 +9,27 @@
#ifndef SUAPPCAST_H
#define SUAPPCAST_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
NS_ASSUME_NONNULL_BEGIN
@class SUAppcastItem;
SU_EXPORT @interface SUAppcast : NSObject<NSURLDownloadDelegate>
SU_EXPORT @interface SUAppcast : NSObject
@property (copy) NSString *userAgentString;
@property (copy) NSDictionary *httpHeaders;
@property (copy, nullable) NSString *userAgentString;
@property (copy, nullable) NSDictionary<NSString *, NSString *> *httpHeaders;
- (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *))err;
- (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)bg completionBlock:(void (^)(NSError *_Nullable))err;
- (SUAppcast *)copyWithoutDeltaUpdates;
@property (readonly, copy) NSArray *items;
@property (readonly, copy, nullable) NSArray *items;
@end
NS_ASSUME_NONNULL_END
#endif

View File

@ -9,19 +9,26 @@
#ifndef SUAPPCASTITEM_H
#define SUAPPCASTITEM_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
@class SUSignatures;
SU_EXPORT @interface SUAppcastItem : NSObject
@property (copy, readonly) NSString *title;
@property (copy, readonly) NSDate *date;
@property (copy, readonly) NSString *dateString;
@property (copy, readonly) NSString *itemDescription;
@property (strong, readonly) NSURL *releaseNotesURL;
@property (copy, readonly) NSString *DSASignature;
@property (strong, readonly) SUSignatures *signatures;
@property (copy, readonly) NSString *minimumSystemVersion;
@property (copy, readonly) NSString *maximumSystemVersion;
@property (strong, readonly) NSURL *fileURL;
@property (nonatomic, readonly) uint64_t contentLength;
@property (copy, readonly) NSString *versionString;
@property (copy, readonly) NSString *osString;
@property (copy, readonly) NSString *displayVersionString;
@property (copy, readonly) NSDictionary *deltaUpdates;
@property (strong, readonly) NSURL *infoURL;
@ -32,6 +39,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
@property (getter=isMacOsUpdate, readonly) BOOL macOsUpdate;
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.

View File

@ -0,0 +1,22 @@
//
// SUCodeSigningVerifier.h
// Sparkle
//
// Created by Andy Matuschak on 7/5/12.
//
//
#ifndef SUCODESIGNINGVERIFIER_H
#define SUCODESIGNINGVERIFIER_H
#import <Foundation/Foundation.h>
#import "SUExport.h"
SU_EXPORT @interface SUCodeSigningVerifier : NSObject
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundlePath matchesSignatureAtBundleURL:(NSURL *)newBundlePath error:(NSError **)error;
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundlePath error:(NSError **)error;
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundlePath;
+ (NSDictionary *)codeSignatureInfoAtBundleURL:(NSURL *)bundlePath;
@end
#endif

View File

@ -9,7 +9,11 @@
#ifndef SUERRORS_H
#define SUERRORS_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
/**
@ -17,16 +21,19 @@
*/
SU_EXPORT extern NSString *const SUSparkleErrorDomain;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat"
typedef NS_ENUM(OSStatus, SUError) {
// Appcast phase errors.
SUAppcastParseError = 1000,
SUNoUpdateError = 1001,
SUAppcastError = 1002,
SURunningFromDiskImageError = 1003,
// Downlaod phase errors.
// Download phase errors.
SUTemporaryDirectoryError = 2000,
SUDownloadError = 2001,
// Extraction phase errors.
SUUnarchivingError = 3000,
SUSignatureError = 3001,
@ -39,9 +46,11 @@ typedef NS_ENUM(OSStatus, SUError) {
SURelaunchError = 4004,
SUInstallationError = 4005,
SUDowngradeError = 4006,
SUInstallationCancelledError = 4007,
// System phase errors
SUSystemPowerOffError = 5000
};
#pragma clang diagnostic pop
#endif

View File

@ -9,10 +9,16 @@
#ifndef SUSTANDARDVERSIONCOMPARATOR_H
#define SUSTANDARDVERSIONCOMPARATOR_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
#import "SUVersionComparisonProtocol.h"
NS_ASSUME_NONNULL_BEGIN
/*!
Sparkle's default version comparator.
@ -22,8 +28,15 @@
*/
SU_EXPORT @interface SUStandardVersionComparator : NSObject <SUVersionComparison>
/*!
Initializes a new instance of the standard version comparator.
*/
- (instancetype)init;
/*!
Returns a singleton instance of the comparator.
It is usually preferred to alloc/init new a comparator instead.
*/
+ (SUStandardVersionComparator *)defaultComparator;
@ -35,4 +48,5 @@ SU_EXPORT @interface SUStandardVersionComparator : NSObject <SUVersionComparison
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB;
@end
NS_ASSUME_NONNULL_END
#endif

View File

@ -9,7 +9,11 @@
#ifndef SUUPDATER_H
#define SUUPDATER_H
#import <Foundation/Foundation.h>
#if __has_feature(modules)
@import Cocoa;
#else
#import <Cocoa/Cocoa.h>
#endif
#import "SUExport.h"
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
@ -28,62 +32,171 @@ SU_EXPORT @interface SUUpdater : NSObject
@property (unsafe_unretained) IBOutlet id<SUUpdaterDelegate> delegate;
/*!
The shared updater for the main bundle.
This is equivalent to passing [NSBundle mainBundle] to SUUpdater::updaterForBundle:
*/
+ (SUUpdater *)sharedUpdater;
/*!
The shared updater for a specified bundle.
If an updater has already been initialized for the provided bundle, that shared instance will be returned.
*/
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
/*!
Designated initializer for SUUpdater.
If an updater has already been initialized for the provided bundle, that shared instance will be returned.
*/
- (instancetype)initForBundle:(NSBundle *)bundle;
@property (readonly, strong) NSBundle *hostBundle;
@property (strong, readonly) NSBundle *sparkleBundle;
@property BOOL automaticallyChecksForUpdates;
@property NSTimeInterval updateCheckInterval;
/*!
* The URL of the appcast used to download update information.
*
* This property must be called on the main thread.
*/
@property (copy) NSURL *feedURL;
Explicitly checks for updates and displays a progress dialog while doing so.
@property (nonatomic, copy) NSString *userAgentString;
This method is meant for a main menu item.
Connect any menu item to this action in Interface Builder,
and Sparkle will check for updates and report back its findings verbosely
when it is invoked.
@property (copy) NSDictionary *httpHeaders;
@property BOOL sendsSystemProfile;
@property BOOL automaticallyDownloadsUpdates;
@property (nonatomic, copy) NSString *decryptionPassword;
/*!
Explicitly checks for updates and displays a progress dialog while doing so.
This method is meant for a main menu item.
Connect any menu item to this action in Interface Builder,
and Sparkle will check for updates and report back its findings verbosely
when it is invoked.
This will find updates that the user has opted into skipping.
*/
- (IBAction)checkForUpdates:(id)sender;
/*!
Checks for updates, but does not display any UI unless an update is found.
The menu item validation used for the -checkForUpdates: action
*/
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
This is meant for programmatically initating a check for updates. That is,
it will display no UI unless it actually finds an update, in which case it
proceeds as usual.
/*!
Checks for updates, but does not display any UI unless an update is found.
If the fully automated updating is turned on, however, this will invoke that
behavior, and if an update is found, it will be downloaded and prepped for
installation.
This is meant for programmatically initating a check for updates. That is,
it will display no UI unless it actually finds an update, in which case it
proceeds as usual.
If automatic downloading of updates it turned on and allowed, however,
this will invoke that behavior, and if an update is found, it will be downloaded
in the background silently and will be prepped for installation.
This will not find updates that the user has opted into skipping.
*/
- (void)checkForUpdatesInBackground;
/*!
Checks for updates and, if available, immediately downloads and installs them.
A property indicating whether or not to check for updates automatically.
Setting this property will persist in the host bundle's user defaults.
The update schedule cycle will be reset in a short delay after the property's new value is set.
This is to allow reverting this property without kicking off a schedule change immediately
*/
@property BOOL automaticallyChecksForUpdates;
/*!
A property indicating whether or not updates can be automatically downloaded in the background.
Note that automatic downloading of updates can be disallowed by the developer
or by the user's system if silent updates cannot be done (eg: if they require authentication).
In this case, -automaticallyDownloadsUpdates will return NO regardless of how this property is set.
Setting this property will persist in the host bundle's user defaults.
*/
@property BOOL automaticallyDownloadsUpdates;
/*!
A property indicating the current automatic update check interval.
Setting this property will persist in the host bundle's user defaults.
The update schedule cycle will be reset in a short delay after the property's new value is set.
This is to allow reverting this property without kicking off a schedule change immediately
*/
@property NSTimeInterval updateCheckInterval;
/*!
Begins a "probing" check for updates which will not actually offer to
update to that version.
However, the delegate methods
SUUpdaterDelegate::updater:didFindValidUpdate: and
SUUpdaterDelegate::updaterDidNotFindUpdate: will be called,
so you can use that information in your UI.
Updates that have been skipped by the user will not be found.
*/
- (void)checkForUpdateInformation;
/*!
The URL of the appcast used to download update information.
Setting this property will persist in the host bundle's user defaults.
If you don't want persistence, you may want to consider instead implementing
SUUpdaterDelegate::feedURLStringForUpdater: or SUUpdaterDelegate::feedParametersForUpdater:sendingSystemProfile:
This property must be called on the main thread.
*/
@property (copy) NSURL *feedURL;
/*!
The host bundle that is being updated.
*/
@property (readonly, strong) NSBundle *hostBundle;
/*!
The bundle this class (SUUpdater) is loaded into.
*/
@property (strong, readonly) NSBundle *sparkleBundle;
/*!
The user agent used when checking for updates.
The default implementation can be overrided.
*/
@property (nonatomic, copy) NSString *userAgentString;
/*!
The HTTP headers used when checking for updates.
The keys of this dictionary are HTTP header fields (NSString) and values are corresponding values (NSString)
*/
@property (copy) NSDictionary<NSString *, NSString *> *httpHeaders;
/*!
A property indicating whether or not the user's system profile information is sent when checking for updates.
Setting this property will persist in the host bundle's user defaults.
*/
@property BOOL sendsSystemProfile;
/*!
A property indicating the decryption password used for extracting updates shipped as Apple Disk Images (dmg)
*/
@property (nonatomic, copy) NSString *decryptionPassword;
/*!
This function ignores normal update schedule, ignores user preferences,
and interrupts users with an unwanted immediate app update.
WARNING: this function should not be used in regular apps. This function
is a user-unfriendly hack only for very special cases, like unstable
rapidly-changing beta builds that would not run correctly if they were
even one day out of date.
Instead of this function you should set `SUAutomaticallyUpdate` to `YES`,
which will gracefully install updates when the app quits.
For UI-less/daemon apps that aren't usually quit, instead of this function,
you can use the delegate method
SUUpdaterDelegate::updater:willInstallUpdateOnQuit:immediateInstallationInvocation:
to immediately start installation when an update was found.
A progress dialog is shown but the user will never be prompted to read the
release notes.
This function will cause update to be downloaded twice if automatic updates are
enabled.
You may want to respond to the userDidCancelDownload delegate method in case
the user clicks the "Cancel" button while the update is downloading.
*/
@ -96,17 +209,6 @@ SU_EXPORT @interface SUUpdater : NSObject
*/
@property (readonly, copy) NSDate *lastUpdateCheckDate;
/*!
Begins a "probing" check for updates which will not actually offer to
update to that version.
However, the delegate methods
SUUpdaterDelegate::updater:didFindValidUpdate: and
SUUpdaterDelegate::updaterDidNotFindUpdate: will be called,
so you can use that information in your UI.
*/
- (void)checkForUpdateInformation;
/*!
Appropriately schedules or cancels the update checking timer according to
the preferences for time interval and automatic checks.
@ -116,251 +218,14 @@ SU_EXPORT @interface SUUpdater : NSObject
*/
- (void)resetUpdateCycle;
/*!
A property indicating whether or not an update is in progress.
Note this property is not indicative of whether or not user initiated updates can be performed.
Use SUUpdater::validateMenuItem: for that instead.
*/
@property (readonly) BOOL updateInProgress;
@end
// -----------------------------------------------------------------------------
// SUUpdater Notifications for events that might be interesting to more than just the delegate
// The updater will be the notification object
// -----------------------------------------------------------------------------
SU_EXPORT extern NSString *const SUUpdaterDidFinishLoadingAppCastNotification;
SU_EXPORT extern NSString *const SUUpdaterDidFindValidUpdateNotification;
SU_EXPORT extern NSString *const SUUpdaterDidNotFindUpdateNotification;
SU_EXPORT extern NSString *const SUUpdaterWillRestartNotification;
#define SUUpdaterWillRelaunchApplicationNotification SUUpdaterWillRestartNotification;
#define SUUpdaterWillInstallUpdateNotification SUUpdaterWillRestartNotification;
// Key for the SUAppcastItem object in the SUUpdaterDidFindValidUpdateNotification userInfo
SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
// Key for the SUAppcast object in the SUUpdaterDidFinishLoadingAppCastNotification userInfo
SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
// -----------------------------------------------------------------------------
// SUUpdater Delegate:
// -----------------------------------------------------------------------------
/*!
Provides methods to control the behavior of an SUUpdater object.
*/
@protocol SUUpdaterDelegate <NSObject>
@optional
/*!
Returns whether to allow Sparkle to pop up.
For example, this may be used to prevent Sparkle from interrupting a setup assistant.
\param updater The SUUpdater instance.
*/
- (BOOL)updaterMayCheckForUpdates:(SUUpdater *)updater;
/*!
Returns additional parameters to append to the appcast URL's query string.
This is potentially based on whether or not Sparkle will also be sending along the system profile.
\param updater The SUUpdater instance.
\param sendingProfile Whether the system profile will also be sent.
\return An array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
*/
- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
/*!
Returns a custom appcast URL.
Override this to dynamically specify the entire URL.
\param updater The SUUpdater instance.
*/
- (NSString *)feedURLStringForUpdater:(SUUpdater *)updater;
/*!
Returns whether Sparkle should prompt the user about automatic update checks.
Use this to override the default behavior.
\param updater The SUUpdater instance.
*/
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)updater;
/*!
Called after Sparkle has downloaded the appcast from the remote server.
Implement this if you want to do some special handling with the appcast once it finishes loading.
\param updater The SUUpdater instance.
\param appcast The appcast that was downloaded from the remote server.
*/
- (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
/*!
Returns the item in the appcast corresponding to the update that should be installed.
If you're using special logic or extensions in your appcast,
implement this to use your own logic for finding a valid update, if any,
in the given appcast.
\param appcast The appcast that was downloaded from the remote server.
\param updater The SUUpdater instance.
*/
- (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)updater;
/*!
Called when a valid update is found by the update driver.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
*/
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
/*!
Called when a valid update is not found.
\param updater The SUUpdater instance.
*/
- (void)updaterDidNotFindUpdate:(SUUpdater *)updater;
/*!
Called immediately before downloading the specified update.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be downloaded.
\param request The mutable URL request that will be used to download the update.
*/
- (void)updater:(SUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request;
/*!
Called after the specified update failed to download.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that failed to download.
\param error The error generated by the failed download.
*/
- (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;
/*!
Called when the user clicks the cancel button while and update is being downloaded.
\param updater The SUUpdater instance.
*/
- (void)userDidCancelDownload:(SUUpdater *)updater;
/*!
Called immediately before installing the specified update.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
*/
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
/*!
Returns whether the relaunch should be delayed in order to perform other tasks.
This is not called if the user didn't relaunch on the previous update,
in that case it will immediately restart.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
\param invocation The invocation that must be completed before continuing with the relaunch.
\return \c YES to delay the relaunch until \p invocation is invoked.
*/
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvoking:(NSInvocation *)invocation;
/*!
Returns whether the application should be relaunched at all.
Some apps \b cannot be relaunched under certain circumstances.
This method can be used to explicitly prevent a relaunch.
\param updater The SUUpdater instance.
*/
- (BOOL)updaterShouldRelaunchApplication:(SUUpdater *)updater;
/*!
Called immediately before relaunching.
\param updater The SUUpdater instance.
*/
- (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
/*!
Returns an object that compares version numbers to determine their arithmetic relation to each other.
This method allows you to provide a custom version comparator.
If you don't implement this method or return \c nil,
the standard version comparator will be used.
\sa SUStandardVersionComparator
\param updater The SUUpdater instance.
*/
- (id<SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
/*!
Returns an object that formats version numbers for display to the user.
If you don't implement this method or return \c nil,
the standard version formatter will be used.
\sa SUUpdateAlert
\param updater The SUUpdater instance.
*/
- (id<SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
/*!
Returns the path which is used to relaunch the client after the update is installed.
The default is the path of the host bundle.
\param updater The SUUpdater instance.
*/
- (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
/*!
Called before an updater shows a modal alert window,
to give the host the opportunity to hide attached windows that may get in the way.
\param updater The SUUpdater instance.
*/
- (void)updaterWillShowModalAlert:(SUUpdater *)updater;
/*!
Called after an updater shows a modal alert window,
to give the host the opportunity to hide attached windows that may get in the way.
\param updater The SUUpdater instance.
*/
- (void)updaterDidShowModalAlert:(SUUpdater *)updater;
/*!
Called when an update is scheduled to be silently installed on quit.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
\param invocation Can be used to trigger an immediate silent install and relaunch.
*/
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation;
/*!
Calls after an update that was scheduled to be silently installed on quit has been canceled.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that was proposed to be installed.
*/
- (void)updater:(SUUpdater *)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)item;
/*!
Called after an update is aborted due to an error.
\param updater The SUUpdater instance.
\param error The error that caused the abort
*/
- (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error;
@end
#endif

View File

@ -0,0 +1,301 @@
//
// SUUpdaterDelegate.h
// Sparkle
//
// Created by Mayur Pawashe on 12/25/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
@protocol SUVersionComparison, SUVersionDisplay;
@class SUUpdater, SUAppcast, SUAppcastItem;
NS_ASSUME_NONNULL_BEGIN
// -----------------------------------------------------------------------------
// SUUpdater Notifications for events that might be interesting to more than just the delegate
// The updater will be the notification object
// -----------------------------------------------------------------------------
SU_EXPORT extern NSString *const SUUpdaterDidFinishLoadingAppCastNotification;
SU_EXPORT extern NSString *const SUUpdaterDidFindValidUpdateNotification;
SU_EXPORT extern NSString *const SUUpdaterDidNotFindUpdateNotification;
SU_EXPORT extern NSString *const SUUpdaterWillRestartNotification;
#define SUUpdaterWillRelaunchApplicationNotification SUUpdaterWillRestartNotification;
#define SUUpdaterWillInstallUpdateNotification SUUpdaterWillRestartNotification;
// Key for the SUAppcastItem object in the SUUpdaterDidFindValidUpdateNotification userInfo
SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
// Key for the SUAppcast object in the SUUpdaterDidFinishLoadingAppCastNotification userInfo
SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
// -----------------------------------------------------------------------------
// SUUpdater Delegate:
// -----------------------------------------------------------------------------
/*!
Provides methods to control the behavior of an SUUpdater object.
*/
@protocol SUUpdaterDelegate <NSObject>
@optional
/*!
Returns whether to allow Sparkle to pop up.
For example, this may be used to prevent Sparkle from interrupting a setup assistant.
\param updater The SUUpdater instance.
*/
- (BOOL)updaterMayCheckForUpdates:(SUUpdater *)updater;
/*!
Returns additional parameters to append to the appcast URL's query string.
This is potentially based on whether or not Sparkle will also be sending along the system profile.
\param updater The SUUpdater instance.
\param sendingProfile Whether the system profile will also be sent.
\return An array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
*/
- (NSArray<NSDictionary<NSString *, NSString *> *> *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
/*!
Returns a custom appcast URL.
Override this to dynamically specify the entire URL.
An alternative may be to use SUUpdaterDelegate::feedParametersForUpdater:sendingSystemProfile:
and let the server handle what kind of feed to provide.
\param updater The SUUpdater instance.
*/
- (nullable NSString *)feedURLStringForUpdater:(SUUpdater *)updater;
/*!
Returns whether Sparkle should prompt the user about automatic update checks.
Use this to override the default behavior.
\param updater The SUUpdater instance.
*/
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)updater;
/*!
Called after Sparkle has downloaded the appcast from the remote server.
Implement this if you want to do some special handling with the appcast once it finishes loading.
\param updater The SUUpdater instance.
\param appcast The appcast that was downloaded from the remote server.
*/
- (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
/*!
Returns the item in the appcast corresponding to the update that should be installed.
If you're using special logic or extensions in your appcast,
implement this to use your own logic for finding a valid update, if any,
in the given appcast.
\param appcast The appcast that was downloaded from the remote server.
\param updater The SUUpdater instance.
*/
- (nullable SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)updater;
/*!
Called when a valid update is found by the update driver.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
*/
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
/*!
Called when a valid update is not found.
\param updater The SUUpdater instance.
*/
- (void)updaterDidNotFindUpdate:(SUUpdater *)updater;
/*!
Called immediately before downloading the specified update.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be downloaded.
\param request The mutable URL request that will be used to download the update.
*/
- (void)updater:(SUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request;
/*!
Called immediately after succesfull download of the specified update.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that has been downloaded.
*/
- (void)updater:(SUUpdater *)updater didDownloadUpdate:(SUAppcastItem *)item;
/*!
Called after the specified update failed to download.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that failed to download.
\param error The error generated by the failed download.
*/
- (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;
/*!
Called when the user clicks the cancel button while and update is being downloaded.
\param updater The SUUpdater instance.
*/
- (void)userDidCancelDownload:(SUUpdater *)updater;
/*!
Called immediately before extracting the specified downloaded update.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be extracted.
*/
- (void)updater:(SUUpdater *)updater willExtractUpdate:(SUAppcastItem *)item;
/*!
Called immediately after extracting the specified downloaded update.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that has been extracted.
*/
- (void)updater:(SUUpdater *)updater didExtractUpdate:(SUAppcastItem *)item;
/*!
Called immediately before installing the specified update.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
*/
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
/*!
Returns whether the relaunch should be delayed in order to perform other tasks.
This is not called if the user didn't relaunch on the previous update,
in that case it will immediately restart.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
\param invocation The invocation that must be completed with `[invocation invoke]` before continuing with the relaunch.
\return \c YES to delay the relaunch until \p invocation is invoked.
*/
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvoking:(NSInvocation *)invocation;
/*!
Returns whether the application should be relaunched at all.
Some apps \b cannot be relaunched under certain circumstances.
This method can be used to explicitly prevent a relaunch.
\param updater The SUUpdater instance.
*/
- (BOOL)updaterShouldRelaunchApplication:(SUUpdater *)updater;
/*!
Called immediately before relaunching.
\param updater The SUUpdater instance.
*/
- (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
/*!
Called immediately after relaunching. SUUpdater delegate must be set before applicationDidFinishLaunching: to catch this event.
\param updater The SUUpdater instance.
*/
- (void)updaterDidRelaunchApplication:(SUUpdater *)updater;
/*!
Returns an object that compares version numbers to determine their arithmetic relation to each other.
This method allows you to provide a custom version comparator.
If you don't implement this method or return \c nil,
the standard version comparator will be used.
\sa SUStandardVersionComparator
\param updater The SUUpdater instance.
*/
- (nullable id<SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
/*!
Returns an object that formats version numbers for display to the user.
If you don't implement this method or return \c nil,
the standard version formatter will be used.
\sa SUUpdateAlert
\param updater The SUUpdater instance.
*/
- (nullable id<SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
/*!
Returns the path which is used to relaunch the client after the update is installed.
The default is the path of the host bundle.
\param updater The SUUpdater instance.
*/
- (nullable NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
/*!
Called before an updater shows a modal alert window,
to give the host the opportunity to hide attached windows that may get in the way.
\param updater The SUUpdater instance.
*/
- (void)updaterWillShowModalAlert:(SUUpdater *)updater;
/*!
Called after an updater shows a modal alert window,
to give the host the opportunity to hide attached windows that may get in the way.
\param updater The SUUpdater instance.
*/
- (void)updaterDidShowModalAlert:(SUUpdater *)updater;
/*!
Called when an update is scheduled to be silently installed on quit.
This is after an update has been automatically downloaded in the background.
(i.e. SUUpdater::automaticallyDownloadsUpdates is YES)
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
\param invocation Can be used to trigger an immediate silent install and relaunch.
*/
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation;
/*!
Calls after an update that was scheduled to be silently installed on quit has been canceled.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that was proposed to be installed.
*/
- (void)updater:(SUUpdater *)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)item;
/*!
Called after an update is aborted due to an error.
\param updater The SUUpdater instance.
\param error The error that caused the abort
*/
- (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error;
@end
NS_ASSUME_NONNULL_END

View File

@ -9,9 +9,15 @@
#ifndef SUVERSIONCOMPARISONPROTOCOL_H
#define SUVERSIONCOMPARISONPROTOCOL_H
#import <Cocoa/Cocoa.h>
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
NS_ASSUME_NONNULL_BEGIN
/*!
Provides version comparison facilities for Sparkle.
*/
@ -27,4 +33,5 @@
@end
NS_ASSUME_NONNULL_END
#endif

View File

@ -6,7 +6,11 @@
// Copyright 2009 Elgato Systems GmbH. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
/*!
@ -20,6 +24,6 @@
Both versions are provided so that important distinguishing information
can be displayed while also leaving out unnecessary/confusing parts.
*/
- (void)formatVersion:(NSString **)inOutVersionA andVersion:(NSString **)inOutVersionB;
- (void)formatVersion:(NSString *_Nonnull*_Nonnull)inOutVersionA andVersion:(NSString *_Nonnull*_Nonnull)inOutVersionB;
@end

View File

@ -9,8 +9,6 @@
#ifndef SPARKLE_H
#define SPARKLE_H
#import <Cocoa/Cocoa.h>
// This list should include the shared headers. It doesn't matter if some of them aren't shared (unless
// there are name-space collisions) so we can list all of them to start with:
@ -18,8 +16,18 @@
#import "SUAppcastItem.h"
#import "SUStandardVersionComparator.h"
#import "SUUpdater.h"
#import "SUUpdaterDelegate.h"
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
#import "SUErrors.h"
#import "SPUDownloader.h"
#import "SPUDownloaderDelegate.h"
#import "SPUDownloaderDeprecated.h"
#import "SPUDownloadData.h"
#import "SPUDownloaderProtocol.h"
#import "SPUDownloaderSession.h"
#import "SPUURLRequest.h"
#import "SUCodeSigningVerifier.h"
#endif

View File

@ -6,31 +6,16 @@
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#ifndef SUUNARCHIVER_H
#define SUUNARCHIVER_H
#import <Foundation/Foundation.h>
@class SUHost;
@protocol SUUnarchiverDelegate;
NS_ASSUME_NONNULL_BEGIN
@protocol SUUnarchiverProtocol;
@interface SUUnarchiver : NSObject
@property (copy, readonly) NSString *archivePath;
@property (copy, readonly) NSString *updateHostBundlePath;
@property (copy, readonly) NSString *decryptionPassword;
@property (weak) id<SUUnarchiverDelegate> delegate;
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword;
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)host withPassword:(NSString *)decryptionPassword;
- (void)start;
@end
@protocol SUUnarchiverDelegate <NSObject>
- (void)unarchiverDidFinish:(SUUnarchiver *)unarchiver;
- (void)unarchiverDidFail:(SUUnarchiver *)unarchiver;
@optional
- (void)unarchiver:(SUUnarchiver *)unarchiver extractedProgress:(double)progress;
@end
#endif
NS_ASSUME_NONNULL_END

View File

@ -3,13 +3,13 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>15E49a</string>
<string>18D42</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Autoupdate</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<string>AppIcon.icns</string>
<key>CFBundleIdentifier</key>
<string>org.sparkle-project.Sparkle.Autoupdate</string>
<key>CFBundleInfoDictionaryVersion</key>
@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.14.0</string>
<string>1.21.3 18-g1ff157710</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
@ -25,21 +25,21 @@
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1.14.0</string>
<string>1.21.3</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>7C1002</string>
<string>10B61</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>15C43</string>
<string>18B71</string>
<key>DTSDKName</key>
<string>macosx10.11</string>
<string>macosx10.14</string>
<key>DTXcode</key>
<string>0721</string>
<string>1010</string>
<key>DTXcodeBuild</key>
<string>7C1002</string>
<string>10B61</string>
<key>LSBackgroundOnly</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>

View File

@ -0,0 +1,9 @@
html {
color: #FFFFFFD8;
}
:link {
color: #419CFF;
}
:link:active {
color: #FF1919;
}

View File

@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>15E49a</string>
<string>18D42</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.14.0</string>
<string>1.21.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
@ -25,20 +25,20 @@
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1.14.0</string>
<string>1.21.3</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>7C1002</string>
<string>10B61</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>15C43</string>
<string>18B71</string>
<key>DTSDKName</key>
<string>macosx10.11</string>
<string>macosx10.14</string>
<key>DTXcode</key>
<string>0721</string>
<string>1010</string>
<key>DTXcodeBuild</key>
<string>7C1002</string>
<string>10B61</string>
</dict>
</plist>

Some files were not shown because too many files have changed in this diff Show More