Implement Android Home activity and HTTPS synchronization (#97)
This commit is contained in:
1 parent
8c9341f214
commit
5c933a99a3
29 files changed
+2008
-110
No files matched your search
@@ -525,6 +525,18 @@ pub struct MobileHomeOperation {
|
||||
|
||||
#[uniffi::export]
|
||||
impl MobileHomeOperation {
|
||||
pub fn activity_known(&self) -> bool {
|
||||
self.operation.activity_known()
|
||||
}
|
||||
pub fn identity(&self) -> Result<MobileGitIdentity, MobileHomeFfiError> {
|
||||
self.operation
|
||||
.identity()
|
||||
.map(|identity| MobileGitIdentity {
|
||||
name: identity.name().to_owned(),
|
||||
email: identity.email().to_owned(),
|
||||
})
|
||||
.map_err(Into::into)
|
||||
}
|
||||
pub fn progress(&self) -> MobileHomeProgress {
|
||||
let progress = self.operation.progress();
|
||||
MobileHomeProgress {
|
||||
@@ -569,6 +581,13 @@ impl MobileHomeOperation {
|
||||
self.operation.sync().map(Into::into).map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn refresh_gesture(&self) -> Result<MobileHomePage, MobileHomeFfiError> {
|
||||
self.operation
|
||||
.refresh_gesture()
|
||||
.map(Into::into)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn cancel(&self) {
|
||||
self.operation.cancel();
|
||||
}
|
||||
|
||||
@@ -96,10 +96,22 @@ pub struct MobilePrivateStorageLayout {
|
||||
|
||||
#[derive(uniffi::Object)]
|
||||
pub struct MobilePrivateRuntime {
|
||||
pub(crate) storage: PrivateStorage,
|
||||
pub(crate) storage: Arc<PrivateStorage>,
|
||||
}
|
||||
#[uniffi::export]
|
||||
impl MobilePrivateRuntime {
|
||||
pub fn android_home_operation(
|
||||
&self,
|
||||
backend: Arc<dyn MobileSecretBackend>,
|
||||
clock: Arc<dyn MobileClock>,
|
||||
) -> Result<Arc<crate::MobileHomeOperation>, crate::MobileHomeFfiError> {
|
||||
let operation = ironstorage::mobile_home::MobileHomeOperation::with_private(
|
||||
Arc::clone(&self.storage),
|
||||
Arc::new(SecretBackendAdapter(backend)),
|
||||
Arc::new(ClockAdapter(clock)),
|
||||
)?;
|
||||
Ok(Arc::new(crate::MobileHomeOperation { operation }))
|
||||
}
|
||||
pub fn android_onboarding(
|
||||
&self,
|
||||
backend: Arc<dyn MobileSecretBackend>,
|
||||
@@ -163,30 +175,11 @@ impl MobilePrivateRuntime {
|
||||
backend: Arc<dyn MobileSecretBackend>,
|
||||
clock: Arc<dyn MobileClock>,
|
||||
) -> Result<Arc<MobileAuthentication>, crate::MobileAuthenticationFfiError> {
|
||||
self.storage
|
||||
.verify_secure_storage(&SecretBackendAdapter(Arc::clone(&backend)))
|
||||
.map_err(private_auth_error)?;
|
||||
let config = self
|
||||
.storage
|
||||
.configuration()
|
||||
.map_err(private_auth_error)?
|
||||
.ok_or_else(|| private_auth_error(PrivateStorageError::ConfigurationMissingWithData))?;
|
||||
let authentication =
|
||||
ironstorage::mobile_authentication::MobileAuthentication::with_platform(
|
||||
config,
|
||||
Arc::new(SecretBackendAdapter(backend)),
|
||||
Arc::new(ClockAdapter(clock)),
|
||||
)?;
|
||||
Ok(Arc::new(MobileAuthentication {
|
||||
authentication: Arc::new(authentication),
|
||||
}))
|
||||
}
|
||||
}
|
||||
fn private_auth_error(error: PrivateStorageError) -> crate::MobileAuthenticationFfiError {
|
||||
crate::MobileAuthenticationFfiError::Failed {
|
||||
kind: crate::MobileAuthenticationErrorKind::Configuration,
|
||||
title: "Private Storage Recovery Required".into(),
|
||||
detail: error.detail().into(),
|
||||
let authentication = self.storage.authentication(
|
||||
Arc::new(SecretBackendAdapter(backend)),
|
||||
Arc::new(ClockAdapter(clock)),
|
||||
)?;
|
||||
Ok(Arc::new(MobileAuthentication { authentication }))
|
||||
}
|
||||
}
|
||||
#[uniffi::export]
|
||||
@@ -198,7 +191,9 @@ pub fn open_mobile_private_runtime(
|
||||
no_backup: directories.no_backup.into(),
|
||||
cache: directories.cache.into(),
|
||||
})?;
|
||||
Ok(Arc::new(MobilePrivateRuntime { storage }))
|
||||
Ok(Arc::new(MobilePrivateRuntime {
|
||||
storage: Arc::new(storage),
|
||||
}))
|
||||
}
|
||||
|
||||
#[uniffi::export]
|
||||
|
||||
Reference in new issue
Block a user