summaryrefslogtreecommitdiffstats
path: root/src/icalwrap
diff options
context:
space:
mode:
authorNora <nora.widdecke@tu-bs.de>2019-01-17 23:42:20 +0100
committerNora <nora.widdecke@tu-bs.de>2019-01-18 23:09:20 +0100
commitdb3f62f570c874056846b7f349e700dc1280837d (patch)
treeee9e3b444762cf3b30a6210cab6ca9d1b40ab207 /src/icalwrap
parentb70837e9e13a654ad450a5b0c840f918c711c50e (diff)
move remove_property to icalcomponent
Diffstat (limited to 'src/icalwrap')
-rw-r--r--src/icalwrap/icalcomponent.rs23
-rw-r--r--src/icalwrap/icalvcalendar.rs19
2 files changed, 23 insertions, 19 deletions
diff --git a/src/icalwrap/icalcomponent.rs b/src/icalwrap/icalcomponent.rs
index e1a315d..43aeacc 100644
--- a/src/icalwrap/icalcomponent.rs
+++ b/src/icalwrap/icalcomponent.rs
@@ -50,8 +50,29 @@ pub trait IcalComponent {
};
self.get_property(property_kind)
}
-}
+ unsafe fn remove_property_all(&self, kind: ical::icalproperty_kind) -> usize {
+
+ unsafe fn remove_property_inner(comp: *mut ical::icalcomponent, kind: ical::icalproperty_kind) -> usize {
+ let mut count = 0;
+ let mut prop = ical::icalcomponent_get_first_property(comp, kind);
+ while !prop.is_null() {
+ ical::icalcomponent_remove_property(comp, prop);
+ count += 1;
+ prop = ical::icalcomponent_get_current_property(comp);
+ }
+ let mut inner_comp = ical::icalcomponent_get_first_component(comp, ical::icalcomponent_kind_ICAL_ANY_COMPONENT);
+ while !inner_comp.is_null() {
+ count += remove_property_inner(inner_comp, kind);
+ inner_comp = ical::icalcomponent_get_next_component(comp, ical::icalcomponent_kind_ICAL_ANY_COMPONENT)
+ }
+ count
+ }
+
+ let comp = self.get_ptr();
+ remove_property_inner(comp, kind)
+ }
+}
#[cfg(test)]
mod tests {
diff --git a/src/icalwrap/icalvcalendar.rs b/src/icalwrap/icalvcalendar.rs
index 69767c6..6e2f538 100644
--- a/src/icalwrap/icalvcalendar.rs
+++ b/src/icalwrap/icalvcalendar.rs
@@ -142,28 +142,11 @@ impl IcalVCalendar {
};
let count = unsafe {
- IcalVCalendar::remove_property(self.get_ptr(), property_kind)
+ IcalComponent::remove_property_all(&self, property_kind)
};
(self, count)
}
- unsafe fn remove_property(comp: *mut ical::icalcomponent, kind: ical::icalproperty_kind) -> usize {
- //let kind = ical::icalproperty_kind_ICAL_ANY_PROPERTY;
- let mut count = 0;
- let mut prop = ical::icalcomponent_get_first_property(comp, kind);
- while !prop.is_null() {
- ical::icalcomponent_remove_property(comp, prop);
- count += 1;
- prop = ical::icalcomponent_get_current_property(comp);
- }
- let mut inner_comp = ical::icalcomponent_get_first_component(comp, ical::icalcomponent_kind_ICAL_ANY_COMPONENT);
- while !inner_comp.is_null() {
- count += IcalVCalendar::remove_property(inner_comp, kind);
- inner_comp = ical::icalcomponent_get_next_component(comp, ical::icalcomponent_kind_ICAL_ANY_COMPONENT)
- }
- count
- }
-
pub fn with_keep_uid(self, uid_to_keep: &str) -> Self {
unsafe {
ical::icalcomponent_get_first_component(