Add first VTODO support

This commit is contained in:
Lennart
2024-09-30 20:20:32 +02:00
parent b3a7806139
commit eeacbc888d
4 changed files with 23 additions and 10 deletions

View File

@@ -115,9 +115,14 @@ impl Resource for CalendarResource {
CalendarPropName::CalendarOrder => CalendarProp::CalendarOrder(Some(self.0.order)), CalendarPropName::CalendarOrder => CalendarProp::CalendarOrder(Some(self.0.order)),
CalendarPropName::SupportedCalendarComponentSet => { CalendarPropName::SupportedCalendarComponentSet => {
CalendarProp::SupportedCalendarComponentSet(SupportedCalendarComponentSet { CalendarProp::SupportedCalendarComponentSet(SupportedCalendarComponentSet {
comp: vec![SupportedCalendarComponent { comp: vec![
name: "VEVENT".to_owned(), SupportedCalendarComponent {
}], name: "VEVENT".to_owned(),
},
SupportedCalendarComponent {
name: "VTODO".to_owned(),
},
],
}) })
} }
CalendarPropName::SupportedCalendarData => { CalendarPropName::SupportedCalendarData => {

View File

@@ -1,6 +1,7 @@
pub mod calendar; pub mod calendar;
pub mod event; pub mod event;
pub mod object; pub mod object;
pub mod todo;
pub use calendar::Calendar; pub use calendar::Calendar;
pub use object::CalendarObject; pub use object::CalendarObject;

View File

@@ -1,7 +1,6 @@
use super::event::EventObject; use super::{event::EventObject, todo::TodoObject};
use crate::Error; use crate::Error;
use anyhow::Result; use anyhow::Result;
use ical::parser::ical::component::IcalTodo;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
use std::io::BufReader; use std::io::BufReader;
@@ -14,11 +13,6 @@ pub enum CalendarObjectType {
Todo, Todo,
} }
#[derive(Debug, Clone)]
pub struct TodoObject {
todo: IcalTodo,
}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum CalendarObjectComponent { pub enum CalendarObjectComponent {
Event(EventObject), Event(EventObject),
@@ -126,4 +120,11 @@ impl CalendarObject {
pub fn get_ics(&self) -> &str { pub fn get_ics(&self) -> &str {
&self.ics &self.ics
} }
pub fn get_component_name(&self) -> &str {
match self.data {
CalendarObjectComponent::Todo(_) => "VTODO",
CalendarObjectComponent::Event(_) => "VEVENT",
}
}
} }

View File

@@ -0,0 +1,6 @@
use ical::parser::ical::component::IcalTodo;
#[derive(Debug, Clone)]
pub struct TodoObject {
pub(crate) todo: IcalTodo,
}