reconnect using reannounce and check if port has changed,

change global account variable
This commit is contained in:
Stefan Bethge 2006-09-25 20:14:17 +00:00
parent 29160807eb
commit f5e00e916c
4 changed files with 126 additions and 104 deletions

View file

@ -121,7 +121,7 @@ SHOW_LIST = ['offline', 'connecting', 'online', 'chat', 'away', 'xa', 'dnd',
'invisible'] 'invisible']
# zeroconf account name # zeroconf account name
LOCAL_ACC = 'local' ZEROCONF_ACC_NAME = 'Local'
def get_nick_from_jid(jid): def get_nick_from_jid(jid):
pos = jid.find('@') pos = jid.find('@')

View file

@ -70,7 +70,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
self.bookmarks = [] self.bookmarks = []
#we don't need a password, but must be non-empty #we don't need a password, but must be non-empty
self.password = gajim.LOCAL_ACC self.password = 'zeroconf'
#XXX use that somewhere #XXX use that somewhere
self.autoconnect = False self.autoconnect = False
@ -104,38 +104,39 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
def get_config_values_or_default(self): def get_config_values_or_default(self):
''' get name, host, port from config, or ''' get name, host, port from config, or
create zeroconf account with default values''' create zeroconf account with default values'''
if not self.username: if not self.username:
self.username = unicode(getpass.getuser()) self.username = unicode(getpass.getuser())
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'name', self.username) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'name', self.username)
else: else:
self.username = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'name') self.username = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'name')
if not gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'name'):
if not gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'name'):
print 'Creating zeroconf account' print 'Creating zeroconf account'
gajim.config.add_per('accounts', gajim.LOCAL_ACC) gajim.config.add_per('accounts', gajim.ZEROCONF_ACC_NAME)
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'autoconnect', True) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'autoconnect', True)
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'no_log_for', '') gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'no_log_for', '')
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'password', 'zeroconf') gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'password', 'zeroconf')
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'sync_with_global_status', True) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'sync_with_global_status', True)
#XXX make sure host is US-ASCII #XXX make sure host is US-ASCII
self.host = unicode(socket.gethostname()) self.host = unicode(socket.gethostname())
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'hostname', self.host) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'hostname', self.host)
self.port = 5298 self.port = 5298
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'custom_port', self.port) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port', self.port)
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'is_zeroconf', True) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'is_zeroconf', True)
else: else:
self.host = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'hostname')
self.host = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'hostname') self.port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port')
self.port = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'custom_port') self.autoconnect = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'autoconnect')
self.autoconnect = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'autoconnect') self.sync_with_global_status = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'sync_with_global_status')
self.sync_with_global_status = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'sync_with_global_status') self.no_log_for = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'no_log_for')
self.no_log_for = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'no_log_for') self.first = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_first_name')
self.first = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'zeroconf_first_name') self.last = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_last_name')
self.last = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'zeroconf_last_name') self.jabber_id = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id')
self.jabber_id = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'zeroconf_jabber_id') self.email = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email')
self.email = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'zeroconf_email')
# END __init__ # END __init__
def put_event(self, ev): def put_event(self, ev):
if gajim.handlers.has_key(ev[0]): if gajim.handlers.has_key(ev[0]):
gajim.handlers[ev[0]](self.name, ev[1]) gajim.handlers[ev[0]](self.name, ev[1])
@ -237,9 +238,6 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
self.call_resolve_timeout = True self.call_resolve_timeout = True
gobject.timeout_add(10000, self._on_resolve_timeout) gobject.timeout_add(10000, self._on_resolve_timeout)
else: else:
notify.popup(_('Connection problem:'), gajim.LOCAL_ACC, None,
title=_('Can not get connection'),
text=_('Please check if avahi-daemon is running.') )
self.dispatch('STATUS', 'offline') self.dispatch('STATUS', 'offline')
self.status = 'offline' self.status = 'offline'
@ -254,12 +252,28 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
self.call_resolve_timeout = False self.call_resolve_timeout = False
self.zeroconf.disconnect() self.zeroconf.disconnect()
def reconnect(self): def reconnect(self, new_port, use_tls):
status = self.status txt = {}
if status != 'offline': txt['1st'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_first_name')
msg = self.zeroconf.txt['msg'] txt['last'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_last_name')
self.change_status('offline', msg) txt['jid'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id')
self.change_status(status, msg) txt['email'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email')
txt2 = {}
for key, val in txt.iteritems():
if val != '':
txt2[key] = val
port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port')
if new_port or use_tls:
self.connection.kill_all_connections()
self.connection.listener.disconnect()
self.connection.start_listener(port)
self.zeroconf.remove_announce()
self.zeroconf.txt = txt2
self.zeroconf.port = port
self.zeroconf.announce()
def change_status(self, show, msg, sync = False, auto = False): def change_status(self, show, msg, sync = False, auto = False):
if not show in STATUS_LIST: if not show in STATUS_LIST:
@ -299,7 +313,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
if check: if check:
self.dispatch('STATUS', show) self.dispatch('STATUS', show)
else: else:
notify.popup(_('Connection problem:'), gajim.LOCAL_ACC, None, notify.popup(_('Connection problem:'), gajim.ZEROCONF_ACC_NAME, None,
title=_('Could not change status'), title=_('Could not change status'),
text=_('Please check if avahi-daemon is running.') ) text=_('Please check if avahi-daemon is running.') )
self.dispatch('STATUS', 'offline') self.dispatch('STATUS', 'offline')

View file

@ -1825,7 +1825,7 @@ class AccountsWindow:
self.show_modification_window(account) self.show_modification_window(account)
def show_modification_window(self, account): def show_modification_window(self, account):
if account == gajim.LOCAL_ACC: if account == gajim.ZEROCONF_ACC_NAME:
if gajim.interface.instances.has_key('zeroconf_properties'): if gajim.interface.instances.has_key('zeroconf_properties'):
gajim.interface.instances['zeroconf_properties'].window.present() gajim.interface.instances['zeroconf_properties'].window.present()
else: else:
@ -1857,23 +1857,23 @@ class AccountsWindow:
def on_enable_zeroconf_checkbutton_toggled(self, widget): def on_enable_zeroconf_checkbutton_toggled(self, widget):
if gajim.config.get('enable_zeroconf'): if gajim.config.get('enable_zeroconf'):
#disable #disable
gajim.interface.roster.close_all(gajim.LOCAL_ACC) gajim.interface.roster.close_all(gajim.ZEROCONF_ACC_NAME)
gajim.connections[gajim.LOCAL_ACC].disable_account() gajim.connections[gajim.ZEROCONF_ACC_NAME].disable_account()
del gajim.connections[gajim.LOCAL_ACC] del gajim.connections[gajim.ZEROCONF_ACC_NAME]
gajim.interface.save_config() gajim.interface.save_config()
del gajim.interface.instances[gajim.LOCAL_ACC] del gajim.interface.instances[gajim.ZEROCONF_ACC_NAME]
del gajim.nicks[gajim.LOCAL_ACC] del gajim.nicks[gajim.ZEROCONF_ACC_NAME]
del gajim.block_signed_in_notifications[gajim.LOCAL_ACC] del gajim.block_signed_in_notifications[gajim.ZEROCONF_ACC_NAME]
del gajim.groups[gajim.LOCAL_ACC] del gajim.groups[gajim.ZEROCONF_ACC_NAME]
gajim.contacts.remove_account(gajim.LOCAL_ACC) gajim.contacts.remove_account(gajim.ZEROCONF_ACC_NAME)
del gajim.gc_connected[gajim.LOCAL_ACC] del gajim.gc_connected[gajim.ZEROCONF_ACC_NAME]
del gajim.automatic_rooms[gajim.LOCAL_ACC] del gajim.automatic_rooms[gajim.ZEROCONF_ACC_NAME]
del gajim.to_be_removed[gajim.LOCAL_ACC] del gajim.to_be_removed[gajim.ZEROCONF_ACC_NAME]
del gajim.newly_added[gajim.LOCAL_ACC] del gajim.newly_added[gajim.ZEROCONF_ACC_NAME]
del gajim.sleeper_state[gajim.LOCAL_ACC] del gajim.sleeper_state[gajim.ZEROCONF_ACC_NAME]
del gajim.encrypted_chats[gajim.LOCAL_ACC] del gajim.encrypted_chats[gajim.ZEROCONF_ACC_NAME]
del gajim.last_message_time[gajim.LOCAL_ACC] del gajim.last_message_time[gajim.ZEROCONF_ACC_NAME]
del gajim.status_before_autoaway[gajim.LOCAL_ACC] del gajim.status_before_autoaway[gajim.ZEROCONF_ACC_NAME]
if len(gajim.connections) >= 2: # Do not merge accounts if only one exists if len(gajim.connections) >= 2: # Do not merge accounts if only one exists
gajim.interface.roster.regroup = gajim.config.get('mergeaccounts') gajim.interface.roster.regroup = gajim.config.get('mergeaccounts')
else: else:
@ -1885,23 +1885,23 @@ class AccountsWindow:
else: else:
# enable (will create new account if not present) # enable (will create new account if not present)
gajim.connections[gajim.LOCAL_ACC] = common.zeroconf.connection_zeroconf.ConnectionZeroconf(gajim.LOCAL_ACC) gajim.connections[gajim.ZEROCONF_ACC_NAME] = common.zeroconf.connection_zeroconf.ConnectionZeroconf(gajim.ZEROCONF_ACC_NAME)
# update variables # update variables
gajim.interface.instances[gajim.LOCAL_ACC] = {'infos': {}, 'disco': {}, gajim.interface.instances[gajim.ZEROCONF_ACC_NAME] = {'infos': {}, 'disco': {},
'gc_config': {}} 'gc_config': {}}
gajim.connections[gajim.LOCAL_ACC].connected = 0 gajim.connections[gajim.ZEROCONF_ACC_NAME].connected = 0
gajim.groups[gajim.LOCAL_ACC] = {} gajim.groups[gajim.ZEROCONF_ACC_NAME] = {}
gajim.contacts.add_account(gajim.LOCAL_ACC) gajim.contacts.add_account(gajim.ZEROCONF_ACC_NAME)
gajim.gc_connected[gajim.LOCAL_ACC] = {} gajim.gc_connected[gajim.ZEROCONF_ACC_NAME] = {}
gajim.automatic_rooms[gajim.LOCAL_ACC] = {} gajim.automatic_rooms[gajim.ZEROCONF_ACC_NAME] = {}
gajim.newly_added[gajim.LOCAL_ACC] = [] gajim.newly_added[gajim.ZEROCONF_ACC_NAME] = []
gajim.to_be_removed[gajim.LOCAL_ACC] = [] gajim.to_be_removed[gajim.ZEROCONF_ACC_NAME] = []
gajim.nicks[gajim.LOCAL_ACC] = gajim.LOCAL_ACC gajim.nicks[gajim.ZEROCONF_ACC_NAME] = gajim.ZEROCONF_ACC_NAME
gajim.block_signed_in_notifications[gajim.LOCAL_ACC] = True gajim.block_signed_in_notifications[gajim.ZEROCONF_ACC_NAME] = True
gajim.sleeper_state[gajim.LOCAL_ACC] = 'off' gajim.sleeper_state[gajim.ZEROCONF_ACC_NAME] = 'off'
gajim.encrypted_chats[gajim.LOCAL_ACC] = [] gajim.encrypted_chats[gajim.ZEROCONF_ACC_NAME] = []
gajim.last_message_time[gajim.LOCAL_ACC] = {} gajim.last_message_time[gajim.ZEROCONF_ACC_NAME] = {}
gajim.status_before_autoaway[gajim.LOCAL_ACC] = '' gajim.status_before_autoaway[gajim.ZEROCONF_ACC_NAME] = ''
# refresh accounts window # refresh accounts window
if gajim.interface.instances.has_key('accounts'): if gajim.interface.instances.has_key('accounts'):
gajim.interface.instances['accounts'].init_accounts() gajim.interface.instances['accounts'].init_accounts()
@ -1913,7 +1913,7 @@ class AccountsWindow:
gajim.interface.roster.draw_roster() gajim.interface.roster.draw_roster()
gajim.interface.roster.actions_menu_needs_rebuild = True gajim.interface.roster.actions_menu_needs_rebuild = True
gajim.interface.save_config() gajim.interface.save_config()
gajim.connections[gajim.LOCAL_ACC].change_status('online', '') gajim.connections[gajim.ZEROCONF_ACC_NAME].change_status('online', '')
self.on_checkbutton_toggled(widget, 'enable_zeroconf') self.on_checkbutton_toggled(widget, 'enable_zeroconf')
@ -3053,53 +3053,53 @@ class ZeroconfPropertiesWindow:
self.window.set_transient_for(gajim.interface.roster.window) self.window.set_transient_for(gajim.interface.roster.window)
self.xml.signal_autoconnect(self) self.xml.signal_autoconnect(self)
st = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'autoconnect') st = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'autoconnect')
if st: if st:
self.xml.get_widget('autoconnect_checkbutton').set_active(st) self.xml.get_widget('autoconnect_checkbutton').set_active(st)
list_no_log_for = gajim.config.get_per('accounts', gajim.LOCAL_ACC,'no_log_for').split() list_no_log_for = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME,'no_log_for').split()
if gajim.LOCAL_ACC in list_no_log_for: if gajim.ZEROCONF_ACC_NAME in list_no_log_for:
self.xml.get_widget('log_history_checkbutton').set_active(0) self.xml.get_widget('log_history_checkbutton').set_active(0)
else: else:
self.xml.get_widget('log_history_checkbutton').set_active(1) self.xml.get_widget('log_history_checkbutton').set_active(1)
st = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'sync_with_global_status') st = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'sync_with_global_status')
if st: if st:
self.xml.get_widget('sync_with_global_status_checkbutton').set_active(st) self.xml.get_widget('sync_with_global_status_checkbutton').set_active(st)
st = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'zeroconf_first_name') st = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_first_name')
if st: if st:
self.xml.get_widget('first_name_entry').set_text(st) self.xml.get_widget('first_name_entry').set_text(st)
st = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'zeroconf_last_name') st = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_last_name')
if st: if st:
self.xml.get_widget('last_name_entry').set_text(st) self.xml.get_widget('last_name_entry').set_text(st)
st = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'zeroconf_jabber_id') st = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id')
if st: if st:
self.xml.get_widget('jabber_id_entry').set_text(st) self.xml.get_widget('jabber_id_entry').set_text(st)
st = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'zeroconf_email') st = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email')
if st: if st:
self.xml.get_widget('email_entry').set_text(st) self.xml.get_widget('email_entry').set_text(st)
st = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'use_ssl') st = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'use_ssl')
if st: if st:
self.xml.get_widget('use_tls_checkbutton').set_active(st) self.xml.get_widget('use_tls_checkbutton').set_active(st)
st = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'custom_port') st = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port')
if st: if st:
self.xml.get_widget('custom_port_entry').set_text(str(st)) self.xml.get_widget('custom_port_entry').set_text(str(st))
st = gajim.config.get_per('accounts', gajim.LOCAL_ACC, 'use_custom_host') st = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'use_custom_host')
if st: if st:
self.xml.get_widget('custom_port_checkbutton').set_active(st) self.xml.get_widget('custom_port_checkbutton').set_active(st)
self.xml.get_widget('custom_port_entry').set_sensitive(bool(st)) self.xml.get_widget('custom_port_entry').set_sensitive(bool(st))
if not st: if not st:
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'custom_port', '5298') gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port', '5298')
self.xml.get_widget('save_button').grab_focus() self.xml.get_widget('save_button').grab_focus()
self.window.show_all() self.window.show_all()
@ -3118,44 +3118,52 @@ class ZeroconfPropertiesWindow:
def on_save_button_clicked(self, widget): def on_save_button_clicked(self, widget):
st = self.xml.get_widget('autoconnect_checkbutton').get_active() st = self.xml.get_widget('autoconnect_checkbutton').get_active()
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'autoconnect', st) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'autoconnect', st)
list_no_log_for = gajim.config.get_per('accounts', list_no_log_for = gajim.config.get_per('accounts',
gajim.LOCAL_ACC, 'no_log_for').split() gajim.ZEROCONF_ACC_NAME, 'no_log_for').split()
if gajim.LOCAL_ACC in list_no_log_for: if gajim.ZEROCONF_ACC_NAME in list_no_log_for:
list_no_log_for.remove(gajim.LOCAL_ACC) list_no_log_for.remove(gajim.ZEROCONF_ACC_NAME)
if not self.xml.get_widget('log_history_checkbutton').get_active(): if not self.xml.get_widget('log_history_checkbutton').get_active():
list_no_log_for.append(gajim.LOCAL_ACC) list_no_log_for.append(gajim.ZEROCONF_ACC_NAME)
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'no_log_for', ' '.join(list_no_log_for)) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'no_log_for', ' '.join(list_no_log_for))
st = self.xml.get_widget('sync_with_global_status_checkbutton').get_active() st = self.xml.get_widget('sync_with_global_status_checkbutton').get_active()
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'sync_with_global_status', st) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'sync_with_global_status', st)
st = self.xml.get_widget('first_name_entry').get_text() st = self.xml.get_widget('first_name_entry').get_text()
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'zeroconf_first_name', st) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_first_name', st)
st = self.xml.get_widget('last_name_entry').get_text() st = self.xml.get_widget('last_name_entry').get_text()
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'zeroconf_last_name', st) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_last_name', st)
st = self.xml.get_widget('jabber_id_entry').get_text() st = self.xml.get_widget('jabber_id_entry').get_text()
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'zeroconf_jabber_id', st) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id', st)
st = self.xml.get_widget('email_entry').get_text() st = self.xml.get_widget('email_entry').get_text()
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'zeroconf_email', st) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email', st)
st = self.xml.get_widget('use_tls_checkbutton').get_active() use_tls = self.xml.get_widget('use_tls_checkbutton').get_active()
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'use_ssl', st) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'use_ssl', use_tls)
st = self.xml.get_widget('custom_port_checkbutton').get_active() use_custom_port = self.xml.get_widget('custom_port_checkbutton').get_active()
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'use_custom_host', st) gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'use_custom_host', use_custom_port)
if st: old_port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port')
st = self.xml.get_widget('custom_port_entry').get_text() if use_custom_port:
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'custom_port', st) port = self.xml.get_widget('custom_port_entry').get_text()
else: else:
gajim.config.set_per('accounts', gajim.LOCAL_ACC, 'custom_port', '5298') port = '5298'
if gajim.connections.has_key(gajim.LOCAL_ACC): gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port', port)
gajim.connections[gajim.LOCAL_ACC].reconnect()
# force restart of listener (because port has changed)
if port != old_port:
use_custom_port = True
else:
use_custom_port = False
if gajim.connections.has_key(gajim.ZEROCONF_ACC_NAME):
gajim.connections[gajim.ZEROCONF_ACC_NAME].reconnect(use_custom_port, use_tls)
self.window.destroy() self.window.destroy()

View file

@ -1869,9 +1869,9 @@ class Interface:
gajim.proxy65_manager = proxy65_manager.Proxy65Manager(gajim.idlequeue) gajim.proxy65_manager = proxy65_manager.Proxy65Manager(gajim.idlequeue)
self.register_handlers() self.register_handlers()
if gajim.config.get('enable_zeroconf'): if gajim.config.get('enable_zeroconf'):
gajim.connections[gajim.LOCAL_ACC] = common.zeroconf.connection_zeroconf.ConnectionZeroconf(gajim.LOCAL_ACC) gajim.connections[gajim.ZEROCONF_ACC_NAME] = common.zeroconf.connection_zeroconf.ConnectionZeroconf(gajim.ZEROCONF_ACC_NAME)
for account in gajim.config.get_per('accounts'): for account in gajim.config.get_per('accounts'):
if account != gajim.LOCAL_ACC: if account != gajim.ZEROCONF_ACC_NAME:
gajim.connections[account] = common.connection.Connection(account) gajim.connections[account] = common.connection.Connection(account)
gtk.about_dialog_set_email_hook(self.on_launch_browser_mailer, 'mail') gtk.about_dialog_set_email_hook(self.on_launch_browser_mailer, 'mail')