Renamed GoogleReaderCompatible to just Reader

This commit is contained in:
Jeremy Beker 2019-06-19 12:25:37 -04:00
parent c8b9cf4d2c
commit d87f68a006
No known key found for this signature in database
GPG Key ID: CD5EE767A4A34FD0
16 changed files with 183 additions and 190 deletions

View File

@ -33,7 +33,7 @@ public enum AccountType: Int {
case feedbin = 17
case feedWrangler = 18
case newsBlur = 19
case googleReaderCompatible = 20
case googleReaderAPI = 20
// TODO: more
}
@ -217,8 +217,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
self.delegate = LocalAccountDelegate()
case .feedbin:
self.delegate = FeedbinAccountDelegate(dataFolder: dataFolder, transport: transport)
case .googleReaderCompatible:
self.delegate = GoogleReaderCompatibleAccountDelegate(dataFolder: dataFolder, transport: transport)
case .googleReaderAPI:
self.delegate = ReaderAPIAccountDelegate(dataFolder: dataFolder, transport: transport)
default:
fatalError("Only Local and Feedbin accounts are supported")
}
@ -246,8 +246,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
defaultName = "FeedWrangler"
case .newsBlur:
defaultName = "NewsBlur"
case .googleReaderCompatible:
defaultName = "Google Reader Compatible"
case .googleReaderAPI:
defaultName = "Reader"
}
NotificationCenter.default.addObserver(self, selector: #selector(downloadProgressDidChange(_:)), name: .DownloadProgressDidChange, object: nil)
@ -327,8 +327,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
LocalAccountDelegate.validateCredentials(transport: transport, credentials: credentials, completion: completion)
case .feedbin:
FeedbinAccountDelegate.validateCredentials(transport: transport, credentials: credentials, completion: completion)
case .googleReaderCompatible:
GoogleReaderCompatibleAccountDelegate.validateCredentials(transport: transport, credentials: credentials, endpoint: endpoint, completion: completion)
case .googleReaderAPI:
ReaderAPIAccountDelegate.validateCredentials(transport: transport, credentials: credentials, endpoint: endpoint, completion: completion)
default:
break
}

View File

@ -35,13 +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 /* GoogleReaderCompatibleEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032ED229D5D5A009559E0 /* GoogleReaderCompatibleEntry.swift */; };
552032F9229D5D5A009559E0 /* GoogleReaderCompatibleSubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032EE229D5D5A009559E0 /* GoogleReaderCompatibleSubscription.swift */; };
552032FB229D5D5A009559E0 /* GoogleReaderCompatibleTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032F0229D5D5A009559E0 /* GoogleReaderCompatibleTag.swift */; };
552032FC229D5D5A009559E0 /* GoogleReaderCompatibleUnreadEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032F1229D5D5A009559E0 /* GoogleReaderCompatibleUnreadEntry.swift */; };
552032FD229D5D5A009559E0 /* GoogleReaderCompatibleTagging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032F2229D5D5A009559E0 /* GoogleReaderCompatibleTagging.swift */; };
552032FE229D5D5A009559E0 /* GoogleReaderCompatibleAccountDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032F3229D5D5A009559E0 /* GoogleReaderCompatibleAccountDelegate.swift */; };
55203300229D5D5A009559E0 /* GoogleReaderCompatibleAPICaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552032F5229D5D5A009559E0 /* GoogleReaderCompatibleAPICaller.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 */; };
@ -143,13 +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 /* GoogleReaderCompatibleEntry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GoogleReaderCompatibleEntry.swift; sourceTree = "<group>"; };
552032EE229D5D5A009559E0 /* GoogleReaderCompatibleSubscription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GoogleReaderCompatibleSubscription.swift; sourceTree = "<group>"; };
552032F0229D5D5A009559E0 /* GoogleReaderCompatibleTag.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GoogleReaderCompatibleTag.swift; sourceTree = "<group>"; };
552032F1229D5D5A009559E0 /* GoogleReaderCompatibleUnreadEntry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GoogleReaderCompatibleUnreadEntry.swift; sourceTree = "<group>"; };
552032F2229D5D5A009559E0 /* GoogleReaderCompatibleTagging.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GoogleReaderCompatibleTagging.swift; sourceTree = "<group>"; };
552032F3229D5D5A009559E0 /* GoogleReaderCompatibleAccountDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GoogleReaderCompatibleAccountDelegate.swift; sourceTree = "<group>"; };
552032F5229D5D5A009559E0 /* GoogleReaderCompatibleAPICaller.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GoogleReaderCompatibleAPICaller.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>"; };
@ -236,18 +236,18 @@
path = JSON;
sourceTree = "<group>";
};
552032EA229D5D5A009559E0 /* GoogleReaderCompatible */ = {
552032EA229D5D5A009559E0 /* ReaderAPI */ = {
isa = PBXGroup;
children = (
552032ED229D5D5A009559E0 /* GoogleReaderCompatibleEntry.swift */,
552032EE229D5D5A009559E0 /* GoogleReaderCompatibleSubscription.swift */,
552032F0229D5D5A009559E0 /* GoogleReaderCompatibleTag.swift */,
552032F1229D5D5A009559E0 /* GoogleReaderCompatibleUnreadEntry.swift */,
552032F2229D5D5A009559E0 /* GoogleReaderCompatibleTagging.swift */,
552032F3229D5D5A009559E0 /* GoogleReaderCompatibleAccountDelegate.swift */,
552032F5229D5D5A009559E0 /* GoogleReaderCompatibleAPICaller.swift */,
552032ED229D5D5A009559E0 /* ReaderAPIEntry.swift */,
552032EE229D5D5A009559E0 /* ReaderAPISubscription.swift */,
552032F0229D5D5A009559E0 /* ReaderAPITag.swift */,
552032F1229D5D5A009559E0 /* ReaderAPIUnreadEntry.swift */,
552032F2229D5D5A009559E0 /* ReaderAPITagging.swift */,
552032F3229D5D5A009559E0 /* ReaderAPIAccountDelegate.swift */,
552032F5229D5D5A009559E0 /* ReaderAPICaller.swift */,
);
path = GoogleReaderCompatible;
path = ReaderAPI;
sourceTree = "<group>";
};
841973E91F6DD19E006346C4 /* Products */ = {
@ -330,7 +330,7 @@
5165D71F22835E9800D9D53D /* FeedFinder */,
8419742B1F6DDE84006346C4 /* LocalAccount */,
84245C7D1FDDD2580074AFBB /* Feedbin */,
552032EA229D5D5A009559E0 /* GoogleReaderCompatible */,
552032EA229D5D5A009559E0 /* ReaderAPI */,
848935031F62484F00CEBD24 /* AccountTests */,
848934F71F62484F00CEBD24 /* Products */,
8469F80F1F6DC3C10084783E /* Frameworks */,
@ -544,13 +544,13 @@
buildActionMask = 2147483647;
files = (
84C8B3F41F89DE430053CCA6 /* DataExtensions.swift in Sources */,
552032F9229D5D5A009559E0 /* GoogleReaderCompatibleSubscription.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 /* GoogleReaderCompatibleTagging.swift in Sources */,
552032FD229D5D5A009559E0 /* ReaderAPITagging.swift in Sources */,
84F73CF1202788D90000BCEF /* ArticleFetcher.swift in Sources */,
841974251F6DDCE4006346C4 /* AccountDelegate.swift in Sources */,
5165D73122837F3400D9D53D /* InitialFeedDownloader.swift in Sources */,
@ -564,15 +564,15 @@
84B99C9F1FAE8D3200ECDEDB /* ContainerPath.swift in Sources */,
5133231122810EB200C30F19 /* FeedbinIcon.swift in Sources */,
846E77501F6EF9C400A165E2 /* LocalAccountRefresher.swift in Sources */,
55203300229D5D5A009559E0 /* GoogleReaderCompatibleAPICaller.swift in Sources */,
55203300229D5D5A009559E0 /* ReaderAPICaller.swift in Sources */,
51E3EB41229AF61B00645299 /* AccountError.swift in Sources */,
51E59599228C77BC00FCC42B /* FeedbinUnreadEntry.swift in Sources */,
552032F8229D5D5A009559E0 /* GoogleReaderCompatibleEntry.swift in Sources */,
552032FB229D5D5A009559E0 /* GoogleReaderCompatibleTag.swift in Sources */,
552032F8229D5D5A009559E0 /* ReaderAPIEntry.swift in Sources */,
552032FB229D5D5A009559E0 /* ReaderAPITag.swift in Sources */,
5165D72822835F7800D9D53D /* FeedFinder.swift in Sources */,
51D58755227F53BE00900287 /* FeedbinTag.swift in Sources */,
552032FE229D5D5A009559E0 /* GoogleReaderCompatibleAccountDelegate.swift in Sources */,
552032FC229D5D5A009559E0 /* GoogleReaderCompatibleUnreadEntry.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

@ -1,5 +1,5 @@
//
// GoogleReaderCompatibleAccountDelegate.swift
// ReaderAPIAccountDelegate.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
@ -19,17 +19,17 @@ import RSWeb
import SyncDatabase
import os.log
public enum GoogleReaderCompatibleAccountDelegateError: String, Error {
public enum ReaderAPIAccountDelegateError: String, Error {
case invalidParameter = "There was an invalid parameter passed."
case invalidResponse = "There was an invalid response from the server."
}
final class GoogleReaderCompatibleAccountDelegate: AccountDelegate {
final class ReaderAPIAccountDelegate: AccountDelegate {
private let database: SyncDatabase
private let caller: GoogleReaderCompatibleAPICaller
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "GoogleReaderCompatible")
private let caller: ReaderAPICaller
private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "ReaderAPI")
let supportsSubFolders = false
let usesTags = true
@ -61,7 +61,7 @@ final class GoogleReaderCompatibleAccountDelegate: AccountDelegate {
if transport != nil {
caller = GoogleReaderCompatibleAPICaller(transport: transport!)
caller = ReaderAPICaller(transport: transport!)
} else {
@ -78,7 +78,7 @@ final class GoogleReaderCompatibleAccountDelegate: AccountDelegate {
sessionConfiguration.httpAdditionalHeaders = userAgentHeaders
}
caller = GoogleReaderCompatibleAPICaller(transport: URLSession(configuration: sessionConfiguration))
caller = ReaderAPICaller(transport: URLSession(configuration: sessionConfiguration))
}
@ -547,7 +547,7 @@ final class GoogleReaderCompatibleAccountDelegate: AccountDelegate {
return
}
let caller = GoogleReaderCompatibleAPICaller(transport: transport)
let caller = ReaderAPICaller(transport: transport)
caller.credentials = credentials
caller.validateCredentials(endpoint: endpoint) { result in
DispatchQueue.main.async {
@ -561,7 +561,7 @@ final class GoogleReaderCompatibleAccountDelegate: AccountDelegate {
// MARK: Private
private extension GoogleReaderCompatibleAccountDelegate {
private extension ReaderAPIAccountDelegate {
func refreshAccount(_ account: Account, completion: @escaping (Result<Void, Error>) -> Void) {
@ -580,7 +580,7 @@ private extension GoogleReaderCompatibleAccountDelegate {
}
func syncFolders(_ account: Account, _ tags: [GoogleReaderCompatibleTag]?) {
func syncFolders(_ account: Account, _ tags: [ReaderAPITag]?) {
guard let tags = tags else { return }
@ -588,7 +588,7 @@ private extension GoogleReaderCompatibleAccountDelegate {
let tagNames = tags.filter { $0.type == "folder" }.map { $0.tagID.replacingOccurrences(of: "user/-/label/", with: "") }
// Delete any folders not at GoogleReaderCompatible
// Delete any folders not at Reader
if let folders = account.folders {
folders.forEach { folder in
if !tagNames.contains(folder.name ?? "") {
@ -611,7 +611,7 @@ private extension GoogleReaderCompatibleAccountDelegate {
}
}()
// Make any folders GoogleReaderCompatible has, but we don't
// Make any folders Reader has, but we don't
tagNames.forEach { tagName in
if !folderNames.contains(tagName) {
DispatchQueue.main.sync {
@ -647,7 +647,7 @@ private extension GoogleReaderCompatibleAccountDelegate {
}
func syncFeeds(_ account: Account, _ subscriptions: [GoogleReaderCompatibleSubscription]?) {
func syncFeeds(_ account: Account, _ subscriptions: [ReaderAPISubscription]?) {
guard let subscriptions = subscriptions else { return }
@ -697,7 +697,7 @@ private extension GoogleReaderCompatibleAccountDelegate {
}
func syncTaggings(_ account: Account, _ subscriptions: [GoogleReaderCompatibleSubscription]?) {
func syncTaggings(_ account: Account, _ subscriptions: [ReaderAPISubscription]?) {
guard let subscriptions = subscriptions else { return }
@ -712,7 +712,7 @@ private extension GoogleReaderCompatibleAccountDelegate {
}
}()
let taggingsDict = subscriptions.reduce([String: [GoogleReaderCompatibleSubscription]]()) { (dict, subscription) in
let taggingsDict = subscriptions.reduce([String: [ReaderAPISubscription]]()) { (dict, subscription) in
var taggedFeeds = dict
// For each category that this feed belongs to, add the feed to that name in the dict
@ -834,7 +834,7 @@ private extension GoogleReaderCompatibleAccountDelegate {
}
}
func decideBestFeedChoice(account: Account, url: String, name: String?, container: Container, choices: [GoogleReaderCompatibleSubscriptionChoice], completion: @escaping (Result<Feed, Error>) -> Void) {
func decideBestFeedChoice(account: Account, url: String, name: String?, container: Container, choices: [ReaderAPISubscriptionChoice], completion: @escaping (Result<Feed, Error>) -> Void) {
let feedSpecifiers: [FeedSpecifier] = choices.map { choice in
let source = url == choice.url ? FeedSpecifier.Source.UserEntered : FeedSpecifier.Source.HTMLLink
@ -847,18 +847,18 @@ private extension GoogleReaderCompatibleAccountDelegate {
createFeed(for: account, url: bestSubscription.url, name: name, container: container, completion: completion)
} else {
DispatchQueue.main.async {
completion(.failure(GoogleReaderCompatibleAccountDelegateError.invalidParameter))
completion(.failure(ReaderAPIAccountDelegateError.invalidParameter))
}
}
} else {
DispatchQueue.main.async {
completion(.failure(GoogleReaderCompatibleAccountDelegateError.invalidParameter))
completion(.failure(ReaderAPIAccountDelegateError.invalidParameter))
}
}
}
func createFeed( account: Account, subscription sub: GoogleReaderCompatibleSubscription, name: String?, container: Container, completion: @escaping (Result<Feed, Error>) -> Void) {
func createFeed( account: Account, subscription sub: ReaderAPISubscription, name: String?, container: Container, completion: @escaping (Result<Feed, Error>) -> Void) {
DispatchQueue.main.async {
@ -1013,7 +1013,7 @@ private extension GoogleReaderCompatibleAccountDelegate {
}
func processEntries(account: Account, entries: [GoogleReaderCompatibleEntry]?, completion: @escaping (() -> Void)) {
func processEntries(account: Account, entries: [ReaderAPIEntry]?, completion: @escaping (() -> Void)) {
let parsedItems = mapEntriesToParsedItems(account: account, entries: entries)
let parsedMap = Dictionary(grouping: parsedItems, by: { item in item.feedURL } )
@ -1042,7 +1042,7 @@ private extension GoogleReaderCompatibleAccountDelegate {
}
func mapEntriesToParsedItems(account: Account, entries: [GoogleReaderCompatibleEntry]?) -> Set<ParsedItem> {
func mapEntriesToParsedItems(account: Account, entries: [ReaderAPIEntry]?) -> Set<ParsedItem> {
guard let entries = entries else {
return Set<ParsedItem>()
@ -1065,11 +1065,11 @@ private extension GoogleReaderCompatibleAccountDelegate {
return
}
let GoogleReaderCompatibleUnreadArticleIDs = Set(articleIDs.map { String($0) } )
let unreadArticleIDs = Set(articleIDs.map { String($0) } )
let currentUnreadArticleIDs = account.fetchUnreadArticleIDs()
// Mark articles as unread
let deltaUnreadArticleIDs = GoogleReaderCompatibleUnreadArticleIDs.subtracting(currentUnreadArticleIDs)
let deltaUnreadArticleIDs = unreadArticleIDs.subtracting(currentUnreadArticleIDs)
let markUnreadArticles = account.fetchArticles(forArticleIDs: deltaUnreadArticleIDs)
DispatchQueue.main.async {
_ = account.update(markUnreadArticles, statusKey: .read, flag: false)
@ -1085,7 +1085,7 @@ private extension GoogleReaderCompatibleAccountDelegate {
}
// Mark articles as read
let deltaReadArticleIDs = currentUnreadArticleIDs.subtracting(GoogleReaderCompatibleUnreadArticleIDs)
let deltaReadArticleIDs = currentUnreadArticleIDs.subtracting(unreadArticleIDs)
let markReadArticles = account.fetchArticles(forArticleIDs: deltaReadArticleIDs)
DispatchQueue.main.async {
_ = account.update(markReadArticles, statusKey: .read, flag: true)
@ -1108,11 +1108,11 @@ private extension GoogleReaderCompatibleAccountDelegate {
return
}
let GoogleReaderCompatibleStarredArticleIDs = Set(articleIDs.map { String($0) } )
let starredArticleIDs = Set(articleIDs.map { String($0) } )
let currentStarredArticleIDs = account.fetchStarredArticleIDs()
// Mark articles as starred
let deltaStarredArticleIDs = GoogleReaderCompatibleStarredArticleIDs.subtracting(currentStarredArticleIDs)
let deltaStarredArticleIDs = starredArticleIDs.subtracting(currentStarredArticleIDs)
let markStarredArticles = account.fetchArticles(forArticleIDs: deltaStarredArticleIDs)
DispatchQueue.main.async {
_ = account.update(markStarredArticles, statusKey: .starred, flag: true)
@ -1128,7 +1128,7 @@ private extension GoogleReaderCompatibleAccountDelegate {
}
// Mark articles as unstarred
let deltaUnstarredArticleIDs = currentStarredArticleIDs.subtracting(GoogleReaderCompatibleStarredArticleIDs)
let deltaUnstarredArticleIDs = currentStarredArticleIDs.subtracting(starredArticleIDs)
let markUnstarredArticles = account.fetchArticles(forArticleIDs: deltaUnstarredArticleIDs)
DispatchQueue.main.async {
_ = account.update(markUnstarredArticles, statusKey: .starred, flag: false)

View File

@ -1,5 +1,5 @@
//
// GoogleReaderCompatibleAPICaller.swift
// ReaderAPICaller.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
@ -9,13 +9,13 @@
import Foundation
import RSWeb
enum CreateGoogleReaderSubscriptionResult {
case created(GoogleReaderCompatibleSubscription)
enum CreateReaderAPISubscriptionResult {
case created(ReaderAPISubscription)
case alreadySubscribed
case notFound
}
final class GoogleReaderCompatibleAPICaller: NSObject {
final class ReaderAPICaller: NSObject {
struct ConditionalGetKeys {
static let subscriptions = "subscriptions"
@ -26,16 +26,16 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
static let starredEntries = "starredEntries"
}
enum GoogleReaderState: String {
enum ReaderState: String {
case read = "user/-/state/com.google/read"
case starred = "user/-/state/com.google/starred"
}
enum GoogleReaderStreams: String {
enum ReaderStreams: String {
case readingList = "user/-/state/com.google/reading-list"
}
enum GoogleReaderEndpoints: String {
enum ReaderAPIEndpoints: String {
case login = "/accounts/ClientLogin"
case token = "/reader/api/0/token"
case disableTag = "/reader/api/0/disable-tag"
@ -89,7 +89,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
return
}
let request = URLRequest(url: endpoint.appendingPathComponent(GoogleReaderEndpoints.login.rawValue), credentials: credentials)
let request = URLRequest(url: endpoint.appendingPathComponent(ReaderAPIEndpoints.login.rawValue), credentials: credentials)
transport.send(request: request) { result in
switch result {
@ -140,7 +140,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
return
}
let request = URLRequest(url: endpoint.appendingPathComponent(GoogleReaderEndpoints.token.rawValue), credentials: credentials)
let request = URLRequest(url: endpoint.appendingPathComponent(ReaderAPIEndpoints.token.rawValue), credentials: credentials)
transport.send(request: request) { result in
switch result {
@ -165,14 +165,14 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
}
func retrieveTags(completion: @escaping (Result<[GoogleReaderCompatibleTag]?, Error>) -> Void) {
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(GoogleReaderEndpoints.tagList.rawValue), resolvingAgainstBaseURL: false) else {
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.tagList.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
@ -189,7 +189,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.tags]
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet)
transport.send(request: request, resultType: GoogleReaderCompatibleTagContainer.self) { result in
transport.send(request: request, resultType: ReaderAPITagContainer.self) { result in
switch result {
case .success(let (response, wrapper)):
@ -212,7 +212,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(GoogleReaderEndpoints.renameTag.rawValue), credentials: self.credentials)
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"
@ -249,7 +249,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(GoogleReaderEndpoints.disableTag.rawValue), credentials: self.credentials)
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.disableTag.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
@ -277,14 +277,14 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
}
func retrieveSubscriptions(completion: @escaping (Result<[GoogleReaderCompatibleSubscription]?, Error>) -> Void) {
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(GoogleReaderEndpoints.subscriptionList.rawValue), resolvingAgainstBaseURL: false) else {
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionList.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
@ -301,7 +301,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.subscriptions]
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet)
transport.send(request: request, resultType: GoogleReaderCompatibleSubscriptionContainer.self) { result in
transport.send(request: request, resultType: ReaderAPISubscriptionContainer.self) { result in
switch result {
case .success(let (response, container)):
@ -315,7 +315,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
}
func createSubscription(url: String, completion: @escaping (Result<CreateGoogleReaderSubscriptionResult, Error>) -> Void) {
func createSubscription(url: String, completion: @escaping (Result<CreateReaderAPISubscriptionResult, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
@ -324,7 +324,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
guard var components = URLComponents(url: baseURL.appendingPathComponent(GoogleReaderEndpoints.subscriptionAdd.rawValue), resolvingAgainstBaseURL: false) else {
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionAdd.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
@ -344,7 +344,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
let postData = "T=\(token)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, data: postData!, resultType: GoogleReaderCompatibleQuickAddResult.self, completion: { (result) in
self.transport.send(request: request, method: HTTPMethod.post, data: postData!, resultType: ReaderAPIQuickAddResult.self, completion: { (result) in
switch result {
case .success(let (_, subResult)):
@ -405,7 +405,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(GoogleReaderEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
@ -440,7 +440,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(GoogleReaderEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
@ -476,7 +476,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(GoogleReaderEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
@ -513,7 +513,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
self.requestAuthorizationToken(endpoint: baseURL) { (result) in
switch result {
case .success(let token):
var request = URLRequest(url: baseURL.appendingPathComponent(GoogleReaderEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
var request = URLRequest(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.subscriptionEdit.rawValue), credentials: self.credentials)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
@ -540,10 +540,10 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
}
}
func retrieveEntries(articleIDs: [String], completion: @escaping (Result<([GoogleReaderCompatibleEntry]?), Error>) -> Void) {
func retrieveEntries(articleIDs: [String], completion: @escaping (Result<([ReaderAPIEntry]?), Error>) -> Void) {
guard !articleIDs.isEmpty else {
completion(.success(([GoogleReaderCompatibleEntry]())))
completion(.success(([ReaderAPIEntry]())))
return
}
@ -556,7 +556,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
switch result {
case .success(let token):
// Do POST asking for data about all the new articles
var request = URLRequest(url: baseURL.appendingPathComponent(GoogleReaderEndpoints.contents.rawValue), credentials: self.credentials)
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"
@ -567,11 +567,11 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
let postData = "T=\(token)&output=json&\(idsToFetch)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, data: postData!, resultType: GoogleReaderCompatibleEntryWrapper.self, completion: { (result) in
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(GoogleReaderCompatibleAccountDelegateError.invalidResponse))
completion(.failure(ReaderAPIAccountDelegateError.invalidResponse))
return
}
@ -589,7 +589,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
}
func retrieveEntries(feedID: String, completion: @escaping (Result<([GoogleReaderCompatibleEntry]?, String?), Error>) -> Void) {
func retrieveEntries(feedID: String, completion: @escaping (Result<([ReaderAPIEntry]?, String?), Error>) -> Void) {
let since = Calendar.current.date(byAdding: .month, value: -3, to: Date()) ?? Date()
@ -599,7 +599,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
}
// 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(GoogleReaderEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
@ -617,7 +617,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: nil)
transport.send(request: request, resultType: GoogleReaderCompatibleReferenceWrapper.self) { result in
transport.send(request: request, resultType: ReaderAPIReferenceWrapper.self) { result in
switch result {
case .success(let (_, unreadEntries)):
@ -650,7 +650,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
}
func retrieveEntries(completion: @escaping (Result<([GoogleReaderCompatibleEntry]?, String?, Int?), Error>) -> Void) {
func retrieveEntries(completion: @escaping (Result<([ReaderAPIEntry]?, String?, Int?), Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
@ -668,7 +668,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
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(GoogleReaderEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
@ -677,8 +677,8 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
URLQueryItem(name: "o", value: String(sinceString)),
URLQueryItem(name: "n", value: "10000"),
URLQueryItem(name: "output", value: "json"),
URLQueryItem(name: "xt", value: GoogleReaderState.read.rawValue),
URLQueryItem(name: "s", value: GoogleReaderStreams.readingList.rawValue)
URLQueryItem(name: "xt", value: ReaderState.read.rawValue),
URLQueryItem(name: "s", value: ReaderStreams.readingList.rawValue)
]
guard let callURL = components.url else {
@ -689,13 +689,13 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.unreadEntries]
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet)
self.transport.send(request: request, resultType: GoogleReaderCompatibleReferenceWrapper.self) { result in
self.transport.send(request: request, resultType: ReaderAPIReferenceWrapper.self) { result in
switch result {
case .success(let (_, entries)):
guard let entries = entries else {
completion(.failure(GoogleReaderCompatibleAccountDelegateError.invalidResponse))
completion(.failure(ReaderAPIAccountDelegateError.invalidResponse))
return
}
@ -703,7 +703,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
switch result {
case .success(let token):
// Do POST asking for data about all the new articles
var request = URLRequest(url: baseURL.appendingPathComponent(GoogleReaderEndpoints.contents.rawValue), credentials: self.credentials)
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"
@ -716,11 +716,11 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
let postData = "T=\(token)&output=json&\(idsToFetch)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, data: postData!, resultType: GoogleReaderCompatibleEntryWrapper.self, completion: { (result) in
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(GoogleReaderCompatibleAccountDelegateError.invalidResponse))
completion(.failure(ReaderAPIAccountDelegateError.invalidResponse))
return
}
@ -748,7 +748,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
}
}
func retrieveEntries(page: String, completion: @escaping (Result<([GoogleReaderCompatibleEntry]?, String?), Error>) -> Void) {
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)))
@ -758,7 +758,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
callComponents.queryItems?.append(URLQueryItem(name: "mode", value: "extended"))
let request = URLRequest(url: callComponents.url!, credentials: credentials)
transport.send(request: request, resultType: [GoogleReaderCompatibleEntry].self) { result in
transport.send(request: request, resultType: [ReaderAPIEntry].self) { result in
switch result {
case .success(let (response, entries)):
@ -783,15 +783,15 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
}
// 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(GoogleReaderEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
components.queryItems = [
URLQueryItem(name: "s", value: GoogleReaderStreams.readingList.rawValue),
URLQueryItem(name: "s", value: ReaderStreams.readingList.rawValue),
URLQueryItem(name: "n", value: "10000"),
URLQueryItem(name: "xt", value: GoogleReaderState.read.rawValue),
URLQueryItem(name: "xt", value: ReaderState.read.rawValue),
URLQueryItem(name: "output", value: "json")
]
@ -803,7 +803,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.unreadEntries]
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet)
transport.send(request: request, resultType: GoogleReaderCompatibleReferenceWrapper.self) { result in
transport.send(request: request, resultType: ReaderAPIReferenceWrapper.self) { result in
switch result {
case .success(let (response, unreadEntries)):
@ -825,7 +825,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
}
func updateStateToEntries(entries: [Int], state: GoogleReaderState, add: Bool, completion: @escaping (Result<Void, Error>) -> Void) {
func updateStateToEntries(entries: [Int], state: ReaderState, add: Bool, completion: @escaping (Result<Void, Error>) -> Void) {
guard let baseURL = APIBaseURL else {
completion(.failure(CredentialsError.incompleteCredentials))
return
@ -835,7 +835,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
switch result {
case .success(let token):
// Do POST asking for data about all the new articles
var request = URLRequest(url: baseURL.appendingPathComponent(GoogleReaderEndpoints.editTag.rawValue), credentials: self.credentials)
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"
@ -889,7 +889,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
return
}
guard var components = URLComponents(url: baseURL.appendingPathComponent(GoogleReaderEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
guard var components = URLComponents(url: baseURL.appendingPathComponent(ReaderAPIEndpoints.itemIds.rawValue), resolvingAgainstBaseURL: false) else {
completion(.failure(TransportError.noURL))
return
}
@ -908,7 +908,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.starredEntries]
let request = URLRequest(url: callURL, credentials: credentials, conditionalGet: conditionalGet)
transport.send(request: request, resultType: GoogleReaderCompatibleReferenceWrapper.self) { result in
transport.send(request: request, resultType: ReaderAPIReferenceWrapper.self) { result in
switch result {
case .success(let (response, unreadEntries)):
@ -936,7 +936,7 @@ final class GoogleReaderCompatibleAPICaller: NSObject {
// MARK: Private
extension GoogleReaderCompatibleAPICaller {
extension ReaderAPICaller {
func storeConditionalGet(key: String, headers: [AnyHashable : Any]) {
if var conditionalGet = accountMetadata?.conditionalGetInfo {

View File

@ -1,5 +1,5 @@
//
// GoogleReaderCompatibleArticle.swift
// ReaderAPIArticle.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
@ -10,10 +10,10 @@ import Foundation
import RSParser
import RSCore
struct GoogleReaderCompatibleEntryWrapper: Codable {
struct ReaderAPIEntryWrapper: Codable {
let id: String
let updated: Int
let entries: [GoogleReaderCompatibleEntry]
let entries: [ReaderAPIEntry]
enum CodingKeys: String, CodingKey {
@ -47,7 +47,7 @@ struct GoogleReaderCompatibleEntryWrapper: Codable {
}
}
*/
struct GoogleReaderCompatibleEntry: Codable {
struct ReaderAPIEntry: Codable {
let articleID: String
let title: String?
@ -56,10 +56,10 @@ struct GoogleReaderCompatibleEntry: Codable {
let crawledTimestamp: String?
let timestampUsec: String?
let summary: GoogleReaderCompatibleArticleSummary
let alternates: [GoogleReaderCompatibleAlternateLocation]
let summary: ReaderAPIArticleSummary
let alternates: [ReaderAPIAlternateLocation]
let categories: [String]
let origin: GoogleReaderCompatibleEntryOrigin
let origin: ReaderAPIEntryOrigin
enum CodingKeys: String, CodingKey {
case articleID = "id"
@ -99,7 +99,7 @@ struct GoogleReaderCompatibleEntry: Codable {
}
}
struct GoogleReaderCompatibleArticleSummary: Codable {
struct ReaderAPIArticleSummary: Codable {
let content: String?
enum CodingKeys: String, CodingKey {
@ -107,7 +107,7 @@ struct GoogleReaderCompatibleArticleSummary: Codable {
}
}
struct GoogleReaderCompatibleAlternateLocation: Codable {
struct ReaderAPIAlternateLocation: Codable {
let url: String?
enum CodingKeys: String, CodingKey {
@ -116,7 +116,7 @@ struct GoogleReaderCompatibleAlternateLocation: Codable {
}
struct GoogleReaderCompatibleEntryOrigin: Codable {
struct ReaderAPIEntryOrigin: Codable {
let streamId: String?
let title: String?

View File

@ -1,5 +1,5 @@
//
// GoogleReaderCompatibleFeed.swift
// ReaderAPIFeed.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
@ -19,7 +19,7 @@ import RSParser
*/
struct GoogleReaderCompatibleQuickAddResult: Codable {
struct ReaderAPIQuickAddResult: Codable {
let numResults: Int
let error: String?
let streamId: String?
@ -31,8 +31,8 @@ struct GoogleReaderCompatibleQuickAddResult: Codable {
}
}
struct GoogleReaderCompatibleSubscriptionContainer: Codable {
let subscriptions: [GoogleReaderCompatibleSubscription]
struct ReaderAPISubscriptionContainer: Codable {
let subscriptions: [ReaderAPISubscription]
enum CodingKeys: String, CodingKey {
case subscriptions = "subscriptions"
@ -55,10 +55,10 @@ struct GoogleReaderCompatibleSubscriptionContainer: Codable {
}
*/
struct GoogleReaderCompatibleSubscription: Codable {
struct ReaderAPISubscription: Codable {
let feedID: String
let name: String?
let categories: [GoogleReaderCompatibleCategory]
let categories: [ReaderAPICategory]
let url: String
let homePageURL: String?
let iconURL: String?
@ -74,7 +74,7 @@ struct GoogleReaderCompatibleSubscription: Codable {
}
struct GoogleReaderCompatibleCategory: Codable {
struct ReaderAPICategory: Codable {
let categoryId: String
let categoryLabel: String
@ -84,21 +84,14 @@ struct GoogleReaderCompatibleCategory: Codable {
}
}
struct GoogleReaderCompatibleCreateSubscription: Codable {
struct ReaderAPICreateSubscription: Codable {
let feedURL: String
enum CodingKeys: String, CodingKey {
case feedURL = "feed_url"
}
}
struct GoogleReaderCompatibleUpdateSubscription: Codable {
let title: String
enum CodingKeys: String, CodingKey {
case title
}
}
struct GoogleReaderCompatibleSubscriptionChoice: Codable {
struct ReaderAPISubscriptionChoice: Codable {
let name: String?
let url: String

View File

@ -1,5 +1,5 @@
//
// GoogleReaderCompatibleTag.swift
// ReaderAPICompatibleTag.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
@ -8,15 +8,15 @@
import Foundation
struct GoogleReaderCompatibleTagContainer: Codable {
let tags: [GoogleReaderCompatibleTag]
struct ReaderAPITagContainer: Codable {
let tags: [ReaderAPITag]
enum CodingKeys: String, CodingKey {
case tags = "tags"
}
}
struct GoogleReaderCompatibleTag: Codable {
struct ReaderAPITag: Codable {
let tagID: String
let type: String?

View File

@ -1,5 +1,5 @@
//
// GoogleReaderCompatibleTagging.swift
// ReaderAPICompatibleTagging.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
@ -8,7 +8,7 @@
import Foundation
struct GoogleReaderCompatibleTagging: Codable {
struct ReaderAPITagging: Codable {
let taggingID: Int
let feedID: Int
@ -22,7 +22,7 @@ struct GoogleReaderCompatibleTagging: Codable {
}
struct GoogleReaderCompatibleCreateTagging: Codable {
struct ReaderAPICreateTagging: Codable {
let feedID: Int
let name: String

View File

@ -1,5 +1,5 @@
//
// GoogleReaderCompatibleUnreadEntry.swift
// ReaderAPIUnreadEntry.swift
// Account
//
// Created by Jeremy Beker on 5/28/19.
@ -8,15 +8,15 @@
import Foundation
struct GoogleReaderCompatibleReferenceWrapper: Codable {
let itemRefs: [GoogleReaderCompatibleReference]
struct ReaderAPIReferenceWrapper: Codable {
let itemRefs: [ReaderAPIReference]
enum CodingKeys: String, CodingKey {
case itemRefs = "itemRefs"
}
}
struct GoogleReaderCompatibleReference: Codable {
struct ReaderAPIReference: Codable {
let itemId: String

View File

@ -64,7 +64,7 @@ extension AccountsAddViewController: NSTableViewDelegate {
cell.accountNameLabel?.stringValue = NSLocalizedString("Feedbin", comment: "Feedbin")
cell.accountImageView?.image = AppAssets.accountFeedbin
case 2:
cell.accountNameLabel?.stringValue = NSLocalizedString("Google Reader API", comment: "Google Reader API")
cell.accountNameLabel?.stringValue = NSLocalizedString("Reader", comment: "Reader")
cell.accountImageView?.image = AppAssets.accountLocal
default:
break
@ -91,9 +91,9 @@ extension AccountsAddViewController: NSTableViewDelegate {
accountsFeedbinWindowController.runSheetOnWindow(self.view.window!)
accountsAddWindowController = accountsFeedbinWindowController
case 2:
let accountsGoogleReaderCompatibleWindowController = AccountsGoogleReaderCompatibleWindowController()
accountsGoogleReaderCompatibleWindowController.runSheetOnWindow(self.view.window!)
accountsAddWindowController = accountsGoogleReaderCompatibleWindowController
let accountsReaderAPIWindowController = AccountsReaderAPIWindowController()
accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!)
accountsAddWindowController = accountsReaderAPIWindowController
default:
break
}

View File

@ -107,7 +107,7 @@ extension AccountsPreferencesViewController: NSTableViewDelegate {
cell.imageView?.image = AppAssets.accountLocal
case .feedbin:
cell.imageView?.image = NSImage(named: "accountFeedbin")
case .googleReaderCompatible:
case .googleReaderAPI:
cell.imageView?.image = AppAssets.accountLocal
default:
break

View File

@ -6,7 +6,7 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccountsGoogleReaderCompatibleWindowController" customModule="NetNewsWire" customModuleProvider="target">
<customObject id="-2" userLabel="File's Owner" customClass="AccountsReaderAPIWindowController" customModule="NetNewsWire" customModuleProvider="target">
<connections>
<outlet property="actionButton" destination="9mz-D9-krh" id="ozu-6Q-9Lb"/>
<outlet property="apiURLTextField" destination="d7d-ZV-CcZ" id="Af4-uM-Dgd"/>
@ -23,13 +23,13 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="433" height="249"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="433" height="278"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1440"/>
<view key="contentView" misplaced="YES" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="433" height="249"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView distribution="fill" orientation="horizontal" alignment="bottom" spacing="19" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7Ht-Fn-0Ya">
<rect key="frame" x="60" y="220" width="314" height="38"/>
<rect key="frame" x="140" y="220" width="153" height="38"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Ssh-Dh-xbg">
<rect key="frame" x="0.0" y="0.0" width="36" height="36"/>
@ -40,8 +40,8 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="accountLocal" id="y38-YL-woC"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lti-yM-8LV">
<rect key="frame" x="53" y="0.0" width="263" height="38"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Google Reader API" id="ras-dj-nP8">
<rect key="frame" x="53" y="0.0" width="102" height="38"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Reader" id="ras-dj-nP8">
<font key="font" metaFont="system" size="32"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>

View File

@ -10,7 +10,7 @@ import AppKit
import Account
import RSWeb
class AccountsGoogleReaderCompatibleWindowController: NSWindowController {
class AccountsReaderAPIWindowController: NSWindowController {
@IBOutlet weak var progressIndicator: NSProgressIndicator!
@IBOutlet weak var usernameTextField: NSTextField!
@ -24,7 +24,7 @@ class AccountsGoogleReaderCompatibleWindowController: NSWindowController {
private weak var hostWindow: NSWindow?
convenience init() {
self.init(windowNibName: NSNib.Name("AccountsGoogleReaderCompatible"))
self.init(windowNibName: NSNib.Name("AccountsReaderAPI"))
}
override func windowDidLoad() {
@ -71,7 +71,7 @@ class AccountsGoogleReaderCompatibleWindowController: NSWindowController {
}
let credentials = Credentials.googleBasicLogin(username: usernameTextField.stringValue, password: passwordTextField.stringValue)
Account.validateCredentials(type: .googleReaderCompatible, credentials: credentials, endpoint: apiURL) { [weak self] result in
Account.validateCredentials(type: .googleReaderAPI, credentials: credentials, endpoint: apiURL) { [weak self] result in
guard let self = self else { return }
@ -89,7 +89,7 @@ class AccountsGoogleReaderCompatibleWindowController: NSWindowController {
var newAccount = false
if self.account == nil {
self.account = AccountManager.shared.createAccount(type: .googleReaderCompatible)
self.account = AccountManager.shared.createAccount(type: .googleReaderAPI)
newAccount = true
}

View File

@ -142,7 +142,7 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
osType = "FWrg"
case .newsBlur:
osType = "NBlr"
case .googleReaderCompatible:
case .googleReaderAPI:
osType = "Grdr"
}
return osType.fourCharCode()

View File

@ -155,9 +155,9 @@
51F85BF92274AA7B00C787DC /* UIBarButtonItem-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51F85BF82274AA7B00C787DC /* UIBarButtonItem-Extensions.swift */; };
51F85BFB2275D85000C787DC /* Array-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51F85BFA2275D85000C787DC /* Array-Extensions.swift */; };
51F85BFD2275DCA800C787DC /* SingleLineUILabelSizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51F85BFC2275DCA800C787DC /* SingleLineUILabelSizer.swift */; };
557EE1AE22B6F4E1004206FA /* SettingsGoogleReaderCompatibleAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 557EE1A522B6F4E1004206FA /* SettingsGoogleReaderCompatibleAccountView.swift */; };
55E15BCB229D65A900D6602A /* AccountsGoogleReaderCompatible.xib in Resources */ = {isa = PBXBuildFile; fileRef = 55E15BC1229D65A900D6602A /* AccountsGoogleReaderCompatible.xib */; };
55E15BCC229D65A900D6602A /* AccountsGoogleReaderCompatibleWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E15BCA229D65A900D6602A /* AccountsGoogleReaderCompatibleWindowController.swift */; };
557EE1AE22B6F4E1004206FA /* SettingsReaderAPIAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 557EE1A522B6F4E1004206FA /* SettingsReaderAPIAccountView.swift */; };
55E15BCB229D65A900D6602A /* AccountsReaderAPI.xib in Resources */ = {isa = PBXBuildFile; fileRef = 55E15BC1229D65A900D6602A /* AccountsReaderAPI.xib */; };
55E15BCC229D65A900D6602A /* AccountsReaderAPIWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55E15BCA229D65A900D6602A /* AccountsReaderAPIWindowController.swift */; };
6581C73820CED60100F4AD34 /* SafariExtensionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6581C73720CED60100F4AD34 /* SafariExtensionHandler.swift */; };
6581C73A20CED60100F4AD34 /* SafariExtensionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6581C73920CED60100F4AD34 /* SafariExtensionViewController.swift */; };
6581C73D20CED60100F4AD34 /* SafariExtensionViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6581C73B20CED60100F4AD34 /* SafariExtensionViewController.xib */; };
@ -753,9 +753,9 @@
51F85BF82274AA7B00C787DC /* UIBarButtonItem-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIBarButtonItem-Extensions.swift"; sourceTree = "<group>"; };
51F85BFA2275D85000C787DC /* Array-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array-Extensions.swift"; sourceTree = "<group>"; };
51F85BFC2275DCA800C787DC /* SingleLineUILabelSizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleLineUILabelSizer.swift; sourceTree = "<group>"; };
557EE1A522B6F4E1004206FA /* SettingsGoogleReaderCompatibleAccountView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsGoogleReaderCompatibleAccountView.swift; sourceTree = "<group>"; };
55E15BC1229D65A900D6602A /* AccountsGoogleReaderCompatible.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AccountsGoogleReaderCompatible.xib; sourceTree = "<group>"; };
55E15BCA229D65A900D6602A /* AccountsGoogleReaderCompatibleWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsGoogleReaderCompatibleWindowController.swift; sourceTree = "<group>"; };
557EE1A522B6F4E1004206FA /* SettingsReaderAPIAccountView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsReaderAPIAccountView.swift; sourceTree = "<group>"; };
55E15BC1229D65A900D6602A /* AccountsReaderAPI.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AccountsReaderAPI.xib; sourceTree = "<group>"; };
55E15BCA229D65A900D6602A /* AccountsReaderAPIWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsReaderAPIWindowController.swift; sourceTree = "<group>"; };
6581C73320CED60000F4AD34 /* Subscribe to Feed.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Subscribe to Feed.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
6581C73420CED60100F4AD34 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
6581C73720CED60100F4AD34 /* SafariExtensionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariExtensionHandler.swift; sourceTree = "<group>"; };
@ -1066,7 +1066,7 @@
5183CCEB227117C70010922C /* Settings */ = {
isa = PBXGroup;
children = (
557EE1A522B6F4E1004206FA /* SettingsGoogleReaderCompatibleAccountView.swift */,
557EE1A522B6F4E1004206FA /* SettingsReaderAPIAccountView.swift */,
510D708122B041CC004E8F65 /* SettingsAccountLabelView.swift */,
510D707322B028E1004E8F65 /* SettingsAddAccountView.swift */,
51F772EC22B2789B0087D9D1 /* SettingsDetailAccountView.swift */,
@ -1669,8 +1669,8 @@
84C9FC6F22629E1200D921D6 /* Accounts */ = {
isa = PBXGroup;
children = (
55E15BC1229D65A900D6602A /* AccountsGoogleReaderCompatible.xib */,
55E15BCA229D65A900D6602A /* AccountsGoogleReaderCompatibleWindowController.swift */,
55E15BC1229D65A900D6602A /* AccountsReaderAPI.xib */,
55E15BCA229D65A900D6602A /* AccountsReaderAPIWindowController.swift */,
84C9FC7022629E1200D921D6 /* AccountsTableViewBackgroundView.swift */,
84C9FC7122629E1200D921D6 /* AccountsControlsBackgroundView.swift */,
84C9FC7222629E1200D921D6 /* AccountsPreferencesViewController.swift */,
@ -2265,7 +2265,7 @@
5144EA52227B8E4500D19003 /* AccountsFeedbin.xib in Resources */,
8405DDA222168920008CE1BF /* TimelineTableView.xib in Resources */,
8483630E2262A3FE00DA1D35 /* MainWindow.storyboard in Resources */,
55E15BCB229D65A900D6602A /* AccountsGoogleReaderCompatible.xib in Resources */,
55E15BCB229D65A900D6602A /* AccountsReaderAPI.xib in Resources */,
84BAE64921CEDAF20046DB56 /* CrashReporterWindow.xib in Resources */,
84C9FC8E22629E8F00D921D6 /* Credits.rtf in Resources */,
84BBB12D20142A4700F054F5 /* Inspector.storyboard in Resources */,
@ -2390,7 +2390,7 @@
51F85BF722749FA100C787DC /* UIFont-Extensions.swift in Sources */,
515436882291D75D005E1CDF /* AddLocalAccountViewController.swift in Sources */,
51C452AF2265108300C03939 /* ArticleArray.swift in Sources */,
557EE1AE22B6F4E1004206FA /* SettingsGoogleReaderCompatibleAccountView.swift in Sources */,
557EE1AE22B6F4E1004206FA /* SettingsReaderAPIAccountView.swift in Sources */,
51C4528E2265099C00C03939 /* SmartFeedsController.swift in Sources */,
51C4529C22650A1000C03939 /* SingleFaviconDownloader.swift in Sources */,
51E595A6228CC36500FCC42B /* ArticleStatusSyncTimer.swift in Sources */,
@ -2487,7 +2487,7 @@
8477ACBE22238E9500DF7F37 /* SearchFeedDelegate.swift in Sources */,
51E3EB33229AB02C00645299 /* ErrorHandler.swift in Sources */,
8472058120142E8900AD578B /* FeedInspectorViewController.swift in Sources */,
55E15BCC229D65A900D6602A /* AccountsGoogleReaderCompatibleWindowController.swift in Sources */,
55E15BCC229D65A900D6602A /* AccountsReaderAPIWindowController.swift in Sources */,
5144EA382279FC6200D19003 /* AccountsAddLocalWindowController.swift in Sources */,
84AD1EAA2031617300BC20B7 /* PasteboardFolder.swift in Sources */,
5144EA51227B8E4500D19003 /* AccountsFeedbinWindowController.swift in Sources */,

View File

@ -1,8 +1,8 @@
//
// SettingsGoogleReaderCompatibleAccountView.swift
// SettingsReaderAPIAccountView.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 6/11/19.
// Created by Jeremy Beker on 5/28/2019.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
@ -11,7 +11,7 @@ import Combine
import Account
import RSWeb
struct SettingsGoogleReaderCompatibleAccountView : View {
struct SettingsReaderAPIAccountView : View {
@Environment(\.isPresented) private var isPresented
@ObjectBinding var viewModel: ViewModel
@State var busy: Bool = false
@ -83,7 +83,7 @@ struct SettingsGoogleReaderCompatibleAccountView : View {
return
}
Account.validateCredentials(type: .googleReaderCompatible, credentials: credentials, endpoint: apiURL) { result in
Account.validateCredentials(type: .googleReaderAPI, credentials: credentials, endpoint: apiURL) { result in
self.busy = false
@ -95,7 +95,7 @@ struct SettingsGoogleReaderCompatibleAccountView : View {
var newAccount = false
let workAccount: Account
if self.viewModel.account == nil {
workAccount = AccountManager.shared.createAccount(type: .googleReaderCompatible)
workAccount = AccountManager.shared.createAccount(type: .googleReaderAPI)
newAccount = true
} else {
workAccount = self.viewModel.account!
@ -179,9 +179,9 @@ struct SettingsGoogleReaderCompatibleAccountView : View {
}
#if DEBUG
struct SettingsGoogleReaderCompatibleAccountView_Previews : PreviewProvider {
struct SettingsReaderAPIAccountView_Previews : PreviewProvider {
static var previews: some View {
SettingsGoogleReaderCompatibleAccountView(viewModel: SettingsGoogleReaderCompatibleAccountView.ViewModel())
SettingsReaderAPIAccountView(viewModel: SettingsReaderAPIAccountView.ViewModel())
}
}
#endif