Re: [patch] [bug 432510] samba filename encoding on none UTF-8 locales



gvfs looks a great implementation.

I updated the patch for this issue. Could you review the attachment?


Alexander Larsson wrote:
On Wed, 2007-05-16 at 16:49 +0900, Takao Fujiwara - Tokyo S/W Center
wrote:

Thanks for the pointer. I was stucked in git on Solaris.
Probably I don't understand the usage of gvfs.

# gvfs-mount -m smb://foo


gvfs is a work in progress, don't expect to be able to use it
productively (or even work) atm. If you're interested in helping out,
what we want is feedback on the APIs.


I'ld like to know if I can disable to use DBus.


No, but neither can you in gnome-vfs.


I agree with most of your mentions. My point is that I want to fix this problem asap in GNOME SVN HEAD.


Well, I just don't think it fixes very much. But ok, it does allow some
people (the very few who knows about this feature and have a setup where
they need it) to set up things in a way that things work slightly
better.
So, while I don't particulary like this solution its probably
acceptable, since it doesn't affect people not using it.

However, the patch looks a bit broken, it uses g_filename_display_name()
to convert the filename, and that only converts things if
G_BROKEN_FILENAMES (or the other env vars like G_FILENAME_ENCODING) is
set (instead of looking at G_BROKEN_FILENAMES_SMB.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Alexander Larsson Red Hat, Inc alexl redhat com alla lysator liu se He's a maverick coffee-fuelled paranormal investigator with nothing left to lose. She's a cold-hearted paranoid socialite with a flame-thrower. They fight crime!

--- nautilus/libnautilus-private/nautilus-file.c.orig	2007-05-18 22:51:54.295827000 +0900
+++ nautilus/libnautilus-private/nautilus-file.c	2007-05-18 22:52:09.471579000 +0900
@@ -1034,6 +1034,12 @@ has_local_path (NautilusFile *file)
 	return eel_str_has_prefix (file->details->directory->details->uri, "file:");
 }
 
+static gboolean
+use_local_charset (NautilusFile *file)
+{
+	return eel_str_has_prefix (file->details->directory->details->uri, "smb:");
+}
+
 static void
 rename_callback (GnomeVFSAsyncHandle *handle,
 		 GnomeVFSResult result,
@@ -1260,9 +1266,10 @@ nautilus_file_rename (NautilusFile *file
 	utf8_filenames = eel_get_filename_charset (&filename_charset);
 
 	/* Note: Desktop file renaming wants utf8, even with G_BROKEN_FILENAMES */
-	if (has_local_path (file) && !utf8_filenames &&
+	if ((has_local_path (file) || use_local_charset (file)) &&
+	    !utf8_filenames &&
 	    !is_desktop_file (file)) {
-		locale_name = g_filename_from_utf8 (new_name, -1, NULL, NULL, NULL);
+		locale_name = g_convert (new_name, -1, filename_charset, "UTF-8", NULL, NULL, NULL);
 		if (locale_name == NULL) {
 			(* callback) (file, GNOME_VFS_ERROR_NOT_PERMITTED, callback_data);
 			return;
@@ -2642,10 +2649,12 @@ static char *
 nautilus_file_get_display_name_nocopy (NautilusFile *file)
 {
 	char *name, *utf8_name, *short_name;
+	const char *filename_charset;
 	gboolean validated;
 	GnomeVFSURI *vfs_uri;
 	const char *method;
 	char *uri, *local_file;
+	
 
 	if (file == NULL) {
 		return NULL;
@@ -2659,6 +2668,16 @@ nautilus_file_get_display_name_nocopy (N
 	
  	if (file->details->got_link_info && file->details->display_name != NULL) {
  		name = g_strdup (file->details->display_name);
+		if (use_local_charset (file) &&
+		    !eel_get_filename_charset (&filename_charset)) {
+			utf8_name = g_convert (name, -1, "UTF-8", filename_charset, NULL, NULL, NULL);
+			if (utf8_name) {
+				g_free (name);
+				name = utf8_name;
+			} else {
+				g_warning (_("Your smb.conf or G_BROKEN_FILE_NAMES is not configured correctly."));
+			}
+		}
 	} else {
 		name = nautilus_file_get_name (file);
 		if (name == NULL) {
@@ -2703,6 +2722,15 @@ nautilus_file_get_display_name_nocopy (N
 				g_free (short_name);
 				
 				gnome_vfs_uri_unref (vfs_uri);
+			} else if (use_local_charset (file) &&
+			           !eel_get_filename_charset (&filename_charset)) {
+				utf8_name = g_convert (name, -1, "UTF-8", filename_charset, NULL, NULL, NULL);
+				if (utf8_name) {
+					g_free (name);
+					name = utf8_name;
+				} else {
+					g_warning (_("Your smb.conf or G_BROKEN_FILE_NAMES is not configured correctly."));
+				}
 			}
 		}
 	}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]