Mercurial > libervia-backend
comparison frontends/src/primitivus/primitivus @ 542:3eeb6c865e4d
frontends: incoming files transfer management:
- quick app: getWaitingConf is used on profile connexion
- primitivus: askConfirmation is now managed, use new 'dir' style of FileDialog
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 14 Nov 2012 20:37:15 +0100 |
parents | 6c07127ad2ed |
children | 9dd297c513b4 |
comparison
equal
deleted
inserted
replaced
541:8b116fa42a31 | 542:3eeb6c865e4d |
---|---|
20 """ | 20 """ |
21 | 21 |
22 | 22 |
23 import urwid | 23 import urwid |
24 from urwid_satext import sat_widgets | 24 from urwid_satext import sat_widgets |
25 from urwid_satext.files_management import FileDialog | |
25 from sat_frontends.quick_frontend.quick_app import QuickApp | 26 from sat_frontends.quick_frontend.quick_app import QuickApp |
26 from sat_frontends.quick_frontend.quick_chat_list import QuickChatList | 27 from sat_frontends.quick_frontend.quick_chat_list import QuickChatList |
28 from sat_frontends.quick_frontend.quick_utils import getNewPath | |
27 from sat_frontends.primitivus.profile_manager import ProfileManager | 29 from sat_frontends.primitivus.profile_manager import ProfileManager |
28 from sat_frontends.primitivus.contact_list import ContactList | 30 from sat_frontends.primitivus.contact_list import ContactList |
29 from sat_frontends.primitivus.chat import Chat | 31 from sat_frontends.primitivus.chat import Chat |
30 from sat_frontends.primitivus.gateways import GatewaysManager | 32 from sat_frontends.primitivus.gateways import GatewaysManager |
31 from sat_frontends.primitivus.xmlui import XMLUI | 33 from sat_frontends.primitivus.xmlui import XMLUI |
33 from sat_frontends.primitivus.notify import Notify | 35 from sat_frontends.primitivus.notify import Notify |
34 import sat_frontends.primitivus.constants | 36 import sat_frontends.primitivus.constants |
35 import logging | 37 import logging |
36 from logging import debug, info, error | 38 from logging import debug, info, error |
37 from sat.tools.jid import JID | 39 from sat.tools.jid import JID |
40 from os.path import join | |
38 | 41 |
39 | 42 |
40 ### logging configuration FIXME: put this elsewhere ### | 43 ### logging configuration FIXME: put this elsewhere ### |
41 logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file | 44 logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file |
42 format='%(message)s') | 45 format='%(message)s') |
391 error(_("INTERNAL ERROR: Unexpected class for main widget's footer")) | 394 error(_("INTERNAL ERROR: Unexpected class for main widget's footer")) |
392 assert(False) | 395 assert(False) |
393 if self.notBar.canHide(): | 396 if self.notBar.canHide(): |
394 #No notification left, we can hide the bar | 397 #No notification left, we can hide the bar |
395 self.main_widget.footer = self.editBar | 398 self.main_widget.footer = self.editBar |
399 | |
400 def askConfirmation(self, confirmation_id, confirmation_type, data, profile): | |
401 if not self.check_profile(profile): | |
402 return | |
403 answer_data={} | |
404 | |
405 def dir_selected_cb(path): | |
406 dest_path = join(path, data['filename']) | |
407 answer_data["dest_path"] = getNewPath(dest_path) | |
408 self.addProgress(confirmation_id, dest_path) | |
409 accept_cb(None) | |
410 | |
411 def accept_file_transfer_cb(widget): | |
412 self.removePopUp() | |
413 pop_up_widget = FileDialog(dir_selected_cb, refuse_cb, title=_(u"Where do you want to save the file ?"), style=['dir']) | |
414 self.showPopUp(pop_up_widget) | |
415 | |
416 def accept_cb(widget): | |
417 self.removePopUp() | |
418 self.bridge.confirmationAnswer(confirmation_id, True, answer_data, profile) | |
419 | |
420 def refuse_cb(widget): | |
421 self.removePopUp() | |
422 self.bridge.confirmationAnswer(confirmation_id, False, answer_data, profile) | |
423 | |
424 if confirmation_type == "FILE_TRANSFER": | |
425 pop_up_widget = sat_widgets.ConfirmDialog(_("The contact %(jid)s wants to send you the file %(filename)s\nDo you accept ?") % {'jid':data["from"], 'filename':data["filename"]}, no_cb=refuse_cb, yes_cb=accept_file_transfer_cb) | |
426 self.showPopUp(pop_up_widget) | |
427 | |
428 elif confirmation_type == "YES/NO": | |
429 pop_up_widget = sat_widgets.ConfirmDialog(data["message"], no_cb=refuse_cb, yes_cb=accept_cb) | |
430 self.showPopUp(pop_up_widget) | |
396 | 431 |
397 def actionResult(self, type, id, data): | 432 def actionResult(self, type, id, data): |
398 if not id in self.current_action_ids: | 433 if not id in self.current_action_ids: |
399 debug (_('unknown id, ignoring')) | 434 debug (_('unknown id, ignoring')) |
400 return | 435 return |