mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 02:22:21 +00:00
caldav: Add supported-collation-set property
This commit is contained in:
@@ -10,6 +10,7 @@ pub enum TextCollation {
|
|||||||
|
|
||||||
impl TextCollation {
|
impl TextCollation {
|
||||||
// Check whether a haystack contains a needle respecting the collation
|
// Check whether a haystack contains a needle respecting the collation
|
||||||
|
#[must_use]
|
||||||
pub fn match_text(&self, needle: &str, haystack: &str) -> bool {
|
pub fn match_text(&self, needle: &str, haystack: &str) -> bool {
|
||||||
match self {
|
match self {
|
||||||
// https://datatracker.ietf.org/doc/html/rfc4790#section-9.2
|
// https://datatracker.ietf.org/doc/html/rfc4790#section-9.2
|
||||||
@@ -21,6 +22,15 @@ impl TextCollation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsRef<str> for TextCollation {
|
||||||
|
fn as_ref(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
Self::AsciiCasemap => "i;ascii-casemap",
|
||||||
|
Self::Octet => "i;octet",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ValueDeserialize for TextCollation {
|
impl ValueDeserialize for TextCollation {
|
||||||
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
fn deserialize(val: &str) -> Result<Self, rustical_xml::XmlError> {
|
||||||
match val {
|
match val {
|
||||||
@@ -60,6 +70,7 @@ pub struct TextMatchElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TextMatchElement {
|
impl TextMatchElement {
|
||||||
|
#[must_use]
|
||||||
pub fn match_property(&self, property: &Property) -> bool {
|
pub fn match_property(&self, property: &Property) -> bool {
|
||||||
let Self {
|
let Self {
|
||||||
collation,
|
collation,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use sync_collection::handle_sync_collection;
|
|||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
mod calendar_multiget;
|
mod calendar_multiget;
|
||||||
mod calendar_query;
|
pub mod calendar_query;
|
||||||
mod sync_collection;
|
mod sync_collection;
|
||||||
|
|
||||||
#[derive(XmlDeserialize, XmlDocument, Clone, Debug, PartialEq)]
|
#[derive(XmlDeserialize, XmlDocument, Clone, Debug, PartialEq)]
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ use rustical_ical::CalendarObjectType;
|
|||||||
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||||
use strum_macros::VariantArray;
|
use strum_macros::VariantArray;
|
||||||
|
|
||||||
|
use crate::calendar::methods::report::calendar_query::text_match::TextCollation;
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq, From, Into)]
|
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq, From, Into)]
|
||||||
pub struct SupportedCalendarComponent {
|
pub struct SupportedCalendarComponent {
|
||||||
#[xml(ty = "attr")]
|
#[xml(ty = "attr")]
|
||||||
@@ -36,6 +38,28 @@ impl From<SupportedCalendarComponentSet> for Vec<CalendarObjectType> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq, From, Into)]
|
||||||
|
pub struct SupportedCollation(#[xml(ty = "text")] pub TextCollation);
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, Eq)]
|
||||||
|
pub struct SupportedCollationSet(
|
||||||
|
#[xml(
|
||||||
|
ns = "rustical_dav::namespace::NS_CALDAV",
|
||||||
|
flatten,
|
||||||
|
rename = "supported-collation"
|
||||||
|
)]
|
||||||
|
pub Vec<SupportedCollation>,
|
||||||
|
);
|
||||||
|
|
||||||
|
impl Default for SupportedCollationSet {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self(vec![
|
||||||
|
SupportedCollation(TextCollation::AsciiCasemap),
|
||||||
|
SupportedCollation(TextCollation::Octet),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq)]
|
#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq)]
|
||||||
pub struct CalendarData {
|
pub struct CalendarData {
|
||||||
#[xml(ty = "attr")]
|
#[xml(ty = "attr")]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use super::prop::{SupportedCalendarComponentSet, SupportedCalendarData};
|
use super::prop::{SupportedCalendarComponentSet, SupportedCalendarData};
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
use crate::calendar::prop::ReportMethod;
|
use crate::calendar::prop::{ReportMethod, SupportedCollationSet};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use derive_more::derive::{From, Into};
|
use derive_more::derive::{From, Into};
|
||||||
use ical::IcalParser;
|
use ical::IcalParser;
|
||||||
@@ -39,6 +39,8 @@ pub enum CalendarProp {
|
|||||||
SupportedCalendarComponentSet(SupportedCalendarComponentSet),
|
SupportedCalendarComponentSet(SupportedCalendarComponentSet),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
||||||
SupportedCalendarData(SupportedCalendarData),
|
SupportedCalendarData(SupportedCalendarData),
|
||||||
|
#[xml(ns = "rustical_dav::namespace::NS_CALDAV", skip_deserializing)]
|
||||||
|
SupportedCollationSet(SupportedCollationSet),
|
||||||
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
#[xml(ns = "rustical_dav::namespace::NS_DAV")]
|
||||||
MaxResourceSize(i64),
|
MaxResourceSize(i64),
|
||||||
#[xml(skip_deserializing)]
|
#[xml(skip_deserializing)]
|
||||||
@@ -156,6 +158,9 @@ impl Resource for CalendarResource {
|
|||||||
CalendarPropName::SupportedCalendarData => {
|
CalendarPropName::SupportedCalendarData => {
|
||||||
CalendarProp::SupportedCalendarData(SupportedCalendarData::default())
|
CalendarProp::SupportedCalendarData(SupportedCalendarData::default())
|
||||||
}
|
}
|
||||||
|
CalendarPropName::SupportedCollationSet => {
|
||||||
|
CalendarProp::SupportedCollationSet(SupportedCollationSet::default())
|
||||||
|
}
|
||||||
CalendarPropName::MaxResourceSize => CalendarProp::MaxResourceSize(10_000_000),
|
CalendarPropName::MaxResourceSize => CalendarProp::MaxResourceSize(10_000_000),
|
||||||
CalendarPropName::SupportedReportSet => {
|
CalendarPropName::SupportedReportSet => {
|
||||||
CalendarProp::SupportedReportSet(SupportedReportSet::all())
|
CalendarProp::SupportedReportSet(SupportedReportSet::all())
|
||||||
@@ -244,6 +249,7 @@ impl Resource for CalendarResource {
|
|||||||
}
|
}
|
||||||
CalendarProp::TimezoneServiceSet(_)
|
CalendarProp::TimezoneServiceSet(_)
|
||||||
| CalendarProp::SupportedCalendarData(_)
|
| CalendarProp::SupportedCalendarData(_)
|
||||||
|
| CalendarProp::SupportedCollationSet(_)
|
||||||
| CalendarProp::MaxResourceSize(_)
|
| CalendarProp::MaxResourceSize(_)
|
||||||
| CalendarProp::SupportedReportSet(_)
|
| CalendarProp::SupportedReportSet(_)
|
||||||
| CalendarProp::Source(_)
|
| CalendarProp::Source(_)
|
||||||
@@ -283,6 +289,7 @@ impl Resource for CalendarResource {
|
|||||||
}
|
}
|
||||||
CalendarPropName::TimezoneServiceSet
|
CalendarPropName::TimezoneServiceSet
|
||||||
| CalendarPropName::SupportedCalendarData
|
| CalendarPropName::SupportedCalendarData
|
||||||
|
| CalendarPropName::SupportedCollationSet
|
||||||
| CalendarPropName::MaxResourceSize
|
| CalendarPropName::MaxResourceSize
|
||||||
| CalendarPropName::SupportedReportSet
|
| CalendarPropName::SupportedReportSet
|
||||||
| CalendarPropName::Source
|
| CalendarPropName::Source
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<calendar-order xmlns="http://apple.com/ns/ical/"/>
|
<calendar-order xmlns="http://apple.com/ns/ical/"/>
|
||||||
<supported-calendar-component-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
<supported-calendar-component-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
<supported-calendar-data xmlns="urn:ietf:params:xml:ns:caldav"/>
|
<supported-calendar-data xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
|
<supported-collation-set xmlns="urn:ietf:params:xml:ns:caldav"/>
|
||||||
<max-resource-size xmlns="DAV:"/>
|
<max-resource-size xmlns="DAV:"/>
|
||||||
<supported-report-set xmlns="DAV:"/>
|
<supported-report-set xmlns="DAV:"/>
|
||||||
<source xmlns="http://calendarserver.org/ns/"/>
|
<source xmlns="http://calendarserver.org/ns/"/>
|
||||||
@@ -160,6 +161,10 @@ END:VCALENDAR
|
|||||||
<CAL:supported-calendar-data>
|
<CAL:supported-calendar-data>
|
||||||
<CAL:calendar-data content-type="text/calendar" version="2.0"/>
|
<CAL:calendar-data content-type="text/calendar" version="2.0"/>
|
||||||
</CAL:supported-calendar-data>
|
</CAL:supported-calendar-data>
|
||||||
|
<CAL:supported-collation-set>
|
||||||
|
<CAL:supported-collation>i;ascii-casemap</CAL:supported-collation>
|
||||||
|
<CAL:supported-collation>i;octet</CAL:supported-collation>
|
||||||
|
</CAL:supported-collation-set>
|
||||||
<max-resource-size>10000000</max-resource-size>
|
<max-resource-size>10000000</max-resource-size>
|
||||||
<supported-report-set>
|
<supported-report-set>
|
||||||
<supported-report>
|
<supported-report>
|
||||||
|
|||||||
Reference in New Issue
Block a user