Index: /gsdl/trunk/perllib/plugins/BasePlugin.pm
===================================================================
--- /gsdl/trunk/perllib/plugins/BasePlugin.pm	(revision 18319)
+++ /gsdl/trunk/perllib/plugins/BasePlugin.pm	(revision 18320)
@@ -44,4 +44,12 @@
     @BasePlugin::ISA = ( 'PrintInfo' );
 }
+
+# the different methods that can be applied when renaming
+# imported documents and their associated files
+our $file_rename_method_list = 
+    [ { 'name' => "url",
+	'desc' => "{BasePlugin.rename_method.url}" },
+      { 'name' => "base64",
+	'desc' => "{BasePlugin.rename_method.base64}" } ];
 
 our $encoding_list =
@@ -126,6 +134,5 @@
 	'deft' => "dc.Identifier",
 	'reqd' => "no",
-	'modegli' => "2" },
-
+	'modegli' => "2" },      
 #      { 'name' => "use_as_doc_identifier",
 #	'desc' => "{BasePlugin.use_as_doc_identifier}",
@@ -133,5 +140,5 @@
 #	'reqd' => "no" ,
 #	'deft' => "" } ,
-     { 'name' => "no_cover_image",
+      { 'name' => "no_cover_image",
 	'desc' => "{BasePlugin.no_cover_image}",
 	'type' => "flag",
@@ -147,6 +154,12 @@
         'type' => "flag",
         'reqd' => "no",
-	'hiddengli' => "yes" } # deprecated, but leave in for old collections
-
+	'hiddengli' => "yes" }, # deprecated, but leave in for old collections
+      { 'name' => "file_rename_method",
+	'desc' => "{BasePlugin.file_rename_method}",
+	'type' => "enum",
+	'deft' => &get_default_file_rename_method(), # by default rename imported files and assoc files using this encoding
+	'list' => $file_rename_method_list,
+	'reqd' => "no"
+      }
       
       ];
@@ -158,5 +171,4 @@
 		'inherits' => "no",
 		'args'     => $arguments };
-
 
 sub new {
@@ -346,4 +358,11 @@
 
     return "";
+}
+
+# rename imported files and assoc files using URL encoding by default
+# as this will work for most plugins and give more legible filenames
+sub get_default_file_rename_method() {
+    my $self = shift (@_);
+    return "url";
 }
 
@@ -566,5 +585,5 @@
 
 # gets the filename with no path, converts to utf8, and then dm safes it.
-#filename_encoding set by user
+# filename_encoding set by user
 sub filename_to_utf8_metadata
 {
@@ -732,17 +751,17 @@
     my ($doc_obj, $filename_no_path, $file_encoding) = @_;
 
-
     my $top_section = $doc_obj->get_top_section();
     
     # UTF-8 version of filename
     my $filemeta = $self->filename_to_utf8_metadata($filename_no_path, $file_encoding);
-
+    
     # Source is the UTF8 display name - not necessarily the name of the file on the system
     $doc_obj->set_utf8_metadata_element($top_section, "Source", $filemeta); 
 
-    # SourceFile is the url-reference to url-encoded filemeta: 
-    # it's a url that refers to the actual file on the system
-    $filemeta = &unicode::url_encode($filemeta);
-    $filemeta = &unicode::filename_to_url($filemeta);
+    $filemeta = &util::rename_file($filemeta, $self->{'file_rename_method'});
+    # If using URL encoding, then SourceFile is the url-reference to url-encoded
+    # filemeta: it's a url that refers to the actual file on the system
+    $filemeta = &unicode::filename_to_url($filemeta, $self->{'file_rename_method'});
+
     $doc_obj->set_utf8_metadata_element($top_section, "SourceFile", $filemeta);
 }
@@ -797,5 +816,5 @@
     my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
     # create a new document
-    my $doc_obj = new doc ($filename_full_path, "indexed_doc");
+    my $doc_obj = new doc ($filename_full_path, "indexed_doc", $self->{'file_rename_method'});
     my $top_section = $doc_obj->get_top_section();
 
@@ -1004,10 +1023,10 @@
 		
 		# we need to make sure the filename is valid utf-8 - we do 
-		# this by url encoding it
+		# this by url or base64 encoding it
 		# $tail_filename is the name that we store the file as
-		$tail_filename = &unicode::url_encode($tail_filename);
+		$tail_filename = &util::rename_file($tail_filename, $self->{'file_rename_method'});
 		$doc_obj->associate_file($full_filename,$tail_filename,$mimetype);
-		# then we need to encode the % signs in the filename, so that 
-		# it works in a url
+		# If the filename is url_encoded, we need to encode the % signs 
+		# in the filename, so that it works in a url
 		my $url_tail_filename = &unicode::filename_to_url($tail_filename);
 		# work out extended tail extension (i.e. matching tail re)
Index: /gsdl/trunk/perllib/plugins/ConvertBinaryFile.pm
===================================================================
--- /gsdl/trunk/perllib/plugins/ConvertBinaryFile.pm	(revision 18319)
+++ /gsdl/trunk/perllib/plugins/ConvertBinaryFile.pm	(revision 18320)
@@ -284,5 +284,5 @@
     # to work on Windows (IE or Firefox), as browsers are looking for filesystem-encoded
     # files on the filesystem.
-    $tailname = &unicode::url_encode($tailname);
+    $tailname = &util::rename_file($tailname, $self->{'file_rename_method'});
 
     $suffix = lc($suffix);
