diff --git a/.ignore b/.ignore new file mode 100644 index 000000000..ac52a79ca --- /dev/null +++ b/.ignore @@ -0,0 +1,9 @@ +# Files ignored for scc line of code calculation +readium-sdk/ +readium-shared-js/ +TestResources +mobile-bookmark-spec/ +PalaceTests/ +adobe-rmsdk/ +PalaceConfig/ +*.xcassets diff --git a/Cartfile b/Cartfile index 9c01e3ff3..8b1378917 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -binary "https://liblcp.dita.digital/readium/liblcp/ios/carthage/xHwy01rpnw/liblcp.json" ~> 3.0.0 + diff --git a/Cartfile.resolved b/Cartfile.resolved index 471dac57f..77ad904e5 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,4 +1,2 @@ github "PureLayout/PureLayout" "v3.1.9" github "dexman/Minizip" "1.4.0" - -binary "https://liblcp.dita.digital/readium/liblcp/ios/carthage/xHwy01rpnw/liblcp.json" "3.0.0" \ No newline at end of file diff --git a/Palace.xcodeproj/project.pbxproj b/Palace.xcodeproj/project.pbxproj index bdd24602e..75f4b0b7c 100644 --- a/Palace.xcodeproj/project.pbxproj +++ b/Palace.xcodeproj/project.pbxproj @@ -215,7 +215,6 @@ 2D382BD71D08BA99002C423D /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D382BD61D08BA99002C423D /* Log.swift */; }; 2D4379FE1C46FDB600AE1AD5 /* ReaderClientCert.sig in Resources */ = {isa = PBXBuildFile; fileRef = 085D31FB1BE7BE86007F7672 /* ReaderClientCert.sig */; }; 2D62568B1D412BCB0080A81F /* BundledHTMLViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D62568A1D412BCB0080A81F /* BundledHTMLViewController.swift */; }; - 2D6256911D41582A0080A81F /* software-licenses.html in Resources */ = {isa = PBXBuildFile; fileRef = 2D6256901D41582A0080A81F /* software-licenses.html */; }; 2D754BBB2002E2FB0061D34F /* TPPOPDSAcquisition.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D754BBA2002E2FB0061D34F /* TPPOPDSAcquisition.m */; }; 2D754BC22002F1B10061D34F /* TPPOPDSIndirectAcquisition.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D754BC12002F1B10061D34F /* TPPOPDSIndirectAcquisition.m */; }; 2D87909D20127AA300E2763F /* TPPOPDSAcquisitionPath.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D87909C20127AA300E2763F /* TPPOPDSAcquisitionPath.m */; }; @@ -517,7 +516,6 @@ 73EB0B5B25821DF4006BC997 /* TPPProblemReportViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 085D31D81BE29ED4007F7672 /* TPPProblemReportViewController.xib */; }; 73EB0B5C25821DF4006BC997 /* readium-shared-js_all.js in Resources */ = {isa = PBXBuildFile; fileRef = 5A69290D1B95ACC600FB4C10 /* readium-shared-js_all.js */; }; 73EB0B5D25821DF4006BC997 /* ReaderClientCert.sig in Resources */ = {isa = PBXBuildFile; fileRef = 085D31FB1BE7BE86007F7672 /* ReaderClientCert.sig */; }; - 73EB0B5E25821DF4006BC997 /* software-licenses.html in Resources */ = {isa = PBXBuildFile; fileRef = 2D6256901D41582A0080A81F /* software-licenses.html */; }; 73EB0B5F25821DF4006BC997 /* TPP_Launch_Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E65977C41F82AC91003CD6BC /* TPP_Launch_Screen.storyboard */; }; 73EB0B6025821DF4006BC997 /* Accounts.json in Resources */ = {isa = PBXBuildFile; fileRef = 03F94CCE1DD627AA00CE8F4F /* Accounts.json */; }; 73EB0B6125821DF4006BC997 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A823D819192BABA400B55DE2 /* InfoPlist.strings */; }; @@ -949,7 +947,6 @@ D570B6D42BA20139003FE991 /* readium-shared-js_all.js in Resources */ = {isa = PBXBuildFile; fileRef = 5A69290D1B95ACC600FB4C10 /* readium-shared-js_all.js */; }; D570B6D52BA20139003FE991 /* ReaderClientCert.sig in Resources */ = {isa = PBXBuildFile; fileRef = 085D31FB1BE7BE86007F7672 /* ReaderClientCert.sig */; }; D570B6D62BA20139003FE991 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 17E81F32261FF758001003C2 /* Localizable.stringsdict */; }; - D570B6D72BA20139003FE991 /* software-licenses.html in Resources */ = {isa = PBXBuildFile; fileRef = 2D6256901D41582A0080A81F /* software-licenses.html */; }; D570B6D82BA20139003FE991 /* TPP_Launch_Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E65977C41F82AC91003CD6BC /* TPP_Launch_Screen.storyboard */; }; D570B6D92BA20139003FE991 /* Accounts.json in Resources */ = {isa = PBXBuildFile; fileRef = 03F94CCE1DD627AA00CE8F4F /* Accounts.json */; }; D570B6DA2BA20139003FE991 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A823D819192BABA400B55DE2 /* InfoPlist.strings */; }; @@ -1701,7 +1698,6 @@ 2D382BCF1D08B1F5002C423D /* Palace-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Palace-Bridging-Header.h"; sourceTree = ""; }; 2D382BD61D08BA99002C423D /* Log.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Log.swift; sourceTree = ""; }; 2D62568A1D412BCB0080A81F /* BundledHTMLViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BundledHTMLViewController.swift; sourceTree = ""; }; - 2D6256901D41582A0080A81F /* software-licenses.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "software-licenses.html"; sourceTree = ""; }; 2D6AF74A1E7E341F005CEC90 /* Palace+RMSDK.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Palace+RMSDK.xcconfig"; path = "../Palace+RMSDK.xcconfig"; sourceTree = ""; }; 2D754BB92002E2FB0061D34F /* TPPOPDSAcquisition.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TPPOPDSAcquisition.h; sourceTree = ""; }; 2D754BBA2002E2FB0061D34F /* TPPOPDSAcquisition.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TPPOPDSAcquisition.m; sourceTree = ""; }; @@ -3340,7 +3336,6 @@ 84B7A3421B84E8FE00584FB2 /* OpenDyslexicFont */, 11C113D319F842E2005B3F63 /* Reader */, E61D7F631F6AC78B0091C781 /* SimplyE.entitlements */, - 2D6256901D41582A0080A81F /* software-licenses.html */, 110F853C19D5FA7300052DF7 /* DetailSummaryTemplate.html */, 738EF2D12405E3D900F388FB /* .gitignore */, 73DA43A12404B4A900985482 /* Cartfile */, @@ -4073,7 +4068,6 @@ 73EB0B5C25821DF4006BC997 /* readium-shared-js_all.js in Resources */, 73EB0B5D25821DF4006BC997 /* ReaderClientCert.sig in Resources */, 17E81F2F261FF758001003C2 /* Localizable.stringsdict in Resources */, - 73EB0B5E25821DF4006BC997 /* software-licenses.html in Resources */, 73EB0B5F25821DF4006BC997 /* TPP_Launch_Screen.storyboard in Resources */, 73EB0B6025821DF4006BC997 /* Accounts.json in Resources */, 73EB0B6125821DF4006BC997 /* InfoPlist.strings in Resources */, @@ -4110,7 +4104,6 @@ 5A69290E1B95ACC600FB4C10 /* readium-shared-js_all.js in Resources */, 2D4379FE1C46FDB600AE1AD5 /* ReaderClientCert.sig in Resources */, 17E81F2C261FF758001003C2 /* Localizable.stringsdict in Resources */, - 2D6256911D41582A0080A81F /* software-licenses.html in Resources */, E65977C51F82AC91003CD6BC /* TPP_Launch_Screen.storyboard in Resources */, 03F94CCF1DD627AA00CE8F4F /* Accounts.json in Resources */, A823D81B192BABA400B55DE2 /* InfoPlist.strings in Resources */, @@ -4147,7 +4140,6 @@ D570B6D42BA20139003FE991 /* readium-shared-js_all.js in Resources */, D570B6D52BA20139003FE991 /* ReaderClientCert.sig in Resources */, D570B6D62BA20139003FE991 /* Localizable.stringsdict in Resources */, - D570B6D72BA20139003FE991 /* software-licenses.html in Resources */, D570B6D82BA20139003FE991 /* TPP_Launch_Screen.storyboard in Resources */, D570B6D92BA20139003FE991 /* Accounts.json in Resources */, D570B6DA2BA20139003FE991 /* InfoPlist.strings in Resources */, diff --git a/Palace/Accounts/Library/Account.swift b/Palace/Accounts/Library/Account.swift index 312087d89..47c90194e 100644 --- a/Palace/Accounts/Library/Account.swift +++ b/Palace/Accounts/Library/Account.swift @@ -397,7 +397,8 @@ protocol AccountLogoDelegate: AnyObject { details = AccountDetails(authenticationDocument: authenticationDocument, uuid: uuid) } } - + var logoUrl: URL? = nil + var loansUrl: URL? { return details?.loansUrl @@ -423,12 +424,9 @@ protocol AccountLogoDelegate: AnyObject { logo = UIImage(named: "LibraryLogoMagic")! homePageUrl = publication.links.first(where: { $0.rel == "alternate" })?.href + logoUrl = publication.thumbnailURL super.init() - - DispatchQueue.main.async { - self.loadLogo(imageURL: publication.thumbnailURL) - } } /// Load authentication documents from the network or cache. @@ -515,8 +513,8 @@ protocol AccountLogoDelegate: AnyObject { } } - private func loadLogo(imageURL: URL?) { - guard let url = imageURL else { return } + func loadLogo() { + guard let url = self.logoUrl else { return } self.fetchImage(from: url, completion: { guard let image = $0 else { return } diff --git a/Palace/Accounts/Library/AccountsManager.swift b/Palace/Accounts/Library/AccountsManager.swift index 13f0f8e7f..5729248aa 100644 --- a/Palace/Accounts/Library/AccountsManager.swift +++ b/Palace/Accounts/Library/AccountsManager.swift @@ -191,6 +191,7 @@ let currentAccountIdentifierKey = "TPPCurrentAccountIdentifier" // changing the `accountsSets` dictionary will also change `currentAccount` Log.debug(#function, "hadAccount=\(hadAccount) currentAccountID=\(currentAccountId ?? "N/A") currentAcct=\(String(describing: currentAccount))") if hadAccount != (self.currentAccount != nil) { + self.currentAccount?.loadLogo() self.currentAccount?.loadAuthenticationDocument(using: TPPUserAccount.sharedAccount(), completion: { success in DispatchQueue.main.async { var mainFeed = URL(string: self.currentAccount?.catalogUrl ?? "") @@ -225,6 +226,9 @@ let currentAccountIdentifierKey = "TPPCurrentAccountIdentifier" // successfully completion(true) } + for account in accountSet { + account.loadLogo() + } } catch (let error) { TPPErrorLogger.logError(error, summary: "Error while parsing catalog feed") diff --git a/Palace/Network/TPPNetworkResponder.swift b/Palace/Network/TPPNetworkResponder.swift index 308f09c09..5493fc777 100644 --- a/Palace/Network/TPPNetworkResponder.swift +++ b/Palace/Network/TPPNetworkResponder.swift @@ -188,7 +188,7 @@ extension TPPNetworkResponder: URLSessionDataDelegate { private func logTaskCompletion(taskID: Int, startDate: Date, metadata: inout [String: Any]) { let elapsed = Date().timeIntervalSince(startDate) metadata["elapsedTime"] = elapsed - Log.info(#file, "Task \(taskID) completed, elapsed time: \(elapsed) sec") + Log.info(#file, "Task \(taskID) completed (\(metadata["currentRequest"] ?? "nil")), elapsed time: \(elapsed) sec") } diff --git a/Palace/Reader2/ReaderStackConfiguration/AdobeDRM/AdobeDRMContentProtection.swift b/Palace/Reader2/ReaderStackConfiguration/AdobeDRM/AdobeDRMContentProtection.swift index 0dd1a474a..e3c8f2cdb 100644 --- a/Palace/Reader2/ReaderStackConfiguration/AdobeDRM/AdobeDRMContentProtection.swift +++ b/Palace/Reader2/ReaderStackConfiguration/AdobeDRM/AdobeDRMContentProtection.swift @@ -107,7 +107,7 @@ extension AdobeDRMContainer: Container { return nil } - return DRMResource(data: data, path: url.anyURL.string, drmContainer: self) + return DataResource(data: self.decode(data, at: url.anyURL.string), sourceURL: url.absoluteURL) } // MARK: - Helpers @@ -141,67 +141,4 @@ extension AdobeDRMContainer: Container { } } } - -struct DRMResource: Resource { - private let data: Data - private let path: String - private let drmContainer: AdobeDRMContainer - - init(data: Data, path: String, drmContainer: AdobeDRMContainer) { - self.data = data - self.path = path - self.drmContainer = drmContainer - } - - func read(range: Range?) async throws -> Data { - let fullData = drmContainer.decode(data, at: path) - - if let range = range { - let start = Int(clamping: range.lowerBound) - let end = Int(clamping: range.upperBound) - let intRange = start..= 0, intRange.upperBound <= fullData.count else { - throw ReadError.access(.fileSystem(.fileNotFound(nil))) - } - - return fullData.subdata(in: intRange) - } else { - return fullData - } - } - - var sourceURL: AbsoluteURL? { - drmContainer.sourceURL - } - - func properties() async -> ReadResult { - var props = ResourceProperties() - props.length = UInt64(data.count) - return .success(props) - } - - func estimatedLength() async -> ReadResult { - return .success(UInt64(data.count)) - } - - func stream(range: Range?, consume: @escaping (Data) -> Void) async -> ReadResult { - do { - let chunk = try await read(range: range) - consume(chunk) - return .success(()) - } catch { - return .failure(.access(.other(error))) - } - } - - func close() {} -} - -extension ResourceProperties { - public var length: UInt64? { - get { self["length"] } - set { self["length"] = newValue } - } -} #endif diff --git a/Palace/Settings/NewSettings/TPPSettingsView.swift b/Palace/Settings/NewSettings/TPPSettingsView.swift index e2b88baf1..106e054c7 100644 --- a/Palace/Settings/NewSettings/TPPSettingsView.swift +++ b/Palace/Settings/NewSettings/TPPSettingsView.swift @@ -117,9 +117,10 @@ struct TPPSettingsView: View { } @ViewBuilder private var softwareLicenseRow: some View { - let viewController = BundledHTMLViewController( - fileURL: Bundle.main.url(forResource: "software-licenses", withExtension: "html")!, - title: Strings.Settings.softwareLicenses + let viewController = RemoteHTMLViewController( + URL: URL(string: TPPSettings.TPPSoftwareLicensesURLString)!, + title: Strings.Settings.softwareLicenses, + failureMessage: Strings.Error.loadFailedError ) let wrapper = UIViewControllerWrapper(viewController, updater: { _ in }) diff --git a/Palace/Settings/TPPSettings.swift b/Palace/Settings/TPPSettings.swift index 018838b6d..917d892d9 100644 --- a/Palace/Settings/TPPSettings.swift +++ b/Palace/Settings/TPPSettings.swift @@ -22,7 +22,8 @@ import Foundation static let TPPAboutPalaceURLString = "http://thepalaceproject.org/" static let TPPUserAgreementURLString = "https://legal.palaceproject.io/End%20User%20License%20Agreement.html" static let TPPPrivacyPolicyURLString = "https://legal.palaceproject.io/Privacy%20Policy.html" - + static let TPPSoftwareLicensesURLString = "https://legal.palaceproject.io/software-licenses.html" + static private let customMainFeedURLKey = "NYPLSettingsCustomMainFeedURL" static private let accountMainFeedURLKey = "NYPLSettingsAccountMainFeedURL" static private let userPresentedAgeCheckKey = "NYPLUserPresentedAgeCheckKey" diff --git a/Palace/software-licenses.html b/Palace/software-licenses.html deleted file mode 100644 index 54d4bac1c..000000000 --- a/Palace/software-licenses.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - Software Licenses - - - - -

