Prepare Apple App Store distribution (#59)
This commit is contained in:
1 parent
b50e47ab73
commit
f894d43eb6
46 files changed
+20694
-166
No files matched your search
@@ -150,6 +150,7 @@ pub enum MobileWatchPreferenceState {
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct MobilePreferences {
|
||||
sync_configured: bool,
|
||||
repository_title: String,
|
||||
repository_url: String,
|
||||
server_title: String,
|
||||
@@ -166,6 +167,10 @@ pub struct MobilePreferences {
|
||||
}
|
||||
|
||||
impl MobilePreferences {
|
||||
pub fn sync_configured(&self) -> bool {
|
||||
self.sync_configured
|
||||
}
|
||||
|
||||
pub fn repository_title(&self) -> &str {
|
||||
&self.repository_title
|
||||
}
|
||||
@@ -562,8 +567,7 @@ impl MobileAuthentication {
|
||||
.git_remotes()
|
||||
.iter()
|
||||
.find(|remote| remote.name().as_str() == "origin")
|
||||
.or_else(|| self.config.git_remotes().first())
|
||||
.ok_or_else(|| config_detail("No HTTPS Git remote is configured."))?;
|
||||
.or_else(|| self.config.git_remotes().first());
|
||||
let handle = self
|
||||
.keys
|
||||
.resolve(self.config.default_key().as_str())
|
||||
@@ -587,20 +591,34 @@ impl MobileAuthentication {
|
||||
let biometric_unlock_enabled = status.biometric_unlock_enabled;
|
||||
let appearance = status.appearance;
|
||||
drop(status);
|
||||
let server_title = remote.url().host_str().unwrap_or("HTTPS server").to_owned();
|
||||
let repository_title = remote
|
||||
.url()
|
||||
.path_segments()
|
||||
.and_then(Iterator::last)
|
||||
.unwrap_or("Password Store")
|
||||
.trim_end_matches(".git")
|
||||
.to_owned();
|
||||
let repository_title = remote.map_or_else(
|
||||
|| "Local Password Store".to_owned(),
|
||||
|remote| {
|
||||
remote
|
||||
.url()
|
||||
.path_segments()
|
||||
.and_then(Iterator::last)
|
||||
.unwrap_or("Password Store")
|
||||
.trim_end_matches(".git")
|
||||
.to_owned()
|
||||
},
|
||||
);
|
||||
Ok(MobilePreferences {
|
||||
sync_configured: remote.is_some(),
|
||||
repository_title,
|
||||
repository_url: remote.url().to_string(),
|
||||
server_title,
|
||||
server_identity: remote.server_id().as_str().to_owned(),
|
||||
application_account: application_account(remote)?,
|
||||
repository_url: remote.map_or_else(
|
||||
|| "Stored and versioned on this iPhone".to_owned(),
|
||||
|remote| remote.url().to_string(),
|
||||
),
|
||||
server_title: remote
|
||||
.and_then(|remote| remote.url().host_str())
|
||||
.unwrap_or("Git Sync Not Configured")
|
||||
.to_owned(),
|
||||
server_identity: remote.map_or_else(
|
||||
|| "Add an HTTPS remote when you want to sync".to_owned(),
|
||||
|remote| remote.server_id().as_str().to_owned(),
|
||||
),
|
||||
application_account: remote.map(application_account).transpose()?.flatten(),
|
||||
default_key_title: key
|
||||
.user_ids()
|
||||
.first()
|
||||
@@ -1073,6 +1091,44 @@ impl MobileAuthentication {
|
||||
self.store_editor(MobileEntryDraft::new(document, true))
|
||||
}
|
||||
|
||||
pub fn create_directory(
|
||||
&self,
|
||||
parent: &str,
|
||||
name: &str,
|
||||
) -> Result<(), MobileAuthenticationError> {
|
||||
self.ensure_repository_idle()?;
|
||||
let parent = DirectoryPath::parse(parent).map_err(entry_error)?;
|
||||
let leaf = DirectoryPath::parse(name).map_err(entry_error)?;
|
||||
if leaf
|
||||
.as_path()
|
||||
.parent()
|
||||
.is_some_and(|parent| !parent.as_os_str().is_empty())
|
||||
{
|
||||
return Err(entry_detail(
|
||||
"Folder Name Is Invalid",
|
||||
"enter a name without a folder separator",
|
||||
));
|
||||
}
|
||||
let directory =
|
||||
DirectoryPath::parse(parent.as_path().join(leaf.as_path())).map_err(entry_error)?;
|
||||
if self
|
||||
.repository
|
||||
.snapshot()
|
||||
.map_err(entry_error)?
|
||||
.directories()
|
||||
.any(|record| record.path() == &directory)
|
||||
{
|
||||
return Err(entry_detail(
|
||||
"Folder Already Exists",
|
||||
"Choose a different folder name.",
|
||||
));
|
||||
}
|
||||
self.repository
|
||||
.ensure_directory(&directory)
|
||||
.map_err(|error| entry_detail("Folder Could Not Be Created", error))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn entry_editor(
|
||||
&self,
|
||||
editor: u64,
|
||||
|
||||
Reference in new issue
Block a user