Skip to content
Snippets Groups Projects
Commit 21a39719 authored by nkour's avatar nkour
Browse files

some more helpers for our API

parent 4c75c558
No related branches found
No related tags found
No related merge requests found
......@@ -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')
......@@ -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:
......
......@@ -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')
......
......@@ -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')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment