gchar * eab_book_and_contact_list_to_string (EBookClient *book_client, const GSList *contacts) { gchar *s0, *s1; s0 = eab_contact_list_to_string (contacts); if (!s0) s0 = g_strdup (""); if (book_client != NULL) { EClient *client; ESource *source; const gchar *uid; client = E_CLIENT (book_client); source = e_client_get_source (client); uid = e_source_get_uid (source); s1 = g_strconcat ("Book: ", uid, "\r\n", s0, NULL); } else s1 = g_strdup (s0); g_free (s0); return s1; }
static void action_task_new_cb (GtkAction *action, ETaskShellView *task_shell_view) { EShellView *shell_view; EShellWindow *shell_window; ETaskShellContent *task_shell_content; ETaskTable *task_table; EClient *client = NULL; GSList *list; shell_view = E_SHELL_VIEW (task_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); task_shell_content = task_shell_view->priv->task_shell_content; task_table = e_task_shell_content_get_task_table (task_shell_content); list = e_task_table_get_selected (task_table); if (list) { ECalModelComponent *comp_data; comp_data = list->data; client = g_object_ref (comp_data->client); g_slist_free (list); } e_cal_ops_new_component_editor (shell_window, E_CAL_CLIENT_SOURCE_TYPE_TASKS, client ? e_source_get_uid (e_client_get_source (client)) : NULL, FALSE); g_clear_object (&client); }
static void calendar_appointment_init (CalendarAppointment *appointment, icalcomponent *ical, ECalClient *cal, icaltimezone *default_zone) { const char *source_uid; appointment->uid = get_ical_uid (ical); appointment->rid = get_ical_rid (ical); appointment->backend_name = get_source_backend_name (cal); appointment->summary = get_ical_summary (ical); appointment->description = get_ical_description (ical); appointment->color_string = get_source_color (cal); appointment->start_time = get_ical_start_time (ical, default_zone); appointment->end_time = get_ical_end_time (ical, default_zone); appointment->is_all_day = get_ical_is_all_day (ical, appointment->start_time, default_zone); /* While the UID is usually enough to identify an event, only the triple * of (source,UID,RID) is fully unambiguous; neither may contain '\n', * so we can safely use it to create a unique ID from the triple */ source_uid = e_source_get_uid (e_client_get_source (E_CLIENT (cal))); appointment->id = g_strdup_printf ("%s\n%s\n%s", source_uid, appointment->uid, appointment->rid ? appointment->rid : ""); }
static void gcal_week_view_component_removed (ECalDataModelSubscriber *subscriber, ECalClient *client, const gchar *uid, const gchar *rid) { GcalWeekView *self = GCAL_WEEK_VIEW (subscriber); ESource *source; gchar *uuid; GCAL_ENTRY; source = e_client_get_source (E_CLIENT (client)); if (rid != NULL) uuid = g_strdup_printf ("%s:%s:%s", e_source_get_uid (source), uid, rid); else uuid = g_strdup_printf ("%s:%s", e_source_get_uid (source), uid); gcal_week_header_remove_event (GCAL_WEEK_HEADER (self->header), uuid); gcal_week_grid_remove_event (GCAL_WEEK_GRID (self->week_grid), uuid); g_free (uuid); GCAL_EXIT; }
static void action_calendar_taskpad_new_cb (GtkAction *action, ECalShellView *cal_shell_view) { EShellView *shell_view; EShellWindow *shell_window; ECalShellContent *cal_shell_content; ECalModelComponent *comp_data; ETaskTable *task_table; GSList *list; shell_view = E_SHELL_VIEW (cal_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); cal_shell_content = cal_shell_view->priv->cal_shell_content; task_table = e_cal_shell_content_get_task_table (cal_shell_content); list = e_task_table_get_selected (task_table); g_return_if_fail (list != NULL); comp_data = list->data; g_slist_free (list); e_cal_ops_new_component_editor (shell_window, E_CAL_CLIENT_SOURCE_TYPE_TASKS, e_source_get_uid (e_client_get_source (E_CLIENT (comp_data->client))), FALSE); }
static gchar * get_source_backend_name (ECalClient *esource) { ESource *source; ECalClientSourceType source_type; ESourceBackend *extension; const gchar *extension_name; g_return_val_if_fail (E_IS_CAL_CLIENT (esource), NULL); source = e_client_get_source (E_CLIENT (esource)); source_type = e_cal_client_get_source_type (esource); switch (source_type) { case E_CAL_CLIENT_SOURCE_TYPE_EVENTS: extension_name = E_SOURCE_EXTENSION_CALENDAR; break; case E_CAL_CLIENT_SOURCE_TYPE_TASKS: extension_name = E_SOURCE_EXTENSION_TASK_LIST; break; default: g_return_val_if_reached (NULL); } extension = e_source_get_extension (source, extension_name); return e_source_backend_dup_backend_name (extension); }
static ECompEditor * get_component_editor (EShell *shell, ECalClient *client, ECalComponent *comp, gboolean is_new, GError **error) { ECompEditorFlags flags = 0; ECompEditor *comp_editor = NULL; ESourceRegistry *registry; g_return_val_if_fail (E_IS_SHELL (shell), NULL); g_return_val_if_fail (E_IS_CAL_CLIENT (client), NULL); g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL); registry = e_shell_get_registry (shell); if (is_new) { flags |= E_COMP_EDITOR_FLAG_IS_NEW; } else { comp_editor = e_comp_editor_find_existing_for ( e_client_get_source (E_CLIENT (client)), e_cal_component_get_icalcomponent (comp)); } if (!comp_editor) { if (itip_organizer_is_user (registry, comp, client)) flags |= E_COMP_EDITOR_FLAG_ORGANIZER_IS_USER; if (e_cal_component_has_attendees (comp)) flags |= E_COMP_EDITOR_FLAG_WITH_ATTENDEES; comp_editor = e_comp_editor_open_for_component (NULL, shell, e_client_get_source (E_CLIENT (client)), e_cal_component_get_icalcomponent (comp), flags); if (comp_editor) { /* request save for new events */ e_comp_editor_set_changed (comp_editor, is_new); } } return comp_editor; }
static void backend_died_cb (EClient *client, CalendarSourceData *source_data) { ESource *source; const char *display_name; source = e_client_get_source (client); display_name = e_source_get_display_name (source); g_warning ("The calendar backend for '%s' has crashed.", display_name); g_hash_table_remove (source_data->clients, source); if (source_data->timeout_id != 0) { g_source_remove (source_data->timeout_id); source_data->timeout_id = 0; } source_data->timeout_id = g_timeout_add_seconds (2, backend_restart, source_data); }
/* ECalDataModelSubscriber implementation */ static void gcal_week_view_component_added (ECalDataModelSubscriber *subscriber, ECalClient *client, ECalComponent *comp) { GcalWeekView *self = GCAL_WEEK_VIEW (subscriber); GcalEvent *event; GCAL_ENTRY; event = gcal_event_new (e_client_get_source (E_CLIENT (client)), comp, NULL); if (gcal_event_is_multiday (event) || gcal_event_get_all_day (event)) gcal_week_header_add_event (GCAL_WEEK_HEADER (self->header), event); else gcal_week_grid_add_event (GCAL_WEEK_GRID (self->week_grid), event); GCAL_EXIT; }
static void address_book_refresh_done_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { EClient *client; ESource *source; EActivity *activity; EAlertSink *alert_sink; const gchar *display_name; GError *local_error = NULL; g_return_if_fail (E_IS_CLIENT (source_object)); client = E_CLIENT (source_object); source = e_client_get_source (client); activity = user_data; e_client_refresh_finish (client, result, &local_error); alert_sink = e_activity_get_alert_sink (activity); display_name = e_source_get_display_name (source); if (e_activity_handle_cancellation (activity, local_error)) { /* nothing to do */ } else if (local_error != NULL) { e_alert_submit ( alert_sink, "addressbook:refresh-error", display_name, local_error->message, NULL); } else { e_activity_set_state (activity, E_ACTIVITY_COMPLETED); } g_clear_object (&activity); g_clear_error (&local_error); }
static void gcal_year_view_component_changed (ECalDataModelSubscriber *subscriber, ECalClient *client, ECalComponent *comp) { GcalYearViewPrivate *priv = GCAL_YEAR_VIEW (subscriber)->priv; GList *children, *l; gchar *uuid; uuid = get_uuid_from_component (e_client_get_source (E_CLIENT (client)), comp); children = gtk_container_get_children (GTK_CONTAINER (priv->events_sidebar)); for (l = children; l != NULL; l = g_list_next (l)) { GcalEventWidget *child_widget = GCAL_EVENT_WIDGET (gtk_bin_get_child (GTK_BIN (l->data))); if (child_widget != NULL && g_strcmp0 (uuid, gcal_event_widget_peek_uuid (child_widget)) == 0) gtk_widget_destroy (GTK_WIDGET (l->data)); } g_list_free (children); g_free (uuid); gcal_year_view_component_added (subscriber, client, comp); }
static void gcal_year_view_component_removed (ECalDataModelSubscriber *subscriber, ECalClient *client, const gchar *uid, const gchar *rid) { GcalYearViewPrivate *priv = GCAL_YEAR_VIEW (subscriber)->priv; GList *children, *l; ESource *source; gchar *uuid; gboolean update_sidebar_needed = FALSE; source = e_client_get_source (E_CLIENT (client)); if (rid != NULL) uuid = g_strdup_printf ("%s:%s:%s", e_source_get_uid (source), uid, rid); else uuid = g_strdup_printf ("%s:%s", e_source_get_uid (source), uid); children = gtk_container_get_children (GTK_CONTAINER (priv->events_sidebar)); for (l = children; l != NULL; l = g_list_next (l)) { GcalEventWidget *child_widget = GCAL_EVENT_WIDGET (gtk_bin_get_child (GTK_BIN (l->data))); if (child_widget != NULL && g_strcmp0 (uuid, gcal_event_widget_peek_uuid (child_widget)) == 0) { if (g_list_length (children) == 1) update_sidebar_needed = TRUE; gtk_widget_destroy (GTK_WIDGET (l->data)); } } g_list_free (children); g_free (uuid); if (update_sidebar_needed) { update_no_events_page (GCAL_YEAR_VIEW (subscriber)); gtk_stack_set_visible_child_name (GTK_STACK (priv->navigator_stack), "no-events"); } }
static void memo_shell_content_table_foreach_cb (gint model_row, gpointer user_data) { ECalModelComponent *comp_data; icalcomponent *clone; icalcomponent *vcal; gchar *string; struct { ECalModel *model; GSList *list; } *foreach_data = user_data; comp_data = e_cal_model_get_component_at ( foreach_data->model, model_row); vcal = e_cal_util_new_top_level (); clone = icalcomponent_new_clone (comp_data->icalcomp); e_cal_util_add_timezones_from_component (vcal, comp_data->icalcomp); icalcomponent_add_component (vcal, clone); /* String is owned by libical; do not free. */ string = icalcomponent_as_ical_string (vcal); if (string != NULL) { ESource *source; const gchar *source_uid; source = e_client_get_source (E_CLIENT (comp_data->client)); source_uid = e_source_get_uid (source); foreach_data->list = g_slist_prepend ( foreach_data->list, g_strdup_printf ("%s\n%s", source_uid, string)); } icalcomponent_free (vcal); }
static void task_shell_view_backend_error_cb (EClientCache *client_cache, EClient *client, EAlert *alert, ETaskShellView *task_shell_view) { ETaskShellContent *task_shell_content; ESource *source; const gchar *extension_name; task_shell_content = task_shell_view->priv->task_shell_content; source = e_client_get_source (client); extension_name = E_SOURCE_EXTENSION_TASK_LIST; /* Only submit alerts from task list backends. */ if (e_source_has_extension (source, extension_name)) { EAlertSink *alert_sink; alert_sink = E_ALERT_SINK (task_shell_content); e_alert_sink_submit_alert (alert_sink, alert); } }
static void cal_shell_view_backend_error_cb (EClientCache *client_cache, EClient *client, EAlert *alert, ECalShellView *cal_shell_view) { ECalShellContent *cal_shell_content; ESource *source; const gchar *extension_name; cal_shell_content = cal_shell_view->priv->cal_shell_content; source = e_client_get_source (client); extension_name = E_SOURCE_EXTENSION_CALENDAR; /* Only submit alerts from calendar backends. */ if (e_source_has_extension (source, extension_name)) { EAlertSink *alert_sink; alert_sink = E_ALERT_SINK (cal_shell_content); e_alert_sink_submit_alert (alert_sink, alert); } }
static void gcal_week_view_component_modified (ECalDataModelSubscriber *subscriber, ECalClient *client, ECalComponent *comp) { GcalWeekView *self = GCAL_WEEK_VIEW (subscriber); GcalWeekHeader *header; gchar *uuid; GCAL_ENTRY; header = GCAL_WEEK_HEADER (self->header); uuid = get_uuid_from_component (e_client_get_source (E_CLIENT (client)), comp); gcal_week_header_remove_event (header, uuid); gcal_week_grid_remove_event (GCAL_WEEK_GRID (self->week_grid), uuid); gcal_week_view_component_added (subscriber, client, comp); g_free (uuid); GCAL_EXIT; }
static void gcal_year_view_component_added (ECalDataModelSubscriber *subscriber, ECalClient *client, ECalComponent *comp) { GcalYearViewPrivate *priv; GcalYearView *year_view = GCAL_YEAR_VIEW (subscriber); GcalEventData *data; GList **days_widgets_array; GList *l; gint i, days_span; ECalComponentDateTime date; time_t event_start, event_end, range_start, range_end; icaltimezone *zone; priv = year_view->priv; update_selected_dates_from_button_data (year_view); days_span = icaltime_day_of_year(*(priv->end_selected_date)) - icaltime_day_of_year(*(priv->start_selected_date)) + 1; days_widgets_array = g_new0 (GList*, days_span); data = g_new0 (GcalEventData, 1); data->source = e_client_get_source (E_CLIENT (client)); data->event_component = e_cal_component_clone (comp); /* check if event belongs to range */ zone = gcal_manager_get_system_timezone (priv->manager); range_start = icaltime_as_timet_with_zone (*(priv->start_selected_date), zone); range_end = icaltime_as_timet_with_zone (*(priv->end_selected_date), zone); e_cal_component_get_dtstart (comp, &date); event_start = icaltime_as_timet_with_zone (*(date.value), date.value->zone != NULL ? date.value->zone : zone); e_cal_component_free_datetime (&date); e_cal_component_get_dtend (comp, &date); if (date.value != NULL) event_end = icaltime_as_timet_with_zone (*(date.value), date.value->zone != NULL ? date.value->zone : zone); else event_end = event_start; e_cal_component_free_datetime (&date); if (!((event_start <= range_start && event_end >= range_end) || (event_start >= range_start && event_end <= range_end) || (event_start >= range_start && event_start <= range_end) || (event_end >= range_start && event_end <= range_end))) { g_object_unref (data->event_component); goto out; } add_event_to_day_array (year_view, data, days_widgets_array, days_span); gtk_stack_set_visible_child_name (GTK_STACK (priv->navigator_stack), "events-list"); for (i = 0; i < days_span; i++) { GList *current_day = days_widgets_array[i]; for (l = current_day; l != NULL; l = g_list_next (l)) { GtkWidget *child_widget = l->data; gtk_widget_show (child_widget); g_signal_connect (child_widget, "activate", G_CALLBACK (event_activated), year_view); g_object_set_data (G_OBJECT (child_widget), "shift", GINT_TO_POINTER (i)); gtk_container_add (GTK_CONTAINER (priv->events_sidebar), child_widget); } g_list_free (current_day); } out: g_free (data); g_free (days_widgets_array); }
/* Stores information about actually shown component and * returns whether component in the preview changed */ static gboolean update_comp_info (ECalComponentPreview *preview, ECalClient *client, ECalComponent *comp, icaltimezone *zone, gboolean use_24_hour_format) { ECalComponentPreviewPrivate *priv; gboolean changed; g_return_val_if_fail (preview != NULL, TRUE); g_return_val_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview), TRUE); priv = preview->priv; if (!E_IS_CAL_COMPONENT (comp) || !E_IS_CAL_CLIENT (client)) { changed = !priv->cal_uid; clear_comp_info (preview); } else { ESource *source; const gchar *uid; gchar *cal_uid; gchar *comp_uid; struct icaltimetype comp_last_modified, *itm = NULL; gint *sequence = NULL; gint comp_sequence; source = e_client_get_source (E_CLIENT (client)); cal_uid = g_strdup (e_source_get_uid (source)); e_cal_component_get_uid (comp, &uid); comp_uid = g_strdup (uid); e_cal_component_get_last_modified (comp, &itm); if (itm) { comp_last_modified = *itm; e_cal_component_free_icaltimetype (itm); } else comp_last_modified = icaltime_null_time (); e_cal_component_get_sequence (comp, &sequence); if (sequence) { comp_sequence = *sequence; e_cal_component_free_sequence (sequence); } else comp_sequence = 0; changed = !priv->cal_uid || !priv->comp_uid || !cal_uid || !comp_uid || !g_str_equal (priv->cal_uid, cal_uid) || !g_str_equal (priv->comp_uid, comp_uid) || priv->comp_sequence != comp_sequence || icaltime_compare (priv->comp_last_modified, comp_last_modified) != 0; clear_comp_info (preview); priv->cal_uid = cal_uid; priv->comp_uid = comp_uid; priv->comp_sequence = comp_sequence; priv->comp_last_modified = comp_last_modified; priv->comp = g_object_ref (comp); priv->client = g_object_ref (client); priv->timezone = icaltimezone_copy (zone); priv->use_24_hour_format = use_24_hour_format; } return changed; }
static void app_load_events (App *app) { GList *clients; GList *l; GList *ll; gchar *since_iso8601; gchar *until_iso8601; /* out with the old */ g_hash_table_remove_all (app->appointments); /* nuke existing views */ for (ll = app->live_views; ll != NULL; ll = ll->next) { ECalClientView *view = E_CAL_CLIENT_VIEW (ll->data); g_signal_handlers_disconnect_by_func (view, on_objects_added, app); g_signal_handlers_disconnect_by_func (view, on_objects_modified, app); g_signal_handlers_disconnect_by_func (view, on_objects_removed, app); e_cal_client_view_stop (view, NULL); g_object_unref (view); } g_list_free (app->live_views); app->live_views = NULL; /* timezone could have changed */ app_update_timezone (app); since_iso8601 = isodate_from_time_t (app->since); until_iso8601 = isodate_from_time_t (app->until); print_debug ("Loading events since %s until %s", since_iso8601, until_iso8601); clients = calendar_sources_get_appointment_clients (app->sources); for (l = clients; l != NULL; l = l->next) { ECalClient *cal = E_CAL_CLIENT (l->data); GError *error; gchar *query; GSList *objects, *j; ECalClientView *view; e_cal_client_set_default_timezone (cal, app->zone); error = NULL; if (!e_client_open_sync (E_CLIENT (cal), TRUE, NULL, &error)) { ESource *source = e_client_get_source (E_CLIENT (cal)); g_warning ("Error opening calendar %s: %s\n", e_source_get_uid (source), error->message); g_error_free (error); continue; } query = g_strdup_printf ("occur-in-time-range? (make-time \"%s\") " "(make-time \"%s\")", since_iso8601, until_iso8601); error = NULL; objects = NULL; if (!e_cal_client_get_object_list_sync (cal, query, &objects, NULL, /* cancellable */ &error)) { ESource *source = e_client_get_source (E_CLIENT (cal)); g_warning ("Error querying calendar %s: %s\n", e_source_get_uid (source), error->message); g_error_free (error); g_free (query); continue; } for (j = objects; j != NULL; j = j->next) { icalcomponent *ical = j->data; CalendarAppointment *appointment; appointment = calendar_appointment_new (ical, cal, app->zone); if (appointment == NULL) continue; calendar_appointment_generate_occurrences (appointment, ical, cal, app->since, app->until, app->zone); g_hash_table_insert (app->appointments, g_strdup (appointment->uid), appointment); } e_cal_client_free_icalcomp_slist (objects); error = NULL; if (!e_cal_client_get_view_sync (cal, query, &view, NULL, /* cancellable */ &error)) { g_warning ("Error setting up live-query on calendar: %s\n", error->message); g_error_free (error); } else { g_signal_connect (view, "objects-added", G_CALLBACK (on_objects_added), app); g_signal_connect (view, "objects-modified", G_CALLBACK (on_objects_modified), app); g_signal_connect (view, "objects-removed", G_CALLBACK (on_objects_removed), app); e_cal_client_view_start (view, NULL); app->live_views = g_list_prepend (app->live_views, view); } g_free (query); } g_list_free (clients); g_free (since_iso8601); g_free (until_iso8601); app->cache_invalid = FALSE; }