Navigate password folders on iPhone
This commit is contained in:
@@ -19,6 +19,11 @@ use ironstorage::{
|
||||
MobileOnboardingErrorKind as StorageOnboardingErrorKind,
|
||||
MobileOnboardingPhase as StorageOnboardingPhase,
|
||||
},
|
||||
mobile_passwords::{
|
||||
MobilePasswordError as StoragePasswordError,
|
||||
MobilePasswordErrorKind as StoragePasswordErrorKind,
|
||||
MobilePasswordRowKind as StoragePasswordRowKind,
|
||||
},
|
||||
};
|
||||
|
||||
uniffi::setup_scaffolding!();
|
||||
@@ -381,6 +386,111 @@ impl MobileHomeOperation {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, uniffi::Enum)]
|
||||
pub enum MobilePasswordRowKind {
|
||||
Directory,
|
||||
Entry,
|
||||
}
|
||||
|
||||
impl From<StoragePasswordRowKind> for MobilePasswordRowKind {
|
||||
fn from(kind: StoragePasswordRowKind) -> Self {
|
||||
match kind {
|
||||
StoragePasswordRowKind::Directory => Self::Directory,
|
||||
StoragePasswordRowKind::Entry => Self::Entry,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct MobilePasswordRow {
|
||||
pub id: String,
|
||||
pub path: String,
|
||||
pub title: String,
|
||||
pub detail: String,
|
||||
pub system_image: String,
|
||||
pub kind: MobilePasswordRowKind,
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct MobilePasswordPage {
|
||||
pub id: String,
|
||||
pub path: String,
|
||||
pub title: String,
|
||||
pub rows: Vec<MobilePasswordRow>,
|
||||
}
|
||||
|
||||
impl From<ironstorage::mobile_passwords::MobilePasswordPage> for MobilePasswordPage {
|
||||
fn from(page: ironstorage::mobile_passwords::MobilePasswordPage) -> Self {
|
||||
Self {
|
||||
id: page.id().to_owned(),
|
||||
path: page.path().to_owned(),
|
||||
title: page.title().to_owned(),
|
||||
rows: page
|
||||
.rows()
|
||||
.iter()
|
||||
.map(|row| MobilePasswordRow {
|
||||
id: row.id().to_owned(),
|
||||
path: row.path().to_owned(),
|
||||
title: row.title().to_owned(),
|
||||
detail: row.detail().to_owned(),
|
||||
system_image: row.system_image().to_owned(),
|
||||
kind: row.kind().into(),
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, uniffi::Enum)]
|
||||
pub enum MobilePasswordErrorKind {
|
||||
MissingConfiguration,
|
||||
Configuration,
|
||||
InvalidPath,
|
||||
DirectoryMissing,
|
||||
Repository,
|
||||
}
|
||||
|
||||
impl From<StoragePasswordErrorKind> for MobilePasswordErrorKind {
|
||||
fn from(kind: StoragePasswordErrorKind) -> Self {
|
||||
match kind {
|
||||
StoragePasswordErrorKind::MissingConfiguration => Self::MissingConfiguration,
|
||||
StoragePasswordErrorKind::Configuration => Self::Configuration,
|
||||
StoragePasswordErrorKind::InvalidPath => Self::InvalidPath,
|
||||
StoragePasswordErrorKind::DirectoryMissing => Self::DirectoryMissing,
|
||||
StoragePasswordErrorKind::Repository => Self::Repository,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, uniffi::Error)]
|
||||
pub enum MobilePasswordFfiError {
|
||||
Failed {
|
||||
kind: MobilePasswordErrorKind,
|
||||
title: String,
|
||||
detail: String,
|
||||
},
|
||||
}
|
||||
|
||||
impl fmt::Display for MobilePasswordFfiError {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Failed { title, detail, .. } => write!(formatter, "{title}: {detail}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for MobilePasswordFfiError {}
|
||||
|
||||
impl From<StoragePasswordError> for MobilePasswordFfiError {
|
||||
fn from(error: StoragePasswordError) -> Self {
|
||||
Self::Failed {
|
||||
kind: error.kind().into(),
|
||||
title: error.title().to_owned(),
|
||||
detail: error.detail().to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, uniffi::Enum)]
|
||||
pub enum MobileOnboardingPhase {
|
||||
Validating,
|
||||
@@ -592,6 +702,15 @@ pub fn mobile_home_operation() -> Arc<MobileHomeOperation> {
|
||||
})
|
||||
}
|
||||
|
||||
#[uniffi::export]
|
||||
pub fn mobile_password_page(
|
||||
path: Option<String>,
|
||||
) -> Result<MobilePasswordPage, MobilePasswordFfiError> {
|
||||
ironstorage::mobile_passwords::MobilePasswordPage::load(path.as_deref())
|
||||
.map(Into::into)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
#[uniffi::export]
|
||||
pub fn mobile_onboarding_operation(
|
||||
server_url: String,
|
||||
|
||||
Reference in New Issue
Block a user