DKNotificationCenter class documentation

Authors

Niels Grewe (niels.grewe@halbordnung.de)

Date: Generated at 2025-05-09 09:10:33 -0600

Copyright: (C) 2010 Free Software Foundation, Inc.

Software documentation for the DKNotificationCenter class

DKNotificationCenter : NSObject

Declared in:
DBusKit/DKNotificationCenter.h
The DKNotificationCenter class allows Objective-C objects to watch for notifications from other D-Bus objects ('signals' in the D-Bus dialect) or to post notifications to D-Bus themselves. You can use this class just as you would use an NSNotificationCenter. Notification names will be mapped to signals as follows: If the introspection data for theD-Bus signal carries an org.gnustep.openstep.notification annotation,the value of this annotation will be used as the name of the notification. Otherwise, the notification name will be DKSignal_<InterfaceName>_<SignalName> . Additionally, D-Bus provides a rather sophisticated matching mechanism to catch only signal emissions with a specific signature. This mechanism is available to applications through the -addObserver:selector:signal:interface:sender:destination: method and its more specific variants. Unfortunately, at this time, you need to specify identical match rules when removing the observer again. Every notification from D-Bus carries a reference to a proxy for the object emitting the signal and also guarantees that the following keys are present in the dictionary:
member
The name of the signal being emitted (e.g. "NameOwnerChanged"
interface
The name of the interface to which the signal belongs. (e.g. "org.freedesktop.DBus").
sender
The service emitting the signal (e.g. "org.freedesktop.DBus"). This will always be the unique name of the service, even if you registered the signal for another name.
path
The path to the object emitting the signal (e.g "/org/freedesktop/DBus").
destination
The intended receiver of the signal, might be empty if the signal was broadcast, which is usually the case.
Additionally the userInfo dictionary will contain keys for every argument specified in the signal, named "arg N ". The dictionary might also contain further keys if org.gnustep.openstep.notification.key annotations were available.

Method summary


centerForBusType: 

+ (id) centerForBusType: (DKDBusBusType)type;
Returns a notification center for the specified bus type.

sessionBusCenter 

+ (id) sessionBusCenter;
Returns a notification center for the session message bus.

systemBusCenter 

+ (id) systemBusCenter;
Returns a notification center for the system message bus.

addObserver: selector: name: object: 

- (void) addObserver: (id)observer selector: (SEL)notifySelector name: (NSString*)notificationName object: (DKProxy*)sender;
Watches the bus for signals matching notificationName from sender. If one of them is nil, the value will not be used to restrict the notifications delivered to the observer. Notifications are delivered by calling notifySelector on observer as a receiver. Neither can be nil and notifySelector takes exactly one argument (the notification).

addObserver: selector: name: sender: destination: 

- (void) addObserver: (id)observer selector: (SEL)notifySelector name: (NSString*)notificationName sender: (DKProxy*)sender destination: (DKProxy*)destination;
Similar to -addObserver:selector:name:object: but allows to specify both sender and destination of the notification.

addObserver: selector: signal: interface: sender: destination: 

- (void) addObserver: (id)observer selector: (SEL)notifySelector signal: (NSString*)signalName interface: (NSString*)interfaceName sender: (DKProxy*)sender destination: (DKProxy*)destination;
Similar to -addObserver:selector:name:sender:destination: but allows finer grained control over what signals to match. (E.g. it would be possible to request all notifications matching a particular interface only.).

addObserver: selector: signal: interface: sender: destination: filter: atIndex: 

- (void) addObserver: (id)observer selector: (SEL)notifySelector signal: (NSString*)signalName interface: (NSString*)interfaceName sender: (DKProxy*)sender destination: (DKProxy*)destination filter: (NSString*)filter atIndex: (NSUInteger)index;
Similar to -addObserver:selector:signal:interface:sender:destination: but additionally allows matching a single argument. Due to D-Bus constraints, index must be less than 64. The signal will only be matched if the value of the argument at index is equal to the value of filter. Additionally, this matching is limited to string arguments.

addObserver: selector: signal: interface: sender: destination: filtersAndIndices: ,...

- (void) addObserver: (id)observer selector: (SEL)notifySelector signal: (NSString*)signalName interface: (NSString*)interfaceName sender: (DKProxy*)sender destination: (DKProxy*)destination filtersAndIndices: (NSString*)firstFilter,...;
Similar to -addObserver:selector:signal:interface:sender:destination:filter:atIndex: but allows matching more than one signal. The argument list needs to be terminated by nil. If you want to match the first argument, specify that particular match as the first one and set firstIndex to 0.

postNotification: 

- (void) postNotification: (NSNotification*)notification;
NOTE: Not yet implemented.

postNotificationName: object: 

- (void) postNotificationName: (NSString*)name object: (id)sender;
NOTE: Not yet implemented.

postNotificationName: object: userInfo: 

- (void) postNotificationName: (NSString*)name object: (id)sender userInfo: (NSDictionary*)info;
NOTE: Not yet implemented.

postSignalName: interface: object: 

- (void) postSignalName: (NSString*)signalName interface: (NSString*)interfaceName object: (id)sender;
NOTE: Not yet implemented.

postSignalName: interface: object: userInfo: 

- (void) postSignalName: (NSString*)signalName interface: (NSString*)interfaceName object: (id)sender userInfo: (NSDictionary*)info;
NOTE: Not yet implemented.

registerNotificationName: asSignal: inInterface: 

- (BOOL) registerNotificationName: (NSString*)notificationName asSignal: (NSString*)signalName inInterface: (NSString*)interface;
This method allows notification names to be registered for specific signals. E.g.:
 [[DKNotificationCenter sessionBusCenter] registerNotificationName: @"DKNameChanged"
                                                          asSignal: @"NameOwnerChanged"
                                                       inInterface: @"org.freedesktop.DBus"];
 
would deliver all " NameOwnerChanged " emissions as notifications named " DKNameChanged ". The method returns NO if the notification name has already been registered.

removeObserver: 

- (void) removeObserver: (id)observer;
Removes all observation activities involving the observer.

removeObserver: name: object: 

- (void) removeObserver: (id)observer name: (NSString*)notificationName object: (DKProxy*)sender;
Removes all observation activities matching the arguments specified. The match is inclusive. Every observation for a more specific rule will also be removed.

removeObserver: name: sender: destination: 

- (void) removeObserver: (id)observer name: (NSString*)notificationName sender: (DKProxy*)sender destination: (DKProxy*)destination;
Removes all observation activities matching the arguments specified. The match is inclusive. Every observation for a more specific rule will also be removed.

removeObserver: signal: interface: object: 

- (void) removeObserver: (id)observer signal: (NSString*)signalName interface: (NSString*)interfaceName object: (DKProxy*)sender;
Removes all observation activities matching the arguments specified. The match is inclusive. Every observation for a more specific rule will also be removed.

removeObserver: signal: interface: sender: destination: 

- (void) removeObserver: (id)observer signal: (NSString*)signalName interface: (NSString*)interfaceName sender: (DKProxy*)sender destination: (DKProxy*)destination;
Removes all observation activities matching the arguments specified. The match is inclusive. Every observation for a more specific rule will also be removed.

removeObserver: signal: interface: sender: destination: filter: atIndex: 

- (void) removeObserver: (id)observer signal: (NSString*)signalName interface: (NSString*)interfaceName sender: (DKProxy*)sender destination: (DKProxy*)destination filter: (NSString*)filter atIndex: (NSUInteger)index;
Removes all observation activities matching the arguments specified. The match is inclusive. Every observation for a more specific rule will also be removed.

removeObserver: signal: interface: sender: destination: filtersAndIndices: ,...

- (void) removeObserver: (id)observer signal: (NSString*)signalName interface: (NSString*)interfaceName sender: (DKProxy*)sender destination: (DKProxy*)destination filtersAndIndices: (NSString*)firstFilter,...;
Removes all observation activities matching the arguments specified. The match is inclusive. Every observation for a more specific rule will also be removed.