Commit 635ead6e authored by Saul Ibarra's avatar Saul Ibarra

Fixed handling unicode in user's home directory

parent 74784843
......@@ -8,6 +8,7 @@ __all__ = ['ApplicationDataPath', 'DefaultPath', 'SoundFile', 'CustomSoundFile',
import os
import re
from urllib import pathname2url, url2pathname
from urlparse import urlparse
......@@ -140,7 +141,7 @@ InvalidToken = AuthorizationToken() # a valid token is never empty
class FileURL(unicode):
def __new__(cls, value):
if not value.startswith('file:'):
value = 'file:' + pathname2url(os.path.abspath(value))
value = 'file:' + pathname2url(os.path.abspath(value).encode('utf-8')).decode('utf-8')
return unicode.__new__(cls, value)
......
......@@ -43,7 +43,7 @@ class ChatSettingsExtension(ChatSettings):
class FileTransferSettingsExtension(FileTransferSettings):
directory = Setting(type=Path, default=Path(os.path.expanduser('~/Downloads')))
directory = Setting(type=Path, default=Path('~/Downloads'))
class GoogleContactsSettings(SettingsGroup):
......@@ -115,7 +115,7 @@ class ChatWindowSettings(SettingsGroup):
class BlinkScreenSharingSettings(SettingsGroup):
screenshots_directory = Setting(type=Path, default=Path(os.path.expanduser('~/Downloads')))
screenshots_directory = Setting(type=Path, default=Path('~/Downloads'))
scale = Setting(type=bool, default=True)
open_fullscreen = Setting(type=bool, default=False)
open_viewonly = Setting(type=bool, default=False)
......
......@@ -20,6 +20,7 @@ from zope.interface import implements
from sipsimple.account import Account, AccountManager, BonjourAccount
from sipsimple.application import SIPApplication
from sipsimple.configuration.datatypes import Path
from sipsimple.configuration.settings import SIPSimpleSettings
from blink.aboutpanel import AboutPanel
......@@ -76,7 +77,7 @@ class MainWindow(base_class, ui_class):
self.default_icon_path = Resources.get('icons/default-avatar.png')
self.default_icon = QIcon(self.default_icon_path)
self.last_icon_directory = os.path.expanduser('~')
self.last_icon_directory = Path('~').normalized
self.set_user_icon(icon_manager.get('avatar'))
self.active_sessions_label.hide()
......
......@@ -20,7 +20,7 @@ from zope.interface import implements
from sipsimple.account import AccountManager, BonjourAccount
from sipsimple.application import SIPApplication
from sipsimple.configuration import DefaultValue
from sipsimple.configuration.datatypes import MSRPRelayAddress, PortRange, SIPProxyAddress
from sipsimple.configuration.datatypes import MSRPRelayAddress, Path, PortRange, SIPProxyAddress
from sipsimple.configuration.settings import SIPSimpleSettings
from sipsimple.threading import run_in_thread
......@@ -1128,7 +1128,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_AccountTLSCertFileBrowseButtonClicked(self, checked):
# TODO: open the file selection dialog in non-modal mode (and the error messages boxes as well). -Dan
account = self.selected_account
directory = os.path.dirname(account.tls.certificate.normalized) if account.tls.certificate else os.path.expanduser('~')
directory = os.path.dirname(account.tls.certificate.normalized) if account.tls.certificate else Path('~').normalized
cert_path = QFileDialog.getOpenFileName(self, u'Select Certificate File', directory, u"TLS certificates (*.crt *.pem)") or None
if cert_path is not None:
cert_path = os.path.normpath(cert_path)
......@@ -1306,7 +1306,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_ScreenshotsDirectoryBrowseButtonClicked(self, checked):
# TODO: open the file selection dialog in non-modal mode. Same for the one for TLS CA list and the IconSelector from contacts. -Dan
settings = BlinkSettings()
directory = settings.screen_sharing.screenshots_directory or os.path.expanduser('~')
directory = settings.screen_sharing.screenshots_directory.normalized
directory = QFileDialog.getExistingDirectory(self, u'Select Screenshots Directory', directory) or None
if directory is not None:
directory = os.path.normpath(directory)
......@@ -1334,7 +1334,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_DownloadDirectoryBrowseButtonClicked(self, checked):
# TODO: open the file selection dialog in non-modal mode. Same for the one for TLS CA list and the IconSelector from contacts. -Dan
settings = SIPSimpleSettings()
directory = settings.file_transfer.directory or os.path.expanduser('~')
directory = settings.file_transfer.directory.normalized
directory = QFileDialog.getExistingDirectory(self, u'Select Download Directory', directory) or None
if directory is not None:
directory = os.path.normpath(directory)
......@@ -1465,7 +1465,7 @@ class PreferencesWindow(base_class, ui_class):
def _SH_TLSCAFileBrowseButtonClicked(self):
# TODO: open the file selection dialog in non-modal mode (and the error messages boxes as well). -Dan
settings = SIPSimpleSettings()
directory = os.path.dirname(settings.tls.ca_list.normalized) if settings.tls.ca_list else os.path.expanduser('~')
directory = os.path.dirname(settings.tls.ca_list.normalized) if settings.tls.ca_list else Path('~').normalized
ca_path = QFileDialog.getOpenFileName(self, u'Select Certificate Authority File', directory, u"TLS certificates (*.crt *.pem)") or None
if ca_path is not None:
ca_path = os.path.normpath(ca_path)
......
......@@ -18,6 +18,7 @@ from application.python.types import Singleton
from application.system import makedirs, unlink
from threading import Event
from sipsimple.configuration.datatypes import Path
from blink.util import run_in_gui_thread
......@@ -43,7 +44,7 @@ class ApplicationData(object):
elif platform.system() == 'Windows':
cls._cached_directory = os.path.join(os.environ['APPDATA'], 'Blink').decode(sys.getfilesystemencoding())
else:
cls._cached_directory = os.path.expanduser('~/.blink').decode(sys.getfilesystemencoding())
cls._cached_directory = Path('~/.blink').normalized
return DirectoryContextManager(cls._cached_directory)
@classmethod
......
......@@ -34,6 +34,7 @@ from zope.interface import implements
from sipsimple.account import Account, AccountManager, BonjourAccount
from sipsimple.application import SIPApplication
from sipsimple.audio import AudioConference, WavePlayer
from sipsimple.configuration.datatypes import Path
from sipsimple.configuration.settings import SIPSimpleSettings
from sipsimple.core import SIPCoreError, SIPURI, ToHeader
from sipsimple.lookup import DNSLookup
......@@ -5120,7 +5121,7 @@ class SessionManager(object):
self.dialog_positions = range(1, 100)
self.file_transfers = []
self.last_dialed_uri = None
self.send_file_directory = os.path.expanduser('~')
self.send_file_directory = Path('~').normalized
self.active_session = None
self.inbound_ringtone = Null
......
......@@ -11,6 +11,8 @@ from PyQt4.QtGui import QAction, QBrush, QColor, QFileDialog, QFontMetrics, QIco
from application.python.types import MarkerType
from sipsimple.configuration.datatypes import Path
from blink.resources import IconManager
from blink.widgets.color import ColorHelperMixin
from blink.widgets.util import QtDynamicProperty, ContextMenuActions
......@@ -32,7 +34,7 @@ class IconSelector(QLabel):
self.contact_icon = None
self.icon = None
self.filename = self.NotSelected
self.last_icon_directory = os.path.expanduser('~')
self.last_icon_directory = Path('~').normalized
def _get_icon(self):
return self.__dict__['icon']
......
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