diff --git a/src/common/gajim.py b/src/common/gajim.py index aaaf4e067..2cbaecf48 100644 --- a/src/common/gajim.py +++ b/src/common/gajim.py @@ -147,3 +147,34 @@ def get_resource_from_jid(jid): def get_number_of_accounts(): return len(connections.keys()) + +def get_transport_name_from_jid(self, jid, use_config_setting = True): + '''returns 'aim', 'gg', 'irc' etc''' + if use_config_setting or not gajim.config.get('use_transports_iconsets'): + return + host = jid.split('@')[-1] + if host.startswith('aim'): + return 'aim' + elif host.startswith('gadugadu'): + return 'gadugadu' + elif host.startswith('gg'): + return 'gadugadu' + elif host.startswith('irc'): + return 'irc' + # abc@icqsucks.org will match as ICQ, but what to do.. + elif host.startswith('icq'): + return 'icq' + elif host.startswith('msn'): + return 'msn' + elif host.startswith('sms'): + return 'sms' + elif host.startswith('tlen'): + return 'tlen' + elif host.startswith('yahoo'): + return 'yahoo' + +def jid_is_transport(jid): + is_transport = jid.startswith('aim') or jid.startswith('gadugadu') or\ + jid.startswith('irc') or jid.startswith('icq') or\ + jid.startswith('msn') or jid.startswith('sms') or\ + jid.startswith('yahoo') diff --git a/src/roster_window.py b/src/roster_window.py index 568cac780..570d2c8f5 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -192,34 +192,9 @@ class RosterWindow: if group_empty: del gajim.groups[account][group] - def get_transport_name_by_jid(self,jid): - if not jid or not gajim.config.get('use_transports_iconsets'): - return None - host = jid.split('@')[-1] - if host.startswith('aim'): - return 'aim' - elif host.startswith('gadugadu'): - return 'gadugadu' - elif host.startswith('gg'): - return 'gadugadu' - elif host.startswith('irc'): - return 'irc' - # abc@icqsucks.org will match as ICQ, but what to do.. - elif host.startswith('icq'): - return 'icq' - elif host.startswith('msn'): - return 'msn' - elif host.startswith('sms'): - return 'sms' - elif host.startswith('tlen'): - return 'tlen' - elif host.startswith('yahoo'): - return 'yahoo' - return None - def get_appropriate_state_images(self, jid): '''check jid and return the appropriate state images dict''' - transport = self.get_transport_name_by_jid(jid) + transport = gajim.get_transport_name_from_jid(jid) if transport: return self.transports_state_images[transport] return self.jabber_state_images @@ -248,7 +223,7 @@ class RosterWindow: if contact.ask == 'subscribe': img = state_images['requested'] else: - transport = self.get_transport_name_by_jid(jid) + transport = gajim.get_transport_name_from_jid(jid) if transport and state_images.has_key(contact.show): img = state_images[contact.show] else: diff --git a/src/tabbed_chat_window.py b/src/tabbed_chat_window.py index f7228bd37..158e2a93f 100644 --- a/src/tabbed_chat_window.py +++ b/src/tabbed_chat_window.py @@ -730,13 +730,8 @@ timestamp, contact): def restore_conversation(self, jid): # don't restore lines if it's a transport - is_transport = jid.startswith('aim') or jid.startswith('gadugadu') or\ - jid.startswith('irc') or jid.startswith('icq') or\ - jid.startswith('msn') or jid.startswith('sms') or\ - jid.startswith('yahoo') - - if is_transport: - return + if gajim.jid_is_transport(jid): + return # How many lines to restore and when to time them out restore = gajim.config.get('restore_lines') diff --git a/src/tooltips.py b/src/tooltips.py index f03b3f786..0a6d09367 100644 --- a/src/tooltips.py +++ b/src/tooltips.py @@ -304,7 +304,7 @@ class RosterTooltip(BaseTooltip, StatusTable): # try to find the image for the contact status state_file = prim_contact.show.replace(' ', '_') - transport = self.plugin.roster.get_transport_name_by_jid(prim_contact.jid) + transport = gajim.get_transport_name_from_jid(prim_contact.jid) if transport: file_path = os.path.join(gajim.DATA_DIR, 'iconsets', 'transports', transport , '16x16')