summaryrefslogtreecommitdiff
path: root/poezio/core/handlers.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2018-06-29 21:18:09 +0200
committermathieui <mathieui@mathieui.net>2018-07-21 20:20:13 +0200
commita28b9c4422317c6fed4a430dad4a478f462d3854 (patch)
treea664c2168a4e04e9bf5466868e0e899d0fc799d1 /poezio/core/handlers.py
parent7d9afc6ad40348fb21bf54ec55e14e22d023400e (diff)
downloadpoezio-a28b9c4422317c6fed4a430dad4a478f462d3854.tar.gz
poezio-a28b9c4422317c6fed4a430dad4a478f462d3854.tar.bz2
poezio-a28b9c4422317c6fed4a430dad4a478f462d3854.tar.xz
poezio-a28b9c4422317c6fed4a430dad4a478f462d3854.zip
Update poezio for the new tabs module
Diffstat (limited to 'poezio/core/handlers.py')
-rw-r--r--poezio/core/handlers.py78
1 files changed, 40 insertions, 38 deletions
diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py
index ca5a3ca8..fcc0a07e 100644
--- a/poezio/core/handlers.py
+++ b/poezio/core/handlers.py
@@ -85,7 +85,8 @@ class HandlerCore:
if not iq:
return
features = iq['disco_info']['features']
- rostertab = self.core.get_tab_by_name('Roster', tabs.RosterInfoTab)
+ rostertab = self.core.tabs.by_name_and_class(
+ 'Roster', tabs.RosterInfoTab)
rostertab.check_blocking(features)
rostertab.check_saslexternal(features)
if (config.get('enable_carbons')
@@ -246,8 +247,8 @@ class HandlerCore:
self.core.room_error(message, jid_from.bare)
else:
text = self.core.get_error_message(message)
- p_tab = self.core.get_tab_by_name(jid_from.full,
- tabs.PrivateTab)
+ p_tab = self.core.tabs.by_name_and_class(
+ jid_from.full, tabs.PrivateTab)
if p_tab:
p_tab.add_error(text)
else:
@@ -368,7 +369,7 @@ class HandlerCore:
if not own and 'private' in config.get('beep_on').split():
if not config.get_by_tabname('disable_beep', conv_jid.bare):
curses.beep()
- if self.core.current_tab() is not conversation:
+ if self.core.tabs.current_tab is not conversation:
if not own:
conversation.state = 'private'
self.core.refresh_tab_win()
@@ -655,7 +656,7 @@ class HandlerCore:
self.core.room_error(message, room_from)
return
- tab = self.core.get_tab_by_name(room_from, tabs.MucTab)
+ tab = self.core.tabs.by_name_and_class(room_from, tabs.MucTab)
if not tab:
self.core.information(
"message received for a non-existing room: %s" % (room_from))
@@ -709,14 +710,14 @@ class HandlerCore:
if message['from'].resource == tab.own_nick:
tab.last_sent_message = message
- if tab is self.core.current_tab():
+ if tab is self.core.tabs.current_tab:
tab.text_win.refresh()
tab.info_header.refresh(tab, tab.text_win, user=tab.own_user)
tab.input.refresh()
self.core.doupdate()
elif tab.state != old_state:
self.core.refresh_tab_win()
- current = self.core.current_tab()
+ current = self.core.tabs.current_tab
if hasattr(current, 'input') and current.input:
current.input.refresh()
self.core.doupdate()
@@ -747,7 +748,7 @@ class HandlerCore:
tmp_dir = get_image_cache()
body = xhtml.get_body_from_message_stanza(
message, use_xhtml=use_xhtml, extract_images_to=tmp_dir)
- tab = self.core.get_tab_by_name(
+ tab = self.core.tabs.by_name_and_class(
jid.full,
tabs.PrivateTab) # get the tab with the private conversation
ignore = config.get_by_tabname('ignore_private', room_from)
@@ -804,7 +805,7 @@ class HandlerCore:
if not sent and 'private' in config.get('beep_on').split():
if not config.get_by_tabname('disable_beep', jid.full):
curses.beep()
- if tab is self.core.current_tab():
+ if tab is self.core.tabs.current_tab:
self.core.refresh_window()
else:
tab.state = 'normal' if sent else 'private'
@@ -830,8 +831,8 @@ class HandlerCore:
def _on_chatstate(self, message, state):
if message['type'] == 'chat':
if not self._on_chatstate_normal_conversation(message, state):
- tab = self.core.get_tab_by_name(message['from'].full,
- tabs.PrivateTab)
+ tab = self.core.tabs.by_name_and_class(message['from'].full,
+ tabs.PrivateTab)
if not tab:
return
self._on_chatstate_private_conversation(message, state)
@@ -846,7 +847,7 @@ class HandlerCore:
tab.chatstate = state
if state == 'gone' and isinstance(tab, tabs.DynamicConversationTab):
tab.unlock()
- if tab == self.core.current_tab():
+ if tab == self.core.tabs.current_tab:
tab.refresh_info_header()
self.core.doupdate()
else:
@@ -858,12 +859,13 @@ class HandlerCore:
"""
Chatstate received in a private conversation from a MUC
"""
- tab = self.core.get_tab_by_name(message['from'].full, tabs.PrivateTab)
+ tab = self.core.tabs.by_name_and_class(message['from'].full,
+ tabs.PrivateTab)
if not tab:
return
self.core.events.trigger('private_chatstate', message, tab)
tab.chatstate = state
- if tab == self.core.current_tab():
+ if tab == self.core.tabs.current_tab:
tab.refresh_info_header()
self.core.doupdate()
else:
@@ -876,11 +878,11 @@ class HandlerCore:
"""
nick = message['mucnick']
room_from = message.get_mucroom()
- tab = self.core.get_tab_by_name(room_from, tabs.MucTab)
+ tab = self.core.tabs.by_name_and_class(room_from, tabs.MucTab)
if tab and tab.get_user_by_name(nick):
self.core.events.trigger('muc_chatstate', message, tab)
tab.get_user_by_name(nick).chatstate = state
- if tab == self.core.current_tab():
+ if tab == self.core.tabs.current_tab:
if not self.core.size.tab_degrade_x:
tab.user_win.refresh(tab.users)
tab.input.refresh()
@@ -927,7 +929,7 @@ class HandlerCore:
else:
roster.update_contact_groups(jid)
roster.update_size()
- if isinstance(self.core.current_tab(), tabs.RosterInfoTab):
+ if isinstance(self.core.tabs.current_tab, tabs.RosterInfoTab):
self.core.refresh_window()
def on_subscription_request(self, presence):
@@ -950,7 +952,7 @@ class HandlerCore:
'tab to accept or reject the query.' % jid, 'Roster')
self.core.get_tab_by_number(0).state = 'highlight'
roster.modified()
- if isinstance(self.core.current_tab(), tabs.RosterInfoTab):
+ if isinstance(self.core.tabs.current_tab, tabs.RosterInfoTab):
self.core.refresh_window()
def on_subscription_authorized(self, presence):
@@ -965,7 +967,7 @@ class HandlerCore:
roster.modified()
- if isinstance(self.core.current_tab(), tabs.RosterInfoTab):
+ if isinstance(self.core.tabs.current_tab, tabs.RosterInfoTab):
self.core.refresh_window()
def on_subscription_remove(self, presence):
@@ -978,7 +980,7 @@ class HandlerCore:
self.core.information(
'%s does not want to receive your status anymore.' % jid, 'Roster')
self.core.get_tab_by_number(0).state = 'highlight'
- if isinstance(self.core.current_tab(), tabs.RosterInfoTab):
+ if isinstance(self.core.tabs.current_tab, tabs.RosterInfoTab):
self.core.refresh_window()
def on_subscription_removed(self, presence):
@@ -997,7 +999,7 @@ class HandlerCore:
'%s does not want you to receive his/her/its status anymore.' %
jid, 'Roster')
self.core.get_tab_by_number(0).state = 'highlight'
- if isinstance(self.core.current_tab(), tabs.RosterInfoTab):
+ if isinstance(self.core.tabs.current_tab, tabs.RosterInfoTab):
self.core.refresh_window()
### Presence-related handlers ###
@@ -1024,9 +1026,9 @@ class HandlerCore:
if tab:
tab.update_status(
Status(show=presence['show'], message=presence['status']))
- if isinstance(self.core.current_tab(), tabs.RosterInfoTab):
+ if isinstance(self.core.tabs.current_tab, tabs.RosterInfoTab):
self.core.refresh_window()
- elif self.core.current_tab() == tab:
+ elif self.core.tabs.current_tab == tab:
tab.refresh()
self.core.doupdate()
@@ -1037,8 +1039,7 @@ class HandlerCore:
return
roster.modified()
contact.error = presence['error']['type'] + ': ' + presence['error']['condition']
- # reset chat states status on presence error
- tab = self.core.get_tab_by_name(jid.full, tabs.ConversationTab)
+ # TODO: reset chat states status on presence error
def on_got_offline(self, presence):
"""
@@ -1066,7 +1067,7 @@ class HandlerCore:
self.core.information('\x193}%s \x195}is \x191}offline' % name,
'Roster')
roster.modified()
- if isinstance(self.core.current_tab(), tabs.RosterInfoTab):
+ if isinstance(self.core.tabs.current_tab, tabs.RosterInfoTab):
self.core.refresh_window()
def on_got_online(self, presence):
@@ -1106,7 +1107,7 @@ class HandlerCore:
"\x193}%s \x195}is \x194}online\x195}" % name, "Roster")
self.core.add_information_message_to_conversation_tab(
jid.bare, '\x195}%s is \x194}online' % name)
- if isinstance(self.core.current_tab(), tabs.RosterInfoTab):
+ if isinstance(self.core.tabs.current_tab, tabs.RosterInfoTab):
self.core.refresh_window()
def on_groupchat_presence(self, presence):
@@ -1116,7 +1117,7 @@ class HandlerCore:
presence information of the concerned user
"""
from_room = presence['from'].bare
- tab = self.core.get_tab_by_name(from_room, tabs.MucTab)
+ tab = self.core.tabs.by_name_and_class(from_room, tabs.MucTab)
if tab:
self.core.events.trigger('muc_presence', presence, tab)
tab.handle_presence(presence)
@@ -1227,7 +1228,7 @@ class HandlerCore:
Those are received when a room configuration change occurs.
"""
room_from = message['from']
- tab = self.core.get_tab_by_name(room_from, tabs.MucTab)
+ tab = self.core.tabs.by_name_and_class(room_from, tabs.MucTab)
status_codes = {
s.attrib['code']
for s in message.xml.findall('{%s}x/{%s}status' %
@@ -1321,7 +1322,7 @@ class HandlerCore:
"""
nick_from = message['mucnick']
room_from = message.get_mucroom()
- tab = self.core.get_tab_by_name(room_from, tabs.MucTab)
+ tab = self.core.tabs.by_name_and_class(room_from, tabs.MucTab)
subject = message['subject']
if subject is None or not tab:
return
@@ -1363,8 +1364,8 @@ class HandlerCore:
typ=2)
tab.topic = subject
tab.topic_from = nick_from
- if self.core.get_tab_by_name(room_from,
- tabs.MucTab) is self.core.current_tab():
+ if self.core.tabs.by_name_and_class(
+ room_from, tabs.MucTab) is self.core.tabs.current_tab:
self.core.refresh_window()
def on_receipt(self, message):
@@ -1376,8 +1377,9 @@ class HandlerCore:
if not msg_id:
return
- conversation = self.core.get_tab_by_name(jid.full, tabs.OneToOneTab)
- conversation = conversation or self.core.get_tab_by_name(
+ conversation = self.core.tabs.by_name_and_class(
+ jid.full, tabs.OneToOneTab)
+ conversation = conversation or self.core.tabs.by_name_and_class(
jid.bare, tabs.OneToOneTab)
if not conversation:
log.error("Received ack from non-existing chat tab: %s", jid)
@@ -1437,8 +1439,8 @@ class HandlerCore:
except:
log.debug('', exc_info=True)
- if isinstance(self.core.current_tab(), tabs.XMLTab):
- self.core.current_tab().refresh()
+ if isinstance(self.core.tabs.current_tab, tabs.XMLTab):
+ self.core.tabs.current_tab.refresh()
self.core.doupdate()
def incoming_stanza(self, stanza):
@@ -1464,8 +1466,8 @@ class HandlerCore:
nickname=get_theme().CHAR_XML_IN)
except:
log.debug('', exc_info=True)
- if isinstance(self.core.current_tab(), tabs.XMLTab):
- self.core.current_tab().refresh()
+ if isinstance(self.core.tabs.current_tab, tabs.XMLTab):
+ self.core.tabs.current_tab.refresh()
self.core.doupdate()
def ssl_invalid_chain(self, tb):