From 56e0c6f3c3cd02b60e848059a74048f0d334feef Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Sun, 14 Aug 2005 19:08:56 +0000 Subject: [PATCH] drop from xffm to gajim tab now works --- src/common/helpers.py | 11 +++++++++++ src/tabbed_chat_window.py | 10 ++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/common/helpers.py b/src/common/helpers.py index 2bffbdc82..be990b14d 100644 --- a/src/common/helpers.py +++ b/src/common/helpers.py @@ -19,6 +19,7 @@ import sre import os +import urllib import gajim from common import i18n @@ -260,3 +261,13 @@ def play_sound(event): command = player + ' "' + path_to_soundfile + '" &' #FIXME: when we require 2.4+ use subprocess module os.system(command) + +def get_file_path_from_dnd_dropped_uri(uri): + path = urllib.url2pathname(uri) # escape special chars + path = path.strip('\r\n\x00') # remove \r\n and NULL + # get the path to file + if path.startswith('file://'): # nautilus, rox + path = path[7:] # 7 is len('file://') + elif path.startswith('file:'): # xffm + path = path[5:] # 5 is len('file:') + return path diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py index 6106b5b8b..861c782c9 100644 --- a/src/tabbed_chat_window.py +++ b/src/tabbed_chat_window.py @@ -106,12 +106,10 @@ class TabbedChatWindow(chat.Chat): timestamp, contact): if target_type == self.TARGET_TYPE_URI_LIST: uri = selection.data.strip() - path = urllib.url2pathname(uri) # escape special chars - if path.startswith('file://'): # get the path to file - path = path[7:] # 7 is len('file://') - if os.path.isfile(path): # is it file? - self.plugin.windows['file_transfers'].send_file(self.account, - contact, path) + path = helpers.get_file_path_from_dnd_dropped_uri(uri) + if os.path.isfile(path): # is it file? + self.plugin.windows['file_transfers'].send_file(self.account, + contact, path) def draw_widgets(self, contact): """draw the widgets in a tab (status_image, contact_button ...)