示例#1
0
static gboolean
update_objects (ECal *client, icalcomponent *icalcomp)
{
	icalcomponent_kind kind;
	icalcomponent *vcal;
	gboolean success = TRUE;

	kind = icalcomponent_isa (icalcomp);

	if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) {
		vcal = e_cal_util_new_top_level ();
		if (icalcomponent_get_method (icalcomp) == ICAL_METHOD_CANCEL)
			icalcomponent_set_method (vcal, ICAL_METHOD_CANCEL);
		else
			icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH);
		icalcomponent_add_component (vcal, icalcomponent_new_clone (icalcomp));
	} else if (kind == ICAL_VCALENDAR_COMPONENT) {
		vcal = icalcomponent_new_clone (icalcomp);
		if (!icalcomponent_get_first_property (vcal, ICAL_METHOD_PROPERTY))
			icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH);
	} else
		return FALSE;

	if (!e_cal_receive_objects (client, vcal, NULL))
		success = FALSE;

	icalcomponent_free (vcal);

	return success;
}
/** Get iTIP method.
 *
 * @param comp iCal component.
 *
 * @return Method.
 */
icalproperty_method icalcomponent_get_itip_method(icalcomponent *comp)
{
    icalproperty_method method = ICAL_METHOD_NONE;

    if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT)
    {
        icalcomponent *vevent = icalcomponent_get_first_component(comp, ICAL_VEVENT_COMPONENT);

        if (vevent && icalcomponent_get_first_property(vevent, ICAL_METHOD_PROPERTY))
        {
            method = icalcomponent_get_method(vevent);
        }
        else
        {
            method = icalcomponent_get_method(comp);
        }
    }
    else if (icalcomponent_isa(comp) == ICAL_VEVENT_COMPONENT)
    {
        method = icalcomponent_get_method(comp);
    }

    return method;
}
示例#3
0
static void
update_objects (ECalClient *cal_client,
                icalcomponent *icalcomp,
                GCancellable *cancellable,
                void (*done_cb) (gpointer user_data),
                gpointer user_data)
{
	icalcomponent_kind kind;
	icalcomponent *vcal;
	struct UpdateObjectsData *uod;

	kind = icalcomponent_isa (icalcomp);
	if (kind == ICAL_VTODO_COMPONENT || kind == ICAL_VEVENT_COMPONENT) {
		vcal = e_cal_util_new_top_level ();
		if (icalcomponent_get_method (icalcomp) == ICAL_METHOD_CANCEL)
			icalcomponent_set_method (vcal, ICAL_METHOD_CANCEL);
		else
			icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH);
		icalcomponent_add_component (vcal, icalcomponent_new_clone (icalcomp));
	} else if (kind == ICAL_VCALENDAR_COMPONENT) {
		vcal = icalcomponent_new_clone (icalcomp);
		if (!icalcomponent_get_first_property (vcal, ICAL_METHOD_PROPERTY))
			icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH);
	} else {
		if (done_cb)
			done_cb (user_data);
		return;
	}

	uod = g_new0 (struct UpdateObjectsData, 1);
	uod->done_cb = done_cb;
	uod->user_data = user_data;

	e_cal_client_receive_objects (cal_client, vcal, cancellable, receive_objects_ready_cb, uod);

	icalcomponent_free (vcal);

	return;
}