@@ -429,5 +429,5 @@
     my $collect_file = &util::filename_within_collection($filename_full_path);
     my $collect_conv_file = &util::filename_within_collection($conv_filename);
-    $doc_obj->set_source_filename ($collect_file); 
+    $doc_obj->set_source_filename ($collect_file, $self->{'file_rename_method'}); 
     $doc_obj->set_converted_filename($collect_conv_file);
 
Index: /gsdl/trunk/perllib/plugins/HTMLPlugin.pm
===================================================================
--- /gsdl/trunk/perllib/plugins/HTMLPlugin.pm	(revision 18319)
+++ /gsdl/trunk/perllib/plugins/HTMLPlugin.pm	(revision 18320)
@@ -635,5 +635,5 @@
 # Given a filename in any encoding, will URL decode it to get back the original filename
 # in the original encoding. Because this method is intended to work out the *original* 
-# filename*, it not URL decode any filename if a file by the name of the *URL-encoded*
+# filename*, it does not URL decode any filename if a file by the name of the *URL-encoded*
 # string already exists in the local folder.
 # Return the original filename corresponding to the parameter URL-encoded filename, and
@@ -1140,7 +1140,7 @@
 	}
 
-	# Make sure this name uses only ASCII characters 
-	# => use URL encoding, as it preserves original encoding
-	$newname = &unicode::url_encode($newname);
+	# Make sure this name uses only ASCII characters. 
+	# We use either base64 or URL encoding, as these preserve original encoding
+	$newname = &util::rename_file($newname, $self->{'file_rename_method'});
 
 	$doc_obj->associate_file($filename, $newname, undef, $section);
Index: /gsdl/trunk/perllib/plugins/ImagePlugin.pm
===================================================================
--- /gsdl/trunk/perllib/plugins/ImagePlugin.pm	(revision 18319)
+++ /gsdl/trunk/perllib/plugins/ImagePlugin.pm	(revision 18320)
@@ -114,5 +114,5 @@
     if ($self->{'image_conversion_available'} == 1) {
 	my $utf8_filename_no_path = $self->filepath_to_utf8($filename_no_path);
-	my $url_encoded_filename = &unicode::url_encode($utf8_filename_no_path);
+	my $url_encoded_filename = &util::rename_file($utf8_filename_no_path, $self->{'file_rename_method'});
 	$self->generate_images($filename_full_path, $url_encoded_filename, $doc_obj, $doc_obj->get_top_section()); # should we check the return value?
     } else {
Index: /gsdl/trunk/perllib/plugins/MP3Plugin.pm
===================================================================
--- /gsdl/trunk/perllib/plugins/MP3Plugin.pm	(revision 18319)
+++ /gsdl/trunk/perllib/plugins/MP3Plugin.pm	(revision 18320)
@@ -60,5 +60,12 @@
 	'desc' => "{MP3Plugin.metadata_fields}",
 	'type' => "string",
-	'deft' => "Title,Artist,Genre" } ];
+	'deft' => "Title,Artist,Genre" },
+      { 'name' => "file_rename_method",
+	'desc' => "{BasePlugin.file_rename_method}",
+	'type' => "enum",
+	'deft' => &get_default_file_rename_method(), # by default rename imported files and assoc files using this encoding
+	'list' => $BasePlugin::file_rename_method_list,
+	'reqd' => "no"
+      } ];
 
 my $options = { 'name'     => "MP3Plugin",
@@ -83,4 +90,13 @@
 sub get_default_process_exp {
     return q^(?i)\.mp3$^;
+}
+
+# rename imported files and assoc files using base64 encoding by default
+# so that the urls generated will always work with media files even when
+# opened in external applications (when wmv file names contain spaces in
+# them and they get url-encoded, wmv player fails to open the doubly url-
+# encoded url reference to the url-encoded filename). 
+sub get_default_file_rename_method() {
+    return "base64";
 }
 
Index: /gsdl/trunk/perllib/plugins/OggVorbisPlugin.pm
===================================================================
--- /gsdl/trunk/perllib/plugins/OggVorbisPlugin.pm	(revision 18319)
+++ /gsdl/trunk/perllib/plugins/OggVorbisPlugin.pm	(revision 18320)
@@ -51,5 +51,12 @@
 	'desc' => "{OggVorbisPlugin.add_technical_metadata}",
 	'type' => "flag",
-	'deft' => "" } ];
+	'deft' => "" }, 
+      { 'name' => "file_rename_method",
+	'desc' => "{BasePlugin.file_rename_method}",
+	'type' => "enum",
+	'deft' => &get_default_file_rename_method(), # by default rename imported files and assoc files using this encoding
+	'list' => $BasePlugin::file_rename_method_list,
+	'reqd' => "no"
+      } ];
 
 my $options = { 'name'     => "OggVorbisPlugin",
@@ -66,4 +73,9 @@
 }
 
+# rename imported media files using base64 encoding by default
+# so that the urls generated will always work with external apps
+sub get_default_file_rename_method() {
+    return "base64";
+}
 
 sub new
Index: /gsdl/trunk/perllib/plugins/ReadTextFile.pm
===================================================================
--- /gsdl/trunk/perllib/plugins/ReadTextFile.pm	(revision 18319)
+++ /gsdl/trunk/perllib/plugins/ReadTextFile.pm	(revision 18320)
@@ -133,5 +133,5 @@
 
     # create a new document
-    my $doc_obj = new doc ($filename_full_path, "indexed_doc");
+    my $doc_obj = new doc ($filename_full_path, "indexed_doc", $self->{'file_rename_method'});
     my $top_section = $doc_obj->get_top_section();
 
