Debian Codegraph @

.cargo/vendor/core-foundation-sys/src/notification_center.rs

raw
1 // Copyright 2023 The Servo Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 use std::os::raw::c_void;
11
12 use crate::base::{Boolean, CFIndex, CFOptionFlags, CFTypeID};
13 use crate::dictionary::CFDictionaryRef;
14 use crate::string::CFStringRef;
15
16 #[repr(C)]
17 pub struct __CFNotificationCenter(c_void);
18
19 pub type CFNotificationCenterRef = *mut __CFNotificationCenter;
20
21 pub type CFNotificationName = CFStringRef;
22 pub type CFNotificationCallback = extern "C" fn(
23 center: CFNotificationCenterRef,
24 observer: *mut c_void,
25 name: CFNotificationName,
26 object: *const c_void,
27 userInfo: CFDictionaryRef,
28 );
29 pub type CFNotificationSuspensionBehavior = CFIndex;
30
31 pub const CFNotificationSuspensionBehaviorDrop: CFNotificationSuspensionBehavior = 1;
32 pub const CFNotificationSuspensionBehaviorCoalesce: CFNotificationSuspensionBehavior = 2;
33 pub const CFNotificationSuspensionBehaviorHold: CFNotificationSuspensionBehavior = 3;
34 pub const CFNotificationSuspensionBehaviorDeliverImmediately: CFNotificationSuspensionBehavior = 4;
35
36 /* Notification Posting Options */
37 pub const kCFNotificationDeliverImmediately: CFOptionFlags = 1usize << 0;
38 pub const kCFNotificationPostToAllSessions: CFOptionFlags = 1usize << 1;
39
40 extern "C" {
41 /*
42 * CFNotificationCenter.h
43 */
44
45 /* Accessing a Notification Center */
46 pub fn CFNotificationCenterGetDarwinNotifyCenter() -> CFNotificationCenterRef;
47 #[cfg(any(target_os = "macos", target_os = "windows"))]
48 pub fn CFNotificationCenterGetDistributedCenter() -> CFNotificationCenterRef;
49 pub fn CFNotificationCenterGetLocalCenter() -> CFNotificationCenterRef;
50
51 /* Posting a Notification */
52 pub fn CFNotificationCenterPostNotification(
53 center: CFNotificationCenterRef,
54 name: CFNotificationName,
55 object: *const c_void,
56 userInfo: CFDictionaryRef,
57 deliverImmediately: Boolean,
58 );
59 pub fn CFNotificationCenterPostNotificationWithOptions(
60 center: CFNotificationCenterRef,
61 name: CFNotificationName,
62 object: *const c_void,
63 userInfo: CFDictionaryRef,
64 options: CFOptionFlags,
65 );
66
67 /* Adding and Removing Observers */
68 pub fn CFNotificationCenterAddObserver(
69 center: CFNotificationCenterRef,
70 observer: *const c_void,
71 callBack: CFNotificationCallback,
72 name: CFStringRef,
73 object: *const c_void,
74 suspensionBehavior: CFNotificationSuspensionBehavior,
75 );
76 pub fn CFNotificationCenterRemoveEveryObserver(
77 center: CFNotificationCenterRef,
78 observer: *const c_void,
79 );
80 pub fn CFNotificationCenterRemoveObserver(
81 center: CFNotificationCenterRef,
82 observer: *const c_void,
83 name: CFNotificationName,
84 object: *const c_void,
85 );
86
87 /* Getting the CFNotificationCenter Type ID */
88 pub fn CFNotificationCenterGetTypeID() -> CFTypeID;
89 }