Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
4caa4971
by Philipp Hörist at 2018-04-04T01:13:02+02:00
3 changed files:
Changes:
| ... | ... | @@ -242,6 +242,9 @@ class ChatControl(ChatControlBase): |
| 242 | 242 |
app.ged.register_event_handler(
|
| 243 | 243 |
'mam-decrypted-message-received',
|
| 244 | 244 |
ged.GUI1, self._nec_mam_decrypted_message_received)
|
| 245 |
+ app.ged.register_event_handler(
|
|
| 246 |
+ 'decrypted-message-received',
|
|
| 247 |
+ ged.GUI1, self._nec_decrypted_message_received)
|
|
| 245 | 248 |
|
| 246 | 249 |
# PluginSystem: adding GUI extension point for this ChatControl
|
| 247 | 250 |
# instance object
|
| ... | ... | @@ -822,6 +825,36 @@ class ChatControl(ChatControlBase): |
| 822 | 825 |
encrypted=obj.encrypted, correct_id=obj.correct_id,
|
| 823 | 826 |
msg_stanza_id=obj.message_id, additional_data=obj.additional_data)
|
| 824 | 827 |
|
| 828 |
+ def _nec_decrypted_message_received(self, obj):
|
|
| 829 |
+ if not obj.msgtxt:
|
|
| 830 |
+ return True
|
|
| 831 |
+ if obj.conn.name != self.account:
|
|
| 832 |
+ return
|
|
| 833 |
+ if obj.mtype != 'chat':
|
|
| 834 |
+ return
|
|
| 835 |
+ if obj.session.control != self:
|
|
| 836 |
+ return
|
|
| 837 |
+ |
|
| 838 |
+ typ = ''
|
|
| 839 |
+ xep0184_id = None
|
|
| 840 |
+ if obj.mtype == 'error':
|
|
| 841 |
+ typ = 'error'
|
|
| 842 |
+ if obj.forwarded and obj.sent:
|
|
| 843 |
+ typ = 'out'
|
|
| 844 |
+ if obj.jid != app.get_jid_from_account(obj.conn.name):
|
|
| 845 |
+ xep0184_id = obj.id_
|
|
| 846 |
+ self.print_conversation(obj.msgtxt, typ,
|
|
| 847 |
+ tim=obj.timestamp, encrypted=obj.encrypted, subject=obj.subject,
|
|
| 848 |
+ xhtml=obj.xhtml, displaymarking=obj.displaymarking,
|
|
| 849 |
+ msg_log_id=obj.msg_log_id, msg_stanza_id=obj.id_, correct_id=obj.correct_id,
|
|
| 850 |
+ xep0184_id=xep0184_id, additional_data=obj.additional_data)
|
|
| 851 |
+ if obj.msg_log_id:
|
|
| 852 |
+ pw = self.parent_win
|
|
| 853 |
+ end = self.conv_textview.autoscroll
|
|
| 854 |
+ if not pw or (pw.get_active_control() and self \
|
|
| 855 |
+ == pw.get_active_control() and pw.is_active() and end):
|
|
| 856 |
+ app.logger.set_read_messages([obj.msg_log_id])
|
|
| 857 |
+ |
|
| 825 | 858 |
def _message_sent(self, obj):
|
| 826 | 859 |
if obj.conn.name != self.account:
|
| 827 | 860 |
return
|
| ... | ... | @@ -1164,6 +1197,9 @@ class ChatControl(ChatControlBase): |
| 1164 | 1197 |
app.ged.remove_event_handler(
|
| 1165 | 1198 |
'mam-decrypted-message-received',
|
| 1166 | 1199 |
ged.GUI1, self._nec_mam_decrypted_message_received)
|
| 1200 |
+ app.ged.remove_event_handler(
|
|
| 1201 |
+ 'decrypted-message-received',
|
|
| 1202 |
+ ged.GUI1, self._nec_decrypted_message_received)
|
|
| 1167 | 1203 |
|
| 1168 | 1204 |
self.unsubscribe_events()
|
| 1169 | 1205 |
|
| ... | ... | @@ -2695,8 +2695,6 @@ class RosterWindow: |
| 2695 | 2695 |
self.draw_account(obj.conn.name)
|
| 2696 | 2696 |
|
| 2697 | 2697 |
def _nec_decrypted_message_received(self, obj):
|
| 2698 |
- if not obj.msgtxt: # empty message text
|
|
| 2699 |
- return True
|
|
| 2700 | 2698 |
if obj.mtype not in ('normal', 'chat'):
|
| 2701 | 2699 |
return
|
| 2702 | 2700 |
if obj.mtype == 'normal' and obj.popup:
|
| ... | ... | @@ -2706,28 +2704,8 @@ class RosterWindow: |
| 2706 | 2704 |
message=obj.msgtxt, resource=obj.resource, session=obj.session,
|
| 2707 | 2705 |
form_node=obj.form_node)
|
| 2708 | 2706 |
return
|
| 2709 |
- if obj.session.control and obj.mtype == 'chat':
|
|
| 2710 |
- typ = ''
|
|
| 2711 |
- xep0184_id = None
|
|
| 2712 |
- if obj.mtype == 'error':
|
|
| 2713 |
- typ = 'error'
|
|
| 2714 |
- if obj.forwarded and obj.sent:
|
|
| 2715 |
- typ = 'out'
|
|
| 2716 |
- if obj.jid != app.get_jid_from_account(obj.conn.name):
|
|
| 2717 |
- xep0184_id = obj.id_
|
|
| 2718 |
- |
|
| 2719 |
- obj.session.control.print_conversation(obj.msgtxt, typ,
|
|
| 2720 |
- tim=obj.timestamp, encrypted=obj.encrypted, subject=obj.subject,
|
|
| 2721 |
- xhtml=obj.xhtml, displaymarking=obj.displaymarking,
|
|
| 2722 |
- msg_log_id=obj.msg_log_id, msg_stanza_id=obj.id_, correct_id=obj.correct_id,
|
|
| 2723 |
- xep0184_id=xep0184_id, additional_data=obj.additional_data)
|
|
| 2724 |
- if obj.msg_log_id:
|
|
| 2725 |
- pw = obj.session.control.parent_win
|
|
| 2726 |
- end = obj.session.control.conv_textview.autoscroll
|
|
| 2727 |
- if not pw or (pw.get_active_control() and obj.session.control \
|
|
| 2728 |
- == pw.get_active_control() and pw.is_active() and end):
|
|
| 2729 |
- app.logger.set_read_messages([obj.msg_log_id])
|
|
| 2730 |
- elif obj.popup and obj.mtype == 'chat':
|
|
| 2707 |
+ |
|
| 2708 |
+ if obj.popup and obj.mtype == 'chat' and not obj.session.control:
|
|
| 2731 | 2709 |
contact = app.contacts.get_contact(obj.conn.name, obj.jid)
|
| 2732 | 2710 |
obj.session.control = app.interface.new_chat(contact,
|
| 2733 | 2711 |
obj.conn.name, session=obj.session)
|
| ... | ... | @@ -40,7 +40,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): |
| 40 | 40 |
def __init__(self, conn, jid, thread_id, type_='chat'):
|
| 41 | 41 |
stanza_session.EncryptedStanzaSession.__init__(self, conn, jid, thread_id,
|
| 42 | 42 |
type_='chat')
|
| 43 |
- app.ged.register_event_handler('decrypted-message-received', ged.GUI1,
|
|
| 43 |
+ app.ged.register_event_handler('decrypted-message-received', ged.PREGUI,
|
|
| 44 | 44 |
self._nec_decrypted_message_received)
|
| 45 | 45 |
|
| 46 | 46 |
self.control = None
|