Authors
- Niels Grewe (
niels.grewe@halbordnung.de)
-
Date: Generated at 2025-02-13 20:13:11 +0000
Copyright: (C) 2010 Free Software Foundation, Inc.
- 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.
+ (id)
centerForBusType: (
DKDBusBusType)type;
Returns a notification center for the specified bus
type.
+ (id)
sessionBusCenter;
Returns a notification center for the session
message bus.
+ (id)
systemBusCenter;
Returns a notification center for the system
message bus.
- (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).
- (void)
addObserver: (id)observer
selector: (SEL)notifySelector
name: (NSString*)notificationName
sender: (
DKProxy*)sender
destination: (
DKProxy*)destination;
- (void)
addObserver: (id)observer
selector: (SEL)notifySelector
signal: (NSString*)signalName
interface: (NSString*)interfaceName
sender: (
DKProxy*)sender
destination: (
DKProxy*)destination;
- (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.
- (void)
addObserver: (id)observer
selector: (SEL)notifySelector
signal: (NSString*)signalName
interface: (NSString*)interfaceName
sender: (
DKProxy*)sender
destination: (
DKProxy*)destination
filters: (NSDictionary*)filters;
- (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.
NOTE: This method has been
deprecated in DBusKit 0.2 and will be removed
in a later version. Please use
-addObserver:signal:interface:sender:destination:filters:
instead.
- (void)
postNotification: (NSNotification*)notification;
Posts a
notification to D-Bus. The
notification must fulfill the following
conditions:
-
The object must already exported. (This is a
temporary limitation, subsequent versions of
DBusKit will automatically export an object if
it tries to post a notification to the
bus.)
-
The notification name must either
conform to the DKSignal_<interface
name>_<member name> format
or a mapping must be registered with the
notification center for this
notification name.
-
The userInfo dictionary must contain all the the
required argument keys, either with the key
mapped by the
org.gnustep.openstep.notification.key
annotation of the D-Bus interface, or with
the format argN, where N is the
index of the argument. If basic typed arguments
(strings, numeric types) are missing, these
are implicitly set to 0 (or the empty string).
Otherwise an exception is raised.
- (void)
postNotificationName: (NSString*)name
object: (id)sender;
- (void)
postNotificationName: (NSString*)name
object: (id)sender
userInfo: (NSDictionary*)info;
- (void)
postSignalName: (NSString*)signalName
interface: (NSString*)interfaceName
object: (id)sender;
- (void)
postSignalName: (NSString*)signalName
interface: (NSString*)interfaceName
object: (id)sender
userInfo: (NSDictionary*)info;
- (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.
- (void)
removeObserver: (id)observer;
Removes all observation activities involving the
observer.
- (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.
- (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.
- (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.
- (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.
- (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.
- (void)
removeObserver: (id)observer
signal: (NSString*)signalName
interface: (NSString*)interfaceName
sender: (
DKProxy*)sender
destination: (
DKProxy*)destination
filters: (NSDictionary*)filters;
Removes all observation activities matching the
arguments specified. The match is inclusive.
Every observation for a more specific rule will also
be removed.
- (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.
NOTE: This method has been
deprecated in DBusKit 0.2 and will be removed
in a later version. Please use
-removeObserver:signal:interface:sender:destination:filters:
instead.