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 gboolean do_manage_comp_idle (struct _manage_comp *mc) { GError *error = NULL; ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_LAST; ECalComponent *edit_comp = NULL; g_return_val_if_fail (mc, FALSE); source_type = e_cal_client_get_source_type (mc->client); if (source_type == E_CAL_CLIENT_SOURCE_TYPE_LAST) { free_manage_comp_struct (mc); g_warning ("mail-to-task: Incorrect call of %s, no data given", G_STRFUNC); return FALSE; } if (mc->stored_comp) { const gchar *ask = get_question_edit_old (source_type); if (ask) { gchar *msg = g_strdup_printf (ask, icalcomponent_get_summary (mc->stored_comp) ? icalcomponent_get_summary (mc->stored_comp) : _("[No Summary]")); gint chosen; chosen = do_ask (msg, TRUE); if (chosen == GTK_RESPONSE_YES) { edit_comp = e_cal_component_new (); if (!e_cal_component_set_icalcomponent (edit_comp, icalcomponent_new_clone (mc->stored_comp))) { g_object_unref (edit_comp); edit_comp = NULL; error = g_error_new ( E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, "%s", _("Invalid object returned from a server")); } } else if (chosen == GTK_RESPONSE_NO) { /* user wants to create a new event, thus generate a new UID */ gchar *new_uid = e_cal_component_gen_uid (); edit_comp = mc->comp; e_cal_component_set_uid (edit_comp, new_uid); e_cal_component_set_recurid (edit_comp, NULL); g_free (new_uid); } g_free (msg); } } else { edit_comp = mc->comp; } if (edit_comp) { EShell *shell; ECompEditor *comp_editor; /* FIXME Pass in the EShell instance. */ shell = e_shell_get_default (); comp_editor = get_component_editor ( shell, mc->client, edit_comp, edit_comp == mc->comp, &error); if (comp_editor && !error) { comp_editor_title_changed (GTK_WIDGET (comp_editor), NULL, mc); e_signal_connect_notify ( comp_editor, "notify::title", G_CALLBACK (comp_editor_title_changed), mc); g_signal_connect ( comp_editor, "editor-closed", G_CALLBACK (comp_editor_closed), mc); gtk_window_present (GTK_WINDOW (comp_editor)); if (edit_comp != mc->comp) g_object_unref (edit_comp); } else { g_warning ("Failed to create event editor: %s", error ? error->message : "Unknown error"); g_cond_signal (&mc->cond); } } else { /* User canceled editing already existing event, so * treat it as if he just closed the editor window. */ comp_editor_closed (NULL, FALSE, mc); } if (error != NULL) { e_notice ( NULL, GTK_MESSAGE_ERROR, _("An error occurred during processing: %s"), error->message); g_clear_error (&error); } return FALSE; }