MUC: Use NewConfirmationDialog for file transfer

This commit is contained in:
Philipp Hörist 2019-03-27 23:32:40 +01:00
parent 2080495efc
commit f838c2faa2
2 changed files with 34 additions and 24 deletions

View File

@ -51,7 +51,8 @@ from gajim.message_control import MessageControl
from gajim.conversation_textview import ConversationTextview from gajim.conversation_textview import ConversationTextview
from gajim.message_textview import MessageTextView from gajim.message_textview import MessageTextView
from gajim.gtk.dialogs import NonModalConfirmationDialog from gajim.gtk.dialogs import NewConfirmationDialog
from gajim.gtk.dialogs import DialogButton
from gajim.gtk import util from gajim.gtk import util
from gajim.gtk.util import convert_rgb_to_hex from gajim.gtk.util import convert_rgb_to_hex
from gajim.gtk.util import at_the_end from gajim.gtk.util import at_the_end
@ -1045,26 +1046,35 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
self.account, c) self.account, c)
if self.type_id == message_control.TYPE_PM: if self.type_id == message_control.TYPE_PM:
gc_contact = self.gc_contact gc_contact = self.gc_contact
if gc_contact:
if not gc_contact:
_on_ok(self.contact)
return
# gc or pm # gc or pm
gc_control = app.interface.msg_win_mgr.get_gc_control( gc_control = app.interface.msg_win_mgr.get_gc_control(
gc_contact.room_jid, self.account) gc_contact.room_jid, self.account)
self_contact = app.contacts.get_gc_contact(self.account, self_contact = app.contacts.get_gc_contact(self.account,
gc_control.room_jid, gc_control.nick) gc_control.room_jid,
if gc_control.is_anonymous and gc_contact.affiliation.value not in ['admin', gc_control.nick)
'owner'] and self_contact.affiliation.value in ['admin', 'owner']: if (gc_control.is_anonymous and
gc_contact.affiliation.value not in ['admin', 'owner'] and
self_contact.affiliation.value in ['admin', 'owner']):
contact = app.contacts.get_contact(self.account, gc_contact.jid) contact = app.contacts.get_contact(self.account, gc_contact.jid)
if not contact or contact.sub not in ('both', 'to'): if not contact or contact.sub not in ('both', 'to'):
prim_text = _('Really send file?')
sec_text = _('If you send a file to %s, your real JID will ' NewConfirmationDialog(
'be revealed.') % gc_contact.name _('Privacy'),
dialog = NonModalConfirmationDialog(prim_text, _('Warning'),
sec_text, on_response_ok=(_on_ok, gc_contact)) _('If you send a file to <b>%s</b>, '
dialog.popup() 'your real JID will be revealed.' % gc_contact.name),
[DialogButton.make('Cancel'),
DialogButton.make(
'OK',
text=_('Continue'),
callback=lambda: _on_ok(gc_contact))]).show()
return return
_on_ok(gc_contact) _on_ok(gc_contact)
return
_on_ok(self.contact)
def on_notify_menuitem_toggled(self, widget): def on_notify_menuitem_toggled(self, widget):
app.config.set_per('rooms', self.contact.jid, 'notify_on_all_messages', app.config.set_per('rooms', self.contact.jid, 'notify_on_all_messages',

View File

@ -2786,12 +2786,12 @@ class GroupchatControl(ChatControlBase):
self.handlers[id_] = item self.handlers[id_] = item
item = xml.get_object('send_file_menuitem') item = xml.get_object('send_file_menuitem')
if not c.resource: if not c.jid:
item.set_sensitive(False) item.set_sensitive(False)
else: else:
item.set_sensitive(False) item.set_sensitive(True)
# ToDo: integrate HTTP File Upload # ToDo: integrate HTTP File Upload
id_ = item.connect('activate', self._on_send_file_jingle, c) id_ = item.connect('activate', lambda x: self._on_send_file_jingle(c))
self.handlers[id_] = item self.handlers[id_] = item
# show the popup now! # show the popup now!