/** * calendar_config_get_hide_completed_tasks_sexp: * * @get_completed: Whether to form subexpression that * gets completed or not completed tasks. * Returns the subexpression to use to filter out completed tasks according * to the config settings. The returned sexp should be freed. **/ char* calendar_config_get_hide_completed_tasks_sexp (gboolean get_completed) { char *sexp = NULL; if (calendar_config_get_hide_completed_tasks ()) { CalUnits units; gint value; units = calendar_config_get_hide_completed_tasks_units (); value = calendar_config_get_hide_completed_tasks_value (); if (value == 0) { /* If the value is 0, we want to hide completed tasks immediately, so we filter out all complete/incomplete tasks.*/ if (!get_completed) sexp = g_strdup ("(not is-completed?)"); else sexp = g_strdup ("(is-completed?)"); } else { char *isodate; icaltimezone *zone; struct icaltimetype tt; time_t t; /* Get the current time, and subtract the appropriate number of days/hours/minutes. */ zone = calendar_config_get_icaltimezone (); tt = icaltime_current_time_with_zone (zone); switch (units) { case CAL_DAYS: icaltime_adjust (&tt, -value, 0, 0, 0); break; case CAL_HOURS: icaltime_adjust (&tt, 0, -value, 0, 0); break; case CAL_MINUTES: icaltime_adjust (&tt, 0, 0, -value, 0); break; default: g_return_val_if_reached (NULL); } t = icaltime_as_timet_with_zone (tt, zone); /* Convert the time to an ISO date string, and build the query sub-expression. */ isodate = isodate_from_time_t (t); if (!get_completed) sexp = g_strdup_printf ("(not (completed-before? (make-time \"%s\")))", isodate); else sexp = g_strdup_printf ("(completed-before? (make-time \"%s\"))", isodate); g_free (isodate); } } return sexp; }
/* Returns the current time, for the ECalendarItem. */ static struct tm get_current_time (ECalendarItem *calitem, gpointer data) { icaltimezone *zone; struct tm tmp_tm = { 0 }; struct icaltimetype tt; /* Get the current timezone. */ zone = calendar_config_get_icaltimezone (); tt = icaltime_from_timet_with_zone (time (NULL), FALSE, zone); /* Now copy it to the struct tm and return it. */ tmp_tm.tm_year = tt.year - 1900; tmp_tm.tm_mon = tt.month - 1; tmp_tm.tm_mday = tt.day; tmp_tm.tm_hour = tt.hour; tmp_tm.tm_min = tt.minute; tmp_tm.tm_sec = tt.second; tmp_tm.tm_isdst = -1; return tmp_tm; }
void calendar_config_select_day_second_zone (void) { icaltimezone *zone = NULL; ETimezoneDialog *tzdlg; GtkWidget *dialog; gchar *second_location; second_location = calendar_config_get_day_second_zone (); if (second_location && *second_location) zone = icaltimezone_get_builtin_timezone (second_location); g_free (second_location); if (!zone) zone = calendar_config_get_icaltimezone (); tzdlg = e_timezone_dialog_new (); e_timezone_dialog_set_timezone (tzdlg, zone); dialog = e_timezone_dialog_get_toplevel (tzdlg); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { const gchar *location = NULL; zone = e_timezone_dialog_get_timezone (tzdlg); if (zone == icaltimezone_get_utc_timezone ()) { location = "UTC"; } else if (zone) { location = icaltimezone_get_location (zone); } calendar_config_set_day_second_zone (location); } g_object_unref (tzdlg); }
void e_sendoptions_utils_fill_component (ESendOptionsDialog *sod, ECalComponent *comp) { int i = 1; icalproperty *prop; icalcomponent *icalcomp; ESendOptionsGeneral *gopts; ESendOptionsStatusTracking *sopts; gopts = sod->data->gopts; sopts = sod->data->sopts; e_cal_component_set_sequence (comp, &i); icalcomp = e_cal_component_get_icalcomponent (comp); if (e_sendoptions_get_need_general_options (sod)) { prop = icalproperty_new_x ((const char *) g_strdup_printf ("%d", gopts->priority)); icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-PRIORITY"); icalcomponent_add_property (icalcomp, prop); if (gopts->reply_enabled) { if (gopts->reply_convenient) prop = icalproperty_new_x ("convenient"); else prop = icalproperty_new_x ((const char *) g_strdup_printf ( "%d", gopts->reply_within)); icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-REPLY"); icalcomponent_add_property (icalcomp, prop); } if (gopts->expiration_enabled && gopts->expire_after) { prop = icalproperty_new_x ((const char *) g_strdup_printf ( "%d", gopts->expire_after)); icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-EXPIRE"); icalcomponent_add_property (icalcomp, prop); } if (gopts->delay_enabled) { struct icaltimetype temp; char *str; icaltimezone *zone = calendar_config_get_icaltimezone (); temp = icaltime_from_timet_with_zone (gopts->delay_until, FALSE, zone); str = icaltime_as_ical_string (temp); prop = icalproperty_new_x (str); g_free (str); icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-DELAY"); icalcomponent_add_property (icalcomp, prop); } } if (sopts->tracking_enabled) prop = icalproperty_new_x ((const char *) g_strdup_printf ( "%d", sopts->track_when)); else prop = icalproperty_new_x ("0"); icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-TRACKINFO"); icalcomponent_add_property (icalcomp, prop); prop = icalproperty_new_x ((const char *) g_strdup_printf ("%d", sopts->opened)); icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-OPENED"); icalcomponent_add_property (icalcomp, prop); prop = icalproperty_new_x ((const char *) g_strdup_printf ("%d", sopts->accepted)); icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-ACCEPTED"); icalcomponent_add_property (icalcomp, prop); prop = icalproperty_new_x ((const char *) g_strdup_printf ("%d", sopts->declined)); icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-DECLINED"); icalcomponent_add_property (icalcomp, prop); prop = icalproperty_new_x ((const char *) g_strdup_printf ("%d", sopts->completed)); icalproperty_set_x_name (prop, "X-EVOLUTION-OPTIONS-COMPLETED"); icalcomponent_add_property (icalcomp, prop); }