aboutsummaryrefslogtreecommitdiff
path: root/aero-dav/src
diff options
context:
space:
mode:
Diffstat (limited to 'aero-dav/src')
-rw-r--r--aero-dav/src/caldecoder.rs16
-rw-r--r--aero-dav/src/calencoder.rs15
-rw-r--r--aero-dav/src/caltypes.rs8
3 files changed, 38 insertions, 1 deletions
diff --git a/aero-dav/src/caldecoder.rs b/aero-dav/src/caldecoder.rs
index b124154..f92cf09 100644
--- a/aero-dav/src/caldecoder.rs
+++ b/aero-dav/src/caldecoder.rs
@@ -25,6 +25,22 @@ impl<E: dav::Extension> QRead<MkCalendarResponse<E>> for MkCalendarResponse<E> {
}
}
+impl<E: dav::Extension> QRead<Report<E>> for Report<E> {
+ async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
+ match CalendarQuery::<E>::qread(xml).await {
+ Err(ParsingError::Recoverable) => (),
+ otherwise => return otherwise.map(Self::Query)
+ }
+
+ match CalendarMultiget::<E>::qread(xml).await {
+ Err(ParsingError::Recoverable) => (),
+ otherwise => return otherwise.map(Self::Multiget),
+ }
+
+ FreeBusyQuery::qread(xml).await.map(Self::FreeBusy)
+ }
+}
+
impl<E: dav::Extension> QRead<CalendarQuery<E>> for CalendarQuery<E> {
async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
xml.open(CAL_URN, "calendar-query").await?;
diff --git a/aero-dav/src/calencoder.rs b/aero-dav/src/calencoder.rs
index d4e79dc..d324c7f 100644
--- a/aero-dav/src/calencoder.rs
+++ b/aero-dav/src/calencoder.rs
@@ -34,6 +34,15 @@ impl<E: Extension> QWrite for MkCalendarResponse<E> {
}
// ----------------------- REPORT METHOD -------------------------------------
+impl<E: Extension> QWrite for Report<E> {
+ async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
+ match self {
+ Self::Query(v) => v.qwrite(xml).await,
+ Self::Multiget(v) => v.qwrite(xml).await,
+ Self::FreeBusy(v) => v.qwrite(xml).await,
+ }
+ }
+}
impl<E: Extension> QWrite for CalendarQuery<E> {
async fn qwrite(&self, xml: &mut Writer<impl IWrite>) -> Result<(), QError> {
@@ -335,6 +344,12 @@ impl QWrite for CalendarDataRequest {
start.push_attribute(("content-type", mime.content_type.as_str()));
start.push_attribute(("version", mime.version.as_str()));
}
+
+ // Empty tag
+ if self.comp.is_none() && self.recurrence.is_none() && self.limit_freebusy_set.is_none() {
+ return xml.q.write_event_async(Event::Empty(start.clone())).await
+ }
+
let end = start.to_end();
xml.q.write_event_async(Event::Start(start.clone())).await?;
if let Some(comp) = &self.comp {
diff --git a/aero-dav/src/caltypes.rs b/aero-dav/src/caltypes.rs
index 602498c..08991a0 100644
--- a/aero-dav/src/caltypes.rs
+++ b/aero-dav/src/caltypes.rs
@@ -51,6 +51,12 @@ pub struct MkCalendar<E: dav::Extension>(pub dav::Set<E>);
pub struct MkCalendarResponse<E: dav::Extension>(pub Vec<dav::PropStat<E>>);
// --- (REPORT PART) ---
+#[derive(Debug, PartialEq, Clone)]
+pub enum Report<E: dav::Extension> {
+ Query(CalendarQuery<E>),
+ Multiget(CalendarMultiget<E>),
+ FreeBusy(FreeBusyQuery),
+}
/// Name: calendar-query
///
@@ -827,7 +833,7 @@ pub struct CalendarDataPayload {
/// when nested in the DAV:prop XML element in a calendaring
/// REPORT request to specify which parts of calendar object
/// resources should be returned in the response;
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Clone, Default)]
pub struct CalendarDataRequest {
pub mime: Option<CalendarDataSupport>,
pub comp: Option<Comp>,