From 62263e0e619625f2c5dd0b4364b43bd4fefc8ccd Mon Sep 17 00:00:00 2001 From: Vika Date: Thu, 30 Jan 2025 08:49:22 +0300 Subject: libsecret: 0.6.0 (private fork) -> 0.7.0 (upstream) libsecret is now maintained again! No need for a private fork. --- libsecret/src/auto/backend.rs | 92 --- libsecret/src/auto/collection.rs | 742 -------------------- libsecret/src/auto/constants.rs | 16 - libsecret/src/auto/enums.rs | 462 ------------ libsecret/src/auto/flags.rs | 591 ---------------- libsecret/src/auto/functions.rs | 41 -- libsecret/src/auto/item.rs | 556 --------------- libsecret/src/auto/mod.rs | 75 -- libsecret/src/auto/prompt.rs | 76 -- libsecret/src/auto/retrievable.rs | 269 ------- libsecret/src/auto/schema.rs | 15 - libsecret/src/auto/schema_attribute.rs | 15 - libsecret/src/auto/service.rs | 1208 -------------------------------- libsecret/src/auto/versions.txt | 3 - libsecret/src/collection.rs | 267 ------- libsecret/src/enums.rs | 25 - libsecret/src/functions.rs | 741 -------------------- libsecret/src/hashtable.rs | 63 -- libsecret/src/item.rs | 314 --------- libsecret/src/lib.rs | 123 ---- libsecret/src/prompt.rs | 100 --- libsecret/src/retrievable.rs | 20 - libsecret/src/schema.rs | 37 - libsecret/src/schema_attribute.rs | 12 - libsecret/src/service.rs | 1147 ------------------------------ libsecret/src/value.rs | 67 -- 26 files changed, 7077 deletions(-) delete mode 100644 libsecret/src/auto/backend.rs delete mode 100644 libsecret/src/auto/collection.rs delete mode 100644 libsecret/src/auto/constants.rs delete mode 100644 libsecret/src/auto/enums.rs delete mode 100644 libsecret/src/auto/flags.rs delete mode 100644 libsecret/src/auto/functions.rs delete mode 100644 libsecret/src/auto/item.rs delete mode 100644 libsecret/src/auto/mod.rs delete mode 100644 libsecret/src/auto/prompt.rs delete mode 100644 libsecret/src/auto/retrievable.rs delete mode 100644 libsecret/src/auto/schema.rs delete mode 100644 libsecret/src/auto/schema_attribute.rs delete mode 100644 libsecret/src/auto/service.rs delete mode 100644 libsecret/src/auto/versions.txt delete mode 100644 libsecret/src/collection.rs delete mode 100644 libsecret/src/enums.rs delete mode 100644 libsecret/src/functions.rs delete mode 100644 libsecret/src/hashtable.rs delete mode 100644 libsecret/src/item.rs delete mode 100644 libsecret/src/lib.rs delete mode 100644 libsecret/src/prompt.rs delete mode 100644 libsecret/src/retrievable.rs delete mode 100644 libsecret/src/schema.rs delete mode 100644 libsecret/src/schema_attribute.rs delete mode 100644 libsecret/src/service.rs delete mode 100644 libsecret/src/value.rs (limited to 'libsecret/src') diff --git a/libsecret/src/auto/backend.rs b/libsecret/src/auto/backend.rs deleted file mode 100644 index bba5bf0..0000000 --- a/libsecret/src/auto/backend.rs +++ /dev/null @@ -1,92 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -use crate::{BackendFlags, ServiceFlags}; -use glib::{prelude::*, translate::*}; -use std::{boxed::Box as Box_, pin::Pin}; - -glib::wrapper! { - #[doc(alias = "SecretBackend")] - pub struct Backend(Interface); - - match fn { - type_ => || ffi::secret_backend_get_type(), - } -} - -impl Backend { - pub const NONE: Option<&'static Backend> = None; - - #[doc(alias = "secret_backend_get")] - pub fn get) + 'static>( - flags: BackendFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn get_trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_backend_get_finish(res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = get_trampoline::

; - unsafe { - ffi::secret_backend_get( - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - pub fn get_future( - flags: BackendFlags, - ) -> Pin> + 'static>> { - Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { - Self::get(flags, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } -} - -mod sealed { - pub trait Sealed {} - impl> Sealed for T {} -} - -pub trait BackendExt: IsA + sealed::Sealed + 'static { - #[cfg(feature = "v0_19")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] - fn flags(&self) -> ServiceFlags { - ObjectExt::property(self.as_ref(), "flags") - } -} - -impl> BackendExt for O {} diff --git a/libsecret/src/auto/collection.rs b/libsecret/src/auto/collection.rs deleted file mode 100644 index 8c91b65..0000000 --- a/libsecret/src/auto/collection.rs +++ /dev/null @@ -1,742 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -use crate::{CollectionCreateFlags, CollectionFlags, Item, Service}; -use glib::{ - prelude::*, - signal::{connect_raw, SignalHandlerId}, - translate::*, -}; -use std::{boxed::Box as Box_, pin::Pin}; - -glib::wrapper! { - #[doc(alias = "SecretCollection")] - pub struct Collection(Object) @extends gio::DBusProxy, @implements gio::DBusInterface, gio::Initable; - - match fn { - type_ => || ffi::secret_collection_get_type(), - } -} - -impl Collection { - pub const NONE: Option<&'static Collection> = None; - - #[doc(alias = "secret_collection_new_for_dbus_path_sync")] - #[doc(alias = "new_for_dbus_path_sync")] - pub fn for_dbus_path_sync( - service: Option<&impl IsA>, - collection_path: &str, - flags: CollectionFlags, - cancellable: Option<&impl IsA>, - ) -> Result { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_collection_new_for_dbus_path_sync( - service.map(|p| p.as_ref()).to_glib_none().0, - collection_path.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_collection_create")] - pub fn create) + 'static>( - service: Option<&impl IsA>, - label: &str, - alias: Option<&str>, - flags: CollectionCreateFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn create_trampoline< - P: FnOnce(Result) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_collection_create_finish(res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = create_trampoline::

; - unsafe { - ffi::secret_collection_create( - service.map(|p| p.as_ref()).to_glib_none().0, - label.to_glib_none().0, - alias.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - pub fn create_future( - service: Option<&(impl IsA + Clone + 'static)>, - label: &str, - alias: Option<&str>, - flags: CollectionCreateFlags, - ) -> Pin> + 'static>> - { - let service = service.map(ToOwned::to_owned); - let label = String::from(label); - let alias = alias.map(ToOwned::to_owned); - Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { - Self::create( - service.as_ref().map(::std::borrow::Borrow::borrow), - &label, - alias.as_ref().map(::std::borrow::Borrow::borrow), - flags, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - #[doc(alias = "secret_collection_create_sync")] - pub fn create_sync( - service: Option<&impl IsA>, - label: &str, - alias: Option<&str>, - flags: CollectionCreateFlags, - cancellable: Option<&impl IsA>, - ) -> Result { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_collection_create_sync( - service.map(|p| p.as_ref()).to_glib_none().0, - label.to_glib_none().0, - alias.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_collection_for_alias")] - pub fn for_alias, glib::Error>) + 'static>( - service: Option<&impl IsA>, - alias: &str, - flags: CollectionFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn for_alias_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_collection_for_alias_finish(res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = for_alias_trampoline::

; - unsafe { - ffi::secret_collection_for_alias( - service.map(|p| p.as_ref()).to_glib_none().0, - alias.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - pub fn for_alias_future( - service: Option<&(impl IsA + Clone + 'static)>, - alias: &str, - flags: CollectionFlags, - ) -> Pin< - Box_, glib::Error>> + 'static>, - > { - let service = service.map(ToOwned::to_owned); - let alias = String::from(alias); - Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { - Self::for_alias( - service.as_ref().map(::std::borrow::Borrow::borrow), - &alias, - flags, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - #[doc(alias = "secret_collection_for_alias_sync")] - pub fn for_alias_sync( - service: Option<&impl IsA>, - alias: &str, - flags: CollectionFlags, - cancellable: Option<&impl IsA>, - ) -> Result, glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_collection_for_alias_sync( - service.map(|p| p.as_ref()).to_glib_none().0, - alias.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_collection_new_for_dbus_path")] - pub fn new_for_dbus_path) + 'static>( - service: Option<&impl IsA>, - collection_path: &str, - flags: CollectionFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn new_for_dbus_path_trampoline< - P: FnOnce(Result) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_collection_new_for_dbus_path_finish(res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = new_for_dbus_path_trampoline::

; - unsafe { - ffi::secret_collection_new_for_dbus_path( - service.map(|p| p.as_ref()).to_glib_none().0, - collection_path.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - pub fn new_for_dbus_path_future( - service: Option<&(impl IsA + Clone + 'static)>, - collection_path: &str, - flags: CollectionFlags, - ) -> Pin> + 'static>> - { - let service = service.map(ToOwned::to_owned); - let collection_path = String::from(collection_path); - Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { - Self::new_for_dbus_path( - service.as_ref().map(::std::borrow::Borrow::borrow), - &collection_path, - flags, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } -} - -mod sealed { - pub trait Sealed {} - impl> Sealed for T {} -} - -pub trait CollectionExt: IsA + sealed::Sealed + 'static { - #[doc(alias = "secret_collection_delete")] - fn delete) + 'static>( - &self, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn delete_trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = ffi::secret_collection_delete_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = delete_trampoline::

; - unsafe { - ffi::secret_collection_delete( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn delete_future( - &self, - ) -> Pin> + 'static>> { - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.delete(Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_collection_delete_sync")] - fn delete_sync( - &self, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_collection_delete_sync( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_collection_get_created")] - #[doc(alias = "get_created")] - fn created(&self) -> u64 { - unsafe { ffi::secret_collection_get_created(self.as_ref().to_glib_none().0) } - } - - #[doc(alias = "secret_collection_get_flags")] - #[doc(alias = "get_flags")] - fn flags(&self) -> CollectionFlags { - unsafe { - from_glib(ffi::secret_collection_get_flags( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_collection_get_items")] - #[doc(alias = "get_items")] - fn items(&self) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_full(ffi::secret_collection_get_items( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_collection_get_label")] - #[doc(alias = "get_label")] - fn label(&self) -> glib::GString { - unsafe { - from_glib_full(ffi::secret_collection_get_label( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_collection_get_locked")] - #[doc(alias = "get_locked")] - fn is_locked(&self) -> bool { - unsafe { - from_glib(ffi::secret_collection_get_locked( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_collection_get_modified")] - #[doc(alias = "get_modified")] - fn modified(&self) -> u64 { - unsafe { ffi::secret_collection_get_modified(self.as_ref().to_glib_none().0) } - } - - #[doc(alias = "secret_collection_get_service")] - #[doc(alias = "get_service")] - fn service(&self) -> Service { - unsafe { - from_glib_none(ffi::secret_collection_get_service( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_collection_load_items")] - fn load_items) + 'static>( - &self, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn load_items_trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = - ffi::secret_collection_load_items_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = load_items_trampoline::

; - unsafe { - ffi::secret_collection_load_items( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn load_items_future( - &self, - ) -> Pin> + 'static>> { - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.load_items(Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_collection_load_items_sync")] - fn load_items_sync( - &self, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_collection_load_items_sync( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_collection_refresh")] - fn refresh(&self) { - unsafe { - ffi::secret_collection_refresh(self.as_ref().to_glib_none().0); - } - } - - #[doc(alias = "secret_collection_set_label")] - fn set_label) + 'static>( - &self, - label: &str, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn set_label_trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = - ffi::secret_collection_set_label_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = set_label_trampoline::

; - unsafe { - ffi::secret_collection_set_label( - self.as_ref().to_glib_none().0, - label.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn set_label_future( - &self, - label: &str, - ) -> Pin> + 'static>> { - let label = String::from(label); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.set_label(&label, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_collection_set_label_sync")] - fn set_label_sync( - &self, - label: &str, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_collection_set_label_sync( - self.as_ref().to_glib_none().0, - label.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - fn set_created(&self, created: u64) { - ObjectExt::set_property(self.as_ref(), "created", created) - } - - fn set_modified(&self, modified: u64) { - ObjectExt::set_property(self.as_ref(), "modified", modified) - } - - #[doc(alias = "created")] - fn connect_created_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_created_trampoline, F: Fn(&P) + 'static>( - this: *mut ffi::SecretCollection, - _param_spec: glib::ffi::gpointer, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(Collection::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::created\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( - notify_created_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } - - #[doc(alias = "label")] - fn connect_label_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_label_trampoline, F: Fn(&P) + 'static>( - this: *mut ffi::SecretCollection, - _param_spec: glib::ffi::gpointer, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(Collection::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::label\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( - notify_label_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } - - #[doc(alias = "locked")] - fn connect_locked_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_locked_trampoline, F: Fn(&P) + 'static>( - this: *mut ffi::SecretCollection, - _param_spec: glib::ffi::gpointer, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(Collection::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::locked\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( - notify_locked_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } - - #[doc(alias = "modified")] - fn connect_modified_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_modified_trampoline, F: Fn(&P) + 'static>( - this: *mut ffi::SecretCollection, - _param_spec: glib::ffi::gpointer, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(Collection::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::modified\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( - notify_modified_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } -} - -impl> CollectionExt for O {} diff --git a/libsecret/src/auto/constants.rs b/libsecret/src/auto/constants.rs deleted file mode 100644 index 1086b79..0000000 --- a/libsecret/src/auto/constants.rs +++ /dev/null @@ -1,16 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -use glib::GStr; - -#[doc(alias = "SECRET_BACKEND_EXTENSION_POINT_NAME")] -pub static BACKEND_EXTENSION_POINT_NAME: &GStr = - unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SECRET_BACKEND_EXTENSION_POINT_NAME) }; -#[doc(alias = "SECRET_COLLECTION_DEFAULT")] -pub static COLLECTION_DEFAULT: &GStr = - unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SECRET_COLLECTION_DEFAULT) }; -#[doc(alias = "SECRET_COLLECTION_SESSION")] -pub static COLLECTION_SESSION: &GStr = - unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SECRET_COLLECTION_SESSION) }; diff --git a/libsecret/src/auto/enums.rs b/libsecret/src/auto/enums.rs deleted file mode 100644 index d9cf2ff..0000000 --- a/libsecret/src/auto/enums.rs +++ /dev/null @@ -1,462 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -use glib::{prelude::*, translate::*}; - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] -#[non_exhaustive] -#[doc(alias = "SecretBackendFlags")] -pub enum BackendFlags { - #[doc(alias = "SECRET_BACKEND_NONE")] - None, - #[doc(alias = "SECRET_BACKEND_OPEN_SESSION")] - OpenSession, - #[doc(alias = "SECRET_BACKEND_LOAD_COLLECTIONS")] - LoadCollections, - #[doc(hidden)] - __Unknown(i32), -} - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -#[doc(hidden)] -impl IntoGlib for BackendFlags { - type GlibType = ffi::SecretBackendFlags; - - #[inline] - fn into_glib(self) -> ffi::SecretBackendFlags { - match self { - Self::None => ffi::SECRET_BACKEND_NONE, - Self::OpenSession => ffi::SECRET_BACKEND_OPEN_SESSION, - Self::LoadCollections => ffi::SECRET_BACKEND_LOAD_COLLECTIONS, - Self::__Unknown(value) => value, - } - } -} - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -#[doc(hidden)] -impl FromGlib for BackendFlags { - #[inline] - unsafe fn from_glib(value: ffi::SecretBackendFlags) -> Self { - match value { - ffi::SECRET_BACKEND_NONE => Self::None, - ffi::SECRET_BACKEND_OPEN_SESSION => Self::OpenSession, - ffi::SECRET_BACKEND_LOAD_COLLECTIONS => Self::LoadCollections, - value => Self::__Unknown(value), - } - } -} - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -impl StaticType for BackendFlags { - #[inline] - #[doc(alias = "secret_backend_flags_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::secret_backend_flags_get_type()) } - } -} - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -impl glib::HasParamSpec for BackendFlags { - type ParamSpec = glib::ParamSpecEnum; - type SetValue = Self; - type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder_with_default - } -} - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -impl glib::value::ValueType for BackendFlags { - type Type = Self; -} - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -unsafe impl<'a> glib::value::FromValue<'a> for BackendFlags { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) - } -} - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -impl ToValue for BackendFlags { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -impl From for glib::Value { - #[inline] - fn from(v: BackendFlags) -> Self { - ToValue::to_value(&v) - } -} - -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] -#[non_exhaustive] -#[doc(alias = "SecretError")] -pub enum Error { - #[doc(alias = "SECRET_ERROR_PROTOCOL")] - Protocol, - #[doc(alias = "SECRET_ERROR_IS_LOCKED")] - IsLocked, - #[doc(alias = "SECRET_ERROR_NO_SUCH_OBJECT")] - NoSuchObject, - #[doc(alias = "SECRET_ERROR_ALREADY_EXISTS")] - AlreadyExists, - #[doc(alias = "SECRET_ERROR_INVALID_FILE_FORMAT")] - InvalidFileFormat, - #[cfg(feature = "v0_21_2")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_21_2")))] - #[doc(alias = "SECRET_ERROR_MISMATCHED_SCHEMA")] - MismatchedSchema, - #[cfg(feature = "v0_21_2")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_21_2")))] - #[doc(alias = "SECRET_ERROR_NO_MATCHING_ATTRIBUTE")] - NoMatchingAttribute, - #[cfg(feature = "v0_21_2")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_21_2")))] - #[doc(alias = "SECRET_ERROR_WRONG_TYPE")] - WrongType, - #[cfg(feature = "v0_21_2")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_21_2")))] - #[doc(alias = "SECRET_ERROR_EMPTY_TABLE")] - EmptyTable, - #[doc(hidden)] - __Unknown(i32), -} - -#[doc(hidden)] -impl IntoGlib for Error { - type GlibType = ffi::SecretError; - - #[inline] - fn into_glib(self) -> ffi::SecretError { - match self { - Self::Protocol => ffi::SECRET_ERROR_PROTOCOL, - Self::IsLocked => ffi::SECRET_ERROR_IS_LOCKED, - Self::NoSuchObject => ffi::SECRET_ERROR_NO_SUCH_OBJECT, - Self::AlreadyExists => ffi::SECRET_ERROR_ALREADY_EXISTS, - Self::InvalidFileFormat => ffi::SECRET_ERROR_INVALID_FILE_FORMAT, - #[cfg(feature = "v0_21_2")] - Self::MismatchedSchema => ffi::SECRET_ERROR_MISMATCHED_SCHEMA, - #[cfg(feature = "v0_21_2")] - Self::NoMatchingAttribute => ffi::SECRET_ERROR_NO_MATCHING_ATTRIBUTE, - #[cfg(feature = "v0_21_2")] - Self::WrongType => ffi::SECRET_ERROR_WRONG_TYPE, - #[cfg(feature = "v0_21_2")] - Self::EmptyTable => ffi::SECRET_ERROR_EMPTY_TABLE, - Self::__Unknown(value) => value, - } - } -} - -#[doc(hidden)] -impl FromGlib for Error { - #[inline] - unsafe fn from_glib(value: ffi::SecretError) -> Self { - match value { - ffi::SECRET_ERROR_PROTOCOL => Self::Protocol, - ffi::SECRET_ERROR_IS_LOCKED => Self::IsLocked, - ffi::SECRET_ERROR_NO_SUCH_OBJECT => Self::NoSuchObject, - ffi::SECRET_ERROR_ALREADY_EXISTS => Self::AlreadyExists, - ffi::SECRET_ERROR_INVALID_FILE_FORMAT => Self::InvalidFileFormat, - #[cfg(feature = "v0_21_2")] - ffi::SECRET_ERROR_MISMATCHED_SCHEMA => Self::MismatchedSchema, - #[cfg(feature = "v0_21_2")] - ffi::SECRET_ERROR_NO_MATCHING_ATTRIBUTE => Self::NoMatchingAttribute, - #[cfg(feature = "v0_21_2")] - ffi::SECRET_ERROR_WRONG_TYPE => Self::WrongType, - #[cfg(feature = "v0_21_2")] - ffi::SECRET_ERROR_EMPTY_TABLE => Self::EmptyTable, - value => Self::__Unknown(value), - } - } -} - -impl StaticType for Error { - #[inline] - #[doc(alias = "secret_error_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::secret_error_get_type()) } - } -} - -impl glib::HasParamSpec for Error { - type ParamSpec = glib::ParamSpecEnum; - type SetValue = Self; - type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder_with_default - } -} - -impl glib::value::ValueType for Error { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for Error { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) - } -} - -impl ToValue for Error { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: Error) -> Self { - ToValue::to_value(&v) - } -} - -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] -#[non_exhaustive] -#[doc(alias = "SecretSchemaAttributeType")] -pub enum SchemaAttributeType { - #[doc(alias = "SECRET_SCHEMA_ATTRIBUTE_STRING")] - String, - #[doc(alias = "SECRET_SCHEMA_ATTRIBUTE_INTEGER")] - Integer, - #[doc(alias = "SECRET_SCHEMA_ATTRIBUTE_BOOLEAN")] - Boolean, - #[doc(hidden)] - __Unknown(i32), -} - -#[doc(hidden)] -impl IntoGlib for SchemaAttributeType { - type GlibType = ffi::SecretSchemaAttributeType; - - #[inline] - fn into_glib(self) -> ffi::SecretSchemaAttributeType { - match self { - Self::String => ffi::SECRET_SCHEMA_ATTRIBUTE_STRING, - Self::Integer => ffi::SECRET_SCHEMA_ATTRIBUTE_INTEGER, - Self::Boolean => ffi::SECRET_SCHEMA_ATTRIBUTE_BOOLEAN, - Self::__Unknown(value) => value, - } - } -} - -#[doc(hidden)] -impl FromGlib for SchemaAttributeType { - #[inline] - unsafe fn from_glib(value: ffi::SecretSchemaAttributeType) -> Self { - match value { - ffi::SECRET_SCHEMA_ATTRIBUTE_STRING => Self::String, - ffi::SECRET_SCHEMA_ATTRIBUTE_INTEGER => Self::Integer, - ffi::SECRET_SCHEMA_ATTRIBUTE_BOOLEAN => Self::Boolean, - value => Self::__Unknown(value), - } - } -} - -impl StaticType for SchemaAttributeType { - #[inline] - #[doc(alias = "secret_schema_attribute_type_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::secret_schema_attribute_type_get_type()) } - } -} - -impl glib::HasParamSpec for SchemaAttributeType { - type ParamSpec = glib::ParamSpecEnum; - type SetValue = Self; - type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder_with_default - } -} - -impl glib::value::ValueType for SchemaAttributeType { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for SchemaAttributeType { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) - } -} - -impl ToValue for SchemaAttributeType { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: SchemaAttributeType) -> Self { - ToValue::to_value(&v) - } -} - -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] -#[non_exhaustive] -#[doc(alias = "SecretSchemaType")] -pub enum SchemaType { - #[doc(alias = "SECRET_SCHEMA_TYPE_NOTE")] - Note, - #[doc(alias = "SECRET_SCHEMA_TYPE_COMPAT_NETWORK")] - CompatNetwork, - #[doc(hidden)] - __Unknown(i32), -} - -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -#[doc(hidden)] -impl IntoGlib for SchemaType { - type GlibType = ffi::SecretSchemaType; - - #[inline] - fn into_glib(self) -> ffi::SecretSchemaType { - match self { - Self::Note => ffi::SECRET_SCHEMA_TYPE_NOTE, - Self::CompatNetwork => ffi::SECRET_SCHEMA_TYPE_COMPAT_NETWORK, - Self::__Unknown(value) => value, - } - } -} - -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -#[doc(hidden)] -impl FromGlib for SchemaType { - #[inline] - unsafe fn from_glib(value: ffi::SecretSchemaType) -> Self { - match value { - ffi::SECRET_SCHEMA_TYPE_NOTE => Self::Note, - ffi::SECRET_SCHEMA_TYPE_COMPAT_NETWORK => Self::CompatNetwork, - value => Self::__Unknown(value), - } - } -} - -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -impl StaticType for SchemaType { - #[inline] - #[doc(alias = "secret_schema_type_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::secret_schema_type_get_type()) } - } -} - -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -impl glib::HasParamSpec for SchemaType { - type ParamSpec = glib::ParamSpecEnum; - type SetValue = Self; - type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder_with_default - } -} - -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -impl glib::value::ValueType for SchemaType { - type Type = Self; -} - -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -unsafe impl<'a> glib::value::FromValue<'a> for SchemaType { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) - } -} - -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -impl ToValue for SchemaType { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -impl From for glib::Value { - #[inline] - fn from(v: SchemaType) -> Self { - ToValue::to_value(&v) - } -} diff --git a/libsecret/src/auto/flags.rs b/libsecret/src/auto/flags.rs deleted file mode 100644 index 81c0f71..0000000 --- a/libsecret/src/auto/flags.rs +++ /dev/null @@ -1,591 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -use glib::{bitflags::bitflags, prelude::*, translate::*}; - -bitflags! { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] - #[doc(alias = "SecretCollectionCreateFlags")] - pub struct CollectionCreateFlags: u32 { - #[doc(alias = "SECRET_COLLECTION_CREATE_NONE")] - const NONE = ffi::SECRET_COLLECTION_CREATE_NONE as _; - } -} - -#[doc(hidden)] -impl IntoGlib for CollectionCreateFlags { - type GlibType = ffi::SecretCollectionCreateFlags; - - #[inline] - fn into_glib(self) -> ffi::SecretCollectionCreateFlags { - self.bits() - } -} - -#[doc(hidden)] -impl FromGlib for CollectionCreateFlags { - #[inline] - unsafe fn from_glib(value: ffi::SecretCollectionCreateFlags) -> Self { - Self::from_bits_truncate(value) - } -} - -impl StaticType for CollectionCreateFlags { - #[inline] - #[doc(alias = "secret_collection_create_flags_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::secret_collection_create_flags_get_type()) } - } -} - -impl glib::HasParamSpec for CollectionCreateFlags { - type ParamSpec = glib::ParamSpecFlags; - type SetValue = Self; - type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder - } -} - -impl glib::value::ValueType for CollectionCreateFlags { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for CollectionCreateFlags { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) - } -} - -impl ToValue for CollectionCreateFlags { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: CollectionCreateFlags) -> Self { - ToValue::to_value(&v) - } -} - -bitflags! { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] - #[doc(alias = "SecretCollectionFlags")] - pub struct CollectionFlags: u32 { - #[doc(alias = "SECRET_COLLECTION_NONE")] - const NONE = ffi::SECRET_COLLECTION_NONE as _; - #[doc(alias = "SECRET_COLLECTION_LOAD_ITEMS")] - const LOAD_ITEMS = ffi::SECRET_COLLECTION_LOAD_ITEMS as _; - } -} - -#[doc(hidden)] -impl IntoGlib for CollectionFlags { - type GlibType = ffi::SecretCollectionFlags; - - #[inline] - fn into_glib(self) -> ffi::SecretCollectionFlags { - self.bits() - } -} - -#[doc(hidden)] -impl FromGlib for CollectionFlags { - #[inline] - unsafe fn from_glib(value: ffi::SecretCollectionFlags) -> Self { - Self::from_bits_truncate(value) - } -} - -impl StaticType for CollectionFlags { - #[inline] - #[doc(alias = "secret_collection_flags_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::secret_collection_flags_get_type()) } - } -} - -impl glib::HasParamSpec for CollectionFlags { - type ParamSpec = glib::ParamSpecFlags; - type SetValue = Self; - type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder - } -} - -impl glib::value::ValueType for CollectionFlags { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for CollectionFlags { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) - } -} - -impl ToValue for CollectionFlags { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: CollectionFlags) -> Self { - ToValue::to_value(&v) - } -} - -bitflags! { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] - #[doc(alias = "SecretItemCreateFlags")] - pub struct ItemCreateFlags: u32 { - #[doc(alias = "SECRET_ITEM_CREATE_NONE")] - const NONE = ffi::SECRET_ITEM_CREATE_NONE as _; - #[doc(alias = "SECRET_ITEM_CREATE_REPLACE")] - const REPLACE = ffi::SECRET_ITEM_CREATE_REPLACE as _; - } -} - -#[doc(hidden)] -impl IntoGlib for ItemCreateFlags { - type GlibType = ffi::SecretItemCreateFlags; - - #[inline] - fn into_glib(self) -> ffi::SecretItemCreateFlags { - self.bits() - } -} - -#[doc(hidden)] -impl FromGlib for ItemCreateFlags { - #[inline] - unsafe fn from_glib(value: ffi::SecretItemCreateFlags) -> Self { - Self::from_bits_truncate(value) - } -} - -impl StaticType for ItemCreateFlags { - #[inline] - #[doc(alias = "secret_item_create_flags_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::secret_item_create_flags_get_type()) } - } -} - -impl glib::HasParamSpec for ItemCreateFlags { - type ParamSpec = glib::ParamSpecFlags; - type SetValue = Self; - type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder - } -} - -impl glib::value::ValueType for ItemCreateFlags { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for ItemCreateFlags { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) - } -} - -impl ToValue for ItemCreateFlags { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: ItemCreateFlags) -> Self { - ToValue::to_value(&v) - } -} - -bitflags! { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] - #[doc(alias = "SecretItemFlags")] - pub struct ItemFlags: u32 { - #[doc(alias = "SECRET_ITEM_NONE")] - const NONE = ffi::SECRET_ITEM_NONE as _; - #[doc(alias = "SECRET_ITEM_LOAD_SECRET")] - const LOAD_SECRET = ffi::SECRET_ITEM_LOAD_SECRET as _; - } -} - -#[doc(hidden)] -impl IntoGlib for ItemFlags { - type GlibType = ffi::SecretItemFlags; - - #[inline] - fn into_glib(self) -> ffi::SecretItemFlags { - self.bits() - } -} - -#[doc(hidden)] -impl FromGlib for ItemFlags { - #[inline] - unsafe fn from_glib(value: ffi::SecretItemFlags) -> Self { - Self::from_bits_truncate(value) - } -} - -impl StaticType for ItemFlags { - #[inline] - #[doc(alias = "secret_item_flags_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::secret_item_flags_get_type()) } - } -} - -impl glib::HasParamSpec for ItemFlags { - type ParamSpec = glib::ParamSpecFlags; - type SetValue = Self; - type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder - } -} - -impl glib::value::ValueType for ItemFlags { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for ItemFlags { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) - } -} - -impl ToValue for ItemFlags { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: ItemFlags) -> Self { - ToValue::to_value(&v) - } -} - -bitflags! { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] - #[doc(alias = "SecretSchemaFlags")] - pub struct SchemaFlags: u32 { - #[doc(alias = "SECRET_SCHEMA_NONE")] - const NONE = ffi::SECRET_SCHEMA_NONE as _; - #[doc(alias = "SECRET_SCHEMA_DONT_MATCH_NAME")] - const DONT_MATCH_NAME = ffi::SECRET_SCHEMA_DONT_MATCH_NAME as _; - } -} - -#[doc(hidden)] -impl IntoGlib for SchemaFlags { - type GlibType = ffi::SecretSchemaFlags; - - #[inline] - fn into_glib(self) -> ffi::SecretSchemaFlags { - self.bits() - } -} - -#[doc(hidden)] -impl FromGlib for SchemaFlags { - #[inline] - unsafe fn from_glib(value: ffi::SecretSchemaFlags) -> Self { - Self::from_bits_truncate(value) - } -} - -impl StaticType for SchemaFlags { - #[inline] - #[doc(alias = "secret_schema_flags_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::secret_schema_flags_get_type()) } - } -} - -impl glib::HasParamSpec for SchemaFlags { - type ParamSpec = glib::ParamSpecFlags; - type SetValue = Self; - type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder - } -} - -impl glib::value::ValueType for SchemaFlags { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for SchemaFlags { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) - } -} - -impl ToValue for SchemaFlags { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: SchemaFlags) -> Self { - ToValue::to_value(&v) - } -} - -bitflags! { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] - #[doc(alias = "SecretSearchFlags")] - pub struct SearchFlags: u32 { - #[doc(alias = "SECRET_SEARCH_NONE")] - const NONE = ffi::SECRET_SEARCH_NONE as _; - #[doc(alias = "SECRET_SEARCH_ALL")] - const ALL = ffi::SECRET_SEARCH_ALL as _; - #[doc(alias = "SECRET_SEARCH_UNLOCK")] - const UNLOCK = ffi::SECRET_SEARCH_UNLOCK as _; - #[doc(alias = "SECRET_SEARCH_LOAD_SECRETS")] - const LOAD_SECRETS = ffi::SECRET_SEARCH_LOAD_SECRETS as _; - } -} - -#[doc(hidden)] -impl IntoGlib for SearchFlags { - type GlibType = ffi::SecretSearchFlags; - - #[inline] - fn into_glib(self) -> ffi::SecretSearchFlags { - self.bits() - } -} - -#[doc(hidden)] -impl FromGlib for SearchFlags { - #[inline] - unsafe fn from_glib(value: ffi::SecretSearchFlags) -> Self { - Self::from_bits_truncate(value) - } -} - -impl StaticType for SearchFlags { - #[inline] - #[doc(alias = "secret_search_flags_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::secret_search_flags_get_type()) } - } -} - -impl glib::HasParamSpec for SearchFlags { - type ParamSpec = glib::ParamSpecFlags; - type SetValue = Self; - type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder - } -} - -impl glib::value::ValueType for SearchFlags { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for SearchFlags { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) - } -} - -impl ToValue for SearchFlags { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: SearchFlags) -> Self { - ToValue::to_value(&v) - } -} - -bitflags! { - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] - #[doc(alias = "SecretServiceFlags")] - pub struct ServiceFlags: u32 { - #[doc(alias = "SECRET_SERVICE_NONE")] - const NONE = ffi::SECRET_SERVICE_NONE as _; - #[doc(alias = "SECRET_SERVICE_OPEN_SESSION")] - const OPEN_SESSION = ffi::SECRET_SERVICE_OPEN_SESSION as _; - #[doc(alias = "SECRET_SERVICE_LOAD_COLLECTIONS")] - const LOAD_COLLECTIONS = ffi::SECRET_SERVICE_LOAD_COLLECTIONS as _; - } -} - -#[doc(hidden)] -impl IntoGlib for ServiceFlags { - type GlibType = ffi::SecretServiceFlags; - - #[inline] - fn into_glib(self) -> ffi::SecretServiceFlags { - self.bits() - } -} - -#[doc(hidden)] -impl FromGlib for ServiceFlags { - #[inline] - unsafe fn from_glib(value: ffi::SecretServiceFlags) -> Self { - Self::from_bits_truncate(value) - } -} - -impl StaticType for ServiceFlags { - #[inline] - #[doc(alias = "secret_service_flags_get_type")] - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::secret_service_flags_get_type()) } - } -} - -impl glib::HasParamSpec for ServiceFlags { - type ParamSpec = glib::ParamSpecFlags; - type SetValue = Self; - type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; - - fn param_spec_builder() -> Self::BuilderFn { - Self::ParamSpec::builder - } -} - -impl glib::value::ValueType for ServiceFlags { - type Type = Self; -} - -unsafe impl<'a> glib::value::FromValue<'a> for ServiceFlags { - type Checker = glib::value::GenericValueTypeChecker; - - #[inline] - unsafe fn from_value(value: &'a glib::Value) -> Self { - from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) - } -} - -impl ToValue for ServiceFlags { - #[inline] - fn to_value(&self) -> glib::Value { - let mut value = glib::Value::for_value_type::(); - unsafe { - glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); - } - value - } - - #[inline] - fn value_type(&self) -> glib::Type { - Self::static_type() - } -} - -impl From for glib::Value { - #[inline] - fn from(v: ServiceFlags) -> Self { - ToValue::to_value(&v) - } -} diff --git a/libsecret/src/auto/functions.rs b/libsecret/src/auto/functions.rs deleted file mode 100644 index 173139f..0000000 --- a/libsecret/src/auto/functions.rs +++ /dev/null @@ -1,41 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -use crate::{Retrievable, Value}; -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -use crate::{Schema, SchemaType}; -use glib::{prelude::*, translate::*}; - -//#[cfg(feature = "v0_21_2")] -//#[cfg_attr(docsrs, doc(cfg(feature = "v0_21_2")))] -//#[doc(alias = "secret_attributes_validate")] -//pub fn attributes_validate(schema: &Schema, attributes: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }) -> Result<(), glib::Error> { -// unsafe { TODO: call ffi:secret_attributes_validate() } -//} - -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -#[doc(alias = "secret_get_schema")] -#[doc(alias = "get_schema")] -pub fn schema(type_: SchemaType) -> Schema { - unsafe { from_glib_none(ffi::secret_get_schema(type_.into_glib())) } -} - -#[doc(alias = "secret_password_free")] -pub fn password_free(password: Option<&str>) { - unsafe { - ffi::secret_password_free(password.to_glib_none().0); - } -} - -#[doc(alias = "secret_password_wipe")] -pub fn password_wipe(password: Option<&str>) { - unsafe { - ffi::secret_password_wipe(password.to_glib_none().0); - } -} diff --git a/libsecret/src/auto/item.rs b/libsecret/src/auto/item.rs deleted file mode 100644 index 5fb03e6..0000000 --- a/libsecret/src/auto/item.rs +++ /dev/null @@ -1,556 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -use crate::Retrievable; -use crate::{ItemFlags, Service, Value}; -use glib::{ - prelude::*, - signal::{connect_raw, SignalHandlerId}, - translate::*, -}; -use std::{boxed::Box as Box_, pin::Pin}; - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -glib::wrapper! { - #[doc(alias = "SecretItem")] - pub struct Item(Object) @extends gio::DBusProxy, @implements gio::DBusInterface, gio::Initable, Retrievable; - - match fn { - type_ => || ffi::secret_item_get_type(), - } -} - -#[cfg(not(any(feature = "v0_19")))] -glib::wrapper! { - #[doc(alias = "SecretItem")] - pub struct Item(Object) @extends gio::DBusProxy, @implements gio::DBusInterface, gio::Initable; - - match fn { - type_ => || ffi::secret_item_get_type(), - } -} - -impl Item { - pub const NONE: Option<&'static Item> = None; - - #[doc(alias = "secret_item_new_for_dbus_path_sync")] - #[doc(alias = "new_for_dbus_path_sync")] - pub fn for_dbus_path_sync( - service: Option<&impl IsA>, - item_path: &str, - flags: ItemFlags, - cancellable: Option<&impl IsA>, - ) -> Result { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_item_new_for_dbus_path_sync( - service.map(|p| p.as_ref()).to_glib_none().0, - item_path.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_item_new_for_dbus_path")] - pub fn new_for_dbus_path) + 'static>( - service: Option<&impl IsA>, - item_path: &str, - flags: ItemFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn new_for_dbus_path_trampoline< - P: FnOnce(Result) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_item_new_for_dbus_path_finish(res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = new_for_dbus_path_trampoline::

; - unsafe { - ffi::secret_item_new_for_dbus_path( - service.map(|p| p.as_ref()).to_glib_none().0, - item_path.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - pub fn new_for_dbus_path_future( - service: Option<&(impl IsA + Clone + 'static)>, - item_path: &str, - flags: ItemFlags, - ) -> Pin> + 'static>> { - let service = service.map(ToOwned::to_owned); - let item_path = String::from(item_path); - Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { - Self::new_for_dbus_path( - service.as_ref().map(::std::borrow::Borrow::borrow), - &item_path, - flags, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } -} - -mod sealed { - pub trait Sealed {} - impl> Sealed for T {} -} - -pub trait ItemExt: IsA + sealed::Sealed + 'static { - #[doc(alias = "secret_item_delete")] - fn delete) + 'static>( - &self, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn delete_trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = ffi::secret_item_delete_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = delete_trampoline::

; - unsafe { - ffi::secret_item_delete( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn delete_future( - &self, - ) -> Pin> + 'static>> { - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.delete(Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_item_delete_sync")] - fn delete_sync( - &self, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_item_delete_sync( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - #[cfg(not(feature = "v0_19"))] - #[cfg_attr(docsrs, doc(cfg(not(feature = "v0_19"))))] - #[doc(alias = "secret_item_get_created")] - #[doc(alias = "get_created")] - fn created(&self) -> u64 { - unsafe { ffi::secret_item_get_created(self.as_ref().to_glib_none().0) } - } - - #[doc(alias = "secret_item_get_flags")] - #[doc(alias = "get_flags")] - fn flags(&self) -> ItemFlags { - unsafe { from_glib(ffi::secret_item_get_flags(self.as_ref().to_glib_none().0)) } - } - - #[cfg(not(feature = "v0_19"))] - #[cfg_attr(docsrs, doc(cfg(not(feature = "v0_19"))))] - #[doc(alias = "secret_item_get_label")] - #[doc(alias = "get_label")] - fn label(&self) -> glib::GString { - unsafe { from_glib_full(ffi::secret_item_get_label(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "secret_item_get_locked")] - #[doc(alias = "get_locked")] - fn is_locked(&self) -> bool { - unsafe { from_glib(ffi::secret_item_get_locked(self.as_ref().to_glib_none().0)) } - } - - #[cfg(not(feature = "v0_19"))] - #[cfg_attr(docsrs, doc(cfg(not(feature = "v0_19"))))] - #[doc(alias = "secret_item_get_modified")] - #[doc(alias = "get_modified")] - fn modified(&self) -> u64 { - unsafe { ffi::secret_item_get_modified(self.as_ref().to_glib_none().0) } - } - - #[doc(alias = "secret_item_get_schema_name")] - #[doc(alias = "get_schema_name")] - fn schema_name(&self) -> Option { - unsafe { - from_glib_full(ffi::secret_item_get_schema_name( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_item_get_secret")] - #[doc(alias = "get_secret")] - fn secret(&self) -> Option { - unsafe { from_glib_full(ffi::secret_item_get_secret(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "secret_item_get_service")] - #[doc(alias = "get_service")] - fn service(&self) -> Service { - unsafe { from_glib_none(ffi::secret_item_get_service(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "secret_item_load_secret")] - fn load_secret) + 'static>( - &self, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn load_secret_trampoline< - P: FnOnce(Result<(), glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = ffi::secret_item_load_secret_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = load_secret_trampoline::

; - unsafe { - ffi::secret_item_load_secret( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn load_secret_future( - &self, - ) -> Pin> + 'static>> { - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.load_secret(Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_item_load_secret_sync")] - fn load_secret_sync( - &self, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_item_load_secret_sync( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_item_refresh")] - fn refresh(&self) { - unsafe { - ffi::secret_item_refresh(self.as_ref().to_glib_none().0); - } - } - - #[doc(alias = "secret_item_set_label")] - fn set_label) + 'static>( - &self, - label: &str, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn set_label_trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = ffi::secret_item_set_label_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = set_label_trampoline::

; - unsafe { - ffi::secret_item_set_label( - self.as_ref().to_glib_none().0, - label.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn set_label_future( - &self, - label: &str, - ) -> Pin> + 'static>> { - let label = String::from(label); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.set_label(&label, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_item_set_label_sync")] - fn set_label_sync( - &self, - label: &str, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_item_set_label_sync( - self.as_ref().to_glib_none().0, - label.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_item_set_secret")] - fn set_secret) + 'static>( - &self, - value: &Value, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn set_secret_trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = ffi::secret_item_set_secret_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = set_secret_trampoline::

; - unsafe { - ffi::secret_item_set_secret( - self.as_ref().to_glib_none().0, - value.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn set_secret_future( - &self, - value: &Value, - ) -> Pin> + 'static>> { - let value = value.clone(); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.set_secret(&value, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_item_set_secret_sync")] - fn set_secret_sync( - &self, - value: &Value, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_item_set_secret_sync( - self.as_ref().to_glib_none().0, - value.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "locked")] - fn connect_locked_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_locked_trampoline, F: Fn(&P) + 'static>( - this: *mut ffi::SecretItem, - _param_spec: glib::ffi::gpointer, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(Item::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::locked\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( - notify_locked_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } -} - -impl> ItemExt for O {} diff --git a/libsecret/src/auto/mod.rs b/libsecret/src/auto/mod.rs deleted file mode 100644 index a8d7346..0000000 --- a/libsecret/src/auto/mod.rs +++ /dev/null @@ -1,75 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -mod backend; -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -pub use self::backend::Backend; - -mod collection; -pub use self::collection::Collection; - -mod item; -pub use self::item::Item; - -mod prompt; -pub use self::prompt::Prompt; - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -mod retrievable; -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -pub use self::retrievable::Retrievable; - -mod service; -pub use self::service::Service; - -mod schema; -pub use self::schema::Schema; - -mod schema_attribute; -pub use self::schema_attribute::SchemaAttribute; - -mod enums; -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -pub use self::enums::BackendFlags; -pub use self::enums::Error; -pub use self::enums::SchemaAttributeType; -#[cfg(feature = "v0_18_6")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_18_6")))] -pub use self::enums::SchemaType; - -mod flags; -pub use self::flags::CollectionCreateFlags; -pub use self::flags::CollectionFlags; -pub use self::flags::ItemCreateFlags; -pub use self::flags::ItemFlags; -pub use self::flags::SchemaFlags; -pub use self::flags::SearchFlags; -pub use self::flags::ServiceFlags; - -pub(crate) mod functions; - -mod constants; -pub use self::constants::BACKEND_EXTENSION_POINT_NAME; -pub use self::constants::COLLECTION_DEFAULT; -pub use self::constants::COLLECTION_SESSION; - -pub(crate) mod traits { - #[cfg(feature = "v0_19")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] - pub use super::backend::BackendExt; - pub use super::collection::CollectionExt; - pub use super::item::ItemExt; - pub use super::prompt::PromptExt; - #[cfg(feature = "v0_19")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] - pub use super::retrievable::RetrievableExt; - pub use super::service::ServiceExt; -} diff --git a/libsecret/src/auto/prompt.rs b/libsecret/src/auto/prompt.rs deleted file mode 100644 index 245f68a..0000000 --- a/libsecret/src/auto/prompt.rs +++ /dev/null @@ -1,76 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -use glib::{prelude::*, translate::*}; - -glib::wrapper! { - #[doc(alias = "SecretPrompt")] - pub struct Prompt(Object) @extends gio::DBusProxy, @implements gio::DBusInterface, gio::Initable; - - match fn { - type_ => || ffi::secret_prompt_get_type(), - } -} - -impl Prompt { - pub const NONE: Option<&'static Prompt> = None; -} - -mod sealed { - pub trait Sealed {} - impl> Sealed for T {} -} - -pub trait PromptExt: IsA + sealed::Sealed + 'static { - #[doc(alias = "secret_prompt_perform_sync")] - fn perform_sync( - &self, - window_id: Option<&str>, - cancellable: Option<&impl IsA>, - return_type: &glib::VariantTy, - ) -> Result { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_prompt_perform_sync( - self.as_ref().to_glib_none().0, - window_id.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - return_type.to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_prompt_run")] - fn run( - &self, - window_id: Option<&str>, - cancellable: Option<&impl IsA>, - return_type: &glib::VariantTy, - ) -> Result { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_prompt_run( - self.as_ref().to_glib_none().0, - window_id.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - return_type.to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } -} - -impl> PromptExt for O {} diff --git a/libsecret/src/auto/retrievable.rs b/libsecret/src/auto/retrievable.rs deleted file mode 100644 index 14ab08f..0000000 --- a/libsecret/src/auto/retrievable.rs +++ /dev/null @@ -1,269 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -use crate::Value; -use glib::{ - prelude::*, - signal::{connect_raw, SignalHandlerId}, - translate::*, -}; -use std::{boxed::Box as Box_, pin::Pin}; - -glib::wrapper! { - #[doc(alias = "SecretRetrievable")] - pub struct Retrievable(Interface); - - match fn { - type_ => || ffi::secret_retrievable_get_type(), - } -} - -impl Retrievable { - pub const NONE: Option<&'static Retrievable> = None; -} - -mod sealed { - pub trait Sealed {} - impl> Sealed for T {} -} - -pub trait RetrievableExt: IsA + sealed::Sealed + 'static { - #[doc(alias = "secret_retrievable_get_created")] - #[doc(alias = "get_created")] - fn created(&self) -> u64 { - unsafe { ffi::secret_retrievable_get_created(self.as_ref().to_glib_none().0) } - } - - #[doc(alias = "secret_retrievable_get_label")] - #[doc(alias = "get_label")] - fn label(&self) -> glib::GString { - unsafe { - from_glib_full(ffi::secret_retrievable_get_label( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_retrievable_get_modified")] - #[doc(alias = "get_modified")] - fn modified(&self) -> u64 { - unsafe { ffi::secret_retrievable_get_modified(self.as_ref().to_glib_none().0) } - } - - #[doc(alias = "secret_retrievable_retrieve_secret")] - fn retrieve_secret, glib::Error>) + 'static>( - &self, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn retrieve_secret_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_retrievable_retrieve_secret_finish( - _source_object as *mut _, - res, - &mut error, - ); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = retrieve_secret_trampoline::

; - unsafe { - ffi::secret_retrievable_retrieve_secret( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn retrieve_secret_future( - &self, - ) -> Pin, glib::Error>> + 'static>> - { - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.retrieve_secret(Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_retrievable_retrieve_secret_sync")] - fn retrieve_secret_sync( - &self, - cancellable: Option<&impl IsA>, - ) -> Result, glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_retrievable_retrieve_secret_sync( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } - - //#[cfg(feature = "v0_19")] - //#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] - //fn set_attributes(&self, attributes: /*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }) { - // ObjectExt::set_property(self.as_ref(),"attributes", attributes) - //} - - #[cfg(feature = "v0_19")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] - fn set_created(&self, created: u64) { - ObjectExt::set_property(self.as_ref(), "created", created) - } - - #[cfg(feature = "v0_19")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] - fn set_label(&self, label: Option<&str>) { - ObjectExt::set_property(self.as_ref(), "label", label) - } - - #[cfg(feature = "v0_19")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] - fn set_modified(&self, modified: u64) { - ObjectExt::set_property(self.as_ref(), "modified", modified) - } - - #[cfg(feature = "v0_19")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] - #[doc(alias = "attributes")] - fn connect_attributes_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_attributes_trampoline< - P: IsA, - F: Fn(&P) + 'static, - >( - this: *mut ffi::SecretRetrievable, - _param_spec: glib::ffi::gpointer, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(Retrievable::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::attributes\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( - notify_attributes_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } - - #[cfg(feature = "v0_19")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] - #[doc(alias = "created")] - fn connect_created_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_created_trampoline, F: Fn(&P) + 'static>( - this: *mut ffi::SecretRetrievable, - _param_spec: glib::ffi::gpointer, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(Retrievable::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::created\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( - notify_created_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } - - #[cfg(feature = "v0_19")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] - #[doc(alias = "label")] - fn connect_label_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_label_trampoline, F: Fn(&P) + 'static>( - this: *mut ffi::SecretRetrievable, - _param_spec: glib::ffi::gpointer, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(Retrievable::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::label\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( - notify_label_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } - - #[cfg(feature = "v0_19")] - #[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] - #[doc(alias = "modified")] - fn connect_modified_notify(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn notify_modified_trampoline< - P: IsA, - F: Fn(&P) + 'static, - >( - this: *mut ffi::SecretRetrievable, - _param_spec: glib::ffi::gpointer, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(Retrievable::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"notify::modified\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( - notify_modified_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) - } - } -} - -impl> RetrievableExt for O {} diff --git a/libsecret/src/auto/schema.rs b/libsecret/src/auto/schema.rs deleted file mode 100644 index 9889b31..0000000 --- a/libsecret/src/auto/schema.rs +++ /dev/null @@ -1,15 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -glib::wrapper! { - #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub struct Schema(Shared); - - match fn { - ref => |ptr| ffi::secret_schema_ref(ptr), - unref => |ptr| ffi::secret_schema_unref(ptr), - type_ => || ffi::secret_schema_get_type(), - } -} diff --git a/libsecret/src/auto/schema_attribute.rs b/libsecret/src/auto/schema_attribute.rs deleted file mode 100644 index be20632..0000000 --- a/libsecret/src/auto/schema_attribute.rs +++ /dev/null @@ -1,15 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -glib::wrapper! { - #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub struct SchemaAttribute(Boxed); - - match fn { - copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::secret_schema_attribute_get_type(), ptr as *mut _) as *mut ffi::SecretSchemaAttribute, - free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::secret_schema_attribute_get_type(), ptr as *mut _), - type_ => || ffi::secret_schema_attribute_get_type(), - } -} diff --git a/libsecret/src/auto/service.rs b/libsecret/src/auto/service.rs deleted file mode 100644 index b4882b3..0000000 --- a/libsecret/src/auto/service.rs +++ /dev/null @@ -1,1208 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from -// from gir-files (https://github.com/gtk-rs/gir-files.git) -// DO NOT EDIT - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -use crate::Backend; -use crate::{Collection, Item, Prompt, ServiceFlags, Value}; -use glib::{prelude::*, translate::*}; -use std::{boxed::Box as Box_, pin::Pin}; - -#[cfg(feature = "v0_19")] -#[cfg_attr(docsrs, doc(cfg(feature = "v0_19")))] -glib::wrapper! { - #[doc(alias = "SecretService")] - pub struct Service(Object) @extends gio::DBusProxy, @implements gio::DBusInterface, gio::Initable, Backend; - - match fn { - type_ => || ffi::secret_service_get_type(), - } -} - -#[cfg(not(any(feature = "v0_19")))] -glib::wrapper! { - #[doc(alias = "SecretService")] - pub struct Service(Object) @extends gio::DBusProxy, @implements gio::DBusInterface, gio::Initable; - - match fn { - type_ => || ffi::secret_service_get_type(), - } -} - -impl Service { - pub const NONE: Option<&'static Service> = None; - - #[doc(alias = "secret_service_disconnect")] - pub fn disconnect() { - unsafe { - ffi::secret_service_disconnect(); - } - } - - #[doc(alias = "secret_service_get")] - pub fn get) + 'static>( - flags: ServiceFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn get_trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_get_finish(res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = get_trampoline::

; - unsafe { - ffi::secret_service_get( - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - pub fn get_future( - flags: ServiceFlags, - ) -> Pin> + 'static>> { - Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { - Self::get(flags, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_service_get_sync")] - #[doc(alias = "get_sync")] - pub fn sync( - flags: ServiceFlags, - cancellable: Option<&impl IsA>, - ) -> Result { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_get_sync( - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_service_open")] - pub fn open) + 'static>( - service_gtype: glib::types::Type, - service_bus_name: Option<&str>, - flags: ServiceFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn open_trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_open_finish(res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = open_trampoline::

; - unsafe { - ffi::secret_service_open( - service_gtype.into_glib(), - service_bus_name.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - pub fn open_future( - service_gtype: glib::types::Type, - service_bus_name: Option<&str>, - flags: ServiceFlags, - ) -> Pin> + 'static>> { - let service_bus_name = service_bus_name.map(ToOwned::to_owned); - Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { - Self::open( - service_gtype, - service_bus_name.as_ref().map(::std::borrow::Borrow::borrow), - flags, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - #[doc(alias = "secret_service_open_sync")] - pub fn open_sync( - service_gtype: glib::types::Type, - service_bus_name: Option<&str>, - flags: ServiceFlags, - cancellable: Option<&impl IsA>, - ) -> Result { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_open_sync( - service_gtype.into_glib(), - service_bus_name.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } -} - -mod sealed { - pub trait Sealed {} - impl> Sealed for T {} -} - -pub trait ServiceExt: IsA + sealed::Sealed + 'static { - //#[doc(alias = "secret_service_clear_sync")] - //fn clear_sync(&self, schema: Option<&Schema>, attributes: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { - // unsafe { TODO: call ffi:secret_service_clear_sync() } - //} - - //#[doc(alias = "secret_service_create_collection_dbus_path_sync")] - //fn create_collection_dbus_path_sync(&self, properties: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 2, id: 222 }, alias: Option<&str>, flags: CollectionCreateFlags, cancellable: Option<&impl IsA>) -> Result { - // unsafe { TODO: call ffi:secret_service_create_collection_dbus_path_sync() } - //} - - //#[doc(alias = "secret_service_create_item_dbus_path_sync")] - //fn create_item_dbus_path_sync(&self, collection_path: &str, properties: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 2, id: 222 }, value: &Value, flags: ItemCreateFlags, cancellable: Option<&impl IsA>) -> Result { - // unsafe { TODO: call ffi:secret_service_create_item_dbus_path_sync() } - //} - - #[doc(alias = "secret_service_decode_dbus_secret")] - fn decode_dbus_secret(&self, value: &glib::Variant) -> Value { - unsafe { - from_glib_full(ffi::secret_service_decode_dbus_secret( - self.as_ref().to_glib_none().0, - value.to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_service_delete_item_dbus_path")] - fn delete_item_dbus_path) + 'static>( - &self, - item_path: &str, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn delete_item_dbus_path_trampoline< - P: FnOnce(Result<(), glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = ffi::secret_service_delete_item_dbus_path_finish( - _source_object as *mut _, - res, - &mut error, - ); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = delete_item_dbus_path_trampoline::

; - unsafe { - ffi::secret_service_delete_item_dbus_path( - self.as_ref().to_glib_none().0, - item_path.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn delete_item_dbus_path_future( - &self, - item_path: &str, - ) -> Pin> + 'static>> { - let item_path = String::from(item_path); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.delete_item_dbus_path(&item_path, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_service_delete_item_dbus_path_sync")] - fn delete_item_dbus_path_sync( - &self, - item_path: &str, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_service_delete_item_dbus_path_sync( - self.as_ref().to_glib_none().0, - item_path.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_service_encode_dbus_secret")] - fn encode_dbus_secret(&self, value: &Value) -> glib::Variant { - unsafe { - from_glib_none(ffi::secret_service_encode_dbus_secret( - self.as_ref().to_glib_none().0, - value.to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_service_ensure_session")] - fn ensure_session) + 'static>( - &self, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn ensure_session_trampoline< - P: FnOnce(Result<(), glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = ffi::secret_service_ensure_session_finish( - _source_object as *mut _, - res, - &mut error, - ); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = ensure_session_trampoline::

; - unsafe { - ffi::secret_service_ensure_session( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn ensure_session_future( - &self, - ) -> Pin> + 'static>> { - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.ensure_session(Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_service_ensure_session_sync")] - fn ensure_session_sync( - &self, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_service_ensure_session_sync( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_service_get_collection_gtype")] - #[doc(alias = "get_collection_gtype")] - fn collection_gtype(&self) -> glib::types::Type { - unsafe { - from_glib(ffi::secret_service_get_collection_gtype( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_service_get_collections")] - #[doc(alias = "get_collections")] - fn collections(&self) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_full(ffi::secret_service_get_collections( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_service_get_flags")] - #[doc(alias = "get_flags")] - fn flags(&self) -> ServiceFlags { - unsafe { - from_glib(ffi::secret_service_get_flags( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_service_get_item_gtype")] - #[doc(alias = "get_item_gtype")] - fn item_gtype(&self) -> glib::types::Type { - unsafe { - from_glib(ffi::secret_service_get_item_gtype( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_service_get_secret_for_dbus_path")] - #[doc(alias = "get_secret_for_dbus_path")] - fn secret_for_dbus_path, glib::Error>) + 'static>( - &self, - item_path: &str, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn secret_for_dbus_path_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_get_secret_for_dbus_path_finish( - _source_object as *mut _, - res, - &mut error, - ); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = secret_for_dbus_path_trampoline::

; - unsafe { - ffi::secret_service_get_secret_for_dbus_path( - self.as_ref().to_glib_none().0, - item_path.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn secret_for_dbus_path_future( - &self, - item_path: &str, - ) -> Pin, glib::Error>> + 'static>> - { - let item_path = String::from(item_path); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.secret_for_dbus_path(&item_path, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_service_get_secret_for_dbus_path_sync")] - #[doc(alias = "get_secret_for_dbus_path_sync")] - fn secret_for_dbus_path_sync( - &self, - item_path: &str, - cancellable: Option<&impl IsA>, - ) -> Result, glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_get_secret_for_dbus_path_sync( - self.as_ref().to_glib_none().0, - item_path.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } - - //#[doc(alias = "secret_service_get_secrets_for_dbus_paths_sync")] - //#[doc(alias = "get_secrets_for_dbus_paths_sync")] - //fn secrets_for_dbus_paths_sync(&self, item_paths: &str, cancellable: Option<&impl IsA>) -> Result { - // unsafe { TODO: call ffi:secret_service_get_secrets_for_dbus_paths_sync() } - //} - - #[doc(alias = "secret_service_get_session_algorithms")] - #[doc(alias = "get_session_algorithms")] - fn session_algorithms(&self) -> Option { - unsafe { - from_glib_none(ffi::secret_service_get_session_algorithms( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_service_get_session_dbus_path")] - #[doc(alias = "get_session_dbus_path")] - fn session_dbus_path(&self) -> Option { - unsafe { - from_glib_none(ffi::secret_service_get_session_dbus_path( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_service_load_collections")] - fn load_collections) + 'static>( - &self, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn load_collections_trampoline< - P: FnOnce(Result<(), glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = ffi::secret_service_load_collections_finish( - _source_object as *mut _, - res, - &mut error, - ); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = load_collections_trampoline::

; - unsafe { - ffi::secret_service_load_collections( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn load_collections_future( - &self, - ) -> Pin> + 'static>> { - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.load_collections(Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_service_load_collections_sync")] - fn load_collections_sync( - &self, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_service_load_collections_sync( - self.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - //#[doc(alias = "secret_service_lock_sync")] - //fn lock_sync(&self, objects: &[gio::DBusProxy], cancellable: Option<&impl IsA>, locked: /*Unimplemented*/Vec) -> Result { - // unsafe { TODO: call ffi:secret_service_lock_sync() } - //} - - //#[doc(alias = "secret_service_lookup_sync")] - //fn lookup_sync(&self, schema: Option<&Schema>, attributes: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, cancellable: Option<&impl IsA>) -> Result { - // unsafe { TODO: call ffi:secret_service_lookup_sync() } - //} - - #[doc(alias = "secret_service_prompt")] - fn prompt) + 'static>( - &self, - prompt: &impl IsA, - return_type: Option<&glib::VariantTy>, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn prompt_trampoline< - P: FnOnce(Result) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_prompt_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = prompt_trampoline::

; - unsafe { - ffi::secret_service_prompt( - self.as_ref().to_glib_none().0, - prompt.as_ref().to_glib_none().0, - return_type.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn prompt_future( - &self, - prompt: &(impl IsA + Clone + 'static), - return_type: Option<&glib::VariantTy>, - ) -> Pin> + 'static>> - { - let prompt = prompt.clone(); - let return_type = return_type.map(ToOwned::to_owned); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.prompt( - &prompt, - return_type.as_ref().map(::std::borrow::Borrow::borrow), - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - #[doc(alias = "secret_service_prompt_at_dbus_path")] - fn prompt_at_dbus_path, glib::Error>) + 'static>( - &self, - prompt_path: &str, - return_type: Option<&glib::VariantTy>, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn prompt_at_dbus_path_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_prompt_at_dbus_path_finish( - _source_object as *mut _, - res, - &mut error, - ); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = prompt_at_dbus_path_trampoline::

; - unsafe { - ffi::secret_service_prompt_at_dbus_path( - self.as_ref().to_glib_none().0, - prompt_path.to_glib_none().0, - return_type.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn prompt_at_dbus_path_future( - &self, - prompt_path: &str, - return_type: Option<&glib::VariantTy>, - ) -> Pin< - Box_< - dyn std::future::Future, glib::Error>> + 'static, - >, - > { - let prompt_path = String::from(prompt_path); - let return_type = return_type.map(ToOwned::to_owned); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.prompt_at_dbus_path( - &prompt_path, - return_type.as_ref().map(::std::borrow::Borrow::borrow), - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - #[doc(alias = "secret_service_prompt_at_dbus_path_sync")] - fn prompt_at_dbus_path_sync( - &self, - prompt_path: &str, - cancellable: Option<&impl IsA>, - return_type: Option<&glib::VariantTy>, - ) -> Result, glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_prompt_at_dbus_path_sync( - self.as_ref().to_glib_none().0, - prompt_path.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - return_type.to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_service_prompt_sync")] - fn prompt_sync( - &self, - prompt: &impl IsA, - cancellable: Option<&impl IsA>, - return_type: &glib::VariantTy, - ) -> Result { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_prompt_sync( - self.as_ref().to_glib_none().0, - prompt.as_ref().to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - return_type.to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_service_read_alias_dbus_path")] - fn read_alias_dbus_path, glib::Error>) + 'static>( - &self, - alias: &str, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn read_alias_dbus_path_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_read_alias_dbus_path_finish( - _source_object as *mut _, - res, - &mut error, - ); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = read_alias_dbus_path_trampoline::

; - unsafe { - ffi::secret_service_read_alias_dbus_path( - self.as_ref().to_glib_none().0, - alias.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn read_alias_dbus_path_future( - &self, - alias: &str, - ) -> Pin< - Box_< - dyn std::future::Future, glib::Error>> + 'static, - >, - > { - let alias = String::from(alias); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.read_alias_dbus_path(&alias, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_service_read_alias_dbus_path_sync")] - fn read_alias_dbus_path_sync( - &self, - alias: &str, - cancellable: Option<&impl IsA>, - ) -> Result, glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_read_alias_dbus_path_sync( - self.as_ref().to_glib_none().0, - alias.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - } - } - } - - //#[doc(alias = "secret_service_search_for_dbus_paths_sync")] - //fn search_for_dbus_paths_sync(&self, schema: Option<&Schema>, attributes: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, cancellable: Option<&impl IsA>) -> Result<(Vec, Vec), glib::Error> { - // unsafe { TODO: call ffi:secret_service_search_for_dbus_paths_sync() } - //} - - //#[doc(alias = "secret_service_search_sync")] - //fn search_sync(&self, schema: Option<&Schema>, attributes: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, flags: SearchFlags, cancellable: Option<&impl IsA>) -> Result, glib::Error> { - // unsafe { TODO: call ffi:secret_service_search_sync() } - //} - - #[doc(alias = "secret_service_set_alias")] - fn set_alias) + 'static>( - &self, - alias: &str, - collection: Option<&impl IsA>, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn set_alias_trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = ffi::secret_service_set_alias_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = set_alias_trampoline::

; - unsafe { - ffi::secret_service_set_alias( - self.as_ref().to_glib_none().0, - alias.to_glib_none().0, - collection.map(|p| p.as_ref()).to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn set_alias_future( - &self, - alias: &str, - collection: Option<&(impl IsA + Clone + 'static)>, - ) -> Pin> + 'static>> { - let alias = String::from(alias); - let collection = collection.map(ToOwned::to_owned); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.set_alias( - &alias, - collection.as_ref().map(::std::borrow::Borrow::borrow), - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - #[doc(alias = "secret_service_set_alias_sync")] - fn set_alias_sync( - &self, - alias: &str, - collection: Option<&impl IsA>, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_service_set_alias_sync( - self.as_ref().to_glib_none().0, - alias.to_glib_none().0, - collection.map(|p| p.as_ref()).to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_service_set_alias_to_dbus_path")] - fn set_alias_to_dbus_path) + 'static>( - &self, - alias: &str, - collection_path: Option<&str>, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn set_alias_to_dbus_path_trampoline< - P: FnOnce(Result<(), glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = std::ptr::null_mut(); - let _ = ffi::secret_service_set_alias_to_dbus_path_finish( - _source_object as *mut _, - res, - &mut error, - ); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = set_alias_to_dbus_path_trampoline::

; - unsafe { - ffi::secret_service_set_alias_to_dbus_path( - self.as_ref().to_glib_none().0, - alias.to_glib_none().0, - collection_path.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn set_alias_to_dbus_path_future( - &self, - alias: &str, - collection_path: Option<&str>, - ) -> Pin> + 'static>> { - let alias = String::from(alias); - let collection_path = collection_path.map(ToOwned::to_owned); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.set_alias_to_dbus_path( - &alias, - collection_path.as_ref().map(::std::borrow::Borrow::borrow), - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - #[doc(alias = "secret_service_set_alias_to_dbus_path_sync")] - fn set_alias_to_dbus_path_sync( - &self, - alias: &str, - collection_path: Option<&str>, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = std::ptr::null_mut(); - let is_ok = ffi::secret_service_set_alias_to_dbus_path_sync( - self.as_ref().to_glib_none().0, - alias.to_glib_none().0, - collection_path.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - //#[doc(alias = "secret_service_store_sync")] - //fn store_sync(&self, schema: Option<&Schema>, attributes: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, collection: Option<&str>, label: &str, value: &Value, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { - // unsafe { TODO: call ffi:secret_service_store_sync() } - //} - - #[doc(alias = "secret_service_unlock_dbus_paths_sync")] - fn unlock_dbus_paths_sync( - &self, - paths: &[&str], - cancellable: Option<&impl IsA>, - ) -> Result<(i32, Vec), glib::Error> { - unsafe { - let mut unlocked = std::ptr::null_mut(); - let mut error = std::ptr::null_mut(); - let ret = ffi::secret_service_unlock_dbus_paths_sync( - self.as_ref().to_glib_none().0, - paths.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut unlocked, - &mut error, - ); - if error.is_null() { - Ok((ret, FromGlibPtrContainer::from_glib_full(unlocked))) - } else { - Err(from_glib_full(error)) - } - } - } - - //#[doc(alias = "secret_service_unlock_sync")] - //fn unlock_sync(&self, objects: &[gio::DBusProxy], cancellable: Option<&impl IsA>, unlocked: /*Unimplemented*/Vec) -> Result { - // unsafe { TODO: call ffi:secret_service_unlock_sync() } - //} -} - -impl> ServiceExt for O {} diff --git a/libsecret/src/auto/versions.txt b/libsecret/src/auto/versions.txt deleted file mode 100644 index 21d9cc7..0000000 --- a/libsecret/src/auto/versions.txt +++ /dev/null @@ -1,3 +0,0 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 4dd714f7f3b1) -from -from gir-files (https://github.com/gtk-rs/gir-files.git @ b9db716f1bb7) diff --git a/libsecret/src/collection.rs b/libsecret/src/collection.rs deleted file mode 100644 index 6360a09..0000000 --- a/libsecret/src/collection.rs +++ /dev/null @@ -1,267 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -use crate::{hashtable::attribute_names_and_values, Item}; -use crate::{Collection, Schema, SearchFlags}; - -use glib::object::IsA; -use glib::translate::*; - -use std::boxed::Box as Box_; -use std::collections::HashMap; -use std::pin::Pin; -use std::ptr; - -pub trait CollectionExtManual: 'static { - #[doc(alias = "secret_collection_search")] - fn search, glib::Error>) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn search_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - ) -> Pin, glib::Error>> + 'static>>; - - #[doc(alias = "secret_collection_search_sync")] - fn search_sync( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - cancellable: Option<&impl IsA>, - ) -> Result, glib::Error>; - - #[doc(alias = "secret_collection_search_for_dbus_paths")] - fn search_for_dbus_paths, glib::Error>) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn search_for_dbus_paths_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - ) -> Pin< - Box_, glib::Error>> + 'static>, - >; - - #[doc(alias = "secret_collection_search_for_dbus_paths_sync")] - fn search_for_dbus_paths_sync( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - ) -> Result, glib::Error>; -} - -impl> CollectionExtManual for O { - fn search, glib::Error>) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn search_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let ret = - ffi::secret_collection_search_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = search_trampoline::

; - - ffi::secret_collection_search( - self.as_ref().to_glib_none().0, - schema.to_glib_none().0, - attribute_names_and_values(attributes), - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn search_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - ) -> Pin, glib::Error>> + 'static>> { - let schema = schema.map(ToOwned::to_owned); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - - obj.search( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - flags, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - fn search_sync( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - cancellable: Option<&impl IsA>, - ) -> Result, glib::Error> { - unsafe { - let mut err = std::ptr::null_mut(); - let res = ffi::secret_collection_search_sync( - self.as_ref().to_glib_none().0, - schema.to_glib_none().0, - attribute_names_and_values(attributes), - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut err, - ); - if err.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(res)) - } else { - Err(from_glib_full(err)) - } - } - } - #[doc(alias = "secret_collection_search_for_dbus_paths_sync")] - fn search_for_dbus_paths_sync( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - ) -> Result, glib::Error> { - unsafe { - let mut err = std::ptr::null_mut(); - let res = ffi::secret_collection_search_for_dbus_paths_sync( - self.as_ref().to_glib_none().0, - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut err, - ); - if err.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(res)) - } else { - Err(from_glib_full(err)) - } - } - } - - #[doc(alias = "secret_collection_search_for_dbus_paths")] - fn search_for_dbus_paths, glib::Error>) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn search_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let ret = ffi::secret_collection_search_for_dbus_paths_finish( - _source_object as *mut _, - res, - &mut error, - ); - let result = if error.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = search_trampoline::

; - - ffi::secret_collection_search_for_dbus_paths( - self.as_ref().to_glib_none().0, - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn search_for_dbus_paths_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - ) -> Pin< - Box_, glib::Error>> + 'static>, - > { - let schema = schema.map(ToOwned::to_owned); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - - obj.search_for_dbus_paths( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } -} diff --git a/libsecret/src/enums.rs b/libsecret/src/enums.rs deleted file mode 100644 index 59de400..0000000 --- a/libsecret/src/enums.rs +++ /dev/null @@ -1,25 +0,0 @@ -use glib::error::ErrorDomain; -use glib::translate::*; - -use crate::Error; - -impl ErrorDomain for Error { - fn domain() -> glib::Quark { - unsafe { from_glib(ffi::secret_error_get_quark()) } - } - - fn code(self) -> i32 { - self.into_glib() - } - - fn from(code: i32) -> Option { - match code { - ffi::SECRET_ERROR_PROTOCOL => Some(Self::Protocol), - ffi::SECRET_ERROR_IS_LOCKED => Some(Self::IsLocked), - ffi::SECRET_ERROR_NO_SUCH_OBJECT => Some(Self::NoSuchObject), - ffi::SECRET_ERROR_ALREADY_EXISTS => Some(Self::AlreadyExists), - ffi::SECRET_ERROR_INVALID_FILE_FORMAT => Some(Self::InvalidFileFormat), - value => Some(Self::__Unknown(value)), - } - } -} diff --git a/libsecret/src/functions.rs b/libsecret/src/functions.rs deleted file mode 100644 index 6dce25e..0000000 --- a/libsecret/src/functions.rs +++ /dev/null @@ -1,741 +0,0 @@ -use std::boxed::Box as Box_; -use std::collections::HashMap; - -use crate::{hashtable::attribute_names_and_values, Schema}; -#[cfg(any(feature = "v0_19", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] -use crate::{Retrievable, SearchFlags, Value}; -use glib::{object::IsA, translate::*}; - -#[doc(alias = "secret_password_clearv_sync")] -#[doc(alias = "secret_password_clear_sync")] -#[doc(alias = "password_clearv_sync")] -pub fn password_clear_sync( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, -) -> Result<(), glib::Error> { - unsafe { - let mut err = std::ptr::null_mut(); - ffi::secret_password_clearv_sync( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|c| c.as_ref()).to_glib_none().0, - &mut err, - ); - if err.is_null() { - Ok(()) - } else { - Err(from_glib_full(err)) - } - } -} - -#[cfg(any(feature = "v0_19", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] -#[doc(alias = "secret_password_lookupv_binary_sync")] -#[doc(alias = "secret_password_lookup_binary_sync")] -#[doc(alias = "password_lookupv_binary_sync")] -pub fn password_lookup_binary_sync( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, -) -> Result, glib::Error> { - unsafe { - let mut err = std::ptr::null_mut(); - let value = ffi::secret_password_lookupv_binary_sync( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|c| c.as_ref()).to_glib_none().0, - &mut err, - ); - if err.is_null() { - Ok(from_glib_full(value)) - } else { - Err(from_glib_full(err)) - } - } -} - -#[doc(alias = "secret_password_lookupv_nonpageable_sync")] -#[doc(alias = "secret_password_lookup_nonpageable_sync")] -#[doc(alias = "password_lookupv_nonpageable_sync")] -pub fn password_lookup_nonpageable_sync( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, -) -> Result { - unsafe { - let mut err = std::ptr::null_mut(); - let res = ffi::secret_password_lookupv_nonpageable_sync( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|c| c.as_ref()).to_glib_none().0, - &mut err, - ); - if err.is_null() { - Ok(from_glib_full(res)) - } else { - Err(from_glib_full(err)) - } - } -} - -#[doc(alias = "secret_password_lookupv_sync")] -#[doc(alias = "secret_password_lookup_sync")] -#[doc(alias = "password_lookupv_sync")] -pub fn password_lookup_sync( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, -) -> Result, glib::Error> { - unsafe { - let mut err = std::ptr::null_mut(); - let res = ffi::secret_password_lookupv_sync( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|c| c.as_ref()).to_glib_none().0, - &mut err, - ); - if err.is_null() { - Ok(from_glib_full(res)) - } else { - Err(from_glib_full(err)) - } - } -} - -#[cfg(any(feature = "v0_19", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] -#[doc(alias = "secret_password_searchv_sync")] -#[doc(alias = "secret_password_search_sync")] -#[doc(alias = "password_searchv_sync")] -pub fn password_search_sync( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - cancellable: Option<&impl IsA>, -) -> Result, glib::Error> { - unsafe { - let mut err = std::ptr::null_mut(); - let res = ffi::secret_password_searchv_sync( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - flags.into_glib(), - cancellable.map(|c| c.as_ref()).to_glib_none().0, - &mut err, - ); - if err.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(res)) - } else { - Err(from_glib_full(err)) - } - } -} - -#[cfg(any(feature = "v0_19", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] -#[doc(alias = "secret_password_storev_binary_sync")] -#[doc(alias = "secret_password_store_binary_sync")] -#[doc(alias = "password_storev_binary_sync")] -pub fn password_store_binary_sync( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - collection: Option<&str>, - label: &str, - value: &Value, - cancellable: Option<&impl IsA>, -) -> Result<(), glib::Error> { - unsafe { - let mut err = std::ptr::null_mut(); - ffi::secret_password_storev_binary_sync( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - collection.to_glib_none().0, - label.to_glib_none().0, - value.to_glib_none().0, - cancellable.map(|c| c.as_ref()).to_glib_none().0, - &mut err, - ); - if err.is_null() { - Ok(()) - } else { - Err(from_glib_full(err)) - } - } -} - -#[doc(alias = "secret_password_storev_sync")] -#[doc(alias = "secret_password_store_sync")] -#[doc(alias = "password_storev_sync")] -pub fn password_store_sync( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - collection: Option<&str>, - label: &str, - password: &str, - cancellable: Option<&impl IsA>, -) -> Result<(), glib::Error> { - unsafe { - let mut err = std::ptr::null_mut(); - ffi::secret_password_storev_sync( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - collection.to_glib_none().0, - label.to_glib_none().0, - password.to_glib_none().0, - cancellable.map(|c| c.as_ref()).to_glib_none().0, - &mut err, - ); - if err.is_null() { - Ok(()) - } else { - Err(from_glib_full(err)) - } - } -} - -#[doc(alias = "secret_password_clearv")] -#[doc(alias = "secret_password_clear")] -#[doc(alias = "password_clearv")] -pub fn password_clear) + 'static>( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, -) { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut err = std::ptr::null_mut(); - ffi::secret_password_clear_finish(res, &mut err); - let result = if err.is_null() { - Ok(()) - } else { - Err(from_glib_full(err)) - }; - - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - - let callback = trampoline::

; - unsafe { - ffi::secret_password_clearv( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|c| c.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } -} - -#[doc(alias = "secret_password_clearv")] -#[doc(alias = "secret_password_clear")] -#[doc(alias = "password_clearv")] -pub async fn password_clear_future( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, -) -> Result<(), glib::Error> { - let schema = schema.map(ToOwned::to_owned); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - gio::GioFuture::new(&(), move |_obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - password_clear( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - }) - .await -} - -#[doc(alias = "secret_password_lookupv")] -#[doc(alias = "secret_password_lookup")] -#[doc(alias = "password_lookupv")] -pub fn password_lookup, glib::Error>) + 'static>( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, -) { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut err = std::ptr::null_mut(); - let res = ffi::secret_password_lookup_finish(res, &mut err); - let result = if err.is_null() { - Ok(from_glib_full(res)) - } else { - Err(from_glib_full(err)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - - let callback = trampoline::

; - unsafe { - ffi::secret_password_lookupv( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|c| c.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } -} - -#[doc(alias = "secret_password_lookupv")] -#[doc(alias = "secret_password_lookup")] -#[doc(alias = "password_lookupv")] -pub async fn password_lookup_future( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, -) -> Result, glib::Error> { - let schema = schema.map(ToOwned::to_owned); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - gio::GioFuture::new(&(), move |_obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - password_lookup( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - }) - .await -} - -#[cfg(any(feature = "v0_19", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] -#[doc(alias = "secret_password_lookupv_binary")] -#[doc(alias = "secret_password_lookup_binary")] -#[doc(alias = "password_lookupv_binary")] -pub fn password_lookup_binary, glib::Error>) + 'static>( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, -) { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn trampoline, glib::Error>) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut err = std::ptr::null_mut(); - let res = ffi::secret_password_lookup_binary_finish(res, &mut err); - let result = if err.is_null() { - Ok(from_glib_full(res)) - } else { - Err(from_glib_full(err)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - - let callback = trampoline::

; - unsafe { - ffi::secret_password_lookupv( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|c| c.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } -} - -#[cfg(any(feature = "v0_19", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] -#[doc(alias = "secret_password_lookupv_binary")] -#[doc(alias = "secret_password_lookup_binary")] -#[doc(alias = "password_lookupv_binary")] -pub async fn password_lookup_binary_future( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, -) -> Result, glib::Error> { - let schema = schema.map(ToOwned::to_owned); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - gio::GioFuture::new(&(), move |_obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - password_lookup_binary( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - }) - .await -} - -#[doc(alias = "secret_password_lookupv_nonpageable")] -#[doc(alias = "secret_password_lookup_nonpageable")] -#[doc(alias = "password_lookupv_nonpageable")] -pub fn password_lookup_nonpageable< - P: FnOnce(Result, glib::Error>) + 'static, ->( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, -) { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut err = std::ptr::null_mut(); - let res = ffi::secret_password_lookup_nonpageable_finish(res, &mut err); - let result = if err.is_null() { - Ok(from_glib_full(res)) - } else { - Err(from_glib_full(err)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - - let callback = trampoline::

; - unsafe { - ffi::secret_password_lookupv( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|c| c.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } -} - -#[doc(alias = "secret_password_lookupv_nonpageable")] -#[doc(alias = "secret_password_lookup_nonpageable")] -#[doc(alias = "password_lookupv_nonpageable")] -pub async fn password_lookup_nonpageable_future( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, -) -> Result, glib::Error> { - let schema = schema.map(ToOwned::to_owned); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - gio::GioFuture::new(&(), move |_obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - password_lookup_nonpageable( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - }) - .await -} - -#[doc(alias = "secret_password_storev")] -#[doc(alias = "secret_password_store")] -#[doc(alias = "password_storev")] -pub fn password_store) + 'static>( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - collection: Option<&str>, - label: &str, - password: &str, - cancellable: Option<&impl IsA>, - callback: P, -) { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut err = std::ptr::null_mut(); - ffi::secret_password_store_finish(res, &mut err); - let result = if err.is_null() { - Ok(()) - } else { - Err(from_glib_full(err)) - }; - - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - - let callback = trampoline::

; - unsafe { - ffi::secret_password_storev( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - collection.to_glib_none().0, - label.to_glib_none().0, - password.to_glib_none().0, - cancellable.map(|c| c.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } -} - -#[doc(alias = "secret_password_storev")] -#[doc(alias = "secret_password_store")] -#[doc(alias = "password_storev")] -pub async fn password_store_future( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - collection: Option<&str>, - label: &str, - password: &str, -) -> Result<(), glib::Error> { - let schema = schema.map(ToOwned::to_owned); - let collection = collection.map(ToOwned::to_owned); - let label = label.to_owned(); - let password = password.to_owned(); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - gio::GioFuture::new(&(), move |_obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - password_store( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - collection.as_ref().map(::std::borrow::Borrow::borrow), - &label, - &password, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - }) - .await -} - -#[cfg(any(feature = "v0_19", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] -#[doc(alias = "secret_password_storev_binary")] -#[doc(alias = "secret_password_store_binary")] -#[doc(alias = "password_storev_binary")] -pub fn password_store_binary) + 'static>( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - collection: Option<&str>, - label: &str, - value: &Value, - cancellable: Option<&impl IsA>, - callback: P, -) { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut err = std::ptr::null_mut(); - let _ = ffi::secret_password_store_finish(res, &mut err); - let result = if err.is_null() { - Ok(()) - } else { - Err(from_glib_full(err)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - - let callback = trampoline::

; - unsafe { - ffi::secret_password_storev_binary( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - collection.to_glib_none().0, - label.to_glib_none().0, - value.to_glib_none().0, - cancellable.map(|c| c.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } -} - -#[cfg(any(feature = "v0_19", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] -#[doc(alias = "secret_password_storev_binary")] -#[doc(alias = "secret_password_store_binary")] -#[doc(alias = "password_storev_binary")] -pub async fn password_store_binary_future( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - collection: Option<&str>, - label: &str, - value: &Value, -) -> Result<(), glib::Error> { - let schema = schema.map(ToOwned::to_owned); - let collection = collection.map(ToOwned::to_owned); - let label = label.to_owned(); - let password = value.clone(); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - gio::GioFuture::new(&(), move |_obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - password_store_binary( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - collection.as_ref().map(::std::borrow::Borrow::borrow), - &label, - &password, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - }) - .await -} - -#[cfg(any(feature = "v0_19", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] -#[doc(alias = "secret_password_searchv")] -#[doc(alias = "secret_password_search")] -#[doc(alias = "password_searchv")] -pub fn password_search, glib::Error>) + 'static>( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - cancellable: Option<&impl IsA>, - callback: P, -) { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn trampoline, glib::Error>) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut err = std::ptr::null_mut(); - let res = ffi::secret_password_search_finish(res, &mut err); - let result = if err.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(res)) - } else { - Err(from_glib_full(err)) - }; - - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - - let callback = trampoline::

; - unsafe { - ffi::secret_password_searchv( - schema.to_glib_none().0, - attribute_names_and_values(attributes), - flags.into_glib(), - cancellable.map(|c| c.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } -} - -#[cfg(any(feature = "v0_19", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] -#[doc(alias = "secret_password_searchv")] -#[doc(alias = "secret_password_search")] -#[doc(alias = "password_searchv")] -pub async fn password_search_future( - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, -) -> Result, glib::Error> { - let schema = schema.map(ToOwned::to_owned); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - gio::GioFuture::new(&(), move |_obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - password_search( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - flags, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - }) - .await -} diff --git a/libsecret/src/hashtable.rs b/libsecret/src/hashtable.rs deleted file mode 100644 index 1f42c95..0000000 --- a/libsecret/src/hashtable.rs +++ /dev/null @@ -1,63 +0,0 @@ -use glib::translate::*; -use std::collections::HashMap; - -use crate::Value; - -pub(crate) unsafe fn attribute_names_and_values( - entry: HashMap<&str, &str>, -) -> *mut glib::ffi::GHashTable { - let hash_table = glib::ffi::g_hash_table_new_full( - Some(glib::ffi::g_str_hash), - Some(glib::ffi::g_str_equal), - Some(glib::ffi::g_free), - Some(glib::ffi::g_free), - ); - - for (key, val) in entry { - let key_ptr: *mut libc::c_char = key.to_glib_full(); - let val_ptr: *mut libc::c_char = val.to_glib_full(); - glib::ffi::g_hash_table_insert(hash_table, key_ptr as *mut _, val_ptr as *mut _); - } - - hash_table -} - -pub(crate) unsafe fn attribute_names_and_properties( - hash_map: HashMap<&str, &glib::Variant>, -) -> *mut glib::ffi::GHashTable { - let hash_table = glib::ffi::g_hash_table_new_full( - Some(glib::ffi::g_str_hash), - Some(glib::ffi::g_str_equal), - Some(glib::ffi::g_free), - Some(glib::ffi::g_free), - ); - - for (name, value) in hash_map { - let key_ptr: *mut libc::c_char = name.to_glib_full(); - glib::ffi::g_hash_table_insert(hash_table, key_ptr as *mut _, value.as_ptr() as _); - } - - hash_table -} - -pub(crate) unsafe fn hash_map_from_glib_none( - ptr: *mut glib::ffi::GHashTable, -) -> HashMap { - unsafe extern "C" fn read_string_hash_table( - key: glib::ffi::gpointer, - value: glib::ffi::gpointer, - hash_map: glib::ffi::gpointer, - ) { - let key: String = from_glib_none(key as *const libc::c_char); - let value: Value = from_glib_none(value as *const ffi::SecretValue); - let hash_map: &mut HashMap = &mut *(hash_map as *mut HashMap); - hash_map.insert(key, value); - } - let mut map = HashMap::with_capacity(glib::ffi::g_hash_table_size(ptr) as usize); - glib::ffi::g_hash_table_foreach( - ptr, - Some(read_string_hash_table), - &mut map as *mut HashMap as *mut _, - ); - map -} diff --git a/libsecret/src/item.rs b/libsecret/src/item.rs deleted file mode 100644 index 0d0d97f..0000000 --- a/libsecret/src/item.rs +++ /dev/null @@ -1,314 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -use crate::{hashtable::attribute_names_and_values, Item}; -use crate::{Collection, ItemCreateFlags, Schema, Value}; - -use glib::object::IsA; -use glib::translate::*; - -use std::boxed::Box as Box_; -use std::collections::HashMap; -use std::pin::Pin; -use std::ptr; - -impl Item { - #[doc(alias = "secret_item_get_attributes")] - pub fn attributes(&self) -> HashMap { - unsafe { - let table = ffi::secret_item_get_attributes(self.to_glib_none().0); - FromGlibPtrContainer::from_glib_full(table) - } - } - - #[doc(alias = "secret_item_create_sync")] - pub fn create_sync( - collection: &impl IsA, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - label: &str, - value: &Value, - flags: ItemCreateFlags, - cancellable: Option<&impl IsA>, - ) -> Result { - unsafe { - let mut err = std::ptr::null_mut(); - let item = ffi::secret_item_create_sync( - collection.as_ref().to_glib_none().0, - schema.to_glib_none().0, - attribute_names_and_values(attributes), - label.to_glib_none().0, - value.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut err, - ); - if err.is_null() { - Ok(from_glib_full(item)) - } else { - Err(from_glib_full(err)) - } - } - } - - #[doc(alias = "secret_item_load_secrets_sync")] - pub fn load_secrets_sync( - items: &[Item], - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut error = ptr::null_mut(); - let is_ok = ffi::secret_item_load_secrets_sync( - items.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut error, - ); - assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); - if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - } - } - } - - #[doc(alias = "secret_item_load_secrets")] - pub fn load_secrets) + 'static>( - items: &[Item], - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn load_secrets_trampoline< - P: FnOnce(Result<(), glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let _ = ffi::secret_item_load_secrets_finish(res, &mut error); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = load_secrets_trampoline::

; - unsafe { - ffi::secret_item_load_secrets( - items.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - pub fn load_secrets_future( - items: &[Item], - ) -> Pin> + 'static>> { - let items = items.to_vec(); - Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { - Self::load_secrets(&items, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - #[doc(alias = "secret_item_create")] - pub fn create) + 'static>( - collection: &impl IsA, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - label: &str, - value: &Value, - flags: ItemCreateFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn create_trampoline< - P: FnOnce(Result) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let ret = ffi::secret_item_create_finish(res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = create_trampoline::

; - - ffi::secret_item_create( - collection.as_ref().to_glib_none().0, - schema.to_glib_none().0, - attribute_names_and_values(attributes), - label.to_glib_none().0, - value.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - pub fn create_future( - collection: &(impl IsA + Clone + 'static), - schema: Option<&Schema>, - attributes: HashMap, - label: &str, - value: &Value, - flags: ItemCreateFlags, - ) -> Pin> + 'static>> { - let collection = collection.clone(); - let schema = schema.map(ToOwned::to_owned); - let label = String::from(label); - let value = value.clone(); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k, v.to_string())) - .collect::>(); - - Box_::pin(gio::GioFuture::new(&(), move |_obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - Self::create( - &collection, - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - &label, - &value, - flags, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - #[doc(alias = "secret_item_set_attributes")] - pub fn set_attributes) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn set_attributes_trampoline< - P: FnOnce(Result<(), glib::Error>) + 'static, - >( - source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut err = ptr::null_mut(); - let _ = - ffi::secret_item_set_attributes_finish(source_object as *mut _, res, &mut err); - let result = if err.is_null() { - Ok(()) - } else { - Err(from_glib_full(err)) - }; - - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = set_attributes_trampoline::

; - - ffi::secret_item_set_attributes( - self.to_glib_none().0, - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - pub fn set_attributes_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - ) -> Pin> + 'static>> { - let schema = schema.map(ToOwned::to_owned); - - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - obj.set_attributes( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - #[doc(alias = "secret_item_set_attributes_sync")] - pub fn set_attributes_sync( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - ) -> Result<(), glib::Error> { - unsafe { - let mut err = std::ptr::null_mut(); - ffi::secret_item_set_attributes_sync( - self.to_glib_none().0, - schema.to_glib_none().0, - attribute_names_and_values(attributes), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut err, - ); - if err.is_null() { - Ok(()) - } else { - Err(from_glib_full(err)) - } - } - } -} diff --git a/libsecret/src/lib.rs b/libsecret/src/lib.rs deleted file mode 100644 index 8d4c306..0000000 --- a/libsecret/src/lib.rs +++ /dev/null @@ -1,123 +0,0 @@ -#![cfg_attr(feature = "dox", feature(doc_cfg))] -//! # Rust Libsecret bindings -//! -//! This library contains safe Rust bindings for -//! [Libsecret](https://gitlab.gnome.org/GNOME/libsecret/), a library that -//! offers access to the Secret Service API. -//! -//! See also -//! -//! - [gtk-rs project overview](https://gtk-rs.org/) -//! -//! ## Usage -//! -//! You can add libsecret by adding it in your `Cargo.toml` file: -//! -//! ```toml -//! [dependencies.secret] -//! package = "libsecret" -//! version = "0.x.y" -//! ``` -//! -//! ### Define a password schema -//! -//! Each stored password has a set of attributes which are later used to lookup -//! the password. The names and types of the attributes are defined in a schema. -//! The schema is usually defined once globally. Here’s how to define a schema: -//! -//! ```no_run -//! let mut attributes = std::collections::HashMap::new(); -//! attributes.insert("number", libsecret::SchemaAttributeType::Integer); -//! attributes.insert("string", libsecret::SchemaAttributeType::String); -//! attributes.insert("even", libsecret::SchemaAttributeType::Boolean); -//! -//! let schema = libsecret::Schema::new("some.app.Id", libsecret::SchemaFlags::NONE, attributes); -//! ``` -//! -//! ### Store a password -//! -//! Each stored password has a set of attributes which are later used to lookup -//! the password. The attributes should not contain secrets, as they are not -//! stored in an encrypted fashion. -//! -//! This first example stores a password asynchronously, and is appropriate for GUI applications so that the UI does not block. -//! -//! ```no_run -//! let mut attributes = std::collections::HashMap::new(); -//! attributes.insert("number", "8"); -//! attributes.insert("string", "eight"); -//! attributes.insert("even", "true"); -//! -//! let collection = libsecret::COLLECTION_DEFAULT; -//! libsecret::password_store_future(Some(&schema), attributes, Some(&collection), "The Label", "the password").await?; -//! ``` -//! -//! ### Lookup a password -//! -//! Each stored password has a set of attributes which are used to lookup the -//! password. If multiple passwords match the lookup attributes, then the one -//! stored most recently is returned. -//! -//! This first example looks up a password asynchronously, and is appropriate -//! for GUI applications so that the UI does not block. -//! -//! ```no_run -//! let mut attributes = std::collections::HashMap::new(); -//! attributes.insert("number", "8"); -//! attributes.insert("even", "true"); -//! -//! let password = libsecret::password_lookup_future(Some(&schema), attributes).await?; -//! ``` -//! ### Remove a password -//! -//! Each stored password has a set of attributes which are used to find which -//! password to remove. If multiple passwords match the attributes, then the one -//! stored most recently is removed. -//! -//! This first example removes a password asynchronously, and is appropriate for -//! GUI applications so that the UI does not block. -//! -//! ```no_run -//! let mut attributes = std::collections::HashMap::new(); -//! attributes.insert("number", "8"); -//! attributes.insert("even", "true"); -//! -//! libsecret::password_clear_future(Some(&schema), attributes).await?; -//! ``` -#[allow(unused_imports)] -mod auto; - -pub use auto::functions::*; -pub use auto::*; -pub use functions::*; - -mod collection; -mod enums; -mod functions; -mod hashtable; -#[allow(clippy::too_many_arguments)] -mod item; -mod prompt; -#[cfg(any(feature = "v0_19", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] -mod retrievable; -mod schema; -mod schema_attribute; -#[allow(clippy::type_complexity)] -#[allow(clippy::too_many_arguments)] -mod service; -mod value; - -pub use value::Value; - -pub use ffi; - -pub mod prelude { - pub use super::auto::traits::*; - pub use super::collection::CollectionExtManual; - pub use super::prompt::PromptExtManual; - #[cfg(any(feature = "v0_19", feature = "dox"))] - #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] - pub use super::retrievable::RetrievableExtManual; - pub use super::service::ServiceExtManual; -} diff --git a/libsecret/src/prompt.rs b/libsecret/src/prompt.rs deleted file mode 100644 index bfb7845..0000000 --- a/libsecret/src/prompt.rs +++ /dev/null @@ -1,100 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -use crate::Prompt; - -use glib::object::IsA; -use glib::translate::*; - -use std::boxed::Box as Box_; -use std::pin::Pin; -use std::ptr; - -pub trait PromptExtManual: 'static { - #[doc(alias = "secret_prompt_perform")] - fn perform) + 'static>( - &self, - window_id: Option<&str>, - return_type: &glib::VariantTy, - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn perform_future( - &self, - window_id: Option<&str>, - return_type: &glib::VariantTy, - ) -> Pin> + 'static>>; -} - -impl> PromptExtManual for O { - fn perform) + 'static>( - &self, - window_id: Option<&str>, - return_type: &glib::VariantTy, - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn perform_trampoline< - P: FnOnce(Result) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let ret = ffi::secret_prompt_perform_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = perform_trampoline::

; - unsafe { - ffi::secret_prompt_perform( - self.as_ref().to_glib_none().0, - window_id.to_glib_none().0, - return_type.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn perform_future( - &self, - window_id: Option<&str>, - return_type: &glib::VariantTy, - ) -> Pin> + 'static>> - { - let window_id = window_id.map(ToOwned::to_owned); - let return_type = return_type.to_owned(); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.perform( - window_id.as_ref().map(::std::borrow::Borrow::borrow), - &return_type, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } -} diff --git a/libsecret/src/retrievable.rs b/libsecret/src/retrievable.rs deleted file mode 100644 index 617d8e3..0000000 --- a/libsecret/src/retrievable.rs +++ /dev/null @@ -1,20 +0,0 @@ -use std::collections::HashMap; - -use crate::Retrievable; -use glib::object::IsA; -use glib::translate::*; - -pub trait RetrievableExtManual: 'static { - #[doc(alias = "secret_retrievable_get_attributes")] - #[doc(alias = "get_attributes")] - fn attributes(&self) -> HashMap; -} - -impl> RetrievableExtManual for O { - fn attributes(&self) -> HashMap { - unsafe { - let table = ffi::secret_retrievable_get_attributes(self.as_ref().to_glib_none().0); - FromGlibPtrContainer::from_glib_full(table) - } - } -} diff --git a/libsecret/src/schema.rs b/libsecret/src/schema.rs deleted file mode 100644 index b3252e2..0000000 --- a/libsecret/src/schema.rs +++ /dev/null @@ -1,37 +0,0 @@ -use crate::{Schema, SchemaAttributeType, SchemaFlags}; -use glib::translate::*; -use std::collections::HashMap; - -impl Schema { - #[doc(alias = "secret_schema_new")] - #[doc(alias = "secret_schema_newv")] - pub fn new( - name: &str, - flags: SchemaFlags, - attribute_names_and_types: HashMap<&str, SchemaAttributeType>, - ) -> Self { - unsafe { - let hash_table = glib::ffi::g_hash_table_new_full( - Some(glib::ffi::g_str_hash), - Some(glib::ffi::g_str_equal), - Some(glib::ffi::g_free), - None, - ); - - for (name, type_) in attribute_names_and_types { - let key_ptr: *mut libc::c_char = name.to_glib_full(); - glib::ffi::g_hash_table_insert( - hash_table, - key_ptr as *mut _, - type_.into_glib() as *mut _, - ); - } - - from_glib_full(ffi::secret_schema_newv( - name.to_glib_none().0, - flags.into_glib(), - hash_table, - )) - } - } -} diff --git a/libsecret/src/schema_attribute.rs b/libsecret/src/schema_attribute.rs deleted file mode 100644 index 562381a..0000000 --- a/libsecret/src/schema_attribute.rs +++ /dev/null @@ -1,12 +0,0 @@ -use crate::{SchemaAttribute, SchemaAttributeType}; -use glib::translate::*; - -impl SchemaAttribute { - pub fn type_(&self) -> SchemaAttributeType { - unsafe { from_glib((*(self.as_ptr())).type_) } - } - - pub fn name(&self) -> glib::GString { - unsafe { from_glib_none((*(self.as_ptr())).name) } - } -} diff --git a/libsecret/src/service.rs b/libsecret/src/service.rs deleted file mode 100644 index 2175667..0000000 --- a/libsecret/src/service.rs +++ /dev/null @@ -1,1147 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -use crate::{ - hashtable::{attribute_names_and_properties, attribute_names_and_values}, - Service, -}; -use crate::{CollectionCreateFlags, Item, ItemCreateFlags, Schema, SearchFlags, Value}; - -use glib::object::IsA; -use glib::translate::*; - -use std::boxed::Box as Box_; -use std::collections::HashMap; -use std::pin::Pin; -use std::ptr; - -pub trait ServiceExtManual: 'static { - #[doc(alias = "secret_service_lock")] - fn lock, glib::Error>) + 'static>( - &self, - objects: &[gio::DBusProxy], - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn lock_future( - &self, - objects: &[gio::DBusProxy], - ) -> Pin< - Box_, glib::Error>> + 'static>, - >; - - #[doc(alias = "secret_service_lock_dbus_paths")] - fn lock_dbus_paths, glib::Error>) + 'static>( - &self, - paths: &[&str], - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn lock_dbus_paths_future( - &self, - paths: &[&str], - ) -> Pin< - Box_, glib::Error>> + 'static>, - >; - - #[doc(alias = "secret_service_lock_dbus_paths_sync")] - fn lock_dbus_paths_sync( - &self, - paths: Vec<&str>, - cancellable: Option<&impl IsA>, - ) -> Result, glib::Error>; - - #[doc(alias = "secret_service_unlock")] - fn unlock, glib::Error>) + 'static>( - &self, - objects: &[gio::DBusProxy], - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn unlock_future( - &self, - objects: &[gio::DBusProxy], - ) -> Pin< - Box_, glib::Error>> + 'static>, - >; - - #[doc(alias = "secret_service_unlock_dbus_paths")] - fn unlock_dbus_paths, glib::Error>) + 'static>( - &self, - paths: &[&str], - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn unlock_dbus_paths_future( - &self, - paths: &[&str], - ) -> Pin< - Box_, glib::Error>> + 'static>, - >; - - #[doc(alias = "secret_service_store")] - fn store) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - collection: Option<&str>, - label: &str, - value: &Value, - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn store_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - collection: Option<&str>, - label: &str, - value: &Value, - ) -> Pin> + 'static>>; - - #[doc(alias = "secret_service_search")] - fn search, glib::Error>) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn search_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - ) -> Pin, glib::Error>> + 'static>>; - - #[doc(alias = "secret_service_lookup")] - fn lookup) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn lookup_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - ) -> Pin> + 'static>>; - - #[doc(alias = "secret_service_clear")] - fn clear) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn clear_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - ) -> Pin> + 'static>>; - - #[doc(alias = "secret_service_create_item_dbus_path")] - fn create_item_dbus_path) + 'static>( - &self, - collection_path: &str, - properties: HashMap<&str, &glib::Variant>, - value: &Value, - flags: ItemCreateFlags, - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn create_item_dbus_path_future( - &self, - collection_path: &str, - properties: HashMap<&str, &glib::Variant>, - value: &Value, - flags: ItemCreateFlags, - ) -> Pin> + 'static>>; - - #[doc(alias = "secret_service_create_collection_dbus_path")] - fn create_collection_dbus_path) + 'static>( - &self, - properties: HashMap<&str, &glib::Variant>, - alias: Option<&str>, - flags: CollectionCreateFlags, - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn create_collection_dbus_path_future( - &self, - properties: HashMap<&str, &glib::Variant>, - alias: Option<&str>, - flags: CollectionCreateFlags, - ) -> Pin> + 'static>>; - - #[doc(alias = "secret_service_get_secrets_for_dbus_paths")] - #[doc(alias = "get_secrets_for_dbus_paths")] - fn secrets_for_dbus_paths, glib::Error>) + 'static>( - &self, - item_paths: &str, - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn secrets_for_dbus_paths_future( - &self, - item_paths: &str, - ) -> Pin< - Box_< - dyn std::future::Future, glib::Error>> + 'static, - >, - >; - - #[doc(alias = "secret_service_search_for_dbus_paths")] - fn search_for_dbus_paths< - P: FnOnce(Result<(Vec, Vec), glib::Error>) + 'static, - >( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, - ); - - fn search_for_dbus_paths_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - ) -> Pin< - Box_< - dyn std::future::Future< - Output = Result<(Vec, Vec), glib::Error>, - > + 'static, - >, - >; -} - -impl> ServiceExtManual for O { - #[doc(alias = "secret_lock_dbus_paths_sync")] - fn lock_dbus_paths_sync( - &self, - paths: Vec<&str>, - cancellable: Option<&impl IsA>, - ) -> Result, glib::Error> { - unsafe { - let mut locked = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::secret_service_lock_dbus_paths_sync( - self.as_ref().to_glib_none().0, - paths.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - &mut locked, - &mut error, - ); - if error.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(locked)) - } else { - Err(from_glib_full(error)) - } - } - } - - fn unlock_dbus_paths, glib::Error>) + 'static>( - &self, - paths: &[&str], - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn unlock_dbus_paths_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let mut unlocked = ptr::null_mut(); - let _ = ffi::secret_service_unlock_dbus_paths_finish( - _source_object as *mut _, - res, - &mut unlocked, - &mut error, - ); - let result = if error.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(unlocked)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = unlock_dbus_paths_trampoline::

; - - unsafe { - ffi::secret_service_unlock_dbus_paths( - self.as_ref().to_glib_none().0, - paths.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn unlock_dbus_paths_future( - &self, - paths: &[&str], - ) -> Pin< - Box_, glib::Error>> + 'static>, - > { - let paths = paths.iter().copied().map(String::from).collect::>(); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let paths = paths.iter().map(|s| s.as_str()).collect::>(); - obj.unlock_dbus_paths(&paths, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - fn unlock, glib::Error>) + 'static>( - &self, - objects: &[gio::DBusProxy], - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn unlock_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let mut unlocked = ptr::null_mut(); - let _ = ffi::secret_service_unlock_finish( - _source_object as *mut _, - res, - &mut unlocked, - &mut error, - ); - let result = if error.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(unlocked)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = unlock_trampoline::

; - unsafe { - ffi::secret_service_unlock( - self.as_ref().to_glib_none().0, - objects.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn unlock_future( - &self, - objects: &[gio::DBusProxy], - ) -> Pin< - Box_, glib::Error>> + 'static>, - > { - let objects = objects.to_vec(); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.unlock(&objects, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - fn lock_dbus_paths, glib::Error>) + 'static>( - &self, - paths: &[&str], - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn lock_dbus_paths_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let mut locked = ptr::null_mut(); - let _ = ffi::secret_service_lock_dbus_paths_finish( - _source_object as *mut _, - res, - &mut locked, - &mut error, - ); - let result = if error.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(locked)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = lock_dbus_paths_trampoline::

; - unsafe { - ffi::secret_service_lock_dbus_paths( - self.as_ref().to_glib_none().0, - paths.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn lock_dbus_paths_future( - &self, - paths: &[&str], - ) -> Pin< - Box_, glib::Error>> + 'static>, - > { - let paths = paths.iter().copied().map(String::from).collect::>(); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let paths = paths.iter().map(|s| s.as_str()).collect::>(); - obj.lock_dbus_paths(&paths, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - fn lock, glib::Error>) + 'static>( - &self, - objects: &[gio::DBusProxy], - cancellable: Option<&impl IsA>, - callback: P, - ) { - let main_context = glib::MainContext::ref_thread_default(); - let is_main_context_owner = main_context.is_owner(); - let has_acquired_main_context = (!is_main_context_owner) - .then(|| main_context.acquire().ok()) - .flatten(); - assert!( - is_main_context_owner || has_acquired_main_context.is_some(), - "Async operations only allowed if the thread is owning the MainContext" - ); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn lock_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let mut locked = ptr::null_mut(); - let _ = ffi::secret_service_lock_finish( - _source_object as *mut _, - res, - &mut locked, - &mut error, - ); - let result = if error.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(locked)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = lock_trampoline::

; - unsafe { - ffi::secret_service_lock( - self.as_ref().to_glib_none().0, - objects.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn lock_future( - &self, - objects: &[gio::DBusProxy], - ) -> Pin< - Box_, glib::Error>> + 'static>, - > { - let objects = objects.to_vec(); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.lock(&objects, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - fn store) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - collection: Option<&str>, - label: &str, - value: &Value, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn store_trampoline) + 'static>( - source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let _ = ffi::secret_service_store_finish(source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = store_trampoline::

; - - ffi::secret_service_store( - self.as_ref().to_glib_none().0, - schema.to_glib_none().0, - attribute_names_and_values(attributes), - collection.to_glib_none().0, - label.to_glib_none().0, - value.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn store_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - collection: Option<&str>, - label: &str, - value: &Value, - ) -> Pin> + 'static>> { - let schema = schema.map(ToOwned::to_owned); - let collection = collection.map(ToOwned::to_owned); - let label = String::from(label); - let value = value.clone(); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - obj.store( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - collection.as_ref().map(::std::borrow::Borrow::borrow), - &label, - &value, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - fn search, glib::Error>) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn search_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let ret = - ffi::secret_service_search_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(FromGlibPtrContainer::from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = search_trampoline::

; - - ffi::secret_service_search( - self.as_ref().to_glib_none().0, - schema.to_glib_none().0, - attribute_names_and_values(attributes), - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn search_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - flags: SearchFlags, - ) -> Pin, glib::Error>> + 'static>> { - let schema = schema.map(ToOwned::to_owned); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - obj.search( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - flags, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - fn lookup) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let hash_table = attribute_names_and_values(attributes); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn lookup_trampoline< - P: FnOnce(Result) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let ret = - ffi::secret_service_lookup_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = lookup_trampoline::

; - - ffi::secret_service_lookup( - self.as_ref().to_glib_none().0, - schema.to_glib_none().0, - hash_table, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn lookup_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - ) -> Pin> + 'static>> { - let schema = schema.map(ToOwned::to_owned); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - - obj.lookup( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - fn clear) + 'static>( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let hash_table = attribute_names_and_values(attributes); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn clear_trampoline) + 'static>( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let _ = ffi::secret_service_clear_finish(_source_object as *mut _, res, &mut error); - let result = if error.is_null() { - Ok(()) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = clear_trampoline::

; - - ffi::secret_service_clear( - self.as_ref().to_glib_none().0, - schema.to_glib_none().0, - hash_table, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn clear_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - ) -> Pin> + 'static>> { - let schema = schema.map(ToOwned::to_owned); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - obj.clear( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - fn create_item_dbus_path) + 'static>( - &self, - collection_path: &str, - properties: HashMap<&str, &glib::Variant>, - value: &Value, - flags: ItemCreateFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let hash_table = attribute_names_and_properties(properties); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn create_item_dbus_path_trampoline< - P: FnOnce(Result) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let ret = ffi::secret_service_create_item_dbus_path_finish( - _source_object as *mut _, - res, - &mut error, - ); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = create_item_dbus_path_trampoline::

; - - ffi::secret_service_create_item_dbus_path( - self.as_ref().to_glib_none().0, - collection_path.to_glib_none().0, - hash_table, - value.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn create_item_dbus_path_future( - &self, - collection_path: &str, - properties: HashMap<&str, &glib::Variant>, - value: &Value, - flags: ItemCreateFlags, - ) -> Pin> + 'static>> - { - let collection_path = String::from(collection_path); - let value = value.clone(); - let owned_map = properties - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_owned())) - .collect::>(); - - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let properties = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v)) - .collect::>(); - obj.create_item_dbus_path( - &collection_path, - properties, - &value, - flags, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - fn create_collection_dbus_path) + 'static>( - &self, - properties: HashMap<&str, &glib::Variant>, - alias: Option<&str>, - flags: CollectionCreateFlags, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let hash_table = attribute_names_and_properties(properties); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn create_collection_dbus_path_trampoline< - P: FnOnce(Result) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let ret = ffi::secret_service_create_collection_dbus_path_finish( - _source_object as *mut _, - res, - &mut error, - ); - let result = if error.is_null() { - Ok(from_glib_full(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = create_collection_dbus_path_trampoline::

; - - ffi::secret_service_create_collection_dbus_path( - self.as_ref().to_glib_none().0, - hash_table, - alias.to_glib_none().0, - flags.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn create_collection_dbus_path_future( - &self, - properties: HashMap<&str, &glib::Variant>, - alias: Option<&str>, - flags: CollectionCreateFlags, - ) -> Pin> + 'static>> - { - let alias = alias.map(ToOwned::to_owned); - let owned_map = properties - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_owned())) - .collect::>(); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let properties = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v)) - .collect::>(); - obj.create_collection_dbus_path( - properties, - alias.as_ref().map(::std::borrow::Borrow::borrow), - flags, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } - - fn secrets_for_dbus_paths, glib::Error>) + 'static>( - &self, - item_paths: &str, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn secrets_for_dbus_paths_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let ret = ffi::secret_service_get_secrets_for_dbus_paths_finish( - _source_object as *mut _, - res, - &mut error, - ); - - let result = if error.is_null() { - Ok(crate::hashtable::hash_map_from_glib_none(ret)) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = secrets_for_dbus_paths_trampoline::

; - - let mut item_paths = item_paths.to_string(); - ffi::secret_service_get_secrets_for_dbus_paths( - self.as_ref().to_glib_none().0, - &mut item_paths as *mut _ as *mut *const libc::c_char, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn secrets_for_dbus_paths_future( - &self, - item_paths: &str, - ) -> Pin< - Box_< - dyn std::future::Future, glib::Error>> + 'static, - >, - > { - let item_paths = String::from(item_paths); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - obj.secrets_for_dbus_paths(&item_paths, Some(cancellable), move |res| { - send.resolve(res); - }); - })) - } - - fn search_for_dbus_paths< - P: FnOnce(Result<(Vec, Vec), glib::Error>) + 'static, - >( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - cancellable: Option<&impl IsA>, - callback: P, - ) { - unsafe { - let hash_table = attribute_names_and_values(attributes); - - let user_data: Box_> = - Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn search_for_dbus_paths_trampoline< - P: FnOnce(Result<(Vec, Vec), glib::Error>) + 'static, - >( - _source_object: *mut glib::gobject_ffi::GObject, - res: *mut gio::ffi::GAsyncResult, - user_data: glib::ffi::gpointer, - ) { - let mut error = ptr::null_mut(); - let mut unlocked = ptr::null_mut(); - let mut locked = ptr::null_mut(); - let _ = ffi::secret_service_search_for_dbus_paths_finish( - _source_object as *mut _, - res, - &mut unlocked, - &mut locked, - &mut error, - ); - let result = if error.is_null() { - Ok(( - FromGlibPtrContainer::from_glib_full(unlocked), - FromGlibPtrContainer::from_glib_full(locked), - )) - } else { - Err(from_glib_full(error)) - }; - let callback: Box_> = - Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); - callback(result); - } - let callback = search_for_dbus_paths_trampoline::

; - - ffi::secret_service_search_for_dbus_paths( - self.as_ref().to_glib_none().0, - schema.to_glib_none().0, - hash_table, - cancellable.map(|p| p.as_ref()).to_glib_none().0, - Some(callback), - Box_::into_raw(user_data) as *mut _, - ); - } - } - - fn search_for_dbus_paths_future( - &self, - schema: Option<&Schema>, - attributes: HashMap<&str, &str>, - ) -> Pin< - Box_< - dyn std::future::Future< - Output = Result<(Vec, Vec), glib::Error>, - > + 'static, - >, - > { - let schema = schema.map(ToOwned::to_owned); - let owned_map = attributes - .into_iter() - .map(|(k, v)| (k.to_string(), v.to_string())) - .collect::>(); - Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { - let attributes = owned_map - .iter() - .map(|(k, v)| (k.as_str(), v.as_str())) - .collect::>(); - obj.search_for_dbus_paths( - schema.as_ref().map(::std::borrow::Borrow::borrow), - attributes, - Some(cancellable), - move |res| { - send.resolve(res); - }, - ); - })) - } -} diff --git a/libsecret/src/value.rs b/libsecret/src/value.rs deleted file mode 100644 index ef43da8..0000000 --- a/libsecret/src/value.rs +++ /dev/null @@ -1,67 +0,0 @@ -use glib::translate::*; -use std::mem; -use std::os::raw::c_void; - -glib::wrapper! { - #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub struct Value(Shared); - - match fn { - ref => |ptr| ffi::secret_value_ref(ptr), - // Manual - unref => |ptr| ffi::secret_value_unref(ptr as *mut _ as *mut c_void), - type_ => || ffi::secret_value_get_type(), - } -} - -impl Value { - #[doc(alias = "secret_value_new")] - pub fn new(secret: &str, content_type: &str) -> Value { - let length = secret.len() as isize; - unsafe { - from_glib_full(ffi::secret_value_new( - secret.to_glib_none().0, - length, - content_type.to_glib_none().0, - )) - } - } - - #[doc(alias = "secret_value_get")] - pub fn get(&self) -> Vec { - unsafe { - let mut length = mem::MaybeUninit::uninit(); - let ret = FromGlibContainer::from_glib_none_num( - ffi::secret_value_get(self.to_glib_none().0, length.as_mut_ptr()), - length.assume_init() as _, - ); - ret - } - } - - #[doc(alias = "secret_value_get_content_type")] - #[doc(alias = "get_content_type")] - pub fn content_type(&self) -> glib::GString { - unsafe { from_glib_none(ffi::secret_value_get_content_type(self.to_glib_none().0)) } - } - - #[doc(alias = "secret_value_get_text")] - #[doc(alias = "get_text")] - pub fn text(&self) -> Option { - unsafe { from_glib_none(ffi::secret_value_get_text(self.to_glib_none().0)) } - } - - #[cfg(any(feature = "v0_19", feature = "dox"))] - #[cfg_attr(feature = "dox", doc(cfg(feature = "v0_19")))] - #[doc(alias = "secret_value_unref_to_password")] - pub fn unref_to_password(&self) -> glib::GString { - unsafe { - let mut length = std::mem::MaybeUninit::uninit(); - let password = - ffi::secret_value_unref_to_password(self.to_glib_none().0, length.as_mut_ptr()); - length.assume_init(); - - from_glib_full(password) - } - } -} -- cgit 1.4.1