2004-01-27  Rodrigo Moya <rodrigo@ximian.com>

	Fixes #53276

	* gui/dialogs/copy-source-dialog.c (show_error): new function to
	create an error message dialog.
	(copy_source): check if the destination calendar is read only, and
	if so, don't try to copy components over. Fixed leaks. Call show_error
	to display meaningful error messages.

svn path=/trunk/; revision=24456
This commit is contained in:
Rodrigo Moya
2004-01-27 00:19:53 +00:00
committed by Rodrigo Moya
parent fa9ea77662
commit 92e99db380
2 changed files with 49 additions and 17 deletions

View File

@ -1,3 +1,13 @@
2004-01-27 Rodrigo Moya <rodrigo@ximian.com>
Fixes #53276
* gui/dialogs/copy-source-dialog.c (show_error): new function to
create an error message dialog.
(copy_source): check if the destination calendar is read only, and
if so, don't try to copy components over. Fixed leaks. Call show_error
to display meaningful error messages.
2004-01-26 JP Rosevear <jpr@ximian.com>
* gui/migration.c (migrate_ical_folder): add the source to the

View File

@ -21,6 +21,7 @@
#include <gtk/gtkbox.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkmessagedialog.h>
#include <gtk/gtkstock.h>
#include <bonobo/bonobo-i18n.h>
#include <widgets/misc/e-source-option-menu.h>
@ -54,11 +55,22 @@ source_selected_cb (ESourceOptionMenu *menu, ESource *selected_source, gpointer
gtk_dialog_set_response_sensitive (GTK_DIALOG (csdd->dialog), GTK_RESPONSE_OK, FALSE);
}
static void
show_error (GtkWindow *parent, const char *msg)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (parent, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, msg);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
static gboolean
copy_source (CopySourceDialogData *csdd)
{
char *uri;
ECal *source_client, *dest_client;
gboolean read_only = TRUE;
GList *obj_list = NULL;
gboolean result = FALSE;
@ -68,40 +80,50 @@ copy_source (CopySourceDialogData *csdd)
/* open the source */
source_client = auth_new_cal_from_source (csdd->orig_source, csdd->obj_type);
if (!e_cal_open (source_client, TRUE, NULL)) {
show_error (GTK_WINDOW (csdd->dialog), _("Could not open source"));
g_object_unref (source_client);
g_warning (G_STRLOC ": Could not open source");
return FALSE;
}
/* open the destination */
dest_client = auth_new_cal_from_source (csdd->selected_source, csdd->obj_type);
if (!e_cal_open (dest_client, FALSE, NULL)) {
show_error (GTK_WINDOW (csdd->dialog), _("Could not open destination"));
g_object_unref (dest_client);
g_object_unref (source_client);
g_warning (G_STRLOC ": Could not open destination");
return FALSE;
}
if (e_cal_get_object_list (source_client, "#t", &obj_list, NULL)) {
GList *l;
const char *uid;
icalcomponent *icalcomp;
/* check if the destination is read only */
e_cal_is_read_only (dest_client, &read_only, NULL);
if (read_only) {
show_error (GTK_WINDOW (csdd->dialog), _("Destination is read only"));
} else {
if (e_cal_get_object_list (source_client, "#t", &obj_list, NULL)) {
GList *l;
const char *uid;
icalcomponent *icalcomp;
for (l = obj_list; l != NULL; l = l->next) {
/* FIXME: process recurrences */
/* FIXME: process errors */
if (e_cal_get_object (dest_client, icalcomponent_get_uid (l->data), NULL,
&icalcomp, NULL)) {
e_cal_modify_object (dest_client, icalcomp, CALOBJ_MOD_ALL, NULL);
} else {
e_cal_create_object (dest_client, l->data, (char **) &uid, NULL);
g_free ((gpointer) uid);
for (l = obj_list; l != NULL; l = l->next) {
/* FIXME: process recurrences */
/* FIXME: process errors */
if (e_cal_get_object (dest_client, icalcomponent_get_uid (l->data), NULL,
&icalcomp, NULL)) {
e_cal_modify_object (dest_client, icalcomp, CALOBJ_MOD_ALL, NULL);
} else {
e_cal_create_object (dest_client, l->data, (char **) &uid, NULL);
g_free ((gpointer) uid);
}
}
}
e_cal_free_object_list (obj_list);
e_cal_free_object_list (obj_list);
}
}
/* free memory */
g_object_unref (dest_client);
g_object_unref (source_client);
return result;
}