From f4ba4a60587bd08fb0712db22f51cd3a26e4d903 Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Wed, 29 May 2019 08:05:10 +0200 Subject: [PATCH] quick fixes --- DashControl.xcodeproj/project.pbxproj | 157 +------- .../Sources/Services/API/APIBaseAuthorized.m | 2 +- DashControl/Sources/Services/API/APIBudget.m | 2 +- .../Sources/Services/API/APIBudgetPrivate.m | 2 +- DashControl/Sources/Services/API/APINews.m | 2 +- .../Sources/Services/API/APIPortfolio.m | 2 +- DashControl/Sources/Services/API/APIPrice.m | 2 +- DashControl/Sources/Services/API/APITrigger.m | 2 +- DashControl/Sources/Services/Injections.m | 2 +- .../Additional/NSURLRequest+DCcURL.h | 28 -- .../Additional/NSURLRequest+DCcURL.m | 54 --- .../NetworkActivityIndicatorManager.h | 33 -- .../NetworkActivityIndicatorManager.m | 79 ---- .../Networking/Blocks/HTTPLoaderBlocks.h | 30 -- .../Networking/Blocks/HTTPLoaderManager.h | 38 -- .../Networking/Blocks/HTTPLoaderManager.m | 127 ------- .../Networking/Blocks/HTTPLoaderOperation.h | 37 -- .../Networking/Blocks/HTTPLoaderOperation.m | 138 ------- .../Blocks/HTTPLoaderOperationProtocol.h | 29 -- .../Networking/HTTPCancellationToken.h | 48 --- .../Sources/Services/Networking/HTTPLoader.h | 46 --- .../Sources/Services/Networking/HTTPLoader.m | 239 ------------ .../Networking/HTTPLoaderAuthoriser.h | 51 --- .../Services/Networking/HTTPLoaderDelegate.h | 47 --- .../Services/Networking/HTTPLoaderFactory.h | 42 --- .../Services/Networking/HTTPLoaderFactory.m | 217 ----------- .../Services/Networking/HTTPRateLimiter.h | 40 -- .../Services/Networking/HTTPRateLimiter.m | 97 ----- .../Services/Networking/HTTPRateLimiterMap.h | 32 -- .../Services/Networking/HTTPRateLimiterMap.m | 103 ------ .../Sources/Services/Networking/HTTPRequest.h | 97 ----- .../Sources/Services/Networking/HTTPRequest.m | 261 ------------- .../Networking/HTTPRequestOperation.h | 55 --- .../Networking/HTTPRequestOperation.m | 239 ------------ .../Networking/HTTPRequestOperationHandler.h | 67 ---- .../Services/Networking/HTTPResponse.h | 97 ----- .../Services/Networking/HTTPResponse.m | 195 ---------- .../Sources/Services/Networking/HTTPService.h | 44 --- .../Sources/Services/Networking/HTTPService.m | 344 ------------------ .../Sources/Services/Networking/Networking.h | 34 -- .../Private/HTTPCancellationTokenImpl.h | 37 -- .../Private/HTTPCancellationTokenImpl.m | 74 ---- .../Networking/Private/HTTPLoader+Private.h | 37 -- .../Private/HTTPLoaderFactory+Private.h | 40 -- .../Networking/Private/HTTPRequest+Private.h | 38 -- .../Networking/Private/HTTPResponse+Private.h | 43 --- .../Private/HTTPURLRequestBuilder.h | 32 -- .../Private/HTTPURLRequestBuilder.m | 195 ---------- .../Private/SPTDataLoaderExponentialTimer.h | 89 ----- .../Private/SPTDataLoaderExponentialTimer.m | 146 -------- .../Masternode/MasternodeViewModel.m | 12 +- .../Sources/UI/Portfolio/PortfolioViewModel.m | 2 +- .../Views/PortfolioHeaderViewModel.m | 2 +- ...PortfolioWalletAddressTableViewCellModel.m | 2 +- DashControl/Sources/Wallet/DCWalletAccount.m | 6 +- Podfile.lock | 22 +- 56 files changed, 29 insertions(+), 3909 deletions(-) delete mode 100644 DashControl/Sources/Services/Networking/Additional/NSURLRequest+DCcURL.h delete mode 100644 DashControl/Sources/Services/Networking/Additional/NSURLRequest+DCcURL.m delete mode 100644 DashControl/Sources/Services/Networking/Additional/NetworkActivityIndicatorManager.h delete mode 100644 DashControl/Sources/Services/Networking/Additional/NetworkActivityIndicatorManager.m delete mode 100644 DashControl/Sources/Services/Networking/Blocks/HTTPLoaderBlocks.h delete mode 100644 DashControl/Sources/Services/Networking/Blocks/HTTPLoaderManager.h delete mode 100644 DashControl/Sources/Services/Networking/Blocks/HTTPLoaderManager.m delete mode 100644 DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperation.h delete mode 100644 DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperation.m delete mode 100644 DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperationProtocol.h delete mode 100644 DashControl/Sources/Services/Networking/HTTPCancellationToken.h delete mode 100755 DashControl/Sources/Services/Networking/HTTPLoader.h delete mode 100644 DashControl/Sources/Services/Networking/HTTPLoader.m delete mode 100755 DashControl/Sources/Services/Networking/HTTPLoaderAuthoriser.h delete mode 100755 DashControl/Sources/Services/Networking/HTTPLoaderDelegate.h delete mode 100644 DashControl/Sources/Services/Networking/HTTPLoaderFactory.h delete mode 100644 DashControl/Sources/Services/Networking/HTTPLoaderFactory.m delete mode 100644 DashControl/Sources/Services/Networking/HTTPRateLimiter.h delete mode 100644 DashControl/Sources/Services/Networking/HTTPRateLimiter.m delete mode 100644 DashControl/Sources/Services/Networking/HTTPRateLimiterMap.h delete mode 100644 DashControl/Sources/Services/Networking/HTTPRateLimiterMap.m delete mode 100644 DashControl/Sources/Services/Networking/HTTPRequest.h delete mode 100644 DashControl/Sources/Services/Networking/HTTPRequest.m delete mode 100644 DashControl/Sources/Services/Networking/HTTPRequestOperation.h delete mode 100644 DashControl/Sources/Services/Networking/HTTPRequestOperation.m delete mode 100644 DashControl/Sources/Services/Networking/HTTPRequestOperationHandler.h delete mode 100644 DashControl/Sources/Services/Networking/HTTPResponse.h delete mode 100644 DashControl/Sources/Services/Networking/HTTPResponse.m delete mode 100644 DashControl/Sources/Services/Networking/HTTPService.h delete mode 100644 DashControl/Sources/Services/Networking/HTTPService.m delete mode 100644 DashControl/Sources/Services/Networking/Networking.h delete mode 100755 DashControl/Sources/Services/Networking/Private/HTTPCancellationTokenImpl.h delete mode 100644 DashControl/Sources/Services/Networking/Private/HTTPCancellationTokenImpl.m delete mode 100755 DashControl/Sources/Services/Networking/Private/HTTPLoader+Private.h delete mode 100644 DashControl/Sources/Services/Networking/Private/HTTPLoaderFactory+Private.h delete mode 100755 DashControl/Sources/Services/Networking/Private/HTTPRequest+Private.h delete mode 100644 DashControl/Sources/Services/Networking/Private/HTTPResponse+Private.h delete mode 100644 DashControl/Sources/Services/Networking/Private/HTTPURLRequestBuilder.h delete mode 100644 DashControl/Sources/Services/Networking/Private/HTTPURLRequestBuilder.m delete mode 100755 DashControl/Sources/Services/Networking/Private/SPTDataLoaderExponentialTimer.h delete mode 100644 DashControl/Sources/Services/Networking/Private/SPTDataLoaderExponentialTimer.m diff --git a/DashControl.xcodeproj/project.pbxproj b/DashControl.xcodeproj/project.pbxproj index ece5b97..9757ab0 100644 --- a/DashControl.xcodeproj/project.pbxproj +++ b/DashControl.xcodeproj/project.pbxproj @@ -14,23 +14,8 @@ 24B0004D1F580FF5007D24A1 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24B0004C1F580FF5007D24A1 /* MobileCoreServices.framework */; }; 24E1D8DE1F4D742D00AE2C47 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24E1D8DD1F4D742D00AE2C47 /* UserNotifications.framework */; }; 24E584071F3ADAC900A12087 /* DashControl.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 24E584051F3ADAC900A12087 /* DashControl.xcdatamodeld */; }; - 2A04E6DB202DA5E20065F30D /* HTTPLoaderManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6B2202DA5E20065F30D /* HTTPLoaderManager.m */; }; - 2A04E6DC202DA5E20065F30D /* HTTPLoaderOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6B4202DA5E20065F30D /* HTTPLoaderOperation.m */; }; - 2A04E6DD202DA5E20065F30D /* HTTPRateLimiter.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6B9202DA5E20065F30D /* HTTPRateLimiter.m */; }; - 2A04E6DE202DA5E20065F30D /* HTTPResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6BB202DA5E20065F30D /* HTTPResponse.m */; }; - 2A04E6DF202DA5E20065F30D /* HTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6BF202DA5E20065F30D /* HTTPRequestOperation.m */; }; - 2A04E6E0202DA5E20065F30D /* HTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6C1202DA5E20065F30D /* HTTPRequest.m */; }; - 2A04E6E1202DA5E20065F30D /* HTTPLoaderFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6C2202DA5E20065F30D /* HTTPLoaderFactory.m */; }; - 2A04E6E2202DA5E20065F30D /* HTTPLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6C5202DA5E20065F30D /* HTTPLoader.m */; }; - 2A04E6E3202DA5E20065F30D /* SPTDataLoaderExponentialTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6CB202DA5E20065F30D /* SPTDataLoaderExponentialTimer.m */; }; - 2A04E6E4202DA5E20065F30D /* HTTPCancellationTokenImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6CC202DA5E20065F30D /* HTTPCancellationTokenImpl.m */; }; - 2A04E6E5202DA5E20065F30D /* HTTPURLRequestBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6CE202DA5E20065F30D /* HTTPURLRequestBuilder.m */; }; - 2A04E6E6202DA5E20065F30D /* NetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6D3202DA5E20065F30D /* NetworkActivityIndicatorManager.m */; }; - 2A04E6E7202DA5E20065F30D /* HTTPRateLimiterMap.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6D6202DA5E20065F30D /* HTTPRateLimiterMap.m */; }; - 2A04E6E8202DA5E20065F30D /* HTTPService.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6D8202DA5E20065F30D /* HTTPService.m */; }; 2A04E6E9202DA5E20065F30D /* Injections.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6DA202DA5E20065F30D /* Injections.m */; }; 2A04E6ED202DAB340065F30D /* RunOnMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A04E6EB202DAB340065F30D /* RunOnMain.m */; }; - 2A08CF57207F0FAE002C1192 /* NSURLRequest+DCcURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A08CF56207F0FAE002C1192 /* NSURLRequest+DCcURL.m */; }; 2A0DAAD42086910200992DC1 /* ProposalsSegmentSelectorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A0DAAD32086910200992DC1 /* ProposalsSegmentSelectorView.m */; }; 2A0DAAD62086913300992DC1 /* ProposalsSegmentSelectorView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2A0DAAD52086913300992DC1 /* ProposalsSegmentSelectorView.xib */; }; 2A0DAAD920872CB000992DC1 /* ProposalsSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A0DAAD820872CB000992DC1 /* ProposalsSegmentedControl.m */; }; @@ -124,13 +109,13 @@ 2A6FBEF5207C0CFF0055BAC8 /* News.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2A6FBEF4207C0CFF0055BAC8 /* News.storyboard */; }; 2A6FBEFA207C97510055BAC8 /* ProposalDetailVotesView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A6FBEF9207C97510055BAC8 /* ProposalDetailVotesView.m */; }; 2A6FBEFD207C98410055BAC8 /* ProposalDetailVotesViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A6FBEFC207C98410055BAC8 /* ProposalDetailVotesViewModel.m */; }; + 2A7DCCD720DB63FC0097049F /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 2A7DCCD920DB63FC0097049F /* Localizable.stringsdict */; }; 2A7F8F6E20F32D030048A9ED /* IPAddressTextFieldFormCellModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A7F8F6D20F32D030048A9ED /* IPAddressTextFieldFormCellModel.m */; }; 2A7F8F7120F330670048A9ED /* PrivateKeyTextFieldFormCellModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A7F8F7020F330670048A9ED /* PrivateKeyTextFieldFormCellModel.m */; }; 2A7F8F7B20F476070048A9ED /* DCBudgetProposalVoteEntity+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A7F8F7920F476070048A9ED /* DCBudgetProposalVoteEntity+CoreDataClass.m */; }; 2A7F8F7C20F476070048A9ED /* DCBudgetProposalVoteEntity+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A7F8F7A20F476070048A9ED /* DCBudgetProposalVoteEntity+CoreDataProperties.m */; }; 2A7F8F7F20F557320048A9ED /* UIImage+DCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A7F8F7E20F557320048A9ED /* UIImage+DCAdditions.m */; }; 2A7F8F8220F7359D0048A9ED /* PrivateKeyQRScannerViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A7F8F8120F7359D0048A9ED /* PrivateKeyQRScannerViewModel.m */; }; - 2A7DCCD720DB63FC0097049F /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 2A7DCCD920DB63FC0097049F /* Localizable.stringsdict */; }; 2A80B584203699E70015E1AA /* DCPersistenceStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A80B583203699E70015E1AA /* DCPersistenceStack.m */; }; 2A80B58720369E7F0015E1AA /* NSData+Hash.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A80B58620369E7F0015E1AA /* NSData+Hash.m */; }; 2A80B58A2036A8F40015E1AA /* DCLogging.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A80B5892036A8F40015E1AA /* DCLogging.m */; }; @@ -279,50 +264,9 @@ 24E584061F3ADAC900A12087 /* DashControl.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DashControl.xcdatamodel; sourceTree = ""; }; 24E584151F3ADCEF00A12087 /* DashControl-PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DashControl-PrefixHeader.pch"; sourceTree = ""; }; 2A04E6AE202DA5E20065F30D /* Injections.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Injections.h; sourceTree = ""; }; - 2A04E6B1202DA5E20065F30D /* HTTPLoaderOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPLoaderOperation.h; sourceTree = ""; }; - 2A04E6B2202DA5E20065F30D /* HTTPLoaderManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPLoaderManager.m; sourceTree = ""; }; - 2A04E6B3202DA5E20065F30D /* HTTPLoaderBlocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPLoaderBlocks.h; sourceTree = ""; }; - 2A04E6B4202DA5E20065F30D /* HTTPLoaderOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPLoaderOperation.m; sourceTree = ""; }; - 2A04E6B5202DA5E20065F30D /* HTTPLoaderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPLoaderManager.h; sourceTree = ""; }; - 2A04E6B6202DA5E20065F30D /* HTTPLoaderOperationProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPLoaderOperationProtocol.h; sourceTree = ""; }; - 2A04E6B7202DA5E20065F30D /* HTTPLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPLoader.h; sourceTree = ""; }; - 2A04E6B8202DA5E20065F30D /* HTTPLoaderAuthoriser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPLoaderAuthoriser.h; sourceTree = ""; }; - 2A04E6B9202DA5E20065F30D /* HTTPRateLimiter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPRateLimiter.m; sourceTree = ""; }; - 2A04E6BA202DA5E20065F30D /* HTTPLoaderFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPLoaderFactory.h; sourceTree = ""; }; - 2A04E6BB202DA5E20065F30D /* HTTPResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPResponse.m; sourceTree = ""; }; - 2A04E6BC202DA5E20065F30D /* HTTPRequestOperationHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPRequestOperationHandler.h; sourceTree = ""; }; - 2A04E6BD202DA5E20065F30D /* HTTPService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPService.h; sourceTree = ""; }; - 2A04E6BE202DA5E20065F30D /* HTTPLoaderDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPLoaderDelegate.h; sourceTree = ""; }; - 2A04E6BF202DA5E20065F30D /* HTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPRequestOperation.m; sourceTree = ""; }; - 2A04E6C0202DA5E20065F30D /* HTTPRateLimiterMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPRateLimiterMap.h; sourceTree = ""; }; - 2A04E6C1202DA5E20065F30D /* HTTPRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPRequest.m; sourceTree = ""; }; - 2A04E6C2202DA5E20065F30D /* HTTPLoaderFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPLoaderFactory.m; sourceTree = ""; }; - 2A04E6C3202DA5E20065F30D /* HTTPCancellationToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPCancellationToken.h; sourceTree = ""; }; - 2A04E6C4202DA5E20065F30D /* HTTPRateLimiter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPRateLimiter.h; sourceTree = ""; }; - 2A04E6C5202DA5E20065F30D /* HTTPLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPLoader.m; sourceTree = ""; }; - 2A04E6C7202DA5E20065F30D /* HTTPCancellationTokenImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPCancellationTokenImpl.h; sourceTree = ""; }; - 2A04E6C8202DA5E20065F30D /* SPTDataLoaderExponentialTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPTDataLoaderExponentialTimer.h; sourceTree = ""; }; - 2A04E6C9202DA5E20065F30D /* HTTPURLRequestBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPURLRequestBuilder.h; sourceTree = ""; }; - 2A04E6CA202DA5E20065F30D /* HTTPLoader+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTTPLoader+Private.h"; sourceTree = ""; }; - 2A04E6CB202DA5E20065F30D /* SPTDataLoaderExponentialTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPTDataLoaderExponentialTimer.m; sourceTree = ""; }; - 2A04E6CC202DA5E20065F30D /* HTTPCancellationTokenImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPCancellationTokenImpl.m; sourceTree = ""; }; - 2A04E6CD202DA5E20065F30D /* HTTPResponse+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTTPResponse+Private.h"; sourceTree = ""; }; - 2A04E6CE202DA5E20065F30D /* HTTPURLRequestBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPURLRequestBuilder.m; sourceTree = ""; }; - 2A04E6CF202DA5E20065F30D /* HTTPRequest+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTTPRequest+Private.h"; sourceTree = ""; }; - 2A04E6D0202DA5E20065F30D /* HTTPLoaderFactory+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTTPLoaderFactory+Private.h"; sourceTree = ""; }; - 2A04E6D1202DA5E20065F30D /* HTTPResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPResponse.h; sourceTree = ""; }; - 2A04E6D3202DA5E20065F30D /* NetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NetworkActivityIndicatorManager.m; sourceTree = ""; }; - 2A04E6D4202DA5E20065F30D /* NetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkActivityIndicatorManager.h; sourceTree = ""; }; - 2A04E6D5202DA5E20065F30D /* HTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPRequest.h; sourceTree = ""; }; - 2A04E6D6202DA5E20065F30D /* HTTPRateLimiterMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPRateLimiterMap.m; sourceTree = ""; }; - 2A04E6D7202DA5E20065F30D /* HTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPRequestOperation.h; sourceTree = ""; }; - 2A04E6D8202DA5E20065F30D /* HTTPService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HTTPService.m; sourceTree = ""; }; - 2A04E6D9202DA5E20065F30D /* Networking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Networking.h; sourceTree = ""; }; 2A04E6DA202DA5E20065F30D /* Injections.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Injections.m; sourceTree = ""; }; 2A04E6EB202DAB340065F30D /* RunOnMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RunOnMain.m; sourceTree = ""; }; 2A04E6EC202DAB340065F30D /* RunOnMain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunOnMain.h; sourceTree = ""; }; - 2A08CF55207F0FAE002C1192 /* NSURLRequest+DCcURL.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSURLRequest+DCcURL.h"; sourceTree = ""; }; - 2A08CF56207F0FAE002C1192 /* NSURLRequest+DCcURL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSURLRequest+DCcURL.m"; sourceTree = ""; }; 2A0DAAD22086910200992DC1 /* ProposalsSegmentSelectorView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProposalsSegmentSelectorView.h; sourceTree = ""; }; 2A0DAAD32086910200992DC1 /* ProposalsSegmentSelectorView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProposalsSegmentSelectorView.m; sourceTree = ""; }; 2A0DAAD52086913300992DC1 /* ProposalsSegmentSelectorView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ProposalsSegmentSelectorView.xib; sourceTree = ""; }; @@ -501,6 +445,7 @@ 2A6FBEF9207C97510055BAC8 /* ProposalDetailVotesView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProposalDetailVotesView.m; sourceTree = ""; }; 2A6FBEFB207C98410055BAC8 /* ProposalDetailVotesViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ProposalDetailVotesViewModel.h; sourceTree = ""; }; 2A6FBEFC207C98410055BAC8 /* ProposalDetailVotesViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ProposalDetailVotesViewModel.m; sourceTree = ""; }; + 2A7DCCD820DB63FC0097049F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = ""; }; 2A7F8F6C20F32D030048A9ED /* IPAddressTextFieldFormCellModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IPAddressTextFieldFormCellModel.h; sourceTree = ""; }; 2A7F8F6D20F32D030048A9ED /* IPAddressTextFieldFormCellModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IPAddressTextFieldFormCellModel.m; sourceTree = ""; }; 2A7F8F6F20F330670048A9ED /* PrivateKeyTextFieldFormCellModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrivateKeyTextFieldFormCellModel.h; sourceTree = ""; }; @@ -513,7 +458,6 @@ 2A7F8F7E20F557320048A9ED /* UIImage+DCAdditions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImage+DCAdditions.m"; sourceTree = ""; }; 2A7F8F8020F7359D0048A9ED /* PrivateKeyQRScannerViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrivateKeyQRScannerViewModel.h; sourceTree = ""; }; 2A7F8F8120F7359D0048A9ED /* PrivateKeyQRScannerViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PrivateKeyQRScannerViewModel.m; sourceTree = ""; }; - 2A7DCCD820DB63FC0097049F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = en; path = en.lproj/Localizable.stringsdict; sourceTree = ""; }; 2A80B582203699E70015E1AA /* DCPersistenceStack.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DCPersistenceStack.h; sourceTree = ""; }; 2A80B583203699E70015E1AA /* DCPersistenceStack.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DCPersistenceStack.m; sourceTree = ""; }; 2A80B58520369E7F0015E1AA /* NSData+Hash.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSData+Hash.h"; sourceTree = ""; }; @@ -899,7 +843,6 @@ isa = PBXGroup; children = ( 2A6F595D2034258600D7BD85 /* API */, - 2A04E6AF202DA5E20065F30D /* Networking */, 2A6FBECE20769B1D0055BAC8 /* Credentials.h */, 2A6FBECF20769B1D0055BAC8 /* Credentials.m */, 2A04E6AE202DA5E20065F30D /* Injections.h */, @@ -908,78 +851,6 @@ path = Services; sourceTree = ""; }; - 2A04E6AF202DA5E20065F30D /* Networking */ = { - isa = PBXGroup; - children = ( - 2A04E6D2202DA5E20065F30D /* Additional */, - 2A04E6B0202DA5E20065F30D /* Blocks */, - 2A04E6C6202DA5E20065F30D /* Private */, - 2A04E6C3202DA5E20065F30D /* HTTPCancellationToken.h */, - 2A04E6B7202DA5E20065F30D /* HTTPLoader.h */, - 2A04E6C5202DA5E20065F30D /* HTTPLoader.m */, - 2A04E6B8202DA5E20065F30D /* HTTPLoaderAuthoriser.h */, - 2A04E6BE202DA5E20065F30D /* HTTPLoaderDelegate.h */, - 2A04E6BA202DA5E20065F30D /* HTTPLoaderFactory.h */, - 2A04E6C2202DA5E20065F30D /* HTTPLoaderFactory.m */, - 2A04E6C4202DA5E20065F30D /* HTTPRateLimiter.h */, - 2A04E6B9202DA5E20065F30D /* HTTPRateLimiter.m */, - 2A04E6C0202DA5E20065F30D /* HTTPRateLimiterMap.h */, - 2A04E6D6202DA5E20065F30D /* HTTPRateLimiterMap.m */, - 2A04E6D5202DA5E20065F30D /* HTTPRequest.h */, - 2A04E6C1202DA5E20065F30D /* HTTPRequest.m */, - 2A04E6D7202DA5E20065F30D /* HTTPRequestOperation.h */, - 2A04E6BF202DA5E20065F30D /* HTTPRequestOperation.m */, - 2A04E6BC202DA5E20065F30D /* HTTPRequestOperationHandler.h */, - 2A04E6D1202DA5E20065F30D /* HTTPResponse.h */, - 2A04E6BB202DA5E20065F30D /* HTTPResponse.m */, - 2A04E6BD202DA5E20065F30D /* HTTPService.h */, - 2A04E6D8202DA5E20065F30D /* HTTPService.m */, - 2A04E6D9202DA5E20065F30D /* Networking.h */, - ); - path = Networking; - sourceTree = ""; - }; - 2A04E6B0202DA5E20065F30D /* Blocks */ = { - isa = PBXGroup; - children = ( - 2A04E6B3202DA5E20065F30D /* HTTPLoaderBlocks.h */, - 2A04E6B5202DA5E20065F30D /* HTTPLoaderManager.h */, - 2A04E6B2202DA5E20065F30D /* HTTPLoaderManager.m */, - 2A04E6B1202DA5E20065F30D /* HTTPLoaderOperation.h */, - 2A04E6B4202DA5E20065F30D /* HTTPLoaderOperation.m */, - 2A04E6B6202DA5E20065F30D /* HTTPLoaderOperationProtocol.h */, - ); - path = Blocks; - sourceTree = ""; - }; - 2A04E6C6202DA5E20065F30D /* Private */ = { - isa = PBXGroup; - children = ( - 2A04E6C7202DA5E20065F30D /* HTTPCancellationTokenImpl.h */, - 2A04E6CC202DA5E20065F30D /* HTTPCancellationTokenImpl.m */, - 2A04E6CA202DA5E20065F30D /* HTTPLoader+Private.h */, - 2A04E6D0202DA5E20065F30D /* HTTPLoaderFactory+Private.h */, - 2A04E6CF202DA5E20065F30D /* HTTPRequest+Private.h */, - 2A04E6CD202DA5E20065F30D /* HTTPResponse+Private.h */, - 2A04E6C9202DA5E20065F30D /* HTTPURLRequestBuilder.h */, - 2A04E6CE202DA5E20065F30D /* HTTPURLRequestBuilder.m */, - 2A04E6C8202DA5E20065F30D /* SPTDataLoaderExponentialTimer.h */, - 2A04E6CB202DA5E20065F30D /* SPTDataLoaderExponentialTimer.m */, - ); - path = Private; - sourceTree = ""; - }; - 2A04E6D2202DA5E20065F30D /* Additional */ = { - isa = PBXGroup; - children = ( - 2A04E6D4202DA5E20065F30D /* NetworkActivityIndicatorManager.h */, - 2A04E6D3202DA5E20065F30D /* NetworkActivityIndicatorManager.m */, - 2A08CF55207F0FAE002C1192 /* NSURLRequest+DCcURL.h */, - 2A08CF56207F0FAE002C1192 /* NSURLRequest+DCcURL.m */, - ); - path = Additional; - sourceTree = ""; - }; 2A04E6EA202DAB340065F30D /* Helpers */ = { isa = PBXGroup; children = ( @@ -1730,6 +1601,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, es, @@ -1883,7 +1755,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-DashControl/Pods-DashControl-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-DashControl/Pods-DashControl-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/DashSync/DashSync.bundle", "${PODS_CONFIGURATION_BUILD_DIR}/MBCircularProgressBar/MBCircularProgressBar.bundle", ); @@ -1894,7 +1766,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DashControl/Pods-DashControl-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-DashControl/Pods-DashControl-resources.sh\"\n"; showEnvVarsInLog = 0; }; 9EDCE32632289D723EF39407 /* [CP] Copy Pods Resources */ = { @@ -1903,7 +1775,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-DashControlTests/Pods-DashControlTests-resources.sh", + "${PODS_ROOT}/Target Support Files/Pods-DashControlTests/Pods-DashControlTests-resources.sh", "${PODS_CONFIGURATION_BUILD_DIR}/DashSync/DashSync.bundle", "${PODS_CONFIGURATION_BUILD_DIR}/MBCircularProgressBar/MBCircularProgressBar.bundle", ); @@ -1914,7 +1786,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DashControlTests/Pods-DashControlTests-resources.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-DashControlTests/Pods-DashControlTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; B13CDC11D77705DD862345F6 /* [CP] Check Pods Manifest.lock */ = { @@ -1974,7 +1846,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2A04E6E2202DA5E20065F30D /* HTTPLoader.m in Sources */, FB4310D71F9DA96700784EBC /* DCWalletManager.m in Sources */, 2AF39E99209BABC600479948 /* UITestingHelper.m in Sources */, 2A04E6E9202DA5E20065F30D /* Injections.m in Sources */, @@ -1982,15 +1853,12 @@ 2A6FBEC120763B2E0055BAC8 /* DCWalletEntity+Extensions.m in Sources */, 2A46C28020AB7095007037FA /* APIBudgetPrivate.m in Sources */, 2A32D6082051D91D004B38A6 /* ProposalDetailHeaderViewModel.m in Sources */, - 2A04E6E7202DA5E20065F30D /* HTTPRateLimiterMap.m in Sources */, FB2F9B3D1F5C9F960035180D /* NSArray+SWAdditions.m in Sources */, 2AEF29702073465A008590E4 /* SelectorFormCellModel.m in Sources */, - 2A04E6DB202DA5E20065F30D /* HTTPLoaderManager.m in Sources */, 2A4A2FE220AD699500835B92 /* PlaceholderTextView.m in Sources */, 2AD0973320571DF300033B72 /* DCChartDataTimeIntervalEntity+Extensions.m in Sources */, 2A587E9E206A846B004BC537 /* PortfolioViewModel.m in Sources */, 2AC693FB2064E74F00F64482 /* PriceViewModel.m in Sources */, - 2A04E6DC202DA5E20065F30D /* HTTPLoaderOperation.m in Sources */, 2AE7F50A2034A99500A8E770 /* DCNewsPostEntity+CoreDataClass.m in Sources */, 2A44739E20419D3000B52BCB /* DCChartDataEntryEntity+Extensions.m in Sources */, 2AD693C32032C99A0084D840 /* NewsViewController.m in Sources */, @@ -2003,12 +1871,10 @@ 2A7F8F6E20F32D030048A9ED /* IPAddressTextFieldFormCellModel.m in Sources */, 2AEF29B920740626008590E4 /* QRCodeButton.m in Sources */, 2A7F8F7F20F557320048A9ED /* UIImage+DCAdditions.m in Sources */, - 2A04E6E1202DA5E20065F30D /* HTTPLoaderFactory.m in Sources */, 2AEF296B207345BC008590E4 /* SelectorFormTableViewCell.m in Sources */, 2A32D63420546347004B38A6 /* ProposalDetailTableViewCell.m in Sources */, 2A3F49B4204BFF50005EB5D9 /* DCBudgetProposalCommentEntity+CoreDataClass.m in Sources */, 2A3F49AF204AEC09005EB5D9 /* APIBudget.m in Sources */, - 2A04E6E0202DA5E20065F30D /* HTTPRequest.m in Sources */, FB4550DE1FB1D3C3001CC1ED /* DCTriggerEntity+CoreDataProperties.m in Sources */, 2AEF298220735DE4008590E4 /* SwitcherFormTableViewCell.m in Sources */, FB84EDC51F32898700E4D400 /* AppDelegate.m in Sources */, @@ -2023,18 +1889,15 @@ 2AEF297F20735DA5008590E4 /* SwitcherFormCellModel.m in Sources */, FBEBE5421F5802DE0056D921 /* DCChartTimeFormatter.m in Sources */, 2AEF299820737E61008590E4 /* MasternodeViewModel.m in Sources */, - 2A04E6E8202DA5E20065F30D /* HTTPService.m in Sources */, 2A289A50203AB44400EDC98E /* BaseNewsTableViewController.m in Sources */, 2A972205204F29B600545079 /* ProposalsHeaderViewModel.m in Sources */, 2A32D64A20571052004B38A6 /* DCChartDataTimeIntervalEntity+CoreDataProperties.m in Sources */, 24E584071F3ADAC900A12087 /* DashControl.xcdatamodeld in Sources */, 2A80B58D2039B3050015E1AA /* UIFont+DCStyle.m in Sources */, 2AE3C466208FCE6600CE83A8 /* UIViewController+DCChildControllers.m in Sources */, - 2A04E6DD202DA5E20065F30D /* HTTPRateLimiter.m in Sources */, FB4310DD1F9EFC4000784EBC /* DCServerBloomFilter.m in Sources */, 2A0DAAEF208DC8C400992DC1 /* FetchedResultsTableViewController.m in Sources */, FB9CC1801F83E45F0079309F /* DCMasternodeEntity+CoreDataClass.m in Sources */, - 2A04E6E3202DA5E20065F30D /* SPTDataLoaderExponentialTimer.m in Sources */, 2A0DAAD42086910200992DC1 /* ProposalsSegmentSelectorView.m in Sources */, 2A3F49AC2049426F005EB5D9 /* DCBudgetInfoEntity+CoreDataProperties.m in Sources */, 2AEF298E20737904008590E4 /* WalletAddressViewController.m in Sources */, @@ -2046,7 +1909,6 @@ 2AC693EC2061D63D00F64482 /* APITrigger.m in Sources */, 2A587E99206A53A5004BC537 /* PortfolioViewController.m in Sources */, 2A6AFF6620ADEBF100F208A6 /* NewsFirstTableViewCell.m in Sources */, - 2A04E6E4202DA5E20065F30D /* HTTPCancellationTokenImpl.m in Sources */, 2A6FBEE3207B18F90055BAC8 /* PortfolioHeaderView.m in Sources */, FBE1F50E1F5D4CF500823A77 /* DCMarketEntity+CoreDataProperties.m in Sources */, 2A8F8187203EBB7200D3D6C9 /* DCExchangeEntity+Extensions.m in Sources */, @@ -2063,7 +1925,6 @@ 2A0DAAF5208DD25400992DC1 /* ProposalsTopViewModel.m in Sources */, 2A28DF3C20A0997300132DBF /* AddressQRScannerViewModel.m in Sources */, 2A80B58A2036A8F40015E1AA /* DCLogging.m in Sources */, - 2A04E6DE202DA5E20065F30D /* HTTPResponse.m in Sources */, 2A7F8F8220F7359D0048A9ED /* PrivateKeyQRScannerViewModel.m in Sources */, FB4310DA1F9EF4B500784EBC /* DCWalletAccount.m in Sources */, 2A6FBEBE207634530055BAC8 /* DCWalletAccountEntity+Extensions.m in Sources */, @@ -2091,11 +1952,9 @@ 2A80B5922039C0DB0015E1AA /* DCSearchBar.m in Sources */, 2A8F817E203E723600D3D6C9 /* APIPrice.m in Sources */, 2AEF29622072CD25008590E4 /* BaseFormCellModel.m in Sources */, - 2A08CF57207F0FAE002C1192 /* NSURLRequest+DCcURL.m in Sources */, 2A46C28D20AC78AD007037FA /* ProposalCommentAddTableViewCell.m in Sources */, 2AEF29E7207421E5008590E4 /* QRScannerViewController.m in Sources */, 2A3F49A92049426F005EB5D9 /* DCBudgetProposalEntity+CoreDataClass.m in Sources */, - 2A04E6E5202DA5E20065F30D /* HTTPURLRequestBuilder.m in Sources */, 2A4FE281203AE489007FD160 /* UIColor+DCStyle.m in Sources */, 2A587EAD206A8D8E004BC537 /* TableViewFRCDelegate.m in Sources */, 2A6FBEFA207C97510055BAC8 /* ProposalDetailVotesView.m in Sources */, @@ -2121,7 +1980,6 @@ 2AEF297320734F30008590E4 /* ButtonFormCellModel.m in Sources */, 2AE3C4722093149C00CE83A8 /* SearchNavigationTitleView.m in Sources */, 2A587EA7206A88AC004BC537 /* ItemTableViewCell.m in Sources */, - 2A04E6E6202DA5E20065F30D /* NetworkActivityIndicatorManager.m in Sources */, 2A0DAAD920872CB000992DC1 /* ProposalsSegmentedControl.m in Sources */, 2A0DAAF2208DD24500992DC1 /* ProposalsTopView.m in Sources */, 2A7F8F7120F330670048A9ED /* PrivateKeyTextFieldFormCellModel.m in Sources */, @@ -2150,7 +2008,6 @@ 2AE7F50B2034A99500A8E770 /* DCNewsPostEntity+CoreDataProperties.m in Sources */, 2A3F49CF204C833D005EB5D9 /* ProposalsViewModel.m in Sources */, 2AEF295C2072B0DF008590E4 /* TextFieldFormTableViewCell.m in Sources */, - 2A04E6DF202DA5E20065F30D /* HTTPRequestOperation.m in Sources */, 2AEF299E20738FF1008590E4 /* AddressTextFieldFormCellModel.m in Sources */, 2AE410532066D33000C41AC5 /* ExchangeMarketPairObject.m in Sources */, 2A46C28920AC26DE007037FA /* QRScannerHintView.m in Sources */, diff --git a/DashControl/Sources/Services/API/APIBaseAuthorized.m b/DashControl/Sources/Services/API/APIBaseAuthorized.m index 99d0315..3df88b4 100644 --- a/DashControl/Sources/Services/API/APIBaseAuthorized.m +++ b/DashControl/Sources/Services/API/APIBaseAuthorized.m @@ -18,7 +18,7 @@ #import "APIBaseAuthorized.h" #import "Credentials.h" -#import "Networking.h" +#import "DSNetworking.h" NS_ASSUME_NONNULL_BEGIN diff --git a/DashControl/Sources/Services/API/APIBudget.m b/DashControl/Sources/Services/API/APIBudget.m index ff8504e..714da10 100644 --- a/DashControl/Sources/Services/API/APIBudget.m +++ b/DashControl/Sources/Services/API/APIBudget.m @@ -25,7 +25,7 @@ #import "NSManagedObject+DCExtensions.h" #import "NSManagedObjectContext+DCExtensions.h" #import "DCPersistenceStack.h" -#import "Networking.h" +#import "DSNetworking.h" NS_ASSUME_NONNULL_BEGIN diff --git a/DashControl/Sources/Services/API/APIBudgetPrivate.m b/DashControl/Sources/Services/API/APIBudgetPrivate.m index 3ddd49f..1e95f2f 100644 --- a/DashControl/Sources/Services/API/APIBudgetPrivate.m +++ b/DashControl/Sources/Services/API/APIBudgetPrivate.m @@ -18,7 +18,7 @@ #import "APIBudgetPrivate.h" #import "DCPersistenceStack.h" -#import "Networking.h" +#import "DSNetworking.h" NS_ASSUME_NONNULL_BEGIN diff --git a/DashControl/Sources/Services/API/APINews.m b/DashControl/Sources/Services/API/APINews.m index 54e91cf..8939021 100644 --- a/DashControl/Sources/Services/API/APINews.m +++ b/DashControl/Sources/Services/API/APINews.m @@ -22,7 +22,7 @@ #import "DCNewsPostEntity+CoreDataClass.h" #import "NSManagedObjectContext+DCExtensions.h" #import "DCPersistenceStack.h" -#import "Networking.h" +#import "DSNetworking.h" NS_ASSUME_NONNULL_BEGIN diff --git a/DashControl/Sources/Services/API/APIPortfolio.m b/DashControl/Sources/Services/API/APIPortfolio.m index d02d604..5933fd0 100644 --- a/DashControl/Sources/Services/API/APIPortfolio.m +++ b/DashControl/Sources/Services/API/APIPortfolio.m @@ -18,7 +18,7 @@ #import "APIPortfolio.h" #import "DCServerBloomFilter.h" -#import "Networking.h" +#import "DSNetworking.h" NS_ASSUME_NONNULL_BEGIN diff --git a/DashControl/Sources/Services/API/APIPrice.m b/DashControl/Sources/Services/API/APIPrice.m index 876580d..f3dee3e 100644 --- a/DashControl/Sources/Services/API/APIPrice.m +++ b/DashControl/Sources/Services/API/APIPrice.m @@ -22,7 +22,7 @@ #import "DCMarketEntity+Extensions.h" #import "NSManagedObjectContext+DCExtensions.h" #import "DCPersistenceStack.h" -#import "Networking.h" +#import "DSNetworking.h" NS_ASSUME_NONNULL_BEGIN diff --git a/DashControl/Sources/Services/API/APITrigger.m b/DashControl/Sources/Services/API/APITrigger.m index 31ce53b..a5d276c 100644 --- a/DashControl/Sources/Services/API/APITrigger.m +++ b/DashControl/Sources/Services/API/APITrigger.m @@ -27,7 +27,7 @@ #import "Credentials.h" #import "DCPersistenceStack.h" #import "DCTrigger.h" -#import "Networking.h" +#import "DSNetworking.h" NS_ASSUME_NONNULL_BEGIN diff --git a/DashControl/Sources/Services/Injections.m b/DashControl/Sources/Services/Injections.m index 1fc0799..85fedaa 100644 --- a/DashControl/Sources/Services/Injections.m +++ b/DashControl/Sources/Services/Injections.m @@ -31,7 +31,7 @@ #import "ChartViewModel.h" #import "DCPersistenceStack.h" #import "DCWalletManager.h" -#import "Networking.h" +#import "DSNetworking.h" NS_ASSUME_NONNULL_BEGIN diff --git a/DashControl/Sources/Services/Networking/Additional/NSURLRequest+DCcURL.h b/DashControl/Sources/Services/Networking/Additional/NSURLRequest+DCcURL.h deleted file mode 100644 index 0267f5f..0000000 --- a/DashControl/Sources/Services/Networking/Additional/NSURLRequest+DCcURL.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 dashfoundation. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface NSURLRequest (DCcURL) - -- (NSString *)dc_cURL; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Additional/NSURLRequest+DCcURL.m b/DashControl/Sources/Services/Networking/Additional/NSURLRequest+DCcURL.m deleted file mode 100644 index 7b684ee..0000000 --- a/DashControl/Sources/Services/Networking/Additional/NSURLRequest+DCcURL.m +++ /dev/null @@ -1,54 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 dashfoundation. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import "NSURLRequest+DCcURL.h" - -NS_ASSUME_NONNULL_BEGIN - -@implementation NSURLRequest (DCcURL) - -- (NSString *)escapeQuotesInString:(NSString *)string { - NSParameterAssert(string.length); - - return [string stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]; -} - -- (NSString *)dc_cURL { - // `-k` allows insecure connections - NSMutableString *cURLString = [NSMutableString stringWithFormat:@"curl -k -X %@ --dump-header -", self.HTTPMethod]; - - for (NSString *key in self.allHTTPHeaderFields) { - NSString *headerKey = [self escapeQuotesInString:key]; - NSString *headerValue = [self escapeQuotesInString:self.allHTTPHeaderFields[key]]; - - [cURLString appendFormat:@" -H \"%@: %@\"", headerKey, headerValue]; - } - - NSString *bodyString = [[NSString alloc] initWithData:self.HTTPBody encoding:NSUTF8StringEncoding]; - if (bodyString.length) { - bodyString = [self escapeQuotesInString:bodyString]; - [cURLString appendFormat:@" -d \"%@\"", bodyString]; - } - - [cURLString appendFormat:@" \"%@\"", self.URL.absoluteString]; - - return cURLString; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Additional/NetworkActivityIndicatorManager.h b/DashControl/Sources/Services/Networking/Additional/NetworkActivityIndicatorManager.h deleted file mode 100644 index b981abb..0000000 --- a/DashControl/Sources/Services/Networking/Additional/NetworkActivityIndicatorManager.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// NetworkActivityIndicatorManager.h -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface NetworkActivityIndicatorManager : NSObject - -+ (void)increaseActivityCounter; -+ (void)decreaseActivityCounter; - -- (instancetype)init NS_UNAVAILABLE; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Additional/NetworkActivityIndicatorManager.m b/DashControl/Sources/Services/Networking/Additional/NetworkActivityIndicatorManager.m deleted file mode 100644 index a8ff856..0000000 --- a/DashControl/Sources/Services/Networking/Additional/NetworkActivityIndicatorManager.m +++ /dev/null @@ -1,79 +0,0 @@ -// -// NetworkActivityIndicatorManager.m -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import - -#import "NetworkActivityIndicatorManager.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface NetworkActivityIndicatorManager () - -@property (assign, nonatomic) NSUInteger counter; - -@end - -@implementation NetworkActivityIndicatorManager - -+ (void)increaseActivityCounter { - NSAssert([NSThread isMainThread], nil); - [[[self class] sharedInstance] increaseActivityCounter]; -} - -+ (void)decreaseActivityCounter { - NSAssert([NSThread isMainThread], nil); - [[[self class] sharedInstance] decreaseActivityCounter]; -} - -#pragma mark Private - -+ (instancetype)sharedInstance { - static id _sharedInstance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - _sharedInstance = [[self alloc] init]; - }); - return _sharedInstance; -} - -- (void)increaseActivityCounter { - self.counter++; - - if (self.counter > 0) { - [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; - } -} - -- (void)decreaseActivityCounter { - if (self.counter == 0) { - DCDebugLog([self class], @"activity counter < 0, something went wrong"); - - return; - } - - self.counter--; - - if (self.counter == 0) { - [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; - } -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderBlocks.h b/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderBlocks.h deleted file mode 100644 index 5afd890..0000000 --- a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderBlocks.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#ifndef HTTPLoaderBlocks_h -#define HTTPLoaderBlocks_h - -NS_ASSUME_NONNULL_BEGIN - -@class HTTPResponse; - -typedef void (^HTTPLoaderCompletionBlock)(id _Nullable parsedData, NSDictionary *_Nullable responseHeaders, NSInteger statusCode, NSError *_Nullable error); -typedef void (^HTTPLoaderRawCompletionBlock)(BOOL success, BOOL cancelled, HTTPResponse * _Nullable response); - -NS_ASSUME_NONNULL_END - -#endif /* HTTPLoaderBlocks_h */ diff --git a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderManager.h b/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderManager.h deleted file mode 100644 index 51bf193..0000000 --- a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderManager.h +++ /dev/null @@ -1,38 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import - -#import "HTTPLoaderBlocks.h" -#import "HTTPLoaderOperationProtocol.h" - -NS_ASSUME_NONNULL_BEGIN - -@class HTTPRequest; -@class HTTPLoaderFactory; - -@interface HTTPLoaderManager : NSObject - -- (instancetype)initWithFactory:(HTTPLoaderFactory *)factory NS_DESIGNATED_INITIALIZER; -- (instancetype)init NS_UNAVAILABLE; - -- (id)sendRequest:(HTTPRequest *)httpRequest completion:(HTTPLoaderCompletionBlock)completion; -- (id)sendRequest:(HTTPRequest *)httpRequest rawCompletion:(HTTPLoaderRawCompletionBlock)rawCompletion; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderManager.m b/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderManager.m deleted file mode 100644 index 16c210c..0000000 --- a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderManager.m +++ /dev/null @@ -1,127 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import "HTTPLoaderManager.h" - -#import "HTTPLoaderOperation.h" -#import "HTTPLoaderFactory.h" -#import "HTTPResponse.h" -#import "HTTPRequest.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPLoaderManager () - -@property (strong, nonatomic) HTTPLoaderFactory *factory; - -@end - -@implementation HTTPLoaderManager - -- (instancetype)initWithFactory:(HTTPLoaderFactory *)factory { - self = [super init]; - if (self) { - _factory = factory; - } - - return self; -} - -- (id)sendRequest:(HTTPRequest *)httpRequest completion:(HTTPLoaderCompletionBlock)completion { - return [self sendRequest:httpRequest factory:self.factory completion:completion]; -} - -- (id)sendRequest:(HTTPRequest *)httpRequest rawCompletion:(HTTPLoaderRawCompletionBlock)rawCompletion { - return [self sendRequest:httpRequest factory:self.factory rawCompletion:rawCompletion]; -} - -- (id)sendRequest:(HTTPRequest *)httpRequest - factory:(HTTPLoaderFactory *)factory - completion:(HTTPLoaderCompletionBlock)completion { - return [self sendRequest:httpRequest factory:factory rawCompletion:^(BOOL success, BOOL cancelled, HTTPResponse *_Nullable response) { - NSAssert([NSThread isMainThread], nil); - - if (success) { - NSError *_Nullable error = nil; - id _Nullable parsedData = [self parseResponse:response.body statusCode:response.statusCode request:httpRequest error:&error]; - NSAssert((!error && parsedData) || (error && !parsedData), nil); // sanity check - - if (completion) { - completion(parsedData, response.responseHeaders, response.statusCode, error ?: response.error); - } - } - else { - if (completion) { - if (cancelled) { - completion(nil, nil, HTTPResponseStatusCode_Invalid, [NSError errorWithDomain:NSURLErrorDomain - code:NSURLErrorCancelled - userInfo:nil]); - } - else { - completion(nil, response.responseHeaders, response.statusCode, response.error); - } - } - } - - }]; -} - -- (id)sendRequest:(HTTPRequest *)httpRequest - factory:(HTTPLoaderFactory *)factory - rawCompletion:(HTTPLoaderRawCompletionBlock)rawCompletion { - HTTPLoaderOperation *operation = [[HTTPLoaderOperation alloc] initWithHTTPRequest:httpRequest httpLoaderFactory:factory]; - [operation performWithCompletion:rawCompletion]; - return operation; -} - -#pragma mark Private - -- (nullable id)parseResponse:(nullable NSData *)data statusCode:(NSInteger)statusCode request:(HTTPRequest *)request error:(NSError *__autoreleasing *)error { - NSError *statusCodeError = nil; - if (statusCode < 200 || statusCode > 300) { - NSDictionary *userInfo = @{NSLocalizedDescriptionKey : [NSHTTPURLResponse localizedStringForStatusCode:statusCode]}; - statusCodeError = [NSError errorWithDomain:HTTPResponseErrorDomain - code:statusCode - userInfo:userInfo]; - } - - if (!data) { - if (error) { - *error = statusCodeError; - } - - return nil; - } - - NSError *parseError = nil; - id parsed = [NSJSONSerialization JSONObjectWithData:data - options:request.jsonReadingOptions - error:&parseError]; - if (parseError) { - if (error) { - *error = parseError; - } - - return nil; - } - - return parsed; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperation.h b/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperation.h deleted file mode 100644 index 10307fe..0000000 --- a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperation.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import - -#import "HTTPLoaderBlocks.h" -#import "HTTPLoaderOperationProtocol.h" - -NS_ASSUME_NONNULL_BEGIN - -@class HTTPRequest; -@class HTTPLoaderFactory; - -@interface HTTPLoaderOperation : NSObject - -- (instancetype)initWithHTTPRequest:(HTTPRequest *)httpRequest httpLoaderFactory:(HTTPLoaderFactory *)httpLoaderFactory NS_DESIGNATED_INITIALIZER; -- (instancetype)init NS_UNAVAILABLE; - -- (void)performWithCompletion:(HTTPLoaderRawCompletionBlock)completion; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperation.m b/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperation.m deleted file mode 100644 index df36979..0000000 --- a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperation.m +++ /dev/null @@ -1,138 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import "HTTPLoaderOperation.h" - -#import "HTTPCancellationToken.h" -#import "HTTPLoader.h" -#import "HTTPLoaderDelegate.h" -#import "HTTPLoaderFactory.h" -#import "HTTPRequest.h" -#import "NetworkActivityIndicatorManager.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPLoaderOperation () - -@property (strong, nonatomic) HTTPLoader *httpLoader; -@property (strong, nonatomic) HTTPRequest *httpRequest; - -@property (weak, nonatomic) id cancellationToken; -@property (nullable, copy, nonatomic) HTTPLoaderRawCompletionBlock completion; - -@end - -@implementation HTTPLoaderOperation - -- (instancetype)initWithHTTPRequest:(HTTPRequest *)httpRequest httpLoaderFactory:(HTTPLoaderFactory *)httpLoaderFactory { - NSParameterAssert(httpRequest); - NSParameterAssert(httpLoaderFactory); - - self = [super init]; - if (self) { - _httpRequest = httpRequest; - _httpLoader = [httpLoaderFactory createHTTPLoader]; - _httpLoader.delegate = self; - } - - return self; -} - -- (void)performWithCompletion:(HTTPLoaderRawCompletionBlock)completion { - NSParameterAssert(completion); - - // - // hold cycle reference to the `self` to keep an operation alive until it completed or cancelled - // - __block id referenceToSelf = self; - self.completion = ^(BOOL success, BOOL cancelled, HTTPResponse *_Nullable response) { - if (completion) { - completion(success, cancelled, response); - } - - referenceToSelf = nil; - }; - - self.cancellationToken = [self.httpLoader performRequest:self.httpRequest]; - NSAssert(self.cancellationToken, @"Performing request failed"); - - RunOnMainThread(^{ - [NetworkActivityIndicatorManager increaseActivityCounter]; - }); -} - -#pragma mark HTTPLoaderOperationProtocol - -- (void)cancel { - [self.cancellationToken cancel]; - - // - // nilled out completion block to break the retain cycle - // @see: performWithCompletion - // - self.completion = nil; -} - -- (void)cancelByProducingResumeData:(void (^)(NSData *_Nullable resumeData))completionHandler { - [self.cancellationToken cancelByProducingResumeData:^(NSData *_Nullable resumeData) { - if (completionHandler) { - completionHandler(resumeData); - } - - // - // nilled out completion block to break the retain cycle - // @see: performWithCompletion - // - self.completion = nil; - }]; -} - -#pragma mark HTTPLoaderDelegate - -- (void)httpLoader:(HTTPLoader *)httpLoader didReceiveSuccessfulResponse:(HTTPResponse *)response { - RunOnMainThread(^{ - [NetworkActivityIndicatorManager decreaseActivityCounter]; - }); - - if (self.completion) { - self.completion(YES, NO, response); - } -} - -- (void)httpLoader:(HTTPLoader *)httpLoader didReceiveErrorResponse:(HTTPResponse *)response { - RunOnMainThread(^{ - [NetworkActivityIndicatorManager decreaseActivityCounter]; - }); - - if (self.completion) { - self.completion(NO, NO, response); - } -} - -- (void)httpLoader:(HTTPLoader *)httpLoader didCancelRequest:(HTTPRequest *)request { - RunOnMainThread(^{ - [NetworkActivityIndicatorManager decreaseActivityCounter]; - }); - - if (self.completion) { - self.completion(NO, YES, nil); - } -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperationProtocol.h b/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperationProtocol.h deleted file mode 100644 index f58e88d..0000000 --- a/DashControl/Sources/Services/Networking/Blocks/HTTPLoaderOperationProtocol.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@protocol HTTPLoaderOperationProtocol - -- (void)cancel; -- (void)cancelByProducingResumeData:(void (^)(NSData *_Nullable resumeData))completionHandler; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPCancellationToken.h b/DashControl/Sources/Services/Networking/HTTPCancellationToken.h deleted file mode 100644 index 30dee8a..0000000 --- a/DashControl/Sources/Services/Networking/HTTPCancellationToken.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@protocol HTTPCancellationToken; - -@protocol HTTPCancellationTokenDelegate - -- (void)cancellationTokenDidCancel:(id)cancellationToken; -- (void)cancellationTokenDidCancel:(id)cancellationToken producingResumeDataCompletion:(void (^)(NSData *_Nullable resumeData))completionHandler; - -@end - -@protocol HTTPCancellationToken - -@property (nonatomic, assign, readonly, getter=isCancelled) BOOL cancelled; -@property (nonatomic, weak, readonly, nullable) id delegate; -@property (nonatomic, strong, readonly, nullable) id objectToCancel; - -- (void)cancel; -- (void)cancelByProducingResumeData:(void (^)(NSData *_Nullable resumeData))completionHandler; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPLoader.h b/DashControl/Sources/Services/Networking/HTTPLoader.h deleted file mode 100755 index bc9c191..0000000 --- a/DashControl/Sources/Services/Networking/HTTPLoader.h +++ /dev/null @@ -1,46 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@protocol HTTPCancellationToken; -@protocol HTTPLoaderDelegate; -@class HTTPRequest; - -@interface HTTPLoader : NSObject - -@property (nullable, weak, nonatomic) id delegate; -@property (strong, nonatomic) dispatch_queue_t delegateQueue; -@property (readonly, copy, nonatomic) NSArray *currentRequests; - -- (nullable id)performRequest:(HTTPRequest *)request; - -- (void)cancelAllLoads; - -- (instancetype)init NS_UNAVAILABLE; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPLoader.m b/DashControl/Sources/Services/Networking/HTTPLoader.m deleted file mode 100644 index 6275464..0000000 --- a/DashControl/Sources/Services/Networking/HTTPLoader.m +++ /dev/null @@ -1,239 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import "HTTPLoader+Private.h" - -#import "HTTPRequest+Private.h" -#import "HTTPResponse+Private.h" -#import "HTTPCancellationTokenImpl.h" -#import "HTTPLoaderDelegate.h" -#import "HTTPRequest.h" -#import "HTTPRequestOperationHandler.h" -#import "HTTPResponse.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPLoader () - -@property (readonly, strong, nonatomic) NSMutableArray> *cancellationTokens; -@property (readonly, strong, nonatomic) NSMutableArray *requests; - -@end - -@implementation HTTPLoader - -- (instancetype)initWithRequestOperationHandlerDelegate:(id)requestOperationHandlerDelegate { - self = [super init]; - if (self) { - _requestOperationHandlerDelegate = requestOperationHandlerDelegate; - - _cancellationTokens = [[NSMutableArray alloc] init]; - _delegateQueue = dispatch_get_main_queue(); - _requests = [[NSMutableArray alloc] init]; - } - return self; -} - -- (void)dealloc { - [self cancelAllLoads]; -} - -#pragma mark HTTPLoader - -- (nullable id)performRequest:(HTTPRequest *)request { - HTTPRequest *copiedRequest = [request copy]; - id delegate = self.delegate; - - // Cancel the request immediately if it requires chunks and the delegate does not support that - BOOL chunksSupported = [delegate respondsToSelector:@selector(httpLoaderShouldSupportChunks:)]; - if (chunksSupported) { - chunksSupported = [delegate httpLoaderShouldSupportChunks:self]; - } - if (!chunksSupported && copiedRequest.chunks) { - NSError *error = [NSError errorWithDomain:HTTPRequestErrorDomain - code:HTTPRequestErrorCode_ChunkedRequestWithoutChunkedDelegate - userInfo:nil]; - HTTPResponse *response = [[HTTPResponse alloc] initWithRequest:request response:nil]; - response.error = error; - [delegate httpLoader:self didReceiveErrorResponse:response]; - return nil; - } - - id cancellationToken = [[HTTPCancellationTokenImpl alloc] initWithDelegate:self cancelObject:copiedRequest]; - copiedRequest.cancellationToken = cancellationToken; - @synchronized(self.cancellationTokens) { - [self.cancellationTokens addObject:cancellationToken]; - } - - @synchronized(self.requests) { - [self.requests addObject:copiedRequest]; - } - - [self.requestOperationHandlerDelegate requestOperationHandler:self performRequest:copiedRequest]; - - return cancellationToken; -} - -- (void)cancelAllLoads { - NSArray *cancellationTokens = nil; - @synchronized(self.cancellationTokens) { - cancellationTokens = [self.cancellationTokens copy]; - [self.cancellationTokens removeAllObjects]; - } - [cancellationTokens makeObjectsPerformSelector:@selector(cancel)]; -} - -- (BOOL)isRequestExpected:(HTTPRequest *)request { - @synchronized(self.requests) { - for (HTTPRequest *expectedRequest in self.requests) { - if (request.uniqueIdentifier == expectedRequest.uniqueIdentifier) { - return YES; - } - } - } - return NO; -} - -- (NSArray *)currentRequests { - return [self.requests copy]; -} - -#pragma mark HTTPRequestOperationHandler - -@synthesize requestOperationHandlerDelegate = _requestOperationHandlerDelegate; - -- (void)successfulResponse:(HTTPResponse *)response { - if (![self isRequestExpected:response.request]) { - return; - } - - [self executeDelegateBlock:^{ - [self.delegate httpLoader:self didReceiveSuccessfulResponse:response]; - }]; - @synchronized(self.requests) { - [self.requests removeObject:response.request]; - } -} - -- (void)failedResponse:(HTTPResponse *)response { - if (![self isRequestExpected:response.request]) { - return; - } - - [self executeDelegateBlock:^{ - [self.delegate httpLoader:self didReceiveErrorResponse:response]; - }]; - @synchronized(self.requests) { - [self.requests removeObject:response.request]; - } -} - -- (void)cancelledRequest:(HTTPRequest *)request { - if (![self isRequestExpected:request]) { - return; - } - - if ([self.delegate respondsToSelector:@selector(httpLoader:didCancelRequest:)]) { - [self executeDelegateBlock:^{ - [self.delegate httpLoader:self didCancelRequest:request]; - }]; - } - @synchronized(self.requests) { - [self.requests removeObject:request]; - } -} - -- (void)receivedDataChunk:(NSData *)data forResponse:(HTTPResponse *)response { - if (![self isRequestExpected:response.request]) { - return; - } - - // Do not send a callback if the request doesn't support it - NSAssert(response.request.chunks, @"The loader is receiving a data chunk for a response that doesn't support data chunks"); - - BOOL didReceiveDataChunkSelectorExists = [self.delegate respondsToSelector:@selector(httpLoader:didReceiveDataChunk:forResponse:)]; - if (didReceiveDataChunkSelectorExists) { - [self executeDelegateBlock:^{ - [self.delegate httpLoader:self didReceiveDataChunk:data forResponse:response]; - }]; - } -} - -- (void)receivedInitialResponse:(HTTPResponse *)response { - if (![self isRequestExpected:response.request]) { - return; - } - - // Do not send a callback if the request doesn't support it - if (!response.request.chunks) { - return; - } - - if ([self.delegate respondsToSelector:@selector(httpLoader:didReceiveInitialResponse:)]) { - [self executeDelegateBlock:^{ - [self.delegate httpLoader:self didReceiveInitialResponse:response]; - }]; - } -} - -- (void)needsNewBodyStream:(void (^)(NSInputStream *))completionHandler forRequest:(HTTPRequest *)request { - if ([self.delegate respondsToSelector:@selector(httpLoader:needsNewBodyStream:forRequest:)]) { - [self executeDelegateBlock:^{ - [self.delegate httpLoader:self - needsNewBodyStream:completionHandler - forRequest:request]; - }]; - } - else { - completionHandler(request.bodyStream); - } -} - -#pragma mark HTTPCancellationTokenDelegate - -- (void)cancellationTokenDidCancel:(id)cancellationToken { - HTTPRequest *request = (HTTPRequest *)cancellationToken.objectToCancel; - [self.requestOperationHandlerDelegate requestOperationHandler:self cancelRequest:request]; - [self cancelledRequest:request]; -} - -- (void)cancellationTokenDidCancel:(id)cancellationToken producingResumeDataCompletion:(void (^)(NSData *_Nullable))completionHandler { - HTTPRequest *request = (HTTPRequest *)cancellationToken.objectToCancel; - [self.requestOperationHandlerDelegate requestOperationHandler:self cancelRequest:request producingResumeDataCompletion:completionHandler]; - [self cancelledRequest:request]; -} - -#pragma mark Private - -- (void)executeDelegateBlock:(dispatch_block_t)block { - if (self.delegateQueue == dispatch_get_main_queue() && [NSThread isMainThread]) { - block(); - } - else { - dispatch_async(self.delegateQueue, block); - } -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPLoaderAuthoriser.h b/DashControl/Sources/Services/Networking/HTTPLoaderAuthoriser.h deleted file mode 100755 index d939fd5..0000000 --- a/DashControl/Sources/Services/Networking/HTTPLoaderAuthoriser.h +++ /dev/null @@ -1,51 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@class HTTPRequest; - -@protocol HTTPLoaderAuthoriser; - -@protocol HTTPLoaderAuthoriserDelegate - -- (void)httpLoaderAuthoriser:(id)httpLoaderAuthoriser authorisedRequest:(HTTPRequest *)request; -- (void)httpLoaderAuthoriser:(id)httpLoaderAuthoriser didFailToAuthoriseRequest:(HTTPRequest *)request withError:(NSError *)error; - -@end - -@protocol HTTPLoaderAuthoriser - -@property (readonly, copy, nonatomic) NSString *identifier; -@property (nullable, weak, nonatomic) id delegate; - -- (BOOL)requestRequiresAuthorisation:(HTTPRequest *)request; -- (void)authoriseRequest:(HTTPRequest *)request; -- (void)requestFailedAuthorisation:(HTTPRequest *)request; -- (void)refresh; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPLoaderDelegate.h b/DashControl/Sources/Services/Networking/HTTPLoaderDelegate.h deleted file mode 100755 index 924a9e3..0000000 --- a/DashControl/Sources/Services/Networking/HTTPLoaderDelegate.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@class HTTPLoader; -@class HTTPResponse; -@class HTTPRequest; - -@protocol HTTPLoaderDelegate - -- (void)httpLoader:(HTTPLoader *)httpLoader didReceiveSuccessfulResponse:(HTTPResponse *)response; -- (void)httpLoader:(HTTPLoader *)httpLoader didReceiveErrorResponse:(HTTPResponse *)response; - -@optional - -- (void)httpLoader:(HTTPLoader *)httpLoader didCancelRequest:(HTTPRequest *)request; -- (BOOL)httpLoaderShouldSupportChunks:(HTTPLoader *)httpLoader; -- (void)httpLoader:(HTTPLoader *)httpLoader didReceiveDataChunk:(NSData *)data forResponse:(HTTPResponse *)response; -- (void)httpLoader:(HTTPLoader *)httpLoader didReceiveInitialResponse:(HTTPResponse *)response; -- (void)httpLoader:(HTTPLoader *)httpLoader needsNewBodyStream:(void (^)(NSInputStream *))completionHandler forRequest:(HTTPRequest *)request; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPLoaderFactory.h b/DashControl/Sources/Services/Networking/HTTPLoaderFactory.h deleted file mode 100644 index b542287..0000000 --- a/DashControl/Sources/Services/Networking/HTTPLoaderFactory.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@class HTTPLoader; -@protocol HTTPLoaderAuthoriser; - -@interface HTTPLoaderFactory : NSObject - -@property (assign, nonatomic, getter=isOffline) BOOL offline; -@property (nullable, readonly, copy, nonatomic) NSArray> *authorisers; - -- (HTTPLoader *)createHTTPLoader; - -- (instancetype)init NS_UNAVAILABLE; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPLoaderFactory.m b/DashControl/Sources/Services/Networking/HTTPLoaderFactory.m deleted file mode 100644 index ac2b0c1..0000000 --- a/DashControl/Sources/Services/Networking/HTTPLoaderFactory.m +++ /dev/null @@ -1,217 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import "HTTPLoaderFactory.h" - -#import "HTTPLoader+Private.h" -#import "HTTPLoaderFactory+Private.h" -#import "HTTPRequest+Private.h" -#import "HTTPResponse+Private.h" -#import "HTTPCancellationTokenImpl.h" -#import "HTTPLoaderAuthoriser.h" -#import "HTTPRequest.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPLoaderFactory () - -@property (strong, nonatomic) NSMapTable> *requestToRequestOperationHandler; -@property (strong, nonatomic) dispatch_queue_t requestTimeoutQueue; - -@end - -@implementation HTTPLoaderFactory - -- (instancetype)initWithRequestOperationHandlerDelegate:(nullable id)requestOperationHandlerDelegate - authorisers:(nullable NSArray> *)authorisers { - self = [super init]; - if (self) { - _requestOperationHandlerDelegate = requestOperationHandlerDelegate; - _authorisers = [authorisers copy]; - - _requestToRequestOperationHandler = [NSMapTable weakToWeakObjectsMapTable]; - _requestTimeoutQueue = dispatch_get_main_queue(); - - for (id authoriser in _authorisers) { - authoriser.delegate = self; - } - } - - return self; -} - -#pragma mark HTTPLoaderFactory - -- (HTTPLoader *)createHTTPLoader { - return [[HTTPLoader alloc] initWithRequestOperationHandlerDelegate:self]; -} - -#pragma mark HTTPRequestOperationHandler - -@synthesize requestOperationHandlerDelegate = _requestOperationHandlerDelegate; - -- (void)successfulResponse:(HTTPResponse *)response { - id requestOperationHandler = nil; - @synchronized(self.requestToRequestOperationHandler) { - requestOperationHandler = [self.requestToRequestOperationHandler objectForKey:response.request]; - [self.requestToRequestOperationHandler removeObjectForKey:response.request]; - } - [requestOperationHandler successfulResponse:response]; -} - -- (void)failedResponse:(HTTPResponse *)response { - // If we failed on authorisation and we have not retried the authorisation, retry it - if (response.error.code == HTTPResponseStatusCode_Unauthorised && !response.request.retriedAuthorisation) { - for (id authoriser in self.authorisers) { - if ([authoriser requestRequiresAuthorisation:response.request]) { - [authoriser requestFailedAuthorisation:response.request]; - } - } - response.request.retriedAuthorisation = YES; - if ([self shouldAuthoriseRequest:response.request]) { - [self authoriseRequest:response.request]; - return; - } - } - - id requestOperationHandler = nil; - @synchronized(self.requestToRequestOperationHandler) { - requestOperationHandler = [self.requestToRequestOperationHandler objectForKey:response.request]; - [self.requestToRequestOperationHandler removeObjectForKey:response.request]; - } - [requestOperationHandler failedResponse:response]; -} - -- (void)cancelledRequest:(HTTPRequest *)request { - id requestOperationHandler = nil; - @synchronized(self.requestToRequestOperationHandler) { - requestOperationHandler = [self.requestToRequestOperationHandler objectForKey:request]; - [self.requestToRequestOperationHandler removeObjectForKey:request]; - } - [requestOperationHandler cancelledRequest:request]; -} - -- (void)receivedDataChunk:(NSData *)data forResponse:(HTTPResponse *)response { - id requestOperationHandler = nil; - @synchronized(self.requestToRequestOperationHandler) { - requestOperationHandler = [self.requestToRequestOperationHandler objectForKey:response.request]; - } - [requestOperationHandler receivedDataChunk:data forResponse:response]; -} - -- (void)receivedInitialResponse:(HTTPResponse *)response { - id requestOperationHandler = nil; - @synchronized(self.requestToRequestOperationHandler) { - requestOperationHandler = [self.requestToRequestOperationHandler objectForKey:response.request]; - } - [requestOperationHandler receivedInitialResponse:response]; -} - -- (BOOL)shouldAuthoriseRequest:(HTTPRequest *)request { - for (id authoriser in self.authorisers) { - if ([authoriser requestRequiresAuthorisation:request]) { - return YES; - } - } - - return NO; -} - -- (void)authoriseRequest:(HTTPRequest *)request { - for (id authoriser in self.authorisers) { - if ([authoriser requestRequiresAuthorisation:request]) { - [authoriser authoriseRequest:request]; - return; - } - } -} - -- (void)needsNewBodyStream:(void (^)(NSInputStream *_Nonnull))completionHandler forRequest:(HTTPRequest *)request { - id requestOperationHandler = nil; - @synchronized(self.requestToRequestOperationHandler) { - requestOperationHandler = [self.requestToRequestOperationHandler objectForKey:request]; - } - [requestOperationHandler needsNewBodyStream:completionHandler forRequest:request]; -} - -#pragma mark HTTPRequestOperationHandlerDelegate - -- (void)requestOperationHandler:(id)requestOperationHandler performRequest:(HTTPRequest *)request { - if (self.offline) { - request.cachePolicy = NSURLRequestReturnCacheDataDontLoad; - } - - @synchronized(self.requestToRequestOperationHandler) { - [self.requestToRequestOperationHandler setObject:requestOperationHandler forKey:request]; - } - - // Add an absolute timeout for responses - if (request.timeout > 0.0) { - __weak __typeof(self) weakSelf = self; - __weak __typeof(request) weakRequest = request; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(request.timeout * NSEC_PER_SEC)), self.requestTimeoutQueue, ^{ - __strong __typeof(self) strongSelf = weakSelf; - __strong __typeof(request) strongRequest = weakRequest; - HTTPResponse *response = [[HTTPResponse alloc] initWithRequest:strongRequest response:nil]; - NSError *error = [NSError errorWithDomain:HTTPRequestErrorDomain - code:HTTPRequestErrorCode_Timeout - userInfo:nil]; - response.error = error; - [strongSelf failedResponse:response]; - }); - } - - [self.requestOperationHandlerDelegate requestOperationHandler:self performRequest:request]; -} - -- (void)requestOperationHandler:(id)requestOperationHandler cancelRequest:(HTTPRequest *)request { - [self.requestOperationHandlerDelegate requestOperationHandler:requestOperationHandler cancelRequest:request]; -} - -- (void)requestOperationHandler:(id)requestOperationHandler - cancelRequest:(HTTPRequest *)request - producingResumeDataCompletion:(nonnull void (^)(NSData *_Nullable))completionHandler { - [self.requestOperationHandlerDelegate requestOperationHandler:requestOperationHandler - cancelRequest:request - producingResumeDataCompletion:completionHandler]; -} - -#pragma mark HTTPLoaderAuthoriserDelegate - -- (void)httpLoaderAuthoriser:(id)httpLoaderAuthoriser authorisedRequest:(HTTPRequest *)request { - id requestOperationHandlerDelegate = self.requestOperationHandlerDelegate; - if ([requestOperationHandlerDelegate respondsToSelector:@selector(requestOperationHandler:authorisedRequest:)]) { - [requestOperationHandlerDelegate requestOperationHandler:self authorisedRequest:request]; - } -} - -- (void)httpLoaderAuthoriser:(id)httpLoaderAuthoriser didFailToAuthoriseRequest:(HTTPRequest *)request withError:(NSError *)error { - id requestOperationHandlerDelegate = self.requestOperationHandlerDelegate; - if ([requestOperationHandlerDelegate respondsToSelector:@selector(requestOperationHandler:failedToAuthoriseRequest:error:)]) { - [requestOperationHandlerDelegate requestOperationHandler:self failedToAuthoriseRequest:request error:error]; - } -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPRateLimiter.h b/DashControl/Sources/Services/Networking/HTTPRateLimiter.h deleted file mode 100644 index 71e6aff..0000000 --- a/DashControl/Sources/Services/Networking/HTTPRateLimiter.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPRateLimiter : NSObject - -@property (readonly, assign, nonatomic) NSTimeInterval window; -@property (readonly, assign, nonatomic) NSUInteger delayAfter; -@property (readonly, assign, nonatomic) NSTimeInterval delay; -@property (readonly, assign, nonatomic) NSUInteger maximum; - -- (instancetype)initWithWindow:(NSTimeInterval)window - delayAfter:(NSUInteger)delayAfter - delay:(NSTimeInterval)delay - maximum:(NSUInteger)maximum NS_DESIGNATED_INITIALIZER; -- (instancetype)init NS_UNAVAILABLE; - -- (NSTimeInterval)earliestTimeUntilRequestCanBeExecuted; -- (void)executedRequest; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPRateLimiter.m b/DashControl/Sources/Services/Networking/HTTPRateLimiter.m deleted file mode 100644 index cb69962..0000000 --- a/DashControl/Sources/Services/Networking/HTTPRateLimiter.m +++ /dev/null @@ -1,97 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import "HTTPRateLimiter.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPRateLimiter () - -@property (strong, nonatomic) NSMutableArray *executionTimes; - -@end - -@implementation HTTPRateLimiter - -- (instancetype)initWithWindow:(NSTimeInterval)window - delayAfter:(NSUInteger)delayAfter - delay:(NSTimeInterval)delay - maximum:(NSUInteger)maximum { - self = [super init]; - if (self) { - _window = window; - _delayAfter = delayAfter; - _delay = delay; - _maximum = maximum; - _executionTimes = [NSMutableArray array]; - } - - return self; -} - -- (NSTimeInterval)earliestTimeUntilRequestCanBeExecuted { - [self cleanupExecutionTimes]; - - NSArray *executionTimes = nil; - @synchronized(self.executionTimes) { - executionTimes = [self.executionTimes copy]; - } - - if (executionTimes.count < self.delayAfter) { - return 0.0; - } - - if (executionTimes.count >= self.maximum) { - return self.window; - } - - CFAbsoluteTime currentTime = CFAbsoluteTimeGetCurrent(); - CFAbsoluteTime lastExecution = executionTimes.lastObject.doubleValue; - CFAbsoluteTime deltaTime = currentTime - lastExecution; - - NSTimeInterval timeInterval = self.delay - deltaTime; - if (timeInterval < 0.0) { - timeInterval = 0.0; - } - - return timeInterval; -} - -- (void)executedRequest { - @synchronized(self.executionTimes) { - [self.executionTimes addObject:@(CFAbsoluteTimeGetCurrent())]; - } -} - -#pragma mark Private - -- (void)cleanupExecutionTimes { - @synchronized(self.executionTimes) { - CFTimeInterval currentTime = CFAbsoluteTimeGetCurrent(); - NSIndexSet *indexesToRemove = [self.executionTimes indexesOfObjectsPassingTest:^BOOL(NSNumber *_Nonnull obj, NSUInteger idx, BOOL *_Nonnull stop) { - CFTimeInterval ti = obj.doubleValue; - CFTimeInterval passed = ti + currentTime; - return (passed > self.window); - }]; - - [self.executionTimes removeObjectsAtIndexes:indexesToRemove]; - } -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPRateLimiterMap.h b/DashControl/Sources/Services/Networking/HTTPRateLimiterMap.h deleted file mode 100644 index c1a3da2..0000000 --- a/DashControl/Sources/Services/Networking/HTTPRateLimiterMap.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@class HTTPRateLimiter; - -@interface HTTPRateLimiterMap : NSObject - -- (void)setRateLimiter:(HTTPRateLimiter *)rateLimiter forURL:(NSURL *)URL; -- (nullable HTTPRateLimiter *)rateLimiterForURL:(NSURL *)URL; -- (void)removeRateLimiterForURL:(NSURL *)URL; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPRateLimiterMap.m b/DashControl/Sources/Services/Networking/HTTPRateLimiterMap.m deleted file mode 100644 index 3242e70..0000000 --- a/DashControl/Sources/Services/Networking/HTTPRateLimiterMap.m +++ /dev/null @@ -1,103 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import "HTTPRateLimiter.h" - -#import "HTTPRateLimiterMap.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPRateLimiterMap () - -@property (strong, nonatomic) NSMutableDictionary *rateLimitersByKey; - -@end - -@implementation HTTPRateLimiterMap - -- (instancetype)init { - self = [super init]; - if (self) { - _rateLimitersByKey = [NSMutableDictionary dictionary]; - } - - return self; -} - -- (void)setRateLimiter:(HTTPRateLimiter *)rateLimiter forURL:(NSURL *)URL { - NSParameterAssert(rateLimiter); - NSParameterAssert(URL); - - if (!rateLimiter || !URL) { - return; - } - - NSString *key = [self keyFromURL:URL]; - @synchronized(self.rateLimitersByKey) { - self.rateLimitersByKey[key] = rateLimiter; - } -} - -- (nullable HTTPRateLimiter *)rateLimiterForURL:(NSURL *)URL { - NSParameterAssert(URL); - - if (!URL) { - return nil; - } - - NSString *key = [self keyFromURL:URL]; - HTTPRateLimiter *rateLimiter = nil; - @synchronized(self.rateLimitersByKey) { - rateLimiter = self.rateLimitersByKey[key]; - } - - return rateLimiter; -} - -- (void)removeRateLimiterForURL:(NSURL *)URL { - NSParameterAssert(URL); - - if (!URL) { - return; - } - - NSString *key = [self keyFromURL:URL]; - @synchronized(self.rateLimitersByKey) { - [self.rateLimitersByKey removeObjectForKey:key]; - } -} - -#pragma mark Private - -- (NSString *)keyFromURL:(NSURL *)URL { - if (!URL) { - return @""; - } - - NSURLComponents *components = [NSURLComponents componentsWithURL:URL resolvingAgainstBaseURL:NO]; - NSURLComponents *keyComponents = [[NSURLComponents alloc] init]; - keyComponents.scheme = components.scheme; - keyComponents.host = components.host; - keyComponents.path = components.path.pathComponents.firstObject; - NSString *key = keyComponents.URL.absoluteString; - - return key; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPRequest.h b/DashControl/Sources/Services/Networking/HTTPRequest.h deleted file mode 100644 index aae2938..0000000 --- a/DashControl/Sources/Services/Networking/HTTPRequest.h +++ /dev/null @@ -1,97 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -typedef NS_ENUM(NSInteger, HTTPRequestMethod) { - HTTPRequestMethod_GET, - HTTPRequestMethod_POST, - HTTPRequestMethod_PUT, - HTTPRequestMethod_DELETE, - HTTPRequestMethod_UPDATE, - HTTPRequestMethod_HEAD, -}; - -typedef NS_ENUM(NSUInteger, HTTPContentType) { - HTTPContentType_JSON, - HTTPContentType_UrlEncoded, -}; - -typedef NS_ENUM(NSUInteger, HTTPRequestDownloadTaskPolicy) { - HTTPRequestDownloadTaskPolicyNone, - HTTPRequestDownloadTaskPolicyOnDemand, - HTTPRequestDownloadTaskPolicyAlways, -}; - -typedef NS_ENUM(NSInteger, HTTPRequestErrorCode) { - HTTPRequestErrorCode_Timeout, - HTTPRequestErrorCode_ChunkedRequestWithoutChunkedDelegate -}; - -extern NSString *const HTTPRequestErrorDomain; - -@interface HTTPRequest : NSObject - -@property (readonly, strong, nonatomic) NSURL *URL; -@property (readonly, assign, nonatomic) HTTPRequestMethod method; -@property (nullable, readonly, strong, nonatomic) NSData *body; -@property (nullable, readonly, strong, nonatomic) NSInputStream *bodyStream; -@property (readonly, copy, nonatomic) NSDictionary *headers; -@property (nullable, readonly, copy, nonatomic) NSString *sourceIdentifier; -@property (readonly, assign, nonatomic) int64_t uniqueIdentifier; - -@property (assign, nonatomic) HTTPRequestDownloadTaskPolicy downloadTaskPolicy; -@property (nullable, copy, nonatomic) NSString *downloadLocationPath; -@property (nullable, copy, nonatomic) NSData *resumeData; -@property (assign, nonatomic) BOOL chunks; -@property (assign, nonatomic) NSURLRequestCachePolicy cachePolicy; -@property (assign, nonatomic) NSJSONReadingOptions jsonReadingOptions; -@property (assign, nonatomic) BOOL skipNSURLCache; -@property (assign, nonatomic) NSTimeInterval timeout; -@property (assign, nonatomic) NSUInteger maximumRetryCount; -@property (copy, nonatomic) NSDictionary *userInfo; - -+ (instancetype)requestWithURL:(NSURL *)URL - method:(HTTPRequestMethod)method - parameters:(nullable NSDictionary *)parameters; -- (instancetype)initWithURL:(NSURL *)URL - method:(HTTPRequestMethod)method - contentType:(HTTPContentType)contentType - parameters:(nullable NSDictionary *)parameters - body:(nullable NSData *)body - sourceIdentifier:(nullable NSString *)sourceIdentifier; -- (instancetype)initWithURL:(NSURL *)URL - method:(HTTPRequestMethod)method - parameters:(nullable NSDictionary *)parameters - bodyStream:(nullable NSInputStream *)bodyStream - sourceIdentifier:(nullable NSString *)sourceIdentifier; -- (instancetype)init NS_UNAVAILABLE; - -- (void)addValue:(NSString *)value forHeader:(NSString *)header; -- (void)removeHeader:(NSString *)header; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPRequest.m b/DashControl/Sources/Services/Networking/HTTPRequest.m deleted file mode 100644 index a2f1728..0000000 --- a/DashControl/Sources/Services/Networking/HTTPRequest.m +++ /dev/null @@ -1,261 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import "HTTPRequest.h" - -#import "HTTPRequest+Private.h" -#import "HTTPURLRequestBuilder.h" - -NS_ASSUME_NONNULL_BEGIN - -NSString *const HTTPRequestErrorDomain = @"dash.httploader.request"; - -static NSString *NSStringFromHTTPRequestMethod(HTTPRequestMethod requestMethod) { - switch (requestMethod) { - case HTTPRequestMethod_DELETE: - return @"DELETE"; - case HTTPRequestMethod_GET: - return @"GET"; - case HTTPRequestMethod_POST: - return @"POST"; - case HTTPRequestMethod_PUT: - return @"PUT"; - case HTTPRequestMethod_HEAD: - return @"HEAD"; - case HTTPRequestMethod_UPDATE: - return @"UPDATE"; - } -} - -@interface HTTPRequest () - -@property (assign, nonatomic) int64_t uniqueIdentifier; - -@property (strong, nonatomic) NSMutableDictionary *mutableHeaders; -@property (assign, nonatomic) BOOL retriedAuthorisation; -@property (weak, nonatomic) id cancellationToken; - -@end - -@implementation HTTPRequest - -+ (instancetype)requestWithURL:(NSURL *)URL - method:(HTTPRequestMethod)method - parameters:(nullable NSDictionary *)parameters { - return [[[self class] alloc] initWithURL:URL - method:method - contentType:HTTPContentType_UrlEncoded - parameters:parameters - body:nil - sourceIdentifier:nil]; -} - -- (instancetype)initWithURL:(NSURL *)URL - method:(HTTPRequestMethod)method - contentType:(HTTPContentType)contentType - parameters:(nullable NSDictionary *)parameters - body:(nullable NSData *)body - sourceIdentifier:(nullable NSString *)sourceIdentifier { - NSAssert(URL != nil, @"URL must not be nil"); - - NSURL *requestURL = URL; - NSData *resultBody = nil; - NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; - - if (method == HTTPRequestMethod_GET || method == HTTPRequestMethod_HEAD || body) { - NSString *query = [HTTPURLRequestBuilder queryStringFromParameters:parameters]; - NSString *absoluteString = URL.absoluteString; - if (query && query.length > 0 && absoluteString.length > 0) { - requestURL = [NSURL URLWithString:[absoluteString stringByAppendingFormat:URL.query ? @"&%@" : @"?%@", query]]; - } - } - else if (parameters && contentType == HTTPContentType_JSON) { - resultBody = [HTTPURLRequestBuilder jsonDataFromParameters:parameters]; - mutableHeaders[@"Content-Type"] = @"application/json"; - mutableHeaders[@"Content-Length"] = @(resultBody.length).stringValue; - } - else if (parameters && contentType == HTTPContentType_UrlEncoded) { - NSString *query = [HTTPURLRequestBuilder queryStringFromParameters:parameters] ?: @""; // an empty string is a valid x-www-form-urlencoded payload - resultBody = [query dataUsingEncoding:NSUTF8StringEncoding]; - mutableHeaders[@"Content-Type"] = @"application/x-www-form-urlencoded; charset=utf-8"; - mutableHeaders[@"Content-Length"] = @(resultBody.length).stringValue; - } - - if (body) { - resultBody = body; - mutableHeaders[@"Content-Length"] = @(resultBody.length).stringValue; - } - - return [self initWithURL:requestURL - method:method - body:resultBody - bodyStream:nil - headers:mutableHeaders - sourceIdentifier:sourceIdentifier]; -} - -- (instancetype)initWithURL:(NSURL *)URL - method:(HTTPRequestMethod)method - parameters:(nullable NSDictionary *)parameters - bodyStream:(nullable NSInputStream *)bodyStream - sourceIdentifier:(nullable NSString *)sourceIdentifier { - NSAssert(URL != nil, @"URL must not be nil"); - - NSURL *requestURL = URL; - NSString *query = [HTTPURLRequestBuilder queryStringFromParameters:parameters]; - NSString *absoluteString = URL.absoluteString; - if (query && query.length > 0 && absoluteString.length > 0) { - requestURL = [NSURL URLWithString:[absoluteString stringByAppendingFormat:URL.query ? @"&%@" : @"?%@", query]]; - } - - return [self initWithURL:requestURL - method:method - body:nil - bodyStream:bodyStream - headers:nil - sourceIdentifier:sourceIdentifier]; -} - -- (instancetype)initWithURL:(NSURL *)URL - method:(HTTPRequestMethod)method - body:(nullable NSData *)body - bodyStream:(nullable NSInputStream *)bodyStream - headers:(nullable NSDictionary *)headers - sourceIdentifier:(nullable NSString *)sourceIdentifier { - static int64_t uniqueIdentifier = 0; - @synchronized(self.class) { - return [self initWithURL:URL - method:method - body:body - bodyStream:bodyStream - headers:headers - sourceIdentifier:sourceIdentifier - uniqueIdentifier:uniqueIdentifier]; - } -} - -- (instancetype)initWithURL:(NSURL *)URL - method:(HTTPRequestMethod)method - body:(nullable NSData *)body - bodyStream:(nullable NSInputStream *)bodyStream - headers:(nullable NSDictionary *)headers - sourceIdentifier:(nullable NSString *)sourceIdentifier - uniqueIdentifier:(int64_t)uniqueIdentifier { - self = [super init]; - if (self) { - _URL = URL; - _method = method; - _body = body; - _bodyStream = bodyStream; - _mutableHeaders = [headers mutableCopy] ?: [NSMutableDictionary dictionary]; - _sourceIdentifier = sourceIdentifier; - _uniqueIdentifier = uniqueIdentifier; - } - - return self; -} - -- (NSDictionary *)headers { - @synchronized(self.mutableHeaders) { - return [self.mutableHeaders copy]; - } -} - -- (void)addValue:(NSString *)value forHeader:(NSString *)header { - if (!header) { - return; - } - - @synchronized(self.mutableHeaders) { - if (!value && header) { - [self.mutableHeaders removeObjectForKey:header]; - return; - } - - self.mutableHeaders[header] = value; - } -} - -- (void)removeHeader:(NSString *)header { - @synchronized(self.mutableHeaders) { - [self.mutableHeaders removeObjectForKey:header]; - } -} - -#pragma mark Private - -- (NSURLRequest *)urlRequest { - NSString *const HTTPRequestContentLengthHeader = @"Content-Length"; - - NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:self.URL]; - - if (self.bodyStream != nil) { - urlRequest.HTTPBodyStream = self.bodyStream; - } - else if (self.body) { - [urlRequest addValue:@(self.body.length).stringValue forHTTPHeaderField:HTTPRequestContentLengthHeader]; - urlRequest.HTTPBody = self.body; - } - - NSDictionary *headers = self.headers; - for (NSString *key in headers) { - NSString *value = headers[key]; - [urlRequest addValue:value forHTTPHeaderField:key]; - } - - urlRequest.cachePolicy = self.cachePolicy; - urlRequest.HTTPMethod = NSStringFromHTTPRequestMethod(self.method); - - return urlRequest; -} - -- (NSString *)description { - return [NSString stringWithFormat:@"<%@: %p URL = \"%@\">", self.class, (void *)self, self.URL]; -} - -#pragma mark NSCopying - -- (id)copyWithZone:(nullable NSZone *)zone { - __typeof(self) copy = [[self.class alloc] initWithURL:self.URL - method:self.method - body:[self.body copy] - bodyStream:self.bodyStream - headers:self.headers - sourceIdentifier:self.sourceIdentifier - uniqueIdentifier:self.uniqueIdentifier]; - copy.downloadTaskPolicy = self.downloadTaskPolicy; - copy.downloadLocationPath = self.downloadLocationPath; - copy.chunks = self.chunks; - copy.cachePolicy = self.cachePolicy; - copy.jsonReadingOptions = self.jsonReadingOptions; - copy.skipNSURLCache = self.skipNSURLCache; - copy.timeout = self.timeout; - copy.maximumRetryCount = self.maximumRetryCount; - copy.userInfo = self.userInfo; - copy.cancellationToken = self.cancellationToken; - return copy; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPRequestOperation.h b/DashControl/Sources/Services/Networking/HTTPRequestOperation.h deleted file mode 100644 index d869be2..0000000 --- a/DashControl/Sources/Services/Networking/HTTPRequestOperation.h +++ /dev/null @@ -1,55 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@class HTTPRequest; -@class HTTPRateLimiter; -@class HTTPResponse; -@protocol HTTPRequestOperationHandler; - -@interface HTTPRequestOperation : NSObject - -@property (atomic, strong) NSURLSessionTask *task; -@property (strong, nonatomic) HTTPRequest *request; -@property (readonly, assign, nonatomic, getter=isCancelled) BOOL cancelled; - -- (instancetype)initWithTask:(NSURLSessionTask *)task - request:(HTTPRequest *)request - requestOperationHandler:(id)requestOperationHandler - rateLimiter:(nullable HTTPRateLimiter *)rateLimiter NS_DESIGNATED_INITIALIZER; - -- (NSURLSessionResponseDisposition)receiveResponse:(NSURLResponse *)response; -- (void)receiveData:(NSData *)data; -- (nullable HTTPResponse *)completeWithError:(nullable NSError *)error response:(nullable NSURLResponse *)response; -- (BOOL)mayRedirect; -- (void)start; -- (void)provideNewBodyStreamWithCompletion:(void (^)(NSInputStream *_Nonnull))completionHandler; - -- (instancetype)init NS_UNAVAILABLE; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPRequestOperation.m b/DashControl/Sources/Services/Networking/HTTPRequestOperation.m deleted file mode 100644 index 1155dfe..0000000 --- a/DashControl/Sources/Services/Networking/HTTPRequestOperation.m +++ /dev/null @@ -1,239 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import "HTTPRequestOperation.h" - -#import "HTTPRateLimiter.h" -#import "HTTPRequest.h" -#import "HTTPResponse.h" - -#import "HTTPResponse+Private.h" -#import "HTTPRequestOperationHandler.h" - -#import "SPTDataLoaderExponentialTimer.h" - -NS_ASSUME_NONNULL_BEGIN - -static NSUInteger const HTTPRequestOperationMaxRedirects = 10; - -@interface HTTPRequestOperation () - -@property (assign, nonatomic, getter=isCancelled) BOOL cancelled; - -@property (weak, nonatomic) id requestOperationHandler; -@property (nullable, strong, nonatomic) HTTPRateLimiter *rateLimiter; - -@property (strong, nonatomic) HTTPResponse *response; -@property (nullable, strong, nonatomic) NSMutableData *receivedData; -@property (assign, nonatomic) CFAbsoluteTime absoluteStartTime; -@property (assign, nonatomic) NSUInteger retryCount; -@property (assign, nonatomic) NSUInteger waitCount; -@property (assign, nonatomic) NSUInteger redirectCount; -@property (copy, nonatomic) dispatch_block_t executionBlock; -@property (strong, nonatomic) SPTDataLoaderExponentialTimer *exponentialTimer; - -@property (assign, nonatomic) BOOL calledSuccessfulResponse; -@property (assign, nonatomic) BOOL calledFailedResponse; -@property (assign, nonatomic) BOOL calledCancelledRequest; -@property (assign, nonatomic) BOOL started; -@property (strong, nonatomic) dispatch_queue_t retryQueue; - -@end - -@implementation HTTPRequestOperation - -- (instancetype)initWithTask:(NSURLSessionTask *)task - request:(HTTPRequest *)request - requestOperationHandler:(id)requestOperationHandler - rateLimiter:(nullable HTTPRateLimiter *)rateLimiter { - const NSTimeInterval HTTPRequestOperationMaximumTime = 60.0; - const NSTimeInterval HTTPRequestOperationInitialTime = 1.0; - - self = [super init]; - if (self) { - _task = task; - _request = request; - _requestOperationHandler = requestOperationHandler; - _rateLimiter = rateLimiter; - - __weak __typeof(self) weakSelf = self; - _executionBlock = ^{ - [weakSelf checkRateLimiterAndExecute]; - }; - _exponentialTimer = [SPTDataLoaderExponentialTimer exponentialTimerWithInitialTime:HTTPRequestOperationInitialTime - maxTime:HTTPRequestOperationMaximumTime]; - _retryQueue = dispatch_get_main_queue(); - } - - return self; -} - -- (void)dealloc { - [self completeIfInFlight]; -} - -- (void)receiveData:(NSData *)data { - [data enumerateByteRangesUsingBlock:^(const void *bytes, NSRange byteRange, BOOL *stop) { - - NSData *dataRange = [NSData dataWithBytes:bytes length:byteRange.length]; - - if (self.request.chunks) { - [self.requestOperationHandler receivedDataChunk:dataRange forResponse:self.response]; - } - else { - if (!self.receivedData) { - self.receivedData = [dataRange mutableCopy]; - } - else { - [self.receivedData appendData:dataRange]; - } - } - }]; -} - -- (nullable HTTPResponse *)completeWithError:(nullable NSError *)error response:(nullable NSURLResponse *)response { - id requestOperationHandler = self.requestOperationHandler; - if (!self.response) { - self.response = [[HTTPResponse alloc] initWithRequest:self.request response:response]; - } - else { - [self.response updateResponseIfNeeded:response]; - } - - if ([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled) { - [requestOperationHandler cancelledRequest:self.request]; - self.calledCancelledRequest = YES; - self.cancelled = YES; - return nil; - } - - [self.rateLimiter executedRequest]; - - if (error) { - self.response.error = error; - } - - self.response.body = self.receivedData; - self.response.requestTime = CFAbsoluteTimeGetCurrent() - self.absoluteStartTime; - - if (self.response.error) { - if ([self.response shouldRetry]) { - if (self.retryCount++ != self.request.maximumRetryCount) { - [self start]; - return nil; - } - } - [requestOperationHandler failedResponse:self.response]; - self.calledFailedResponse = YES; - return self.response; - } - - [requestOperationHandler successfulResponse:self.response]; - self.calledSuccessfulResponse = YES; - return self.response; -} - -- (NSURLSessionResponseDisposition)receiveResponse:(NSURLResponse *)response { - self.response = [[HTTPResponse alloc] initWithRequest:self.request response:response]; - [self.requestOperationHandler receivedInitialResponse:self.response]; - - if ([response isKindOfClass:[NSHTTPURLResponse class]]) { - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; - if (httpResponse.expectedContentLength > 0) { - self.receivedData = [NSMutableData dataWithCapacity:(NSUInteger)httpResponse.expectedContentLength]; - } - } - - if (!self.receivedData) { - self.receivedData = [NSMutableData data]; - } - - if (self.request.downloadTaskPolicy == HTTPRequestDownloadTaskPolicyOnDemand) { - return NSURLSessionResponseBecomeDownload; - } - else { - return NSURLSessionResponseAllow; - } -} - -- (BOOL)mayRedirect { - // Limit the amount of possible redirects - if (++self.redirectCount > HTTPRequestOperationMaxRedirects) { - return NO; - } - - return YES; -} - -- (void)start { - self.started = YES; - self.executionBlock(); -} - -- (void)provideNewBodyStreamWithCompletion:(void (^)(NSInputStream *_Nonnull))completionHandler { - [self.requestOperationHandler needsNewBodyStream:completionHandler forRequest:self.request]; -} - -- (void)checkRateLimiterAndExecute { - NSTimeInterval waitTime = [self.rateLimiter earliestTimeUntilRequestCanBeExecuted]; - if (waitTime == 0.0) { - [self checkRetryLimiterAndExecute]; - } - else { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, - (int64_t)(waitTime * NSEC_PER_SEC)), - self.retryQueue, - self.executionBlock); - } -} - -- (void)checkRetryLimiterAndExecute { - if (self.waitCount < self.retryCount) { - self.waitCount++; - if (self.waitCount == 1) { - self.executionBlock(); - } - else { - NSTimeInterval waitTime = self.exponentialTimer.timeIntervalAndCalculateNext; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, - (int64_t)(waitTime * NSEC_PER_SEC)), - self.retryQueue, - self.executionBlock); - } - return; - } - - self.absoluteStartTime = CFAbsoluteTimeGetCurrent(); - [self.task resume]; -} - -- (void)completeIfInFlight { - // Always call the last error the request completed with if retrying - if (self.started && !self.calledCancelledRequest && !self.calledFailedResponse && !self.calledSuccessfulResponse) { - [self completeWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:nil] response:nil]; - } -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPRequestOperationHandler.h b/DashControl/Sources/Services/Networking/HTTPRequestOperationHandler.h deleted file mode 100644 index 69ee761..0000000 --- a/DashControl/Sources/Services/Networking/HTTPRequestOperationHandler.h +++ /dev/null @@ -1,67 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@class HTTPRequest; -@class HTTPResponse; - -@protocol HTTPCancellationToken; -@protocol HTTPRequestOperationHandler; - -@protocol HTTPRequestOperationHandlerDelegate - -- (void)requestOperationHandler:(id)requestOperationHandler performRequest:(HTTPRequest *)request; -- (void)requestOperationHandler:(id)requestOperationHandler cancelRequest:(HTTPRequest *)request; -- (void)requestOperationHandler:(id)requestOperationHandler - cancelRequest:(HTTPRequest *)request - producingResumeDataCompletion:(void (^)(NSData *_Nullable resumeData))completionHandler; - -@optional - -- (void)requestOperationHandler:(id)requestOperationHandler authorisedRequest:(HTTPRequest *)request; -- (void)requestOperationHandler:(id)requestOperationHandler failedToAuthoriseRequest:(HTTPRequest *)request error:(NSError *)error; - -@end - -@protocol HTTPRequestOperationHandler - -@property (nullable, readonly, weak, nonatomic) id requestOperationHandlerDelegate; - -- (void)successfulResponse:(HTTPResponse *)response; -- (void)failedResponse:(HTTPResponse *)response; -- (void)cancelledRequest:(HTTPRequest *)request; -- (void)receivedDataChunk:(NSData *)data forResponse:(HTTPResponse *)response; -- (void)receivedInitialResponse:(HTTPResponse *)response; -- (void)needsNewBodyStream:(void (^)(NSInputStream *))completionHandler forRequest:(HTTPRequest *)request; - -@optional - -- (BOOL)shouldAuthoriseRequest:(HTTPRequest *)request; -- (void)authoriseRequest:(HTTPRequest *)request; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPResponse.h b/DashControl/Sources/Services/Networking/HTTPResponse.h deleted file mode 100644 index 6407c97..0000000 --- a/DashControl/Sources/Services/Networking/HTTPResponse.h +++ /dev/null @@ -1,97 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -/// http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html -typedef NS_ENUM(NSInteger, HTTPResponseStatusCode) { - HTTPResponseStatusCode_Invalid = 0, - // Informational - HTTPResponseStatusCode_Continue = 100, - HTTPResponseStatusCode_SwitchProtocols = 101, - // Successful - HTTPResponseStatusCode_OK = 200, - HTTPResponseStatusCode_Created = 201, - HTTPResponseStatusCode_Accepted = 202, - HTTPResponseStatusCode_NonAuthoritiveInformation = 203, - HTTPResponseStatusCode_NoContent = 204, - HTTPResponseStatusCode_ResetContent = 205, - HTTPResponseStatusCode_PartialContent = 206, - // Redirection - HTTPResponseStatusCode_MovedMultipleChoices = 300, - HTTPResponseStatusCode_MovedPermanently = 301, - HTTPResponseStatusCode_Found = 302, - HTTPResponseStatusCode_SeeOther = 303, - HTTPResponseStatusCode_NotModified = 304, - HTTPResponseStatusCode_UseProxy = 305, - HTTPResponseStatusCode_Unused = 306, - HTTPResponseStatusCode_TemporaryRedirect = 307, - // Client Error - HTTPResponseStatusCode_BadRequest = 400, - HTTPResponseStatusCode_Unauthorised = 401, - HTTPResponseStatusCode_PaymentRequired = 402, - HTTPResponseStatusCode_Forbidden = 403, - HTTPResponseStatusCode_NotFound = 404, - HTTPResponseStatusCode_MethodNotAllowed = 405, - HTTPResponseStatusCode_NotAcceptable = 406, - HTTPResponseStatusCode_ProxyAuthenticationRequired = 407, - HTTPResponseStatusCode_RequestTimeout = 408, - HTTPResponseStatusCode_Conflict = 409, - HTTPResponseStatusCode_Gone = 410, - HTTPResponseStatusCode_LengthRequired = 411, - HTTPResponseStatusCode_PreconditionFailed = 412, - HTTPResponseStatusCode_RequestEntityTooLarge = 413, - HTTPResponseStatusCode_RequestURITooLong = 414, - HTTPResponseStatusCode_UnsupportedMediaTypes = 415, - HTTPResponseStatusCode_RequestRangeUnsatisifiable = 416, - HTTPResponseStatusCode_ExpectationFail = 417, - // Server Error - HTTPResponseStatusCode_InternalServerError = 500, - HTTPResponseStatusCode_NotImplemented = 501, - HTTPResponseStatusCode_BadGateway = 502, - HTTPResponseStatusCode_ServiceUnavailable = 503, - HTTPResponseStatusCode_GatewayTimeout = 504, - HTTPResponseStatusCode_HTTPVersionNotSupported = 505 -}; - -@class HTTPRequest; - -extern NSString *const HTTPResponseErrorDomain; - -@interface HTTPResponse : NSObject - -@property (readonly, strong, nonatomic) HTTPRequest *request; -@property (nullable, readonly, strong, nonatomic) NSError *error; -@property (readonly, copy, nonatomic) NSDictionary *responseHeaders; -@property (nullable, readonly, strong, nonatomic) NSDate *retryAfter; -@property (nullable, readonly, strong, nonatomic) NSData *body; -@property (readonly, assign, nonatomic) NSTimeInterval requestTime; -@property (readonly, assign, nonatomic) HTTPResponseStatusCode statusCode; - -- (instancetype)init NS_UNAVAILABLE; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPResponse.m b/DashControl/Sources/Services/Networking/HTTPResponse.m deleted file mode 100644 index 20971db..0000000 --- a/DashControl/Sources/Services/Networking/HTTPResponse.m +++ /dev/null @@ -1,195 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import "HTTPResponse.h" - -#import "HTTPResponse+Private.h" - -NS_ASSUME_NONNULL_BEGIN - -NSString *const HTTPResponseErrorDomain = @"dash.httpresponse.error"; - -static NSString *const HTTPResponseHeaderRetryAfter = @"Retry-After"; - -@interface HTTPResponse () - -@property (nullable, strong, nonatomic) NSURLResponse *response; -@property (copy, nonatomic) NSDictionary *responseHeaders; -@property (strong, nonatomic) NSError *error; -@property (nullable, strong, nonatomic) NSDate *retryAfter; -@property (strong, nonatomic) NSData *body; -@property (assign, nonatomic) NSTimeInterval requestTime; -@property (assign, nonatomic) HTTPResponseStatusCode statusCode; - -@end - -@implementation HTTPResponse - -#pragma mark Private - -- (instancetype)initWithRequest:(HTTPRequest *)request response:(nullable NSURLResponse *)response { - self = [super init]; - if (self) { - _request = request; - [self updateResponseIfNeeded:response]; - } - - return self; -} - -- (void)updateResponseIfNeeded:(nullable NSURLResponse *)response { - if (self.response) { - return; - } - - self.response = response; - - if ([self.response isKindOfClass:[NSHTTPURLResponse class]]) { - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; - if (httpResponse.statusCode >= 300 || httpResponse.statusCode <= 101) { - self.error = [NSError errorWithDomain:HTTPResponseErrorDomain - code:httpResponse.statusCode - userInfo:nil]; - } - self.responseHeaders = httpResponse.allHeaderFields; - self.statusCode = httpResponse.statusCode; - } - - self.retryAfter = [self retryAfterForHeaders:self.responseHeaders]; -} - -- (BOOL)shouldRetry { - if ([self.error.domain isEqualToString:HTTPResponseErrorDomain]) { - switch (self.error.code) { - case HTTPResponseStatusCode_Invalid: - case HTTPResponseStatusCode_Continue: - case HTTPResponseStatusCode_SwitchProtocols: - case HTTPResponseStatusCode_OK: - case HTTPResponseStatusCode_Created: - case HTTPResponseStatusCode_Accepted: - case HTTPResponseStatusCode_NonAuthoritiveInformation: - case HTTPResponseStatusCode_NoContent: - case HTTPResponseStatusCode_ResetContent: - case HTTPResponseStatusCode_PartialContent: - case HTTPResponseStatusCode_MovedMultipleChoices: - case HTTPResponseStatusCode_MovedPermanently: - case HTTPResponseStatusCode_Found: - case HTTPResponseStatusCode_SeeOther: - case HTTPResponseStatusCode_NotModified: - case HTTPResponseStatusCode_UseProxy: - case HTTPResponseStatusCode_Unused: - case HTTPResponseStatusCode_TemporaryRedirect: - case HTTPResponseStatusCode_BadRequest: - case HTTPResponseStatusCode_Unauthorised: - case HTTPResponseStatusCode_PaymentRequired: - case HTTPResponseStatusCode_Forbidden: - case HTTPResponseStatusCode_MethodNotAllowed: - case HTTPResponseStatusCode_NotAcceptable: - case HTTPResponseStatusCode_ProxyAuthenticationRequired: - case HTTPResponseStatusCode_Conflict: - case HTTPResponseStatusCode_Gone: - case HTTPResponseStatusCode_LengthRequired: // We always include the content-length header - case HTTPResponseStatusCode_PreconditionFailed: - case HTTPResponseStatusCode_RequestEntityTooLarge: - case HTTPResponseStatusCode_RequestURITooLong: - case HTTPResponseStatusCode_RequestRangeUnsatisifiable: - case HTTPResponseStatusCode_ExpectationFail: - case HTTPResponseStatusCode_HTTPVersionNotSupported: - case HTTPResponseStatusCode_NotImplemented: - return NO; - case HTTPResponseStatusCode_NotFound: - case HTTPResponseStatusCode_RequestTimeout: - case HTTPResponseStatusCode_UnsupportedMediaTypes: - case HTTPResponseStatusCode_InternalServerError: - case HTTPResponseStatusCode_BadGateway: - case HTTPResponseStatusCode_ServiceUnavailable: - case HTTPResponseStatusCode_GatewayTimeout: - return YES; - } - } - - if ([self.error.domain isEqualToString:NSURLErrorDomain]) { - switch (self.error.code) { - case NSURLErrorCancelled: - case NSURLErrorUnknown: - case NSURLErrorBadURL: - case NSURLErrorUnsupportedURL: - case NSURLErrorZeroByteResource: - case NSURLErrorCannotDecodeRawData: - case NSURLErrorCannotDecodeContentData: - case NSURLErrorCannotParseResponse: - case NSURLErrorFileDoesNotExist: - case NSURLErrorNoPermissionsToReadFile: - case NSURLErrorDataLengthExceedsMaximum: - case NSURLErrorRedirectToNonExistentLocation: - case NSURLErrorBadServerResponse: - case NSURLErrorUserCancelledAuthentication: - case NSURLErrorUserAuthenticationRequired: - case NSURLErrorServerCertificateHasBadDate: - case NSURLErrorServerCertificateUntrusted: - case NSURLErrorServerCertificateHasUnknownRoot: - case NSURLErrorServerCertificateNotYetValid: - case NSURLErrorClientCertificateRejected: - case NSURLErrorClientCertificateRequired: - return NO; - case NSURLErrorTimedOut: - case NSURLErrorCannotFindHost: - case NSURLErrorCannotConnectToHost: - case NSURLErrorNetworkConnectionLost: - case NSURLErrorDNSLookupFailed: - case NSURLErrorHTTPTooManyRedirects: - case NSURLErrorResourceUnavailable: - case NSURLErrorNotConnectedToInternet: - case NSURLErrorSecureConnectionFailed: - case NSURLErrorCannotLoadFromNetwork: - return YES; - } - } - - return NO; -} - -- (nullable NSDate *)retryAfterForHeaders:(NSDictionary *)headers { - static NSDateFormatter *httpDateFormatter; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - httpDateFormatter = [[NSDateFormatter alloc] init]; - [httpDateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss zzz"]; - }); - - NSTimeInterval retryAfterSeconds = [headers[HTTPResponseHeaderRetryAfter] doubleValue]; - if (retryAfterSeconds != 0.0) { - return [NSDate dateWithTimeIntervalSinceNow:retryAfterSeconds]; - } - - NSString *retryAfterValue = headers[HTTPResponseHeaderRetryAfter]; - return [httpDateFormatter dateFromString:retryAfterValue]; -} - -- (NSString *)description { - return [NSString stringWithFormat:@"<%@: %p URL = \"%@\"; status-code = %ld; headers = %@>", self.class, (void *)self, self.response.URL, (long)self.statusCode, self.responseHeaders]; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPService.h b/DashControl/Sources/Services/Networking/HTTPService.h deleted file mode 100644 index 5cc3072..0000000 --- a/DashControl/Sources/Services/Networking/HTTPService.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@class HTTPLoaderFactory; -@class HTTPRateLimiterMap; -@protocol HTTPLoaderAuthoriser; - -@interface HTTPService : NSObject - -@property (assign, nonatomic, getter=areAllCertificatesAllowed) BOOL allCertificatesAllowed; -@property (readonly, strong, nonatomic) HTTPRateLimiterMap *rateLimiterMap; - -- (instancetype)initWithConfiguration:(NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; -- (instancetype)init NS_UNAVAILABLE; - -- (HTTPLoaderFactory *)createHTTPLoaderFactoryWithAuthorisers:(nullable NSArray> *)authorisers; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/HTTPService.m b/DashControl/Sources/Services/Networking/HTTPService.m deleted file mode 100644 index 15fb5f9..0000000 --- a/DashControl/Sources/Services/Networking/HTTPService.m +++ /dev/null @@ -1,344 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import "HTTPService.h" - -#import "HTTPLoaderFactory+Private.h" -#import "HTTPRequest+Private.h" -#import "HTTPResponse+Private.h" -#import "NSURLRequest+DCcURL.h" -#import "HTTPCancellationToken.h" -#import "HTTPRateLimiterMap.h" -#import "HTTPRequestOperation.h" -#import "HTTPRequestOperationHandler.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPService () - -@property (strong, nonatomic) NSURLSession *session; -@property (strong, nonatomic) NSOperationQueue *sessionQueue; -@property (strong, nonatomic) NSMutableArray *operations; - -@end - -@implementation HTTPService - -- (instancetype)initWithConfiguration:(NSURLSessionConfiguration *)configuration { - const NSUInteger HTTPServiceMaxConcurrentOperations = 32; - - self = [super init]; - if (self) { - _rateLimiterMap = [[HTTPRateLimiterMap alloc] init]; - _sessionQueue = [[NSOperationQueue alloc] init]; - _sessionQueue.maxConcurrentOperationCount = HTTPServiceMaxConcurrentOperations; - _sessionQueue.name = NSStringFromClass(self.class); - _session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:_sessionQueue]; - _operations = [[NSMutableArray alloc] init]; - } - - return self; -} - -- (void)dealloc { - [self cancelAllLoads]; -} - -- (HTTPLoaderFactory *)createHTTPLoaderFactoryWithAuthorisers:(nullable NSArray> *)authorisers { - return [[HTTPLoaderFactory alloc] initWithRequestOperationHandlerDelegate:self authorisers:authorisers]; -} - -#pragma mark HTTPRequestOperationHandlerDelegate - -- (void)requestOperationHandler:(id)requestOperationHandler performRequest:(HTTPRequest *)request { - if ([requestOperationHandler respondsToSelector:@selector(shouldAuthoriseRequest:)]) { - if ([requestOperationHandler shouldAuthoriseRequest:request]) { - if ([requestOperationHandler respondsToSelector:@selector(authoriseRequest:)]) { - [requestOperationHandler authoriseRequest:request]; - return; - } - } - } - - [self performRequest:request requestOperationHandler:requestOperationHandler]; -} - -- (void)requestOperationHandler:(id)requestOperationHandler cancelRequest:(HTTPRequest *)request { - NSArray *operations = nil; - @synchronized(self.operations) { - operations = [self.operations copy]; - } - for (HTTPRequestOperation *operation in operations) { - if ([operation.request isEqual:request]) { - [operation.task cancel]; - break; - } - } -} - -- (void)requestOperationHandler:(id)requestOperationHandler - cancelRequest:(HTTPRequest *)request - producingResumeDataCompletion:(void (^)(NSData *_Nullable resumeData))completionHandler { - NSArray *operations = nil; - @synchronized(self.operations) { - operations = [self.operations copy]; - } - for (HTTPRequestOperation *operation in operations) { - if ([operation.request isEqual:request]) { - NSURLSessionDownloadTask *downloadTask = (NSURLSessionDownloadTask *)operation.task; - NSParameterAssert([downloadTask isKindOfClass:NSURLSessionDownloadTask.class]); - if ([downloadTask isKindOfClass:NSURLSessionDownloadTask.class]) { - [downloadTask cancelByProducingResumeData:completionHandler]; - } - return; - } - } - - if (completionHandler) { - RunOnMainThread(^{ - completionHandler(nil); - }); - } -} - -- (void)requestOperationHandler:(id)requestOperationHandler authorisedRequest:(HTTPRequest *)request { - [self performRequest:request requestOperationHandler:requestOperationHandler]; -} - -- (void)requestOperationHandler:(id)requestOperationHandler failedToAuthoriseRequest:(HTTPRequest *)request error:(NSError *)error { - HTTPResponse *response = [[HTTPResponse alloc] initWithRequest:request response:nil]; - response.error = error; - [requestOperationHandler failedResponse:response]; -} - -#pragma mark NSURLSessionDataDelegate - -- (void)URLSession:(NSURLSession *)session - dataTask:(NSURLSessionDataTask *)dataTask - didReceiveResponse:(NSURLResponse *)response - completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler { - HTTPRequestOperation *operation = [self handlerForTask:dataTask]; - if (completionHandler) { - completionHandler([operation receiveResponse:response]); - } -} - -- (void)URLSession:(NSURLSession *)session - dataTask:(NSURLSessionDataTask *)dataTask - didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask { - HTTPRequestOperation *operation = [self handlerForTask:dataTask]; - operation.task = downloadTask; -} - -- (void)URLSession:(NSURLSession *)session - dataTask:(NSURLSessionDataTask *)dataTask - didReceiveData:(NSData *)data { - HTTPRequestOperation *operation = [self handlerForTask:dataTask]; - [operation receiveData:data]; -} - -- (void)URLSession:(NSURLSession *)session - dataTask:(NSURLSessionDataTask *)dataTask - willCacheResponse:(NSCachedURLResponse *)proposedResponse - completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler { - if (!completionHandler) { - return; - } - HTTPRequestOperation *operation = [self handlerForTask:dataTask]; - completionHandler(operation.request.skipNSURLCache ? nil : proposedResponse); -} - -- (void)URLSession:(NSURLSession *)session - task:(NSURLSessionTask *)task - didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge - completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *__nullable credential))completionHandler { - if (!completionHandler) { - return; - } - - NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; - NSURLCredential *credential = nil; - - if (self.areAllCertificatesAllowed) { - SecTrustRef trust = challenge.protectionSpace.serverTrust; - disposition = NSURLSessionAuthChallengeUseCredential; - credential = [NSURLCredential credentialForTrust:trust]; - } - else { - // No-op - // Use default handing - } - - completionHandler(disposition, credential); -} - -#pragma mark NSURLSessionTaskDelegate - -- (void)URLSession:(NSURLSession *)session - task:(NSURLSessionTask *)task - didCompleteWithError:(nullable NSError *)error { - HTTPRequestOperation *operation = [self handlerForTask:task]; - if (operation == nil) { - return; - } - NSData *resumeData = error.userInfo[NSURLSessionDownloadTaskResumeData]; - if (resumeData) { - operation.task = [self.session downloadTaskWithResumeData:resumeData]; - } - else if (operation.request.downloadTaskPolicy == HTTPRequestDownloadTaskPolicyAlways) { - operation.task = [self.session downloadTaskWithRequest:operation.request.urlRequest]; - } - else { - operation.task = [self.session dataTaskWithRequest:operation.request.urlRequest]; - } - HTTPResponse *response = [operation completeWithError:error response:task.response]; - if (response == nil && !operation.cancelled) { - return; - } - - @synchronized(self.operations) { - [self.operations removeObject:operation]; - } -} - -- (void)URLSession:(NSURLSession *)session - task:(NSURLSessionTask *)task - needNewBodyStream:(void (^)(NSInputStream *_Nullable))completionHandler { - HTTPRequestOperation *operation = [self handlerForTask:task]; - [operation provideNewBodyStreamWithCompletion:completionHandler]; -} - -#pragma mark NSURLSessionDownloadDelegate - -- (void)URLSession:(NSURLSession *)session - downloadTask:(NSURLSessionDownloadTask *)downloadTask - didFinishDownloadingToURL:(NSURL *)location { - if (!location.path || !location.lastPathComponent) { - [self URLSession:session task:downloadTask didCompleteWithError:nil]; - return; - } - NSFileManager *fileManager = [NSFileManager defaultManager]; - HTTPRequestOperation *operation = [self handlerForTask:downloadTask]; - - NSString *filePath = operation.request.downloadLocationPath; - if (!filePath) { - NSString *cachePath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject; - cachePath = [cachePath stringByAppendingPathComponent:@"httpservice.temporary"]; - [fileManager createDirectoryAtPath:cachePath - withIntermediateDirectories:YES - attributes:nil - error:nil]; - filePath = [cachePath stringByAppendingPathComponent:(NSString * _Nonnull)location.lastPathComponent]; - operation.request.downloadLocationPath = filePath; - } - - NSError *fileError; - if ([fileManager moveItemAtPath:(NSString * _Nonnull)location.path toPath:filePath error:&fileError]) { - if (operation.request.downloadTaskPolicy == HTTPRequestDownloadTaskPolicyAlways) { - [self URLSession:session task:downloadTask didCompleteWithError:nil]; - } - else { - [self.sessionQueue addOperationWithBlock:^{ - NSError *readError; - NSData *data = [NSData dataWithContentsOfFile:filePath options:NSDataReadingUncached error:&readError]; - - [fileManager removeItemAtPath:filePath error:nil]; - - if (!readError) { - [operation receiveData:data]; - } - - [self URLSession:session task:downloadTask didCompleteWithError:readError]; - }]; - } - } - else { - [self URLSession:session task:downloadTask didCompleteWithError:fileError]; - } -} - -#pragma mark Private - -- (nullable HTTPRequestOperation *)handlerForTask:(NSURLSessionTask *)task { - NSArray *operations = nil; - @synchronized(self.operations) { - operations = [self.operations copy]; - } - for (HTTPRequestOperation *operation in operations) { - if ([operation.task isEqual:task]) { - return operation; - } - } - return nil; -} - -- (void)performRequest:(HTTPRequest *)request requestOperationHandler:(id)requestOperationHandler { - if (request.cancellationToken.cancelled) { - return; - } - - if (request.URL.host == nil) { - return; - } - - NSURLRequest *urlRequest = request.urlRequest; -#ifdef DEBUG - __unused NSString *cURLSting = [urlRequest dc_cURL]; -#endif - HTTPRateLimiter *rateLimiter = [self.rateLimiterMap rateLimiterForURL:request.URL]; - NSURLSessionTask *task; - if (request.downloadTaskPolicy == HTTPRequestDownloadTaskPolicyAlways) { - if (request.resumeData) { - task = [self.session downloadTaskWithResumeData:request.resumeData]; - } - else { - task = [self.session downloadTaskWithRequest:urlRequest]; - } - } - else { - NSAssert(!request.resumeData, @"Inconsistent HTTPRequest configuration"); - task = [self.session dataTaskWithRequest:urlRequest]; - } - HTTPRequestOperation *operation = [[HTTPRequestOperation alloc] initWithTask:task - request:request - requestOperationHandler:requestOperationHandler - rateLimiter:rateLimiter]; - @synchronized(self.operations) { - [self.operations addObject:operation]; - } - [operation start]; -} - -- (void)cancelAllLoads { - NSArray *operations = nil; - @synchronized(self.operations) { - operations = [self.operations copy]; - } - for (HTTPRequestOperation *operation in operations) { - [operation.task cancel]; - } -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Networking.h b/DashControl/Sources/Services/Networking/Networking.h deleted file mode 100644 index da30087..0000000 --- a/DashControl/Sources/Services/Networking/Networking.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2018 Andrew Podkovyrin. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#ifndef Networking_h -#define Networking_h - -#import "HTTPCancellationToken.h" -#import "HTTPLoader.h" -#import "HTTPLoaderAuthoriser.h" -#import "HTTPLoaderDelegate.h" -#import "HTTPLoaderFactory.h" -#import "HTTPLoaderManager.h" -#import "HTTPLoaderOperation.h" -#import "HTTPRateLimiter.h" -#import "HTTPRateLimiterMap.h" -#import "HTTPRequest.h" -#import "HTTPResponse.h" -#import "HTTPService.h" - -#endif /* Networking_h */ diff --git a/DashControl/Sources/Services/Networking/Private/HTTPCancellationTokenImpl.h b/DashControl/Sources/Services/Networking/Private/HTTPCancellationTokenImpl.h deleted file mode 100755 index 91dbbb6..0000000 --- a/DashControl/Sources/Services/Networking/Private/HTTPCancellationTokenImpl.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import - -#import "HTTPCancellationToken.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPCancellationTokenImpl : NSObject - -- (instancetype)initWithDelegate:(id)delegate cancelObject:(nullable id)cancelObject NS_DESIGNATED_INITIALIZER; -- (instancetype)init NS_UNAVAILABLE; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Private/HTTPCancellationTokenImpl.m b/DashControl/Sources/Services/Networking/Private/HTTPCancellationTokenImpl.m deleted file mode 100644 index 54e2347..0000000 --- a/DashControl/Sources/Services/Networking/Private/HTTPCancellationTokenImpl.m +++ /dev/null @@ -1,74 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import "HTTPCancellationTokenImpl.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPCancellationTokenImpl () - -@property (assign, nonatomic, getter=isCancelled) BOOL cancelled; - -@end - -@implementation HTTPCancellationTokenImpl - -- (instancetype)initWithDelegate:(id)delegate cancelObject:(nullable id)cancelObject { - self = [super init]; - if (self) { - _delegate = delegate; - _objectToCancel = cancelObject; - } - - return self; -} - -#pragma mark HTTPCancellationToken - -@synthesize cancelled = _cancelled; -@synthesize delegate = _delegate; -@synthesize objectToCancel = _objectToCancel; - -- (void)cancel { - if (self.cancelled) { - return; - } - - [self.delegate cancellationTokenDidCancel:self]; - - self.cancelled = YES; -} - -- (void)cancelByProducingResumeData:(void (^)(NSData *_Nullable resumeData))completionHandler { - [self.delegate cancellationTokenDidCancel:self producingResumeDataCompletion:^(NSData *_Nullable resumeData) { - if (completionHandler) { - RunOnMainThread(^{ - completionHandler(resumeData); - }); - } - }]; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Private/HTTPLoader+Private.h b/DashControl/Sources/Services/Networking/Private/HTTPLoader+Private.h deleted file mode 100755 index c8e0cbb..0000000 --- a/DashControl/Sources/Services/Networking/Private/HTTPLoader+Private.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - - -#import "HTTPLoader.h" - -#import "HTTPRequestOperationHandler.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPLoader (Private) - -- (instancetype)initWithRequestOperationHandlerDelegate:(id)requestOperationHandlerDelegate; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Private/HTTPLoaderFactory+Private.h b/DashControl/Sources/Services/Networking/Private/HTTPLoaderFactory+Private.h deleted file mode 100644 index 0436c1c..0000000 --- a/DashControl/Sources/Services/Networking/Private/HTTPLoaderFactory+Private.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import "HTTPLoaderFactory.h" - -#import "HTTPRequestOperationHandler.h" - -NS_ASSUME_NONNULL_BEGIN - -@protocol HTTPRequestOperationHandlerDelegate; -@protocol HTTPLoaderAuthoriser; - -@interface HTTPLoaderFactory (Private) - -- (instancetype)initWithRequestOperationHandlerDelegate:(nullable id)requestOperationHandlerDelegate - authorisers:(nullable NSArray> *)authorisers; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Private/HTTPRequest+Private.h b/DashControl/Sources/Services/Networking/Private/HTTPRequest+Private.h deleted file mode 100755 index aa09971..0000000 --- a/DashControl/Sources/Services/Networking/Private/HTTPRequest+Private.h +++ /dev/null @@ -1,38 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import "HTTPRequest.h" - -NS_ASSUME_NONNULL_BEGIN - -@protocol HTTPCancellationToken; - -@interface HTTPRequest (Private) - -@property (readonly, strong, nonatomic) NSURLRequest *urlRequest; -@property (assign, nonatomic) BOOL retriedAuthorisation; -@property (weak, nonatomic) id cancellationToken; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Private/HTTPResponse+Private.h b/DashControl/Sources/Services/Networking/Private/HTTPResponse+Private.h deleted file mode 100644 index 0902b7b..0000000 --- a/DashControl/Sources/Services/Networking/Private/HTTPResponse+Private.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// Created by Andrew Podkovyrin -// -// Copyright (c) 2015-2018 Spotify AB. -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 -// -// http://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. -// - -#import "HTTPResponse.h" - -NS_ASSUME_NONNULL_BEGIN - -@class HTTPRequest; - -@interface HTTPResponse (Private) - -@property (nullable, strong, nonatomic) NSError *error; -@property (nullable, strong, nonatomic) NSData *body; -@property (assign, nonatomic) NSTimeInterval requestTime; - -- (instancetype)initWithRequest:(HTTPRequest *)request response:(nullable NSURLResponse *)response; - -- (void)updateResponseIfNeeded:(nullable NSURLResponse *)response; -- (BOOL)shouldRetry; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Private/HTTPURLRequestBuilder.h b/DashControl/Sources/Services/Networking/Private/HTTPURLRequestBuilder.h deleted file mode 100644 index f7114cd..0000000 --- a/DashControl/Sources/Services/Networking/Private/HTTPURLRequestBuilder.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2016. All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface HTTPURLRequestBuilder : NSObject - -+ (nullable NSData *)jsonDataFromParameters:(nullable NSDictionary *)parameters; -+ (NSString *)queryStringFromParameters:(nullable NSDictionary *)parameters; -+ (NSString *)percentEscapedStringFromString:(NSString *)string; - -- (instancetype)init NS_UNAVAILABLE; - -@end - -NS_ASSUME_NONNULL_END diff --git a/DashControl/Sources/Services/Networking/Private/HTTPURLRequestBuilder.m b/DashControl/Sources/Services/Networking/Private/HTTPURLRequestBuilder.m deleted file mode 100644 index 0806846..0000000 --- a/DashControl/Sources/Services/Networking/Private/HTTPURLRequestBuilder.m +++ /dev/null @@ -1,195 +0,0 @@ -// -// Created by Andrew Podkovyrin -// Copyright © 2016 All rights reserved. -// -// Licensed under the MIT License (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://opensource.org/licenses/MIT -// -// 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. -// - -#import "HTTPURLRequestBuilder.h" - -// Based on AFNetworking -// https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking/AFURLRequestSerialization.m - -extern NSString *PercentEscapedStringFromString(NSString *string); -extern NSArray *QueryStringPairsFromKeyAndValue(NSString *key, id value); -extern NSArray *QueryStringPairsFromDictionary(NSDictionary *dictionary); - -#pragma mark - Pair - -@interface MLWQueryStringPair : NSObject - -@property (strong, nonatomic) id field; -@property (strong, nonatomic) id value; - -- (instancetype)initWithField:(id)field value:(id)value; -- (NSString *)URLEncodedStringValue; - -@end - -@implementation MLWQueryStringPair - -- (instancetype)initWithField:(id)field value:(id)value { - self = [super init]; - if (self) { - self.field = field; - self.value = value; - } - - return self; -} - -- (NSString *)URLEncodedStringValue { - if (!self.value || [self.value isEqual:[NSNull null]]) { - return PercentEscapedStringFromString([self.field description]); - } - else { - return [NSString stringWithFormat:@"%@=%@", PercentEscapedStringFromString([self.field description]), PercentEscapedStringFromString([self.value description])]; - } -} - -@end - -#pragma mark - Builder - -@implementation HTTPURLRequestBuilder - -+ (nullable NSData *)jsonDataFromParameters:(nullable NSDictionary *)parameters { - if (!parameters) { - return nil; - } - - NSDictionary *_parameters = parameters; - - NSError *serializeError = nil; - NSData *result = [NSJSONSerialization dataWithJSONObject:_parameters - options:kNilOptions - error:&serializeError]; - NSAssert(result, serializeError.localizedDescription); - return result; -} - -+ (NSString *)queryStringFromParameters:(nullable NSDictionary *)parameters { - if (!parameters) { - return @""; - } - - NSDictionary *_parameters = parameters; - - NSMutableArray *mutablePairs = [NSMutableArray array]; - for (MLWQueryStringPair *pair in QueryStringPairsFromDictionary(_parameters)) { - [mutablePairs addObject:[pair URLEncodedStringValue]]; - } - - return [mutablePairs componentsJoinedByString:@"&"]; -} - -+ (NSString *)percentEscapedStringFromString:(NSString *)string { - return PercentEscapedStringFromString(string); -} - -@end - -#pragma mark - Helpers - -NSArray *QueryStringPairsFromDictionary(NSDictionary *dictionary) { - return QueryStringPairsFromKeyAndValue(nil, dictionary); -} - -NSArray *QueryStringPairsFromKeyAndValue(NSString *key, id value) { - NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; - - NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" - ascending:YES - selector:@selector(compare:)]; - - if ([value isKindOfClass:[NSDictionary class]]) { - NSDictionary *dictionary = value; - // Sort dictionary keys to ensure consistent ordering in query string, which - // is important when deserializing potentially ambiguous sequences, such as - // an array of dictionaries - for (id nestedKey in - [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { - id nestedValue = dictionary[nestedKey]; - if (nestedValue) { - NSCAssert(nestedValue != value, @"Infinite recursion"); - [mutableQueryStringComponents addObjectsFromArray: - QueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; - } - } - } - else if ([value isKindOfClass:[NSArray class]]) { - NSArray *array = value; - for (id nestedValue in array) { - NSCAssert(nestedValue != value, @"Infinite recursion"); - [mutableQueryStringComponents addObjectsFromArray:QueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; - } - } - else if ([value isKindOfClass:[NSSet class]]) { - NSSet *set = value; - for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { - NSCAssert(obj != value, @"Infinite recursion"); - [mutableQueryStringComponents addObjectsFromArray:QueryStringPairsFromKeyAndValue(key, obj)]; - } - } - else { - [mutableQueryStringComponents addObject:[[MLWQueryStringPair alloc] initWithField:key value:value]]; - } - - return mutableQueryStringComponents; -} - -/** - Returns a percent-escaped string following RFC 3986 for a query string key or - value. - RFC 3986 states that the following characters are "reserved" characters. - - General Delimiters: ":", "#", "[", "]", "@", "?", "/" - - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" - In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not - be escaped to allow - query strings to include a URL. Therefore, all "reserved" characters with the - exception of "?" and "/" - should be percent-escaped in the query string. - - parameter string: The string to be percent-escaped. - - returns: The percent-escaped string. - */ -NSString *PercentEscapedStringFromString(NSString *string) { - static NSString *const kAFCharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4 - static NSString *const kAFCharactersSubDelimitersToEncode = @"!$&'()*+,;="; - - NSMutableCharacterSet *allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy]; - [allowedCharacterSet removeCharactersInString:[kAFCharactersGeneralDelimitersToEncode stringByAppendingString:kAFCharactersSubDelimitersToEncode]]; - - // see https://github.com/AFNetworking/AFNetworking/pull/3028 - // return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; - - static NSUInteger const batchSize = 50; - - NSUInteger index = 0; - NSMutableString *escaped = @"".mutableCopy; - - while (index < string.length) { - NSUInteger length = MIN(string.length - index, batchSize); - NSRange range = NSMakeRange(index, length); - - // To avoid breaking up character sequences such as 👴🏻👮🏽 - range = [string rangeOfComposedCharacterSequencesForRange:range]; - - NSString *substring = [string substringWithRange:range]; - NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; - [escaped appendString:encoded]; - - index += range.length; - } - - return escaped; -} diff --git a/DashControl/Sources/Services/Networking/Private/SPTDataLoaderExponentialTimer.h b/DashControl/Sources/Services/Networking/Private/SPTDataLoaderExponentialTimer.h deleted file mode 100755 index 107684f..0000000 --- a/DashControl/Sources/Services/Networking/Private/SPTDataLoaderExponentialTimer.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2015-2018 Spotify AB. - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 - * - * http://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. - */ -#import - -#pragma mark - Default Jitter Values - -/// The default jitter value which should give very good results most of the time. -FOUNDATION_EXPORT const double SPTDataLoaderExponentialTimerDefaultJitter; - -#pragma mark - SPTDataLoaderExponentialTimer Interface - -/** - * Exponential timer with jitter for proper backoff handling in data transmissions. - */ -@interface SPTDataLoaderExponentialTimer : NSObject - -#pragma mark Creating an Exponential Timer Object - -/** - * Create a timer with an initial time and maximum limit. - * - * @param initialTime The initial time to start counting the delay from. - * @param maxTime Upper limit which shouldnt be exceeded when calculating a new delay value. - */ -+ (instancetype)exponentialTimerWithInitialTime:(NSTimeInterval)initialTime - maxTime:(NSTimeInterval)maxTime; - -/** - * Create timer with initial time and max limit and user defined jitter - * - * @warning The default jitter gives very good results. If you stil want to use your own jitter - * please perform verification of the delay values you get from the timer before putting the code - * into production. - * - * @param initialTime The initial time to start counting the delay from. - * @param maxTime Upper limit which shouldnt be exceeded when calculating a new delay value. - * @param jitter Jitter value for calculating the delay. - */ -+ (instancetype)exponentialTimerWithInitialTime:(NSTimeInterval)initialTime - maxTime:(NSTimeInterval)maxTime - jitter:(double)jitter; - -#pragma mark Accessing and Updating the Delay Value - -/** - * Returns the current delay value while also calculating the next one. - * - * @note This is the convenience method for `-timeInterval` and `-calculateNext` - * - * @return The current delay time interval. - */ -- (NSTimeInterval)timeIntervalAndCalculateNext; - -/** - * The current delay time interval. - */ -@property (nonatomic, assign, readonly) NSTimeInterval timeInterval; - -/** - * Calculate next delay time interval and return it. - * - * @return The time interval for the next delay. - */ -- (NSTimeInterval)calculateNext; - -/* - * Reset timer to initial state. After rset it can be reused. - */ -- (void)reset; - -@end diff --git a/DashControl/Sources/Services/Networking/Private/SPTDataLoaderExponentialTimer.m b/DashControl/Sources/Services/Networking/Private/SPTDataLoaderExponentialTimer.m deleted file mode 100644 index 6520c49..0000000 --- a/DashControl/Sources/Services/Networking/Private/SPTDataLoaderExponentialTimer.m +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2015-2018 Spotify AB. - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 - * - * http://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. - */ -#import "SPTDataLoaderExponentialTimer.h" - -#import -#import - -#pragma mark - Default Values - -static const double SPTDataLoaderExponentialTimerDefaultGrow = M_E; -const double SPTDataLoaderExponentialTimerDefaultJitter = 0.11304999836; - -#pragma mark - SPTDataLoaderExponentialTimer Private Interface - -@interface SPTDataLoaderExponentialTimer () - -@property (nonatomic, assign, readwrite) NSTimeInterval timeInterval; -@property (nonatomic, assign, readonly) NSTimeInterval maxTime; -@property (nonatomic, assign, readonly) NSTimeInterval initialTime; - -@property (nonatomic, assign, readonly) double jitter; -@property (nonatomic, assign, readonly) double growFactor; - -@end - -#pragma mark - SPTDataLoaderExponentialTimer Implementation - -@implementation SPTDataLoaderExponentialTimer - -#pragma mark Creating an Exponential Timer Object - -+ (instancetype)exponentialTimerWithInitialTime:(NSTimeInterval)initialTime - maxTime:(NSTimeInterval)maxTime { - return [self exponentialTimerWithInitialTime:initialTime maxTime:maxTime jitter:SPTDataLoaderExponentialTimerDefaultJitter]; -} - -+ (instancetype)exponentialTimerWithInitialTime:(NSTimeInterval)initialTime - maxTime:(NSTimeInterval)maxTime - jitter:(double)jitter { - return [[self alloc] initWithInitialTime:initialTime - maxTime:maxTime - growFactor:SPTDataLoaderExponentialTimerDefaultGrow - jitter:jitter]; -} - -- (instancetype)initWithInitialTime:(NSTimeInterval)initialTime - maxTime:(NSTimeInterval)maxTime - growFactor:(double)growFactor - jitter:(double)jitter { - self = [super init]; - if (self) { - _initialTime = initialTime; - _timeInterval = initialTime; - _maxTime = maxTime; - _growFactor = growFactor; - _jitter = jitter; - } - return self; -} - -#pragma mark Accessing and Updating the Delay Value - -- (void)reset { - self.timeInterval = self.initialTime; -} - -- (NSTimeInterval)calculateNext { - NSTimeInterval nextTime = self.timeInterval * self.growFactor; - - if (nextTime > self.maxTime) { - nextTime = self.maxTime; - } - - if (self.jitter < 0.0001) { - self.timeInterval = nextTime; - } - else { - const double sigma = self.jitter * nextTime; - self.timeInterval = [self.class normalWithMu:nextTime sigma:sigma]; - } - - if (self.timeInterval > self.maxTime) { - self.timeInterval = self.maxTime; - } - - return self.timeInterval; -} - -- (NSTimeInterval)timeIntervalAndCalculateNext { - const NSTimeInterval timeInterval = self.timeInterval; - [self calculateNext]; - - return timeInterval; -} - -#pragma mark Calculating Exponential Backoff - -#define EXPT_MODULO ((u_int32_t)RAND_MAX) -#define EXPT_MODULO_F64 ((double)(EXPT_MODULO)) -NS_INLINE double SPTExptRandom() { - // We need [0, 1) interval - return arc4random_uniform(EXPT_MODULO); -} - -+ (NSTimeInterval)normalWithMu:(double)mu sigma:(double)sigma { - /** - * Uses Kinderman and Monahan method. Reference: Kinderman, - * A.J. and Monahan, J.F., "Computer generation of random - * variables using the ratio of uniform deviates", ACM Trans - * Math Software, 3, (1977), pp257-260. - */ - - const int attempts = 20; - for (int i = 0; i < attempts; ++i) { - const double a = SPTExptRandom() / EXPT_MODULO_F64; - const double b = 1.0 - (SPTExptRandom() / EXPT_MODULO_F64); - const double c = 1.7155277699214135 * (a - 0.5) / b; - const double d = c * c / 4.0; - - if (d <= -1.0 * log(b)) { - return mu + c * sigma; - } - } - - return mu + 2.0 * sigma * (SPTExptRandom() / EXPT_MODULO_F64); -} - -@end diff --git a/DashControl/Sources/UI/Portfolio/Masternode/MasternodeViewModel.m b/DashControl/Sources/UI/Portfolio/Masternode/MasternodeViewModel.m index e8f10d0..eb7b12e 100644 --- a/DashControl/Sources/UI/Portfolio/Masternode/MasternodeViewModel.m +++ b/DashControl/Sources/UI/Portfolio/Masternode/MasternodeViewModel.m @@ -63,7 +63,7 @@ - (instancetype)initWithMasternode:(nullable DSSimplifiedMasternodeEntryEntity * _ipAddressKeyDetail.returnKeyType = UIReturnKeyNext; if (masternode) { char s[INET6_ADDRSTRLEN]; - uint32_t ipAddress = masternode.address; + uint32_t ipAddress = (uint32_t)masternode.address; _ipAddressKeyDetail.text = [NSString stringWithFormat:@"%s", inet_ntop(AF_INET, &ipAddress, s, sizeof(s))]; _ipAddressKeyDetail.userInteractionEnabled = NO; } @@ -110,7 +110,7 @@ - (instancetype)initWithMasternode:(nullable DSSimplifiedMasternodeEntryEntity * self.simplifiedMasternodeEntry = masternodes.firstObject; char s[INET6_ADDRSTRLEN]; - uint32_t ipAddress = self.simplifiedMasternodeEntry.address; + uint32_t ipAddress = (uint32_t)self.simplifiedMasternodeEntry.address; self.ipAddressKeyDetail.text = [NSString stringWithFormat:@"%s", inet_ntop(AF_INET, &ipAddress, s, sizeof(s))]; } }]; @@ -131,7 +131,7 @@ - (void)deleteCurrentWithCompletion:(void (^)(void))completion { NSManagedObjectContext * context = [DSSimplifiedMasternodeEntryEntity context]; [context performBlockAndWait:^{ - self.simplifiedMasternodeEntry.claimed = NO; + self.simplifiedMasternodeEntry.localMasternode = nil; //todo (review this) [DSSimplifiedMasternodeEntryEntity saveContext]; if (completion) { @@ -172,8 +172,8 @@ - (void)registerMasternodeCompletion:(void (^)(NSString *_Nullable errorMessage, } DSSimplifiedMasternodeEntry *masternode = [self.simplifiedMasternodeEntry simplifiedMasternodeEntry]; - DSKey *key = [DSKey keyWithPrivateKey:self.privateKeyDetail.text onChain:self.chain]; - if (!uint160_eq([key.publicKey hash160], masternode.keyIDVoting)) { + DSECDSAKey *key = [DSECDSAKey keyWithPrivateKey:self.privateKeyDetail.text onChain:self.chain]; + if (!uint160_eq([key.publicKeyData hash160], masternode.keyIDVoting)) { if (completion) { completion(NSLocalizedString(@"Mismatched Key. This private key is valid but does not correspond to this masternode.", nil), MasternodeType_PrivateKey); } @@ -181,7 +181,7 @@ - (void)registerMasternodeCompletion:(void (^)(NSString *_Nullable errorMessage, return; } - [self.chain registerVotingKey:self.privateKeyDetail.text.base58ToData forMasternodeEntry:masternode]; + //[self.chain registerVotingKey:self.privateKeyDetail.text.base58ToData forMasternodeEntry:masternode]; todo if (completion) { completion(nil, NSNotFound); diff --git a/DashControl/Sources/UI/Portfolio/PortfolioViewModel.m b/DashControl/Sources/UI/Portfolio/PortfolioViewModel.m index 0833897..b61ba1b 100644 --- a/DashControl/Sources/UI/Portfolio/PortfolioViewModel.m +++ b/DashControl/Sources/UI/Portfolio/PortfolioViewModel.m @@ -78,7 +78,7 @@ - (instancetype)init { NSPredicate *predicate = [NSCompoundPredicate andPredicateWithSubpredicates:@[ [NSPredicate predicateWithFormat:@"chain == %@", self.chain.chainEntity], - [NSPredicate predicateWithFormat:@"claimed == %@", @YES], + [NSPredicate predicateWithFormat:@"localMasternode != nil"], ]]; fetchRequest.predicate = predicate; diff --git a/DashControl/Sources/UI/Portfolio/Views/PortfolioHeaderViewModel.m b/DashControl/Sources/UI/Portfolio/Views/PortfolioHeaderViewModel.m index 6f0ccb5..7b1021a 100644 --- a/DashControl/Sources/UI/Portfolio/Views/PortfolioHeaderViewModel.m +++ b/DashControl/Sources/UI/Portfolio/Views/PortfolioHeaderViewModel.m @@ -23,7 +23,7 @@ #import "APIPortfolio.h" #import "DCFormattingUtils.h" #import "DCPersistenceStack.h" -#import "Networking.h" +#import "DSNetworking.h" #import "UITestingHelper.h" NS_ASSUME_NONNULL_BEGIN diff --git a/DashControl/Sources/UI/Portfolio/Views/PortfolioWalletAddressTableViewCellModel.m b/DashControl/Sources/UI/Portfolio/Views/PortfolioWalletAddressTableViewCellModel.m index 6775827..fc01542 100644 --- a/DashControl/Sources/UI/Portfolio/Views/PortfolioWalletAddressTableViewCellModel.m +++ b/DashControl/Sources/UI/Portfolio/Views/PortfolioWalletAddressTableViewCellModel.m @@ -23,7 +23,7 @@ #import "APIPortfolio.h" #import "DCFormattingUtils.h" #import "DCPersistenceStack.h" -#import "Networking.h" +#import "DSNetworking.h" #import "UITestingHelper.h" NS_ASSUME_NONNULL_BEGIN diff --git a/DashControl/Sources/Wallet/DCWalletAccount.m b/DashControl/Sources/Wallet/DCWalletAccount.m index 084f129..29c4891 100644 --- a/DashControl/Sources/Wallet/DCWalletAccount.m +++ b/DashControl/Sources/Wallet/DCWalletAccount.m @@ -24,7 +24,7 @@ @interface DCWalletAccount () @property (strong, nonatomic) DSChain *chain; -@property (strong, nonatomic) DSDerivationPath *derivationPath; +@property (strong, nonatomic) DSFundsDerivationPath *derivationPath; @property (assign, nonatomic) WalletAccountState state; @property (strong, nonatomic) NSData *publicKey; @property (strong, nonatomic) NSMutableArray *internalAddresses; @@ -98,8 +98,8 @@ - (NSArray *)addressesWithGapLimit:(NSUInteger)gapLimit internal:(BOOL)internal NSMutableSet *createdAddresses = [NSMutableSet set]; while (a.count < gapLimit) { // generate new addresses up to gapLimit - NSData *pubKey = [self.derivationPath generatePublicKeyAtIndex:n internal:internal]; - NSString *addr = [[DSKey keyWithPublicKey:pubKey] addressForChain:self.chain]; + NSData *pubKey = [self.derivationPath publicKeyDataAtIndex:n internal:internal]; + NSString *addr = [[DSECDSAKey keyWithPublicKey:pubKey] addressForChain:self.chain]; if (!addr) { DCDebugLog(self.class, @"error generating keys"); return @[]; diff --git a/Podfile.lock b/Podfile.lock index 7582bba..031cd84 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,22 +1,6 @@ PODS: - - AFNetworking (3.2.1): - - AFNetworking/NSURLSession (= 3.2.1) - - AFNetworking/Reachability (= 3.2.1) - - AFNetworking/Security (= 3.2.1) - - AFNetworking/Serialization (= 3.2.1) - - AFNetworking/UIKit (= 3.2.1) - - AFNetworking/NSURLSession (3.2.1): - - AFNetworking/Reachability - - AFNetworking/Security - - AFNetworking/Serialization - - AFNetworking/Reachability (3.2.1) - - AFNetworking/Security (3.2.1) - - AFNetworking/Serialization (3.2.1) - - AFNetworking/UIKit (3.2.1): - - AFNetworking/NSURLSession - bls-signatures-pod (0.2.9) - DashSync (0.1.0): - - AFNetworking (~> 3.0) - bls-signatures-pod (= 0.2.9) - secp256k1_dash (= 0.1.2) - DeluxeInjection (0.8.6): @@ -46,7 +30,6 @@ DEPENDENCIES: SPEC REPOS: https://github.com/cocoapods/specs.git: - - AFNetworking - bls-signatures-pod - DeluxeInjection - Godzippa @@ -64,9 +47,8 @@ EXTERNAL SOURCES: :path: "../DashSync/" SPEC CHECKSUMS: - AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057 bls-signatures-pod: 56adce76843f10f484ff996c33aee36cfd98ae5e - DashSync: e6a30009f9499549bce8043e443b86dc9333dced + DashSync: 421125885841a5c20e8a2409718067acf9921f14 DeluxeInjection: 03964b27f8aa5a787221907e1f82364ef7bafef7 Godzippa: b423a467a9e4b4cb43bb4f3adb989d312795eb88 KVO-MVVM: 4df3afd1f7ebcb69735458b85db59c4271ada7c6 @@ -80,4 +62,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: aed60bb0d69db0a0c58511219052e28fda2ce52e -COCOAPODS: 1.5.3 +COCOAPODS: 1.6.1