Example #1
0
static icalcomponent *icalmessage_new_reply_base(icalcomponent *c,
                                                 const char *user, const char *msg)
{
    icalproperty *attendee;
    char tmp[45];

    icalcomponent *reply =
        icalcomponent_vanew(
            ICAL_VCALENDAR_COMPONENT, icalproperty_new_method(ICAL_METHOD_REPLY),
            icalcomponent_vanew(
                ICAL_VEVENT_COMPONENT,
                icalproperty_new_dtstamp(icaltime_from_timet_with_zone(time(0), 0, NULL)),
                0),
            0);

    icalcomponent *inner = icalmessage_get_inner(reply);

    icalerror_check_arg_rz(c, "c");

    icalmessage_copy_properties(reply, c, ICAL_UID_PROPERTY);
    icalmessage_copy_properties(reply, c, ICAL_ORGANIZER_PROPERTY);
    icalmessage_copy_properties(reply, c, ICAL_RECURRENCEID_PROPERTY);
    icalmessage_copy_properties(reply, c, ICAL_SUMMARY_PROPERTY);
    icalmessage_copy_properties(reply, c, ICAL_SEQUENCE_PROPERTY);

    icalcomponent_set_dtstamp(reply, icaltime_from_timet_with_zone(time(0), 0, NULL));

    if (msg != 0) {
        icalcomponent_add_property(inner, icalproperty_new_comment(msg));
    }

    /* Copy this user's attendee property */

    attendee = icalmessage_find_attendee(c, user);

    if (attendee == 0) {
        icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);
        icalcomponent_free(reply);
        return 0;
    }

    icalcomponent_add_property(inner, icalproperty_new_clone(attendee));

    /* Add PRODID and VERSION */

    icalcomponent_add_property(reply, icalproperty_new_version("2.0"));

    snprintf(tmp, sizeof(tmp), "-//SoftwareStudio//NONSGML %s %s //EN", ICAL_PACKAGE, ICAL_VERSION);

    icalcomponent_add_property(reply, icalproperty_new_prodid(tmp));

    return reply;
}
Example #2
0
/**
 * e_cal_util_new_component:
 * @kind: Kind of the component to create.
 *
 * Creates a new #icalcomponent of the specified kind.
 *
 * Returns: the newly created component.
 */
icalcomponent *
e_cal_util_new_component (icalcomponent_kind kind)
{
	icalcomponent *comp;
	struct icaltimetype dtstamp;
	gchar *uid;

	comp = icalcomponent_new (kind);
	uid = e_cal_component_gen_uid ();
	icalcomponent_set_uid (comp, uid);
	g_free (uid);
	dtstamp = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
	icalcomponent_set_dtstamp (comp, dtstamp);

	return comp;
}