summaryrefslogtreecommitdiff
path: root/src/tabs
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-30 21:34:09 +0200
committermathieui <mathieui@mathieui.net>2014-04-30 21:34:09 +0200
commitbbdc14aaa5a47e77ad46d1ad7b4465ac065d6677 (patch)
tree190e961ea1c516ad0127e1c82cddb5fee263e565 /src/tabs
parentd859ec2ea19654603075b556094c6b59aad8e73a (diff)
downloadpoezio-bbdc14aaa5a47e77ad46d1ad7b4465ac065d6677.tar.gz
poezio-bbdc14aaa5a47e77ad46d1ad7b4465ac065d6677.tar.bz2
poezio-bbdc14aaa5a47e77ad46d1ad7b4465ac065d6677.tar.xz
poezio-bbdc14aaa5a47e77ad46d1ad7b4465ac065d6677.zip
Remove Tab.get_name() and use Tab.name instead
(keep a get_name() fallback just in case for now)
Diffstat (limited to 'src/tabs')
-rw-r--r--src/tabs/basetabs.py12
-rw-r--r--src/tabs/conversationtab.py29
-rw-r--r--src/tabs/muclisttab.py3
-rw-r--r--src/tabs/muctab.py45
-rw-r--r--src/tabs/privatetab.py17
-rw-r--r--src/tabs/rostertab.py3
-rw-r--r--src/tabs/xmltab.py1
7 files changed, 49 insertions, 61 deletions
diff --git a/src/tabs/basetabs.py b/src/tabs/basetabs.py
index f16e3f93..9759431d 100644
--- a/src/tabs/basetabs.py
+++ b/src/tabs/basetabs.py
@@ -90,6 +90,7 @@ class Tab(object):
plugin_commands = {}
plugin_keys = {}
def __init__(self):
+ self.name = self.__class__.__name__
self.input = None
self._state = 'normal'
self._prev_state = None
@@ -299,13 +300,13 @@ class Tab(object):
"""
get the name of the tab
"""
- return self.__class__.__name__
+ return self.name
def get_nick(self):
"""
Get the nick of the tab (defaults to its name)
"""
- return self.get_name()
+ return self.name
def get_text_window(self):
"""
@@ -410,7 +411,8 @@ class GapTab(Tab):
def __len__(self):
return 0
- def get_name(self):
+ @property
+ def name(self):
return ''
def refresh(self):
@@ -476,7 +478,7 @@ class ChatTab(Tab):
return False
def load_logs(self, log_nb):
- logs = logger.get_logs(safeJID(self.get_name()).bare, log_nb)
+ logs = logger.get_logs(safeJID(self.name).bare, log_nb)
return logs
def log_message(self, txt, nickname, time=None, typ=1):
@@ -569,7 +571,7 @@ class ChatTab(Tab):
return msg
def get_dest_jid(self):
- return self.get_name()
+ return self.name
@refresh_wrapper.always
def command_clear(self, args):
diff --git a/src/tabs/conversationtab.py b/src/tabs/conversationtab.py
index 756634ce..7480906b 100644
--- a/src/tabs/conversationtab.py
+++ b/src/tabs/conversationtab.py
@@ -73,7 +73,7 @@ class ConversationTab(ChatTab):
@property
def general_jid(self):
- return safeJID(self.get_name()).bare
+ return safeJID(self.name).bare
@staticmethod
def add_information_element(plugin_name, callback):
@@ -109,7 +109,7 @@ class ConversationTab(ChatTab):
replaced = False
if correct or msg['replace']['id']:
msg['replace']['id'] = self.last_sent_message['id']
- if config.get_by_tabname('group_corrections', True, self.get_name()):
+ if config.get_by_tabname('group_corrections', True, self.name):
try:
self.modify_message(msg['body'], self.last_sent_message['id'], msg['id'], jid=self.core.xmpp.boundjid,
nickname=self.core.own_nick)
@@ -306,9 +306,6 @@ class ConversationTab(ChatTab):
self.text_win, self.chatstate, ConversationTab.additional_informations)
self.input.refresh()
- def get_name(self):
- return self.name
-
def get_nick(self):
jid = safeJID(self.name)
contact = roster[jid.bare]
@@ -382,10 +379,10 @@ class ConversationTab(ChatTab):
def matching_names(self):
res = []
- jid = safeJID(self.get_name())
+ jid = safeJID(self.name)
res.append((2, jid.bare))
res.append((1, jid.user))
- contact = roster[self.get_name()]
+ contact = roster[self.name]
if contact and contact.name:
res.append((0, contact.name))
return res
@@ -450,8 +447,8 @@ class DynamicConversationTab(ConversationTab):
the conversation is not locked.
"""
if self.locked_resource:
- return "%s/%s" % (self.get_name(), self.locked_resource)
- return self.get_name()
+ return "%s/%s" % (self.name, self.locked_resource)
+ return self.name
def refresh(self):
"""
@@ -464,12 +461,12 @@ class DynamicConversationTab(ConversationTab):
self.text_win.refresh()
if display_bar:
- self.upper_bar.refresh(self.get_name(), roster[self.get_name()])
+ self.upper_bar.refresh(self.name, roster[self.name])
if self.locked_resource:
- displayed_jid = "%s/%s" % (self.get_name(), self.locked_resource)
+ displayed_jid = "%s/%s" % (self.name, self.locked_resource)
else:
- displayed_jid = self.get_name()
- self.info_header.refresh(displayed_jid, roster[self.get_name()],
+ displayed_jid = self.name
+ self.info_header.refresh(displayed_jid, roster[self.name],
self.text_win, self.chatstate,
ConversationTab.additional_informations)
if display_info_win:
@@ -483,10 +480,10 @@ class DynamicConversationTab(ConversationTab):
Different from the parent class only for the info_header object.
"""
if self.locked_resource:
- displayed_jid = "%s/%s" % (self.get_name(), self.locked_resource)
+ displayed_jid = "%s/%s" % (self.name, self.locked_resource)
else:
- displayed_jid = self.get_name()
- self.info_header.refresh(displayed_jid, roster[self.get_name()],
+ displayed_jid = self.name
+ self.info_header.refresh(displayed_jid, roster[self.name],
self.text_win, self.chatstate, ConversationTab.additional_informations)
self.input.refresh()
diff --git a/src/tabs/muclisttab.py b/src/tabs/muclisttab.py
index b8c49e8c..c04c3ed5 100644
--- a/src/tabs/muclisttab.py
+++ b/src/tabs/muclisttab.py
@@ -184,9 +184,6 @@ class MucListTab(Tab):
self.execute_command(txt)
return self.reset_help_message()
- def get_name(self):
- return self.name
-
def completion(self):
if isinstance(self.input, windows.Input):
self.complete_commands(self.input)
diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py
index 2ea7fe1f..201010f5 100644
--- a/src/tabs/muctab.py
+++ b/src/tabs/muctab.py
@@ -196,7 +196,7 @@ class MucTab(ChatTab):
@property
def general_jid(self):
- return self.get_name()
+ return self.name
@property
def is_muc(self):
@@ -251,7 +251,7 @@ class MucTab(ChatTab):
"""Completion for /nick"""
nicks = [os.environ.get('USER'),
config.get('default_nick', ''),
- self.core.get_bookmark_nickname(self.get_name())]
+ self.core.get_bookmark_nickname(self.name)]
nicks = [i for i in nicks if i]
return the_input.auto_completion(nicks, '', quotify=False)
@@ -360,7 +360,7 @@ class MucTab(ChatTab):
"""
/configure
"""
- form = fixes.get_room_form(self.core.xmpp, self.get_name())
+ form = fixes.get_room_form(self.core.xmpp, self.name)
if not form:
self.core.information(
_('Could not retrieve the configuration form'),
@@ -372,14 +372,14 @@ class MucTab(ChatTab):
"""
The user do not want to send his/her config, send an iq cancel
"""
- self.core.xmpp.plugin['xep_0045'].cancelConfig(self.get_name())
+ self.core.xmpp.plugin['xep_0045'].cancelConfig(self.name)
self.core.close_tab()
def send_config(self, form):
"""
The user sends his/her config to the server
"""
- self.core.xmpp.plugin['xep_0045'].configureRoom(self.get_name(), form)
+ self.core.xmpp.plugin['xep_0045'].configureRoom(self.name, form)
self.core.close_tab()
def command_cycle(self, arg):
@@ -450,7 +450,7 @@ class MucTab(ChatTab):
return self.core.information(_('/nick only works in joined rooms'),
_('Info'))
current_status = self.core.get_status()
- if not safeJID(self.get_name() + '/' + nick):
+ if not safeJID(self.name + '/' + nick):
return self.core.information('Invalid nick', 'Info')
muc.change_nick(self.core, self.name, nick,
current_status.message,
@@ -632,7 +632,7 @@ class MucTab(ChatTab):
"""
def callback(iq):
if iq['type'] == 'error':
- self.core.room_error(iq, self.get_name())
+ self.core.room_error(iq, self.name)
args = common.shell_split(arg)
if not args:
return self.core.command_help('ban')
@@ -643,11 +643,11 @@ class MucTab(ChatTab):
nick = args[0]
if nick in [user.nick for user in self.users]:
- res = muc.set_user_affiliation(self.core.xmpp, self.get_name(),
+ res = muc.set_user_affiliation(self.core.xmpp, self.name,
'outcast', nick=nick,
callback=callback, reason=msg)
else:
- res = muc.set_user_affiliation(self.core.xmpp, self.get_name(),
+ res = muc.set_user_affiliation(self.core.xmpp, self.name,
'outcast', jid=safeJID(nick),
callback=callback, reason=msg)
if not res:
@@ -661,7 +661,7 @@ class MucTab(ChatTab):
"""
def callback(iq):
if iq['type'] == 'error':
- self.core.room_error(iq, self.get_name())
+ self.core.room_error(iq, self.name)
args = common.shell_split(arg)
if len(args) < 2:
self.core.command_help('role')
@@ -674,9 +674,9 @@ class MucTab(ChatTab):
if not self.joined or \
not role in ('none', 'visitor', 'participant', 'moderator'):
return
- if not safeJID(self.get_name() + '/' + nick):
+ if not safeJID(self.name + '/' + nick):
return self.core('Invalid nick', 'Info')
- muc.set_user_role(self.core.xmpp, self.get_name(), nick, reason, role,
+ muc.set_user_role(self.core.xmpp, self.name, nick, reason, role,
callback=callback)
def command_affiliation(self, arg):
@@ -687,7 +687,7 @@ class MucTab(ChatTab):
"""
def callback(iq):
if iq['type'] == 'error':
- self.core.room_error(iq, self.get_name())
+ self.core.room_error(iq, self.name)
args = common.shell_split(arg)
if len(args) < 2:
self.core.command_help('affiliation')
@@ -699,11 +699,11 @@ class MucTab(ChatTab):
self.core.command_help('affiliation')
return
if nick in [user.nick for user in self.users]:
- res = muc.set_user_affiliation(self.core.xmpp, self.get_name(),
+ res = muc.set_user_affiliation(self.core.xmpp, self.name,
affiliation, nick=nick,
callback=callback)
else:
- res = muc.set_user_affiliation(self.core.xmpp, self.get_name(),
+ res = muc.set_user_affiliation(self.core.xmpp, self.name,
affiliation, jid=safeJID(nick),
callback=callback)
if not res:
@@ -715,7 +715,7 @@ class MucTab(ChatTab):
Or normal input + enter
"""
needed = 'inactive' if self.inactive else 'active'
- msg = self.core.xmpp.make_message(self.get_name())
+ msg = self.core.xmpp.make_message(self.name)
msg['type'] = 'groupchat'
msg['body'] = line
# trigger the event BEFORE looking for colors.
@@ -900,9 +900,6 @@ class MucTab(ChatTab):
self.input.get_text().startswith('//'))
self.send_composing_chat_state(empty_after)
- def get_name(self):
- return self.name
-
def get_nick(self):
if not config.get('show_muc_jid', True):
return safeJID(self.name).user
@@ -989,8 +986,8 @@ class MucTab(ChatTab):
# not send a 110 status code with the presence
self.own_nick = from_nick
self.joined = True
- if self.get_name() in self.core.initial_joins:
- self.core.initial_joins.remove(self.get_name())
+ if self.name in self.core.initial_joins:
+ self.core.initial_joins.remove(self.name)
self._state = 'normal'
elif self != self.core.current_tab():
self._state = 'joined'
@@ -1045,7 +1042,7 @@ class MucTab(ChatTab):
self.refresh_tab_win()
self.core.current_tab().input.refresh()
self.core.doupdate()
- self.core.enable_private_tabs(self.get_name())
+ self.core.enable_private_tabs(self.name)
else:
change_nick = '303' in status_codes
kick = '307' in status_codes and typ == 'unavailable'
@@ -1521,7 +1518,7 @@ class MucTab(ChatTab):
and self.state != 'current'):
if (self.state != 'highlight' and
config.get_by_tabname('notify_messages',
- True, self.get_name())):
+ True, self.name)):
self.state = 'message'
if time:
txt = '\x19%(info_col)s}%(txt)s' % {
@@ -1552,6 +1549,6 @@ class MucTab(ChatTab):
return False
def matching_names(self):
- return [(1, safeJID(self.get_name()).user), (3, self.get_name())]
+ return [(1, safeJID(self.name).user), (3, self.name)]
diff --git a/src/tabs/privatetab.py b/src/tabs/privatetab.py
index a88e9060..b8699bd2 100644
--- a/src/tabs/privatetab.py
+++ b/src/tabs/privatetab.py
@@ -66,7 +66,7 @@ class PrivateTab(ChatTab):
@property
def general_jid(self):
- return self.get_name()
+ return self.name
@property
def nick(self):
@@ -84,7 +84,7 @@ class PrivateTab(ChatTab):
del PrivateTab.additional_informations[plugin_name]
def load_logs(self, log_nb):
- logs = logger.get_logs(safeJID(self.get_name()).full.replace('/', '\\'), log_nb)
+ logs = logger.get_logs(safeJID(self.name).full.replace('/', '\\'), log_nb)
def log_message(self, txt, nickname, time=None, typ=1):
"""
@@ -121,7 +121,7 @@ class PrivateTab(ChatTab):
def command_say(self, line, attention=False, correct=False):
if not self.on:
return
- msg = self.core.xmpp.make_message(self.get_name())
+ msg = self.core.xmpp.make_message(self.name)
msg['type'] = 'chat'
msg['body'] = line
# trigger the event BEFORE looking for colors.
@@ -137,7 +137,7 @@ class PrivateTab(ChatTab):
replaced = False
if correct or msg['replace']['id']:
msg['replace']['id'] = self.last_sent_message['id']
- if config.get_by_tabname('group_corrections', True, self.get_name()):
+ if config.get_by_tabname('group_corrections', True, self.name):
try:
self.modify_message(msg['body'], self.last_sent_message['id'], msg['id'],
user=user, jid=self.core.xmpp.boundjid, nickname=self.own_nick)
@@ -181,13 +181,13 @@ class PrivateTab(ChatTab):
if message is not '':
self.command_say(message, attention=True)
else:
- msg = self.core.xmpp.make_message(self.get_name())
+ msg = self.core.xmpp.make_message(self.name)
msg['type'] = 'chat'
msg['attention'] = True
msg.send()
def check_attention(self):
- self.core.xmpp.plugin['xep_0030'].get_info(jid=self.get_name(), block=False, timeout=5, callback=self.on_attention_checked)
+ self.core.xmpp.plugin['xep_0030'].get_info(jid=self.name, block=False, timeout=5, callback=self.on_attention_checked)
def on_attention_checked(self, iq):
if 'urn:xmpp:attention:0' in iq['disco_info'].get_features():
@@ -274,9 +274,6 @@ class PrivateTab(ChatTab):
self.info_header.refresh(self.name, self.text_win, self.chatstate, PrivateTab.additional_informations)
self.input.refresh()
- def get_name(self):
- return self.name
-
def get_nick(self):
return safeJID(self.name).resource
@@ -376,6 +373,6 @@ class PrivateTab(ChatTab):
self.add_message(txt=reason, typ=2)
def matching_names(self):
- return [(3, safeJID(self.get_name()).resource), (4, self.get_name())]
+ return [(3, safeJID(self.name).resource), (4, self.name)]
diff --git a/src/tabs/rostertab.py b/src/tabs/rostertab.py
index adc83445..81b5fcb5 100644
--- a/src/tabs/rostertab.py
+++ b/src/tabs/rostertab.py
@@ -738,9 +738,6 @@ class RosterInfoTab(Tab):
self.refresh_tab_win()
self.input.refresh()
- def get_name(self):
- return self.name
-
def on_input(self, key, raw):
if key == '^M':
selected_row = self.roster_win.get_selected_row()
diff --git a/src/tabs/xmltab.py b/src/tabs/xmltab.py
index 7c79da67..57b55103 100644
--- a/src/tabs/xmltab.py
+++ b/src/tabs/xmltab.py
@@ -22,6 +22,7 @@ class XMLTab(Tab):
def __init__(self):
Tab.__init__(self)
self.state = 'normal'
+ self.name = 'XMLTab'
self.text_win = windows.TextWin()
self.core.xml_buffer.add_window(self.text_win)
self.info_header = windows.XMLInfoWin()