mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-04 08:44:40 +01:00
Remove once_cell dependency
This commit is contained in:
parent
4e8dba793b
commit
ab1efc4075
17 changed files with 51 additions and 50 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -293,7 +293,6 @@ dependencies = [
|
||||||
"hex",
|
"hex",
|
||||||
"image 0.25.4",
|
"image 0.25.4",
|
||||||
"libadwaita",
|
"libadwaita",
|
||||||
"once_cell",
|
|
||||||
"oo7",
|
"oo7",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"prost",
|
"prost",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
name = "authenticator"
|
name = "authenticator"
|
||||||
rust-version = "1.70"
|
rust-version = "1.80"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
debug = true
|
debug = true
|
||||||
|
@ -29,7 +29,6 @@ gettext-rs = {version = "0.7", features = ["gettext-system"]}
|
||||||
gtk = {package = "gtk4", version = "0.9", features = ["v4_10"]}
|
gtk = {package = "gtk4", version = "0.9", features = ["v4_10"]}
|
||||||
hex = {version = "0.4.3", features = ["serde"]}
|
hex = {version = "0.4.3", features = ["serde"]}
|
||||||
image = {version = "0.25", default-features = false, features = ["png"]}
|
image = {version = "0.25", default-features = false, features = ["png"]}
|
||||||
once_cell = "1.9"
|
|
||||||
oo7 = {version = "0.3", default-features = false, features = ["tokio", "native_crypto", "tracing"]}
|
oo7 = {version = "0.3", default-features = false, features = ["tokio", "native_crypto", "tracing"]}
|
||||||
percent-encoding = "2.1"
|
percent-encoding = "2.1"
|
||||||
prost = "0.13"
|
prost = "0.13"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::{fmt, io::Cursor, path::PathBuf};
|
use std::{fmt, io::Cursor, path::PathBuf};
|
||||||
|
|
||||||
use image::io::Reader as ImageReader;
|
use image::ImageReader;
|
||||||
use tokio::{io::AsyncWriteExt, sync::Mutex};
|
use tokio::{io::AsyncWriteExt, sync::Mutex};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
|
|
@ -90,9 +90,7 @@ impl Restorable for Google {
|
||||||
secret: {
|
secret: {
|
||||||
let string = data_encoding::BASE32_NOPAD.encode(&otp.secret);
|
let string = data_encoding::BASE32_NOPAD.encode(&otp.secret);
|
||||||
|
|
||||||
string
|
string.trim_end_matches(['\0', '=']).to_owned()
|
||||||
.trim_end_matches(|c| c == '\0' || c == '=')
|
|
||||||
.to_owned()
|
|
||||||
},
|
},
|
||||||
label: otp.name.clone(),
|
label: otp.name.clone(),
|
||||||
issuer: otp.issuer.clone(),
|
issuer: otp.issuer.clone(),
|
||||||
|
|
|
@ -34,10 +34,12 @@ pub struct DieselAccount {
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
mod imp {
|
mod imp {
|
||||||
use std::cell::{Cell, OnceCell, RefCell};
|
use std::{
|
||||||
|
cell::{Cell, OnceCell, RefCell},
|
||||||
|
sync::LazyLock,
|
||||||
|
};
|
||||||
|
|
||||||
use glib::ParamSpecObject;
|
use glib::ParamSpecObject;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -79,7 +81,7 @@ mod imp {
|
||||||
|
|
||||||
impl ObjectImpl for Account {
|
impl ObjectImpl for Account {
|
||||||
fn properties() -> &'static [glib::ParamSpec] {
|
fn properties() -> &'static [glib::ParamSpec] {
|
||||||
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
|
static PROPERTIES: LazyLock<Vec<glib::ParamSpec>> = LazyLock::new(|| {
|
||||||
let mut props = Account::derived_properties().to_vec();
|
let mut props = Account::derived_properties().to_vec();
|
||||||
props.push(ParamSpecObject::builder::<Provider>("provider").build());
|
props.push(ParamSpecObject::builder::<Provider>("provider").build());
|
||||||
props
|
props
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use std::{fs, fs::File, path::PathBuf};
|
use std::{fs, fs::File, path::PathBuf, sync::LazyLock};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use diesel::{prelude::*, r2d2, r2d2::ConnectionManager};
|
use diesel::{prelude::*, r2d2, r2d2::ConnectionManager};
|
||||||
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
|
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
|
|
||||||
type Pool = r2d2::Pool<ConnectionManager<SqliteConnection>>;
|
type Pool = r2d2::Pool<ConnectionManager<SqliteConnection>>;
|
||||||
|
|
||||||
static DB_PATH: Lazy<PathBuf> = Lazy::new(|| gtk::glib::user_data_dir().join("authenticator"));
|
static DB_PATH: LazyLock<PathBuf> =
|
||||||
static POOL: Lazy<Pool> = Lazy::new(|| init_pool().expect("Failed to create a pool"));
|
LazyLock::new(|| gtk::glib::user_data_dir().join("authenticator"));
|
||||||
|
static POOL: LazyLock<Pool> = LazyLock::new(|| init_pool().expect("Failed to create a pool"));
|
||||||
|
|
||||||
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations/");
|
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations/");
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
use std::collections::HashMap;
|
use std::{collections::HashMap, sync::OnceLock};
|
||||||
|
|
||||||
use once_cell::sync::OnceCell;
|
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
|
|
||||||
use crate::config;
|
use crate::config;
|
||||||
|
|
||||||
pub static SECRET_SERVICE: OnceCell<oo7::Keyring> = OnceCell::new();
|
pub static SECRET_SERVICE: OnceLock<oo7::Keyring> = OnceLock::new();
|
||||||
|
|
||||||
fn token_attributes(token_id: &str) -> HashMap<&str, &str> {
|
fn token_attributes(token_id: &str) -> HashMap<&str, &str> {
|
||||||
HashMap::from([
|
HashMap::from([
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use once_cell::sync::Lazy;
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
mod account;
|
mod account;
|
||||||
mod accounts;
|
mod accounts;
|
||||||
|
@ -13,10 +13,10 @@ mod providers;
|
||||||
mod search_provider;
|
mod search_provider;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
|
||||||
pub static RUNTIME: Lazy<tokio::runtime::Runtime> =
|
pub static RUNTIME: LazyLock<tokio::runtime::Runtime> =
|
||||||
Lazy::new(|| tokio::runtime::Runtime::new().unwrap());
|
LazyLock::new(|| tokio::runtime::Runtime::new().unwrap());
|
||||||
pub static SETTINGS: Lazy<Settings> = Lazy::new(Settings::default);
|
pub static SETTINGS: LazyLock<Settings> = LazyLock::new(Settings::default);
|
||||||
pub static FAVICONS_PATH: Lazy<std::path::PathBuf> = Lazy::new(|| {
|
pub static FAVICONS_PATH: LazyLock<std::path::PathBuf> = LazyLock::new(|| {
|
||||||
gtk::glib::user_cache_dir()
|
gtk::glib::user_cache_dir()
|
||||||
.join("authenticator")
|
.join("authenticator")
|
||||||
.join("favicons")
|
.join("favicons")
|
||||||
|
|
|
@ -206,10 +206,9 @@ impl Provider {
|
||||||
.load::<DieselProvider>(&mut conn)?
|
.load::<DieselProvider>(&mut conn)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(From::from)
|
.map(From::from)
|
||||||
.map(|p: Provider| {
|
.inspect(|p: &Provider| {
|
||||||
let accounts = Account::load(&p).unwrap().collect::<Vec<_>>();
|
let accounts = Account::load(p).unwrap().collect::<Vec<_>>();
|
||||||
p.add_accounts(&accounts);
|
p.add_accounts(&accounts);
|
||||||
p
|
|
||||||
});
|
});
|
||||||
Ok(results)
|
Ok(results)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,12 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
use std::cell::{OnceCell, RefCell};
|
use std::{
|
||||||
|
cell::{OnceCell, RefCell},
|
||||||
|
sync::LazyLock,
|
||||||
|
};
|
||||||
|
|
||||||
use glib::subclass::{InitializingObject, Signal};
|
use glib::subclass::{InitializingObject, Signal};
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -118,8 +120,8 @@ mod imp {
|
||||||
#[glib::derived_properties]
|
#[glib::derived_properties]
|
||||||
impl ObjectImpl for AccountAddDialog {
|
impl ObjectImpl for AccountAddDialog {
|
||||||
fn signals() -> &'static [Signal] {
|
fn signals() -> &'static [Signal] {
|
||||||
static SIGNALS: Lazy<Vec<Signal>> =
|
static SIGNALS: LazyLock<Vec<Signal>> =
|
||||||
Lazy::new(|| vec![Signal::builder("added").action().build()]);
|
LazyLock::new(|| vec![Signal::builder("added").action().build()]);
|
||||||
SIGNALS.as_ref()
|
SIGNALS.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,12 @@ use crate::{
|
||||||
widgets::UrlRow,
|
widgets::UrlRow,
|
||||||
};
|
};
|
||||||
mod imp {
|
mod imp {
|
||||||
use std::cell::{OnceCell, RefCell};
|
use std::{
|
||||||
|
cell::{OnceCell, RefCell},
|
||||||
|
sync::LazyLock,
|
||||||
|
};
|
||||||
|
|
||||||
use glib::subclass::Signal;
|
use glib::subclass::Signal;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@ mod imp {
|
||||||
|
|
||||||
impl ObjectImpl for AccountDetailsPage {
|
impl ObjectImpl for AccountDetailsPage {
|
||||||
fn signals() -> &'static [Signal] {
|
fn signals() -> &'static [Signal] {
|
||||||
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
|
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
|
||||||
vec![
|
vec![
|
||||||
Signal::builder("removed")
|
Signal::builder("removed")
|
||||||
.param_types([Account::static_type()])
|
.param_types([Account::static_type()])
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
use std::{cell::OnceCell, os::fd::OwnedFd, sync::Once};
|
use std::{
|
||||||
|
cell::OnceCell,
|
||||||
|
os::fd::OwnedFd,
|
||||||
|
sync::{LazyLock, Once},
|
||||||
|
};
|
||||||
|
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
@ -9,7 +13,6 @@ use gtk::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use image::GenericImageView;
|
use image::GenericImageView;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
|
|
||||||
use super::CameraRow;
|
use super::CameraRow;
|
||||||
use crate::utils::spawn_tokio;
|
use crate::utils::spawn_tokio;
|
||||||
|
@ -99,7 +102,7 @@ mod imp {
|
||||||
|
|
||||||
impl ObjectImpl for Camera {
|
impl ObjectImpl for Camera {
|
||||||
fn signals() -> &'static [Signal] {
|
fn signals() -> &'static [Signal] {
|
||||||
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
|
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
|
||||||
vec![
|
vec![
|
||||||
Signal::builder("close").action().build(),
|
Signal::builder("close").action().build(),
|
||||||
Signal::builder("code-detected")
|
Signal::builder("code-detected")
|
||||||
|
|
|
@ -22,11 +22,11 @@ mod imp {
|
||||||
use std::{
|
use std::{
|
||||||
cell::{Cell, OnceCell, RefCell},
|
cell::{Cell, OnceCell, RefCell},
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
|
sync::LazyLock,
|
||||||
};
|
};
|
||||||
|
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
use glib::subclass::Signal;
|
use glib::subclass::Signal;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -97,8 +97,8 @@ mod imp {
|
||||||
#[glib::derived_properties]
|
#[glib::derived_properties]
|
||||||
impl ObjectImpl for PreferencesWindow {
|
impl ObjectImpl for PreferencesWindow {
|
||||||
fn signals() -> &'static [Signal] {
|
fn signals() -> &'static [Signal] {
|
||||||
static SIGNALS: Lazy<Vec<Signal>> =
|
static SIGNALS: LazyLock<Vec<Signal>> =
|
||||||
Lazy::new(|| vec![Signal::builder("restore-completed").action().build()]);
|
LazyLock::new(|| vec![Signal::builder("restore-completed").action().build()]);
|
||||||
SIGNALS.as_ref()
|
SIGNALS.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,9 @@ enum View {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
use std::cell::OnceCell;
|
use std::{cell::OnceCell, sync::LazyLock};
|
||||||
|
|
||||||
use glib::subclass::Signal;
|
use glib::subclass::Signal;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::config;
|
use crate::config;
|
||||||
|
@ -82,8 +81,8 @@ mod imp {
|
||||||
#[glib::derived_properties]
|
#[glib::derived_properties]
|
||||||
impl ObjectImpl for ProvidersDialog {
|
impl ObjectImpl for ProvidersDialog {
|
||||||
fn signals() -> &'static [Signal] {
|
fn signals() -> &'static [Signal] {
|
||||||
static SIGNALS: Lazy<Vec<Signal>> =
|
static SIGNALS: LazyLock<Vec<Signal>> =
|
||||||
Lazy::new(|| vec![Signal::builder("changed").build()]);
|
LazyLock::new(|| vec![Signal::builder("changed").build()]);
|
||||||
SIGNALS.as_ref()
|
SIGNALS.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ pub enum ProvidersListView {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use glib::subclass::Signal;
|
use glib::subclass::Signal;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -52,8 +54,7 @@ mod imp {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signals() -> &'static [Signal] {
|
fn signals() -> &'static [Signal] {
|
||||||
use once_cell::sync::Lazy;
|
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
|
||||||
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
|
|
||||||
vec![Signal::builder("shared")
|
vec![Signal::builder("shared")
|
||||||
.param_types([Account::static_type()])
|
.param_types([Account::static_type()])
|
||||||
.action()
|
.action()
|
||||||
|
|
|
@ -14,7 +14,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
use std::cell::RefCell;
|
use std::{cell::RefCell, sync::LazyLock};
|
||||||
|
|
||||||
use glib::subclass::Signal;
|
use glib::subclass::Signal;
|
||||||
|
|
||||||
|
@ -114,8 +114,7 @@ mod imp {
|
||||||
|
|
||||||
impl ObjectImpl for ProviderPage {
|
impl ObjectImpl for ProviderPage {
|
||||||
fn signals() -> &'static [Signal] {
|
fn signals() -> &'static [Signal] {
|
||||||
use once_cell::sync::Lazy;
|
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
|
||||||
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
|
|
||||||
vec![
|
vec![
|
||||||
Signal::builder("created")
|
Signal::builder("created")
|
||||||
.param_types([Provider::static_type()])
|
.param_types([Provider::static_type()])
|
||||||
|
|
|
@ -12,10 +12,9 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
mod imp {
|
mod imp {
|
||||||
use std::cell::OnceCell;
|
use std::{cell::OnceCell, sync::LazyLock};
|
||||||
|
|
||||||
use glib::subclass::Signal;
|
use glib::subclass::Signal;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -53,7 +52,7 @@ mod imp {
|
||||||
#[glib::derived_properties]
|
#[glib::derived_properties]
|
||||||
impl ObjectImpl for ProviderRow {
|
impl ObjectImpl for ProviderRow {
|
||||||
fn signals() -> &'static [Signal] {
|
fn signals() -> &'static [Signal] {
|
||||||
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
|
static SIGNALS: LazyLock<Vec<Signal>> = LazyLock::new(|| {
|
||||||
vec![
|
vec![
|
||||||
Signal::builder("changed").action().build(),
|
Signal::builder("changed").action().build(),
|
||||||
Signal::builder("shared")
|
Signal::builder("shared")
|
||||||
|
|
Loading…
Add table
Reference in a new issue