You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
//! This module is the data source of the Caldav items |
|
//! |
|
//! This gives access to data from both the server and a local database for quick retrieval when the app starts |
|
|
|
use std::sync::Arc; |
|
|
|
mod calendar; |
|
mod tasks; |
|
mod client; |
|
|
|
pub use calendar::Calendar; |
|
pub use tasks::Task; |
|
use client::Client; |
|
|
|
/// A Caldav data source |
|
pub struct DataSource { |
|
client: Option<Client>, |
|
|
|
calendars: Vec<Calendar> |
|
} |
|
|
|
impl DataSource { |
|
/// Create a new data source |
|
pub fn new() -> Self { |
|
Self{ |
|
client: None, |
|
calendars: Vec::new(), |
|
} |
|
} |
|
|
|
/// Tell this data source what the source server is |
|
pub fn set_server(&mut self, url: String, username: String, password: String) { |
|
self.client = Client::new(url, username, password); |
|
} |
|
|
|
/// Update the local database with info from the Client |
|
pub fn fetch_from_server(&self) { |
|
// TODO: how to handle conflicts? |
|
} |
|
|
|
pub fn calendars(&self) -> Vec<&Calendar> { |
|
self.calendars |
|
.iter() |
|
.map(|c| &c) |
|
.collect() |
|
} |
|
}
|
|
|