/** * e_cal_util_generate_alarms_for_list: * @comps: (element-type ECalComponent): List of #ECalComponent<!-- -->s * @start: Start time * @end: End time * @omit: Alarm types to omit * @comp_alarms: (out) (transfer full) (element-type ECalComponentAlarms): List * to be returned * @resolve_tzid: (closure user_data) (scope call): Callback for resolving * timezones * @user_data: (closure): Data to be passed to the resolve_tzid callback * @default_timezone: The timezone used to resolve DATE and floating DATE-TIME * values. * * Iterates through all the components in the @comps list and generates alarm * instances for them; putting them in the @comp_alarms list. * * Returns: the number of elements it added to the list */ gint e_cal_util_generate_alarms_for_list (GList *comps, time_t start, time_t end, ECalComponentAlarmAction *omit, GSList **comp_alarms, ECalRecurResolveTimezoneFn resolve_tzid, gpointer user_data, icaltimezone *default_timezone) { GList *l; gint n; n = 0; for (l = comps; l; l = l->next) { ECalComponent *comp; ECalComponentAlarms *alarms; comp = E_CAL_COMPONENT (l->data); alarms = e_cal_util_generate_alarms_for_comp ( comp, start, end, omit, resolve_tzid, user_data, default_timezone); if (alarms) { *comp_alarms = g_slist_prepend (*comp_alarms, alarms); n++; } } return n; }
/* (has-alarms-in-range? START END) * * START - time_t, start of the time range * END - time_t, end of the time range * * Returns: a boolean indicating whether the component has alarms in the given * time range or not. */ static ESExpResult * func_has_alarms_in_range (ESExp *esexp, gint argc, ESExpResult **argv, gpointer data) { time_t start, end; ESExpResult *result; icaltimezone *default_zone; ECalComponentAlarms *alarms; ECalComponentAlarmAction omit[] = {-1}; SearchContext *ctx = data; /* Check argument types */ if (argc != 2) { e_sexp_fatal_error ( esexp, _("\"%s\" expects two arguments"), "has-alarms-in-range"); return NULL; } if (argv[0]->type != ESEXP_RES_TIME) { e_sexp_fatal_error ( esexp, _("\"%s\" expects the first " "argument to be a time_t"), "has-alarms-in-range"); return NULL; } start = argv[0]->value.time; if (argv[1]->type != ESEXP_RES_TIME) { e_sexp_fatal_error ( esexp, _("\"%s\" expects the second " "argument to be a time_t"), "has-alarms-in-range"); return NULL; } end = argv[1]->value.time; /* See if the object has alarms in the given time range */ default_zone = icaltimezone_get_utc_timezone (); alarms = e_cal_util_generate_alarms_for_comp ( ctx->comp, start, end, omit, resolve_tzid, ctx, default_zone); result = e_sexp_result_new (esexp, ESEXP_RES_BOOL); if (alarms) { result->value.boolean = TRUE; e_cal_component_alarms_free (alarms); } else result->value.boolean = FALSE; return result; }