Initial commit of version 0.2.0
This commit is contained in:
parent
86fc06b877
commit
dfb04462f3
108 changed files with 16167 additions and 80 deletions
45
app/src-tauri/src/lib.rs
Normal file
45
app/src-tauri/src/lib.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
const CREDENTIAL_SERVICE: &str = "com.elijahkuntz.decky.nextcloud";
|
||||
|
||||
fn credential_entry(server: &str, username: &str) -> Result<keyring::Entry, String> {
|
||||
let account = format!("{}|{}", server.trim().to_lowercase(), username.trim());
|
||||
keyring::Entry::new(CREDENTIAL_SERVICE, &account).map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn get_credential(server: String, username: String) -> Result<Option<String>, String> {
|
||||
match credential_entry(&server, &username)?.get_password() {
|
||||
Ok(password) => Ok(Some(password)),
|
||||
Err(keyring::Error::NoEntry) => Ok(None),
|
||||
Err(error) => Err(error.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn set_credential(server: String, username: String, password: String) -> Result<(), String> {
|
||||
credential_entry(&server, &username)?
|
||||
.set_password(&password)
|
||||
.map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn delete_credential(server: String, username: String) -> Result<(), String> {
|
||||
match credential_entry(&server, &username)?.delete_credential() {
|
||||
Ok(()) | Err(keyring::Error::NoEntry) => Ok(()),
|
||||
Err(error) => Err(error.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_http::init())
|
||||
.plugin(tauri_plugin_process::init())
|
||||
.plugin(tauri_plugin_updater::Builder::new().build())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
get_credential,
|
||||
set_credential,
|
||||
delete_credential
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running Decky");
|
||||
}
|
||||
5
app/src-tauri/src/main.rs
Normal file
5
app/src-tauri/src/main.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
decky_lib::run();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue