[Xfce4-commits] r29232 - thunar/branches/port-to-gio/thunar
Jannis Pohlmann
jannis at xfce.org
Wed Jan 14 01:07:16 CET 2009
Author: jannis
Date: 2009-01-14 00:07:16 +0000 (Wed, 14 Jan 2009)
New Revision: 29232
Modified:
thunar/branches/port-to-gio/thunar/thunar-file.c
Log:
* thunar/thunar-file.c: Implement thunar_file_get_emblem_names()
without the ThunarVfsInfo member of ThunarFile. Remove
thunar_file_denies_access_permission() because GIO determines this
internally when setting G_FILE_INFO_ATTRIBUTE_CAN_READ etc.
Modified: thunar/branches/port-to-gio/thunar/thunar-file.c
===================================================================
--- thunar/branches/port-to-gio/thunar/thunar-file.c 2009-01-14 00:01:52 UTC (rev 29231)
+++ thunar/branches/port-to-gio/thunar/thunar-file.c 2009-01-14 00:07:16 UTC (rev 29232)
@@ -101,10 +101,6 @@
static gboolean thunar_file_info_is_directory (ThunarxFileInfo *file_info);
static ThunarVfsInfo *thunar_file_info_get_vfs_info (ThunarxFileInfo *file_info);
static void thunar_file_info_changed (ThunarxFileInfo *file_info);
-static gboolean thunar_file_denies_access_permission (const ThunarFile *file,
- ThunarFileMode usr_permissions,
- ThunarFileMode grp_permissions,
- ThunarFileMode oth_permissions);
static ThunarMetafile *thunar_file_get_metafile (ThunarFile *file);
static void thunar_file_monitor (GFileMonitor *monitor,
GFile *gfile,
@@ -416,81 +412,6 @@
-static gboolean
-thunar_file_denies_access_permission (const ThunarFile *file,
- ThunarFileMode usr_permissions,
- ThunarFileMode grp_permissions,
- ThunarFileMode oth_permissions)
-{
- ThunarFileMode mode;
- ThunarGroup *group;
- ThunarUser *user;
- gboolean result;
- GList *groups;
- GList *lp;
-
- /* root is allowed to do everything */
- if (G_UNLIKELY (effective_user_id == 0))
- return FALSE;
-
- /* query the file mode */
- mode = thunar_file_get_mode (file);
-
- /* query the owner of the file, if we cannot determine
- * the owner, we can't tell if we're denied to access
- * the file, so we simply return FALSE then.
- */
- user = thunar_file_get_user (file);
- if (G_UNLIKELY (user == NULL))
- return FALSE;
-
- if (thunar_user_is_me (user))
- {
- /* we're the owner, so the usr permissions must be granted */
- result = ((mode & usr_permissions) == 0);
-
- /* release the user */
- g_object_unref (G_OBJECT (user));
- }
- else
- {
- group = thunar_file_get_group (file);
- if (G_LIKELY (group != NULL))
- {
- /* release the file owner */
- g_object_unref (G_OBJECT (user));
-
- /* determine the effective user */
- user = thunar_user_manager_get_user_by_id (user_manager, effective_user_id);
- if (G_LIKELY (user != NULL))
- {
- /* check the group permissions */
- groups = thunar_user_get_groups (user);
- for (lp = groups; lp != NULL; lp = lp->next)
- if (THUNAR_GROUP (lp->data) == group)
- {
- g_object_unref (G_OBJECT (user));
- g_object_unref (G_OBJECT (group));
- return ((mode & grp_permissions) == 0);
- }
-
- /* release the effective user */
- g_object_unref (G_OBJECT (user));
- }
-
- /* release the file group */
- g_object_unref (G_OBJECT (group));
- }
-
- /* check other permissions */
- result = ((mode & oth_permissions) == 0);
- }
-
- return result;
-}
-
-
-
static ThunarMetafile*
thunar_file_get_metafile (ThunarFile *file)
{
@@ -1464,10 +1385,9 @@
GList*
thunar_file_get_emblem_names (ThunarFile *file)
{
- const ThunarVfsInfo *info = file->info;
- const gchar *emblem_string;
- gchar **emblem_names;
- GList *emblems = NULL;
+ const gchar *emblem_string;
+ gchar **emblem_names;
+ GList *emblems = NULL;
_thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
@@ -1492,24 +1412,20 @@
emblems = g_list_append (emblems, *emblem_names);
}
- if ((info->flags & THUNAR_VFS_FILE_FLAGS_SYMLINK) != 0)
+ if (thunar_file_is_symlink (file))
emblems = g_list_prepend (emblems, THUNAR_FILE_EMBLEM_NAME_SYMBOLIC_LINK);
/* we add "cant-read" if either (a) the file is not readable or (b) a directory, that lacks the
* x-bit, see http://bugzilla.xfce.org/show_bug.cgi?id=1408 for the details about this change.
*/
- if (!thunar_file_is_readable (file)
- || (thunar_file_is_directory (file)
- && thunar_file_denies_access_permission (file, THUNAR_VFS_FILE_MODE_USR_EXEC,
- THUNAR_VFS_FILE_MODE_GRP_EXEC,
- THUNAR_VFS_FILE_MODE_OTH_EXEC)))
+ if (!thunar_file_is_readable (file) || (thunar_file_is_directory (file) && !thunar_file_is_executable (file)))
{
emblems = g_list_prepend (emblems, THUNAR_FILE_EMBLEM_NAME_CANT_READ);
}
- else if (G_UNLIKELY (file->info->uid == effective_user_id && !thunar_file_is_writable (file)))
+ else if (G_UNLIKELY (!thunar_file_is_writable (file)))
{
- /* we own the file, but we cannot write to it, that's why we mark it as "cant-write", so
- * users won't be surprised when opening the file in a text editor, but are unable to save.
+ /* we cannot write to the file, that's why we mark it as "cant-write", so users won't
+ * be surprised when opening the file in a text editor, but are unable to save.
*/
emblems = g_list_prepend (emblems, THUNAR_FILE_EMBLEM_NAME_CANT_WRITE);
}
More information about the Xfce4-commits
mailing list