summaryrefslogtreecommitdiff
path: root/src/tabs.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-02-25 18:58:33 +0100
committermathieui <mathieui@mathieui.net>2012-02-25 18:58:33 +0100
commit73c8206cc7926757ccc963ede581989078e6c780 (patch)
tree35218687d8250382d2cd6bbc25becba081fd430a /src/tabs.py
parente3f0faf6d0dfd8d3b450b06aebf90614061245c9 (diff)
downloadpoezio-73c8206cc7926757ccc963ede581989078e6c780.tar.gz
poezio-73c8206cc7926757ccc963ede581989078e6c780.tar.bz2
poezio-73c8206cc7926757ccc963ede581989078e6c780.tar.xz
poezio-73c8206cc7926757ccc963ede581989078e6c780.zip
Fourth of #2336 (fixes #2336)
Diffstat (limited to 'src/tabs.py')
-rw-r--r--src/tabs.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tabs.py b/src/tabs.py
index 8760abe8..2f384e22 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -39,6 +39,8 @@ import multiuserchat as muc
from theming import get_theme
from sleekxmpp.xmlstream.stanzabase import JID
+from sleekxmpp.xmlstream import matcher
+from sleekxmpp.xmlstream.handler import Callback
from config import config
from roster import RosterGroup, roster
from contact import Contact
@@ -2584,6 +2586,10 @@ class XMLTab(Tab):
self.default_help_message = windows.HelpText("/ to enter a command")
self.commands['close'] = (self.close, _("Usage: /close\nClose: Just close this tab."), None)
self.commands['clear'] = (self.command_clear, _("Usage: /clear\nClear: Clear the content of the current buffer."), None)
+ self.commands['reset'] = (self.command_reset, _("Usage: /reset\nReset: Reset the stanza filter."), None)
+ self.commands['filter_id'] = (self.command_filter_id, _("Usage: /filter_id <id>\nFilterId: Show only the stanzas with the id <id>."), None)
+ self.commands['filter_xpath'] = (self.command_filter_xpath, _("Usage: /filter_xpath <xpath>\nFilterXPath: Show only the stanzas matching the xpath <xpath>."), None)
+ self.commands['filter_xmlmask'] = (self.command_filter_xmlmask, _("Usage: /filter_xmlmask <xml mask>\nFilterXMLMask: Show only the stanzas matching the given xml mask."), None)
self.input = self.default_help_message
self.key_func['^T'] = self.close
self.key_func['^I'] = self.completion
@@ -2597,6 +2603,41 @@ class XMLTab(Tab):
self.text_win.toggle_lock()
self.refresh()
+ def command_filter_xmlmask(self, arg):
+ """/filter_xmlmask <xml mask>"""
+ try:
+ handler = Callback('custom matcher', matcher.MatchXMLMask(arg),
+ self.core.incoming_stanza)
+ self.core.xmpp.remove_handler('custom matcher')
+ self.core.xmpp.register_handler(handler)
+ except:
+ self.core.information('Invalid XML Mask', 'Error')
+ self.command_reset('')
+
+ def command_filter_id(self, arg):
+ """/filter_id <id>"""
+ self.core.xmpp.remove_handler('custom matcher')
+ handler = Callback('custom matcher', matcher.MatcherId(arg),
+ self.core.incoming_stanza)
+ self.core.xmpp.register_handler(handler)
+
+ def command_filter_xpath(self, arg):
+ """/filter_xpath <xpath>"""
+ try:
+ handler = Callback('custom matcher', matcher.MatchXPath(
+ arg.replace('%n', self.core.xmpp.default_ns)),
+ self.core.incoming_stanza)
+ self.core.xmpp.remove_handler('custom matcher')
+ self.core.xmpp.register_handler(handler)
+ except:
+ self.core.information('Invalid XML Path', 'Error')
+ self.command_reset('')
+
+ def command_reset(self, arg):
+ """/reset"""
+ self.core.xmpp.remove_handler('custom matcher')
+ self.core.xmpp.register_handler(self.core.all_stanzas)
+
def on_slash(self):
"""
'/' is pressed, activate the input