only restart listener or reconnect upon changing preferences if necessary

This commit is contained in:
Stefan Bethge 2006-10-02 14:15:51 +00:00
parent d557725810
commit e1dadf48c1
3 changed files with 30 additions and 23 deletions

View File

@ -566,6 +566,7 @@ You might consider to change possible firewall settings.</property>
<child>
<widget class="GtkEntry" id="gpg_password_entry">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">False</property>

View File

@ -189,8 +189,10 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
diffs = self.roster.getDiffs()
for key in diffs:
self.roster.setItem(key)
self.dispatch('ROSTER_INFO', (key, self.roster.getName(key), 'both', 'no', self.roster.getGroups(key)))
self.dispatch('NOTIFY', (key, self.roster.getStatus(key), self.roster.getMessage(key), 'local', 0, None, 0))
self.dispatch('ROSTER_INFO', (key, self.roster.getName(key),
'both', 'no', self.roster.getGroups(key)))
self.dispatch('NOTIFY', (key, self.roster.getStatus(key),
self.roster.getMessage(key), 'local', 0, None, 0))
#XXX open chat windows don't get refreshed (full name), add that
return self.call_resolve_timeout
@ -260,7 +262,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
self.call_resolve_timeout = False
self.zeroconf.disconnect()
def reconnect(self, new_port):
def reconnect(self):
if self.connected:
txt = {}
txt['1st'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_first_name')
@ -268,19 +270,20 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
txt['jid'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id')
txt['email'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_email')
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 = txt
self.zeroconf.port = port
self.zeroconf.port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port')
self.zeroconf.username = self.username
self.zeroconf.announce()
def restart_listener(self):
if self.connection:
port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'custom_port')
self.connection.kill_all_connections()
if self.connection.listener:
self.connection.listener.disconnect()
self.connection.start_listener(port)
def change_status(self, show, msg, sync = False, auto = False):
if not show in STATUS_LIST:
return -1

View File

@ -3233,13 +3233,7 @@ class ZeroconfPropertiesWindow:
if use_custom_port:
port = self.xml.get_widget('custom_port_entry').get_text()
else:
port = '5298'
# force restart of listener (because port has changed)
if port != old_port:
use_custom_port = True
else:
use_custom_port = False
port = 5298
config['custom_port'] = port
@ -3255,11 +3249,20 @@ class ZeroconfPropertiesWindow:
config['gpgpassword'] = self.xml.get_widget('gpg_password_entry'
).get_text().decode('utf-8')
reconnect = False
for opt in ('zeroconf_first_name','zeroconf_last_name', 'zeroconf_jabber_id', 'zeroconf_email', 'custom_port'):
if gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, opt) != config[opt]:
reconnect = True
for opt in config:
gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, opt, config[opt])
if gajim.connections.has_key(gajim.ZEROCONF_ACC_NAME):
gajim.connections[gajim.ZEROCONF_ACC_NAME].reconnect(use_custom_port)
if port != old_port:
# restart listener if port has changed
gajim.connections[gajim.ZEROCONF_ACC_NAME].restart_listener()
if reconnect:
gajim.connections[gajim.ZEROCONF_ACC_NAME].reconnect()
self.window.destroy()