Commit b450cc9e authored by John Sullivan's avatar John Sullivan

reviewed by: Pavel Cisler <pavel@eazel.com>

	Fixed bug 5157 (Nautilus won't display directories for
	which it thinks it doesn't have permissions)

	I removed the code that prevented Nautilus from even
	trying to load a location for which the perceived
	permissions didn't allow reading (because the perceived
	permissions can be wrong with some file systems). Now
	it always tries, and puts up an error dialog only if
	it gets an error while actually loading the directory.

	* src/file-manager/fm-error-reporting.h:
	* src/file-manager/fm-error-reporting.c:
	(fm_report_error_loading_directory): New function, currently
	only handles GNOME_VFS_ERROR_ACCESS_DENIED and a fallback
	default case.
	(fm_report_error_renaming_file), (fm_report_error_setting_group),
	(fm_report_error_setting_owner),
	(fm_report_error_setting_permissions), (rename_callback):
	All the report_error functions now take a parent-window
	parameter (which is often NULL). Also, they now all use
	gnome_vfs_error_result_to_string when whining about
	unhandled cases.

	* src/file-manager/fm-directory-view.h: Changed comments
	and copyright notice only.
	* src/file-manager/fm-directory-view.c:
	(real_load_error): New function, calls
	fm_report_error_loading_directory unless an error has already
	been reported for the current directory load operation.
	(fm_directory_view_initialize_class): Wire up real_load_error
	as default handler for LOAD_ERROR signal.
	(activate_callback): Pass parent window to error-reporting call.
	(load_directory): Reset the reported_load_error boolean since
	we're about to load anew.

	* src/file-manager/fm-properties-window.c: (rename_callback),
	(group_change_callback), (owner_change_callback),
	(permission_change_callback):
	Pass parent window to error-reporting-calls. I just passed NULL
	if it was not trivial to pass a good window.

	* src/nautilus-window-manage-views.c:
	(handle_unreadable_location), (open_location): Remove code that
	was preventing "unreadable" locations from being loaded.
