native gtk on osx seems to like to send file uri's like
'file://localhost/usr/bin/foo'. rip out the host and check the uri's for valid before asking the user to send the files.
This commit is contained in:
parent
aa3932f147
commit
f995b3268e
2 changed files with 15 additions and 2 deletions
|
@ -506,7 +506,11 @@ def get_file_path_from_dnd_dropped_uri(uri):
|
||||||
if path.startswith('file:\\\\\\'): # windows
|
if path.startswith('file:\\\\\\'): # windows
|
||||||
path = path[8:] # 8 is len('file:///')
|
path = path[8:] # 8 is len('file:///')
|
||||||
elif path.startswith('file://'): # nautilus, rox
|
elif path.startswith('file://'): # nautilus, rox
|
||||||
path = path[7:] # 7 is len('file://')
|
if sys.platform == 'darwin':
|
||||||
|
# OS/X includes hostname in file:// URI
|
||||||
|
path = re.sub('file://[^/]*', '', path)
|
||||||
|
else:
|
||||||
|
path = path[7:] # 7 is len('file://')
|
||||||
elif path.startswith('file:'): # xffm
|
elif path.startswith('file:'): # xffm
|
||||||
path = path[5:] # 5 is len('file:')
|
path = path[5:] # 5 is len('file:')
|
||||||
return path
|
return path
|
||||||
|
|
|
@ -5018,6 +5018,15 @@ class RosterWindow:
|
||||||
uri = data.strip()
|
uri = data.strip()
|
||||||
uri_splitted = uri.split() # we may have more than one file dropped
|
uri_splitted = uri.split() # we may have more than one file dropped
|
||||||
nb_uri = len(uri_splitted)
|
nb_uri = len(uri_splitted)
|
||||||
|
# Check the URIs
|
||||||
|
bad_uris = []
|
||||||
|
for a_uri in uri_splitted:
|
||||||
|
path = helpers.get_file_path_from_dnd_dropped_uri(a_uri)
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
bad_uris.append(a_uri)
|
||||||
|
if len(bad_uris):
|
||||||
|
dialogs.ErrorDialog(_('Invalid file URI:'), '\n'.join(bad_uris))
|
||||||
|
return
|
||||||
def _on_send_files(account, jid, uris):
|
def _on_send_files(account, jid, uris):
|
||||||
c = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
c = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
for uri in uris:
|
for uri in uris:
|
||||||
|
@ -5027,7 +5036,7 @@ class RosterWindow:
|
||||||
account, c, path)
|
account, c, path)
|
||||||
# Popup dialog to confirm sending
|
# Popup dialog to confirm sending
|
||||||
prim_text = 'Send file?'
|
prim_text = 'Send file?'
|
||||||
sec_text = i18n.ngettext('Do you want to send that file to %s:',
|
sec_text = i18n.ngettext('Do you want to send this file to %s:',
|
||||||
'Do you want to send those files to %s:', nb_uri) %\
|
'Do you want to send those files to %s:', nb_uri) %\
|
||||||
c_dest.get_shown_name()
|
c_dest.get_shown_name()
|
||||||
for uri in uri_splitted:
|
for uri in uri_splitted:
|
||||||
|
|
Loading…
Add table
Reference in a new issue