Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
9314a054
by Philipp Hörist at 2018-03-24T01:47:03+01:00
-
af2c66b5
by Philipp Hörist at 2018-03-24T02:36:22+01:00
5 changed files:
- gajim/chat_control_base.py
- gajim/common/config.py
- gajim/common/connection_handlers.py
- gajim/common/helpers.py
- gajim/common/message_archiving.py
Changes:
| ... | ... | @@ -596,9 +596,12 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 596 | 596 |
valid, entries = self.keymap.get_entries_for_keyval(event.keyval)
|
| 597 | 597 |
keycode = entries[0].keycode
|
| 598 | 598 |
if (event.get_state() & Gdk.ModifierType.CONTROL_MASK and keycode in (
|
| 599 |
- self.keycode_c, self.keycode_ins)) or (
|
|
| 600 |
- event.get_state() & Gdk.ModifierType.SHIFT_MASK and \
|
|
| 601 |
- event.keyval in (Gdk.KEY_Page_Down, Gdk.KEY_Page_Up)):
|
|
| 599 |
+ self.keycode_c, self.keycode_ins)):
|
|
| 600 |
+ return False
|
|
| 601 |
+
|
|
| 602 |
+ if event.get_state() & Gdk.ModifierType.SHIFT_MASK and \
|
|
| 603 |
+ event.keyval in (Gdk.KEY_Page_Down, Gdk.KEY_Page_Up):
|
|
| 604 |
+ self._on_scroll(None, event.keyval)
|
|
| 602 | 605 |
return False
|
| 603 | 606 |
self.parent_win.notebook.event(event)
|
| 604 | 607 |
return True
|
| ... | ... | @@ -1224,6 +1227,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1224 | 1227 |
if pos != Gtk.PositionType.BOTTOM:
|
| 1225 | 1228 |
return
|
| 1226 | 1229 |
# Remove all events and set autoscroll True
|
| 1230 |
+ app.log('autoscroll').info('Autoscroll enabled')
|
|
| 1227 | 1231 |
self.conv_textview.autoscroll = True
|
| 1228 | 1232 |
if self.resource:
|
| 1229 | 1233 |
jid = self.contact.get_full_jid()
|
| ... | ... | @@ -1253,13 +1257,27 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1253 | 1257 |
self.redraw_after_event_removed(jid)
|
| 1254 | 1258 |
|
| 1255 | 1259 |
def _on_scroll(self, widget, event):
|
| 1256 |
- # On scrolliung UP disable autoscroll
|
|
| 1257 |
- has_direction, direction = event.get_scroll_direction()
|
|
| 1258 |
- if has_direction and direction == Gdk.ScrollDirection.UP:
|
|
| 1259 |
- # Check if we have a Scrollbar
|
|
| 1260 |
- adjustment = self.conv_scrolledwindow.get_vadjustment()
|
|
| 1261 |
- if adjustment.get_upper() != adjustment.get_page_size():
|
|
| 1262 |
- self.conv_textview.autoscroll = False
|
|
| 1260 |
+ if not self.conv_textview.autoscroll:
|
|
| 1261 |
+ # autoscroll is already disabled
|
|
| 1262 |
+ return
|
|
| 1263 |
+ |
|
| 1264 |
+ if widget is None:
|
|
| 1265 |
+ # call from _conv_textview_key_press_event()
|
|
| 1266 |
+ # SHIFT + Gdk.KEY_Page_Up
|
|
| 1267 |
+ if event != Gdk.KEY_Page_Up:
|
|
| 1268 |
+ return
|
|
| 1269 |
+ else:
|
|
| 1270 |
+ # On scrolliung UP disable autoscroll
|
|
| 1271 |
+ # has_direction is on some systems always False
|
|
| 1272 |
+ # so we cant use it
|
|
| 1273 |
+ has_direction, direction = event.get_scroll_direction()
|
|
| 1274 |
+ if direction != Gdk.ScrollDirection.UP:
|
|
| 1275 |
+ return
|
|
| 1276 |
+ # Check if we have a Scrollbar
|
|
| 1277 |
+ adjustment = self.conv_scrolledwindow.get_vadjustment()
|
|
| 1278 |
+ if adjustment.get_upper() != adjustment.get_page_size():
|
|
| 1279 |
+ app.log('autoscroll').info('Autoscroll disabled')
|
|
| 1280 |
+ self.conv_textview.autoscroll = False
|
|
| 1263 | 1281 |
|
| 1264 | 1282 |
def on_conversation_vadjustment_changed(self, adjustment):
|
| 1265 | 1283 |
self.scroll_to_end()
|
| ... | ... | @@ -305,6 +305,7 @@ class Config: |
| 305 | 305 |
'use_keyring': [opt_bool, True, _('If True, Gajim will use the Systems Keyring to store account passwords.')],
|
| 306 | 306 |
'pgp_encoding': [ opt_str, '', _('Sets the encoding used by python-gnupg'), True],
|
| 307 | 307 |
'remote_commands': [opt_bool, False, _('If True, Gajim will execute XEP-0146 Commands.')],
|
| 308 |
+ 'mam_blacklist': [opt_str, '', _('All non-compliant MAM Groupchats')],
|
|
| 308 | 309 |
}, {})
|
| 309 | 310 |
|
| 310 | 311 |
__options_per_key = {
|
| ... | ... | @@ -1067,9 +1067,17 @@ class ConnectionHandlersBase: |
| 1067 | 1067 |
conn=self, msg_obj=obj, stanza_id=obj.unique_id))
|
| 1068 | 1068 |
return True
|
| 1069 | 1069 |
|
| 1070 |
+ def _check_for_mam_compliance(self, room_jid, stanza_id):
|
|
| 1071 |
+ namespace = muc_caps_cache.get_mam_namespace(room_jid)
|
|
| 1072 |
+ if stanza_id is None and namespace == nbxmpp.NS_MAM_2:
|
|
| 1073 |
+ helpers.add_to_mam_blacklist(room_jid)
|
|
| 1074 |
+ |
|
| 1070 | 1075 |
def _nec_gc_message_received(self, obj):
|
| 1071 | 1076 |
if obj.conn.name != self.name:
|
| 1072 | 1077 |
return
|
| 1078 |
+ |
|
| 1079 |
+ self._check_for_mam_compliance(obj.jid, obj.unique_id)
|
|
| 1080 |
+ |
|
| 1073 | 1081 |
if (app.config.should_log(obj.conn.name, obj.jid) and
|
| 1074 | 1082 |
obj.msgtxt and obj.nick):
|
| 1075 | 1083 |
# if not obj.nick, it means message comes from room itself
|
| ... | ... | @@ -1626,3 +1626,21 @@ def get_emoticon_theme_path(theme): |
| 1626 | 1626 |
emoticons_user_path = os.path.join(app.MY_EMOTS_PATH, theme)
|
| 1627 | 1627 |
if os.path.exists(emoticons_user_path):
|
| 1628 | 1628 |
return emoticons_user_path
|
| 1629 |
+ |
|
| 1630 |
+def add_to_mam_blacklist(jid):
|
|
| 1631 |
+ config_value = app.config.get('mam_blacklist')
|
|
| 1632 |
+ if not config_value:
|
|
| 1633 |
+ config_value = [jid]
|
|
| 1634 |
+ else:
|
|
| 1635 |
+ if jid in config_value:
|
|
| 1636 |
+ return
|
|
| 1637 |
+ config_value = config_value.split(',')
|
|
| 1638 |
+ config_value.append(jid)
|
|
| 1639 |
+ log.warning('Found not-compliant MUC. %s added to MAM Blacklist', jid)
|
|
| 1640 |
+ app.config.set('mam_blacklist', ','.join(config_value))
|
|
| 1641 |
+ |
|
| 1642 |
+def get_mam_blacklist():
|
|
| 1643 |
+ config_value = app.config.get('mam_blacklist')
|
|
| 1644 |
+ if not config_value:
|
|
| 1645 |
+ return []
|
|
| 1646 |
+ return config_value.split(',')
|
| ... | ... | @@ -25,6 +25,7 @@ import nbxmpp |
| 25 | 25 |
|
| 26 | 26 |
from gajim.common import app
|
| 27 | 27 |
from gajim.common import ged
|
| 28 |
+from gajim.common import helpers
|
|
| 28 | 29 |
from gajim.common.logger import KindConstant, JIDConstant
|
| 29 | 30 |
from gajim.common.const import ArchiveState
|
| 30 | 31 |
from gajim.common.caps_cache import muc_caps_cache
|
| ... | ... | @@ -205,7 +206,8 @@ class ConnectionArchive313: |
| 205 | 206 |
if obj.groupchat:
|
| 206 | 207 |
namespace = muc_caps_cache.get_mam_namespace(obj.room_jid)
|
| 207 | 208 |
|
| 208 |
- if namespace != nbxmpp.NS_MAM_2:
|
|
| 209 |
+ blacklisted = obj.room_jid in helpers.get_mam_blacklist()
|
|
| 210 |
+ if namespace != nbxmpp.NS_MAM_2 or blacklisted:
|
|
| 209 | 211 |
# Fallback duplicate search without stanza-id
|
| 210 | 212 |
duplicate = app.logger.search_for_duplicate(
|
| 211 | 213 |
self.name, obj.with_, obj.timestamp, obj.msgtxt)
|