More expressive return codes for bus name requests

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/dbuskit/trunk@40504 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Niels Grewe 2017-05-15 20:40:32 +00:00
parent 6537103a9e
commit c7c8d3dbf0
2 changed files with 39 additions and 11 deletions

View File

@ -34,6 +34,31 @@ typedef NS_OPTIONS(NSUInteger, DKPortNameFlags)
DKPortNameFlagMax = 7
};
/**
* The status returned by D-Bus in response to a request to register a name.
*/
typedef NS_ENUM(uint32_t, DKPortNameRegistrationStatus)
{
/**
* The port is now the primary owner of the name.
*/
DKPortNamePrimaryOwner = 1,
/**
* The name has been queued and will be assigned to the port once previous
* registrands of the name go away.
*/
DKPortNameQueued = 2,
/**
* The name is already in use by a different port, but queuing was not
* requested.
*/
DKPortNameExists = 3,
/**
* The port had already been registered by the port. No changes occurred.
*/
DKPortNameAlreadyOwner = 4
};
@interface DKPortNameServer: NSObject
{
@private
@ -68,12 +93,12 @@ typedef NS_OPTIONS(NSUInteger, DKPortNameFlags)
- (DKPort*)portForName: (NSString*)name;
- (BOOL)registerPort: (DKPort*)port
name: (NSString*)name;
- (DKPortNameRegistrationStatus)registerPort: (DKPort*)port
name: (NSString*)name;
- (BOOL)registerPort: (DKPort*)port
name: (NSString*)name
flags: (DKPortNameFlags)flags;
- (DKPortNameRegistrationStatus)registerPort: (DKPort*)port
name: (NSString*)name
flags: (DKPortNameFlags)flags;
- (void)removePortForName: (NSString*)name;
@end

View File

@ -30,6 +30,7 @@
#import <Foundation/NSDictionary.h>
#import <Foundation/NSHashTable.h>
#import <Foundation/NSString.h>
#import <Foundation/NSException.h>
#include <stdint.h>
#include <dbus/dbus.h>
@ -120,18 +121,20 @@ static DKPortNameServer *sessionBusNameServer;
return thisPort;
}
- (BOOL)registerPort: (DKPort*)port
name: (NSString*)name
- (DKPortNameRegistrationStatus)registerPort: (DKPort*)port
name: (NSString*)name
{
return [self registerPort: port
name: name
flags: 0];
}
- (BOOL)registerPort: (DKPort*)port
name: (NSString*)name
flags: (DKPortNameFlags)flags
- (DKPortNameRegistrationStatus)registerPort: (DKPort*)port
name: (NSString*)name
flags: (DKPortNameFlags)flags
{
return NO;
[NSException raise: NSGenericException
format: @"Not implemented"];
return DKPortNameExists;
}
- (void)removePortForName: (NSString*)name