Commit e1de0d95 authored by Maxime Buquet's avatar Maxime Buquet

*ConversationTab: Use jid parameter instead of name where appropriate

Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <pep@bouah.net>
parent 20717889
...@@ -47,7 +47,6 @@ class ConversationTab(OneToOneTab): ...@@ -47,7 +47,6 @@ class ConversationTab(OneToOneTab):
self.nick = None self.nick = None
self.nick_sent = False self.nick_sent = False
self.state = 'normal' self.state = 'normal'
self.name = jid # a conversation tab is linked to one specific full jid OR bare jid
self.text_win = windows.TextWin() self.text_win = windows.TextWin()
self._text_buffer.add_window(self.text_win) self._text_buffer.add_window(self.text_win)
self.upper_bar = windows.ConversationStatusMessageWin() self.upper_bar = windows.ConversationStatusMessageWin()
...@@ -83,7 +82,7 @@ class ConversationTab(OneToOneTab): ...@@ -83,7 +82,7 @@ class ConversationTab(OneToOneTab):
@property @property
def general_jid(self): def general_jid(self):
return safeJID(self.name).bare return self.jid.bare
def get_info_header(self): def get_info_header(self):
raise NotImplementedError raise NotImplementedError
...@@ -125,7 +124,7 @@ class ConversationTab(OneToOneTab): ...@@ -125,7 +124,7 @@ class ConversationTab(OneToOneTab):
replaced = False replaced = False
if correct or msg['replace']['id']: if correct or msg['replace']['id']:
msg['replace']['id'] = self.last_sent_message['id'] msg['replace']['id'] = self.last_sent_message['id']
if config.get_by_tabname('group_corrections', self.name): if config.get_by_tabname('group_corrections', self.jid.full):
try: try:
self.modify_message( self.modify_message(
msg['body'], msg['body'],
...@@ -244,7 +243,7 @@ class ConversationTab(OneToOneTab): ...@@ -244,7 +243,7 @@ class ConversationTab(OneToOneTab):
""" """
if args: if args:
return self.core.command.version(args[0]) return self.core.command.version(args[0])
jid = safeJID(self.name) jid = self.jid
if not jid.resource: if not jid.resource:
if jid in roster: if jid in roster:
resource = roster[jid].get_highest_priority_resource() resource = roster[jid].get_highest_priority_resource()
...@@ -303,14 +302,13 @@ class ConversationTab(OneToOneTab): ...@@ -303,14 +302,13 @@ class ConversationTab(OneToOneTab):
self.input.refresh() self.input.refresh()
def get_nick(self): def get_nick(self):
jid = safeJID(self.name) contact = roster[self.jid.bare]
contact = roster[jid.bare]
if contact: if contact:
return contact.name or jid.user return contact.name or jid.user
else: else:
if self.nick: if self.nick:
return self.nick return self.nick
return jid.user return self.jid.user
def on_input(self, key, raw): def on_input(self, key, raw):
if not raw and key in self.key_func: if not raw and key in self.key_func:
...@@ -383,7 +381,7 @@ class ConversationTab(OneToOneTab): ...@@ -383,7 +381,7 @@ class ConversationTab(OneToOneTab):
def matching_names(self): def matching_names(self):
res = [] res = []
jid = safeJID(self.name) jid = self.jid
res.append((2, jid.bare)) res.append((2, jid.bare))
res.append((1, jid.user)) res.append((1, jid.user))
contact = roster[self.name] contact = roster[self.name]
...@@ -404,8 +402,8 @@ class DynamicConversationTab(ConversationTab): ...@@ -404,8 +402,8 @@ class DynamicConversationTab(ConversationTab):
def __init__(self, core, jid, resource=None): def __init__(self, core, jid, resource=None):
self.locked_resource = None self.locked_resource = None
self.name = safeJID(jid).bare
ConversationTab.__init__(self, core, jid) ConversationTab.__init__(self, core, jid)
self.jid.resource = None
self.info_header = windows.DynamicConversationInfoWin() self.info_header = windows.DynamicConversationInfoWin()
self.register_command( self.register_command(
'unlock', self.unlock_command, shortdesc='Deprecated, do nothing.') 'unlock', self.unlock_command, shortdesc='Deprecated, do nothing.')
...@@ -429,7 +427,7 @@ class DynamicConversationTab(ConversationTab): ...@@ -429,7 +427,7 @@ class DynamicConversationTab(ConversationTab):
""" """
Returns the bare jid. Returns the bare jid.
""" """
return self.name return self.jid.bare
def refresh(self): def refresh(self):
""" """
...@@ -442,9 +440,9 @@ class DynamicConversationTab(ConversationTab): ...@@ -442,9 +440,9 @@ class DynamicConversationTab(ConversationTab):
self.text_win.refresh() self.text_win.refresh()
if display_bar: if display_bar:
self.upper_bar.refresh(self.name, roster[self.name]) self.upper_bar.refresh(self.jid.bare, roster[self.jid.bare])
displayed_jid = self.name displayed_jid = self.jid.bare
self.get_info_header().refresh(displayed_jid, roster[self.name], self.get_info_header().refresh(displayed_jid, roster[self.jid.bare],
self.text_win, self.chatstate, self.text_win, self.chatstate,
ConversationTab.additional_information) ConversationTab.additional_information)
if display_info_win: if display_info_win:
...@@ -457,8 +455,8 @@ class DynamicConversationTab(ConversationTab): ...@@ -457,8 +455,8 @@ class DynamicConversationTab(ConversationTab):
""" """
Different from the parent class only for the info_header object. Different from the parent class only for the info_header object.
""" """
displayed_jid = self.name displayed_jid = self.jid.bare
self.get_info_header().refresh(displayed_jid, roster[self.name], self.get_info_header().refresh(displayed_jid, roster[self.jid.bare],
self.text_win, self.chatstate, self.text_win, self.chatstate,
ConversationTab.additional_information) ConversationTab.additional_information)
self.input.refresh() self.input.refresh()
...@@ -473,8 +471,8 @@ class StaticConversationTab(ConversationTab): ...@@ -473,8 +471,8 @@ class StaticConversationTab(ConversationTab):
plugin_keys = {} # type: Dict[str, Callable] plugin_keys = {} # type: Dict[str, Callable]
def __init__(self, core, jid): def __init__(self, core, jid):
assert (safeJID(jid).resource)
ConversationTab.__init__(self, core, jid) ConversationTab.__init__(self, core, jid)
assert jid.resource
self.info_header = windows.ConversationInfoWin() self.info_header = windows.ConversationInfoWin()
self.resize() self.resize()
self.update_commands() self.update_commands()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment