Implement iPhone password swipe actions

This commit is contained in:
2026-08-11 22:13:29 +02:00
parent a748744425
commit 6edcb5fc86
7 changed files with 1816 additions and 6 deletions

View File

@@ -37,6 +37,11 @@ use ironstorage::{
MobileKeyTransferKind as StorageKeyTransferKind,
MobileKeyTransferProgress as StorageKeyTransferProgress,
},
mobile_mutation::{
MobileMutationAction as StorageMutationAction,
MobileMutationOutcome as StorageMutationOutcome, MobileMutationPlan as StorageMutationPlan,
MobileMutationRequest as StorageMutationRequest,
},
mobile_onboarding::{
self, MobileOnboardingError as StorageOnboardingError,
MobileOnboardingErrorKind as StorageOnboardingErrorKind,
@@ -560,6 +565,121 @@ pub struct MobileAuthenticationState {
pub remaining_seconds: u64,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, uniffi::Enum)]
pub enum MobileMutationAction {
Move,
Copy,
Delete,
}
impl From<StorageMutationAction> for MobileMutationAction {
fn from(action: StorageMutationAction) -> Self {
match action {
StorageMutationAction::Move => Self::Move,
StorageMutationAction::Copy => Self::Copy,
StorageMutationAction::Delete => Self::Delete,
}
}
}
impl From<MobileMutationAction> for StorageMutationAction {
fn from(action: MobileMutationAction) -> Self {
match action {
MobileMutationAction::Move => Self::Move,
MobileMutationAction::Copy => Self::Copy,
MobileMutationAction::Delete => Self::Delete,
}
}
}
#[derive(Clone, uniffi::Record)]
pub struct MobileMutationDestination {
pub path: String,
pub title: String,
pub detail: String,
pub requires_overwrite: bool,
}
#[derive(Clone, uniffi::Record)]
pub struct MobileMutationPlan {
pub action: MobileMutationAction,
pub source: String,
pub source_title: String,
pub revision: String,
pub destinations: Vec<MobileMutationDestination>,
pub has_open_editor: bool,
pub has_dirty_editor: bool,
}
impl From<StorageMutationPlan> for MobileMutationPlan {
fn from(plan: StorageMutationPlan) -> Self {
Self {
action: plan.action().into(),
source: plan.source().to_owned(),
source_title: plan.source_title().to_owned(),
revision: plan.revision().to_owned(),
destinations: plan
.destinations()
.iter()
.map(|destination| MobileMutationDestination {
path: destination.path().to_owned(),
title: destination.title().to_owned(),
detail: destination.detail().to_owned(),
requires_overwrite: destination.requires_overwrite(),
})
.collect(),
has_open_editor: plan.has_open_editor(),
has_dirty_editor: plan.has_dirty_editor(),
}
}
}
#[derive(Clone, uniffi::Record)]
pub struct MobileMutationRequest {
pub action: MobileMutationAction,
pub source: String,
pub revision: String,
pub destination: Option<String>,
pub confirmed: bool,
pub overwrite: bool,
pub discard_editor: bool,
}
impl From<MobileMutationRequest> for StorageMutationRequest {
fn from(request: MobileMutationRequest) -> Self {
Self {
action: request.action.into(),
source: request.source,
revision: request.revision,
destination: request.destination,
confirmed: request.confirmed,
overwrite: request.overwrite,
discard_editor: request.discard_editor,
}
}
}
#[derive(Clone, uniffi::Record)]
pub struct MobileMutationOutcome {
pub action: MobileMutationAction,
pub source: String,
pub destination: Option<String>,
pub title: String,
pub detail: String,
}
impl From<StorageMutationOutcome> for MobileMutationOutcome {
fn from(outcome: StorageMutationOutcome) -> Self {
Self {
action: outcome.action().into(),
source: outcome.source().to_owned(),
destination: outcome.destination().map(str::to_owned),
title: outcome.title().to_owned(),
detail: outcome.detail().to_owned(),
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, uniffi::Enum)]
pub enum MobileEntrySectionKind {
Password,
@@ -1193,6 +1313,27 @@ impl MobileAuthentication {
.map_err(Into::into)
}
pub fn prepare_entry_mutation(
&self,
path: String,
action: MobileMutationAction,
) -> Result<MobileMutationPlan, MobileAuthenticationFfiError> {
self.authentication
.prepare_entry_mutation(&path, action.into())
.map(Into::into)
.map_err(Into::into)
}
pub fn perform_entry_mutation(
&self,
request: MobileMutationRequest,
) -> Result<MobileMutationOutcome, MobileAuthenticationFfiError> {
self.authentication
.perform_entry_mutation(request.into())
.map(Into::into)
.map_err(Into::into)
}
pub fn replace_entry_field(
&self,
path: String,