Palace License

-

Copyright © 2021 LYRASIS

-

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

-

https://www.apache.org/licenses/LICENSE-2.0

-

Unless required by applicable law or agreed to in writing, software distributed under the License -is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -or implied. See the License for the specific language governing permissions and limitations under -the License.

- -

Licenses for Included Software

- -

Adobe DRM Connector

-

The Palace Project contains Adobe® Reader® Mobile software under license from Adobe Systems Incorporated, Copyright © 1995-2018 Adobe Systems Incorporated & its Distributor. All rights reserved. Adobe and Reader are trademarks of Adobe Systems Incorporated.

- -

Pure Layout

-

Copyright (c) 2014-2015 Tyler Fox ( - https://github.com/PureLayout/PureLayout)

-

This code is distributed under the terms and conditions of the MIT license.

- -

SQLlite.swift

-

Copyright (c) 2014-2015 Stephen Celis ( - https://github.com/stephencelis/SQLite.swift)

-

This code is distributed under the terms and conditions of the MIT license.

- -

Firebase Crashlytics

-

Copyright (c) 2020 Google

-

Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at

-

https://www.apache.org/licenses/LICENSE-2.0

-

Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.

- -

Readium

-

Copyright (c) 2017 Readium

-

Modules: readium-sdk, readium-shared-js, r2-shared-swift, r2-streamer-swift, r2-lcp-swift, r2-navigator-swift.

-

This code is distributed under the terms and conditions of the BSD 3-Clause License.

- -

TenPrintCover

-

Copyright (c) 2014 Mauricio Giraldo ( - https://github.com/ThePalaceProject/ios-tenprintcover)

-

This code is distributed under the terms and conditions of the MIT license.

- - - diff --git a/scripts/count-loc.sh b/scripts/count-loc.sh new file mode 100755 index 000000000..56c1d562d --- /dev/null +++ b/scripts/count-loc.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# In order to run this script you need the scc tool installed +# https://github.com/boyter/scc +# brew install scc + +scc . -p --include-symlinks --no-gitmodule --no-complexity --no-cocomo