Revision: 28198
http://sourceforge.net/p/bibdesk/svn/28198
Author: hofman
Date: 2023-03-29 16:34:32 +0000 (Wed, 29 Mar 2023)
Log Message:
-----------
no need for the soap binding to run the operation, run the operation directly
from the caller
Modified Paths:
--------------
trunk/bibdesk/BDSKISIGroupServer.m
trunk/bibdesk/BDSKSoapBinding.h
trunk/bibdesk/BDSKSoapBinding.m
Modified: trunk/bibdesk/BDSKISIGroupServer.m
===================================================================
--- trunk/bibdesk/BDSKISIGroupServer.m 2023-03-29 09:28:32 UTC (rev 28197)
+++ trunk/bibdesk/BDSKISIGroupServer.m 2023-03-29 16:34:32 UTC (rev 28198)
@@ -284,7 +284,8 @@
[operation cancel];
[operation release];
- operation = [[binding
performAsynchronousOperationWithParameters:authRequest delegate:self] retain];
+ operation = [[BDSKSoapBindingOperation alloc] initWithBinding:binding
delegate:self parameters:authRequest];
+ [operation start];
}
}
@@ -336,7 +337,8 @@
[operation cancel];
[operation release];
- operation = [[binding
performAsynchronousOperationWithParameters:request delegate:self] retain];
+ operation = [[BDSKSoapBindingOperation alloc]
initWithBinding:binding delegate:self parameters:request];
+ [operation start];
}
}
}
@@ -347,7 +349,9 @@
WOKMWSAuthenticateService *binding = [WOKMWSAuthenticateService
soapBinding];
WOKMWSAuthenticateService_closeSession *closeSessionRequest =
[[[WOKMWSAuthenticateService_closeSession alloc] init] autorelease];
[binding addCookie:sessionCookie];
- [binding
performSynchronousOperationWithParameters:closeSessionRequest];
+ BDSKSoapBindingOperation *closeOperation = [[[BDSKSoapBindingOperation
alloc] initWithBinding:binding delegate:nil parameters:closeSessionRequest]
autorelease];
+ [closeOperation start];
+ [closeOperation waitUntilExit];
}
@catch (id exception) {
NSLog(@"Exception \"%@\" raised in object %@", exception, self);
Modified: trunk/bibdesk/BDSKSoapBinding.h
===================================================================
--- trunk/bibdesk/BDSKSoapBinding.h 2023-03-29 09:28:32 UTC (rev 28197)
+++ trunk/bibdesk/BDSKSoapBinding.h 2023-03-29 16:34:32 UTC (rev 28198)
@@ -12,13 +12,12 @@
- (NSWindow *)operationWindowForAuthenticationSheet:(BDSKSoapBindingOperation
*)anOperation;
@end
-@interface BDSKSoapBinding : NSObject <BDSKSoapBindingOperationDelegate> {
+@interface BDSKSoapBinding : NSObject {
NSURL *address;
NSString *namespaceURI;
NSTimeInterval defaultTimeout;
NSMutableArray *cookies;
BOOL logXMLInOut;
- BOOL synchronousOperationComplete;
NSString *authUsername;
NSString *authPassword;
}
@@ -36,10 +35,6 @@
- (NSString *)serializedEnvelopeUsingHeaderElements:(NSDictionary
*)headerElements bodyElements:(NSDictionary *)bodyElements;
- (NSURLRequest *)requestUsingBody:(NSString *)body soapAction:(NSString
*)soapAction;
- (void)addCookie:(NSHTTPCookie *)toAdd;
-- (BDSKSoapBindingResponse
*)performSynchronousOperation:(BDSKSoapBindingOperation *)operation;
-- (void)performAsynchronousOperation:(BDSKSoapBindingOperation *)operation
delegate:(id<BDSKSoapBindingOperationDelegate>)delegate;
-- (BDSKSoapBindingResponse
*)performSynchronousOperationWithParameters:(BDSKSoapBindingRequest
*)parameters;
-- (BDSKSoapBindingOperation
*)performAsynchronousOperationWithParameters:(BDSKSoapBindingRequest
*)parameters delegate:(id<BDSKSoapBindingOperationDelegate>)delegate;
@end
@interface BDSKSoapBindingOperation : NSObject {
@@ -50,6 +45,8 @@
BDSKSoapBindingResponse *response;
id<BDSKSoapBindingOperationDelegate> delegate;
BDSKDownload *download;
+ BOOL complete;
+
}
@property (nonatomic, retain) BDSKSoapBinding *binding;
@property (nonatomic, retain) NSDictionary *bodyElements;
@@ -59,8 +56,9 @@
@property (nonatomic, assign) id<BDSKSoapBindingOperationDelegate> delegate;
@property (nonatomic, retain) BDSKDownload *download;
- (id)initWithBinding:(BDSKSoapBinding *)aBinding
delegate:(id<BDSKSoapBindingOperationDelegate>)aDelegate soapAction:(NSString
*)aSoapAction bodyElements:(NSDictionary *)aBodyElements
responseClasses:(NSDictionary *)aResponseClasses;
-- (id)initWithBinding:(BDSKSoapBinding *)aBinding
delegate:(id<BDSKSoapBindingOperationDelegate>)aDelegate
bodyElements:(NSDictionary *)aBodyElements responseClasses:(NSDictionary
*)aResponseClasses;
+- (id)initWithBinding:(BDSKSoapBinding *)aBinding
delegate:(id<BDSKSoapBindingOperationDelegate>)aDelegate
parameters:(BDSKSoapBindingRequest *)parameters;
- (void)start;
+- (void)waitUntilExit;
- (void)cancel;
@end
Modified: trunk/bibdesk/BDSKSoapBinding.m
===================================================================
--- trunk/bibdesk/BDSKSoapBinding.m 2023-03-29 09:28:32 UTC (rev 28197)
+++ trunk/bibdesk/BDSKSoapBinding.m 2023-03-29 16:34:32 UTC (rev 28198)
@@ -32,7 +32,6 @@
cookies = nil;
defaultTimeout = 10;//seconds
logXMLInOut = NO;
- synchronousOperationComplete = NO;
}
return self;
@@ -53,42 +52,6 @@
[cookies addObject:toAdd];
}
}
-- (BDSKSoapBindingResponse
*)performSynchronousOperation:(BDSKSoapBindingOperation *)operation
-{
- synchronousOperationComplete = NO;
- [operation setDelegate:self];
- [operation start];
-
- // Now wait for response
- NSRunLoop *theRL = [NSRunLoop currentRunLoop];
-
- while (!synchronousOperationComplete && [theRL
runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
- return operation.response;
-}
-- (void)performAsynchronousOperation:(BDSKSoapBindingOperation *)operation
delegate:(id<BDSKSoapBindingOperationDelegate>)delegate
-{
- [operation setDelegate:delegate];
- [operation start];
-}
-- (BDSKSoapBindingResponse
*)performSynchronousOperationWithParameters:(BDSKSoapBindingRequest *)parameters
-{
- NSDictionary *bodyElements = [NSDictionary
dictionaryWithObjectsAndKeys:parameters, [parameters elementName], nil];
- NSDictionary *responseClasses = [parameters responseClasses];
- BDSKSoapBindingOperation *operation = [[[BDSKSoapBindingOperation alloc]
initWithBinding:self delegate:self bodyElements:bodyElements
responseClasses:responseClasses] autorelease];
- return [self performSynchronousOperation:operation];
-}
-- (BDSKSoapBindingOperation
*)performAsynchronousOperationWithParameters:(BDSKSoapBindingRequest
*)parameters delegate:(id<BDSKSoapBindingOperationDelegate>)delegate
-{
- NSDictionary *bodyElements = [NSDictionary
dictionaryWithObjectsAndKeys:parameters, [parameters elementName], nil];
- NSDictionary *responseClasses = [parameters responseClasses];
- BDSKSoapBindingOperation *operation = [[[BDSKSoapBindingOperation alloc]
initWithBinding:self delegate:delegate bodyElements:bodyElements
responseClasses:responseClasses] autorelease];
- [self performAsynchronousOperation:operation delegate:delegate];
- return operation;
-}
-- (void)operation:(BDSKSoapBindingOperation *)operation
completedWithResponse:(BDSKSoapBindingResponse *)response
-{
- synchronousOperationComplete = YES;
-}
- (NSString *)serializedEnvelopeUsingHeaderElements:(NSDictionary
*)headerElements bodyElements:(NSDictionary *)bodyElements
{
NSXMLElement *root = [NSXMLElement elementWithName:@"soap:Envelope"];
@@ -194,18 +157,22 @@
response = nil;
self.delegate = aDelegate;
self.download = nil;
+ complete = NO;
}
return self;
}
-- (id)initWithBinding:(BDSKSoapBinding *)aBinding
delegate:(id<BDSKSoapBindingOperationDelegate>)aDelegate
bodyElements:(NSDictionary *)aBodyElements responseClasses:(NSDictionary
*)aResponseClasses
+- (id)initWithBinding:(BDSKSoapBinding *)aBinding
delegate:(id<BDSKSoapBindingOperationDelegate>)aDelegate
parameters:(BDSKSoapBindingRequest *)parameters
{
- return [self initWithBinding:aBinding delegate:aDelegate soapAction:@""
bodyElements:aBodyElements responseClasses:aResponseClasses];
+ NSDictionary *aBodyElements = [NSDictionary
dictionaryWithObjectsAndKeys:parameters, [parameters elementName], nil];
+ NSDictionary *aResponseClasses = [parameters responseClasses];
+ return [self initWithBinding:aBinding delegate:aDelegate soapAction:@""
bodyElements:aBodyElements responseClasses:aResponseClasses];
}
- (void)start
{
[response autorelease];
response = [BDSKSoapBindingResponse new];
+ complete = NO;
NSMutableDictionary *headerElements = [NSMutableDictionary dictionary];
@@ -215,6 +182,11 @@
self.download = [[BDSKDownloader sharedDownloader]
startDataDownloadWithRequest:request delegate:self];
}
+- (void)waitUntilExit
+{
+ NSRunLoop *theRL = [NSRunLoop currentRunLoop];
+ while (!complete && [theRL runMode:NSDefaultRunLoopMode beforeDate:[NSDate
distantFuture]]);
+}
- (void)cancel
{
[self.download cancel];
@@ -280,6 +252,7 @@
// ignore explict cancellation of the connection or the
authentication
// we call ourselves with a more detailed error in that case, and
we should not call this twice
response.error = error;
+ complete = YES;
[delegate operation:self completedWithResponse:response];
}
return;
@@ -333,7 +306,7 @@
[doc release];
}
-
+ complete = YES;
[delegate operation:self completedWithResponse:response];
}
}
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