Commit 216eae42 authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist

ChatControl: Add menu item for blocking/reporting

parent 1448b59b
......@@ -251,8 +251,9 @@ class ChatControl(ChatControlBase):
actions = [
('invite-contacts-', self._on_invite_contacts),
('add-to-roster-', self._on_add_to_roster),
('block-contact-', self._on_block_contact),
('information-', self._on_information),
]
]
for action in actions:
action_name, func = action
......@@ -300,6 +301,11 @@ class ChatControl(ChatControlBase):
win.lookup_action(
'add-to-roster-' + self.control_id).set_enabled(False)
# Block contact
win.lookup_action(
'block-contact-' + self.control_id).set_enabled(
online and con.get_module('Blocking').supported)
# Audio
win.lookup_action('toggle-audio-' + self.control_id).set_enabled(
online and self.jingle['audio'].available)
......@@ -376,6 +382,33 @@ class ChatControl(ChatControlBase):
def _on_add_to_roster(self, _action, _param):
AddNewContactWindow(self.account, self.contact.jid)
def _on_block_contact(self, _action, _param):
def _block_contact(report=None):
con = app.connections[self.account]
con.get_module('Blocking').block([self.contact.jid], report=report)
self.parent_win.remove_tab(self, None, force=True)
if _('Not in contact list') in self.contact.get_shown_groups():
app.interface.roster.remove_contact(
self.contact.jid, self.account, force=True, backend=True)
return
app.interface.roster.draw_contact(self.contact.jid, self.account)
NewConfirmationDialog(
_('Block Contact'),
_('Really block this contact?'),
_('You will appear offline for this contact and you will '
'not receive further messages.'),
[DialogButton.make('Cancel'),
DialogButton.make('OK',
text=_('_Report Spam'),
callback=_block_contact,
kwargs={'report': 'spam'}),
DialogButton.make('Remove',
text=_('_Block'),
callback=_block_contact)],
modal=False).show()
def _on_information(self, _action, _param):
app.interface.roster.on_info(None, self.contact, self.account)
......
......@@ -522,6 +522,7 @@ def get_singlechat_menu(control_id, account, jid):
(_('Send Chatstate'), ['chatstate']),
('win.invite-contacts-', _('Invite Contacts…')),
('win.add-to-roster-', _('Add to Contact List…')),
('win.block-contact-', _('Block Contact…')),
('win.toggle-audio-', _('Voice Chat')),
('win.toggle-video-', _('Video Chat')),
('win.information-', _('Information')),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment