2000-07-04 11:05:46 +00:00
|
|
|
|
/* Interface for GNU Objective-C version of NSConnection
|
|
|
|
|
Copyright (C) 1997,2000 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
Original by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
|
|
|
|
Version for OPENSTEP by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
|
Created: August 1997, updated June 2000
|
|
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2000-07-04 11:05:46 +00:00
|
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
2000-07-04 11:05:46 +00:00
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2000-07-04 11:05:46 +00:00
|
|
|
|
License along with this library; if not, write to the Free
|
2006-10-31 07:05:46 +00:00
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02111 USA.
|
2000-07-04 11:05:46 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __NSConnection_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
|
#define __NSConnection_h_GNUSTEP_BASE_INCLUDE
|
2006-10-31 07:05:46 +00:00
|
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
2000-07-04 11:05:46 +00:00
|
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
|
#import <Foundation/NSObject.h>
|
|
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
|
#import <Foundation/NSTimer.h>
|
|
|
|
|
#import <Foundation/NSRunLoop.h>
|
|
|
|
|
#import <Foundation/NSMapTable.h>
|
2000-07-04 11:05:46 +00:00
|
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2000-07-04 11:05:46 +00:00
|
|
|
|
@class NSDistantObject;
|
|
|
|
|
@class NSPort;
|
|
|
|
|
@class NSPortNameServer;
|
|
|
|
|
@class NSData;
|
2000-12-08 19:06:00 +00:00
|
|
|
|
@class NSInvocation;
|
2000-07-04 11:05:46 +00:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Keys for the NSDictionary returned by [NSConnection -statistics]
|
|
|
|
|
*/
|
|
|
|
|
/* These in OPENSTEP 4.2 */
|
2004-07-29 15:30:47 +00:00
|
|
|
|
/**
|
|
|
|
|
* Key for dictionary returned by [NSConnection-statistics]: number of
|
|
|
|
|
* messages replied to so far by the remote connection.
|
|
|
|
|
*/
|
2004-09-19 23:19:53 +00:00
|
|
|
|
GS_EXPORT NSString* const NSConnectionRepliesReceived;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Key for dictionary returned by [NSConnection-statistics]: number of
|
|
|
|
|
* messages sent so far to the remote connection.
|
|
|
|
|
*/
|
2004-09-19 23:19:53 +00:00
|
|
|
|
GS_EXPORT NSString* const NSConnectionRepliesSent;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Key for dictionary returned by [NSConnection-statistics]: number of
|
|
|
|
|
* messages received so far from the remote connection.
|
|
|
|
|
*/
|
2004-09-19 23:19:53 +00:00
|
|
|
|
GS_EXPORT NSString* const NSConnectionRequestsReceived;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Key for dictionary returned by [NSConnection-statistics]: number of
|
|
|
|
|
* messages sent so far to the remote connection.
|
|
|
|
|
*/
|
2004-09-19 23:19:53 +00:00
|
|
|
|
GS_EXPORT NSString* const NSConnectionRequestsSent;
|
2000-07-04 11:05:46 +00:00
|
|
|
|
/* These Are GNUstep extras */
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GNUstep-specific key for dictionary returned by [NSConnection-statistics]:
|
|
|
|
|
* number of local objects currently in use remotely.
|
|
|
|
|
*/
|
2004-09-19 23:19:53 +00:00
|
|
|
|
GS_EXPORT NSString* const NSConnectionLocalCount; /* Objects sent out */
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GNUstep-specific key for dictionary returned by [NSConnection-statistics]:
|
|
|
|
|
* number of remote objects currently in use.
|
|
|
|
|
*/
|
2004-09-19 23:19:53 +00:00
|
|
|
|
GS_EXPORT NSString* const NSConnectionProxyCount; /* Objects received */
|
2000-07-04 11:05:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* NSConnection class interface.
|
|
|
|
|
*
|
|
|
|
|
* A few methods are in the specification but not yet implemented.
|
|
|
|
|
*/
|
|
|
|
|
@interface NSConnection : NSObject
|
|
|
|
|
{
|
2010-02-26 11:04:14 +00:00
|
|
|
|
#if GS_NONFRAGILE
|
|
|
|
|
# if defined(GS_NSConnection_IVARS)
|
2011-02-14 10:57:57 +00:00
|
|
|
|
@public
|
|
|
|
|
GS_NSConnection_IVARS;
|
2010-02-26 11:04:14 +00:00
|
|
|
|
# endif
|
|
|
|
|
#else
|
|
|
|
|
@private id _internal;
|
|
|
|
|
#endif
|
2000-07-04 11:05:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (NSArray*) allConnections;
|
|
|
|
|
+ (NSConnection*) connectionWithReceivePort: (NSPort*)r
|
|
|
|
|
sendPort: (NSPort*)s;
|
|
|
|
|
+ (NSConnection*) connectionWithRegisteredName: (NSString*)n
|
|
|
|
|
host: (NSString*)h;
|
|
|
|
|
+ (NSConnection*) connectionWithRegisteredName: (NSString*)n
|
|
|
|
|
host: (NSString*)h
|
|
|
|
|
usingNameServer: (NSPortNameServer*)s;
|
|
|
|
|
+ (id) currentConversation;
|
|
|
|
|
+ (NSConnection*) defaultConnection;
|
2001-12-17 14:31:42 +00:00
|
|
|
|
+ (NSDistantObject*) rootProxyForConnectionWithRegisteredName: (NSString*)n
|
|
|
|
|
host: (NSString*)h;
|
|
|
|
|
+ (NSDistantObject*) rootProxyForConnectionWithRegisteredName: (NSString*)n
|
|
|
|
|
host: (NSString*)h usingNameServer: (NSPortNameServer*)s;
|
2000-07-04 11:05:46 +00:00
|
|
|
|
|
2013-07-01 07:08:55 +00:00
|
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST)
|
2008-06-06 13:57:06 +00:00
|
|
|
|
+ (id) serviceConnectionWithName: (NSString *)name
|
|
|
|
|
rootObject: (id)root;
|
|
|
|
|
+ (id) serviceConnectionWithName: (NSString *)name
|
|
|
|
|
rootObject: (id)root
|
|
|
|
|
usingNameServer: (NSPortNameServer *)server;
|
|
|
|
|
#endif
|
2000-07-04 11:05:46 +00:00
|
|
|
|
|
|
|
|
|
- (void) addRequestMode: (NSString*)mode;
|
2001-12-17 14:31:42 +00:00
|
|
|
|
- (void) addRunLoop: (NSRunLoop*)loop;
|
2000-07-04 11:05:46 +00:00
|
|
|
|
- (id) delegate;
|
|
|
|
|
- (void) enableMultipleThreads;
|
|
|
|
|
- (BOOL) independentConversationQueueing;
|
|
|
|
|
- (id) initWithReceivePort: (NSPort*)r
|
|
|
|
|
sendPort: (NSPort*)s;
|
|
|
|
|
- (void) invalidate;
|
|
|
|
|
- (BOOL) isValid;
|
|
|
|
|
- (NSArray*)localObjects;
|
|
|
|
|
- (BOOL) multipleThreadsEnabled;
|
|
|
|
|
- (NSPort*) receivePort;
|
|
|
|
|
- (BOOL) registerName: (NSString*)name;
|
|
|
|
|
- (BOOL) registerName: (NSString*)name withNameServer: (NSPortNameServer*)svr;
|
|
|
|
|
- (NSArray*) remoteObjects;
|
|
|
|
|
- (void) removeRequestMode: (NSString*)mode;
|
2001-12-17 14:31:42 +00:00
|
|
|
|
- (void) removeRunLoop: (NSRunLoop *)loop;
|
2000-07-04 11:05:46 +00:00
|
|
|
|
- (NSTimeInterval) replyTimeout;
|
|
|
|
|
- (NSArray*) requestModes;
|
|
|
|
|
- (NSTimeInterval) requestTimeout;
|
|
|
|
|
- (id) rootObject;
|
|
|
|
|
- (NSDistantObject*) rootProxy;
|
|
|
|
|
- (void) runInNewThread;
|
|
|
|
|
- (NSPort*) sendPort;
|
|
|
|
|
- (void) setDelegate: anObj;
|
|
|
|
|
- (void) setIndependentConversationQueueing: (BOOL)flag;
|
2001-12-17 14:31:42 +00:00
|
|
|
|
- (void) setReplyTimeout: (NSTimeInterval)to;
|
2000-07-04 11:05:46 +00:00
|
|
|
|
- (void) setRequestMode: (NSString*)mode;
|
2001-12-17 14:31:42 +00:00
|
|
|
|
- (void) setRequestTimeout: (NSTimeInterval)to;
|
2000-07-04 11:05:46 +00:00
|
|
|
|
- (void) setRootObject: anObj;
|
|
|
|
|
- (NSDictionary*) statistics;
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
2005-06-18 15:45:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* This category represents an informal protocol to which NSConnection
|
|
|
|
|
* delegates may conform ... These methods are not actually implemented
|
|
|
|
|
* by NSObject, so implementing these methods in your class has the effect
|
|
|
|
|
* documented.
|
|
|
|
|
*/
|
|
|
|
|
@interface NSObject (NSConnectionDelegate)
|
2000-07-04 11:05:46 +00:00
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
|
/**
|
2005-06-18 15:45:54 +00:00
|
|
|
|
* <p>
|
|
|
|
|
* This is not an NSConnection method, but is a method that may
|
|
|
|
|
* be implemented by the delegate of an NSConnection object.
|
|
|
|
|
* </p>
|
|
|
|
|
* <p>
|
|
|
|
|
* If the delegate implements this method, the NSConnection will
|
|
|
|
|
* invoke the method for every message request or reply it receives
|
|
|
|
|
* from the remote NSConnection. The delegate should use the
|
|
|
|
|
* authentication data to check all the NSData objects
|
|
|
|
|
* in the components array (ignoring NSPort objects),
|
|
|
|
|
* and return YES if they are valid, NO otherwise.
|
|
|
|
|
* </p>
|
|
|
|
|
* <p>
|
|
|
|
|
* If the method returns NO then an
|
|
|
|
|
* NSFailedAuthentication exception will be raised.
|
|
|
|
|
* </p>
|
|
|
|
|
* <p>
|
|
|
|
|
* In GNUstep the components array is mutable, allowing
|
|
|
|
|
* you to replace the NSData objects with your own version.
|
|
|
|
|
* </p>
|
2000-07-04 11:05:46 +00:00
|
|
|
|
*/
|
2005-06-18 15:45:54 +00:00
|
|
|
|
- (BOOL) authenticateComponents: (NSMutableArray*)components
|
|
|
|
|
withData: (NSData*)authenticationData;
|
2000-07-04 11:05:46 +00:00
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
|
/**
|
2005-06-18 15:45:54 +00:00
|
|
|
|
* <p>
|
|
|
|
|
* This is not an NSConnection method, but is a method that may
|
|
|
|
|
* be implemented by the delegate of an NSConnection object.
|
|
|
|
|
* </p>
|
|
|
|
|
* <p>
|
|
|
|
|
* If the delegate implements this method, the NSConnection will
|
2005-11-06 13:53:40 +00:00
|
|
|
|
* invoke the method for every message request to reply it sends
|
2005-06-18 15:45:54 +00:00
|
|
|
|
* to the remote NSConnection. The delegate should generate
|
|
|
|
|
* authentication data by examining all the NSData objects
|
|
|
|
|
* in the components array (ignoring NSPort objects),
|
|
|
|
|
* and return the authentication data that can be used by the
|
|
|
|
|
* remote NSConnection.
|
|
|
|
|
* </p>
|
|
|
|
|
* <p>
|
|
|
|
|
* If the method returns nil then an
|
|
|
|
|
* NSGenericException exception will be raised.
|
|
|
|
|
* </p>
|
|
|
|
|
* <p>
|
|
|
|
|
* In GNUstep the components array is mutable, allowing
|
|
|
|
|
* you to replace the NSData objects with your own version.
|
|
|
|
|
* </p>
|
2000-07-04 11:05:46 +00:00
|
|
|
|
*/
|
2005-06-18 15:45:54 +00:00
|
|
|
|
- (NSData*) authenticationDataForComponents: (NSMutableArray*)components;
|
2000-07-04 11:05:46 +00:00
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
|
/**
|
2005-06-18 15:45:54 +00:00
|
|
|
|
* <p>
|
|
|
|
|
* This is not an NSConnection method, but is a method that may
|
|
|
|
|
* be implemented by the delegate of an NSConnection object.
|
|
|
|
|
* </p>
|
|
|
|
|
* <p>
|
|
|
|
|
* If the delegate implements this method, it will be called
|
|
|
|
|
* whenever a new NSConnection is created that has this
|
|
|
|
|
* NSConnection as its parent. The delegate may take this
|
|
|
|
|
* opportunity to adjust the configuration of the new
|
|
|
|
|
* connection and may return a boolean value to tell the
|
|
|
|
|
* parent whether the creation of the new connection is to
|
|
|
|
|
* be permitted or not.
|
|
|
|
|
* </p>
|
2000-07-04 11:05:46 +00:00
|
|
|
|
*/
|
2005-06-18 15:45:54 +00:00
|
|
|
|
- (BOOL) connection: (NSConnection*)parent
|
|
|
|
|
shouldMakeNewConnection: (NSConnection*)newConnection;
|
|
|
|
|
|
2000-07-04 11:05:46 +00:00
|
|
|
|
- (NSConnection*) connection: (NSConnection*)ancestorConn
|
|
|
|
|
didConnect: (NSConnection*)newConn;
|
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
|
/**
|
2005-06-18 15:45:54 +00:00
|
|
|
|
* An old fashioned synonym for -connection:shouldMakeNewConnection: -
|
|
|
|
|
* don't use this.
|
|
|
|
|
*/
|
|
|
|
|
- (BOOL) makeNewConnection: (NSConnection*)newConnection
|
|
|
|
|
sender: (NSConnection*)parent;
|
2000-07-04 11:05:46 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* NSRunLoop mode, NSNotification name and NSException strings.
|
|
|
|
|
*/
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [NSRunLoop] mode for [NSConnection] objects waiting for replies.
|
|
|
|
|
* Mainly used internally by distributed objects system.
|
|
|
|
|
*/
|
2002-05-08 05:43:15 +00:00
|
|
|
|
GS_EXPORT NSString * const NSConnectionReplyMode;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Posted when an [NSConnection] is deallocated or it is notified its port is
|
|
|
|
|
* deactivated. (Note, connections to remote ports don't get such a
|
|
|
|
|
* notification.) Receivers should deregister themselves for notifications
|
|
|
|
|
* from the given connection.
|
|
|
|
|
*/
|
2002-05-08 05:43:15 +00:00
|
|
|
|
GS_EXPORT NSString * const NSConnectionDidDieNotification;
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Posted when an [NSConnection] is initialized.
|
|
|
|
|
*/
|
2002-05-08 05:43:15 +00:00
|
|
|
|
GS_EXPORT NSString * const NSConnectionDidInitializeNotification; /* OPENSTEP */
|
2004-07-29 15:30:47 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Raised by an [NSConnection] on receiving a message that it or its delegate
|
|
|
|
|
* cannot authenticate.
|
|
|
|
|
*/
|
2002-05-08 05:43:15 +00:00
|
|
|
|
GS_EXPORT NSString * const NSFailedAuthenticationException; /* MacOS-X */
|
2000-07-04 11:05:46 +00:00
|
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2000-07-04 11:05:46 +00:00
|
|
|
|
#endif /* __NSConnection_h_GNUSTEP_BASE_INCLUDE */
|