From 410d663a5ecbb6ca46ac049227afdaaaf50ac27f Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 28 May 2024 13:04:46 +0200 Subject: add a multistatus extension entrypoint --- aero-dav/src/caldecoder.rs | 1 + aero-dav/src/calencoder.rs | 1 + aero-dav/src/decoder.rs | 5 +++++ aero-dav/src/encoder.rs | 7 +++++++ aero-dav/src/realization.rs | 4 ++++ aero-dav/src/types.rs | 2 ++ aero-proto/src/dav/controller.rs | 1 + 7 files changed, 21 insertions(+) diff --git a/aero-dav/src/caldecoder.rs b/aero-dav/src/caldecoder.rs index 0df867f..9ed783a 100644 --- a/aero-dav/src/caldecoder.rs +++ b/aero-dav/src/caldecoder.rs @@ -1198,6 +1198,7 @@ END:VCALENDAR]]> #[tokio::test] async fn rfc_calendar_query_res() { let expected = dav::Multistatus:: { + extension: None, responses: vec![ dav::Response { status_or_propstat: dav::StatusOrPropstat::PropStat( diff --git a/aero-dav/src/calencoder.rs b/aero-dav/src/calencoder.rs index a41747f..15df965 100644 --- a/aero-dav/src/calencoder.rs +++ b/aero-dav/src/calencoder.rs @@ -950,6 +950,7 @@ mod tests { #[tokio::test] async fn rfc_calendar_query1_res() { let got = serialize(&dav::Multistatus:: { + extension: None, responses: vec![ dav::Response { status_or_propstat: dav::StatusOrPropstat::PropStat( diff --git a/aero-dav/src/decoder.rs b/aero-dav/src/decoder.rs index bd724e8..bb64455 100644 --- a/aero-dav/src/decoder.rs +++ b/aero-dav/src/decoder.rs @@ -67,11 +67,13 @@ impl QRead> for Multistatus { xml.open(DAV_URN, "multistatus").await?; let mut responses = Vec::new(); let mut responsedescription = None; + let mut extension = None; loop { let mut dirty = false; xml.maybe_push(&mut responses, &mut dirty).await?; xml.maybe_read(&mut responsedescription, &mut dirty).await?; + xml.maybe_read(&mut extension, &mut dirty).await?; if !dirty { match xml.peek() { Event::End(_) => break, @@ -84,6 +86,7 @@ impl QRead> for Multistatus { Ok(Multistatus { responses, responsedescription, + extension, }) } } @@ -983,6 +986,7 @@ mod tests { }, ], responsedescription: None, + extension: None, } ); } @@ -1053,6 +1057,7 @@ mod tests { assert_eq!( got, Multistatus { + extension: None, responses: vec![ Response { status_or_propstat: StatusOrPropstat::PropStat( diff --git a/aero-dav/src/encoder.rs b/aero-dav/src/encoder.rs index fd87e95..6c77aa6 100644 --- a/aero-dav/src/encoder.rs +++ b/aero-dav/src/encoder.rs @@ -60,6 +60,9 @@ impl QWrite for Multistatus { if let Some(description) = &self.responsedescription { description.qwrite(xml).await?; } + if let Some(extension) = &self.extension { + extension.qwrite(xml).await?; + } xml.q.write_event_async(Event::End(end)).await?; Ok(()) @@ -752,6 +755,7 @@ mod tests { #[tokio::test] async fn basic_multistatus() { let orig = Multistatus:: { + extension: None, responses: vec![], responsedescription: Some(ResponseDescription("Hello world".into())), }; @@ -808,6 +812,7 @@ mod tests { #[tokio::test] async fn rfc_propname_res() { let orig = Multistatus:: { + extension: None, responses: vec![ Response { status_or_propstat: StatusOrPropstat::PropStat( @@ -916,6 +921,7 @@ mod tests { use chrono::{FixedOffset, TimeZone}; let orig = Multistatus:: { + extension: None, responses: vec![ Response { status_or_propstat: StatusOrPropstat::PropStat( @@ -1140,6 +1146,7 @@ mod tests { #[tokio::test] async fn rfc_delete_locked2() { let orig = Multistatus:: { + extension: None, responses: vec![Response { status_or_propstat: StatusOrPropstat::Status( vec![Href("http://www.example.com/container/resource3".into())], diff --git a/aero-dav/src/realization.rs b/aero-dav/src/realization.rs index b37e0f1..1e6f25e 100644 --- a/aero-dav/src/realization.rs +++ b/aero-dav/src/realization.rs @@ -35,6 +35,7 @@ impl dav::Extension for Core { type ResourceType = Disabled; type ReportType = Disabled; type ReportTypeName = Disabled; + type Multistatus = Disabled; } // WebDAV with the base Calendar implementation (RFC4791) @@ -47,6 +48,7 @@ impl dav::Extension for Calendar { type ResourceType = cal::ResourceType; type ReportType = cal::ReportType; type ReportTypeName = cal::ReportTypeName; + type Multistatus = Disabled; } // ACL @@ -59,6 +61,7 @@ impl dav::Extension for Acl { type ResourceType = acl::ResourceType; type ReportType = Disabled; type ReportTypeName = Disabled; + type Multistatus = Disabled; } // All merged @@ -71,6 +74,7 @@ impl dav::Extension for All { type ResourceType = ResourceType; type ReportType = ReportType; type ReportTypeName = ReportTypeName; + type Multistatus = Disabled; } #[derive(Debug, PartialEq, Clone)] diff --git a/aero-dav/src/types.rs b/aero-dav/src/types.rs index 92c63e0..61a6fe9 100644 --- a/aero-dav/src/types.rs +++ b/aero-dav/src/types.rs @@ -13,6 +13,7 @@ pub trait Extension: std::fmt::Debug + PartialEq + Clone { type ResourceType: xml::Node; type ReportType: xml::Node; type ReportTypeName: xml::Node; + type Multistatus: xml::Node; } /// 14.1. activelock XML Element @@ -338,6 +339,7 @@ pub enum LockType { pub struct Multistatus { pub responses: Vec>, pub responsedescription: Option, + pub extension: Option, } /// 14.17. owner XML Element diff --git a/aero-proto/src/dav/controller.rs b/aero-proto/src/dav/controller.rs index 1b7f7ee..4bae68a 100644 --- a/aero-proto/src/dav/controller.rs +++ b/aero-proto/src/dav/controller.rs @@ -309,6 +309,7 @@ impl Controller { dav::Multistatus:: { responses, responsedescription: None, + extension: None, } } } -- cgit v1.2.3