From 56f90332db822e73f42be1192a5d795d43a09603 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 16:42:38 -0700 Subject: [PATCH 01/20] Attempt to build against glib-rs 0.1.3 This is a newer version of glib-rs than the original crate was compiled against. glib-rs 0.0.x fails to compile on Rust 1.22 (2017/11) or newer and much older compilers are just broken in a modern environment. There was a conflict between the libsecret-sys being loaded as private, but the ffi module was exported as public. Defaulted it to private as well. --- Cargo.toml | 3 ++- secret-sys/Cargo.toml | 5 +++-- secret-sys/src/lib.rs | 6 ++++-- src/lib.rs | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9eb7dc2..1af6fdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,8 @@ license = "MIT" [dependencies] libc = "*" -glib = "*" +glib = "0.1.3" +glib-sys = "0.3.4" [dependencies.secret-sys] path = "secret-sys" diff --git a/secret-sys/Cargo.toml b/secret-sys/Cargo.toml index e36f973..fff71f5 100644 --- a/secret-sys/Cargo.toml +++ b/secret-sys/Cargo.toml @@ -10,7 +10,8 @@ license = "MIT" [dependencies] libc = "*" -glib = "*" +glib = "0.1.3" +glib-sys = "0.3.4" [build-dependencies] -pkg-config = "0.3" +pkg-config = "=0.3.12" diff --git a/secret-sys/src/lib.rs b/secret-sys/src/lib.rs index 5acc03f..8db3fed 100644 --- a/secret-sys/src/lib.rs +++ b/secret-sys/src/lib.rs @@ -1,9 +1,11 @@ #![allow(non_camel_case_types)] extern crate libc; extern crate glib; +extern crate glib_sys; -use libc::{c_uint, c_char, c_int, c_ulong, c_long}; -use glib::ffi::{GError, GType, GList, gboolean, gsize, gpointer, GHashTable}; +use libc::{c_uint, c_char, c_int, c_ulong, c_long, size_t}; +use glib_sys::{GError, GType, GList, gboolean, gpointer, GHashTable}; +type gsize = size_t; //glib stuff not provided by glib-rs pub type gchar = c_char; diff --git a/src/lib.rs b/src/lib.rs index f163a2a..a7a56b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,7 @@ mod secret_item; mod secret_value; mod util; -pub use self::secret_sys as ffi; +use self::secret_sys as ffi; pub use self::secret_service::SecretService; pub use self::secret_collection::SecretCollection; pub use self::secret_item::SecretItem; From dd13728e0372c2a5be8b49eab03c0c08c533089d Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 18:29:25 -0700 Subject: [PATCH 02/20] Use glib_wrapper! macro for object wrappers and fixed trait bounds This version nearly compiles successfully with Rust 1.22 and glib 0.1.3. There are a few lines in util.rs that need to be commented out for that. A slightly newer version of glib-rs should have some improvements to fix that bit of code. --- secret-sys/Cargo.toml | 1 - secret-sys/src/lib.rs | 1 - src/lib.rs | 4 +++- src/secret_collection.rs | 38 +++++++++----------------------------- src/secret_item.rs | 36 ++++++++---------------------------- src/secret_service.rs | 37 ++++++++----------------------------- src/util.rs | 11 +++++------ 7 files changed, 33 insertions(+), 95 deletions(-) diff --git a/secret-sys/Cargo.toml b/secret-sys/Cargo.toml index fff71f5..0dcc777 100644 --- a/secret-sys/Cargo.toml +++ b/secret-sys/Cargo.toml @@ -10,7 +10,6 @@ license = "MIT" [dependencies] libc = "*" -glib = "0.1.3" glib-sys = "0.3.4" [build-dependencies] diff --git a/secret-sys/src/lib.rs b/secret-sys/src/lib.rs index 8db3fed..a877dac 100644 --- a/secret-sys/src/lib.rs +++ b/secret-sys/src/lib.rs @@ -1,6 +1,5 @@ #![allow(non_camel_case_types)] extern crate libc; -extern crate glib; extern crate glib_sys; use libc::{c_uint, c_char, c_int, c_ulong, c_long, size_t}; diff --git a/src/lib.rs b/src/lib.rs index a7a56b4..c98f90c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,9 @@ //! gnome project. extern crate libc; +#[macro_use] extern crate glib; +extern crate glib_sys; extern crate secret_sys; mod secret_service; @@ -25,7 +27,7 @@ pub use self::secret_item::SecretItem; pub use self::secret_value::SecretValue; use glib::Error; -use glib::object::Wrapper; +use glib::wrapper::Wrapper; /// A Result which may contain an error from the SecretService backend. pub type SecretResult = Result; diff --git a/src/secret_collection.rs b/src/secret_collection.rs index 0551d6b..9131900 100644 --- a/src/secret_collection.rs +++ b/src/secret_collection.rs @@ -1,9 +1,8 @@ use std::ptr; use glib::Error; -use glib::object::{Object, Upcast, Wrapper, Ref}; +use glib::object::{Object}; use glib::types::{StaticType, Type}; use glib::translate::*; -use glib::glib_container::GlibContainer; use secret_service::SecretService; use secret_item::SecretItem; use SecretResult; @@ -17,7 +16,13 @@ use ffi; /// `Lock::unlock()` to lock or unlock the collection. /// Use `get_items()` to lookup the items in the collection. There may not be /// any items exposed when the collection is locked. -pub struct SecretCollection(Ref); +glib_wrapper! { + pub struct SecretCollection(Object); + + match fn { + get_type => || ffi::secret_collection_get_type(), + } +} impl SecretCollection { @@ -68,7 +73,7 @@ impl SecretCollection { unsafe { from_glib_full(ptr) } - ) + ) } else { Err(Error::wrap(err)) } @@ -203,31 +208,6 @@ impl SecretCollection { } } -impl StaticType for SecretCollection { - fn static_type() -> Type{ - unsafe { - from_glib(ffi::secret_collection_get_type()) - } - } -} - -unsafe impl Upcast for SecretCollection { } - -impl Wrapper for SecretCollection { - type GlibType = ffi::SecretCollection; - unsafe fn wrap(r: Ref) -> Self{ - SecretCollection(r) - } - - fn as_ref(&self) -> &Ref{ - &self.0 - } - - fn unwrap(self) -> Ref{ - self.0 - } -} - impl Lock for SecretCollection { fn lock(&self) -> SecretResult>{ diff --git a/src/secret_item.rs b/src/secret_item.rs index 08be80c..db4305b 100644 --- a/src/secret_item.rs +++ b/src/secret_item.rs @@ -1,8 +1,7 @@ use std::ptr; use std::collections::HashMap; use glib::Error; -use glib::glib_container::GlibContainer; -use glib::object::{Wrapper, Ref, Object, Upcast}; +use glib::object::{Object}; use glib::types::{StaticType, Type}; use glib::translate::*; use secret_service::SecretService; @@ -28,7 +27,13 @@ use Lock; /// attributes associated with an item. /// Items can be created with `create()` or `SecretService::store()`. /// -pub struct SecretItem(Ref); +glib_wrapper! { + pub struct SecretItem(Object); + + match fn { + get_type => || ffi::secret_item_get_type(), + } +} impl SecretItem { @@ -202,31 +207,6 @@ impl SecretItem { } } -impl StaticType for SecretItem { - fn static_type() -> Type{ - unsafe { - from_glib(ffi::secret_item_get_type()) - } - } -} - -unsafe impl Upcast for SecretItem { } - -impl Wrapper for SecretItem { - type GlibType = ffi::SecretItem; - unsafe fn wrap(r: Ref) -> Self{ - SecretItem(r) - } - - fn as_ref(&self) -> &Ref{ - &self.0 - } - - fn unwrap(self) -> Ref{ - self.0 - } -} - impl Lock for SecretItem { fn lock(&self) -> SecretResult>{ diff --git a/src/secret_service.rs b/src/secret_service.rs index 921de83..cea3b20 100644 --- a/src/secret_service.rs +++ b/src/secret_service.rs @@ -11,8 +11,7 @@ pub use secret_value::*; use std::ptr; use std::collections::HashMap; use glib::Error; -use glib::glib_container::GlibContainer; -use glib::object::{Ref, Wrapper, Object, Upcast}; +use glib::object::{Object}; use glib::types::{StaticType, Type}; use glib::translate::*; use SecretResult; @@ -32,7 +31,13 @@ use ffi; /// prompt is necessary, then a SecretPrompt object is created by libsecret, /// and passed to the secret_service_prompt() method. In this way it is handled /// automatically. -pub struct SecretService(Ref); +glib_wrapper! { + pub struct SecretService(Object); + + match fn { + get_type => || ffi::secret_service_get_type(), + } +} impl SecretService { @@ -206,32 +211,6 @@ impl SecretService { } } -unsafe impl Upcast for SecretService { } - -impl StaticType for SecretService { - fn static_type() -> Type{ - unsafe { - from_glib(ffi::secret_service_get_type()) - } - } -} - -impl Wrapper for SecretService { - type GlibType = ffi::SecretService; - - unsafe fn wrap(r: Ref) -> Self{ - SecretService(r) - } - - fn as_ref(&self) -> &Ref{ - &self.0 - } - - fn unwrap(self) -> Ref{ - self.0 - } -} - #[allow(dead_code)] const SECRET_SERVICE_NONE: i32 = 0; const SECRET_SERVICE_OPEN_SESSION: i32 = 1 << 1; diff --git a/src/util.rs b/src/util.rs index 1615a0e..5b490ee 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,16 +1,15 @@ use std::ptr; use glib::Error; -use glib::ffi::{GList}; -use glib::object::{Wrapper}; -use glib::translate::{ToGlibPtr, FromGlibPtrContainer}; -use glib::glib_container::GlibContainer; +use glib_sys::{GList}; +use glib::wrapper::{Wrapper}; +use glib::translate::{ToGlibPtr, FromGlibPtrContainer, GlibPtrDefault}; use glib::types::StaticType; use secret_item::SecretItem; use secret_collection::SecretCollection; use ffi; use SecretResult; -pub fn lock_object(obj: &W) -> SecretResult>{ +pub fn lock_object(obj: &W) -> SecretResult>{ debug_assert!(W::static_type() == SecretItem::static_type() || W::static_type() == SecretCollection::static_type(), "Can only lock items or collections"); let mut err = ptr::null_mut(); let mut res = ptr::null_mut(); @@ -32,7 +31,7 @@ pub fn lock_object(obj: &W) -> SecretResult>{ } } -pub fn unlock_object(obj: &W) -> SecretResult>{ +pub fn unlock_object(obj: &W) -> SecretResult>{ debug_assert!(W::static_type() == SecretItem::static_type() || W::static_type() == SecretCollection::static_type(), "Can only unlock items or collections"); let mut err = ptr::null_mut(); let mut res = ptr::null_mut(); From 4b7a67720802e182aa89abe9c888c6c9835214b8 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 18:37:00 -0700 Subject: [PATCH 03/20] Cleaned up some warnings --- src/secret_collection.rs | 2 -- src/secret_item.rs | 2 -- src/secret_service.rs | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/secret_collection.rs b/src/secret_collection.rs index 9131900..fac0ce0 100644 --- a/src/secret_collection.rs +++ b/src/secret_collection.rs @@ -1,7 +1,5 @@ use std::ptr; use glib::Error; -use glib::object::{Object}; -use glib::types::{StaticType, Type}; use glib::translate::*; use secret_service::SecretService; use secret_item::SecretItem; diff --git a/src/secret_item.rs b/src/secret_item.rs index db4305b..70ecd0a 100644 --- a/src/secret_item.rs +++ b/src/secret_item.rs @@ -1,8 +1,6 @@ use std::ptr; use std::collections::HashMap; use glib::Error; -use glib::object::{Object}; -use glib::types::{StaticType, Type}; use glib::translate::*; use secret_service::SecretService; use secret_collection::SecretCollection; diff --git a/src/secret_service.rs b/src/secret_service.rs index cea3b20..a1bd85c 100644 --- a/src/secret_service.rs +++ b/src/secret_service.rs @@ -11,8 +11,6 @@ pub use secret_value::*; use std::ptr; use std::collections::HashMap; use glib::Error; -use glib::object::{Object}; -use glib::types::{StaticType, Type}; use glib::translate::*; use SecretResult; use ffi; From cf4d013318cd4c61f9b444fb1a069d80069ee91d Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 19:02:03 -0700 Subject: [PATCH 04/20] Applied fixes to bump it up to glib 0.3.4 Except for the few lines in util.rs mentioned in the last commit that need to be commented out, this compiles with the newer glib-rs and passes the test suite. --- Cargo.toml | 5 +++-- secret-sys/Cargo.toml | 2 +- src/lib.rs | 1 + src/secret_collection.rs | 3 +++ src/secret_item.rs | 3 +++ src/secret_service.rs | 3 +++ 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1af6fdc..2f3ea85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,9 @@ license = "MIT" [dependencies] libc = "*" -glib = "0.1.3" -glib-sys = "0.3.4" +glib = "0.3.1" +glib-sys = "0.4.0" +gobject-sys = "0.4.0" [dependencies.secret-sys] path = "secret-sys" diff --git a/secret-sys/Cargo.toml b/secret-sys/Cargo.toml index 0dcc777..b2e9b38 100644 --- a/secret-sys/Cargo.toml +++ b/secret-sys/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" [dependencies] libc = "*" -glib-sys = "0.3.4" +glib-sys = "0.4.0" [build-dependencies] pkg-config = "=0.3.12" diff --git a/src/lib.rs b/src/lib.rs index c98f90c..32046cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,7 @@ extern crate libc; #[macro_use] extern crate glib; extern crate glib_sys; +extern crate gobject_sys; extern crate secret_sys; mod secret_service; diff --git a/src/secret_collection.rs b/src/secret_collection.rs index fac0ce0..b42e7b9 100644 --- a/src/secret_collection.rs +++ b/src/secret_collection.rs @@ -7,6 +7,9 @@ use SecretResult; use util::{lock_object, unlock_object}; use Lock; use ffi; +use glib_sys as glib_ffi; // FIXME workaround for bug in glib 0.3.1 +use std::mem; // FIXME workaround for bug in glib 0.3.1 +use gobject_sys as gobject_ffi; // FIXME workaround for bug in glib 0.3.1 /// SecretCollection represents a collection of secret items stored in the /// Secret Service. diff --git a/src/secret_item.rs b/src/secret_item.rs index 70ecd0a..5dc3ada 100644 --- a/src/secret_item.rs +++ b/src/secret_item.rs @@ -7,6 +7,9 @@ use secret_collection::SecretCollection; use secret_value::SecretValue; use SecretResult; use ffi; +use glib_sys as glib_ffi; // FIXME workaround for bug in glib 0.3.1 +use std::mem; // FIXME workaround for bug in glib 0.3.1 +use gobject_sys as gobject_ffi; // FIXME workaround for bug in glib 0.3.1 use util::{lock_object, unlock_object}; use Lock; diff --git a/src/secret_service.rs b/src/secret_service.rs index a1bd85c..2f7463f 100644 --- a/src/secret_service.rs +++ b/src/secret_service.rs @@ -14,6 +14,9 @@ use glib::Error; use glib::translate::*; use SecretResult; use ffi; +use glib_sys as glib_ffi; // FIXME workaround for bug in glib 0.3.1 +use std::mem; // FIXME workaround for bug in glib 0.3.1 +use gobject_sys as gobject_ffi; // FIXME workaround for bug in glib 0.3.1 /// A SecretService object represents the Secret Service implementation which /// runs as a D-Bus service. From 3bd0a1f67b4f35f882c89212a21d0594a01e79f3 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 20:38:01 -0700 Subject: [PATCH 05/20] FIXME: Revert this workaround for compilation errors This comments out lines that breaks the lock/unlock calls for secret items and collections. This will need to be reverted once the correct code has been implemented to get this to compile on glib-rs. With this workaround added, the crate compiled even with current stable and nightly compilers using this older glib 0.3.1 crate. --- src/util.rs | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/util.rs b/src/util.rs index 5b490ee..8e7dcd6 100644 --- a/src/util.rs +++ b/src/util.rs @@ -3,31 +3,35 @@ use glib::Error; use glib_sys::{GList}; use glib::wrapper::{Wrapper}; use glib::translate::{ToGlibPtr, FromGlibPtrContainer, GlibPtrDefault}; +use glib::translate::ToGlibContainerFromSlice; use glib::types::StaticType; use secret_item::SecretItem; use secret_collection::SecretCollection; use ffi; use SecretResult; -pub fn lock_object(obj: &W) -> SecretResult>{ +//pub fn lock_object<'a, W: Wrapper + StaticType + GlibPtrDefault + ToGlibContainerFromSlice<'a, *mut ::GlibType>>(obj: &W) -> SecretResult>{ +//pub fn lock_object<'a, W: Wrapper + StaticType + GlibPtrDefault + ToGlibContainerFromSlice<'a, *mut GList>>(obj: &W) -> SecretResult>{ +pub fn lock_object<'a, W: Wrapper + StaticType + GlibPtrDefault + ToGlibPtr<'a, ::GlibType>>(obj: &'a W) -> SecretResult>{ debug_assert!(W::static_type() == SecretItem::static_type() || W::static_type() == SecretCollection::static_type(), "Can only lock items or collections"); let mut err = ptr::null_mut(); let mut res = ptr::null_mut(); let arr = [obj]; - let slice = (&arr[..]).to_glib_none(); + //let slice: (*mut GList, <&W as ToGlibContainerFromSlice<'a, *mut GList>>::Storage) = ToGlibContainerFromSlice::to_glib_none_from_slice(&arr[..]); unsafe { ffi::secret_service_lock_sync( ptr::null_mut(), - slice.0 as *mut GList, + //slice.0 as *mut GList, + ptr::null_mut(), ptr::null_mut(), &mut res, &mut err ); - if err.is_null() { - Ok(Vec::from_glib_full(res)) - } else { + //if err.is_null() { + // Ok(Vec::from_glib_full(res)) + //} else { Err(Error::wrap(err)) - } + //} } } @@ -36,19 +40,20 @@ pub fn unlock_object(obj: &W) -> Secre let mut err = ptr::null_mut(); let mut res = ptr::null_mut(); let arr = [obj]; - let slice = (&arr[..]).to_glib_none(); + //let slice = (&arr[..]).to_glib_none(); unsafe { ffi::secret_service_unlock_sync( ptr::null_mut(), - slice.0 as *mut GList, + //slice.0 as *mut GList, + ptr::null_mut(), ptr::null_mut(), &mut res, &mut err ); - if err.is_null() { - Ok(Vec::from_glib_full(res)) - } else { + //if err.is_null() { + // Ok(Vec::from_glib_full(res)) + //} else { Err(Error::wrap(err)) - } + //} } } From 234e6ad7bd75218c53829ae3f58e07428aac92fb Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 21:09:38 -0700 Subject: [PATCH 06/20] Bumped to glib 0.5.0 It no longer compiles with Rust 1.22, but it does compile and pass all tests on stable and nightly channels. --- Cargo.toml | 6 +++--- secret-sys/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2f3ea85..0dc9abd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,9 +10,9 @@ license = "MIT" [dependencies] libc = "*" -glib = "0.3.1" -glib-sys = "0.4.0" -gobject-sys = "0.4.0" +glib = "0.5.0" +glib-sys = "0.6.0" +gobject-sys = "0.6.0" [dependencies.secret-sys] path = "secret-sys" diff --git a/secret-sys/Cargo.toml b/secret-sys/Cargo.toml index b2e9b38..0a51317 100644 --- a/secret-sys/Cargo.toml +++ b/secret-sys/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" [dependencies] libc = "*" -glib-sys = "0.4.0" +glib-sys = "0.6.0" [build-dependencies] pkg-config = "=0.3.12" From 1cfce8e8a3bf99e53a203fbdce960b333504f9ff Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 21:20:06 -0700 Subject: [PATCH 07/20] Bumped to glib 0.6.1 --- Cargo.toml | 6 +++--- secret-sys/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0dc9abd..435cb7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,9 +10,9 @@ license = "MIT" [dependencies] libc = "*" -glib = "0.5.0" -glib-sys = "0.6.0" -gobject-sys = "0.6.0" +glib = "0.6.1" +glib-sys = "0.7.0" +gobject-sys = "0.7.0" [dependencies.secret-sys] path = "secret-sys" diff --git a/secret-sys/Cargo.toml b/secret-sys/Cargo.toml index 0a51317..4911a5a 100644 --- a/secret-sys/Cargo.toml +++ b/secret-sys/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" [dependencies] libc = "*" -glib-sys = "0.6.0" +glib-sys = "0.7.0" [build-dependencies] pkg-config = "=0.3.12" From 38a3b9495fe31ef758e8a866a7158e4ffa27bc1c Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 21:32:12 -0700 Subject: [PATCH 08/20] Bumped to glib 0.7.1 Small fix-ups needed for new glib. --- Cargo.toml | 6 +++--- secret-sys/Cargo.toml | 2 +- src/lib.rs | 4 ++-- src/secret_collection.rs | 2 +- src/secret_item.rs | 2 +- src/secret_service.rs | 2 +- src/util.rs | 10 +++++----- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 435cb7e..8fde066 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,9 +10,9 @@ license = "MIT" [dependencies] libc = "*" -glib = "0.6.1" -glib-sys = "0.7.0" -gobject-sys = "0.7.0" +glib = "0.7.1" +glib-sys = "0.8.0" +gobject-sys = "0.8.0" [dependencies.secret-sys] path = "secret-sys" diff --git a/secret-sys/Cargo.toml b/secret-sys/Cargo.toml index 4911a5a..8e6df4a 100644 --- a/secret-sys/Cargo.toml +++ b/secret-sys/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" [dependencies] libc = "*" -glib-sys = "0.7.0" +glib-sys = "0.8.0" [build-dependencies] pkg-config = "=0.3.12" diff --git a/src/lib.rs b/src/lib.rs index 32046cb..fde662f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,13 +28,13 @@ pub use self::secret_item::SecretItem; pub use self::secret_value::SecretValue; use glib::Error; -use glib::wrapper::Wrapper; +use glib::object::ObjectType; /// A Result which may contain an error from the SecretService backend. pub type SecretResult = Result; /// This Trait is implemented by objects which can be locked and unlocked -pub trait Lock { +pub trait Lock { /// Lock the object. fn lock(&self) -> SecretResult>; diff --git a/src/secret_collection.rs b/src/secret_collection.rs index b42e7b9..a1d061f 100644 --- a/src/secret_collection.rs +++ b/src/secret_collection.rs @@ -18,7 +18,7 @@ use gobject_sys as gobject_ffi; // FIXME workaround for bug in glib 0.3.1 /// Use `get_items()` to lookup the items in the collection. There may not be /// any items exposed when the collection is locked. glib_wrapper! { - pub struct SecretCollection(Object); + pub struct SecretCollection(Object); match fn { get_type => || ffi::secret_collection_get_type(), diff --git a/src/secret_item.rs b/src/secret_item.rs index 5dc3ada..4a323cc 100644 --- a/src/secret_item.rs +++ b/src/secret_item.rs @@ -29,7 +29,7 @@ use Lock; /// Items can be created with `create()` or `SecretService::store()`. /// glib_wrapper! { - pub struct SecretItem(Object); + pub struct SecretItem(Object); match fn { get_type => || ffi::secret_item_get_type(), diff --git a/src/secret_service.rs b/src/secret_service.rs index 2f7463f..280e125 100644 --- a/src/secret_service.rs +++ b/src/secret_service.rs @@ -33,7 +33,7 @@ use gobject_sys as gobject_ffi; // FIXME workaround for bug in glib 0.3.1 /// and passed to the secret_service_prompt() method. In this way it is handled /// automatically. glib_wrapper! { - pub struct SecretService(Object); + pub struct SecretService(Object); match fn { get_type => || ffi::secret_service_get_type(), diff --git a/src/util.rs b/src/util.rs index 8e7dcd6..245f7e8 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,7 +1,7 @@ use std::ptr; use glib::Error; use glib_sys::{GList}; -use glib::wrapper::{Wrapper}; +use glib::object::ObjectType; use glib::translate::{ToGlibPtr, FromGlibPtrContainer, GlibPtrDefault}; use glib::translate::ToGlibContainerFromSlice; use glib::types::StaticType; @@ -10,9 +10,9 @@ use secret_collection::SecretCollection; use ffi; use SecretResult; -//pub fn lock_object<'a, W: Wrapper + StaticType + GlibPtrDefault + ToGlibContainerFromSlice<'a, *mut ::GlibType>>(obj: &W) -> SecretResult>{ -//pub fn lock_object<'a, W: Wrapper + StaticType + GlibPtrDefault + ToGlibContainerFromSlice<'a, *mut GList>>(obj: &W) -> SecretResult>{ -pub fn lock_object<'a, W: Wrapper + StaticType + GlibPtrDefault + ToGlibPtr<'a, ::GlibType>>(obj: &'a W) -> SecretResult>{ +//pub fn lock_object<'a, W: ObjectType + StaticType + GlibPtrDefault + ToGlibContainerFromSlice<'a, *mut ::GlibType>>(obj: &W) -> SecretResult>{ +//pub fn lock_object<'a, W: ObjectType + StaticType + GlibPtrDefault + ToGlibContainerFromSlice<'a, *mut GList>>(obj: &W) -> SecretResult>{ +pub fn lock_object<'a, W: ObjectType + StaticType + GlibPtrDefault + ToGlibPtr<'a, ::GlibType>>(obj: &'a W) -> SecretResult>{ debug_assert!(W::static_type() == SecretItem::static_type() || W::static_type() == SecretCollection::static_type(), "Can only lock items or collections"); let mut err = ptr::null_mut(); let mut res = ptr::null_mut(); @@ -35,7 +35,7 @@ pub fn lock_object<'a, W: Wrapper + StaticType + GlibPtrDefault + ToGlibPtr<'a, } } -pub fn unlock_object(obj: &W) -> SecretResult>{ +pub fn unlock_object(obj: &W) -> SecretResult>{ debug_assert!(W::static_type() == SecretItem::static_type() || W::static_type() == SecretCollection::static_type(), "Can only unlock items or collections"); let mut err = ptr::null_mut(); let mut res = ptr::null_mut(); From a4aa9dc337e564070e3fa3e7adde2481e719290e Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 21:54:14 -0700 Subject: [PATCH 09/20] Bumped to glib 0.10.3 Small fix-ups needed for new glib. --- Cargo.toml | 6 +++--- secret-sys/Cargo.toml | 2 +- src/secret_collection.rs | 30 +++++++++++++++++++++++++----- src/secret_item.rs | 30 +++++++++++++++++++++++++----- src/secret_service.rs | 36 ++++++++++++++++++++++++++++++------ src/util.rs | 14 +++++++++++--- 6 files changed, 95 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8fde066..7766612 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,9 +10,9 @@ license = "MIT" [dependencies] libc = "*" -glib = "0.7.1" -glib-sys = "0.8.0" -gobject-sys = "0.8.0" +glib = "0.10.3" +glib-sys = "0.10.1" +gobject-sys = "0.10.0" [dependencies.secret-sys] path = "secret-sys" diff --git a/secret-sys/Cargo.toml b/secret-sys/Cargo.toml index 8e6df4a..f992448 100644 --- a/secret-sys/Cargo.toml +++ b/secret-sys/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" [dependencies] libc = "*" -glib-sys = "0.8.0" +glib-sys = "0.10.1" [build-dependencies] pkg-config = "=0.3.12" diff --git a/src/secret_collection.rs b/src/secret_collection.rs index a1d061f..2c9db94 100644 --- a/src/secret_collection.rs +++ b/src/secret_collection.rs @@ -48,7 +48,11 @@ impl SecretCollection { } ) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } @@ -76,7 +80,11 @@ impl SecretCollection { } ) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } @@ -94,7 +102,11 @@ impl SecretCollection { if err.is_null(){ Ok(()) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } @@ -173,7 +185,11 @@ impl SecretCollection { if err.is_null() { Ok(()) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } } @@ -193,7 +209,11 @@ impl SecretCollection { if err.is_null() { Ok(()) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } } diff --git a/src/secret_item.rs b/src/secret_item.rs index 4a323cc..f5b0b8c 100644 --- a/src/secret_item.rs +++ b/src/secret_item.rs @@ -60,7 +60,11 @@ impl SecretItem { if err.is_null() { //TODO for all patterns like this: This if does not need to be in the unsafe block. Fix pls. Ok(from_glib_full(item)) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } } @@ -78,7 +82,11 @@ impl SecretItem { if err.is_null() { Ok(()) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } @@ -135,7 +143,11 @@ impl SecretItem { if err.is_null() { Ok(()) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } @@ -167,7 +179,11 @@ impl SecretItem { if err.is_null() { Ok(()) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } } @@ -194,7 +210,11 @@ impl SecretItem { if err.is_null() { Ok(()) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } } diff --git a/src/secret_service.rs b/src/secret_service.rs index 280e125..70ebb06 100644 --- a/src/secret_service.rs +++ b/src/secret_service.rs @@ -58,7 +58,11 @@ impl SecretService { if err.is_null() { Ok(unsafe{from_glib_full(ptr)}) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } @@ -116,7 +120,11 @@ impl SecretService { if err.is_null() { Ok(Vec::from_glib_full(glist)) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } } @@ -146,7 +154,11 @@ impl SecretService { if err.is_null() { Ok(()) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } } @@ -172,7 +184,11 @@ impl SecretService { if err.is_null() { Ok(()) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } } @@ -189,7 +205,11 @@ impl SecretService { if err.is_null() { Ok(()) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } } @@ -206,7 +226,11 @@ impl SecretService { if err.is_null() { Ok(()) } else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) } } } diff --git a/src/util.rs b/src/util.rs index 245f7e8..8d5cbdd 100644 --- a/src/util.rs +++ b/src/util.rs @@ -3,7 +3,7 @@ use glib::Error; use glib_sys::{GList}; use glib::object::ObjectType; use glib::translate::{ToGlibPtr, FromGlibPtrContainer, GlibPtrDefault}; -use glib::translate::ToGlibContainerFromSlice; +use glib::translate::{from_glib_full, ToGlibContainerFromSlice}; use glib::types::StaticType; use secret_item::SecretItem; use secret_collection::SecretCollection; @@ -30,7 +30,11 @@ pub fn lock_object<'a, W: ObjectType + StaticType + GlibPtrDefault + ToGlibPtr<' //if err.is_null() { // Ok(Vec::from_glib_full(res)) //} else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) //} } } @@ -53,7 +57,11 @@ pub fn unlock_object(obj: &W) -> Se //if err.is_null() { // Ok(Vec::from_glib_full(res)) //} else { - Err(Error::wrap(err)) + Err( + unsafe { + from_glib_full(err) + } + ) //} } } From 5c7eab21d1c4020686e939279d1e2beb541936e2 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 22:29:04 -0700 Subject: [PATCH 10/20] Bumped to glib 0.14.8 from_glib() is now unsafe in this glib release and needs to be wrapped appropriately. Also, the actual classes (structs) for GObjects need to be imported with the FFI now. --- Cargo.toml | 6 +++--- secret-sys/Cargo.toml | 2 +- secret-sys/src/lib.rs | 3 +++ src/secret_collection.rs | 17 +++++++++-------- src/secret_item.rs | 8 ++++---- src/secret_service.rs | 15 ++++++++------- 6 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7766612..f48481b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,9 +10,9 @@ license = "MIT" [dependencies] libc = "*" -glib = "0.10.3" -glib-sys = "0.10.1" -gobject-sys = "0.10.0" +glib = "0.14.8" +glib-sys = "0.14.0" +gobject-sys = "0.14.0" [dependencies.secret-sys] path = "secret-sys" diff --git a/secret-sys/Cargo.toml b/secret-sys/Cargo.toml index f992448..bc6bcab 100644 --- a/secret-sys/Cargo.toml +++ b/secret-sys/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" [dependencies] libc = "*" -glib-sys = "0.10.1" +glib-sys = "0.14.0" [build-dependencies] pkg-config = "=0.3.12" diff --git a/secret-sys/src/lib.rs b/secret-sys/src/lib.rs index a877dac..78f3dc8 100644 --- a/secret-sys/src/lib.rs +++ b/secret-sys/src/lib.rs @@ -17,9 +17,12 @@ pub type gssize = c_long; //libsecret #[repr(C)] pub struct SecretService; +#[repr(C)] pub struct SecretServiceClass; #[repr(C)] pub struct SecretSchema; #[repr(C)] pub struct SecretCollection; +#[repr(C)] pub struct SecretCollectionClass; #[repr(C)] pub struct SecretItem; +#[repr(C)] pub struct SecretItemClass; #[repr(C)] pub struct SecretValue; #[link(name="secret-1")] diff --git a/src/secret_collection.rs b/src/secret_collection.rs index 2c9db94..dce111a 100644 --- a/src/secret_collection.rs +++ b/src/secret_collection.rs @@ -17,11 +17,11 @@ use gobject_sys as gobject_ffi; // FIXME workaround for bug in glib 0.3.1 /// `Lock::unlock()` to lock or unlock the collection. /// Use `get_items()` to lookup the items in the collection. There may not be /// any items exposed when the collection is locked. -glib_wrapper! { - pub struct SecretCollection(Object); +wrapper! { + pub struct SecretCollection(Object); match fn { - get_type => || ffi::secret_collection_get_type(), + type_ => || ffi::secret_collection_get_type(), } } @@ -225,7 +225,7 @@ impl SecretCollection { self.to_glib_none().0 ) }; - from_glib(gbool) + unsafe { from_glib(gbool) } } } @@ -262,10 +262,11 @@ mod test { } */ #[test] + #[ignore = "glib 0.14.x no longer uses an enum Type"] pub fn test_sc_static_type() { - match SecretCollection::static_type() { - Type::Other(_) => {}, - _ => panic!("Expected Type::Other") - } + //match SecretCollection::static_type() { + // Type::Other(_) => {}, + // _ => panic!("Expected Type::Other") + //} } } diff --git a/src/secret_item.rs b/src/secret_item.rs index f5b0b8c..791f2b5 100644 --- a/src/secret_item.rs +++ b/src/secret_item.rs @@ -28,11 +28,11 @@ use Lock; /// attributes associated with an item. /// Items can be created with `create()` or `SecretService::store()`. /// -glib_wrapper! { - pub struct SecretItem(Object); +wrapper! { + pub struct SecretItem(Object); match fn { - get_type => || ffi::secret_item_get_type(), + type_ => || ffi::secret_item_get_type(), } } @@ -224,7 +224,7 @@ impl SecretItem { let gbool = unsafe { ffi::secret_item_get_locked(self.to_glib_none().0) }; - from_glib(gbool) + unsafe { from_glib(gbool) } } } diff --git a/src/secret_service.rs b/src/secret_service.rs index 70ebb06..4aa9e2a 100644 --- a/src/secret_service.rs +++ b/src/secret_service.rs @@ -32,11 +32,11 @@ use gobject_sys as gobject_ffi; // FIXME workaround for bug in glib 0.3.1 /// prompt is necessary, then a SecretPrompt object is created by libsecret, /// and passed to the secret_service_prompt() method. In this way it is handled /// automatically. -glib_wrapper! { - pub struct SecretService(Object); +wrapper! { + pub struct SecretService(Object); match fn { - get_type => || ffi::secret_service_get_type(), + type_ => || ffi::secret_service_get_type(), } } @@ -270,11 +270,12 @@ mod test { } #[test] + #[ignore = "glib 0.14.x no longer uses an enum Type"] pub fn test_ss_static_type() { - match SecretService::static_type() { - Type::Other(_) => {}, - _ => panic!("Expected Type::Other") - } + //match SecretService::static_type() { + // Type::Other(_) => {}, + // _ => panic!("Expected Type::Other") + //} } #[test] From 49964a9d7c67d7ccbf2b862be0f1807b5bb86bd4 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 22:34:53 -0700 Subject: [PATCH 11/20] Bumped to glib 0.18.1 This is the latest glib release at this time. --- Cargo.toml | 6 +++--- secret-sys/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f48481b..ada3f48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,9 +10,9 @@ license = "MIT" [dependencies] libc = "*" -glib = "0.14.8" -glib-sys = "0.14.0" -gobject-sys = "0.14.0" +glib = "0.18.1" +glib-sys = "0.18.0" +gobject-sys = "0.18.0" [dependencies.secret-sys] path = "secret-sys" diff --git a/secret-sys/Cargo.toml b/secret-sys/Cargo.toml index bc6bcab..bf8a7af 100644 --- a/secret-sys/Cargo.toml +++ b/secret-sys/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" [dependencies] libc = "*" -glib-sys = "0.14.0" +glib-sys = "0.18.0" [build-dependencies] pkg-config = "=0.3.12" From 0d73ff3bbf4a610cfa5c31354d1cdc4f1518f15c Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 22:36:40 -0700 Subject: [PATCH 12/20] Revert "Applied fixes to bump it up to glib 0.3.4" This reverts commit cf4d013318cd4c61f9b444fb1a069d80069ee91d. --- Cargo.toml | 1 - src/lib.rs | 1 - src/secret_collection.rs | 3 --- src/secret_item.rs | 3 --- src/secret_service.rs | 3 --- 5 files changed, 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ada3f48..5174927 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ license = "MIT" libc = "*" glib = "0.18.1" glib-sys = "0.18.0" -gobject-sys = "0.18.0" [dependencies.secret-sys] path = "secret-sys" diff --git a/src/lib.rs b/src/lib.rs index fde662f..8a447f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,6 @@ extern crate libc; #[macro_use] extern crate glib; extern crate glib_sys; -extern crate gobject_sys; extern crate secret_sys; mod secret_service; diff --git a/src/secret_collection.rs b/src/secret_collection.rs index dce111a..702f38c 100644 --- a/src/secret_collection.rs +++ b/src/secret_collection.rs @@ -7,9 +7,6 @@ use SecretResult; use util::{lock_object, unlock_object}; use Lock; use ffi; -use glib_sys as glib_ffi; // FIXME workaround for bug in glib 0.3.1 -use std::mem; // FIXME workaround for bug in glib 0.3.1 -use gobject_sys as gobject_ffi; // FIXME workaround for bug in glib 0.3.1 /// SecretCollection represents a collection of secret items stored in the /// Secret Service. diff --git a/src/secret_item.rs b/src/secret_item.rs index 791f2b5..b108c34 100644 --- a/src/secret_item.rs +++ b/src/secret_item.rs @@ -7,9 +7,6 @@ use secret_collection::SecretCollection; use secret_value::SecretValue; use SecretResult; use ffi; -use glib_sys as glib_ffi; // FIXME workaround for bug in glib 0.3.1 -use std::mem; // FIXME workaround for bug in glib 0.3.1 -use gobject_sys as gobject_ffi; // FIXME workaround for bug in glib 0.3.1 use util::{lock_object, unlock_object}; use Lock; diff --git a/src/secret_service.rs b/src/secret_service.rs index 4aa9e2a..890e48f 100644 --- a/src/secret_service.rs +++ b/src/secret_service.rs @@ -14,9 +14,6 @@ use glib::Error; use glib::translate::*; use SecretResult; use ffi; -use glib_sys as glib_ffi; // FIXME workaround for bug in glib 0.3.1 -use std::mem; // FIXME workaround for bug in glib 0.3.1 -use gobject_sys as gobject_ffi; // FIXME workaround for bug in glib 0.3.1 /// A SecretService object represents the Secret Service implementation which /// runs as a D-Bus service. From 9564fb9da80c38f623fb4d406a62399b2c96e782 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 22:42:32 -0700 Subject: [PATCH 13/20] Dropped hard-coded versions It is now that it's compatible with the latest dependencies. --- Cargo.toml | 4 ++-- secret-sys/Cargo.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5174927..a353fb2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,8 @@ license = "MIT" [dependencies] libc = "*" -glib = "0.18.1" -glib-sys = "0.18.0" +glib = "*" +glib-sys = "*" [dependencies.secret-sys] path = "secret-sys" diff --git a/secret-sys/Cargo.toml b/secret-sys/Cargo.toml index bf8a7af..8628b84 100644 --- a/secret-sys/Cargo.toml +++ b/secret-sys/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" [dependencies] libc = "*" -glib-sys = "0.18.0" +glib-sys = "*" [build-dependencies] -pkg-config = "=0.3.12" +pkg-config = "0.3" From 4bb9a292cfaa9a5997d15f935ae0a258a3696687 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 23:00:56 -0700 Subject: [PATCH 14/20] Cleaned up warnings and fixed doc strings --- src/secret_collection.rs | 25 ++++++++------------ src/secret_item.rs | 43 ++++++++++++++------------------- src/secret_service.rs | 51 ++++++++++++++++------------------------ src/util.rs | 11 +++------ 4 files changed, 51 insertions(+), 79 deletions(-) diff --git a/src/secret_collection.rs b/src/secret_collection.rs index 702f38c..645329b 100644 --- a/src/secret_collection.rs +++ b/src/secret_collection.rs @@ -1,5 +1,4 @@ use std::ptr; -use glib::Error; use glib::translate::*; use secret_service::SecretService; use secret_item::SecretItem; @@ -8,13 +7,13 @@ use util::{lock_object, unlock_object}; use Lock; use ffi; -/// SecretCollection represents a collection of secret items stored in the -/// Secret Service. -/// A collection can be in a locked or unlocked state. Use `Lock::lock()` or -/// `Lock::unlock()` to lock or unlock the collection. -/// Use `get_items()` to lookup the items in the collection. There may not be -/// any items exposed when the collection is locked. wrapper! { + /// SecretCollection represents a collection of secret items stored in the + /// Secret Service. + /// A collection can be in a locked or unlocked state. Use `Lock::lock()` or + /// `Lock::unlock()` to lock or unlock the collection. + /// Use `get_items()` to lookup the items in the collection. There may not be + /// any items exposed when the collection is locked. pub struct SecretCollection(Object); match fn { @@ -183,9 +182,7 @@ impl SecretCollection { Ok(()) } else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) } } @@ -207,9 +204,7 @@ impl SecretCollection { Ok(()) } else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) } } @@ -244,8 +239,8 @@ const SECRET_COLLECTION_LOAD_ITEMS: i32 = 1 << 1; #[cfg(test)] mod test { - use glib::types::{StaticType, Type}; - use super::SecretCollection; + // use glib::types::{StaticType, Type}; + // use super::SecretCollection; /* #[test] diff --git a/src/secret_item.rs b/src/secret_item.rs index b108c34..e99d8a8 100644 --- a/src/secret_item.rs +++ b/src/secret_item.rs @@ -1,6 +1,5 @@ use std::ptr; use std::collections::HashMap; -use glib::Error; use glib::translate::*; use secret_service::SecretService; use secret_collection::SecretCollection; @@ -10,22 +9,22 @@ use ffi; use util::{lock_object, unlock_object}; use Lock; -/// SecretItem represents a secret item stored in the Secret Service. -/// Each item has a value, represented by a SecretValue, which can be retrieved -/// by `get_secret()` or set by `set_secret()`. The item is only available when -/// the item is not locked. -/// Items can be locked or unlocked using the `Lock::lock()` or `Lock::unlock()` -/// functions. The Lock trait is implemented by SecretItem. The Secret Service -/// may not be able to unlock individual items, and may unlock an entire -/// collection when a single item is unlocked. -/// Each item has a set of attributes, which are used to locate the item later. -/// These are not stored or transferred in a secure manner. Each attribute has -/// a string name and a string value. Use `SecretService::search()` to search -/// for items based on their attributes, and `set_attributes()` to change the -/// attributes associated with an item. -/// Items can be created with `create()` or `SecretService::store()`. -/// wrapper! { + /// SecretItem represents a secret item stored in the Secret Service. + /// Each item has a value, represented by a SecretValue, which can be retrieved + /// by `get_secret()` or set by `set_secret()`. The item is only available when + /// the item is not locked. + /// Items can be locked or unlocked using the `Lock::lock()` or `Lock::unlock()` + /// functions. The Lock trait is implemented by SecretItem. The Secret Service + /// may not be able to unlock individual items, and may unlock an entire + /// collection when a single item is unlocked. + /// Each item has a set of attributes, which are used to locate the item later. + /// These are not stored or transferred in a secure manner. Each attribute has + /// a string name and a string value. Use `SecretService::search()` to search + /// for items based on their attributes, and `set_attributes()` to change the + /// attributes associated with an item. + /// Items can be created with `create()` or `SecretService::store()`. + /// pub struct SecretItem(Object); match fn { @@ -58,9 +57,7 @@ impl SecretItem { Ok(from_glib_full(item)) } else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) } } @@ -177,9 +174,7 @@ impl SecretItem { Ok(()) } else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) } } @@ -208,9 +203,7 @@ impl SecretItem { Ok(()) } else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) } } diff --git a/src/secret_service.rs b/src/secret_service.rs index 890e48f..67051ef 100644 --- a/src/secret_service.rs +++ b/src/secret_service.rs @@ -10,26 +10,25 @@ pub use secret_value::*; //========================================================================= use std::ptr; use std::collections::HashMap; -use glib::Error; use glib::translate::*; use SecretResult; use ffi; -/// A SecretService object represents the Secret Service implementation which -/// runs as a D-Bus service. -/// In order to securely transfer secrets to the Sercret Service, a session is -/// established. This will automatically be done when calling -/// `SecretService::get()` -/// To search for items, use the `search()` method. -/// Multiple collections can exist in the Secret Service, each of which -/// contains secret items. To access the list of Collections, use -/// `get_collections()`. -/// Certain actions on the Secret Service require user prompting to complete, -/// such as creating a collection, or unlocking a collection. When such a -/// prompt is necessary, then a SecretPrompt object is created by libsecret, -/// and passed to the secret_service_prompt() method. In this way it is handled -/// automatically. wrapper! { + /// A SecretService object represents the Secret Service implementation which + /// runs as a D-Bus service. + /// In order to securely transfer secrets to the Sercret Service, a session is + /// established. This will automatically be done when calling + /// `SecretService::get()` + /// To search for items, use the `search()` method. + /// Multiple collections can exist in the Secret Service, each of which + /// contains secret items. To access the list of Collections, use + /// `get_collections()`. + /// Certain actions on the Secret Service require user prompting to complete, + /// such as creating a collection, or unlocking a collection. When such a + /// prompt is necessary, then a SecretPrompt object is created by libsecret, + /// and passed to the secret_service_prompt() method. In this way it is handled + /// automatically. pub struct SecretService(Object); match fn { @@ -118,9 +117,7 @@ impl SecretService { Ok(Vec::from_glib_full(glist)) } else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) } } @@ -152,9 +149,7 @@ impl SecretService { Ok(()) } else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) } } @@ -182,9 +177,7 @@ impl SecretService { Ok(()) } else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) } } @@ -203,9 +196,7 @@ impl SecretService { Ok(()) } else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) } } @@ -224,9 +215,7 @@ impl SecretService { Ok(()) } else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) } } @@ -247,7 +236,7 @@ const SECRET_SEARCH_LOAD_SECRETS: i32 = 1 << 3; #[cfg(test)] mod test { use std::collections::HashMap; - use glib::types::{StaticType, Type}; + // use glib::types::{StaticType, Type}; use secret_value::SecretValue; use super::SecretService; diff --git a/src/util.rs b/src/util.rs index 8d5cbdd..f62061f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,6 +1,5 @@ use std::ptr; -use glib::Error; -use glib_sys::{GList}; +use glib_sys::GList; use glib::object::ObjectType; use glib::translate::{ToGlibPtr, FromGlibPtrContainer, GlibPtrDefault}; use glib::translate::{from_glib_full, ToGlibContainerFromSlice}; @@ -31,9 +30,7 @@ pub fn lock_object<'a, W: ObjectType + StaticType + GlibPtrDefault + ToGlibPtr<' // Ok(Vec::from_glib_full(res)) //} else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) //} } @@ -58,9 +55,7 @@ pub fn unlock_object(obj: &W) -> Se // Ok(Vec::from_glib_full(res)) //} else { Err( - unsafe { - from_glib_full(err) - } + from_glib_full(err) ) //} } From 32cdb75769d3a9d8eb171a77a98fe8a1575b10e9 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sat, 9 Sep 2023 23:29:47 -0700 Subject: [PATCH 15/20] Cleaned up remaining warnings and selectively pull in macros --- secret-sys/src/lib.rs | 18 +++++++++--------- src/lib.rs | 1 - src/secret_collection.rs | 1 + src/secret_item.rs | 1 + src/secret_service.rs | 1 + src/util.rs | 14 +++++++++----- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/secret-sys/src/lib.rs b/secret-sys/src/lib.rs index 78f3dc8..b9ef62d 100644 --- a/secret-sys/src/lib.rs +++ b/secret-sys/src/lib.rs @@ -12,18 +12,18 @@ pub type gint = c_int; pub type guint = c_uint; pub type guint64 = c_ulong; pub type gssize = c_long; -#[repr(C)] pub struct GCancellable; +#[repr(C)] pub struct GCancellable { private: [u8; 0] } //libsecret -#[repr(C)] pub struct SecretService; -#[repr(C)] pub struct SecretServiceClass; -#[repr(C)] pub struct SecretSchema; -#[repr(C)] pub struct SecretCollection; -#[repr(C)] pub struct SecretCollectionClass; -#[repr(C)] pub struct SecretItem; -#[repr(C)] pub struct SecretItemClass; -#[repr(C)] pub struct SecretValue; +#[repr(C)] pub struct SecretService { private: [u8; 0] } +#[repr(C)] pub struct SecretServiceClass { private: [u8; 0] } +#[repr(C)] pub struct SecretSchema { private: [u8; 0] } +#[repr(C)] pub struct SecretCollection { private: [u8; 0] } +#[repr(C)] pub struct SecretCollectionClass { private: [u8; 0] } +#[repr(C)] pub struct SecretItem { private: [u8; 0] } +#[repr(C)] pub struct SecretItemClass { private: [u8; 0] } +#[repr(C)] pub struct SecretValue { private: [u8; 0] } #[link(name="secret-1")] extern "C" { diff --git a/src/lib.rs b/src/lib.rs index 8a447f5..2344eeb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,6 @@ //! gnome project. extern crate libc; -#[macro_use] extern crate glib; extern crate glib_sys; extern crate secret_sys; diff --git a/src/secret_collection.rs b/src/secret_collection.rs index 645329b..5c0ae8c 100644 --- a/src/secret_collection.rs +++ b/src/secret_collection.rs @@ -1,5 +1,6 @@ use std::ptr; use glib::translate::*; +use glib::wrapper; use secret_service::SecretService; use secret_item::SecretItem; use SecretResult; diff --git a/src/secret_item.rs b/src/secret_item.rs index e99d8a8..cabab17 100644 --- a/src/secret_item.rs +++ b/src/secret_item.rs @@ -1,6 +1,7 @@ use std::ptr; use std::collections::HashMap; use glib::translate::*; +use glib::wrapper; use secret_service::SecretService; use secret_collection::SecretCollection; use secret_value::SecretValue; diff --git a/src/secret_service.rs b/src/secret_service.rs index 67051ef..d6566c4 100644 --- a/src/secret_service.rs +++ b/src/secret_service.rs @@ -11,6 +11,7 @@ pub use secret_value::*; use std::ptr; use std::collections::HashMap; use glib::translate::*; +use glib::wrapper; use SecretResult; use ffi; diff --git a/src/util.rs b/src/util.rs index f62061f..f58c852 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,8 +1,10 @@ use std::ptr; -use glib_sys::GList; +//use glib_sys::GList; +//use glib::translate::FromGlibPtrContainer; +//use glib::translate::ToGlibContainerFromSlice; use glib::object::ObjectType; -use glib::translate::{ToGlibPtr, FromGlibPtrContainer, GlibPtrDefault}; -use glib::translate::{from_glib_full, ToGlibContainerFromSlice}; +use glib::translate::{ToGlibPtr, GlibPtrDefault}; +use glib::translate::from_glib_full; use glib::types::StaticType; use secret_item::SecretItem; use secret_collection::SecretCollection; @@ -15,7 +17,8 @@ pub fn lock_object<'a, W: ObjectType + StaticType + GlibPtrDefault + ToGlibPtr<' debug_assert!(W::static_type() == SecretItem::static_type() || W::static_type() == SecretCollection::static_type(), "Can only lock items or collections"); let mut err = ptr::null_mut(); let mut res = ptr::null_mut(); - let arr = [obj]; + let _arr = [obj]; + //let arr = [obj]; //let slice: (*mut GList, <&W as ToGlibContainerFromSlice<'a, *mut GList>>::Storage) = ToGlibContainerFromSlice::to_glib_none_from_slice(&arr[..]); unsafe { ffi::secret_service_lock_sync( @@ -40,7 +43,8 @@ pub fn unlock_object(obj: &W) -> Se debug_assert!(W::static_type() == SecretItem::static_type() || W::static_type() == SecretCollection::static_type(), "Can only unlock items or collections"); let mut err = ptr::null_mut(); let mut res = ptr::null_mut(); - let arr = [obj]; + let _arr = [obj]; + //let arr = [obj]; //let slice = (&arr[..]).to_glib_none(); unsafe { ffi::secret_service_unlock_sync( From 2789c8b5e810482186260bb48a41da090322643a Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sun, 10 Sep 2023 11:52:55 -0700 Subject: [PATCH 16/20] Fixed the glib conversions in the lock/unlock object functions With this commit, the last breakage in this crate has been fixed for the latest glib library. All functionality should be restored. --- src/util.rs | 66 ++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/util.rs b/src/util.rs index f58c852..65e3647 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,66 +1,66 @@ use std::ptr; -//use glib_sys::GList; -//use glib::translate::FromGlibPtrContainer; -//use glib::translate::ToGlibContainerFromSlice; -use glib::object::ObjectType; -use glib::translate::{ToGlibPtr, GlibPtrDefault}; +use glib::ffi::GList; +use glib::translate::{ToGlibPtr, ToGlibContainerFromSlice, GlibPtrDefault}; +use glib::translate::{FromGlibPtrFull, FromGlibPtrNone, FromGlibPtrContainer}; use glib::translate::from_glib_full; +use glib::translate::Stash; use glib::types::StaticType; use secret_item::SecretItem; use secret_collection::SecretCollection; use ffi; use SecretResult; -//pub fn lock_object<'a, W: ObjectType + StaticType + GlibPtrDefault + ToGlibContainerFromSlice<'a, *mut ::GlibType>>(obj: &W) -> SecretResult>{ -//pub fn lock_object<'a, W: ObjectType + StaticType + GlibPtrDefault + ToGlibContainerFromSlice<'a, *mut GList>>(obj: &W) -> SecretResult>{ -pub fn lock_object<'a, W: ObjectType + StaticType + GlibPtrDefault + ToGlibPtr<'a, ::GlibType>>(obj: &'a W) -> SecretResult>{ +pub fn lock_object(obj: &W) -> SecretResult> +where + W: StaticType + GlibPtrDefault, + W: FromGlibPtrFull + FromGlibPtrNone, + for<'a> W: ToGlibPtr<'a, W::GlibType> +{ debug_assert!(W::static_type() == SecretItem::static_type() || W::static_type() == SecretCollection::static_type(), "Can only lock items or collections"); let mut err = ptr::null_mut(); let mut res = ptr::null_mut(); - let _arr = [obj]; - //let arr = [obj]; - //let slice: (*mut GList, <&W as ToGlibContainerFromSlice<'a, *mut GList>>::Storage) = ToGlibContainerFromSlice::to_glib_none_from_slice(&arr[..]); + let arr = [obj]; + let slice: (*mut GList, <&W as ToGlibContainerFromSlice<*mut GList>>::Storage) = + ToGlibContainerFromSlice::to_glib_none_from_slice(arr.as_ref()); unsafe { ffi::secret_service_lock_sync( ptr::null_mut(), - //slice.0 as *mut GList, - ptr::null_mut(), + slice.0, ptr::null_mut(), &mut res, &mut err ); - //if err.is_null() { - // Ok(Vec::from_glib_full(res)) - //} else { - Err( - from_glib_full(err) - ) - //} + if err.is_null() { + Ok(Vec::from_glib_full(res)) + } else { + Err(from_glib_full(err)) + } } } -pub fn unlock_object(obj: &W) -> SecretResult>{ +pub fn unlock_object(obj: &W) -> SecretResult> +where + W: StaticType + GlibPtrDefault, + W: FromGlibPtrFull + FromGlibPtrNone, + for<'a> W: ToGlibPtr<'a, W::GlibType> +{ debug_assert!(W::static_type() == SecretItem::static_type() || W::static_type() == SecretCollection::static_type(), "Can only unlock items or collections"); let mut err = ptr::null_mut(); let mut res = ptr::null_mut(); - let _arr = [obj]; - //let arr = [obj]; - //let slice = (&arr[..]).to_glib_none(); + let arr = [obj]; + let slice: Stash<'_, *mut GList, [&W]> = (&arr[..]).to_glib_none(); unsafe { ffi::secret_service_unlock_sync( ptr::null_mut(), - //slice.0 as *mut GList, - ptr::null_mut(), + slice.0, ptr::null_mut(), &mut res, &mut err ); - //if err.is_null() { - // Ok(Vec::from_glib_full(res)) - //} else { - Err( - from_glib_full(err) - ) - //} + if err.is_null() { + Ok(Vec::from_glib_full(res)) + } else { + Err(from_glib_full(err)) + } } } From 1f1eacd8e26fc0b64a472b415e208e86a5db6465 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sun, 10 Sep 2023 11:58:29 -0700 Subject: [PATCH 17/20] Dropped direct dependency on glib-sys crate This uses glib::ffi again to access anything it might need from that crate indirectly. --- Cargo.toml | 1 - secret-sys/Cargo.toml | 2 +- secret-sys/src/lib.rs | 4 ++-- src/lib.rs | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a353fb2..9eb7dc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,6 @@ license = "MIT" [dependencies] libc = "*" glib = "*" -glib-sys = "*" [dependencies.secret-sys] path = "secret-sys" diff --git a/secret-sys/Cargo.toml b/secret-sys/Cargo.toml index 8628b84..e36f973 100644 --- a/secret-sys/Cargo.toml +++ b/secret-sys/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT" [dependencies] libc = "*" -glib-sys = "*" +glib = "*" [build-dependencies] pkg-config = "0.3" diff --git a/secret-sys/src/lib.rs b/secret-sys/src/lib.rs index b9ef62d..d8d9a8e 100644 --- a/secret-sys/src/lib.rs +++ b/secret-sys/src/lib.rs @@ -1,9 +1,9 @@ #![allow(non_camel_case_types)] extern crate libc; -extern crate glib_sys; +extern crate glib; use libc::{c_uint, c_char, c_int, c_ulong, c_long, size_t}; -use glib_sys::{GError, GType, GList, gboolean, gpointer, GHashTable}; +use glib::ffi::{GError, GType, GList, gboolean, gpointer, GHashTable}; type gsize = size_t; //glib stuff not provided by glib-rs diff --git a/src/lib.rs b/src/lib.rs index 2344eeb..1c28693 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,6 @@ extern crate libc; extern crate glib; -extern crate glib_sys; extern crate secret_sys; mod secret_service; From c586f5a89e286757b87bd50fe4844babbbb008c9 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sun, 10 Sep 2023 12:28:18 -0700 Subject: [PATCH 18/20] Simplified conversion used inside lock_object() --- src/secret_collection.rs | 8 ++------ src/secret_item.rs | 12 +++--------- src/secret_service.rs | 20 +++++--------------- src/util.rs | 5 ++--- 4 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/secret_collection.rs b/src/secret_collection.rs index 5c0ae8c..21c1552 100644 --- a/src/secret_collection.rs +++ b/src/secret_collection.rs @@ -182,9 +182,7 @@ impl SecretCollection { if err.is_null() { Ok(()) } else { - Err( - from_glib_full(err) - ) + Err(from_glib_full(err)) } } } @@ -204,9 +202,7 @@ impl SecretCollection { if err.is_null() { Ok(()) } else { - Err( - from_glib_full(err) - ) + Err(from_glib_full(err)) } } } diff --git a/src/secret_item.rs b/src/secret_item.rs index cabab17..4bcff44 100644 --- a/src/secret_item.rs +++ b/src/secret_item.rs @@ -57,9 +57,7 @@ impl SecretItem { if err.is_null() { //TODO for all patterns like this: This if does not need to be in the unsafe block. Fix pls. Ok(from_glib_full(item)) } else { - Err( - from_glib_full(err) - ) + Err(from_glib_full(err)) } } } @@ -174,9 +172,7 @@ impl SecretItem { if err.is_null() { Ok(()) } else { - Err( - from_glib_full(err) - ) + Err(from_glib_full(err)) } } } @@ -203,9 +199,7 @@ impl SecretItem { if err.is_null() { Ok(()) } else { - Err( - from_glib_full(err) - ) + Err(from_glib_full(err)) } } } diff --git a/src/secret_service.rs b/src/secret_service.rs index d6566c4..bfe67e1 100644 --- a/src/secret_service.rs +++ b/src/secret_service.rs @@ -117,9 +117,7 @@ impl SecretService { if err.is_null() { Ok(Vec::from_glib_full(glist)) } else { - Err( - from_glib_full(err) - ) + Err(from_glib_full(err)) } } } @@ -149,9 +147,7 @@ impl SecretService { if err.is_null() { Ok(()) } else { - Err( - from_glib_full(err) - ) + Err(from_glib_full(err)) } } } @@ -177,9 +173,7 @@ impl SecretService { if err.is_null() { Ok(()) } else { - Err( - from_glib_full(err) - ) + Err(from_glib_full(err)) } } } @@ -196,9 +190,7 @@ impl SecretService { if err.is_null() { Ok(()) } else { - Err( - from_glib_full(err) - ) + Err(from_glib_full(err)) } } } @@ -215,9 +207,7 @@ impl SecretService { if err.is_null() { Ok(()) } else { - Err( - from_glib_full(err) - ) + Err(from_glib_full(err)) } } } diff --git a/src/util.rs b/src/util.rs index 65e3647..c5a0816 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,6 +1,6 @@ use std::ptr; use glib::ffi::GList; -use glib::translate::{ToGlibPtr, ToGlibContainerFromSlice, GlibPtrDefault}; +use glib::translate::{ToGlibPtr, GlibPtrDefault}; use glib::translate::{FromGlibPtrFull, FromGlibPtrNone, FromGlibPtrContainer}; use glib::translate::from_glib_full; use glib::translate::Stash; @@ -20,8 +20,7 @@ where let mut err = ptr::null_mut(); let mut res = ptr::null_mut(); let arr = [obj]; - let slice: (*mut GList, <&W as ToGlibContainerFromSlice<*mut GList>>::Storage) = - ToGlibContainerFromSlice::to_glib_none_from_slice(arr.as_ref()); + let slice: Stash<'_, *mut GList, [&W]> = (&arr[..]).to_glib_none(); unsafe { ffi::secret_service_lock_sync( ptr::null_mut(), From df7c0b51e30e5ae2492c43965f3e89d1231cf928 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sun, 10 Sep 2023 12:46:47 -0700 Subject: [PATCH 19/20] Fixed broken tests All tests marked as ignored are now fixed and passing. --- src/secret_collection.rs | 13 ++++++------- src/secret_service.rs | 11 +++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/secret_collection.rs b/src/secret_collection.rs index 21c1552..bc57e18 100644 --- a/src/secret_collection.rs +++ b/src/secret_collection.rs @@ -236,8 +236,8 @@ const SECRET_COLLECTION_LOAD_ITEMS: i32 = 1 << 1; #[cfg(test)] mod test { - // use glib::types::{StaticType, Type}; - // use super::SecretCollection; + use glib::types::{StaticType, Type}; + use super::SecretCollection; /* #[test] @@ -251,11 +251,10 @@ mod test { } */ #[test] - #[ignore = "glib 0.14.x no longer uses an enum Type"] pub fn test_sc_static_type() { - //match SecretCollection::static_type() { - // Type::Other(_) => {}, - // _ => panic!("Expected Type::Other") - //} + let type_ = SecretCollection::static_type(); + assert!(type_.is_valid()); + assert!(type_ > Type::OBJECT); + assert_eq!(type_.name(), "SecretCollection"); } } diff --git a/src/secret_service.rs b/src/secret_service.rs index bfe67e1..7ae85ac 100644 --- a/src/secret_service.rs +++ b/src/secret_service.rs @@ -227,7 +227,7 @@ const SECRET_SEARCH_LOAD_SECRETS: i32 = 1 << 3; #[cfg(test)] mod test { use std::collections::HashMap; - // use glib::types::{StaticType, Type}; + use glib::types::{StaticType, Type}; use secret_value::SecretValue; use super::SecretService; @@ -247,12 +247,11 @@ mod test { } #[test] - #[ignore = "glib 0.14.x no longer uses an enum Type"] pub fn test_ss_static_type() { - //match SecretService::static_type() { - // Type::Other(_) => {}, - // _ => panic!("Expected Type::Other") - //} + let type_ = SecretService::static_type(); + assert!(type_.is_valid()); + assert!(type_ > Type::OBJECT); + assert_eq!(type_.name(), "SecretService"); } #[test] From a8e9fe98b26f73adf033e09f83705ef93fd445a9 Mon Sep 17 00:00:00 2001 From: "Loren M. Lang" Date: Sun, 10 Sep 2023 14:11:03 -0700 Subject: [PATCH 20/20] Simplified translate imports to match other modules' style --- src/util.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/util.rs b/src/util.rs index c5a0816..8fc0600 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,9 +1,6 @@ use std::ptr; use glib::ffi::GList; -use glib::translate::{ToGlibPtr, GlibPtrDefault}; -use glib::translate::{FromGlibPtrFull, FromGlibPtrNone, FromGlibPtrContainer}; -use glib::translate::from_glib_full; -use glib::translate::Stash; +use glib::translate::*; use glib::types::StaticType; use secret_item::SecretItem; use secret_collection::SecretCollection;