parent 55a708f1
2001-02-06 John Sullivan <sullivan@eazel.com>
reviewed by: <delete if not using a buddy>
Fixed bug 5157 (Nautilus won't display directories for
which it thinks it doesn't have permissions)
I removed the code that prevented Nautilus from even
trying to load a location for which the perceived
permissions didn't allow reading (because the perceived
permissions can be wrong with some file systems). Now
it always tries, and puts up an error dialog only if
it gets an error while actually loading the directory.
* src/file-manager/fm-error-reporting.h:
* src/file-manager/fm-error-reporting.c:
(fm_report_error_loading_directory): New function, currently
only handles GNOME_VFS_ERROR_ACCESS_DENIED and a fallback
default case.
(fm_report_error_renaming_file), (fm_report_error_setting_group),
(fm_report_error_setting_owner),
(fm_report_error_setting_permissions), (rename_callback):
All the report_error functions now take a parent-window
parameter (which is often NULL). Also, they now all use
gnome_vfs_error_result_to_string when whining about
unhandled cases.
* src/file-manager/fm-directory-view.h: Changed comments
and copyright notice only.
* src/file-manager/fm-directory-view.c:
(real_load_error): New function, calls
fm_report_error_loading_directory unless an error has already
been reported for the current directory load operation.
(fm_directory_view_initialize_class): Wire up real_load_error
as default handler for LOAD_ERROR signal.
(activate_callback): Pass parent window to error-reporting call.
(load_directory): Reset the reported_load_error boolean since
we're about to load anew.
* src/file-manager/fm-properties-window.c: (rename_callback),
(group_change_callback), (owner_change_callback),
(permission_change_callback):
Pass parent window to error-reporting-calls. I just passed NULL
if it was not trivial to pass a good window.
* src/nautilus-window-manage-views.c:
(handle_unreadable_location), (open_location): Remove code that
was preventing "unreadable" locations from being loaded.
2001-02-06 Gene Z. Ragan <gzr@eazel.com>
Fixed bug 6375, Certain menu shortcuts don't work when
......
......@@ -3,7 +3,7 @@
/* fm-directory-view.c
*
* Copyright (C) 1999, 2000 Free Software Foundaton
* Copyright (C) 2000 Eazel, Inc.
* Copyright (C) 2000, 2001 Eazel, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -30,6 +30,7 @@
#include "fm-directory-view.h"
#include "fm-desktop-icon-view.h"
#include "fm-error-reporting.h"
#include "fm-properties-window.h"
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-zoomable.h>
......@@ -140,6 +141,7 @@ struct FMDirectoryViewDetails
gboolean loading;
gboolean menus_merged;
gboolean menu_states_untrustworthy;
gboolean reported_load_error;
gboolean show_hidden_files;
gboolean show_backup_files;
......@@ -199,6 +201,8 @@ static void load_directory
gboolean force_reload);
static void fm_directory_view_merge_menus (FMDirectoryView *view);
static void real_file_limit_reached (FMDirectoryView *view);
static void real_load_error (FMDirectoryView *view,
GnomeVFSResult result);
static void real_merge_menus (FMDirectoryView *view);
static void real_update_menus (FMDirectoryView *view);
static gboolean real_is_read_only (FMDirectoryView *view);
......@@ -346,6 +350,7 @@ fm_directory_view_initialize_class (FMDirectoryViewClass *klass)
klass->supports_zooming = real_supports_zooming;
klass->supports_properties = real_supports_properties;
klass->file_limit_reached = real_file_limit_reached;
klass->load_error = real_load_error;
klass->reveal_selection = NULL;
/* Function pointers that subclasses must override */
......@@ -1990,6 +1995,26 @@ load_error_callback (NautilusDirectory *directory,
gtk_signal_emit (GTK_OBJECT (view), signals[LOAD_ERROR], load_error_code);
}
static void
real_load_error (FMDirectoryView *view, GnomeVFSResult result)
{
g_assert (result != GNOME_VFS_OK);
/* Report only one error per failed directory load (from the UI
* point of view, not from the NautilusDirectory point of view).
* Otherwise you can get multiple identical errors caused by
* unrelated code that just happens to try to iterate this
* directory.
*/
if (!view->details->reported_load_error) {
fm_report_error_loading_directory
(fm_directory_view_get_directory_as_file (view),
result,
fm_directory_view_get_containing_window (view));
}
view->details->reported_load_error = TRUE;
}
/**
* fm_directory_queue_notice_file_change
*
......@@ -3497,7 +3522,8 @@ activate_callback (NautilusFile *file, gpointer callback_data)
* the security risk of executing arbitrary commands. */
if (!nautilus_file_is_local (file)) {
nautilus_show_error_dialog (_("Sorry, but you can't execute commands from a remote site due to security considerations."),
_("Can't execute remote links"), NULL);
_("Can't execute remote links"),
fm_directory_view_get_containing_window (view));
action = ACTIVATION_ACTION_DO_NOTHING;
} else {
/* as an additional security precaution, we only execute commands without
......@@ -3733,6 +3759,7 @@ load_directory (FMDirectoryView *view,
nautilus_file_unref (old_file);
view->details->force_reload = force_reload;
view->details->reported_load_error = FALSE;
/* FIXME bugzilla.eazel.com 5062: In theory, we also need to monitor metadata here (as
* well as doing a call when ready), in case external forces
......
......@@ -2,7 +2,7 @@
/* fm-directory-view.h
*
* Copyright (C) 1999, 2000 Free Software Foundaton
* Copyright (C) 2000 Eazel, Inc.
* Copyright (C) 2000, 2001 Eazel, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -19,7 +19,10 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Ettore Perazzoli
* Authors: Ettore Perazzoli
* Darin Adler <darin@eazel.com>
* John Sullivan <sullivan@eazel.com>
* Pavel Cisler <pavel@eazel.com>
*/
#ifndef FM_DIRECTORY_VIEW_H
......@@ -125,10 +128,12 @@ struct FMDirectoryViewClass {
void (* end_loading) (FMDirectoryView *view);
/* The 'load_error' signal is emitted when the directory model
reports an error in the process of monitoring the directory's
contents. The load error indicates that the process of
load the contents has ended, but the directory is still
being monitored*/
* reports an error in the process of monitoring the directory's
* contents. The load error indicates that the process of
* loading the contents has ended, but the directory is still
* being monitored. The default implementation handles common
* load failures like ACCESS_DENIED.
*/
void (* load_error) (FMDirectoryView *view,
GnomeVFSResult result);
......
......@@ -29,6 +29,7 @@
#include <string.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomevfs/gnome-vfs-result.h>
#include <libnautilus-extensions/nautilus-file.h>
#include <libnautilus-extensions/nautilus-stock-dialogs.h>
......@@ -36,10 +37,43 @@
static void cancel_rename (NautilusFile *file);
void
fm_report_error_loading_directory (NautilusFile *file,
GnomeVFSResult error,
GtkWindow *parent_window)
{
char *file_name;
char *message;
if (error == GNOME_VFS_OK) {
return;
}
file_name = nautilus_file_get_name (file);
switch (error) {
case GNOME_VFS_ERROR_ACCESS_DENIED:
message = g_strdup_printf (_("You do not have the permissions necessary to view the contents of \"%s\"."),
file_name);
break;
default:
/* We should invent decent error messages for every case we actually experience. */
g_warning ("Hit unhandled case %d (%s) in fm_report_error_loading_directory, tell sullivan@eazel.com",
error, gnome_vfs_result_to_string (error));
message = g_strdup_printf (_("Sorry, couldn't display all the contents of \"%s\"."), file_name);
}
nautilus_show_error_dialog (message, _("Error Displaying Folder"), parent_window);
g_free (file_name);
g_free (message);
}
void
fm_report_error_renaming_file (NautilusFile *file,
const char *new_name,
GnomeVFSResult error)
GnomeVFSResult error,
GtkWindow *parent_window)
{
char *original_name;
char *message;
......@@ -82,7 +116,8 @@ fm_report_error_renaming_file (NautilusFile *file,
break;
default:
/* We should invent decent error messages for every case we actually experience. */
g_warning ("Hit unhandled case %d in fm_report_error_renaming_file, tell sullivan@eazel.com", error);
g_warning ("Hit unhandled case %d (%s) in fm_report_error_renaming_file, tell sullivan@eazel.com",
error, gnome_vfs_result_to_string (error));
/* fall through */
message = g_strdup_printf (_("Sorry, couldn't rename \"%s\" to \"%s\"."),
original_name, new_name);
......@@ -90,13 +125,14 @@ fm_report_error_renaming_file (NautilusFile *file,
g_free (original_name);
nautilus_show_error_dialog (message, _("Renaming Error"), NULL);
nautilus_show_error_dialog (message, _("Renaming Error"), parent_window);
g_free (message);
}
void
fm_report_error_setting_group (NautilusFile *file,
GnomeVFSResult error)
GnomeVFSResult error,
GtkWindow *parent_window)
{
char *file_name;
char *message;
......@@ -118,13 +154,14 @@ fm_report_error_setting_group (NautilusFile *file,
break;
default:
/* We should invent decent error messages for every case we actually experience. */
g_warning ("Hit unhandled case %d in fm_report_error_setting_group, tell sullivan@eazel.com", error);
g_warning ("Hit unhandled case %d (%s) in fm_report_error_setting_group, tell sullivan@eazel.com",
error, gnome_vfs_result_to_string (error));
file_name = nautilus_file_get_name (file);
message = g_strdup_printf (_("Sorry, couldn't change the group of \"%s\"."), file_name);
g_free (file_name);
}
nautilus_show_error_dialog (message, _("Error Setting Group"), NULL);
nautilus_show_error_dialog (message, _("Error Setting Group"), parent_window);
g_free (file_name);
g_free (message);
......@@ -132,7 +169,8 @@ fm_report_error_setting_group (NautilusFile *file,
void
fm_report_error_setting_owner (NautilusFile *file,
GnomeVFSResult error)
GnomeVFSResult error,
GtkWindow *parent_window)
{
char *file_name;
char *message;
......@@ -150,11 +188,12 @@ fm_report_error_setting_owner (NautilusFile *file,
break;
default:
/* We should invent decent error messages for every case we actually experience. */
g_warning ("Hit unhandled case %d in fm_report_error_setting_owner, tell sullivan@eazel.com", error);
g_warning ("Hit unhandled case %d (%s) in fm_report_error_setting_owner, tell sullivan@eazel.com",
error, gnome_vfs_result_to_string (error));
message = g_strdup_printf (_("Sorry, couldn't change the owner of \"%s\"."), file_name);
}
nautilus_show_error_dialog (message, _("Error Setting Owner"), NULL);
nautilus_show_error_dialog (message, _("Error Setting Owner"), parent_window);
g_free (file_name);
g_free (message);
......@@ -162,7 +201,8 @@ fm_report_error_setting_owner (NautilusFile *file,
void
fm_report_error_setting_permissions (NautilusFile *file,
GnomeVFSResult error)
GnomeVFSResult error,
GtkWindow *parent_window)
{
char *file_name;
char *message;
......@@ -180,11 +220,12 @@ fm_report_error_setting_permissions (NautilusFile *file,
break;
default:
/* We should invent decent error messages for every case we actually experience. */
g_warning ("Hit unhandled case %d in fm_report_error_setting_permissions, tell sullivan@eazel.com", error);
g_warning ("Hit unhandled case %d (%s) in fm_report_error_setting_permissions, tell sullivan@eazel.com",
error, gnome_vfs_result_to_string (error));
message = g_strdup_printf (_("Sorry, couldn't change the permissions of \"%s\"."), file_name);
}
nautilus_show_error_dialog (message, _("Error Setting Permissions"), NULL);
nautilus_show_error_dialog (message, _("Error Setting Permissions"), parent_window);
g_free (file_name);
g_free (message);
......@@ -201,7 +242,7 @@ rename_callback (NautilusFile *file, GnomeVFSResult result, gpointer callback_da
g_assert (name != NULL);
/* If rename failed, notify the user. */
fm_report_error_renaming_file (file, name, result);
fm_report_error_renaming_file (file, name, result, NULL);
cancel_rename (file);
}
......
......@@ -27,18 +27,26 @@
#define FM_ERROR_REPORTING_H
#include <glib.h>
#include <gtk/gtkwindow.h>
#include <libgnomevfs/gnome-vfs-types.h>
#include <libnautilus-extensions/nautilus-file.h>
void fm_report_error_loading_directory (NautilusFile *file,
GnomeVFSResult error_code,
GtkWindow *parent_window);
void fm_report_error_renaming_file (NautilusFile *file,
const char *new_name,
GnomeVFSResult error_code);
GnomeVFSResult error_code,
GtkWindow *parent_window);
void fm_report_error_setting_permissions (NautilusFile *file,
GnomeVFSResult error_code);
GnomeVFSResult error_code,
GtkWindow *parent_window);
void fm_report_error_setting_owner (NautilusFile *file,
GnomeVFSResult error_code);
GnomeVFSResult error_code,
GtkWindow *parent_window);
void fm_report_error_setting_group (NautilusFile *file,
GnomeVFSResult error_code);
GnomeVFSResult error_code,
GtkWindow *parent_window);
/* FIXME bugzilla.eazel.com 2394: Should this file be renamed or should these be moved? */
void fm_rename_file (NautilusFile *file,
......
......@@ -355,7 +355,8 @@ rename_callback (NautilusFile *file, GnomeVFSResult result, gpointer callback_da
new_name = window->details->pending_name;
fm_report_error_renaming_file (file,
window->details->pending_name,
result);
result,
GTK_WINDOW (window));
/* This can trigger after window destroy, before finalize. */
if (!GTK_OBJECT_DESTROYED (window)) {
name_field_restore_original_name (window->details->name_field);
......@@ -667,7 +668,7 @@ group_change_callback (NautilusFile *file, GnomeVFSResult result, gpointer callb
/* Report the error if it's an error. */
nautilus_timed_wait_stop (cancel_group_change_callback, file);
fm_report_error_setting_group (file, result);
fm_report_error_setting_group (file, result, NULL);
nautilus_file_unref (file);
}
......@@ -826,7 +827,7 @@ owner_change_callback (NautilusFile *file, GnomeVFSResult result, gpointer callb
/* Report the error if it's an error. */
nautilus_timed_wait_stop (cancel_owner_change_callback, file);
fm_report_error_setting_owner (file, result);
fm_report_error_setting_owner (file, result, NULL);
nautilus_file_unref (file);
}
......@@ -1705,7 +1706,7 @@ permission_change_callback (NautilusFile *file, GnomeVFSResult result, gpointer
g_assert (callback_data == NULL);
/* Report the error if it's an error. */
fm_report_error_setting_permissions (file, result);
fm_report_error_setting_permissions (file, result, NULL);
}
static void
......
......@@ -614,44 +614,6 @@ location_has_really_changed (NautilusWindow *window)
update_title (window);
}
static gboolean
handle_unreadable_location (NautilusWindow *window, const char *location)
{
NautilusFile *file;
gboolean unreadable;
char *file_name;
char *message;
/* An empty location doesn't jibe with our logic. It will
* work if there are any characters (even just one space).
*/
if (location[0] == '\0') {
return TRUE;
}
/* FIXME bugzilla.eazel.com 866: Can't expect to read the
* permissions instantly here. We might need to wait for
* a stat first.
*/
file = nautilus_file_get (location);
/* If it's gone, it doesn't count as unreadable, and will be handled
* by the normal missing-uri mechanism.
*/
unreadable = !nautilus_file_is_gone (file) && !nautilus_file_can_read (file);
if (unreadable) {
file_name = nautilus_file_get_name (file);
message = g_strdup_printf (_("You do not have the permissions necessary to view \"%s\"."), file_name);
g_free (file_name);
nautilus_show_error_dialog (message, _("Inadequate Permissions"), GTK_WINDOW (window));
g_free (message);
}
nautilus_file_unref (file);
return unreadable;
}
static NautilusWindow *
get_topmost_nautilus_window (void)
......@@ -683,10 +645,6 @@ open_location (NautilusWindow *window,
NautilusWindow *target_window;
gboolean create_new_window;
if (handle_unreadable_location (window, location)) {
return;
}
target_window = window;
create_new_window = force_new_window;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment