CardDAV working with Thunderbird and Apple Contacts
This commit is contained in:
@@ -16,6 +16,10 @@ pub struct DavConfig {
|
||||
pub max_changes: usize,
|
||||
pub max_match_results: usize,
|
||||
pub max_vcard_size: usize,
|
||||
pub default_calendar_name: Option<String>,
|
||||
pub default_addressbook_name: Option<String>,
|
||||
pub default_calendar_display_name: Option<String>,
|
||||
pub default_addressbook_display_name: Option<String>,
|
||||
}
|
||||
|
||||
impl DavConfig {
|
||||
@@ -41,6 +45,24 @@ impl DavConfig {
|
||||
max_vcard_size: config
|
||||
.property("dav.limits.size.vcard")
|
||||
.unwrap_or(512 * 1024),
|
||||
default_calendar_name: config
|
||||
.property_or_default::<Option<String>>("dav.default.calendar.name", "default")
|
||||
.unwrap_or_default(),
|
||||
default_addressbook_name: config
|
||||
.property_or_default::<Option<String>>("dav.default.addressbook.name", "default")
|
||||
.unwrap_or_default(),
|
||||
default_calendar_display_name: config
|
||||
.property_or_default::<Option<String>>(
|
||||
"dav.default.calendar.display-name",
|
||||
"Default Calendar",
|
||||
)
|
||||
.unwrap_or_default(),
|
||||
default_addressbook_display_name: config
|
||||
.property_or_default::<Option<String>>(
|
||||
"dav.default.addressbook.display-name",
|
||||
"Default Address Book",
|
||||
)
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +242,7 @@ pub struct DavResourceId {
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct DavResources {
|
||||
pub base_path: String,
|
||||
pub paths: IdBimap<DavResource>,
|
||||
pub size: u64,
|
||||
pub modseq: Option<u64>,
|
||||
@@ -479,7 +480,7 @@ impl DavResources {
|
||||
self.paths.iter().filter(move |item| {
|
||||
item.name
|
||||
.strip_prefix(&prefix)
|
||||
.is_some_and(|name| name.as_bytes().iter().filter(|&&c| c == b'/').count() <= depth)
|
||||
.is_some_and(|name| name.as_bytes().iter().filter(|&&c| c == b'/').count() < depth)
|
||||
|| item.name == search_path
|
||||
})
|
||||
}
|
||||
@@ -503,6 +504,22 @@ impl DavResources {
|
||||
let prefix = format!("{ancestor}/");
|
||||
descendant.starts_with(&prefix) || descendant == ancestor
|
||||
}
|
||||
|
||||
pub fn format_resource(&self, resource: &DavResource) -> String {
|
||||
if resource.is_container {
|
||||
format!("{}{}/", self.base_path, resource.name)
|
||||
} else {
|
||||
format!("{}{}", self.base_path, resource.name)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format_collection(&self, name: &str) -> String {
|
||||
format!("{}{name}/", self.base_path)
|
||||
}
|
||||
|
||||
pub fn format_item(&self, name: &str) -> String {
|
||||
format!("{}{}", self.base_path, name)
|
||||
}
|
||||
}
|
||||
|
||||
impl IdBimapItem for DavResource {
|
||||
|
||||
Reference in New Issue
Block a user