Revision: 23981
http://sourceforge.net/p/bibdesk/svn/23981
Author: hofman
Date: 2019-07-09 18:03:46 +0000 (Tue, 09 Jul 2019)
Log Message:
-----------
implement authentication handler in superclass of downloader
Modified Paths:
--------------
trunk/bibdesk/BDSKDownloader.h
trunk/bibdesk/BDSKDownloader.m
trunk/bibdesk/BDSKDownloaderDeprecated.m
trunk/bibdesk/BDSKDownloaderSession.m
Modified: trunk/bibdesk/BDSKDownloader.h
===================================================================
--- trunk/bibdesk/BDSKDownloader.h 2019-07-09 17:57:15 UTC (rev 23980)
+++ trunk/bibdesk/BDSKDownloader.h 2019-07-09 18:03:46 UTC (rev 23981)
@@ -41,6 +41,13 @@
@class BDSKDownload;
@protocol BDSKDownloaderDelegate;
+typedef NS_ENUM(NSInteger, BDSKDownloaderAuthChallengeDisposition) {
+ BDSKDownloaderAuthChallengeUseCredential = 0,
+ BDSKDownloaderAuthChallengePerformDefaultHandling = 1,
+ BDSKDownloaderAuthChallengeCancelAuthenticationChallenge = 2,
+ BDSKDownloaderAuthChallengeRejectProtectionSpace = 3,
+};
+
@interface BDSKDownloader : NSObject {
NSMapTable *downloads;
}
@@ -68,6 +75,8 @@
- (void)cleanupDownload:(BDSKDownload *)download;
+- (void)download:(BDSKDownload *)download
didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition disposition,
NSURLCredential *credential))completionHandler;
+
@end
#pragma mark -
@@ -90,15 +99,6 @@
#pragma mark -
-typedef NS_ENUM(NSInteger, BDSKDownloaderAuthChallengeDisposition) {
- BDSKDownloaderAuthChallengeUseCredential = 0,
- BDSKDownloaderAuthChallengePerformDefaultHandling = 1,
- BDSKDownloaderAuthChallengeCancelAuthenticationChallenge = 2,
- BDSKDownloaderAuthChallengeRejectProtectionSpace = 3,
-};
-
-#pragma mark -
-
@protocol BDSKDownloaderDelegate <NSObject>
@optional
Modified: trunk/bibdesk/BDSKDownloader.m
===================================================================
--- trunk/bibdesk/BDSKDownloader.m 2019-07-09 17:57:15 UTC (rev 23980)
+++ trunk/bibdesk/BDSKDownloader.m 2019-07-09 18:03:46 UTC (rev 23981)
@@ -39,6 +39,7 @@
#import "BDSKDownloader.h"
#import "BDSKDownloaderDeprecated.h"
#import "BDSKDownloaderSession.h"
+#import "BDSKAuthenticationHandler.h"
@implementation BDSKDownloader
@@ -105,6 +106,19 @@
[downloads removeObjectForKey:task];
}
+- (void)download:(BDSKDownload *)download
didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition disposition,
NSURLCredential *credential))completionHandler {
+ id<BDSKDownloaderDelegate> delegate = [download delegate];
+ if ([delegate
respondsToSelector:@selector(downloader:download:didReceiveChallenge:completionHandler:)])
{
+ [delegate downloader:self download:download
didReceiveChallenge:challenge completionHandler:(void
(^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential
*credential))completionHandler];
+ } else {
+ NSWindow *window = nil;
+ if ([delegate
respondsToSelector:@selector(downloader:downloadWindowForAuthenticationSheet:)])
{
+ window = [delegate downloader:self
downloadWindowForAuthenticationSheet:download];
+ }
+ [[BDSKAuthenticationHandler sharedHandler]
startAuthentication:challenge window:window completionHandler:(void
(^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential
*credential))completionHandler];
+ }
+}
+
@end
#pragma mark -
Modified: trunk/bibdesk/BDSKDownloaderDeprecated.m
===================================================================
--- trunk/bibdesk/BDSKDownloaderDeprecated.m 2019-07-09 17:57:15 UTC (rev
23980)
+++ trunk/bibdesk/BDSKDownloaderDeprecated.m 2019-07-09 18:03:46 UTC (rev
23981)
@@ -38,7 +38,6 @@
#import "BDSKDownloaderDeprecated.h"
#import "NSFileManager_BDSKExtensions.h"
-#import "BDSKAuthenticationHandler.h"
@interface BDSKDownloadDeprecated : BDSKDownload {
NSURLResponse *response;
@@ -80,7 +79,7 @@
BDSKDownload *download = [[[self downloadForTask:task] retain]
autorelease];
id<BDSKDownloaderDelegate> delegate = [download delegate];
- void (^completionHandler)(BDSKDownloaderAuthChallengeDisposition,
NSURLCredential *) = ^(BDSKDownloaderAuthChallengeDisposition disposition,
NSURLCredential *credential){
+ [self download:download didReceiveChallenge:challenge
completionHandler:^(BDSKDownloaderAuthChallengeDisposition disposition,
NSURLCredential *credential){
id <NSURLAuthenticationChallengeSender> sender = [challenge sender];
switch (disposition) {
case BDSKDownloaderAuthChallengeUseCredential:
@@ -96,17 +95,7 @@
[sender
rejectProtectionSpaceAndContinueWithChallenge:challenge];
break;
}
- };
-
- if ([delegate
respondsToSelector:@selector(downloader:download:didReceiveChallenge:completionHandler:)])
{
- [delegate downloader:self download:download
didReceiveChallenge:challenge completionHandler:completionHandler];
- } else {
- NSWindow *window = nil;
- if ([delegate
respondsToSelector:@selector(downloader:downloadWindowForAuthenticationSheet:)])
{
- window = [delegate downloader:self
downloadWindowForAuthenticationSheet:download];
- }
- [[BDSKAuthenticationHandler sharedHandler]
startAuthentication:challenge window:window
completionHandler:completionHandler];
- }
+ }];
}
- (void)download:(NSURLDownload *)task
decideDestinationWithSuggestedFilename:(NSString *)suggestedFileName {
Modified: trunk/bibdesk/BDSKDownloaderSession.m
===================================================================
--- trunk/bibdesk/BDSKDownloaderSession.m 2019-07-09 17:57:15 UTC (rev
23980)
+++ trunk/bibdesk/BDSKDownloaderSession.m 2019-07-09 18:03:46 UTC (rev
23981)
@@ -39,7 +39,6 @@
#import "BDSKDownloaderSession.h"
#import "NSFileManager_BDSKExtensions.h"
#import "NSURLSession_BDSKForwardDeclarations.h"
-#import "BDSKAuthenticationHandler.h"
@interface BDSKDownloadSession : BDSKDownload {
@@ -204,16 +203,7 @@
- (void)URLSession:(NSURLSession *)aSession task:(NSURLSessionTask *)task
didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition,
NSURLCredential * _Nullable credential))completionHandler {
BDSKDownload *download = [[[self downloadForTask:task] retain]
autorelease];
- id<BDSKDownloaderDelegate> delegate = [download delegate];
- if ([delegate
respondsToSelector:@selector(downloader:download:didReceiveChallenge:completionHandler:)])
{
- [delegate downloader:self download:download
didReceiveChallenge:challenge completionHandler:(void
(^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential
*credential))completionHandler];
- } else {
- NSWindow *window = nil;
- if ([delegate
respondsToSelector:@selector(downloader:downloadWindowForAuthenticationSheet:)])
{
- window = [delegate downloader:self
downloadWindowForAuthenticationSheet:download];
- }
- [[BDSKAuthenticationHandler sharedHandler]
startAuthentication:challenge window:window completionHandler:(void
(^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential
*credential))completionHandler];
- }
+ [self download:download didReceiveChallenge:challenge
completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition disposition,
NSURLCredential *credential))completionHandler];
}
- (void)URLSession:(NSURLSession *)aSession task:(NSURLSessionTask *)task
didCompleteWithError:(NSError *)error {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit