Mercurial > libervia-backend
comparison frontends/src/primitivus/chat.py @ 1180:69aace10b46d
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
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 08 Sep 2014 15:50:51 +0200 |
parents | cae023216bba |
children | 6184779544c7 |
comparison
equal
deleted
inserted
replaced
1179:9a85836f0d45 | 1180:69aace10b46d |
---|---|
16 | 16 |
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat.core import log as logging | |
22 log = logging.getLogger(__name__) | |
21 import urwid | 23 import urwid |
22 from urwid_satext import sat_widgets | 24 from urwid_satext import sat_widgets |
23 from urwid_satext.files_management import FileDialog | 25 from urwid_satext.files_management import FileDialog |
24 from sat_frontends.quick_frontend.quick_chat import QuickChat | 26 from sat_frontends.quick_frontend.quick_chat import QuickChat |
25 from sat_frontends.primitivus.card_game import CardGame | 27 from sat_frontends.primitivus.card_game import CardGame |
383 self.host.showPopUp(dialog, 80, 80) | 385 self.host.showPopUp(dialog, 80, 80) |
384 | 386 |
385 #MISC EVENTS# | 387 #MISC EVENTS# |
386 def onFileSelected(self, filepath): | 388 def onFileSelected(self, filepath): |
387 self.host.removePopUp() | 389 self.host.removePopUp() |
390 try: | |
391 filepath = filepath.decode('utf-8') # FIXME: correctly manage unicode | |
392 except UnicodeError: | |
393 log.error("FIXME: filepath with unicode error are not managed yet") | |
394 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") | |
395 return | |
388 #FIXME: check last_resource: what if self.target.resource exists ? | 396 #FIXME: check last_resource: what if self.target.resource exists ? |
389 last_resource = self.host.bridge.getLastResource(unicode(self.target.bare), self.host.profile) | 397 last_resource = self.host.bridge.getLastResource(unicode(self.target.bare), self.host.profile) |
390 if last_resource: | 398 if last_resource: |
391 full_jid = JID("%s/%s" % (self.target.bare, last_resource)) | 399 full_jid = JID("%s/%s" % (self.target.bare, last_resource)) |
392 else: | 400 else: |
393 full_jid = self.target | 401 full_jid = self.target |
394 progress_id = self.host.bridge.sendFile(full_jid, filepath, {}, self.host.profile) | 402 progress_id = self.host.bridge.sendFile(full_jid, filepath, {}, self.host.profile) |
395 self.host.addProgress(progress_id,filepath) | 403 self.host.addProgress(progress_id,filepath) |
404 self.host.showDialog(_(u"You file request has been sent, we are waiting for your contact answer"), title=_("File request sent")) |