1 /* Interface of NSDistributedNotificationCenter class
2    Copyright (C) 1998 Free Software Foundation, Inc.
3 
4    Written by:  Richard Frith-Macdonald <richard@brainstorm.co.uk>
5    Created: October 1998
6 
7    This file is part of the GNUstep Base Library.
8 
9    This library is free software; you can redistribute it and/or
10    modify it under the terms of the GNU Lesser General Public
11    License as published by the Free Software Foundation; either
12    version 2 of the License, or (at your option) any later version.
13 
14    This library is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    Lesser General Public License for more details.
18 
19    You should have received a copy of the GNU Lesser General Public
20    License along with this library; if not, write to the Free
21    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22    Boston, MA 02110 USA.
23    */
24 
25 #ifndef __NSDistributedNotificationCenter_h_GNUSTEP_BASE_INCLUDE
26 #define __NSDistributedNotificationCenter_h_GNUSTEP_BASE_INCLUDE
27 #import	<GNUstepBase/GSVersionMacros.h>
28 
29 #if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
30 
31 #import	<Foundation/NSObject.h>
32 #import	<Foundation/NSLock.h>
33 #import	<Foundation/NSNotification.h>
34 
35 #if	defined(__cplusplus)
36 extern "C" {
37 #endif
38 
39 
40 /**
41  *  Enumeration of possible values for specifying how
42  *  [NSDistributedNotificationCenter] deals with notifications when the
43  *  process to which the notification should be delivered is suspended:
44  <example>
45  {
46   NSNotificationSuspensionBehaviorDrop,       // drop the notification
47   NSNotificationSuspensionBehaviorCoalesce,   // drop all for this process but the latest-sent notification
48   NSNotificationSuspensionBehaviorHold,       // queue all notifications for this process until it is resumed
49   NSNotificationSuspensionBehaviorDeliverImmediately  // resume the process and deliver
50 }
51  </example>
52  */
53 enum {
54   NSNotificationSuspensionBehaviorDrop = 1,
55   NSNotificationSuspensionBehaviorCoalesce = 2,
56   NSNotificationSuspensionBehaviorHold = 3,
57   NSNotificationSuspensionBehaviorDeliverImmediately = 4
58 };
59 typedef NSUInteger NSNotificationSuspensionBehavior;
60 
61 /**
62  *  Type for [NSDistributedNotificationCenter+notificationCenterForType:] -
63  *  localhost current user broadcast only.  This is the only type on OS X.
64  */
65 GS_EXPORT NSString* const NSLocalNotificationCenterType;
66 #if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
67 
68 /**
69  *  Type of [NSDistributedNotificationCenter+notificationCenterForType:] -
70  *  all users on the local host.  This type is available only on GNUstep.
71  */
72 GS_EXPORT NSString* const GSPublicNotificationCenterType;
73 
74 /**
75  *  Type of [NSDistributedNotificationCenter+notificationCenterForType:] -
76  *  localhost and LAN broadcast.  This type is available only on GNUstep.
77  */
78 GS_EXPORT NSString* const GSNetworkNotificationCenterType;
79 #endif
80 
81 @interface	NSDistributedNotificationCenter : NSNotificationCenter
82 {
83 #if	GS_EXPOSE(NSDistributedNotificationCenter)
84   NSRecursiveLock *_centerLock;	/* For thread safety.		*/
85   NSString	*_type;		/* Type of notification center.	*/
86   id		_remote;	/* Proxy for center.		*/
87   BOOL		_suspended;	/* Is delivery suspended?	*/
88 #endif
89 #if     GS_NONFRAGILE
90 #else
91   /* Pointer to private additional data used to avoid breaking ABI
92    * when we don't have the non-fragile ABI available.
93    * Use this mechanism rather than changing the instance variable
94    * layout (see Source/GSInternal.h for details).
95    */
96   @private id _internal GS_UNUSED_IVAR;
97 #endif
98 }
99 + (id) defaultCenter;
100 + (NSDistributedNotificationCenter*) notificationCenterForType: (NSString*)type;
101 
102 - (void) addObserver: (id)anObserver
103 	    selector: (SEL)aSelector
104 		name: (NSString*)notificationName
105 	      object: (NSString*)anObject;
106 - (void) addObserver: (id)anObserver
107 	    selector: (SEL)aSelector
108 		name: (NSString*)notificationName
109 	      object: (NSString*)anObject
110   suspensionBehavior: (NSNotificationSuspensionBehavior)suspensionBehavior;
111 - (void) postNotification: (NSNotification*)notification;
112 - (void) postNotificationName: (NSString*)notificationName
113 		       object: (NSString*)anObject;
114 - (void) postNotificationName: (NSString*)notificationName
115 		       object: (NSString*)anObject
116 		     userInfo: (NSDictionary*)userInfo;
117 - (void) postNotificationName: (NSString*)notificationName
118 		       object: (NSString*)anObject
119 		     userInfo: (NSDictionary*)userInfo
120 	   deliverImmediately: (BOOL)deliverImmediately;
121 - (void) removeObserver: (id)anObserver
122 		   name: (NSString*)notificationName
123 		 object: (NSString*)anObject;
124 - (void) setSuspended: (BOOL)flag;
125 - (BOOL) suspended;
126 
127 @end
128 
129 #if	defined(__cplusplus)
130 }
131 #endif
132 
133 #endif
134 #endif
135 
136