Revision: 25124 http://sourceforge.net/p/bibdesk/svn/25124 Author: hofman Date: 2020-12-02 17:32:35 +0000 (Wed, 02 Dec 2020) Log Message: ----------- Use NSURLSessionAuthChallenge enum
Modified Paths: -------------- trunk/bibdesk/BDSKAuthenticationController.h trunk/bibdesk/BDSKAuthenticationController.m trunk/bibdesk/BDSKAuthenticationHandler.h trunk/bibdesk/BDSKAuthenticationHandler.m trunk/bibdesk/BDSKDownloader.h trunk/bibdesk/BDSKDownloader.m trunk/bibdesk/BDSKSoapBinding.m Modified: trunk/bibdesk/BDSKAuthenticationController.h =================================================================== --- trunk/bibdesk/BDSKAuthenticationController.h 2020-12-02 17:21:24 UTC (rev 25123) +++ trunk/bibdesk/BDSKAuthenticationController.h 2020-12-02 17:32:35 UTC (rev 25124) @@ -57,7 +57,7 @@ @property (nonatomic, assign) IBOutlet NSTextField *userField; @property (nonatomic, assign) IBOutlet NSButton *rememberButton; -- (void)runAuthentication:(NSURLAuthenticationChallenge *)challenge window:(NSWindow *)window completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler; +- (void)runAuthentication:(NSURLAuthenticationChallenge *)challenge window:(NSWindow *)window completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler; @end Modified: trunk/bibdesk/BDSKAuthenticationController.m =================================================================== --- trunk/bibdesk/BDSKAuthenticationController.m 2020-12-02 17:21:24 UTC (rev 25123) +++ trunk/bibdesk/BDSKAuthenticationController.m 2020-12-02 17:32:35 UTC (rev 25124) @@ -134,7 +134,7 @@ return [NSURLCredential credentialWithUser:[userField stringValue] ?: @"" password:[passwordField stringValue] ?: @"" persistence:([rememberButton state] == NSOnState) ? NSURLCredentialPersistencePermanent : NSURLCredentialPersistenceForSession]; } -- (void)runAuthentication:(NSURLAuthenticationChallenge *)challenge window:(NSWindow *)window completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { +- (void)runAuthentication:(NSURLAuthenticationChallenge *)challenge window:(NSWindow *)window completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { [self setUpForChallenge:challenge]; if (window) { @@ -141,17 +141,17 @@ usingSheet = YES; [self beginSheetModalForWindow:window completionHandler:^(NSInteger result){ if (result == NSOKButton) - completionHandler(BDSKDownloaderAuthChallengeUseCredential, [self credential]); + completionHandler(NSURLSessionAuthChallengeUseCredential, [self credential]); else - completionHandler(BDSKDownloaderAuthChallengePerformDefaultHandling, nil); + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); }]; } else { usingSheet = NO; [self retain]; if ([NSApp runModalForWindow:[self window]] == NSOKButton) - completionHandler(BDSKDownloaderAuthChallengeUseCredential, [self credential]); + completionHandler(NSURLSessionAuthChallengeUseCredential, [self credential]); else - completionHandler(BDSKDownloaderAuthChallengePerformDefaultHandling, nil); + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); } } Modified: trunk/bibdesk/BDSKAuthenticationHandler.h =================================================================== --- trunk/bibdesk/BDSKAuthenticationHandler.h 2020-12-02 17:21:24 UTC (rev 25123) +++ trunk/bibdesk/BDSKAuthenticationHandler.h 2020-12-02 17:32:35 UTC (rev 25124) @@ -47,6 +47,6 @@ + (id)sharedHandler; -- (void)startAuthentication:(NSURLAuthenticationChallenge *)challenge window:(NSWindow *)window completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler; +- (void)startAuthentication:(NSURLAuthenticationChallenge *)challenge window:(NSWindow *)window completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler; @end Modified: trunk/bibdesk/BDSKAuthenticationHandler.m =================================================================== --- trunk/bibdesk/BDSKAuthenticationHandler.m 2020-12-02 17:21:24 UTC (rev 25123) +++ trunk/bibdesk/BDSKAuthenticationHandler.m 2020-12-02 17:32:35 UTC (rev 25124) @@ -68,7 +68,7 @@ [super dealloc]; } -- (void)enqueueChallenge:(NSURLAuthenticationChallenge *)challenge forWindow:(NSWindow *)window completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { +- (void)enqueueChallenge:(NSURLAuthenticationChallenge *)challenge forWindow:(NSWindow *)window completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { id key = window ?: (id)[NSNull null]; NSMutableArray *queue = [queues objectForKey:key]; if (queue == nil) { @@ -91,12 +91,12 @@ [queues removeObjectForKey:key]; NSURLAuthenticationChallenge *challenge = [challengeAndHandler objectForKey:CHALLENGE_KEY]; - void (^completionHandler)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential *credential) = [challengeAndHandler objectForKey:COMPLETIONHANDLER_KEY]; + void (^completionHandler)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential) = [challengeAndHandler objectForKey:COMPLETIONHANDLER_KEY]; NSURLCredential *latestCredential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]]; if ([latestCredential hasPassword]) - completionHandler(BDSKDownloaderAuthChallengeUseCredential, latestCredential); + completionHandler(NSURLSessionAuthChallengeUseCredential, latestCredential); else [self startAuthentication:challenge window:window completionHandler:completionHandler]; @@ -103,7 +103,7 @@ [challengeAndHandler release]; } -- (void)startAuthentication:(NSURLAuthenticationChallenge *)challenge window:(NSWindow *)window completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { +- (void)startAuthentication:(NSURLAuthenticationChallenge *)challenge window:(NSWindow *)window completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { if ([controllers objectForKey:window] != nil) { [self enqueueChallenge:challenge forWindow:window completionHandler:completionHandler]; @@ -111,7 +111,7 @@ } if ([window attachedSheet] != nil) { - completionHandler(BDSKDownloaderAuthChallengePerformDefaultHandling, nil); + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); return; } @@ -119,7 +119,7 @@ id key = window ?: (id)[NSNull null]; [controllers setObject:controller forKey:key]; - [controller runAuthentication:challenge window:window completionHandler:^(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential *credential){ + [controller runAuthentication:challenge window:window completionHandler:^(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential){ [controllers removeObjectForKey:key]; completionHandler(disposition, credential); [self performSelector:@selector(tryNextChallengeForWindow:) withObject:window afterDelay:0.0]; Modified: trunk/bibdesk/BDSKDownloader.h =================================================================== --- trunk/bibdesk/BDSKDownloader.h 2020-12-02 17:21:24 UTC (rev 25123) +++ trunk/bibdesk/BDSKDownloader.h 2020-12-02 17:32:35 UTC (rev 25124) @@ -41,13 +41,6 @@ @class BDSKDownload; @protocol BDSKDownloaderDelegate; -typedef NS_ENUM(NSInteger, BDSKDownloaderAuthChallengeDisposition) { - BDSKDownloaderAuthChallengeUseCredential = 0, - BDSKDownloaderAuthChallengePerformDefaultHandling = 1, - BDSKDownloaderAuthChallengeCancelAuthenticationChallenge = 2, - BDSKDownloaderAuthChallengeRejectProtectionSpace = 3, -}; - @interface BDSKDownloader : NSObject <NSURLSessionDelegate> { NSMapTable *downloads; NSURLSession *session; @@ -99,7 +92,7 @@ - (void)downloader:(BDSKDownloader *)downloader download:(BDSKDownload *)download didReceiveExpectedContentLength:(int64_t)expectedContentLength; - (void)downloader:(BDSKDownloader *)downloader download:(BDSKDownload *)download didReceiveDataOfLength:(uint64_t)length; -- (void)downloader:(BDSKDownloader *)downloader download:(BDSKDownload *)download didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler; +- (void)downloader:(BDSKDownloader *)downloader download:(BDSKDownload *)download didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler; - (NSWindow *)downloader:(BDSKDownloader *)downloader downloadWindowForAuthenticationSheet:(BDSKDownload *)download; // only for file downloads Modified: trunk/bibdesk/BDSKDownloader.m =================================================================== --- trunk/bibdesk/BDSKDownloader.m 2020-12-02 17:21:24 UTC (rev 25123) +++ trunk/bibdesk/BDSKDownloader.m 2020-12-02 17:32:35 UTC (rev 25124) @@ -163,7 +163,7 @@ } } -- (void)_download:(BDSKDownload *)download didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { +- (void)_download:(BDSKDownload *)download didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition 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:completionHandler]; @@ -252,7 +252,7 @@ - (void)URLSession:(NSURLSession *)aSession task:(NSURLSessionTask *)task didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { BDSKDownload *download = [[[self downloadForTask:task] retain] autorelease]; - [self _download:download didReceiveChallenge:challenge completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler]; + [self _download:download didReceiveChallenge:challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler]; } - (void)URLSession:(NSURLSession *)aSession task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error { Modified: trunk/bibdesk/BDSKSoapBinding.m =================================================================== --- trunk/bibdesk/BDSKSoapBinding.m 2020-12-02 17:21:24 UTC (rev 25123) +++ trunk/bibdesk/BDSKSoapBinding.m 2020-12-02 17:32:35 UTC (rev 25124) @@ -219,7 +219,7 @@ [self.download cancel]; } -- (void)downloader:(BDSKDownloader *)downloader download:(BDSKDownload *)aDownload didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(BDSKDownloaderAuthChallengeDisposition, NSURLCredential *))completionHandler +- (void)downloader:(BDSKDownloader *)downloader download:(BDSKDownload *)aDownload didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler { if ([challenge previousFailureCount] == 0 && self.binding.authUsername && self.binding.authPassword) { NSURLCredential *newCredential; @@ -226,7 +226,7 @@ newCredential=[NSURLCredential credentialWithUser:self.binding.authUsername password:self.binding.authPassword persistence:NSURLCredentialPersistenceForSession]; - completionHandler(BDSKDownloaderAuthChallengeUseCredential, newCredential); + completionHandler(NSURLSessionAuthChallengeUseCredential, newCredential); } else { NSWindow *window = nil; if ([delegate respondsToSelector:@selector(operationWindowForAuthenticationSheet:)]){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit