aboutsummaryrefslogtreecommitdiff
path: root/aero-dav/src/acldecoder.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-03-19 17:36:32 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-03-19 17:36:32 +0100
commitfb6a379f43ff579dbc224fb52180ba3a6d6cde5c (patch)
tree0b570817fb7be8a30a2161b0782b54c710509f18 /aero-dav/src/acldecoder.rs
parent5bf3517acfea3694fbe586e69a0e02b94c61eb1b (diff)
downloadaerogramme-fb6a379f43ff579dbc224fb52180ba3a6d6cde5c.tar.gz
aerogramme-fb6a379f43ff579dbc224fb52180ba3a6d6cde5c.zip
Working thunderbird autodetect
Diffstat (limited to 'aero-dav/src/acldecoder.rs')
-rw-r--r--aero-dav/src/acldecoder.rs68
1 files changed, 68 insertions, 0 deletions
diff --git a/aero-dav/src/acldecoder.rs b/aero-dav/src/acldecoder.rs
new file mode 100644
index 0000000..67dfb0b
--- /dev/null
+++ b/aero-dav/src/acldecoder.rs
@@ -0,0 +1,68 @@
+use super::acltypes::*;
+use super::types as dav;
+use super::xml::{QRead, Reader, IRead, DAV_URN};
+use super::error::ParsingError;
+
+impl QRead<Property> for Property {
+ async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
+ if xml.maybe_open_start(DAV_URN, "owner").await?.is_some() {
+ let href = xml.find().await?;
+ xml.close().await?;
+ return Ok(Self::Owner(href))
+ }
+ if xml.maybe_open_start(DAV_URN, "current-user-principal").await?.is_some() {
+ let user = xml.find().await?;
+ xml.close().await?;
+ return Ok(Self::CurrentUserPrincipal(user))
+ }
+ if xml.maybe_open_start(DAV_URN, "current-user-privilege-set").await?.is_some() {
+ xml.close().await?;
+ return Ok(Self::CurrentUserPrivilegeSet(vec![]))
+ }
+
+ Err(ParsingError::Recoverable)
+ }
+}
+
+impl QRead<PropertyRequest> for PropertyRequest {
+ async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
+ if xml.maybe_open(DAV_URN, "owner").await?.is_some() {
+ xml.close().await?;
+ return Ok(Self::Owner)
+ }
+
+ if xml.maybe_open(DAV_URN, "current-user-principal").await?.is_some() {
+ xml.close().await?;
+ return Ok(Self::CurrentUserPrincipal)
+ }
+
+ if xml.maybe_open(DAV_URN, "current-user-privilege-set").await?.is_some() {
+ xml.close().await?;
+ return Ok(Self::CurrentUserPrivilegeSet)
+ }
+
+ Err(ParsingError::Recoverable)
+ }
+}
+
+impl QRead<ResourceType> for ResourceType {
+ async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
+ if xml.maybe_open(DAV_URN, "principal").await?.is_some() {
+ xml.close().await?;
+ return Ok(Self::Principal)
+ }
+ Err(ParsingError::Recoverable)
+ }
+}
+
+// -----
+impl QRead<User> for User {
+ async fn qread(xml: &mut Reader<impl IRead>) -> Result<Self, ParsingError> {
+ if xml.maybe_open(DAV_URN, "unauthenticated").await?.is_some() {
+ xml.close().await?;
+ return Ok(Self::Unauthenticated)
+ }
+
+ dav::Href::qread(xml).await.map(Self::Authenticated)
+ }
+}