get_hostname_from_account can now return the srv_hostname

This commit is contained in:
Yann Leboulanger 2005-11-20 13:27:37 +00:00
parent a2467b8a8d
commit 6e593107e0
3 changed files with 6 additions and 4 deletions

View File

@ -157,6 +157,7 @@ class Connection:
self.vcard_shas = {} # sha of contacts self.vcard_shas = {} # sha of contacts
self.status = '' self.status = ''
self.old_show = '' self.old_show = ''
self.connected_hostname = None
self.time_to_reconnect = None self.time_to_reconnect = None
self.new_account_info = None self.new_account_info = None
self.bookmarks = [] self.bookmarks = []
@ -1606,7 +1607,7 @@ class Connection:
self.dispatch('ERROR', (_('Could not connect to "%s"') % h, self.dispatch('ERROR', (_('Could not connect to "%s"') % h,
_('Check your connection or try again later.'))) _('Check your connection or try again later.')))
return None, '' return None, ''
self.connected_hostname = host['host']
con.RegisterDisconnectHandler(self._disconnectedReconnCB) con.RegisterDisconnectHandler(self._disconnectedReconnCB)
gajim.log.debug(_('Connected to server %s:%s with %s') % (host['host'], gajim.log.debug(_('Connected to server %s:%s with %s') % (host['host'],
host['port'], con_type)) host['port'], con_type))

View File

@ -262,9 +262,10 @@ def get_jid_from_account(account_name):
jid = name + '@' + hostname jid = name + '@' + hostname
return jid return jid
def get_hostname_from_account(account_name): def get_hostname_from_account(account_name, use_srv = False):
'''returns hostname (if custom hostname is used, that is returned)''' '''returns hostname (if custom hostname is used, that is returned)'''
#FIXME: save srv record result and ask it here if use_srv and connections[account_name].connected_hostname:
return connections[account_name].connected_hostname
if config.get_per('accounts', account_name, 'use_custom_host'): if config.get_per('accounts', account_name, 'use_custom_host'):
return config.get_per('accounts', account_name, 'custom_host') return config.get_per('accounts', account_name, 'custom_host')
return config.get_per('accounts', account_name, 'hostname') return config.get_per('accounts', account_name, 'hostname')

View File

@ -452,7 +452,7 @@ _('Without a connection, you can not browse available services')).get_response()
self.address_comboboxentry.set_model(liststore) self.address_comboboxentry.set_model(liststore)
self.address_comboboxentry.set_text_column(0) self.address_comboboxentry.set_text_column(0)
self.latest_addresses = gajim.config.get('latest_disco_addresses').split() self.latest_addresses = gajim.config.get('latest_disco_addresses').split()
jid = gajim.get_hostname_from_account(self.account) jid = gajim.get_hostname_from_account(self.account, True)
if jid in self.latest_addresses: if jid in self.latest_addresses:
self.latest_addresses.remove(jid) self.latest_addresses.remove(jid)
self.latest_addresses.insert(0, jid) self.latest_addresses.insert(0, jid)