46 #include "CACFDistributedNotification.h"
49 #include "CADebugMacros.h"
55 void CACFDistributedNotification::AddObserver(
const void* inObserver, CFNotificationCallback inCallback, CFStringRef inName, CFNotificationSuspensionBehavior inSuspensionBehavior)
58 CFNotificationCenterRef theCenter = CFNotificationCenterGetDistributedCenter();
59 CFNotificationSuspensionBehavior theSuspensionBehavior = inSuspensionBehavior;
61 #pragma unused(inSuspensionBehavior)
62 CFNotificationCenterRef theCenter = CFNotificationCenterGetDarwinNotifyCenter();
63 CFNotificationSuspensionBehavior theSuspensionBehavior = 0;
66 CFNotificationCenterAddObserver(theCenter, inObserver, inCallback, inName, NULL, theSuspensionBehavior);
69 void CACFDistributedNotification::RemoveObserver(
const void* inObserver, CFStringRef inName)
72 CFNotificationCenterRef theCenter = CFNotificationCenterGetDistributedCenter();
74 CFNotificationCenterRef theCenter = CFNotificationCenterGetDarwinNotifyCenter();
77 CFNotificationCenterRemoveObserver(theCenter, inObserver, inName, NULL);
80 void CACFDistributedNotification::PostNotification(CFStringRef inName, CFDictionaryRef inUserInfo,
bool inPostToAllSessions)
83 CFNotificationCenterRef theCenter = CFNotificationCenterGetDistributedCenter();
84 CFDictionaryRef theUserInfo = inUserInfo;
85 CFOptionFlags theFlags = kCFNotificationDeliverImmediately;
86 if(inPostToAllSessions)
88 theFlags += kCFNotificationPostToAllSessions;
92 Assert(inUserInfo == NULL,
"CACFDistributedNotification::PostNotification: distributed notifications do not support a payload");
93 Assert(inPostToAllSessions,
"CACFDistributedNotification::PostNotification: distributed notifications do not support per-session delivery");
95 CFNotificationCenterRef theCenter = CFNotificationCenterGetDarwinNotifyCenter();
96 CFDictionaryRef theUserInfo = NULL;
97 CFOptionFlags theFlags = 0;
100 CFNotificationCenterPostNotificationWithOptions(theCenter, inName, NULL, theUserInfo, theFlags);