Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
429f108e
by Philipp Hörist at 2019-11-12T18:48:35Z
-
b9f0ea9a
by Philipp Hörist at 2019-11-12T19:12:50Z
-
d3ab2efe
by Philipp Hörist at 2019-11-12T19:30:29Z
-
6ea3e539
by Philipp Hörist at 2019-11-12T19:41:12Z
-
1f8ecb58
by Philipp Hörist at 2019-11-12T19:42:48Z
3 changed files:
Changes:
| ... | ... | @@ -34,9 +34,14 @@ from gi.repository import Gio |
| 34 | 34 |
from gi.repository import Pango
|
| 35 | 35 |
from gi.repository import GLib
|
| 36 | 36 |
from gi.repository import Gdk
|
| 37 |
-from nbxmpp.protocol import NS_XHTML_IM, NS_FILE, NS_MUC
|
|
| 38 |
-from nbxmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO
|
|
| 39 |
-from nbxmpp.protocol import NS_JINGLE_ICE_UDP, NS_JINGLE_FILE_TRANSFER_5
|
|
| 37 |
+ |
|
| 38 |
+from nbxmpp.protocol import NS_XHTML_IM
|
|
| 39 |
+from nbxmpp.protocol import NS_FILE
|
|
| 40 |
+from nbxmpp.protocol import NS_MUC
|
|
| 41 |
+from nbxmpp.protocol import NS_JINGLE_RTP_AUDIO
|
|
| 42 |
+from nbxmpp.protocol import NS_JINGLE_RTP_VIDEO
|
|
| 43 |
+from nbxmpp.protocol import NS_JINGLE_ICE_UDP
|
|
| 44 |
+from nbxmpp.protocol import NS_JINGLE_FILE_TRANSFER_5
|
|
| 40 | 45 |
|
| 41 | 46 |
from gajim.common import app
|
| 42 | 47 |
from gajim.common import helpers
|
| ... | ... | @@ -82,11 +87,11 @@ class ChatControl(ChatControlBase): |
| 82 | 87 |
A control for standard 1-1 chat
|
| 83 | 88 |
"""
|
| 84 | 89 |
(
|
| 85 |
- JINGLE_STATE_NULL,
|
|
| 86 |
- JINGLE_STATE_CONNECTING,
|
|
| 87 |
- JINGLE_STATE_CONNECTION_RECEIVED,
|
|
| 88 |
- JINGLE_STATE_CONNECTED,
|
|
| 89 |
- JINGLE_STATE_ERROR
|
|
| 90 |
+ JINGLE_STATE_NULL,
|
|
| 91 |
+ JINGLE_STATE_CONNECTING,
|
|
| 92 |
+ JINGLE_STATE_CONNECTION_RECEIVED,
|
|
| 93 |
+ JINGLE_STATE_CONNECTED,
|
|
| 94 |
+ JINGLE_STATE_ERROR
|
|
| 90 | 95 |
) = range(5)
|
| 91 | 96 |
|
| 92 | 97 |
TYPE_ID = message_control.TYPE_CHAT
|
| ... | ... | @@ -97,8 +102,13 @@ class ChatControl(ChatControlBase): |
| 97 | 102 |
COMMAND_HOST = ChatCommands # type: ClassVar[Type[CommandHost]]
|
| 98 | 103 |
|
| 99 | 104 |
def __init__(self, parent_win, contact, acct, session, resource=None):
|
| 100 |
- ChatControlBase.__init__(self, self.TYPE_ID, parent_win,
|
|
| 101 |
- 'chat_control', contact, acct, resource)
|
|
| 105 |
+ ChatControlBase.__init__(self,
|
|
| 106 |
+ self.TYPE_ID,
|
|
| 107 |
+ parent_win,
|
|
| 108 |
+ 'chat_control',
|
|
| 109 |
+ contact,
|
|
| 110 |
+ acct,
|
|
| 111 |
+ resource)
|
|
| 102 | 112 |
|
| 103 | 113 |
self.last_recv_message_id = None
|
| 104 | 114 |
self.last_recv_message_marks = None
|
| ... | ... | @@ -133,13 +143,13 @@ class ChatControl(ChatControlBase): |
| 133 | 143 |
# Hook up signals
|
| 134 | 144 |
widget = self.xml.location_eventbox
|
| 135 | 145 |
id_ = widget.connect('button-release-event',
|
| 136 |
- self.on_location_eventbox_button_release_event)
|
|
| 146 |
+ self.on_location_eventbox_button_release_event)
|
|
| 137 | 147 |
self.handlers[id_] = widget
|
| 138 | 148 |
id_ = widget.connect('enter-notify-event',
|
| 139 |
- self.on_location_eventbox_enter_notify_event)
|
|
| 149 |
+ self.on_location_eventbox_enter_notify_event)
|
|
| 140 | 150 |
self.handlers[id_] = widget
|
| 141 | 151 |
id_ = widget.connect('leave-notify-event',
|
| 142 |
- self.on_location_eventbox_leave_notify_event)
|
|
| 152 |
+ self.on_location_eventbox_leave_notify_event)
|
|
| 143 | 153 |
self.handlers[id_] = widget
|
| 144 | 154 |
|
| 145 | 155 |
for key in ('1', '2', '3', '4', '5', '6', '7', '8', '9', '*', '0', '#'):
|
| ... | ... | @@ -154,7 +164,8 @@ class ChatControl(ChatControlBase): |
| 154 | 164 |
self.handlers[id_] = widget
|
| 155 | 165 |
|
| 156 | 166 |
widget = self.xml.sound_hscale
|
| 157 |
- id_ = widget.connect('value_changed', self.on_sound_hscale_value_changed)
|
|
| 167 |
+ id_ = widget.connect('value_changed',
|
|
| 168 |
+ self.on_sound_hscale_value_changed)
|
|
| 158 | 169 |
self.handlers[id_] = widget
|
| 159 | 170 |
|
| 160 | 171 |
self.info_bar = Gtk.InfoBar()
|
| ... | ... | @@ -188,8 +199,6 @@ class ChatControl(ChatControlBase): |
| 188 | 199 |
session.control = self
|
| 189 | 200 |
self.session = session
|
| 190 | 201 |
|
| 191 |
- # Enable encryption if needed
|
|
| 192 |
- self.no_autonegotiation = False
|
|
| 193 | 202 |
self.add_actions()
|
| 194 | 203 |
self.update_ui()
|
| 195 | 204 |
self.set_lock_image()
|
| ... | ... | @@ -202,41 +211,31 @@ class ChatControl(ChatControlBase): |
| 202 | 211 |
self.restore_conversation()
|
| 203 | 212 |
self.msg_textview.grab_focus()
|
| 204 | 213 |
|
| 205 |
- app.ged.register_event_handler('nickname-received', ged.GUI1,
|
|
| 206 |
- self._on_nickname_received)
|
|
| 207 |
- app.ged.register_event_handler('mood-received', ged.GUI1,
|
|
| 208 |
- self._on_mood_received)
|
|
| 209 |
- app.ged.register_event_handler('activity-received', ged.GUI1,
|
|
| 210 |
- self._on_activity_received)
|
|
| 211 |
- app.ged.register_event_handler('tune-received', ged.GUI1,
|
|
| 212 |
- self._on_tune_received)
|
|
| 213 |
- app.ged.register_event_handler('location-received', ged.GUI1,
|
|
| 214 |
- self._on_location_received)
|
|
| 215 |
- app.ged.register_event_handler('update-client-info', ged.GUI1,
|
|
| 216 |
- self._on_update_client_info)
|
|
| 214 |
+ # pylint: disable=line-too-long
|
|
| 215 |
+ self._event_handlers = [
|
|
| 216 |
+ ('nickname-received', ged.GUI1, self._on_nickname_received),
|
|
| 217 |
+ ('mood-received', ged.GUI1, self._on_mood_received),
|
|
| 218 |
+ ('activity-received', ged.GUI1, self._on_activity_received),
|
|
| 219 |
+ ('tune-received', ged.GUI1, self._on_tune_received),
|
|
| 220 |
+ ('location-received', ged.GUI1, self._on_location_received),
|
|
| 221 |
+ ('update-client-info', ged.GUI1, self._on_update_client_info),
|
|
| 222 |
+ ('chatstate-received', ged.GUI1, self._nec_chatstate_received),
|
|
| 223 |
+ ('caps-update', ged.GUI1, self._nec_caps_received),
|
|
| 224 |
+ ('message-sent', ged.OUT_POSTCORE, self._message_sent),
|
|
| 225 |
+ ('mam-decrypted-message-received', ged.GUI1, self._nec_mam_decrypted_message_received),
|
|
| 226 |
+ ('decrypted-message-received', ged.GUI1, self._nec_decrypted_message_received),
|
|
| 227 |
+ ('receipt-received', ged.GUI1, self._receipt_received),
|
|
| 228 |
+ ('message-error', ged.GUI1, self._on_message_error),
|
|
| 229 |
+ ('zeroconf-error', ged.GUI1, self._on_zeroconf_error),
|
|
| 230 |
+ ]
|
|
| 231 |
+ |
|
| 217 | 232 |
if self.TYPE_ID == message_control.TYPE_CHAT:
|
| 218 | 233 |
# Dont connect this when PrivateChatControl is used
|
| 219 |
- app.ged.register_event_handler('update-roster-avatar', ged.GUI1,
|
|
| 220 |
- self._nec_update_avatar)
|
|
| 221 |
- app.ged.register_event_handler('chatstate-received', ged.GUI1,
|
|
| 222 |
- self._nec_chatstate_received)
|
|
| 223 |
- app.ged.register_event_handler('caps-update', ged.GUI1,
|
|
| 224 |
- self._nec_caps_received)
|
|
| 225 |
- app.ged.register_event_handler('message-sent', ged.OUT_POSTCORE,
|
|
| 226 |
- self._message_sent)
|
|
| 227 |
- app.ged.register_event_handler(
|
|
| 228 |
- 'mam-decrypted-message-received',
|
|
| 229 |
- ged.GUI1, self._nec_mam_decrypted_message_received)
|
|
| 230 |
- app.ged.register_event_handler(
|
|
| 231 |
- 'decrypted-message-received',
|
|
| 232 |
- ged.GUI1, self._nec_decrypted_message_received)
|
|
| 233 |
- app.ged.register_event_handler(
|
|
| 234 |
- 'receipt-received',
|
|
| 235 |
- ged.GUI1, self._receipt_received)
|
|
| 236 |
- app.ged.register_event_handler('message-error',
|
|
| 237 |
- ged.GUI1, self._on_message_error)
|
|
| 238 |
- app.ged.register_event_handler('zeroconf-error', ged.GUI1,
|
|
| 239 |
- self._on_zeroconf_error)
|
|
| 234 |
+ self._event_handlers.append(('update-roster-avatar', ged.GUI1, self._nec_update_avatar))
|
|
| 235 |
+ # pylint: enable=line-too-long
|
|
| 236 |
+ |
|
| 237 |
+ for handler in self._event_handlers:
|
|
| 238 |
+ app.ged.register_event_handler(*handler)
|
|
| 240 | 239 |
|
| 241 | 240 |
# PluginSystem: adding GUI extension point for this ChatControl
|
| 242 | 241 |
# instance object
|
| ... | ... | @@ -317,14 +316,14 @@ class ChatControl(ChatControlBase): |
| 317 | 316 |
jingle_conditions = (
|
| 318 | 317 |
(self.contact.supports(NS_FILE) or
|
| 319 | 318 |
self.contact.supports(NS_JINGLE_FILE_TRANSFER_5)) and
|
| 320 |
- self.contact.show != 'offline')
|
|
| 319 |
+ self.contact.show != 'offline')
|
|
| 321 | 320 |
jingle = win.lookup_action('send-file-jingle-' + self.control_id)
|
| 322 | 321 |
jingle.set_enabled(online and jingle_conditions)
|
| 323 | 322 |
|
| 324 | 323 |
# Send file
|
| 325 | 324 |
win.lookup_action(
|
| 326 | 325 |
'send-file-' + self.control_id).set_enabled(
|
| 327 |
- jingle.get_enabled() or httpupload.get_enabled())
|
|
| 326 |
+ jingle.get_enabled() or httpupload.get_enabled())
|
|
| 328 | 327 |
|
| 329 | 328 |
# Set File Transfer Button tooltip
|
| 330 | 329 |
if online and (httpupload.get_enabled() or jingle.get_enabled()):
|
| ... | ... | @@ -371,13 +370,13 @@ class ChatControl(ChatControlBase): |
| 371 | 370 |
|
| 372 | 371 |
return Gdk.EVENT_PROPAGATE
|
| 373 | 372 |
|
| 374 |
- def _on_add_to_roster(self, action, param):
|
|
| 373 |
+ def _on_add_to_roster(self, _action, _param):
|
|
| 375 | 374 |
AddNewContactWindow(self.account, self.contact.jid)
|
| 376 | 375 |
|
| 377 |
- def _on_information(self, action, param):
|
|
| 376 |
+ def _on_information(self, _action, _param):
|
|
| 378 | 377 |
app.interface.roster.on_info(None, self.contact, self.account)
|
| 379 | 378 |
|
| 380 |
- def _on_invite_contacts(self, action, param):
|
|
| 379 |
+ def _on_invite_contacts(self, _action, _param):
|
|
| 381 | 380 |
"""
|
| 382 | 381 |
User wants to invite some friends to chat
|
| 383 | 382 |
"""
|
| ... | ... | @@ -474,6 +473,7 @@ class ChatControl(ChatControlBase): |
| 474 | 473 |
return self.xml.tune_image
|
| 475 | 474 |
if type_ == PEPEventType.LOCATION:
|
| 476 | 475 |
return self.xml.location_image
|
| 476 |
+ return None
|
|
| 477 | 477 |
|
| 478 | 478 |
@ensure_proper_control
|
| 479 | 479 |
def _on_mood_received(self, _event):
|
| ... | ... | @@ -515,17 +515,17 @@ class ChatControl(ChatControlBase): |
| 515 | 515 |
else:
|
| 516 | 516 |
banner_image.show()
|
| 517 | 517 |
if state == self.JINGLE_STATE_CONNECTING:
|
| 518 |
- banner_image.set_from_icon_name(
|
|
| 519 |
- 'network-transmit-symbolic', Gtk.IconSize.MENU)
|
|
| 518 |
+ banner_image.set_from_icon_name('network-transmit-symbolic',
|
|
| 519 |
+ Gtk.IconSize.MENU)
|
|
| 520 | 520 |
elif state == self.JINGLE_STATE_CONNECTION_RECEIVED:
|
| 521 |
- banner_image.set_from_icon_name(
|
|
| 522 |
- 'network-receive-symbolic', Gtk.IconSize.MENU)
|
|
| 521 |
+ banner_image.set_from_icon_name('network-receive-symbolic',
|
|
| 522 |
+ Gtk.IconSize.MENU)
|
|
| 523 | 523 |
elif state == self.JINGLE_STATE_CONNECTED:
|
| 524 |
- banner_image.set_from_icon_name(
|
|
| 525 |
- 'network-transmit-receive-symbolic', Gtk.IconSize.MENU)
|
|
| 524 |
+ banner_image.set_from_icon_name('network-transmit-receive-symbolic',
|
|
| 525 |
+ Gtk.IconSize.MENU)
|
|
| 526 | 526 |
elif state == self.JINGLE_STATE_ERROR:
|
| 527 |
- banner_image.set_from_icon_name(
|
|
| 528 |
- 'network-error-symbolic', Gtk.IconSize.MENU)
|
|
| 527 |
+ banner_image.set_from_icon_name('network-error-symbolic',
|
|
| 528 |
+ Gtk.IconSize.MENU)
|
|
| 529 | 529 |
self.update_toolbar()
|
| 530 | 530 |
|
| 531 | 531 |
def update_audio(self):
|
| ... | ... | @@ -562,7 +562,7 @@ class ChatControl(ChatControlBase): |
| 562 | 562 |
# update MessageWindow._controls
|
| 563 | 563 |
self.parent_win.change_jid(self.account, old_full_jid, new_full_jid)
|
| 564 | 564 |
|
| 565 |
- def stop_jingle(self, sid=None, reason=None):
|
|
| 565 |
+ def stop_jingle(self, sid=None, _reason=None):
|
|
| 566 | 566 |
if self.audio_sid and sid in (self.audio_sid, None):
|
| 567 | 567 |
self.close_jingle_content('audio')
|
| 568 | 568 |
if self.video_sid and sid in (self.video_sid, None):
|
| ... | ... | @@ -573,20 +573,24 @@ class ChatControl(ChatControlBase): |
| 573 | 573 |
return
|
| 574 | 574 |
if state in ('connecting', 'connected', 'stop', 'error') and reason:
|
| 575 | 575 |
info = _('%(type)s state : %(state)s, reason: %(reason)s') % {
|
| 576 |
- 'type': jingle_type.capitalize(), 'state': state, 'reason': reason}
|
|
| 576 |
+ 'type': jingle_type.capitalize(),
|
|
| 577 |
+ 'state': state,
|
|
| 578 |
+ 'reason': reason}
|
|
| 577 | 579 |
self.add_info_message(info)
|
| 578 | 580 |
|
| 579 | 581 |
states = {'connecting': self.JINGLE_STATE_CONNECTING,
|
| 580 |
- 'connection_received': self.JINGLE_STATE_CONNECTION_RECEIVED,
|
|
| 581 |
- 'connected': self.JINGLE_STATE_CONNECTED,
|
|
| 582 |
- 'stop': self.JINGLE_STATE_NULL,
|
|
| 583 |
- 'error': self.JINGLE_STATE_ERROR}
|
|
| 582 |
+ 'connection_received': self.JINGLE_STATE_CONNECTION_RECEIVED,
|
|
| 583 |
+ 'connected': self.JINGLE_STATE_CONNECTED,
|
|
| 584 |
+ 'stop': self.JINGLE_STATE_NULL,
|
|
| 585 |
+ 'error': self.JINGLE_STATE_ERROR}
|
|
| 584 | 586 |
|
| 585 | 587 |
jingle_state = states[state]
|
| 586 |
- if getattr(self, jingle_type + '_state') == jingle_state or state == 'error':
|
|
| 588 |
+ if (getattr(self, jingle_type + '_state') == jingle_state or
|
|
| 589 |
+ state == 'error'):
|
|
| 587 | 590 |
return
|
| 588 | 591 |
|
| 589 |
- if state == 'stop' and getattr(self, jingle_type + '_sid') not in (None, sid):
|
|
| 592 |
+ if (state == 'stop' and
|
|
| 593 |
+ getattr(self, jingle_type + '_sid') not in (None, sid)):
|
|
| 590 | 594 |
return
|
| 591 | 595 |
|
| 592 | 596 |
setattr(self, jingle_type + '_state', jingle_state)
|
| ... | ... | @@ -596,8 +600,8 @@ class ChatControl(ChatControlBase): |
| 596 | 600 |
if state in ('connection_received', 'connecting'):
|
| 597 | 601 |
setattr(self, jingle_type + '_sid', sid)
|
| 598 | 602 |
|
| 599 |
- v = GLib.Variant.new_boolean(jingle_state != self.JINGLE_STATE_NULL)
|
|
| 600 |
- getattr(self, jingle_type + '_action').change_state(v)
|
|
| 603 |
+ var = GLib.Variant.new_boolean(jingle_state != self.JINGLE_STATE_NULL)
|
|
| 604 |
+ getattr(self, jingle_type + '_action').change_state(var)
|
|
| 601 | 605 |
|
| 602 | 606 |
getattr(self, 'update_' + jingle_type)()
|
| 603 | 607 |
|
| ... | ... | @@ -608,27 +612,28 @@ class ChatControl(ChatControlBase): |
| 608 | 612 |
self._set_jingle_state('video', state, sid=sid, reason=reason)
|
| 609 | 613 |
|
| 610 | 614 |
def _get_audio_content(self):
|
| 611 |
- session = app.connections[self.account].get_module('Jingle').get_jingle_session(
|
|
| 612 |
- self.contact.get_full_jid(), self.audio_sid)
|
|
| 615 |
+ con = app.connections[self.account]
|
|
| 616 |
+ session = con.get_module('Jingle').get_jingle_session(
|
|
| 617 |
+ self.contact.get_full_jid(), self.audio_sid)
|
|
| 613 | 618 |
return session.get_content('audio')
|
| 614 | 619 |
|
| 615 |
- def on_num_button_pressed(self, widget, num):
|
|
| 620 |
+ def on_num_button_pressed(self, _widget, num):
|
|
| 616 | 621 |
self._get_audio_content()._start_dtmf(num)
|
| 617 | 622 |
|
| 618 |
- def on_num_button_released(self, released):
|
|
| 623 |
+ def on_num_button_released(self, _released):
|
|
| 619 | 624 |
self._get_audio_content()._stop_dtmf()
|
| 620 | 625 |
|
| 621 |
- def on_mic_hscale_value_changed(self, widget, value):
|
|
| 626 |
+ def on_mic_hscale_value_changed(self, _widget, value):
|
|
| 622 | 627 |
self._get_audio_content().set_mic_volume(value / 100)
|
| 623 | 628 |
# Save volume to config
|
| 624 | 629 |
app.config.set('audio_input_volume', value)
|
| 625 | 630 |
|
| 626 |
- def on_sound_hscale_value_changed(self, widget, value):
|
|
| 631 |
+ def on_sound_hscale_value_changed(self, _widget, value):
|
|
| 627 | 632 |
self._get_audio_content().set_out_volume(value / 100)
|
| 628 | 633 |
# Save volume to config
|
| 629 | 634 |
app.config.set('audio_output_volume', value)
|
| 630 | 635 |
|
| 631 |
- def on_location_eventbox_button_release_event(self, widget, event):
|
|
| 636 |
+ def on_location_eventbox_button_release_event(self, _widget, _event):
|
|
| 632 | 637 |
if 'geoloc' in self.contact.pep:
|
| 633 | 638 |
location = self.contact.pep['geoloc'].data
|
| 634 | 639 |
if 'lat' in location and 'lon' in location:
|
| ... | ... | @@ -636,14 +641,14 @@ class ChatControl(ChatControlBase): |
| 636 | 641 |
location['lon'])
|
| 637 | 642 |
open_uri(uri)
|
| 638 | 643 |
|
| 639 |
- def on_location_eventbox_leave_notify_event(self, widget, event):
|
|
| 644 |
+ def on_location_eventbox_leave_notify_event(self, _widget, _event):
|
|
| 640 | 645 |
"""
|
| 641 | 646 |
Just moved the mouse so show the cursor
|
| 642 | 647 |
"""
|
| 643 | 648 |
cursor = get_cursor('default')
|
| 644 | 649 |
self.parent_win.window.get_window().set_cursor(cursor)
|
| 645 | 650 |
|
| 646 |
- def on_location_eventbox_enter_notify_event(self, widget, event):
|
|
| 651 |
+ def on_location_eventbox_enter_notify_event(self, _widget, _event):
|
|
| 647 | 652 |
cursor = get_cursor('pointer')
|
| 648 | 653 |
self.parent_win.window.get_window().set_cursor(cursor)
|
| 649 | 654 |
|
| ... | ... | @@ -672,7 +677,8 @@ class ChatControl(ChatControlBase): |
| 672 | 677 |
|
| 673 | 678 |
# We know our contacts nick, but if another contact has the same nick
|
| 674 | 679 |
# in another account we need to also display the account.
|
| 675 |
- # except if we are talking to two different resources of the same contact
|
|
| 680 |
+ # except if we are talking to two different resources of the
|
|
| 681 |
+ # same contact
|
|
| 676 | 682 |
acct_info = ''
|
| 677 | 683 |
for account in app.contacts.get_accounts():
|
| 678 | 684 |
if account == self.account:
|
| ... | ... | @@ -739,14 +745,15 @@ class ChatControl(ChatControlBase): |
| 739 | 745 |
return
|
| 740 | 746 |
setattr(self, jingle_type + '_sid', None)
|
| 741 | 747 |
setattr(self, jingle_type + '_state', self.JINGLE_STATE_NULL)
|
| 742 |
- session = app.connections[self.account].get_module('Jingle').get_jingle_session(
|
|
| 748 |
+ con = app.connections[self.account]
|
|
| 749 |
+ session = con.get_module('Jingle').get_jingle_session(
|
|
| 743 | 750 |
self.contact.get_full_jid(), sid)
|
| 744 | 751 |
if session:
|
| 745 | 752 |
content = session.get_content(jingle_type)
|
| 746 | 753 |
if content:
|
| 747 | 754 |
session.remove_content(content.creator, content.name)
|
| 748 |
- v = GLib.Variant.new_boolean(False)
|
|
| 749 |
- getattr(self, jingle_type + '_action').change_state(v)
|
|
| 755 |
+ var = GLib.Variant.new_boolean(False)
|
|
| 756 |
+ getattr(self, jingle_type + '_action').change_state(var)
|
|
| 750 | 757 |
getattr(self, 'update_' + jingle_type)()
|
| 751 | 758 |
|
| 752 | 759 |
def on_jingle_button_toggled(self, state, jingle_type):
|
| ... | ... | @@ -772,7 +779,8 @@ class ChatControl(ChatControlBase): |
| 772 | 779 |
in_da = self.xml.incoming_drawingarea
|
| 773 | 780 |
in_da.realize()
|
| 774 | 781 |
in_xid = in_da.get_window().get_xid()
|
| 775 |
- sid = app.connections[self.account].get_module('Jingle').start_video(
|
|
| 782 |
+ con = app.connections[self.account]
|
|
| 783 |
+ sid = con.get_module('Jingle').start_video(
|
|
| 776 | 784 |
self.contact.get_full_jid(), in_xid, out_xid)
|
| 777 | 785 |
else:
|
| 778 | 786 |
sid = getattr(app.connections[self.account],
|
| ... | ... | @@ -878,14 +886,14 @@ class ChatControl(ChatControlBase): |
| 878 | 886 |
|
| 879 | 887 |
if self.encryption:
|
| 880 | 888 |
self.sendmessage = True
|
| 881 |
- app.plugin_manager.extension_point(
|
|
| 882 |
- 'send_message' + self.encryption, self)
|
|
| 889 |
+ app.plugin_manager.extension_point('send_message' + self.encryption,
|
|
| 890 |
+ self)
|
|
| 883 | 891 |
if not self.sendmessage:
|
| 884 | 892 |
return
|
| 885 | 893 |
|
| 886 | 894 |
message = helpers.remove_invalid_xml_chars(message)
|
| 887 | 895 |
if message in ('', None, '\n'):
|
| 888 |
- return None
|
|
| 896 |
+ return
|
|
| 889 | 897 |
|
| 890 | 898 |
ChatControlBase.send_message(self,
|
| 891 | 899 |
message,
|
| ... | ... | @@ -913,8 +921,8 @@ class ChatControl(ChatControlBase): |
| 913 | 921 |
|
| 914 | 922 |
If frm is set to status: it's a status message.
|
| 915 | 923 |
if frm is set to error: it's an error message. The difference between
|
| 916 |
- status and error is mainly that with error, msg count as a new message
|
|
| 917 |
- (in systray and in control).
|
|
| 924 |
+ status and error is mainly that with error, msg count as a new
|
|
| 925 |
+ message (in systray and in control).
|
|
| 918 | 926 |
If frm is set to info: it's a information message.
|
| 919 | 927 |
If frm is set to print_queue: it is incoming from queue.
|
| 920 | 928 |
If frm is set to another value: it's an outgoing message.
|
| ... | ... | @@ -932,19 +940,26 @@ class ChatControl(ChatControlBase): |
| 932 | 940 |
if not frm:
|
| 933 | 941 |
kind = 'incoming'
|
| 934 | 942 |
name = contact.get_shown_name()
|
| 935 |
- elif frm == 'print_queue': # incoming message, but do not update time
|
|
| 943 |
+ elif frm == 'print_queue':
|
|
| 936 | 944 |
kind = 'incoming_queue'
|
| 937 | 945 |
name = contact.get_shown_name()
|
| 938 | 946 |
else:
|
| 939 | 947 |
kind = 'outgoing'
|
| 940 | 948 |
name = self.get_our_nick()
|
| 941 | 949 |
|
| 942 |
- ChatControlBase.add_message(self, text, kind, name, tim,
|
|
| 943 |
- subject=subject, old_kind=self.old_msg_kind,
|
|
| 944 |
- displaymarking=displaymarking,
|
|
| 945 |
- msg_log_id=msg_log_id, message_id=message_id,
|
|
| 946 |
- correct_id=correct_id, additional_data=additional_data,
|
|
| 947 |
- error=error)
|
|
| 950 |
+ ChatControlBase.add_message(self,
|
|
| 951 |
+ text,
|
|
| 952 |
+ kind,
|
|
| 953 |
+ name,
|
|
| 954 |
+ tim,
|
|
| 955 |
+ subject=subject,
|
|
| 956 |
+ old_kind=self.old_msg_kind,
|
|
| 957 |
+ displaymarking=displaymarking,
|
|
| 958 |
+ msg_log_id=msg_log_id,
|
|
| 959 |
+ message_id=message_id,
|
|
| 960 |
+ correct_id=correct_id,
|
|
| 961 |
+ additional_data=additional_data,
|
|
| 962 |
+ error=error)
|
|
| 948 | 963 |
if text.startswith('/me ') or text.startswith('/me\n'):
|
| 949 | 964 |
self.old_msg_kind = None
|
| 950 | 965 |
else:
|
| ... | ... | @@ -960,8 +975,8 @@ class ChatControl(ChatControlBase): |
| 960 | 975 |
jid = self.contact.get_full_jid()
|
| 961 | 976 |
else:
|
| 962 | 977 |
jid = self.contact.jid
|
| 963 |
- num_unread = len(app.events.get_events(self.account, jid,
|
|
| 964 |
- ['printed_' + self.type_id, self.type_id]))
|
|
| 978 |
+ num_unread = len(app.events.get_events(
|
|
| 979 |
+ self.account, jid, ['printed_' + self.type_id, self.type_id]))
|
|
| 965 | 980 |
if num_unread == 1 and not app.config.get('show_unread_tab_icon'):
|
| 966 | 981 |
unread = '*'
|
| 967 | 982 |
elif num_unread > 1:
|
| ... | ... | @@ -989,8 +1004,8 @@ class ChatControl(ChatControlBase): |
| 989 | 1004 |
return surface
|
| 990 | 1005 |
|
| 991 | 1006 |
if count_unread:
|
| 992 |
- num_unread = len(app.events.get_events(self.account, jid,
|
|
| 993 |
- ['printed_' + self.type_id, self.type_id]))
|
|
| 1007 |
+ num_unread = len(app.events.get_events(
|
|
| 1008 |
+ self.account, jid, ['printed_' + self.type_id, self.type_id]))
|
|
| 994 | 1009 |
else:
|
| 995 | 1010 |
num_unread = 0
|
| 996 | 1011 |
|
| ... | ... | @@ -1002,7 +1017,7 @@ class ChatControl(ChatControlBase): |
| 1002 | 1017 |
icon_name = get_icon_name('event', transport=transport)
|
| 1003 | 1018 |
else:
|
| 1004 | 1019 |
contact = app.contacts.get_contact_with_highest_priority(
|
| 1005 |
- self.account, self.contact.jid)
|
|
| 1020 |
+ self.account, self.contact.jid)
|
|
| 1006 | 1021 |
if not contact or self.resource:
|
| 1007 | 1022 |
# For transient contacts
|
| 1008 | 1023 |
contact = self.contact
|
| ... | ... | @@ -1018,11 +1033,15 @@ class ChatControl(ChatControlBase): |
| 1018 | 1033 |
"""
|
| 1019 | 1034 |
if app.jid_is_transport(self.contact.jid):
|
| 1020 | 1035 |
menu = gui_menu_builder.get_transport_menu(self.contact,
|
| 1021 |
- self.account)
|
|
| 1036 |
+ self.account)
|
|
| 1022 | 1037 |
else:
|
| 1023 |
- menu = gui_menu_builder.get_contact_menu(self.contact, self.account,
|
|
| 1024 |
- use_multiple_contacts=False, show_start_chat=False,
|
|
| 1025 |
- show_encryption=True, control=self,
|
|
| 1038 |
+ menu = gui_menu_builder.get_contact_menu(
|
|
| 1039 |
+ self.contact,
|
|
| 1040 |
+ self.account,
|
|
| 1041 |
+ use_multiple_contacts=False,
|
|
| 1042 |
+ show_start_chat=False,
|
|
| 1043 |
+ show_encryption=True,
|
|
| 1044 |
+ control=self,
|
|
| 1026 | 1045 |
show_buttonbar_items=not hide_buttonbar_items)
|
| 1027 | 1046 |
return menu
|
| 1028 | 1047 |
|
| ... | ... | @@ -1030,36 +1049,10 @@ class ChatControl(ChatControlBase): |
| 1030 | 1049 |
# PluginSystem: removing GUI extension points connected with ChatControl
|
| 1031 | 1050 |
# instance object
|
| 1032 | 1051 |
app.plugin_manager.remove_gui_extension_point('chat_control', self)
|
| 1033 |
- app.ged.remove_event_handler('nickname-received', ged.GUI1,
|
|
| 1034 |
- self._on_nickname_received)
|
|
| 1035 |
- app.ged.remove_event_handler('mood-received', ged.GUI1,
|
|
| 1036 |
- self._on_mood_received)
|
|
| 1037 |
- app.ged.remove_event_handler('activity-received', ged.GUI1,
|
|
| 1038 |
- self._on_activity_received)
|
|
| 1039 |
- app.ged.remove_event_handler('tune-received', ged.GUI1,
|
|
| 1040 |
- self._on_tune_received)
|
|
| 1041 |
- app.ged.remove_event_handler('location-received', ged.GUI1,
|
|
| 1042 |
- self._on_location_received)
|
|
| 1043 |
- app.ged.remove_event_handler('update-client-info', ged.GUI1,
|
|
| 1044 |
- self._on_update_client_info)
|
|
| 1045 |
- if self.TYPE_ID == message_control.TYPE_CHAT:
|
|
| 1046 |
- app.ged.remove_event_handler('update-roster-avatar', ged.GUI1,
|
|
| 1047 |
- self._nec_update_avatar)
|
|
| 1048 |
- app.ged.remove_event_handler('chatstate-received', ged.GUI1,
|
|
| 1049 |
- self._nec_chatstate_received)
|
|
| 1050 |
- app.ged.remove_event_handler('caps-update', ged.GUI1,
|
|
| 1051 |
- self._nec_caps_received)
|
|
| 1052 |
- app.ged.remove_event_handler('message-sent', ged.OUT_POSTCORE,
|
|
| 1053 |
- self._message_sent)
|
|
| 1054 |
- app.ged.remove_event_handler(
|
|
| 1055 |
- 'mam-decrypted-message-received',
|
|
| 1056 |
- ged.GUI1, self._nec_mam_decrypted_message_received)
|
|
| 1057 |
- app.ged.remove_event_handler(
|
|
| 1058 |
- 'decrypted-message-received',
|
|
| 1059 |
- ged.GUI1, self._nec_decrypted_message_received)
|
|
| 1060 |
- app.ged.remove_event_handler(
|
|
| 1061 |
- 'receipt-received',
|
|
| 1062 |
- ged.GUI1, self._receipt_received)
|
|
| 1052 |
+ |
|
| 1053 |
+ # Unregister handlers
|
|
| 1054 |
+ for handler in self._event_handlers:
|
|
| 1055 |
+ app.ged.remove_event_handler(*handler)
|
|
| 1063 | 1056 |
|
| 1064 | 1057 |
self.unsubscribe_events()
|
| 1065 | 1058 |
|
| ... | ... | @@ -1075,18 +1068,22 @@ class ChatControl(ChatControlBase): |
| 1075 | 1068 |
self.session.control = None
|
| 1076 | 1069 |
|
| 1077 | 1070 |
# Clean events
|
| 1078 |
- app.events.remove_events(self.account, self.get_full_jid(),
|
|
| 1079 |
- types=['printed_' + self.type_id, self.type_id])
|
|
| 1071 |
+ app.events.remove_events(
|
|
| 1072 |
+ self.account,
|
|
| 1073 |
+ self.get_full_jid(),
|
|
| 1074 |
+ types=['printed_' + self.type_id, self.type_id])
|
|
| 1080 | 1075 |
# Remove contact instance if contact has been removed
|
| 1081 | 1076 |
key = (self.contact.jid, self.account)
|
| 1082 | 1077 |
roster = app.interface.roster
|
| 1083 |
- if key in roster.contacts_to_be_removed.keys() and \
|
|
| 1084 |
- not roster.contact_has_pending_roster_events(self.contact,
|
|
| 1085 |
- self.account):
|
|
| 1078 |
+ has_pending = roster.contact_has_pending_roster_events(self.contact,
|
|
| 1079 |
+ self.account)
|
|
| 1080 |
+ if key in roster.contacts_to_be_removed.keys() and not has_pending:
|
|
| 1086 | 1081 |
backend = roster.contacts_to_be_removed[key]['backend']
|
| 1087 | 1082 |
del roster.contacts_to_be_removed[key]
|
| 1088 |
- roster.remove_contact(self.contact.jid, self.account, force=True,
|
|
| 1089 |
- backend=backend)
|
|
| 1083 |
+ roster.remove_contact(self.contact.jid,
|
|
| 1084 |
+ self.account,
|
|
| 1085 |
+ force=True,
|
|
| 1086 |
+ backend=backend)
|
|
| 1090 | 1087 |
# remove all register handlers on widgets, created by self.xml
|
| 1091 | 1088 |
# to prevent circular references among objects
|
| 1092 | 1089 |
for i in list(self.handlers.keys()):
|
| ... | ... | @@ -1192,13 +1189,13 @@ class ChatControl(ChatControlBase): |
| 1192 | 1189 |
|
| 1193 | 1190 |
# get contact info (check for PM = private chat)
|
| 1194 | 1191 |
if self.TYPE_ID == message_control.TYPE_PM:
|
| 1195 |
- c = self.gc_contact.as_contact()
|
|
| 1192 |
+ contact = self.gc_contact.as_contact()
|
|
| 1196 | 1193 |
else:
|
| 1197 |
- c = self.contact
|
|
| 1194 |
+ contact = self.contact
|
|
| 1198 | 1195 |
|
| 1199 | 1196 |
if target_type == self.TARGET_TYPE_URI_LIST:
|
| 1200 | 1197 |
# File drag and drop (handled in chat_control_base)
|
| 1201 |
- self.drag_data_file_transfer(c, selection, self)
|
|
| 1198 |
+ self.drag_data_file_transfer(contact, selection, self)
|
|
| 1202 | 1199 |
else:
|
| 1203 | 1200 |
# Convert single chat to MUC
|
| 1204 | 1201 |
treeview = app.interface.roster.tree
|
| ... | ... | @@ -1212,11 +1209,13 @@ class ChatControl(ChatControlBase): |
| 1212 | 1209 |
dropped_jid = data
|
| 1213 | 1210 |
|
| 1214 | 1211 |
dropped_transport = app.get_transport_name_from_jid(dropped_jid)
|
| 1215 |
- c_transport = app.get_transport_name_from_jid(c.jid)
|
|
| 1212 |
+ c_transport = app.get_transport_name_from_jid(contact.jid)
|
|
| 1216 | 1213 |
if dropped_transport or c_transport:
|
| 1217 | 1214 |
return # transport contacts cannot be invited
|
| 1218 | 1215 |
|
| 1219 |
- dialogs.TransformChatToMUC(self.account, [c.jid], [dropped_jid])
|
|
| 1216 |
+ dialogs.TransformChatToMUC(self.account,
|
|
| 1217 |
+ [contact.jid],
|
|
| 1218 |
+ [dropped_jid])
|
|
| 1220 | 1219 |
|
| 1221 | 1220 |
def restore_conversation(self):
|
| 1222 | 1221 |
jid = self.contact.jid
|
| ... | ... | @@ -1226,11 +1225,11 @@ class ChatControl(ChatControlBase): |
| 1226 | 1225 |
|
| 1227 | 1226 |
# number of messages that are in queue and are already logged, we want
|
| 1228 | 1227 |
# to avoid duplication
|
| 1229 |
- pending = len(app.events.get_events(self.account, jid,
|
|
| 1230 |
- ['chat', 'pm']))
|
|
| 1228 |
+ pending = len(app.events.get_events(self.account, jid, ['chat', 'pm']))
|
|
| 1231 | 1229 |
if self.resource:
|
| 1232 | 1230 |
pending += len(app.events.get_events(self.account,
|
| 1233 |
- self.contact.get_full_jid(), ['chat', 'pm']))
|
|
| 1231 |
+ self.contact.get_full_jid(),
|
|
| 1232 |
+ ['chat', 'pm']))
|
|
| 1234 | 1233 |
|
| 1235 | 1234 |
rows = app.logger.get_last_conversation_lines(
|
| 1236 | 1235 |
self.account, jid, pending)
|
| ... | ... | @@ -1247,7 +1246,7 @@ class ChatControl(ChatControlBase): |
| 1247 | 1246 |
kind = 'outgoing'
|
| 1248 | 1247 |
name = self.get_our_nick()
|
| 1249 | 1248 |
elif row.kind in (KindConstant.SINGLE_MSG_RECV,
|
| 1250 |
- KindConstant.CHAT_MSG_RECV):
|
|
| 1249 |
+ KindConstant.CHAT_MSG_RECV):
|
|
| 1251 | 1250 |
kind = 'incoming'
|
| 1252 | 1251 |
name = self.contact.get_shown_name()
|
| 1253 | 1252 |
elif row.kind == KindConstant.ERROR:
|
| ... | ... | @@ -1270,7 +1269,8 @@ class ChatControl(ChatControlBase): |
| 1270 | 1269 |
message_id=row.message_id,
|
| 1271 | 1270 |
marker=row.marker,
|
| 1272 | 1271 |
error=row.error)
|
| 1273 |
- if row.message.startswith('/me ') or row.message.startswith('/me\n'):
|
|
| 1272 |
+ if (row.message.startswith('/me ') or
|
|
| 1273 |
+ row.message.startswith('/me\n')):
|
|
| 1274 | 1274 |
local_old_kind = None
|
| 1275 | 1275 |
else:
|
| 1276 | 1276 |
local_old_kind = kind
|
| ... | ... | @@ -1310,8 +1310,9 @@ class ChatControl(ChatControlBase): |
| 1310 | 1310 |
self.set_session(event.session)
|
| 1311 | 1311 |
if message_ids:
|
| 1312 | 1312 |
app.logger.set_read_messages(message_ids)
|
| 1313 |
- app.events.remove_events(self.account, jid_with_resource,
|
|
| 1314 |
- types=[self.type_id])
|
|
| 1313 |
+ app.events.remove_events(self.account,
|
|
| 1314 |
+ jid_with_resource,
|
|
| 1315 |
+ types=[self.type_id])
|
|
| 1315 | 1316 |
|
| 1316 | 1317 |
typ = 'chat' # Is it a normal chat or a pm ?
|
| 1317 | 1318 |
|
| ... | ... | @@ -1319,7 +1320,7 @@ class ChatControl(ChatControlBase): |
| 1319 | 1320 |
# Is it a pm ?
|
| 1320 | 1321 |
room_jid, nick = app.get_room_and_nick_from_fjid(jid)
|
| 1321 | 1322 |
control = app.interface.msg_win_mgr.get_gc_control(room_jid,
|
| 1322 |
- self.account)
|
|
| 1323 |
+ self.account)
|
|
| 1323 | 1324 |
if control and control.type_id == message_control.TYPE_GC:
|
| 1324 | 1325 |
control.update_ui()
|
| 1325 | 1326 |
control.parent_win.show_title()
|
| ... | ... | @@ -1333,11 +1334,11 @@ class ChatControl(ChatControlBase): |
| 1333 | 1334 |
(not show_offline and typ == 'chat' and \
|
| 1334 | 1335 |
len(app.contacts.get_contacts(self.account, jid)) < 2):
|
| 1335 | 1336 |
app.interface.roster.remove_to_be_removed(self.contact.jid,
|
| 1336 |
- self.account)
|
|
| 1337 |
+ self.account)
|
|
| 1337 | 1338 |
elif typ == 'pm':
|
| 1338 | 1339 |
control.remove_contact(nick)
|
| 1339 | 1340 |
|
| 1340 |
- def _on_convert_to_gc_menuitem_activate(self, widget):
|
|
| 1341 |
+ def _on_convert_to_gc_menuitem_activate(self, _widget):
|
|
| 1341 | 1342 |
"""
|
| 1342 | 1343 |
User wants to invite some friends to chat
|
| 1343 | 1344 |
"""
|
| ... | ... | @@ -1347,7 +1348,7 @@ class ChatControl(ChatControlBase): |
| 1347 | 1348 |
ChatControlBase.got_connected(self)
|
| 1348 | 1349 |
# Refreshing contact
|
| 1349 | 1350 |
contact = app.contacts.get_contact_with_highest_priority(
|
| 1350 |
- self.account, self.contact.jid)
|
|
| 1351 |
+ self.account, self.contact.jid)
|
|
| 1351 | 1352 |
if isinstance(contact, GC_Contact):
|
| 1352 | 1353 |
contact = contact.as_contact()
|
| 1353 | 1354 |
if contact:
|
| ... | ... | @@ -1387,8 +1388,8 @@ class ChatControl(ChatControlBase): |
| 1387 | 1388 |
|
| 1388 | 1389 |
# Remove old buttons
|
| 1389 | 1390 |
area = self.info_bar.get_action_area()
|
| 1390 |
- for b in area.get_children():
|
|
| 1391 |
- area.remove(b)
|
|
| 1391 |
+ for button in area.get_children():
|
|
| 1392 |
+ area.remove(button)
|
|
| 1392 | 1393 |
|
| 1393 | 1394 |
# Add new buttons
|
| 1394 | 1395 |
for button in buttons:
|
| ... | ... | @@ -1410,15 +1411,16 @@ class ChatControl(ChatControlBase): |
| 1410 | 1411 |
return ev
|
| 1411 | 1412 |
return None
|
| 1412 | 1413 |
|
| 1413 |
- def _on_accept_file_request(self, widget, file_props):
|
|
| 1414 |
+ def _on_accept_file_request(self, _widget, file_props):
|
|
| 1414 | 1415 |
app.interface.instances['file_transfers'].on_file_request_accepted(
|
| 1415 | 1416 |
self.account, self.contact, file_props)
|
| 1416 | 1417 |
ev = self._get_file_props_event(file_props, 'file-request')
|
| 1417 | 1418 |
if ev:
|
| 1418 | 1419 |
app.events.remove_events(self.account, self.contact.jid, event=ev)
|
| 1419 | 1420 |
|
| 1420 |
- def _on_cancel_file_request(self, widget, file_props):
|
|
| 1421 |
- app.connections[self.account].get_module('Bytestream').send_file_rejection(file_props)
|
|
| 1421 |
+ def _on_cancel_file_request(self, _widget, file_props):
|
|
| 1422 |
+ con = app.connections[self.account]
|
|
| 1423 |
+ con.get_module('Bytestream').send_file_rejection(file_props)
|
|
| 1422 | 1424 |
ev = self._get_file_props_event(file_props, 'file-request')
|
| 1423 | 1425 |
if ev:
|
| 1424 | 1426 |
app.events.remove_events(self.account, self.contact.jid, event=ev)
|
| ... | ... | @@ -1448,7 +1450,7 @@ class ChatControl(ChatControlBase): |
| 1448 | 1450 |
file_props,
|
| 1449 | 1451 |
Gtk.MessageType.QUESTION)
|
| 1450 | 1452 |
|
| 1451 |
- def _on_open_ft_folder(self, widget, file_props):
|
|
| 1453 |
+ def _on_open_ft_folder(self, _widget, file_props):
|
|
| 1452 | 1454 |
path = os.path.split(file_props.file_name)[0]
|
| 1453 | 1455 |
if os.path.exists(path) and os.path.isdir(path):
|
| 1454 | 1456 |
open_file(path)
|
| ... | ... | @@ -1456,14 +1458,14 @@ class ChatControl(ChatControlBase): |
| 1456 | 1458 |
if ev:
|
| 1457 | 1459 |
app.events.remove_events(self.account, self.contact.jid, event=ev)
|
| 1458 | 1460 |
|
| 1459 |
- def _on_ok(self, widget, file_props, type_):
|
|
| 1461 |
+ def _on_ok(self, _widget, file_props, type_):
|
|
| 1460 | 1462 |
ev = self._get_file_props_event(file_props, type_)
|
| 1461 | 1463 |
if ev:
|
| 1462 | 1464 |
app.events.remove_events(self.account, self.contact.jid, event=ev)
|
| 1463 | 1465 |
|
| 1464 | 1466 |
def _got_file_completed(self, file_props):
|
| 1465 | 1467 |
markup = '<b>%s</b>\n%s' % (_('File Transfer Completed'),
|
| 1466 |
- file_props.name)
|
|
| 1468 |
+ file_props.name)
|
|
| 1467 | 1469 |
if file_props.desc:
|
| 1468 | 1470 |
markup += '\n(%s)' % file_props.desc
|
| 1469 | 1471 |
b1 = Gtk.Button.new_with_mnemonic(_('Open _Folder'))
|
| ... | ... | @@ -1477,21 +1479,21 @@ class ChatControl(ChatControlBase): |
| 1477 | 1479 |
|
| 1478 | 1480 |
def _got_file_error(self, file_props, type_, pri_txt, sec_txt):
|
| 1479 | 1481 |
markup = '<b>%s</b>\n%s' % (pri_txt, sec_txt)
|
| 1480 |
- b = Gtk.Button.new_with_mnemonic(_('_Close'))
|
|
| 1481 |
- b.connect('clicked', self._on_ok, file_props, type_)
|
|
| 1482 |
+ button = Gtk.Button.new_with_mnemonic(_('_Close'))
|
|
| 1483 |
+ button.connect('clicked', self._on_ok, file_props, type_)
|
|
| 1482 | 1484 |
self._add_info_bar_message(
|
| 1483 | 1485 |
markup,
|
| 1484 |
- [b],
|
|
| 1486 |
+ [button],
|
|
| 1485 | 1487 |
file_props,
|
| 1486 | 1488 |
Gtk.MessageType.ERROR)
|
| 1487 | 1489 |
|
| 1488 |
- def _on_accept_gc_invitation(self, widget, event):
|
|
| 1490 |
+ def _on_accept_gc_invitation(self, _widget, event):
|
|
| 1489 | 1491 |
app.interface.show_or_join_groupchat(self.account,
|
| 1490 | 1492 |
str(event.muc),
|
| 1491 | 1493 |
password=event.password)
|
| 1492 | 1494 |
app.events.remove_events(self.account, self.contact.jid, event=event)
|
| 1493 | 1495 |
|
| 1494 |
- def _on_cancel_gc_invitation(self, widget, event):
|
|
| 1496 |
+ def _on_cancel_gc_invitation(self, _widget, event):
|
|
| 1495 | 1497 |
app.events.remove_events(self.account, self.contact.jid, event=event)
|
| 1496 | 1498 |
|
| 1497 | 1499 |
def _get_gc_invitation(self, event):
|
| ... | ... | @@ -1524,9 +1526,11 @@ class ChatControl(ChatControlBase): |
| 1524 | 1526 |
elif event.file_props.error == -6:
|
| 1525 | 1527 |
msg_err = _('Error opening file')
|
| 1526 | 1528 |
self._got_file_error(event.file_props, event.type_,
|
| 1527 |
- _('File transfer stopped'), msg_err)
|
|
| 1529 |
+ _('File transfer stopped'), msg_err)
|
|
| 1528 | 1530 |
elif event.type_ in ('file-request-error', 'file-send-error'):
|
| 1529 |
- self._got_file_error(event.file_props, event.type_,
|
|
| 1531 |
+ self._got_file_error(
|
|
| 1532 |
+ event.file_props,
|
|
| 1533 |
+ event.type_,
|
|
| 1530 | 1534 |
_('File transfer cancelled'),
|
| 1531 | 1535 |
_('Connection with peer cannot be established.'))
|
| 1532 | 1536 |
elif event.type_ == 'gc-invitation':
|
| ... | ... | @@ -1541,9 +1545,13 @@ class ChatControl(ChatControlBase): |
| 1541 | 1545 |
continue
|
| 1542 | 1546 |
if ev.jid != self.contact.jid:
|
| 1543 | 1547 |
continue
|
| 1544 |
- if ev.type_ not in ('file-request', 'file-completed', 'file-error',
|
|
| 1545 |
- 'file-stopped', 'file-request-error', 'file-send-error',
|
|
| 1546 |
- 'gc-invitation'):
|
|
| 1548 |
+ if ev.type_ not in ('file-request',
|
|
| 1549 |
+ 'file-completed',
|
|
| 1550 |
+ 'file-error',
|
|
| 1551 |
+ 'file-stopped',
|
|
| 1552 |
+ 'file-request-error',
|
|
| 1553 |
+ 'file-send-error',
|
|
| 1554 |
+ 'gc-invitation'):
|
|
| 1547 | 1555 |
continue
|
| 1548 | 1556 |
i = 0
|
| 1549 | 1557 |
removed = False
|
| ... | ... | @@ -91,116 +91,8 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 91 | 91 |
# Multiple hardware keycodes can trigger a keyval like Gdk.KEY_c.
|
| 92 | 92 |
keycodes_c = get_hardware_key_codes(Gdk.KEY_c)
|
| 93 | 93 |
|
| 94 |
- def get_nb_unread(self):
|
|
| 95 |
- jid = self.contact.jid
|
|
| 96 |
- if self.resource:
|
|
| 97 |
- jid += '/' + self.resource
|
|
| 98 |
- type_ = self.type_id
|
|
| 99 |
- return len(app.events.get_events(self.account, jid, ['printed_' + type_,
|
|
| 100 |
- type_]))
|
|
| 101 |
- |
|
| 102 |
- def draw_banner(self):
|
|
| 103 |
- """
|
|
| 104 |
- Draw the fat line at the top of the window that houses the icon, jid, etc
|
|
| 105 |
- |
|
| 106 |
- Derived types MAY implement this.
|
|
| 107 |
- """
|
|
| 108 |
- self.draw_banner_text()
|
|
| 109 |
- self._update_banner_state_image()
|
|
| 110 |
- app.plugin_manager.gui_extension_point('chat_control_base_draw_banner',
|
|
| 111 |
- self)
|
|
| 112 |
- |
|
| 113 |
- def update_toolbar(self):
|
|
| 114 |
- """
|
|
| 115 |
- update state of buttons in toolbar
|
|
| 116 |
- """
|
|
| 117 |
- self._update_toolbar()
|
|
| 118 |
- app.plugin_manager.gui_extension_point(
|
|
| 119 |
- 'chat_control_base_update_toolbar', self)
|
|
| 120 |
- |
|
| 121 |
- def draw_banner_text(self):
|
|
| 122 |
- """
|
|
| 123 |
- Derived types SHOULD implement this
|
|
| 124 |
- """
|
|
| 125 |
- |
|
| 126 |
- def update_ui(self):
|
|
| 127 |
- """
|
|
| 128 |
- Derived types SHOULD implement this
|
|
| 129 |
- """
|
|
| 130 |
- self.draw_banner()
|
|
| 131 |
- |
|
| 132 |
- def repaint_themed_widgets(self):
|
|
| 133 |
- """
|
|
| 134 |
- Derived types MAY implement this
|
|
| 135 |
- """
|
|
| 136 |
- self.draw_banner()
|
|
| 137 |
- |
|
| 138 |
- def _update_banner_state_image(self):
|
|
| 139 |
- """
|
|
| 140 |
- Derived types MAY implement this
|
|
| 141 |
- """
|
|
| 142 |
- |
|
| 143 |
- def _update_toolbar(self):
|
|
| 144 |
- """
|
|
| 145 |
- Derived types MAY implement this
|
|
| 146 |
- """
|
|
| 147 |
- |
|
| 148 |
- def _nec_our_status(self, obj):
|
|
| 149 |
- if self.account != obj.conn.name:
|
|
| 150 |
- return
|
|
| 151 |
- if obj.show == 'offline' or (obj.show == 'invisible' and \
|
|
| 152 |
- obj.conn.is_zeroconf):
|
|
| 153 |
- self.got_disconnected()
|
|
| 154 |
- else:
|
|
| 155 |
- # Other code rejoins all GCs, so we don't do it here
|
|
| 156 |
- if not self.type_id == message_control.TYPE_GC:
|
|
| 157 |
- self.got_connected()
|
|
| 158 |
- if self.parent_win:
|
|
| 159 |
- self.parent_win.redraw_tab(self)
|
|
| 160 |
- |
|
| 161 |
- def setup_seclabel(self):
|
|
| 162 |
- self.xml.label_selector.hide()
|
|
| 163 |
- self.xml.label_selector.set_no_show_all(True)
|
|
| 164 |
- lb = Gtk.ListStore(str)
|
|
| 165 |
- self.xml.label_selector.set_model(lb)
|
|
| 166 |
- cell = Gtk.CellRendererText()
|
|
| 167 |
- cell.set_property('xpad', 5) # padding for status text
|
|
| 168 |
- self.xml.label_selector.pack_start(cell, True)
|
|
| 169 |
- # text to show is in in first column of liststore
|
|
| 170 |
- self.xml.label_selector.add_attribute(cell, 'text', 0)
|
|
| 171 |
- con = app.connections[self.account]
|
|
| 172 |
- jid = self.contact.jid
|
|
| 173 |
- if self.TYPE_ID == 'pm':
|
|
| 174 |
- jid = self.gc_contact.room_jid
|
|
| 175 |
- if con.get_module('SecLabels').supported:
|
|
| 176 |
- con.get_module('SecLabels').request_catalog(jid)
|
|
| 177 |
- |
|
| 178 |
- def _sec_labels_received(self, event):
|
|
| 179 |
- if event.account != self.account:
|
|
| 180 |
- return
|
|
| 181 |
- |
|
| 182 |
- jid = self.contact.jid
|
|
| 183 |
- if self.TYPE_ID == 'pm':
|
|
| 184 |
- jid = self.gc_contact.room_jid
|
|
| 185 |
- |
|
| 186 |
- if event.jid != jid:
|
|
| 187 |
- return
|
|
| 188 |
- model = self.xml.label_selector.get_model()
|
|
| 189 |
- model.clear()
|
|
| 190 |
- |
|
| 191 |
- sel = 0
|
|
| 192 |
- _label, labellist, default = event.catalog
|
|
| 193 |
- for index, label in enumerate(labellist):
|
|
| 194 |
- model.append([label])
|
|
| 195 |
- if label == default:
|
|
| 196 |
- sel = index
|
|
| 197 |
- |
|
| 198 |
- self.xml.label_selector.set_active(sel)
|
|
| 199 |
- self.xml.label_selector.set_no_show_all(False)
|
|
| 200 |
- self.xml.label_selector.show_all()
|
|
| 201 |
- |
|
| 202 | 94 |
def __init__(self, type_id, parent_win, widget_name, contact, acct,
|
| 203 |
- resource=None):
|
|
| 95 |
+ resource=None):
|
|
| 204 | 96 |
# Undo needs this variable to know if space has been pressed.
|
| 205 | 97 |
# Initialize it to True so empty textview is saved in undo list
|
| 206 | 98 |
self.space_pressed = True
|
| ... | ... | @@ -208,13 +100,13 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 208 | 100 |
if resource is None:
|
| 209 | 101 |
# We very likely got a contact with a random resource.
|
| 210 | 102 |
# This is bad, we need the highest for caps etc.
|
| 211 |
- c = app.contacts.get_contact_with_highest_priority(acct,
|
|
| 212 |
- contact.jid)
|
|
| 213 |
- if c and not isinstance(c, GC_Contact):
|
|
| 214 |
- contact = c
|
|
| 103 |
+ _contact = app.contacts.get_contact_with_highest_priority(
|
|
| 104 |
+ acct, contact.jid)
|
|
| 105 |
+ if _contact and not isinstance(_contact, GC_Contact):
|
|
| 106 |
+ contact = _contact
|
|
| 215 | 107 |
|
| 216 | 108 |
MessageControl.__init__(self, type_id, parent_win, widget_name,
|
| 217 |
- contact, acct, resource=resource)
|
|
| 109 |
+ contact, acct, resource=resource)
|
|
| 218 | 110 |
|
| 219 | 111 |
if self.TYPE_ID != message_control.TYPE_GC:
|
| 220 | 112 |
# Create banner and connect signals
|
| ... | ... | @@ -279,7 +171,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 279 | 171 |
self.conv_scrolledwindow.add(self.conv_textview.tv)
|
| 280 | 172 |
widget = self.conv_scrolledwindow.get_vadjustment()
|
| 281 | 173 |
id_ = widget.connect('changed',
|
| 282 |
- self.on_conversation_vadjustment_changed)
|
|
| 174 |
+ self.on_conversation_vadjustment_changed)
|
|
| 283 | 175 |
self.handlers[id_] = widget
|
| 284 | 176 |
|
| 285 | 177 |
vscrollbar = self.conv_scrolledwindow.get_vscrollbar()
|
| ... | ... | @@ -298,13 +190,14 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 298 | 190 |
self.xml.hbox.pack_start(self.msg_scrolledwindow, True, True, 0)
|
| 299 | 191 |
|
| 300 | 192 |
id_ = self.msg_textview.connect('paste-clipboard',
|
| 301 |
- self._on_message_textview_paste_event)
|
|
| 193 |
+ self._on_message_textview_paste_event)
|
|
| 302 | 194 |
self.handlers[id_] = self.msg_textview
|
| 303 |
- id_ = self.msg_textview.connect('key_press_event',
|
|
| 195 |
+ id_ = self.msg_textview.connect(
|
|
| 196 |
+ 'key_press_event',
|
|
| 304 | 197 |
self._on_message_textview_key_press_event)
|
| 305 | 198 |
self.handlers[id_] = self.msg_textview
|
| 306 | 199 |
id_ = self.msg_textview.connect('populate_popup',
|
| 307 |
- self.on_msg_textview_populate_popup)
|
|
| 200 |
+ self.on_msg_textview_populate_popup)
|
|
| 308 | 201 |
self.handlers[id_] = self.msg_textview
|
| 309 | 202 |
|
| 310 | 203 |
# Setup DND
|
| ... | ... | @@ -335,15 +228,17 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 335 | 228 |
self.command_hits = []
|
| 336 | 229 |
self.last_key_tabs = False
|
| 337 | 230 |
|
| 231 |
+ self.sendmessage = True
|
|
| 232 |
+ |
|
| 338 | 233 |
con = app.connections[self.account]
|
| 339 | 234 |
con.get_module('Chatstate').set_active(self.contact)
|
| 340 | 235 |
|
| 341 | 236 |
id_ = self.msg_textview.connect('text-changed',
|
| 342 |
- self._on_message_tv_buffer_changed)
|
|
| 237 |
+ self._on_message_tv_buffer_changed)
|
|
| 343 | 238 |
self.handlers[id_] = self.msg_textview
|
| 344 | 239 |
if parent_win is not None:
|
| 345 | 240 |
id_ = parent_win.window.connect('motion-notify-event',
|
| 346 |
- self._on_window_motion_notify)
|
|
| 241 |
+ self._on_window_motion_notify)
|
|
| 347 | 242 |
self.handlers[id_] = parent_win.window
|
| 348 | 243 |
|
| 349 | 244 |
self.encryption = self.get_encryption_state()
|
| ... | ... | @@ -353,23 +248,137 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 353 | 248 |
# instance object (also subclasses, eg. ChatControl or GroupchatControl)
|
| 354 | 249 |
app.plugin_manager.gui_extension_point('chat_control_base', self)
|
| 355 | 250 |
|
| 356 |
- app.ged.register_event_handler('our-show', ged.GUI1,
|
|
| 357 |
- self._nec_our_status)
|
|
| 358 |
- app.ged.register_event_handler('ping-sent', ged.GUI1,
|
|
| 359 |
- self._nec_ping)
|
|
| 360 |
- app.ged.register_event_handler('ping-reply', ged.GUI1,
|
|
| 361 |
- self._nec_ping)
|
|
| 362 |
- app.ged.register_event_handler('ping-error', ged.GUI1,
|
|
| 363 |
- self._nec_ping)
|
|
| 364 |
- app.ged.register_event_handler('sec-catalog-received', ged.GUI1,
|
|
| 365 |
- self._sec_labels_received)
|
|
| 366 |
- app.ged.register_event_handler('style-changed', ged.GUI1,
|
|
| 367 |
- self._style_changed)
|
|
| 251 |
+ # pylint: disable=line-too-long
|
|
| 252 |
+ self._base_event_handlers = [
|
|
| 253 |
+ ('our-show', ged.GUI1, self._nec_our_status),
|
|
| 254 |
+ ('ping-sent', ged.GUI1, self._nec_ping),
|
|
| 255 |
+ ('ping-reply', ged.GUI1, self._nec_ping),
|
|
| 256 |
+ ('ping-error', ged.GUI1, self._nec_ping),
|
|
| 257 |
+ ('sec-catalog-received', ged.GUI1, self._sec_labels_received),
|
|
| 258 |
+ ('style-changed', ged.GUI1, self._style_changed),
|
|
| 259 |
+ ]
|
|
| 260 |
+ # pylint: enable=line-too-long
|
|
| 261 |
+ |
|
| 262 |
+ for handler in self._base_event_handlers:
|
|
| 263 |
+ app.ged.register_event_handler(*handler)
|
|
| 368 | 264 |
|
| 369 | 265 |
# This is basically a very nasty hack to surpass the inability
|
| 370 | 266 |
# to properly use the super, because of the old code.
|
| 371 | 267 |
CommandTools.__init__(self)
|
| 372 | 268 |
|
| 269 |
+ def get_nb_unread(self):
|
|
| 270 |
+ jid = self.contact.jid
|
|
| 271 |
+ if self.resource:
|
|
| 272 |
+ jid += '/' + self.resource
|
|
| 273 |
+ type_ = self.type_id
|
|
| 274 |
+ return len(app.events.get_events(self.account,
|
|
| 275 |
+ jid,
|
|
| 276 |
+ ['printed_' + type_, type_]))
|
|
| 277 |
+ |
|
| 278 |
+ def draw_banner(self):
|
|
| 279 |
+ """
|
|
| 280 |
+ Draw the fat line at the top of the window
|
|
| 281 |
+ that houses the icon, jid, etc
|
|
| 282 |
+ |
|
| 283 |
+ Derived types MAY implement this.
|
|
| 284 |
+ """
|
|
| 285 |
+ self.draw_banner_text()
|
|
| 286 |
+ self._update_banner_state_image()
|
|
| 287 |
+ app.plugin_manager.gui_extension_point('chat_control_base_draw_banner',
|
|
| 288 |
+ self)
|
|
| 289 |
+ |
|
| 290 |
+ def update_toolbar(self):
|
|
| 291 |
+ """
|
|
| 292 |
+ update state of buttons in toolbar
|
|
| 293 |
+ """
|
|
| 294 |
+ self._update_toolbar()
|
|
| 295 |
+ app.plugin_manager.gui_extension_point(
|
|
| 296 |
+ 'chat_control_base_update_toolbar', self)
|
|
| 297 |
+ |
|
| 298 |
+ def draw_banner_text(self):
|
|
| 299 |
+ """
|
|
| 300 |
+ Derived types SHOULD implement this
|
|
| 301 |
+ """
|
|
| 302 |
+ |
|
| 303 |
+ def update_ui(self):
|
|
| 304 |
+ """
|
|
| 305 |
+ Derived types SHOULD implement this
|
|
| 306 |
+ """
|
|
| 307 |
+ self.draw_banner()
|
|
| 308 |
+ |
|
| 309 |
+ def repaint_themed_widgets(self):
|
|
| 310 |
+ """
|
|
| 311 |
+ Derived types MAY implement this
|
|
| 312 |
+ """
|
|
| 313 |
+ self.draw_banner()
|
|
| 314 |
+ |
|
| 315 |
+ def _update_banner_state_image(self):
|
|
| 316 |
+ """
|
|
| 317 |
+ Derived types MAY implement this
|
|
| 318 |
+ """
|
|
| 319 |
+ |
|
| 320 |
+ def _update_toolbar(self):
|
|
| 321 |
+ """
|
|
| 322 |
+ Derived types MAY implement this
|
|
| 323 |
+ """
|
|
| 324 |
+ |
|
| 325 |
+ def _nec_our_status(self, obj):
|
|
| 326 |
+ if self.account != obj.conn.name:
|
|
| 327 |
+ return
|
|
| 328 |
+ if obj.show == 'offline' or (obj.show == 'invisible' and \
|
|
| 329 |
+ obj.conn.is_zeroconf):
|
|
| 330 |
+ self.got_disconnected()
|
|
| 331 |
+ else:
|
|
| 332 |
+ # Other code rejoins all GCs, so we don't do it here
|
|
| 333 |
+ if not self.type_id == message_control.TYPE_GC:
|
|
| 334 |
+ self.got_connected()
|
|
| 335 |
+ if self.parent_win:
|
|
| 336 |
+ self.parent_win.redraw_tab(self)
|
|
| 337 |
+ |
|
| 338 |
+ def _nec_ping(self, obj):
|
|
| 339 |
+ raise NotImplementedError
|
|
| 340 |
+ |
|
| 341 |
+ def setup_seclabel(self):
|
|
| 342 |
+ self.xml.label_selector.hide()
|
|
| 343 |
+ self.xml.label_selector.set_no_show_all(True)
|
|
| 344 |
+ lb = Gtk.ListStore(str)
|
|
| 345 |
+ self.xml.label_selector.set_model(lb)
|
|
| 346 |
+ cell = Gtk.CellRendererText()
|
|
| 347 |
+ cell.set_property('xpad', 5) # padding for status text
|
|
| 348 |
+ self.xml.label_selector.pack_start(cell, True)
|
|
| 349 |
+ # text to show is in in first column of liststore
|
|
| 350 |
+ self.xml.label_selector.add_attribute(cell, 'text', 0)
|
|
| 351 |
+ con = app.connections[self.account]
|
|
| 352 |
+ jid = self.contact.jid
|
|
| 353 |
+ if self.TYPE_ID == 'pm':
|
|
| 354 |
+ jid = self.gc_contact.room_jid
|
|
| 355 |
+ if con.get_module('SecLabels').supported:
|
|
| 356 |
+ con.get_module('SecLabels').request_catalog(jid)
|
|
| 357 |
+ |
|
| 358 |
+ def _sec_labels_received(self, event):
|
|
| 359 |
+ if event.account != self.account:
|
|
| 360 |
+ return
|
|
| 361 |
+ |
|
| 362 |
+ jid = self.contact.jid
|
|
| 363 |
+ if self.TYPE_ID == 'pm':
|
|
| 364 |
+ jid = self.gc_contact.room_jid
|
|
| 365 |
+ |
|
| 366 |
+ if event.jid != jid:
|
|
| 367 |
+ return
|
|
| 368 |
+ model = self.xml.label_selector.get_model()
|
|
| 369 |
+ model.clear()
|
|
| 370 |
+ |
|
| 371 |
+ sel = 0
|
|
| 372 |
+ _label, labellist, default = event.catalog
|
|
| 373 |
+ for index, label in enumerate(labellist):
|
|
| 374 |
+ model.append([label])
|
|
| 375 |
+ if label == default:
|
|
| 376 |
+ sel = index
|
|
| 377 |
+ |
|
| 378 |
+ self.xml.label_selector.set_active(sel)
|
|
| 379 |
+ self.xml.label_selector.set_no_show_all(False)
|
|
| 380 |
+ self.xml.label_selector.show_all()
|
|
| 381 |
+ |
|
| 373 | 382 |
def delegate_action(self, action):
|
| 374 | 383 |
if action == 'browse-history':
|
| 375 | 384 |
dict_ = {'jid': GLib.Variant('s', self.contact.jid),
|
| ... | ... | @@ -536,7 +545,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 536 | 545 |
gspell_lang = Gspell.language_get_default()
|
| 537 | 546 |
return gspell_lang
|
| 538 | 547 |
|
| 539 |
- def on_language_changed(self, checker, param):
|
|
| 548 |
+ def on_language_changed(self, checker, _param):
|
|
| 540 | 549 |
gspell_lang = checker.get_language()
|
| 541 | 550 |
per_type = 'contacts'
|
| 542 | 551 |
if self.type_id == message_control.TYPE_GC:
|
| ... | ... | @@ -553,7 +562,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 553 | 562 |
self.msg_textview.grab_focus()
|
| 554 | 563 |
return Gdk.EVENT_STOP
|
| 555 | 564 |
|
| 556 |
- def on_banner_label_populate_popup(self, label, menu):
|
|
| 565 |
+ def on_banner_label_populate_popup(self, _label, menu):
|
|
| 557 | 566 |
"""
|
| 558 | 567 |
Override the default context menu and add our own menuitems
|
| 559 | 568 |
"""
|
| ... | ... | @@ -571,22 +580,19 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 571 | 580 |
|
| 572 | 581 |
def shutdown(self):
|
| 573 | 582 |
super(ChatControlBase, self).shutdown()
|
| 574 |
- # PluginSystem: removing GUI extension points connected with ChatControlBase
|
|
| 575 |
- # instance object
|
|
| 583 |
+ # PluginSystem: removing GUI extension points
|
|
| 584 |
+ # connected with ChatControlBase instance object
|
|
| 576 | 585 |
app.plugin_manager.remove_gui_extension_point('chat_control_base', self)
|
| 577 | 586 |
app.plugin_manager.remove_gui_extension_point(
|
| 578 | 587 |
'chat_control_base_draw_banner', self)
|
| 579 | 588 |
app.plugin_manager.remove_gui_extension_point(
|
| 580 | 589 |
'chat_control_base_update_toolbar', self)
|
| 581 |
- app.ged.remove_event_handler('our-show', ged.GUI1,
|
|
| 582 |
- self._nec_our_status)
|
|
| 583 |
- app.ged.remove_event_handler('sec-catalog-received', ged.GUI1,
|
|
| 584 |
- self._sec_labels_received)
|
|
| 585 |
- app.ged.remove_event_handler('style-changed', ged.GUI1,
|
|
| 586 |
- self._style_changed)
|
|
| 587 | 590 |
|
| 591 |
+ # Unregister handlers
|
|
| 592 |
+ for handler in self._base_event_handlers:
|
|
| 593 |
+ app.ged.remove_event_handler(*handler)
|
|
| 588 | 594 |
|
| 589 |
- def on_msg_textview_populate_popup(self, textview, menu):
|
|
| 595 |
+ def on_msg_textview_populate_popup(self, _textview, menu):
|
|
| 590 | 596 |
"""
|
| 591 | 597 |
Override the default context menu and we prepend an option to switch
|
| 592 | 598 |
languages
|
| ... | ... | @@ -622,18 +628,18 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 622 | 628 |
text = clipboard.wait_for_text()
|
| 623 | 629 |
self.insert_as_quote(text)
|
| 624 | 630 |
|
| 625 |
- def on_quote(self, widget, text):
|
|
| 631 |
+ def on_quote(self, _widget, text):
|
|
| 626 | 632 |
self.insert_as_quote(text)
|
| 627 | 633 |
|
| 628 | 634 |
# moved from ChatControl
|
| 629 |
- def _on_banner_eventbox_button_press_event(self, widget, event):
|
|
| 635 |
+ def _on_banner_eventbox_button_press_event(self, _widget, event):
|
|
| 630 | 636 |
"""
|
| 631 | 637 |
If right-clicked, show popup
|
| 632 | 638 |
"""
|
| 633 | 639 |
if event.button == 3: # right click
|
| 634 | 640 |
self.parent_win.popup_menu(event)
|
| 635 | 641 |
|
| 636 |
- def _on_message_textview_paste_event(self, texview):
|
|
| 642 |
+ def _on_message_textview_paste_event(self, _texview):
|
|
| 637 | 643 |
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
| 638 | 644 |
image = clipboard.wait_for_image()
|
| 639 | 645 |
if image is not None:
|
| ... | ... | @@ -706,7 +712,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 706 | 712 |
# pressing Control again (as in ctrl+z)
|
| 707 | 713 |
_buffer = widget.get_buffer()
|
| 708 | 714 |
start_iter, end_iter = _buffer.get_bounds()
|
| 709 |
- self.msg_textview.save_undo(_buffer.get_text(start_iter, end_iter, True))
|
|
| 715 |
+ self.msg_textview.save_undo(_buffer.get_text(start_iter,
|
|
| 716 |
+ end_iter,
|
|
| 717 |
+ True))
|
|
| 710 | 718 |
self.space_pressed = False
|
| 711 | 719 |
|
| 712 | 720 |
# Ctrl [+ Shift] + Tab are not forwarded to notebook. We handle it here
|
| ... | ... | @@ -738,8 +746,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 738 | 746 |
end = message_buffer.get_iter_at_mark(position)
|
| 739 | 747 |
text = message_buffer.get_text(start, end, False)
|
| 740 | 748 |
splitted = text.split()
|
| 741 |
- if (text.startswith(self.COMMAND_PREFIX) and not
|
|
| 742 |
- text.startswith(self.COMMAND_PREFIX * 2) and len(splitted) == 1):
|
|
| 749 |
+ if (text.startswith(self.COMMAND_PREFIX) and
|
|
| 750 |
+ not text.startswith(self.COMMAND_PREFIX * 2) and
|
|
| 751 |
+ len(splitted) == 1):
|
|
| 743 | 752 |
text = splitted[0]
|
| 744 | 753 |
bare = text.lstrip(self.COMMAND_PREFIX)
|
| 745 | 754 |
if len(text) == 1:
|
| ... | ... | @@ -816,7 +825,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 816 | 825 |
return False
|
| 817 | 826 |
|
| 818 | 827 |
def _on_drag_data_received(self, widget, context, x, y, selection,
|
| 819 |
- target_type, timestamp):
|
|
| 828 |
+ target_type, timestamp):
|
|
| 820 | 829 |
"""
|
| 821 | 830 |
Derived types SHOULD implement this
|
| 822 | 831 |
"""
|
| ... | ... | @@ -829,11 +838,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 829 | 838 |
def _on_drag_motion(self, *args):
|
| 830 | 839 |
# FIXME: DND on non editable TextView, find a better way
|
| 831 | 840 |
if not self.drag_entered:
|
| 832 |
- # We drag new data over the TextView, make it editable to catch dnd
|
|
| 833 |
- self.drag_entered_conv = True
|
|
| 834 | 841 |
self.conv_textview.tv.set_editable(True)
|
| 835 | 842 |
|
| 836 |
- def drag_data_file_transfer(self, contact, selection, widget):
|
|
| 843 |
+ def drag_data_file_transfer(self, contact, selection, _widget):
|
|
| 837 | 844 |
# get file transfer preference
|
| 838 | 845 |
ft_pref = app.config.get_per('accounts', self.account,
|
| 839 | 846 |
'filetransfer_preference')
|
| ... | ... | @@ -874,7 +881,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 874 | 881 |
def get_seclabel(self):
|
| 875 | 882 |
idx = self.xml.label_selector.get_active()
|
| 876 | 883 |
if idx == -1:
|
| 877 |
- return
|
|
| 884 |
+ return None
|
|
| 878 | 885 |
|
| 879 | 886 |
con = app.connections[self.account]
|
| 880 | 887 |
jid = self.contact.jid
|
| ... | ... | @@ -886,8 +893,13 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 886 | 893 |
label = labels[lname]
|
| 887 | 894 |
return label
|
| 888 | 895 |
|
| 889 |
- def send_message(self, message, type_='chat',
|
|
| 890 |
- resource=None, xhtml=None, process_commands=True, attention=False):
|
|
| 896 |
+ def send_message(self,
|
|
| 897 |
+ message,
|
|
| 898 |
+ type_='chat',
|
|
| 899 |
+ resource=None,
|
|
| 900 |
+ xhtml=None,
|
|
| 901 |
+ process_commands=True,
|
|
| 902 |
+ attention=False):
|
|
| 891 | 903 |
"""
|
| 892 | 904 |
Send the given message to the active tab. Doesn't return None if error
|
| 893 | 905 |
"""
|
| ... | ... | @@ -996,13 +1008,24 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 996 | 1008 |
self.conv_textview.print_conversation_line(
|
| 997 | 1009 |
text, 'status', '', None)
|
| 998 | 1010 |
|
| 999 |
- def add_message(self, text, kind, name, tim,
|
|
| 1000 |
- other_tags_for_name=None, other_tags_for_time=None,
|
|
| 1001 |
- other_tags_for_text=None, restored=False, subject=None,
|
|
| 1011 |
+ def add_message(self,
|
|
| 1012 |
+ text,
|
|
| 1013 |
+ kind,
|
|
| 1014 |
+ name,
|
|
| 1015 |
+ tim,
|
|
| 1016 |
+ other_tags_for_name=None,
|
|
| 1017 |
+ other_tags_for_time=None,
|
|
| 1018 |
+ other_tags_for_text=None,
|
|
| 1019 |
+ restored=False,
|
|
| 1020 |
+ subject=None,
|
|
| 1002 | 1021 |
old_kind=None,
|
| 1003 |
- displaymarking=None, msg_log_id=None,
|
|
| 1004 |
- message_id=None, correct_id=None, additional_data=None,
|
|
| 1005 |
- marker=None, error=None):
|
|
| 1022 |
+ displaymarking=None,
|
|
| 1023 |
+ msg_log_id=None,
|
|
| 1024 |
+ message_id=None,
|
|
| 1025 |
+ correct_id=None,
|
|
| 1026 |
+ additional_data=None,
|
|
| 1027 |
+ marker=None,
|
|
| 1028 |
+ error=None):
|
|
| 1006 | 1029 |
"""
|
| 1007 | 1030 |
Print 'chat' type messages
|
| 1008 | 1031 |
correct_id = (message_id, correct_id)
|
| ... | ... | @@ -1023,12 +1046,21 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1023 | 1046 |
if additional_data is None:
|
| 1024 | 1047 |
additional_data = AdditionalDataDict()
|
| 1025 | 1048 |
|
| 1026 |
- textview.print_conversation_line(text, kind, name, tim,
|
|
| 1027 |
- other_tags_for_name, other_tags_for_time, other_tags_for_text,
|
|
| 1028 |
- subject, old_kind,
|
|
| 1029 |
- displaymarking=displaymarking, message_id=message_id,
|
|
| 1030 |
- correct_id=correct_id, additional_data=additional_data,
|
|
| 1031 |
- marker=marker, error=error)
|
|
| 1049 |
+ textview.print_conversation_line(text,
|
|
| 1050 |
+ kind,
|
|
| 1051 |
+ name,
|
|
| 1052 |
+ tim,
|
|
| 1053 |
+ other_tags_for_name,
|
|
| 1054 |
+ other_tags_for_time,
|
|
| 1055 |
+ other_tags_for_text,
|
|
| 1056 |
+ subject,
|
|
| 1057 |
+ old_kind,
|
|
| 1058 |
+ displaymarking=displaymarking,
|
|
| 1059 |
+ message_id=message_id,
|
|
| 1060 |
+ correct_id=correct_id,
|
|
| 1061 |
+ additional_data=additional_data,
|
|
| 1062 |
+ marker=marker,
|
|
| 1063 |
+ error=error)
|
|
| 1032 | 1064 |
|
| 1033 | 1065 |
if restored:
|
| 1034 | 1066 |
return
|
| ... | ... | @@ -1075,14 +1107,16 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1075 | 1107 |
show_in_systray = get_show_in_systray(
|
| 1076 | 1108 |
event_type.type_, self.contact.jid)
|
| 1077 | 1109 |
|
| 1078 |
- event = event_type(text, subject, self, msg_log_id,
|
|
| 1079 |
- show_in_roster=show_in_roster,
|
|
| 1080 |
- show_in_systray=show_in_systray)
|
|
| 1110 |
+ event = event_type(text,
|
|
| 1111 |
+ subject,
|
|
| 1112 |
+ self, msg_log_id,
|
|
| 1113 |
+ show_in_roster=show_in_roster,
|
|
| 1114 |
+ show_in_systray=show_in_systray)
|
|
| 1081 | 1115 |
app.events.add_event(self.account, full_jid, event)
|
| 1082 | 1116 |
# We need to redraw contact if we show in roster
|
| 1083 | 1117 |
if show_in_roster:
|
| 1084 | 1118 |
app.interface.roster.draw_contact(self.contact.jid,
|
| 1085 |
- self.account)
|
|
| 1119 |
+ self.account)
|
|
| 1086 | 1120 |
|
| 1087 | 1121 |
if not self.parent_win:
|
| 1088 | 1122 |
return
|
| ... | ... | @@ -1118,13 +1152,13 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1118 | 1152 |
emoji_chooser.text_widget = self.msg_textview
|
| 1119 | 1153 |
self.xml.emoticons_button.set_popover(emoji_chooser)
|
| 1120 | 1154 |
|
| 1121 |
- def on_color_menuitem_activate(self, widget):
|
|
| 1155 |
+ def on_color_menuitem_activate(self, _widget):
|
|
| 1122 | 1156 |
color_dialog = Gtk.ColorChooserDialog(None, self.parent_win.window)
|
| 1123 | 1157 |
color_dialog.set_use_alpha(False)
|
| 1124 | 1158 |
color_dialog.connect('response', self.msg_textview.color_set)
|
| 1125 | 1159 |
color_dialog.show_all()
|
| 1126 | 1160 |
|
| 1127 |
- def on_font_menuitem_activate(self, widget):
|
|
| 1161 |
+ def on_font_menuitem_activate(self, _widget):
|
|
| 1128 | 1162 |
font_dialog = Gtk.FontChooserDialog(None, self.parent_win.window)
|
| 1129 | 1163 |
start, finish = self.msg_textview.get_active_iters()
|
| 1130 | 1164 |
font_dialog.connect('response', self.msg_textview.font_set, start, finish)
|
| ... | ... | @@ -1134,7 +1168,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1134 | 1168 |
tag = widget.get_name()
|
| 1135 | 1169 |
self.msg_textview.set_tag(tag)
|
| 1136 | 1170 |
|
| 1137 |
- def on_clear_formatting_menuitem_activate(self, widget):
|
|
| 1171 |
+ def on_clear_formatting_menuitem_activate(self, _widget):
|
|
| 1138 | 1172 |
self.msg_textview.clear_tags()
|
| 1139 | 1173 |
|
| 1140 | 1174 |
def _style_changed(self, *args):
|
| ... | ... | @@ -1143,12 +1177,13 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1143 | 1177 |
def update_tags(self):
|
| 1144 | 1178 |
self.conv_textview.update_tags()
|
| 1145 | 1179 |
|
| 1146 |
- def clear(self, tv):
|
|
| 1180 |
+ @staticmethod
|
|
| 1181 |
+ def clear(tv):
|
|
| 1147 | 1182 |
buffer_ = tv.get_buffer()
|
| 1148 | 1183 |
start, end = buffer_.get_bounds()
|
| 1149 | 1184 |
buffer_.delete(start, end)
|
| 1150 | 1185 |
|
| 1151 |
- def _on_send_file(self, action, param):
|
|
| 1186 |
+ def _on_send_file(self, _action, _param):
|
|
| 1152 | 1187 |
# get file transfer preference
|
| 1153 | 1188 |
ft_pref = app.config.get_per('accounts', self.account,
|
| 1154 | 1189 |
'filetransfer_preference')
|
| ... | ... | @@ -1168,19 +1203,20 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1168 | 1203 |
elif jingle.get_enabled():
|
| 1169 | 1204 |
jingle.activate()
|
| 1170 | 1205 |
|
| 1171 |
- def _on_send_httpupload(self, action, param):
|
|
| 1206 |
+ def _on_send_httpupload(self, _action, _param):
|
|
| 1172 | 1207 |
app.interface.send_httpupload(self)
|
| 1173 | 1208 |
|
| 1174 |
- def _on_send_jingle(self, action, param):
|
|
| 1209 |
+ def _on_send_jingle(self, _action, _param):
|
|
| 1175 | 1210 |
self._on_send_file_jingle()
|
| 1176 | 1211 |
|
| 1177 | 1212 |
def _on_send_file_jingle(self, gc_contact=None):
|
| 1178 | 1213 |
"""
|
| 1179 | 1214 |
gc_contact can be set when we are in a groupchat control
|
| 1180 | 1215 |
"""
|
| 1181 |
- def _on_ok(c):
|
|
| 1216 |
+ def _on_ok(_contact):
|
|
| 1182 | 1217 |
app.interface.instances['file_transfers'].show_file_send_request(
|
| 1183 |
- self.account, c)
|
|
| 1218 |
+ self.account, _contact)
|
|
| 1219 |
+ |
|
| 1184 | 1220 |
if self.type_id == message_control.TYPE_PM:
|
| 1185 | 1221 |
gc_contact = self.gc_contact
|
| 1186 | 1222 |
|
| ... | ... | @@ -1214,8 +1250,10 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1214 | 1250 |
_on_ok(gc_contact)
|
| 1215 | 1251 |
|
| 1216 | 1252 |
def on_notify_menuitem_toggled(self, widget):
|
| 1217 |
- app.config.set_per('rooms', self.contact.jid, 'notify_on_all_messages',
|
|
| 1218 |
- widget.get_active())
|
|
| 1253 |
+ app.config.set_per('rooms',
|
|
| 1254 |
+ self.contact.jid,
|
|
| 1255 |
+ 'notify_on_all_messages',
|
|
| 1256 |
+ widget.get_active())
|
|
| 1219 | 1257 |
|
| 1220 | 1258 |
def set_control_active(self, state):
|
| 1221 | 1259 |
con = app.connections[self.account]
|
| ... | ... | @@ -1227,8 +1265,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1227 | 1265 |
type_ = ['printed_' + self.type_id]
|
| 1228 | 1266 |
if self.type_id == message_control.TYPE_GC:
|
| 1229 | 1267 |
type_ = ['printed_gc_msg', 'printed_marked_gc_msg']
|
| 1230 |
- if not app.events.remove_events(self.account, self.get_full_jid(),
|
|
| 1231 |
- types=type_):
|
|
| 1268 |
+ if not app.events.remove_events(self.account,
|
|
| 1269 |
+ self.get_full_jid(),
|
|
| 1270 |
+ types=type_):
|
|
| 1232 | 1271 |
# There were events to remove
|
| 1233 | 1272 |
self.redraw_after_event_removed(jid)
|
| 1234 | 1273 |
# send chatstate inactive to the one we're leaving
|
| ... | ... | @@ -1246,7 +1285,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1246 | 1285 |
def scroll_to_end(self, force=False):
|
| 1247 | 1286 |
self.conv_textview.scroll_to_end(force)
|
| 1248 | 1287 |
|
| 1249 |
- def _on_edge_reached(self, scrolledwindow, pos):
|
|
| 1288 |
+ def _on_edge_reached(self, _scrolledwindow, pos):
|
|
| 1250 | 1289 |
if pos != Gtk.PositionType.BOTTOM:
|
| 1251 | 1290 |
return
|
| 1252 | 1291 |
# Remove all events and set autoscroll True
|
| ... | ... | @@ -1331,7 +1370,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1331 | 1370 |
app.log('autoscroll').info('Autoscroll disabled')
|
| 1332 | 1371 |
self.conv_textview.autoscroll = False
|
| 1333 | 1372 |
|
| 1334 |
- def on_conversation_vadjustment_changed(self, adjustment):
|
|
| 1373 |
+ def on_conversation_vadjustment_changed(self, _adjustment):
|
|
| 1335 | 1374 |
self.scroll_to_end()
|
| 1336 | 1375 |
|
| 1337 | 1376 |
def redraw_after_event_removed(self, jid):
|
| ... | ... | @@ -1345,7 +1384,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1345 | 1384 |
if self.type_id == message_control.TYPE_PM:
|
| 1346 | 1385 |
room_jid, nick = app.get_room_and_nick_from_fjid(jid)
|
| 1347 | 1386 |
groupchat_control = app.interface.msg_win_mgr.get_gc_control(
|
| 1348 |
- room_jid, self.account)
|
|
| 1387 |
+ room_jid, self.account)
|
|
| 1349 | 1388 |
if room_jid in app.interface.minimized_controls[self.account]:
|
| 1350 | 1389 |
groupchat_control = \
|
| 1351 | 1390 |
app.interface.minimized_controls[self.account][room_jid]
|
| ... | ... | @@ -1418,7 +1457,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1418 | 1457 |
self.msg_textview.set_editable(False)
|
| 1419 | 1458 |
self.conv_textview.tv.grab_focus()
|
| 1420 | 1459 |
|
| 1421 |
- self.no_autonegotiation = False
|
|
| 1422 | 1460 |
self.update_toolbar()
|
| 1423 | 1461 |
|
| 1424 | 1462 |
|
| ... | ... | @@ -57,6 +57,7 @@ class PrivateChatControl(ChatControl): |
| 57 | 57 |
ChatControl.__init__(self, parent_win, contact, account, session)
|
| 58 | 58 |
self.TYPE_ID = 'pm'
|
| 59 | 59 |
|
| 60 |
+ # pylint: disable=line-too-long
|
|
| 60 | 61 |
self.__event_handlers = [
|
| 61 | 62 |
('update-gc-avatar', ged.GUI1, self._nec_update_avatar),
|
| 62 | 63 |
('caps-update', ged.GUI1, self._nec_caps_received_pm),
|
| ... | ... | @@ -68,6 +69,7 @@ class PrivateChatControl(ChatControl): |
| 68 | 69 |
('muc-user-status-show-changed', ged.GUI1, self._on_status_show_changed),
|
| 69 | 70 |
('muc-destroyed', ged.GUI1, self._on_diconnected),
|
| 70 | 71 |
]
|
| 72 |
+ # pylint: enable=line-too-long
|
|
| 71 | 73 |
|
| 72 | 74 |
for handler in self.__event_handlers:
|
| 73 | 75 |
app.ged.register_event_handler(*handler)
|