summaryrefslogtreecommitdiff
path: root/src/tabs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tabs')
-rw-r--r--src/tabs/adhoc_commands_list.py4
-rw-r--r--src/tabs/basetabs.py35
-rw-r--r--src/tabs/conversationtab.py2
-rw-r--r--src/tabs/muclisttab.py2
-rw-r--r--src/tabs/muctab.py12
-rw-r--r--src/tabs/rostertab.py44
-rw-r--r--src/tabs/xmltab.py4
7 files changed, 47 insertions, 56 deletions
diff --git a/src/tabs/adhoc_commands_list.py b/src/tabs/adhoc_commands_list.py
index 87ee0c52..7f5abf6a 100644
--- a/src/tabs/adhoc_commands_list.py
+++ b/src/tabs/adhoc_commands_list.py
@@ -11,14 +11,14 @@ log = logging.getLogger(__name__)
from . import ListTab
-from sleekxmpp.plugins.xep_0030.stanza.items import DiscoItem
+from slixmpp.plugins.xep_0030.stanza.items import DiscoItem
class AdhocCommandsListTab(ListTab):
plugin_commands = {}
plugin_keys = {}
def __init__(self, jid):
- ListTab.__init__(self, jid,
+ ListTab.__init__(self, jid.full,
"“Enter”: execute selected command.",
_('Ad-hoc commands of JID %s (Loading)') % jid,
(('Node', 0), ('Description', 1)))
diff --git a/src/tabs/basetabs.py b/src/tabs/basetabs.py
index f684a08f..0a55640c 100644
--- a/src/tabs/basetabs.py
+++ b/src/tabs/basetabs.py
@@ -35,7 +35,6 @@ from decorators import refresh_wrapper
from logger import logger
from text_buffer import TextBuffer
from theming import get_theme, dump_tuple
-from windows import g_lock
# getters for tab colors (lambdas, so that they are dynamic)
@@ -187,9 +186,8 @@ class Tab(object):
@staticmethod
def resize(scr):
- with g_lock:
- Tab.height, Tab.width = scr.getmaxyx()
- windows.Win._tab_win = scr
+ Tab.height, Tab.width = scr.getmaxyx()
+ windows.Win._tab_win = scr
def missing_command_callback(self, command_name):
"""
@@ -447,12 +445,9 @@ class ChatTab(Tab):
self.text_win = None
self._text_buffer = TextBuffer()
self.chatstate = None # can be "active", "composing", "paused", "gone", "inactive"
- # We keep a weakref of the event that will set our chatstate to "paused", so that
+ # We keep a reference of the event that will set our chatstate to "paused", so that
# we can delete it or change it if we need to
self.timed_event_paused = None
- # if that’s None, then no paused chatstate was sent recently
- # if that’s a weakref returning None, then a paused chatstate was sent
- # since the last input
# Keeps the last sent message to complete it easily in completion_correct, and to replace it.
self.last_sent_message = None
self.key_func['M-v'] = self.move_separator
@@ -625,17 +620,12 @@ class ChatTab(Tab):
"""
if not config.get_by_tabname('send_chat_states', self.general_jid):
return
- if self.timed_event_paused:
- # check the weakref
- event = self.timed_event_paused()
- if event:
- # the event already exists: we just update
- # its date
- event.change_date(datetime.now() + timedelta(seconds=4))
- return
+ # First, cancel the delay if it already exists, before rescheduling
+ # it at a new date
+ self.cancel_paused_delay()
new_event = timed_events.DelayedEvent(4, self.send_chat_state, 'paused')
self.core.add_timed_event(new_event)
- self.timed_event_paused = weakref.ref(new_event)
+ self.timed_event_paused = new_event
def cancel_paused_delay(self):
"""
@@ -643,12 +633,9 @@ class ChatTab(Tab):
Called for example when the input is emptied, or when the message
is sent
"""
- if self.timed_event_paused:
- event = self.timed_event_paused()
- if event:
- self.core.remove_timed_event(event)
- del event
- self.timed_event_paused = None
+ if self.timed_event_paused is not None:
+ self.core.remove_timed_event(self.timed_event_paused)
+ self.timed_event_paused = None
def command_correct(self, line):
"""
@@ -738,7 +725,7 @@ class OneToOneTab(ChatTab):
"check the features supported by the other party"
if safeJID(self.get_dest_jid()).resource:
self.core.xmpp.plugin['xep_0030'].get_info(
- jid=self.get_dest_jid(), block=False, timeout=5,
+ jid=self.get_dest_jid(), timeout=5,
callback=self.features_checked)
def command_attention(self, message=''):
diff --git a/src/tabs/conversationtab.py b/src/tabs/conversationtab.py
index 99f9fe47..52c503d7 100644
--- a/src/tabs/conversationtab.py
+++ b/src/tabs/conversationtab.py
@@ -188,7 +188,7 @@ class ConversationTab(OneToOneTab):
self.add_message(msg)
self.core.refresh_window()
- self.core.xmpp.plugin['xep_0012'].get_last_activity(self.general_jid, block=False, callback=callback)
+ self.core.xmpp.plugin['xep_0012'].get_last_activity(self.general_jid, callback=callback)
@refresh_wrapper.conditional
def command_info(self, arg):
diff --git a/src/tabs/muclisttab.py b/src/tabs/muclisttab.py
index d7c68588..55d5c2bd 100644
--- a/src/tabs/muclisttab.py
+++ b/src/tabs/muclisttab.py
@@ -11,7 +11,7 @@ log = logging.getLogger(__name__)
from . import ListTab
-from sleekxmpp.plugins.xep_0030.stanza.items import DiscoItem
+from slixmpp.plugins.xep_0030.stanza.items import DiscoItem
class MucListTab(ListTab):
"""
diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py
index fb89b0fa..547830cb 100644
--- a/src/tabs/muctab.py
+++ b/src/tabs/muctab.py
@@ -362,13 +362,15 @@ class MucTab(ChatTab):
"""
/configure
"""
- form = fixes.get_room_form(self.core.xmpp, self.name)
- if not form:
- self.core.information(
+ def on_form_received(form):
+ if not form:
+ self.core.information(
_('Could not retrieve the configuration form'),
_('Error'))
- return
- self.core.open_new_form(form, self.cancel_config, self.send_config)
+ return
+ self.core.open_new_form(form, self.cancel_config, self.send_config)
+
+ form = fixes.get_room_form(self.core.xmpp, self.name, on_form_received)
def cancel_config(self, form):
"""
diff --git a/src/tabs/rostertab.py b/src/tabs/rostertab.py
index 26f429d0..878e89ed 100644
--- a/src/tabs/rostertab.py
+++ b/src/tabs/rostertab.py
@@ -175,7 +175,7 @@ class RosterInfoTab(Tab):
jid = item.bare_jid
elif isinstance(item, Resource):
jid = item.jid.bare
- self.core.xmpp.plugin['xep_0191'].block(jid, block=False, callback=callback)
+ self.core.xmpp.plugin['xep_0191'].block(jid, callback=callback)
def completion_block(self, the_input):
"""
@@ -202,22 +202,21 @@ class RosterInfoTab(Tab):
jid = item.bare_jid
elif isinstance(item, Resource):
jid = item.jid.bare
- self.core.xmpp.plugin['xep_0191'].unblock(jid, block=False, callback=callback)
+ self.core.xmpp.plugin['xep_0191'].unblock(jid, callback=callback)
def completion_unblock(self, the_input):
"""
Completion for /unblock
"""
+ def on_result(iq):
+ if iq['type'] == 'error':
+ return
+ l = sorted(str(item) for item in iq['blocklist']['items'])
+ return the_input.new_completion(l, 1, quotify=False)
+
if the_input.get_argument_position():
- try:
- iq = self.core.xmpp.plugin['xep_0191'].get_blocked(block=True)
- except Exception as e:
- iq = e.iq
- finally:
- if iq['type'] == 'error':
- return
- l = sorted(str(item) for item in iq['blocklist']['items'])
- return the_input.new_completion(l, 1, quotify=False)
+ self.core.xmpp.plugin['xep_0191'].get_blocked(callback=on_result)
+ return True
def command_list_blocks(self, arg=None):
"""
@@ -235,13 +234,16 @@ class RosterInfoTab(Tab):
s = 'No blocked JIDs.'
self.core.information(s, 'Info')
- self.core.xmpp.plugin['xep_0191'].get_blocked(block=False, callback=callback)
+ self.core.xmpp.plugin['xep_0191'].get_blocked(callback=callback)
def command_reconnect(self, args=None):
"""
/reconnect
"""
- self.core.disconnect(reconnect=True)
+ if self.core.xmpp.is_connected():
+ self.core.disconnect(reconnect=True)
+ else:
+ self.core.xmpp.connect()
def command_disconnect(self, args=None):
"""
@@ -419,8 +421,8 @@ class RosterInfoTab(Tab):
if 'none' in groups:
groups.remove('none')
subscription = contact.subscription
- self.core.xmpp.update_roster(jid, name=name, groups=groups, subscription=subscription,
- callback=callback, block=False)
+ self.core.xmpp.update_roster(jid, name=name, groups=groups,
+ subscription=subscription, callback=callback)
def command_groupadd(self, args):
"""
@@ -459,8 +461,8 @@ class RosterInfoTab(Tab):
self.core.information('The group could not be set.', 'Error')
log.debug('Error in groupadd:\n%s', iq)
- self.core.xmpp.update_roster(jid, name=name, groups=new_groups, subscription=subscription,
- callback=callback, block=False)
+ self.core.xmpp.update_roster(jid, name=name, groups=new_groups,
+ subscription=subscription, callback=callback)
def command_groupmove(self, arg):
"""
@@ -514,8 +516,8 @@ class RosterInfoTab(Tab):
self.core.information('The group could not be set')
log.debug('Error in groupmove:\n%s', iq)
- self.core.xmpp.update_roster(jid, name=name, groups=new_groups, subscription=subscription,
- callback=callback, block=False)
+ self.core.xmpp.update_roster(jid, name=name, groups=new_groups,
+ subscription=subscription, callback=callback)
def command_groupremove(self, args):
"""
@@ -554,8 +556,8 @@ class RosterInfoTab(Tab):
self.core.information('The group could not be set')
log.debug('Error in groupremove:\n%s', iq)
- self.core.xmpp.update_roster(jid, name=name, groups=new_groups, subscription=subscription,
- callback=callback, block=False)
+ self.core.xmpp.update_roster(jid, name=name, groups=new_groups,
+ subscription=subscription, callback=callback)
def command_remove(self, args):
"""
diff --git a/src/tabs/xmltab.py b/src/tabs/xmltab.py
index d33f4d48..083e97c5 100644
--- a/src/tabs/xmltab.py
+++ b/src/tabs/xmltab.py
@@ -12,8 +12,8 @@ log = logging.getLogger(__name__)
import curses
import os
-from sleekxmpp.xmlstream import matcher
-from sleekxmpp.xmlstream.handler import Callback
+from slixmpp.xmlstream import matcher
+from slixmpp.xmlstream.handler import Callback
from . import Tab