Primitivus (file transfer): an error popup is shown when bad unicode is used in path, and an info popup is show to indicate that the file request has been sent

This commit is contained in:
Goffi 2014-09-08 15:50:51 +02:00
commit 9a04bc6d32

View file

@ -18,6 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from sat.core.i18n import _
from sat.core import log as logging
log = logging.getLogger(__name__)
import urwid
from urwid_satext import sat_widgets
from urwid_satext.files_management import FileDialog
@ -385,6 +387,12 @@ class Chat(urwid.WidgetWrap, QuickChat):
#MISC EVENTS#
def onFileSelected(self, filepath):
self.host.removePopUp()
try:
filepath = filepath.decode('utf-8') # FIXME: correctly manage unicode
except UnicodeError:
log.error("FIXME: filepath with unicode error are not managed yet")
self.host.showDialog(_(u"File has a unicode error in its name, it's not yet managed by SàT"), title=_("Can't send file"), type_="error")
return
#FIXME: check last_resource: what if self.target.resource exists ?
last_resource = self.host.bridge.getLastResource(unicode(self.target.bare), self.host.profile)
if last_resource:
@ -393,3 +401,4 @@ class Chat(urwid.WidgetWrap, QuickChat):
full_jid = self.target
progress_id = self.host.bridge.sendFile(full_jid, filepath, {}, self.host.profile)
self.host.addProgress(progress_id,filepath)
self.host.showDialog(_(u"You file request has been sent, we are waiting for your contact answer"), title=_("File request sent"))