aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-09-19 10:20:37 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-09-19 10:20:37 +0800
commitc8509a58159cc1d2899236c0571453f020ae47b4 (patch)
tree7686e78736be640cafea668df76658cc60e16673 /calendar
parente54241baa88fba95c357bdde508c9c924275c3a3 (diff)
downloadgsoc2013-evolution-c8509a58159cc1d2899236c0571453f020ae47b4.tar.gz
gsoc2013-evolution-c8509a58159cc1d2899236c0571453f020ae47b4.tar.zst
gsoc2013-evolution-c8509a58159cc1d2899236c0571453f020ae47b4.zip
Fixes bug #6350.
2001-09-18 Federico Mena Quintero <federico@ximian.com> Fixes bug #6350. * gui/component-factory.c (remove_folder): Use a simplified method for removing our folder data; we just need to remove calendar.ics or tasks.ics and the corresponding backup files. svn path=/trunk/; revision=12966
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog8
-rw-r--r--calendar/gui/calendar-component.c154
-rw-r--r--calendar/gui/component-factory.c154
3 files changed, 174 insertions, 142 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index ac79893664..e3712ea18f 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,13 @@
2001-09-18 Federico Mena Quintero <federico@ximian.com>
+ Fixes bug #6350.
+
+ * gui/component-factory.c (remove_folder): Use a simplified method
+ for removing our folder data; we just need to remove calendar.ics
+ or tasks.ics and the corresponding backup files.
+
+2001-09-18 Federico Mena Quintero <federico@ximian.com>
+
Fixes bug #2830.
* gui/calendar-config.c (calendar_config_get_confirm_delete): New
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index 2e6186974f..637f6976cc 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -70,20 +70,7 @@ static const EvolutionShellComponentFolderType folder_types[] = {
};
-/* Utility functions. */
-static const char *
-get_local_file_name_for_folder_type (const char *type)
-{
- if (strcmp (type, "calendar") == 0)
- return "calendar.ics";
- else if (strcmp (type, "tasks") == 0)
- return "tasks.ics";
- else
- return NULL;
-}
-
-
/* EvolutionShellComponent methods and signals. */
static EvolutionShellComponentResult
@@ -160,26 +147,33 @@ remove_folder (EvolutionShellComponent *shell_component,
const GNOME_Evolution_ShellComponentListener listener,
void *closure)
{
- CORBA_Environment ev;
- GnomeVFSURI *uri;
- GnomeVFSResult result;
- GList *file_list;
-
- CORBA_exception_init(&ev);
+ GnomeVFSURI *dir_uri, *data_uri, *backup_uri;
+ GnomeVFSResult data_result, backup_result;
/* check type */
if (strcmp (type, FOLDER_CALENDAR) && strcmp (type, FOLDER_TASKS)) {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
GNOME_Evolution_ShellComponentListener_notifyResult (
listener,
GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE,
&ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_message ("remove_folder(): Could not notify the listener of "
+ "an unsupported folder type");
+
CORBA_exception_free (&ev);
return;
}
/* check URI */
- uri = gnome_vfs_uri_new_private (physical_uri, TRUE, TRUE, TRUE);
- if (!uri) {
+ dir_uri = gnome_vfs_uri_new_private (physical_uri, TRUE, TRUE, TRUE);
+ if (!dir_uri) {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
GNOME_Evolution_ShellComponentListener_notifyResult (
listener,
GNOME_Evolution_ShellComponentListener_INVALID_URI,
@@ -188,64 +182,82 @@ remove_folder (EvolutionShellComponent *shell_component,
return;
}
- /* remove all files in that directory */
- result = gnome_vfs_directory_list_load (&file_list, physical_uri, 0, NULL);
- if (result == GNOME_VFS_OK) {
- GList *l;
- gboolean success = TRUE;
-
- for (l = file_list; l; l = l->next) {
- GnomeVFSFileInfo *file_info;
- GnomeVFSURI *tmp_uri;
-
- /* ignore hidden files */
- file_info = (GnomeVFSFileInfo *) l->data;
- if (!file_info || file_info->name[0] == '.')
- continue;
-
- if (file_info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
- GNOME_Evolution_ShellComponentListener_notifyResult (
- listener,
- GNOME_Evolution_ShellComponentListener_HAS_SUBFOLDERS,
- &ev);
- success = FALSE;
- break;
- }
-
- tmp_uri = gnome_vfs_uri_new_private (physical_uri, TRUE, TRUE, TRUE);
- tmp_uri = gnome_vfs_uri_append_file_name (tmp_uri, file_info->name);
-
- result = gnome_vfs_unlink_from_uri (tmp_uri);
- gnome_vfs_uri_unref (tmp_uri);
- if (result != GNOME_VFS_OK) {
- GNOME_Evolution_ShellComponentListener_notifyResult (
- listener,
- GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED,
- &ev);
- success = FALSE;
- break;
- }
- }
-
- if (success) {
- GNOME_Evolution_ShellComponentListener_notifyResult (
- listener,
- GNOME_Evolution_ShellComponentListener_OK,
- &ev);
- }
+ /* Compute the URIs of the appropriate files */
+
+ if (strcmp (type, FOLDER_CALENDAR) == 0) {
+ data_uri = gnome_vfs_uri_append_file_name (dir_uri, "calendar.ics");
+ backup_uri = gnome_vfs_uri_append_file_name (dir_uri, "calendar.ics~");
+ } else if (strcmp (type, FOLDER_TASKS) == 0) {
+ data_uri = gnome_vfs_uri_append_file_name (dir_uri, "tasks.ics");
+ backup_uri = gnome_vfs_uri_append_file_name (dir_uri, "tasks.ics~");
+ } else {
+ g_assert_not_reached ();
+ return;
}
- else {
+
+ if (!data_uri || !backup_uri) {
+ CORBA_Environment ev;
+
+ g_message ("remove_folder(): Could not generate the data/backup URIs");
+
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_ShellComponentListener_notifyResult (
+ listener,
+ GNOME_Evolution_ShellComponentListener_INVALID_URI,
+ &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_message ("remove_folder(): Could not notify the listener "
+ "of an invalid URI");
+
+ CORBA_exception_free (&ev);
+
+ goto out;
+ }
+
+ /* Delete the data and backup files; the shell will take care of the rest */
+
+ data_result = gnome_vfs_unlink_from_uri (data_uri);
+ backup_result = gnome_vfs_unlink_from_uri (backup_uri);
+
+ if ((data_result == GNOME_VFS_OK || data_result == GNOME_VFS_ERROR_NOT_FOUND)
+ && (backup_result == GNOME_VFS_OK || backup_result == GNOME_VFS_ERROR_NOT_FOUND)) {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_ShellComponentListener_notifyResult (
+ listener,
+ GNOME_Evolution_ShellComponentListener_OK,
+ &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_message ("remove_folder(): Could not notify the listener about success");
+
+ CORBA_exception_free (&ev);
+ } else {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
GNOME_Evolution_ShellComponentListener_notifyResult (
listener,
GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED,
&ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_message ("remove_folder(): Could not notify the listener about failure");
+
+ CORBA_exception_free (&ev);
}
- /* free memory */
- gnome_vfs_file_info_list_free (file_list);
- gnome_vfs_uri_unref (uri);
+ out:
+
+ gnome_vfs_uri_unref (dir_uri);
+
+ if (data_uri)
+ gnome_vfs_uri_unref (data_uri);
- CORBA_exception_free(&ev);
+ if (backup_uri)
+ gnome_vfs_uri_unref (backup_uri);
}
static void
diff --git a/calendar/gui/component-factory.c b/calendar/gui/component-factory.c
index 2e6186974f..637f6976cc 100644
--- a/calendar/gui/component-factory.c
+++ b/calendar/gui/component-factory.c
@@ -70,20 +70,7 @@ static const EvolutionShellComponentFolderType folder_types[] = {
};
-/* Utility functions. */
-static const char *
-get_local_file_name_for_folder_type (const char *type)
-{
- if (strcmp (type, "calendar") == 0)
- return "calendar.ics";
- else if (strcmp (type, "tasks") == 0)
- return "tasks.ics";
- else
- return NULL;
-}
-
-
/* EvolutionShellComponent methods and signals. */
static EvolutionShellComponentResult
@@ -160,26 +147,33 @@ remove_folder (EvolutionShellComponent *shell_component,
const GNOME_Evolution_ShellComponentListener listener,
void *closure)
{
- CORBA_Environment ev;
- GnomeVFSURI *uri;
- GnomeVFSResult result;
- GList *file_list;
-
- CORBA_exception_init(&ev);
+ GnomeVFSURI *dir_uri, *data_uri, *backup_uri;
+ GnomeVFSResult data_result, backup_result;
/* check type */
if (strcmp (type, FOLDER_CALENDAR) && strcmp (type, FOLDER_TASKS)) {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
GNOME_Evolution_ShellComponentListener_notifyResult (
listener,
GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE,
&ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_message ("remove_folder(): Could not notify the listener of "
+ "an unsupported folder type");
+
CORBA_exception_free (&ev);
return;
}
/* check URI */
- uri = gnome_vfs_uri_new_private (physical_uri, TRUE, TRUE, TRUE);
- if (!uri) {
+ dir_uri = gnome_vfs_uri_new_private (physical_uri, TRUE, TRUE, TRUE);
+ if (!dir_uri) {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
GNOME_Evolution_ShellComponentListener_notifyResult (
listener,
GNOME_Evolution_ShellComponentListener_INVALID_URI,
@@ -188,64 +182,82 @@ remove_folder (EvolutionShellComponent *shell_component,
return;
}
- /* remove all files in that directory */
- result = gnome_vfs_directory_list_load (&file_list, physical_uri, 0, NULL);
- if (result == GNOME_VFS_OK) {
- GList *l;
- gboolean success = TRUE;
-
- for (l = file_list; l; l = l->next) {
- GnomeVFSFileInfo *file_info;
- GnomeVFSURI *tmp_uri;
-
- /* ignore hidden files */
- file_info = (GnomeVFSFileInfo *) l->data;
- if (!file_info || file_info->name[0] == '.')
- continue;
-
- if (file_info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
- GNOME_Evolution_ShellComponentListener_notifyResult (
- listener,
- GNOME_Evolution_ShellComponentListener_HAS_SUBFOLDERS,
- &ev);
- success = FALSE;
- break;
- }
-
- tmp_uri = gnome_vfs_uri_new_private (physical_uri, TRUE, TRUE, TRUE);
- tmp_uri = gnome_vfs_uri_append_file_name (tmp_uri, file_info->name);
-
- result = gnome_vfs_unlink_from_uri (tmp_uri);
- gnome_vfs_uri_unref (tmp_uri);
- if (result != GNOME_VFS_OK) {
- GNOME_Evolution_ShellComponentListener_notifyResult (
- listener,
- GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED,
- &ev);
- success = FALSE;
- break;
- }
- }
-
- if (success) {
- GNOME_Evolution_ShellComponentListener_notifyResult (
- listener,
- GNOME_Evolution_ShellComponentListener_OK,
- &ev);
- }
+ /* Compute the URIs of the appropriate files */
+
+ if (strcmp (type, FOLDER_CALENDAR) == 0) {
+ data_uri = gnome_vfs_uri_append_file_name (dir_uri, "calendar.ics");
+ backup_uri = gnome_vfs_uri_append_file_name (dir_uri, "calendar.ics~");
+ } else if (strcmp (type, FOLDER_TASKS) == 0) {
+ data_uri = gnome_vfs_uri_append_file_name (dir_uri, "tasks.ics");
+ backup_uri = gnome_vfs_uri_append_file_name (dir_uri, "tasks.ics~");
+ } else {
+ g_assert_not_reached ();
+ return;
}
- else {
+
+ if (!data_uri || !backup_uri) {
+ CORBA_Environment ev;
+
+ g_message ("remove_folder(): Could not generate the data/backup URIs");
+
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_ShellComponentListener_notifyResult (
+ listener,
+ GNOME_Evolution_ShellComponentListener_INVALID_URI,
+ &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_message ("remove_folder(): Could not notify the listener "
+ "of an invalid URI");
+
+ CORBA_exception_free (&ev);
+
+ goto out;
+ }
+
+ /* Delete the data and backup files; the shell will take care of the rest */
+
+ data_result = gnome_vfs_unlink_from_uri (data_uri);
+ backup_result = gnome_vfs_unlink_from_uri (backup_uri);
+
+ if ((data_result == GNOME_VFS_OK || data_result == GNOME_VFS_ERROR_NOT_FOUND)
+ && (backup_result == GNOME_VFS_OK || backup_result == GNOME_VFS_ERROR_NOT_FOUND)) {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_ShellComponentListener_notifyResult (
+ listener,
+ GNOME_Evolution_ShellComponentListener_OK,
+ &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_message ("remove_folder(): Could not notify the listener about success");
+
+ CORBA_exception_free (&ev);
+ } else {
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
GNOME_Evolution_ShellComponentListener_notifyResult (
listener,
GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED,
&ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION)
+ g_message ("remove_folder(): Could not notify the listener about failure");
+
+ CORBA_exception_free (&ev);
}
- /* free memory */
- gnome_vfs_file_info_list_free (file_list);
- gnome_vfs_uri_unref (uri);
+ out:
+
+ gnome_vfs_uri_unref (dir_uri);
+
+ if (data_uri)
+ gnome_vfs_uri_unref (data_uri);
- CORBA_exception_free(&ev);
+ if (backup_uri)
+ gnome_vfs_uri_unref (backup_uri);
}
static void