14
|
1 /**
|
|
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
|
|
3 * Authors: Jacob Carlborg
|
|
4 * Version: Initial created: Aug 3, 2009
|
|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
|
|
6 */
|
|
7 module dstep.foundation.NSDistributedNotificationCenter;
|
|
8
|
|
9 import dstep.foundation.NSDictionary;
|
|
10 import dstep.foundation.NSNotification;
|
|
11 import dstep.foundation.NSString;
|
|
12 import dstep.objc.bridge.Bridge;
|
|
13 import dstep.objc.objc : id;
|
|
14
|
|
15 import bindings = dstep.foundation.NSDistributedNotificationCenter_bindings;
|
|
16
|
|
17 alias NSUInteger NSNotificationSuspensionBehavior;
|
|
18
|
|
19 const NSString NSLocalNotificationCenterType;
|
|
20
|
|
21 enum
|
|
22 {
|
|
23 NSNotificationSuspensionBehaviorDrop = 1,
|
|
24 NSNotificationSuspensionBehaviorCoalesce = 2,
|
|
25 NSNotificationSuspensionBehaviorHold = 3,
|
|
26 NSNotificationSuspensionBehaviorDeliverImmediately = 4
|
|
27 }
|
|
28
|
|
29 enum
|
|
30 {
|
|
31 NSNotificationDeliverImmediately = (1 << 0),
|
|
32 NSNotificationPostToAllSessions = (1 << 1)
|
|
33 }
|
|
34
|
|
35 static this ()
|
|
36 {
|
|
37 NSLocalNotificationCenterType = new NSString(bindings.NSLocalNotificationCenterType);
|
|
38 }
|
|
39
|
|
40 class NSDistributedNotificationCenter : NSNotificationCenter
|
|
41 {
|
|
42 mixin ObjcWrap;
|
|
43
|
|
44 static NSDistributedNotificationCenter notificationCenterForType (NSString notificationCenterType)
|
|
45 {
|
|
46 return invokeObjcSelfClass!(NSDistributedNotificationCenter, "notificationCenterForType:", NSString)(notificationCenterTypereturn result is this.objcObject ? this : (result !is null ? new NSDistributedNotificationCenter(result) : null); }
|
|
47
|
|
48 static Object defaultCenter ()
|
|
49 {
|
|
50 return invokeObjcSelfClass!(Object, "defaultCenter");
|
|
51 }
|
|
52
|
|
53 void addObserver (Object observer, SEL selector, NSString name, NSString object, uint suspensionBehavior)
|
|
54 {
|
|
55 return invokeObjcSelf!(void, "addObserver:selector:name:object:suspensionBehavior:", Object, SEL, NSString, NSString, uint)(observer, selector, name, object, suspensionBehavior);
|
|
56 }
|
|
57
|
|
58 void postNotificationName (NSString name, NSString object, NSDictionary userInfo, bool deliverImmediately)
|
|
59 {
|
|
60 return invokeObjcSelf!(void, "postNotificationName:object:userInfo:deliverImmediately:", NSString, NSString, NSDictionary, bool)(name, object, userInfo, deliverImmediately);
|
|
61 }
|
|
62
|
|
63 void postNotificationName (NSString name, NSString object, NSDictionary userInfo, NSUInteger options)
|
|
64 {
|
|
65 return invokeObjcSelf!(void, "postNotificationName:object:userInfo:options:", NSString, NSString, NSDictionary, NSUInteger)(name, object, userInfo, options);
|
|
66 }
|
|
67
|
|
68 void setSuspended (bool suspended)
|
|
69 {
|
|
70 return invokeObjcSelf!(void, "setSuspended:", bool)(suspended);
|
|
71 }
|
|
72
|
|
73 bool suspended ()
|
|
74 {
|
|
75 return invokeObjcSelf!(bool, "suspended");
|
|
76 }
|
|
77
|
|
78 void addObserver (Object observer, SEL aSelector, NSString aName, NSString anObject)
|
|
79 {
|
|
80 return invokeObjcSelf!(void, "addObserver:selector:name:object:", Object, SEL, NSString, NSString)(observer, aSelector, aName, anObject);
|
|
81 }
|
|
82
|
|
83 void postNotificationName (NSString aName, NSString anObject)
|
|
84 {
|
|
85 return invokeObjcSelf!(void, "postNotificationName:object:", NSString, NSString)(aName, anObject);
|
|
86 }
|
|
87
|
|
88 void postNotificationName (NSString aName, NSString anObject, NSDictionary aUserInfo)
|
|
89 {
|
|
90 return invokeObjcSelf!(void, "postNotificationName:object:userInfo:", NSString, NSString, NSDictionary)(aName, anObject, aUserInfo);
|
|
91 }
|
|
92
|
|
93 void removeObserver (Object observer, NSString aName, NSString anObject)
|
|
94 {
|
|
95 return invokeObjcSelf!(void, "removeObserver:name:object:", Object, NSString, NSString)(observer, aName, anObject);
|
|
96 }
|
|
97 }
|
|
98
|