Update to zbus 4

This commit is contained in:
Maximiliano Sandoval 2024-02-21 18:51:10 +01:00
parent 7411da1d40
commit 151323e0c1
Failed to generate hash of commit
4 changed files with 329 additions and 411 deletions

707
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -17,8 +17,8 @@ opt-level = 3
adw = {package = "libadwaita", version = "0.6", features = ["v1_4"]}
aes-gcm = "0.10"
anyhow = "1.0"
aperture = "0.5"
ashpd = {version = "0.7", default-features = false, features = ["gtk4", "tokio", "tracing"]}
aperture = "0.6"
ashpd = {version = "0.8", default-features = false, features = ["gtk4", "tokio", "tracing"]}
data-encoding = "2.3"
diesel = {version = "2.0", features = ["sqlite", "r2d2"]}
diesel_migrations = {version = "2.0", features = ["sqlite"]}
@ -31,7 +31,7 @@ gtk = {package = "gtk4", version = "0.8", features = ["v4_10"]}
hex = {version = "0.4.3", features = ["serde"]}
image = {version = "0.24", default-features = false, features = ["png"]}
once_cell = "1.9"
oo7 = {version = "0.2", default-features = false, features = ["tokio", "native_crypto", "tracing"]}
oo7 = {version = "0.3", default-features = false, features = ["tokio", "native_crypto", "tracing"]}
percent-encoding = "2.1"
prost = "0.12"
qrencode = {version = "0.14", features = ["image"]}
@ -39,7 +39,7 @@ rand = "0.8"
ring = "0.17"
rust-argon2 = {version = "2.0", default-features = false}
scrypt = {version = "0.11", default-features = false}
search-provider = {version = "0.7", default-features = false, features = ["tokio"]}
search-provider = {version = "0.8", default-features = false, features = ["tokio"]}
serde = "1.0"
serde_json = "1.0"
tokio = {version = "1.0", default-features = false, features = ["rt-multi-thread", "fs", "io-util"]}

View file

@ -36,7 +36,7 @@ pub async fn store(label: &str, token: &str) -> anyhow::Result<String> {
SECRET_SERVICE
.get()
.unwrap()
.create_item(label, attributes, base64_encoded_token.as_bytes(), true)
.create_item(label, &attributes, base64_encoded_token.as_bytes(), true)
.await?;
Ok(token_id)
}
@ -46,7 +46,7 @@ pub async fn token(token_id: &str) -> anyhow::Result<Option<String>> {
let items = SECRET_SERVICE
.get()
.unwrap()
.search_items(attributes)
.search_items(&attributes)
.await?;
Ok(match items.first() {
Some(e) => Some(String::from_utf8(hex::decode(&*e.secret().await?)?)?),
@ -56,7 +56,7 @@ pub async fn token(token_id: &str) -> anyhow::Result<Option<String>> {
pub async fn remove_token(token_id: &str) -> anyhow::Result<()> {
let attributes = token_attributes(token_id);
SECRET_SERVICE.get().unwrap().delete(attributes).await?;
SECRET_SERVICE.get().unwrap().delete(&attributes).await?;
Ok(())
}
@ -65,7 +65,7 @@ pub async fn token_exists(token: &str) -> anyhow::Result<bool> {
let items = SECRET_SERVICE
.get()
.unwrap()
.search_items(attributes)
.search_items(&attributes)
.await?;
for item in items {
let item_token = String::from_utf8(hex::decode(&*item.secret().await?)?)?;
@ -78,7 +78,12 @@ pub async fn token_exists(token: &str) -> anyhow::Result<bool> {
pub async fn has_set_password() -> anyhow::Result<bool> {
let attributes = password_attributes();
match SECRET_SERVICE.get().unwrap().search_items(attributes).await {
match SECRET_SERVICE
.get()
.unwrap()
.search_items(&attributes)
.await
{
Ok(items) => Ok(items.first().is_some()),
_ => Ok(false),
}
@ -93,7 +98,7 @@ pub async fn set_password(password: &str) -> anyhow::Result<()> {
.unwrap()
.create_item(
"Authenticator password",
attributes,
&attributes,
encoded_password.as_bytes(),
true,
)
@ -103,7 +108,7 @@ pub async fn set_password(password: &str) -> anyhow::Result<()> {
pub async fn reset_password() -> anyhow::Result<()> {
let attributes = password_attributes();
SECRET_SERVICE.get().unwrap().delete(attributes).await?;
SECRET_SERVICE.get().unwrap().delete(&attributes).await?;
Ok(())
}
@ -112,7 +117,7 @@ pub async fn is_current_password(password: &str) -> anyhow::Result<bool> {
let items = SECRET_SERVICE
.get()
.unwrap()
.search_items(attributes)
.search_items(&attributes)
.await?;
Ok(match items.first() {
Some(i) => {

View file

@ -1,4 +1,4 @@
use std::{cell::OnceCell, os::fd::RawFd, sync::Once};
use std::{cell::OnceCell, os::fd::OwnedFd, sync::Once};
use adw::subclass::prelude::*;
use anyhow::Result;
@ -308,7 +308,7 @@ impl Default for Camera {
}
}
async fn stream() -> ashpd::Result<RawFd> {
async fn stream() -> ashpd::Result<OwnedFd> {
let proxy = ashpd::desktop::camera::Camera::new().await?;
proxy.request_access().await?;