Add events

This commit is contained in:
Ilya
2022-04-13 12:43:45 +02:00
parent 2281c34529
commit 644800907d
8 changed files with 401 additions and 104 deletions
+1
View File
@@ -7,6 +7,7 @@ use kitchen_fridge::traits::CalDavSource;
use kitchen_fridge::calendar::SupportedComponents;
use kitchen_fridge::Item;
use kitchen_fridge::Task;
use kitchen_fridge::Event;
use kitchen_fridge::task::CompletionStatus;
use kitchen_fridge::CalDavProvider;
use kitchen_fridge::traits::BaseCalendar;
+14 -10
View File
@@ -1,24 +1,27 @@
use std::path::Path;
use kitchen_fridge::cache::Cache;
use kitchen_fridge::client::Client;
use kitchen_fridge::traits::CalDavSource;
use kitchen_fridge::CalDavProvider;
use kitchen_fridge::cache::Cache;
// TODO: change these values with yours
pub const URL: &str = "https://my.server.com/remote.php/dav/files/john";
pub const USERNAME: &str = "username";
pub const PASSWORD: &str = "secret_password";
pub const URL: &str = "https://next.anshorei.me/remote.php/dav/files/test";
pub const USERNAME: &str = "test";
pub const PASSWORD: &str = "1ETsJD6BPTIMLhmVQcCK";
pub const EXAMPLE_EXISTING_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_name/";
pub const EXAMPLE_CREATED_CALENDAR_URL: &str = "https://my.server.com/remote.php/dav/calendars/john/a_calendar_that_we_have_created/";
// pub const EXAMPLE_EXISTING_CALENDAR_URL: &str =
// "https://my.server.com/remote.php/dav/calendars/john/a_calendar_name/";
pub const EXAMPLE_CREATED_CALENDAR_URL: &str =
"https://next.anshorei.me/remote.php/dav/calendars/test/a_calendar_that_we_have_created/";
// https://next.anshorei.me/remote.php/dav
pub const EXAMPLE_EXISTING_CALENDAR_URL: &str =
"https://next.anshorei.me/remote.php/dav/calendars/test/personal/";
fn main() {
panic!("This file is not supposed to be executed");
}
/// Initializes a Provider, and run an initial sync from the server
pub async fn initial_sync(cache_folder: &str) -> CalDavProvider {
let cache_path = Path::new(cache_folder);
@@ -33,13 +36,14 @@ pub async fn initial_sync(cache_folder: &str) -> CalDavProvider {
};
let mut provider = CalDavProvider::new(client, cache);
let cals = provider.local().get_calendars().await.unwrap();
println!("---- Local items, before sync -----");
kitchen_fridge::utils::print_calendar_list(&cals).await;
println!("Starting a sync...");
println!("Depending on your RUST_LOG value, you may see more or less details about the progress.");
println!(
"Depending on your RUST_LOG value, you may see more or less details about the progress."
);
// Note that we could use sync_with_feedback() to have better and formatted feedback
if provider.sync().await == false {
log::warn!("Sync did not complete, see the previous log lines for more info. You can safely start a new sync.");