static icalproperty * ical_property_add_x_property_value(icalcomponent *parent, const char *propname, const char *value) { icalproperty *prop; icalvalue *icalText; /* Sanity checks */ if (!parent) return NULL; if (!propname) return NULL; if (!value) return NULL; icalText = icalvalue_new_text(value); prop = icalproperty_new_x(icalvalue_as_ical_string(icalText)); icalvalue_free(icalText); icalproperty_set_x_name(prop, propname); icalcomponent_add_property(parent, prop); return prop; }
NS_IMETHODIMP calIcalProperty::SetValue(const nsACString &str) { icalvalue_kind kind = icalproperty_kind_to_value_kind(icalproperty_isa(mProperty)); if (kind == ICAL_TEXT_VALUE) { icalvalue *v = icalvalue_new_text(PromiseFlatCString(str).get()); icalproperty_set_value(mProperty, v); } else if (kind == ICAL_X_VALUE) { icalvalue *v = icalvalue_new_x(PromiseFlatCString(str).get()); icalproperty_set_value(mProperty, v); } else if (kind == ICAL_ATTACH_VALUE) { const char *strdata = PromiseFlatCString(str).get(); icalattach *v = icalattach_new_from_data(strdata, nullptr, nullptr); icalproperty_set_attach(mProperty, v); } else { icalproperty_set_value_from_string(mProperty, PromiseFlatCString(str).get(), icalvalue_kind_to_string(kind)); } return NS_OK; }