void dates_new_cb (GtkWidget *source, DatesData *d) { icalcomponent *comp; struct icalperiodtype period; if (!dates_view_get_selected_period (d->view, &period)) { struct icaltimetype date, now; /* Create a default time event */ date = *(dates_view_get_date (d->view)); now = icaltime_current_time_with_zone (date.zone); date.is_date = FALSE; now.is_date = FALSE; period.duration = icaldurationtype_null_duration (); period.duration.minutes = 0; /* New events default to starting at 9am */ period.duration.hours = 9; period.start = icaltime_add ( date, period.duration); /* NOTE: 11 is the magic number where we're viewing a * month or more. See dates_zoom_change. */ period.duration.hours = (d->zoom >= 11) ? 8 : 2; period.end = icaltime_add (period.start, period.duration); } comp = icalcomponent_new_vevent (); icalcomponent_set_dtstart (comp, period.start); icalcomponent_set_dtend (comp, period.end); icalcomponent_set_summary (comp, _("New event")); dates_new (d, comp, TRUE); }
/* From Seth Alves, <*****@*****.**> */ struct icaldurationtype icaldurationtype_from_int(int t) { struct icaldurationtype dur; int used = 0; dur = icaldurationtype_null_duration(); if(t < 0){ dur.is_neg = 1; t = -t; } if (t % (60 * 60 * 24 * 7) == 0) { dur.weeks = t / (60 * 60 * 24 * 7); } else { used += dur.weeks * (60 * 60 * 24 * 7); dur.days = (t - used) / (60 * 60 * 24); used += dur.days * (60 * 60 * 24); dur.hours = (t - used) / (60 * 60); used += dur.hours * (60 * 60); dur.minutes = (t - used) / (60); used += dur.minutes * (60); dur.seconds = (t - used); } return dur; }
static gboolean free_busy_instance (ECalComponent *comp, time_t instance_start, time_t instance_end, gpointer data) { icalcomponent *vfb = data; icalproperty *prop; icalparameter *param; struct icalperiodtype ipt; icaltimezone *utc_zone; utc_zone = icaltimezone_get_utc_timezone (); ipt.start = icaltime_from_timet_with_zone (instance_start, FALSE, utc_zone); ipt.end = icaltime_from_timet_with_zone (instance_end, FALSE, utc_zone); ipt.duration = icaldurationtype_null_duration (); /* add busy information to the vfb component */ prop = icalproperty_new (ICAL_FREEBUSY_PROPERTY); icalproperty_set_freebusy (prop, ipt); param = icalparameter_new_fbtype (ICAL_FBTYPE_BUSY); icalproperty_add_parameter (prop, param); icalcomponent_add_property (vfb, prop); return TRUE; }
struct icalperiodtype icalperiodtype_null_period(void) { struct icalperiodtype p; p.start = icaltime_null_time(); p.end = icaltime_null_time(); p.duration = icaldurationtype_null_duration(); return p; }
icalcomponent *icalspanlist_as_vfreebusy(icalspanlist* sl, const char* organizer, const char* attendee) { icalcomponent *comp; icalproperty *p; struct icaltimetype atime = icaltime_from_timet( time(0),0); pvl_elem itr; icaltimezone *utc_zone; icalparameter *param; if (!attendee) { icalerror_set_errno(ICAL_USAGE_ERROR); return 0; } utc_zone = icaltimezone_get_utc_timezone (); comp = icalcomponent_new_vfreebusy(); icalcomponent_add_property(comp, icalproperty_new_dtstart(sl->start)); icalcomponent_add_property(comp, icalproperty_new_dtend(sl->end)); icalcomponent_add_property(comp, icalproperty_new_dtstamp(atime)); if (organizer) { icalcomponent_add_property(comp, icalproperty_new_organizer(organizer)); } icalcomponent_add_property(comp, icalproperty_new_attendee(attendee)); /* now add the freebusy sections.. */ for( itr = pvl_head(sl->spans); itr != 0; itr = pvl_next(itr)) { struct icalperiodtype period; struct icaltime_span *s = (struct icaltime_span*)pvl_data(itr); if (s->is_busy == 1) { period.start = icaltime_from_timet_with_zone (s->start, 0, utc_zone); period.end = icaltime_from_timet_with_zone (s->end, 0, utc_zone); period.duration = icaldurationtype_null_duration(); p = icalproperty_new_freebusy(period); param = icalparameter_new_fbtype(ICAL_FBTYPE_BUSY); icalproperty_add_parameter(p, param); icalcomponent_add_property(comp, p); } } return comp; }
void dates_event_moved_cb (DatesView *view, ECalComponent *comp, DatesData *d) { ECalComponentDateTime start, end; struct icaldurationtype duration = icaldurationtype_null_duration (); if (d->comp) g_object_unref (d->comp); d->comp = g_object_ref (comp); e_cal_component_get_dtstart (d->comp, &start); if (!start.value->is_date) { e_cal_component_get_dtend (d->comp, &end); duration = icaltime_subtract (*end.value, *start.value); *end.value = icaltime_add (*start.value, duration); e_cal_component_set_dtstart (d->comp, &start); e_cal_component_set_dtend (d->comp, &end); e_cal_component_free_datetime (&end); } e_cal_component_free_datetime (&start); dates_commit_event_cb (NULL, d, CALOBJ_MOD_THIS); }
Duration() : icaldurationtype( icaldurationtype_null_duration() ) { }