Fix encoding issue with UTF-8 filenames (Maemo bug 11811)

Conflicts:

	src/gpodder/gui.py
This commit is contained in:
Thomas Perl 2011-02-25 16:33:01 +01:00
parent 1174ec69dc
commit fb2f181757
3 changed files with 11 additions and 5 deletions

View File

@ -231,7 +231,7 @@ class MafwPlaybackMonitor(object):
# XXX: WTF?
pass
self._start_time = time.time()
self._player.PlaybackStarted(self._start_position, self._filename)
self._player.PlaybackStarted(self._start_position, self._filename.decode('utf-8'))
else:
if self._is_playing:
try:
@ -248,7 +248,7 @@ class MafwPlaybackMonitor(object):
position = self._start_position + (time.time()-self._start_time)
if self._start_position != position:
self._player.PlaybackStopped(self._start_position, \
position, self._duration, self._filename)
position, self._duration, self._filename.decode('utf-8'))
self._is_playing = False
self._resume_handler.on_state_changed(state)

View File

@ -534,9 +534,9 @@ class gPodder(BuilderWidget, dbus.service.Object):
URL (e.g. from external D-Bus calls / signals, etc..)
"""
if uri.startswith('/'):
uri = 'file://' + uri
uri = 'file://' + urllib.quote(uri)
prefix = 'file://' + gpodder.downloads
prefix = 'file://' + urllib.quote(gpodder.downloads)
if uri.startswith(prefix):
# File is on the local filesystem in the download folder

View File

@ -32,6 +32,7 @@ except ImportError:
from gpodder.gui import dbus
import gpodder
import urllib
class MediaPlayerDBusReceiver(object):
INTERFACE = 'org.gpodder.player'
@ -57,7 +58,12 @@ class MediaPlayerDBusReceiver(object):
pass
def on_playback_stopped(self, start, end, total, file_uri):
# Assume the URI comes as quoted UTF-8 string, so decode
# it first to utf-8 (should be no problem) for unquoting
# to work correctly on this later on (Maemo bug 11811)
if isinstance(file_uri, unicode):
file_uri = file_uri.encode('utf-8')
if file_uri.startswith('/'):
file_uri = 'file://' + file_uri
file_uri = 'file://' + urllib.quote(file_uri)
self.on_play_event(start, end, total, file_uri)