// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

#[cfg(feature = "v23_7")]
#[cfg_attr(docsrs, doc(cfg(feature = "v23_7")))]
use crate::CertificateInfo;
use crate::{Backend, ffi};
use glib::translate::*;

#[cfg(feature = "v23_7")]
#[cfg_attr(docsrs, doc(cfg(feature = "v23_7")))]
#[doc(alias = "poppler_get_available_signing_certificates")]
#[doc(alias = "get_available_signing_certificates")]
pub fn available_signing_certificates() -> Vec<CertificateInfo> {
    unsafe {
        FromGlibPtrContainer::from_glib_full(ffi::poppler_get_available_signing_certificates())
    }
}

#[doc(alias = "poppler_get_backend")]
#[doc(alias = "get_backend")]
pub fn backend() -> Backend {
    unsafe { from_glib(ffi::poppler_get_backend()) }
}

#[cfg(feature = "v23_7")]
#[cfg_attr(docsrs, doc(cfg(feature = "v23_7")))]
#[doc(alias = "poppler_get_certificate_info_by_id")]
#[doc(alias = "get_certificate_info_by_id")]
pub fn certificate_info_by_id(id: &str) -> Option<CertificateInfo> {
    unsafe { from_glib_full(ffi::poppler_get_certificate_info_by_id(id.to_glib_none().0)) }
}

#[cfg(feature = "v23_7")]
#[cfg_attr(docsrs, doc(cfg(feature = "v23_7")))]
#[doc(alias = "poppler_get_nss_dir")]
#[doc(alias = "get_nss_dir")]
pub fn nss_dir() -> Option<glib::GString> {
    unsafe { from_glib_full(ffi::poppler_get_nss_dir()) }
}

#[doc(alias = "poppler_get_version")]
#[doc(alias = "get_version")]
pub fn version() -> Option<glib::GString> {
    unsafe { from_glib_none(ffi::poppler_get_version()) }
}

#[cfg(feature = "v0_73")]
#[cfg_attr(docsrs, doc(cfg(feature = "v0_73")))]
#[doc(alias = "poppler_named_dest_from_bytestring")]
pub fn named_dest_from_bytestring(data: &[u8]) -> Option<glib::GString> {
    let length = data.len() as _;
    unsafe {
        from_glib_full(ffi::poppler_named_dest_from_bytestring(
            data.to_glib_none().0,
            length,
        ))
    }
}

#[cfg(feature = "v0_73")]
#[cfg_attr(docsrs, doc(cfg(feature = "v0_73")))]
#[doc(alias = "poppler_named_dest_to_bytestring")]
pub fn named_dest_to_bytestring(name: &str) -> Vec<u8> {
    unsafe {
        let mut length = std::mem::MaybeUninit::uninit();
        let ret = FromGlibContainer::from_glib_full_num(
            ffi::poppler_named_dest_to_bytestring(name.to_glib_none().0, length.as_mut_ptr()),
            length.assume_init() as _,
        );
        ret
    }
}

#[cfg(feature = "v23_7")]
#[cfg_attr(docsrs, doc(cfg(feature = "v23_7")))]
#[doc(alias = "poppler_set_nss_dir")]
pub fn set_nss_dir(path: &str) {
    unsafe {
        ffi::poppler_set_nss_dir(path.to_glib_none().0);
    }
}

//#[cfg(feature = "v23_7")]
//#[cfg_attr(docsrs, doc(cfg(feature = "v23_7")))]
//#[doc(alias = "poppler_set_nss_password_callback")]
//pub fn set_nss_password_callback<P: FnMut() -> String>(func: P) {
//    unsafe { TODO: call ffi:poppler_set_nss_password_callback() }
//}
