//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;

use crate::*;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencesanyapplication?language=objc)
    #[cfg(feature = "CFBase")]
    pub static kCFPreferencesAnyApplication: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencescurrentapplication?language=objc)
    #[cfg(feature = "CFBase")]
    pub static kCFPreferencesCurrentApplication: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencesanyhost?language=objc)
    #[cfg(feature = "CFBase")]
    pub static kCFPreferencesAnyHost: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencescurrenthost?language=objc)
    #[cfg(feature = "CFBase")]
    pub static kCFPreferencesCurrentHost: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencesanyuser?language=objc)
    #[cfg(feature = "CFBase")]
    pub static kCFPreferencesAnyUser: &'static CFString;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfpreferencescurrentuser?language=objc)
    #[cfg(feature = "CFBase")]
    pub static kCFPreferencesCurrentUser: &'static CFString;
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFPreferencesCopyAppValue(
    key: &CFString,
    application_id: &CFString,
) -> Option<CFRetained<CFPropertyList>> {
    extern "C-unwind" {
        fn CFPreferencesCopyAppValue(
            key: &CFString,
            application_id: &CFString,
        ) -> Option<NonNull<CFPropertyList>>;
    }
    let ret = unsafe { CFPreferencesCopyAppValue(key, application_id) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFPreferencesGetAppBooleanValue(
    key: &CFString,
    application_id: &CFString,
    key_exists_and_has_valid_format: *mut Boolean,
) -> bool {
    extern "C-unwind" {
        fn CFPreferencesGetAppBooleanValue(
            key: &CFString,
            application_id: &CFString,
            key_exists_and_has_valid_format: *mut Boolean,
        ) -> Boolean;
    }
    let ret = unsafe {
        CFPreferencesGetAppBooleanValue(key, application_id, key_exists_and_has_valid_format)
    };
    ret != 0
}

extern "C-unwind" {
    #[cfg(feature = "CFBase")]
    pub fn CFPreferencesGetAppIntegerValue(
        key: &CFString,
        application_id: &CFString,
        key_exists_and_has_valid_format: *mut Boolean,
    ) -> CFIndex;
}

extern "C-unwind" {
    #[cfg(feature = "CFBase")]
    pub fn CFPreferencesSetAppValue(
        key: &CFString,
        value: Option<&CFPropertyList>,
        application_id: &CFString,
    );
}

extern "C-unwind" {
    #[cfg(feature = "CFBase")]
    pub fn CFPreferencesAddSuitePreferencesToApp(application_id: &CFString, suite_id: &CFString);
}

extern "C-unwind" {
    #[cfg(feature = "CFBase")]
    pub fn CFPreferencesRemoveSuitePreferencesFromApp(
        application_id: &CFString,
        suite_id: &CFString,
    );
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFPreferencesAppSynchronize(application_id: &CFString) -> bool {
    extern "C-unwind" {
        fn CFPreferencesAppSynchronize(application_id: &CFString) -> Boolean;
    }
    let ret = unsafe { CFPreferencesAppSynchronize(application_id) };
    ret != 0
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFPreferencesCopyValue(
    key: &CFString,
    application_id: &CFString,
    user_name: &CFString,
    host_name: &CFString,
) -> Option<CFRetained<CFPropertyList>> {
    extern "C-unwind" {
        fn CFPreferencesCopyValue(
            key: &CFString,
            application_id: &CFString,
            user_name: &CFString,
            host_name: &CFString,
        ) -> Option<NonNull<CFPropertyList>>;
    }
    let ret = unsafe { CFPreferencesCopyValue(key, application_id, user_name, host_name) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(all(feature = "CFArray", feature = "CFBase", feature = "CFDictionary"))]
#[inline]
pub unsafe extern "C-unwind" fn CFPreferencesCopyMultiple(
    keys_to_fetch: Option<&CFArray>,
    application_id: &CFString,
    user_name: &CFString,
    host_name: &CFString,
) -> CFRetained<CFDictionary> {
    extern "C-unwind" {
        fn CFPreferencesCopyMultiple(
            keys_to_fetch: Option<&CFArray>,
            application_id: &CFString,
            user_name: &CFString,
            host_name: &CFString,
        ) -> Option<NonNull<CFDictionary>>;
    }
    let ret =
        unsafe { CFPreferencesCopyMultiple(keys_to_fetch, application_id, user_name, host_name) };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}

extern "C-unwind" {
    #[cfg(feature = "CFBase")]
    pub fn CFPreferencesSetValue(
        key: &CFString,
        value: Option<&CFPropertyList>,
        application_id: &CFString,
        user_name: &CFString,
        host_name: &CFString,
    );
}

extern "C-unwind" {
    #[cfg(all(feature = "CFArray", feature = "CFBase", feature = "CFDictionary"))]
    pub fn CFPreferencesSetMultiple(
        keys_to_set: Option<&CFDictionary>,
        keys_to_remove: Option<&CFArray>,
        application_id: &CFString,
        user_name: &CFString,
        host_name: &CFString,
    );
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFPreferencesSynchronize(
    application_id: &CFString,
    user_name: &CFString,
    host_name: &CFString,
) -> bool {
    extern "C-unwind" {
        fn CFPreferencesSynchronize(
            application_id: &CFString,
            user_name: &CFString,
            host_name: &CFString,
        ) -> Boolean;
    }
    let ret = unsafe { CFPreferencesSynchronize(application_id, user_name, host_name) };
    ret != 0
}

#[cfg(all(feature = "CFArray", feature = "CFBase"))]
#[deprecated = "Unsupported API"]
#[inline]
pub unsafe extern "C-unwind" fn CFPreferencesCopyApplicationList(
    user_name: &CFString,
    host_name: &CFString,
) -> Option<CFRetained<CFArray>> {
    extern "C-unwind" {
        fn CFPreferencesCopyApplicationList(
            user_name: &CFString,
            host_name: &CFString,
        ) -> Option<NonNull<CFArray>>;
    }
    let ret = unsafe { CFPreferencesCopyApplicationList(user_name, host_name) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(all(feature = "CFArray", feature = "CFBase"))]
#[inline]
pub unsafe extern "C-unwind" fn CFPreferencesCopyKeyList(
    application_id: &CFString,
    user_name: &CFString,
    host_name: &CFString,
) -> Option<CFRetained<CFArray>> {
    extern "C-unwind" {
        fn CFPreferencesCopyKeyList(
            application_id: &CFString,
            user_name: &CFString,
            host_name: &CFString,
        ) -> Option<NonNull<CFArray>>;
    }
    let ret = unsafe { CFPreferencesCopyKeyList(application_id, user_name, host_name) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CFBase")]
#[inline]
pub unsafe extern "C-unwind" fn CFPreferencesAppValueIsForced(
    key: &CFString,
    application_id: &CFString,
) -> bool {
    extern "C-unwind" {
        fn CFPreferencesAppValueIsForced(key: &CFString, application_id: &CFString) -> Boolean;
    }
    let ret = unsafe { CFPreferencesAppValueIsForced(key, application_id) };
    ret != 0
}
