objc2_system_configuration/generated/
SCPreferences.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "dispatch2")]
8use dispatch2::*;
9#[cfg(feature = "objc2")]
10use objc2::__framework_prelude::*;
11use objc2_core_foundation::*;
12#[cfg(feature = "objc2-security")]
13use objc2_security::*;
14
15use crate::*;
16
17/// This is the handle to an open preferences session for
18/// accessing system configuration preferences.
19///
20/// See also [Apple's documentation](https://developer.apple.com/documentation/systemconfiguration/scpreferences?language=objc)
21#[doc(alias = "SCPreferencesRef")]
22#[repr(C)]
23pub struct SCPreferences {
24    inner: [u8; 0],
25    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
26}
27
28cf_type!(
29    unsafe impl SCPreferences {}
30);
31#[cfg(feature = "objc2")]
32cf_objc2_type!(
33    unsafe impl RefEncode<"__SCPreferences"> for SCPreferences {}
34);
35
36/// Used with the SCPreferencesCallBack callback
37/// to describe the type of notification.
38///
39/// preferences have been saved.
40///
41/// request has been made to apply the currently saved
42/// preferences to the active system configuration.
43///
44/// See also [Apple's documentation](https://developer.apple.com/documentation/systemconfiguration/scpreferencesnotification?language=objc)
45// NS_OPTIONS
46#[repr(transparent)]
47#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
48pub struct SCPreferencesNotification(pub u32);
49bitflags::bitflags! {
50    impl SCPreferencesNotification: u32 {
51        #[doc(alias = "kSCPreferencesNotificationCommit")]
52        const Commit = 1<<0;
53        #[doc(alias = "kSCPreferencesNotificationApply")]
54        const Apply = 1<<1;
55    }
56}
57
58#[cfg(feature = "objc2")]
59unsafe impl Encode for SCPreferencesNotification {
60    const ENCODING: Encoding = u32::ENCODING;
61}
62
63#[cfg(feature = "objc2")]
64unsafe impl RefEncode for SCPreferencesNotification {
65    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
66}
67
68/// Structure containing user-specified data and callbacks for SCPreferences.
69/// Field: version The version number of the structure type being passed
70/// in as a parameter to the SCPreferencesSetCallback function.
71/// This structure is version 0.
72/// Field: info A C pointer to a user-specified block of data.
73/// Field: retain The callback used to add a retain for the info field.
74/// If this parameter is not a pointer to a function of the correct
75/// prototype, the behavior is undefined.
76/// The value may be NULL.
77/// Field: release The calllback used to remove a retain previously added
78/// for the info field.
79/// If this parameter is not a pointer to a function of the
80/// correct prototype, the behavior is undefined.
81/// The value may be NULL.
82/// Field: copyDescription The callback used to provide a description of
83/// the info field.
84///
85/// See also [Apple's documentation](https://developer.apple.com/documentation/systemconfiguration/scpreferencescontext?language=objc)
86#[repr(C)]
87#[allow(unpredictable_function_pointer_comparisons)]
88#[derive(Clone, Copy, Debug, PartialEq)]
89pub struct SCPreferencesContext {
90    pub version: CFIndex,
91    pub info: *mut c_void,
92    pub retain: Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NonNull<c_void>>,
93    pub release: Option<unsafe extern "C-unwind" fn(NonNull<c_void>)>,
94    pub copyDescription: Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NonNull<CFString>>,
95}
96
97#[cfg(feature = "objc2")]
98unsafe impl Encode for SCPreferencesContext {
99    const ENCODING: Encoding = Encoding::Struct(
100        "?",
101        &[
102            <CFIndex>::ENCODING,
103            <*mut c_void>::ENCODING,
104            <Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NonNull<c_void>>>::ENCODING,
105            <Option<unsafe extern "C-unwind" fn(NonNull<c_void>)>>::ENCODING,
106            <Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NonNull<CFString>>>::ENCODING,
107        ],
108    );
109}
110
111#[cfg(feature = "objc2")]
112unsafe impl RefEncode for SCPreferencesContext {
113    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
114}
115
116/// Type of the callback function used when the
117/// preferences have been updated and/or applied.
118///
119/// Parameter `prefs`: The preferences session.
120///
121/// Parameter `notificationType`: The type of notification, such as changes
122/// committed, changes applied, etc.
123///
124/// Parameter `info`: A C pointer to a user-specified block of data.
125///
126/// See also [Apple's documentation](https://developer.apple.com/documentation/systemconfiguration/scpreferencescallback?language=objc)
127pub type SCPreferencesCallBack = Option<
128    unsafe extern "C-unwind" fn(NonNull<SCPreferences>, SCPreferencesNotification, *mut c_void),
129>;
130
131unsafe impl ConcreteType for SCPreferences {
132    /// Returns the type identifier of all SCPreferences instances.
133    #[doc(alias = "SCPreferencesGetTypeID")]
134    #[inline]
135    fn type_id() -> CFTypeID {
136        extern "C-unwind" {
137            fn SCPreferencesGetTypeID() -> CFTypeID;
138        }
139        unsafe { SCPreferencesGetTypeID() }
140    }
141}
142
143impl SCPreferences {
144    /// Initiates access to the per-system set of configuration
145    /// preferences.
146    ///
147    /// Parameter `allocator`: The CFAllocator that should be used to allocate
148    /// memory for this preferences session.
149    /// This parameter may be NULL in which case the current
150    /// default CFAllocator is used.
151    /// If this reference is not a valid CFAllocator, the behavior
152    /// is undefined.
153    ///
154    /// Parameter `name`: A string that describes the name of the calling
155    /// process.
156    ///
157    /// Parameter `prefsID`: A string that identifies the name of the
158    /// group of preferences to be accessed or updated.
159    ///
160    /// Returns: Returns a reference to the new SCPreferences.
161    /// You must release the returned value.
162    #[doc(alias = "SCPreferencesCreate")]
163    #[inline]
164    pub fn new(
165        allocator: Option<&CFAllocator>,
166        name: &CFString,
167        prefs_id: Option<&CFString>,
168    ) -> Option<CFRetained<SCPreferences>> {
169        extern "C-unwind" {
170            fn SCPreferencesCreate(
171                allocator: Option<&CFAllocator>,
172                name: &CFString,
173                prefs_id: Option<&CFString>,
174            ) -> Option<NonNull<SCPreferences>>;
175        }
176        let ret = unsafe { SCPreferencesCreate(allocator, name, prefs_id) };
177        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
178    }
179
180    /// Initiates access to the per-system set of configuration
181    /// preferences.
182    ///
183    /// Parameter `allocator`: The CFAllocator that should be used to allocate
184    /// memory for this preferences session.
185    /// This parameter may be NULL in which case the current
186    /// default CFAllocator is used.
187    /// If this reference is not a valid CFAllocator, the behavior
188    /// is undefined.
189    ///
190    /// Parameter `name`: A string that describes the name of the calling
191    /// process.
192    ///
193    /// Parameter `prefsID`: A string that identifies the name of the
194    /// group of preferences to be accessed or updated.
195    ///
196    /// Parameter `authorization`: An authorization reference that is used to
197    /// authorize any access to the enhanced privileges needed
198    /// to manage the preferences session.
199    ///
200    /// Returns: Returns a reference to the new SCPreferences.
201    /// You must release the returned value.
202    ///
203    /// # Safety
204    ///
205    /// `authorization` must be a valid pointer or null.
206    #[doc(alias = "SCPreferencesCreateWithAuthorization")]
207    #[cfg(feature = "objc2-security")]
208    #[inline]
209    pub unsafe fn with_authorization(
210        allocator: Option<&CFAllocator>,
211        name: &CFString,
212        prefs_id: Option<&CFString>,
213        authorization: AuthorizationRef,
214    ) -> Option<CFRetained<SCPreferences>> {
215        extern "C-unwind" {
216            fn SCPreferencesCreateWithAuthorization(
217                allocator: Option<&CFAllocator>,
218                name: &CFString,
219                prefs_id: Option<&CFString>,
220                authorization: AuthorizationRef,
221            ) -> Option<NonNull<SCPreferences>>;
222        }
223        let ret = unsafe {
224            SCPreferencesCreateWithAuthorization(allocator, name, prefs_id, authorization)
225        };
226        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
227    }
228
229    /// Locks access to the configuration preferences.
230    ///
231    /// This function obtains exclusive access to the configuration
232    /// preferences.  Clients attempting to obtain exclusive access
233    /// to the preferences will either receive a kSCStatusPrefsBusy
234    /// error or block waiting for the lock to be released.
235    ///
236    /// Parameter `prefs`: The preferences session.
237    ///
238    /// Parameter `wait`: A boolean flag indicating whether the calling process
239    /// should block waiting for another process to complete its update
240    /// operation and release its lock.
241    ///
242    /// Returns: Returns TRUE if the lock was obtained;
243    /// FALSE if an error occurred.
244    #[doc(alias = "SCPreferencesLock")]
245    #[inline]
246    pub fn lock(&self, wait: bool) -> bool {
247        extern "C-unwind" {
248            fn SCPreferencesLock(prefs: &SCPreferences, wait: Boolean) -> Boolean;
249        }
250        let ret = unsafe { SCPreferencesLock(self, wait as _) };
251        ret != 0
252    }
253
254    /// Commits changes made to the configuration preferences to
255    /// persistent storage.
256    ///
257    /// This function commits any changes to permanent storage.
258    /// Implicit calls to the SCPreferencesLock and SCPreferencesUnlock
259    /// functions will be made if exclusive access has not already been
260    /// established.
261    ///
262    /// Note: This routine commits changes to persistent storage.
263    /// Call the SCPreferencesApplyChanges function to apply the
264    /// changes to the running system.
265    ///
266    /// Parameter `prefs`: The preferences session.
267    ///
268    /// Returns: Returns TRUE if the lock was obtained;
269    /// FALSE if an error occurred.
270    #[doc(alias = "SCPreferencesCommitChanges")]
271    #[inline]
272    pub fn commit_changes(&self) -> bool {
273        extern "C-unwind" {
274            fn SCPreferencesCommitChanges(prefs: &SCPreferences) -> Boolean;
275        }
276        let ret = unsafe { SCPreferencesCommitChanges(self) };
277        ret != 0
278    }
279
280    /// Requests that the currently stored configuration
281    /// preferences be applied to the active configuration.
282    ///
283    /// Parameter `prefs`: The preferences session.
284    ///
285    /// Returns: Returns TRUE if the lock was obtained;
286    /// FALSE if an error occurred.
287    #[doc(alias = "SCPreferencesApplyChanges")]
288    #[inline]
289    pub fn apply_changes(&self) -> bool {
290        extern "C-unwind" {
291            fn SCPreferencesApplyChanges(prefs: &SCPreferences) -> Boolean;
292        }
293        let ret = unsafe { SCPreferencesApplyChanges(self) };
294        ret != 0
295    }
296
297    /// Releases exclusive access to the configuration preferences.
298    ///
299    /// This function releases the exclusive access lock to the
300    /// preferences.  Other clients will be now be able to establish
301    /// exclusive access to the preferences.
302    ///
303    /// Parameter `prefs`: The preferences session.
304    ///
305    /// Returns: Returns TRUE if the lock was obtained;
306    /// FALSE if an error occurred.
307    #[doc(alias = "SCPreferencesUnlock")]
308    #[inline]
309    pub fn unlock(&self) -> bool {
310        extern "C-unwind" {
311            fn SCPreferencesUnlock(prefs: &SCPreferences) -> Boolean;
312        }
313        let ret = unsafe { SCPreferencesUnlock(self) };
314        ret != 0
315    }
316
317    /// Returns a sequence of bytes that can be used to determine
318    /// if the saved configuration preferences have changed.
319    ///
320    /// Parameter `prefs`: The preferences session.
321    ///
322    /// Returns: Returns a CFDataRef that reflects the signature of the configuration
323    /// preferences at the time of the call to the SCPreferencesCreate function.
324    #[doc(alias = "SCPreferencesGetSignature")]
325    #[inline]
326    pub fn signature(&self) -> Option<CFRetained<CFData>> {
327        extern "C-unwind" {
328            fn SCPreferencesGetSignature(prefs: &SCPreferences) -> Option<NonNull<CFData>>;
329        }
330        let ret = unsafe { SCPreferencesGetSignature(self) };
331        ret.map(|ret| unsafe { CFRetained::retain(ret) })
332    }
333
334    /// Returns an array of currently defined preference keys.
335    ///
336    /// Parameter `prefs`: The preferences session.
337    ///
338    /// Returns: Returns the list of keys.
339    /// You must release the returned value.
340    #[doc(alias = "SCPreferencesCopyKeyList")]
341    #[inline]
342    pub fn key_list(&self) -> Option<CFRetained<CFArray>> {
343        extern "C-unwind" {
344            fn SCPreferencesCopyKeyList(prefs: &SCPreferences) -> Option<NonNull<CFArray>>;
345        }
346        let ret = unsafe { SCPreferencesCopyKeyList(self) };
347        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
348    }
349
350    /// Returns the data associated with a preference key.
351    ///
352    /// This function retrieves data associated with the specified
353    /// key.
354    ///
355    /// Note: To avoid inadvertantly reading stale data, first call
356    /// the SCPreferencesLock function.
357    ///
358    /// Parameter `prefs`: The preferences session.
359    ///
360    /// Parameter `key`: The preference key to be returned.
361    ///
362    /// Returns: Returns the value associated with the specified preference key;
363    /// NULL if no value was located.
364    #[doc(alias = "SCPreferencesGetValue")]
365    #[inline]
366    pub fn value(&self, key: &CFString) -> Option<CFRetained<CFPropertyList>> {
367        extern "C-unwind" {
368            fn SCPreferencesGetValue(
369                prefs: &SCPreferences,
370                key: &CFString,
371            ) -> Option<NonNull<CFPropertyList>>;
372        }
373        let ret = unsafe { SCPreferencesGetValue(self, key) };
374        ret.map(|ret| unsafe { CFRetained::retain(ret) })
375    }
376
377    /// Adds data for a preference key.
378    ///
379    /// This function associates new data with the specified key.
380    /// To commit these changes to permanent storage, a call must
381    /// be made to the SCPreferencesCommitChanges function.
382    ///
383    /// Parameter `prefs`: The preferences session.
384    ///
385    /// Parameter `key`: The preference key to be updated.
386    ///
387    /// Parameter `value`: The CFPropertyListRef object containing the
388    /// value to be associated with the specified preference key.
389    ///
390    /// Returns: Returns TRUE if the value was added;
391    /// FALSE if the key already exists or
392    /// if an error occurred.
393    ///
394    /// # Safety
395    ///
396    /// `value` should be of the correct type.
397    #[doc(alias = "SCPreferencesAddValue")]
398    #[inline]
399    pub unsafe fn add_value(&self, key: &CFString, value: &CFPropertyList) -> bool {
400        extern "C-unwind" {
401            fn SCPreferencesAddValue(
402                prefs: &SCPreferences,
403                key: &CFString,
404                value: &CFPropertyList,
405            ) -> Boolean;
406        }
407        let ret = unsafe { SCPreferencesAddValue(self, key, value) };
408        ret != 0
409    }
410
411    /// Updates the data associated with a preference key.
412    ///
413    /// This function adds or replaces the value associated with the
414    /// specified key.  To commit these changes to permanent storage
415    /// a call must be made to the SCPreferencesCommitChanges function.
416    ///
417    /// Parameter `prefs`: The preferences session.
418    ///
419    /// Parameter `key`: The preference key to be updated.
420    ///
421    /// Parameter `value`: The CFPropertyListRef object containing the
422    /// data to be associated with the specified preference key.
423    ///
424    /// Returns: Returns TRUE if the value was set;
425    /// FALSE if an error occurred.
426    ///
427    /// # Safety
428    ///
429    /// `value` should be of the correct type.
430    #[doc(alias = "SCPreferencesSetValue")]
431    #[inline]
432    pub unsafe fn set_value(&self, key: &CFString, value: &CFPropertyList) -> bool {
433        extern "C-unwind" {
434            fn SCPreferencesSetValue(
435                prefs: &SCPreferences,
436                key: &CFString,
437                value: &CFPropertyList,
438            ) -> Boolean;
439        }
440        let ret = unsafe { SCPreferencesSetValue(self, key, value) };
441        ret != 0
442    }
443
444    /// Removes the data associated with a preference key.
445    ///
446    /// This function removes the data associated with the specified
447    /// key.  To commit these changes to permanent storage a call must
448    /// be made to the SCPreferencesCommitChanges function.
449    ///
450    /// Parameter `prefs`: The preferences session.
451    ///
452    /// Parameter `key`: The preference key to be removed.
453    ///
454    /// Returns: Returns TRUE if the value was removed;
455    /// FALSE if the key did not exist or if an error occurred.
456    #[doc(alias = "SCPreferencesRemoveValue")]
457    #[inline]
458    pub fn remove_value(&self, key: &CFString) -> bool {
459        extern "C-unwind" {
460            fn SCPreferencesRemoveValue(prefs: &SCPreferences, key: &CFString) -> Boolean;
461        }
462        let ret = unsafe { SCPreferencesRemoveValue(self, key) };
463        ret != 0
464    }
465
466    /// Assigns a callback to a preferences session.  The function
467    /// is called when the changes to the preferences have been
468    /// committed or applied.
469    ///
470    /// Parameter `prefs`: The preferences session.
471    ///
472    /// Parameter `callout`: The function to be called when the preferences have
473    /// been changed or applied.
474    /// If NULL, the current callback is removed.
475    ///
476    /// Parameter `context`: The SCPreferencesContext associated with
477    /// the callout.
478    ///
479    /// Returns: Returns TRUE if the notification client was successfully set.
480    ///
481    /// # Safety
482    ///
483    /// - `callout` must be implemented correctly.
484    /// - `context` must be a valid pointer or null.
485    #[doc(alias = "SCPreferencesSetCallback")]
486    #[inline]
487    pub unsafe fn set_callback(
488        &self,
489        callout: SCPreferencesCallBack,
490        context: *mut SCPreferencesContext,
491    ) -> bool {
492        extern "C-unwind" {
493            fn SCPreferencesSetCallback(
494                prefs: &SCPreferences,
495                callout: SCPreferencesCallBack,
496                context: *mut SCPreferencesContext,
497            ) -> Boolean;
498        }
499        let ret = unsafe { SCPreferencesSetCallback(self, callout, context) };
500        ret != 0
501    }
502
503    /// Schedule commit and apply notifications for the specified
504    /// preferences session using the specified run loop and mode.
505    ///
506    /// Parameter `prefs`: The preferences session.
507    ///
508    /// Parameter `runLoop`: A reference to a run loop on which the notification
509    /// should be scheduled.
510    /// Must be non-NULL.
511    ///
512    /// Parameter `runLoopMode`: The mode on which to schedule the notification.
513    /// Must be non-NULL.
514    ///
515    /// Returns: Returns TRUE if the notifications are successfully scheduled;
516    /// FALSE otherwise.
517    #[doc(alias = "SCPreferencesScheduleWithRunLoop")]
518    #[inline]
519    pub fn schedule_with_run_loop(&self, run_loop: &CFRunLoop, run_loop_mode: &CFString) -> bool {
520        extern "C-unwind" {
521            fn SCPreferencesScheduleWithRunLoop(
522                prefs: &SCPreferences,
523                run_loop: &CFRunLoop,
524                run_loop_mode: &CFString,
525            ) -> Boolean;
526        }
527        let ret = unsafe { SCPreferencesScheduleWithRunLoop(self, run_loop, run_loop_mode) };
528        ret != 0
529    }
530
531    /// Unschedule commit and apply notifications for the specified
532    /// preferences session from the specified run loop and mode.
533    ///
534    /// Parameter `prefs`: The preferences session.
535    ///
536    /// Parameter `runLoop`: A reference to a run loop from which the notification
537    /// should be unscheduled.
538    /// Must be non-NULL.
539    ///
540    /// Parameter `runLoopMode`: The mode on which to unschedule the notification.
541    /// Must be non-NULL.
542    ///
543    /// Returns: Returns TRUE if the notifications are successfully unscheduled;
544    /// FALSE otherwise.
545    #[doc(alias = "SCPreferencesUnscheduleFromRunLoop")]
546    #[inline]
547    pub fn unschedule_from_run_loop(&self, run_loop: &CFRunLoop, run_loop_mode: &CFString) -> bool {
548        extern "C-unwind" {
549            fn SCPreferencesUnscheduleFromRunLoop(
550                prefs: &SCPreferences,
551                run_loop: &CFRunLoop,
552                run_loop_mode: &CFString,
553            ) -> Boolean;
554        }
555        let ret = unsafe { SCPreferencesUnscheduleFromRunLoop(self, run_loop, run_loop_mode) };
556        ret != 0
557    }
558
559    /// Schedule commit and apply notifications for the specified
560    /// preferences session.
561    ///
562    /// Parameter `prefs`: The preferences session.
563    ///
564    /// Parameter `queue`: The dispatch queue to run the callback function on.
565    ///
566    /// Returns: Returns TRUE if the notifications are successfully scheduled;
567    /// FALSE otherwise.
568    ///
569    /// # Safety
570    ///
571    /// `queue` possibly has additional threading requirements.
572    #[doc(alias = "SCPreferencesSetDispatchQueue")]
573    #[cfg(feature = "dispatch2")]
574    #[inline]
575    pub unsafe fn set_dispatch_queue(&self, queue: Option<&DispatchQueue>) -> bool {
576        extern "C-unwind" {
577            fn SCPreferencesSetDispatchQueue(
578                prefs: &SCPreferences,
579                queue: Option<&DispatchQueue>,
580            ) -> Boolean;
581        }
582        let ret = unsafe { SCPreferencesSetDispatchQueue(self, queue) };
583        ret != 0
584    }
585
586    /// Synchronizes accessed preferences with committed changes.
587    ///
588    /// Any references to preference values returned by calls to the
589    /// SCPreferencesGetValue function are no longer valid unless they
590    /// were explicitly retained or copied.  Any preference values
591    /// that were updated (add, set, remove) but not committed will
592    /// be discarded.
593    ///
594    /// Parameter `prefs`: The preferences session.
595    #[doc(alias = "SCPreferencesSynchronize")]
596    #[inline]
597    pub fn synchronize(&self) {
598        extern "C-unwind" {
599            fn SCPreferencesSynchronize(prefs: &SCPreferences);
600        }
601        unsafe { SCPreferencesSynchronize(self) }
602    }
603}
604
605#[deprecated = "renamed to `SCPreferences::new`"]
606#[inline]
607pub extern "C-unwind" fn SCPreferencesCreate(
608    allocator: Option<&CFAllocator>,
609    name: &CFString,
610    prefs_id: Option<&CFString>,
611) -> Option<CFRetained<SCPreferences>> {
612    extern "C-unwind" {
613        fn SCPreferencesCreate(
614            allocator: Option<&CFAllocator>,
615            name: &CFString,
616            prefs_id: Option<&CFString>,
617        ) -> Option<NonNull<SCPreferences>>;
618    }
619    let ret = unsafe { SCPreferencesCreate(allocator, name, prefs_id) };
620    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
621}
622
623#[cfg(feature = "objc2-security")]
624#[deprecated = "renamed to `SCPreferences::with_authorization`"]
625#[inline]
626pub unsafe extern "C-unwind" fn SCPreferencesCreateWithAuthorization(
627    allocator: Option<&CFAllocator>,
628    name: &CFString,
629    prefs_id: Option<&CFString>,
630    authorization: AuthorizationRef,
631) -> Option<CFRetained<SCPreferences>> {
632    extern "C-unwind" {
633        fn SCPreferencesCreateWithAuthorization(
634            allocator: Option<&CFAllocator>,
635            name: &CFString,
636            prefs_id: Option<&CFString>,
637            authorization: AuthorizationRef,
638        ) -> Option<NonNull<SCPreferences>>;
639    }
640    let ret =
641        unsafe { SCPreferencesCreateWithAuthorization(allocator, name, prefs_id, authorization) };
642    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
643}
644
645#[deprecated = "renamed to `SCPreferences::lock`"]
646#[inline]
647pub extern "C-unwind" fn SCPreferencesLock(prefs: &SCPreferences, wait: bool) -> bool {
648    extern "C-unwind" {
649        fn SCPreferencesLock(prefs: &SCPreferences, wait: Boolean) -> Boolean;
650    }
651    let ret = unsafe { SCPreferencesLock(prefs, wait as _) };
652    ret != 0
653}
654
655#[deprecated = "renamed to `SCPreferences::commit_changes`"]
656#[inline]
657pub extern "C-unwind" fn SCPreferencesCommitChanges(prefs: &SCPreferences) -> bool {
658    extern "C-unwind" {
659        fn SCPreferencesCommitChanges(prefs: &SCPreferences) -> Boolean;
660    }
661    let ret = unsafe { SCPreferencesCommitChanges(prefs) };
662    ret != 0
663}
664
665#[deprecated = "renamed to `SCPreferences::apply_changes`"]
666#[inline]
667pub extern "C-unwind" fn SCPreferencesApplyChanges(prefs: &SCPreferences) -> bool {
668    extern "C-unwind" {
669        fn SCPreferencesApplyChanges(prefs: &SCPreferences) -> Boolean;
670    }
671    let ret = unsafe { SCPreferencesApplyChanges(prefs) };
672    ret != 0
673}
674
675#[deprecated = "renamed to `SCPreferences::unlock`"]
676#[inline]
677pub extern "C-unwind" fn SCPreferencesUnlock(prefs: &SCPreferences) -> bool {
678    extern "C-unwind" {
679        fn SCPreferencesUnlock(prefs: &SCPreferences) -> Boolean;
680    }
681    let ret = unsafe { SCPreferencesUnlock(prefs) };
682    ret != 0
683}
684
685#[deprecated = "renamed to `SCPreferences::signature`"]
686#[inline]
687pub extern "C-unwind" fn SCPreferencesGetSignature(
688    prefs: &SCPreferences,
689) -> Option<CFRetained<CFData>> {
690    extern "C-unwind" {
691        fn SCPreferencesGetSignature(prefs: &SCPreferences) -> Option<NonNull<CFData>>;
692    }
693    let ret = unsafe { SCPreferencesGetSignature(prefs) };
694    ret.map(|ret| unsafe { CFRetained::retain(ret) })
695}
696
697#[deprecated = "renamed to `SCPreferences::key_list`"]
698#[inline]
699pub extern "C-unwind" fn SCPreferencesCopyKeyList(
700    prefs: &SCPreferences,
701) -> Option<CFRetained<CFArray>> {
702    extern "C-unwind" {
703        fn SCPreferencesCopyKeyList(prefs: &SCPreferences) -> Option<NonNull<CFArray>>;
704    }
705    let ret = unsafe { SCPreferencesCopyKeyList(prefs) };
706    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
707}
708
709#[deprecated = "renamed to `SCPreferences::value`"]
710#[inline]
711pub extern "C-unwind" fn SCPreferencesGetValue(
712    prefs: &SCPreferences,
713    key: &CFString,
714) -> Option<CFRetained<CFPropertyList>> {
715    extern "C-unwind" {
716        fn SCPreferencesGetValue(
717            prefs: &SCPreferences,
718            key: &CFString,
719        ) -> Option<NonNull<CFPropertyList>>;
720    }
721    let ret = unsafe { SCPreferencesGetValue(prefs, key) };
722    ret.map(|ret| unsafe { CFRetained::retain(ret) })
723}
724
725#[deprecated = "renamed to `SCPreferences::add_value`"]
726#[inline]
727pub unsafe extern "C-unwind" fn SCPreferencesAddValue(
728    prefs: &SCPreferences,
729    key: &CFString,
730    value: &CFPropertyList,
731) -> bool {
732    extern "C-unwind" {
733        fn SCPreferencesAddValue(
734            prefs: &SCPreferences,
735            key: &CFString,
736            value: &CFPropertyList,
737        ) -> Boolean;
738    }
739    let ret = unsafe { SCPreferencesAddValue(prefs, key, value) };
740    ret != 0
741}
742
743#[deprecated = "renamed to `SCPreferences::set_value`"]
744#[inline]
745pub unsafe extern "C-unwind" fn SCPreferencesSetValue(
746    prefs: &SCPreferences,
747    key: &CFString,
748    value: &CFPropertyList,
749) -> bool {
750    extern "C-unwind" {
751        fn SCPreferencesSetValue(
752            prefs: &SCPreferences,
753            key: &CFString,
754            value: &CFPropertyList,
755        ) -> Boolean;
756    }
757    let ret = unsafe { SCPreferencesSetValue(prefs, key, value) };
758    ret != 0
759}
760
761#[deprecated = "renamed to `SCPreferences::remove_value`"]
762#[inline]
763pub extern "C-unwind" fn SCPreferencesRemoveValue(prefs: &SCPreferences, key: &CFString) -> bool {
764    extern "C-unwind" {
765        fn SCPreferencesRemoveValue(prefs: &SCPreferences, key: &CFString) -> Boolean;
766    }
767    let ret = unsafe { SCPreferencesRemoveValue(prefs, key) };
768    ret != 0
769}
770
771#[deprecated = "renamed to `SCPreferences::set_callback`"]
772#[inline]
773pub unsafe extern "C-unwind" fn SCPreferencesSetCallback(
774    prefs: &SCPreferences,
775    callout: SCPreferencesCallBack,
776    context: *mut SCPreferencesContext,
777) -> bool {
778    extern "C-unwind" {
779        fn SCPreferencesSetCallback(
780            prefs: &SCPreferences,
781            callout: SCPreferencesCallBack,
782            context: *mut SCPreferencesContext,
783        ) -> Boolean;
784    }
785    let ret = unsafe { SCPreferencesSetCallback(prefs, callout, context) };
786    ret != 0
787}
788
789#[deprecated = "renamed to `SCPreferences::schedule_with_run_loop`"]
790#[inline]
791pub extern "C-unwind" fn SCPreferencesScheduleWithRunLoop(
792    prefs: &SCPreferences,
793    run_loop: &CFRunLoop,
794    run_loop_mode: &CFString,
795) -> bool {
796    extern "C-unwind" {
797        fn SCPreferencesScheduleWithRunLoop(
798            prefs: &SCPreferences,
799            run_loop: &CFRunLoop,
800            run_loop_mode: &CFString,
801        ) -> Boolean;
802    }
803    let ret = unsafe { SCPreferencesScheduleWithRunLoop(prefs, run_loop, run_loop_mode) };
804    ret != 0
805}
806
807#[deprecated = "renamed to `SCPreferences::unschedule_from_run_loop`"]
808#[inline]
809pub extern "C-unwind" fn SCPreferencesUnscheduleFromRunLoop(
810    prefs: &SCPreferences,
811    run_loop: &CFRunLoop,
812    run_loop_mode: &CFString,
813) -> bool {
814    extern "C-unwind" {
815        fn SCPreferencesUnscheduleFromRunLoop(
816            prefs: &SCPreferences,
817            run_loop: &CFRunLoop,
818            run_loop_mode: &CFString,
819        ) -> Boolean;
820    }
821    let ret = unsafe { SCPreferencesUnscheduleFromRunLoop(prefs, run_loop, run_loop_mode) };
822    ret != 0
823}
824
825#[cfg(feature = "dispatch2")]
826#[deprecated = "renamed to `SCPreferences::set_dispatch_queue`"]
827#[inline]
828pub unsafe extern "C-unwind" fn SCPreferencesSetDispatchQueue(
829    prefs: &SCPreferences,
830    queue: Option<&DispatchQueue>,
831) -> bool {
832    extern "C-unwind" {
833        fn SCPreferencesSetDispatchQueue(
834            prefs: &SCPreferences,
835            queue: Option<&DispatchQueue>,
836        ) -> Boolean;
837    }
838    let ret = unsafe { SCPreferencesSetDispatchQueue(prefs, queue) };
839    ret != 0
840}
841
842#[deprecated = "renamed to `SCPreferences::synchronize`"]
843#[inline]
844pub extern "C-unwind" fn SCPreferencesSynchronize(prefs: &SCPreferences) {
845    extern "C-unwind" {
846        fn SCPreferencesSynchronize(prefs: &SCPreferences);
847    }
848    unsafe { SCPreferencesSynchronize(prefs) }
849}