only restart listener or reconnect upon changing preferences if necessary
This commit is contained in:
parent
d557725810
commit
e1dadf48c1
|
@ -566,6 +566,7 @@ You might consider to change possible firewall settings.</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkEntry" id="gpg_password_entry">
|
<widget class="GtkEntry" id="gpg_password_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<property name="sensitive">False</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="editable">True</property>
|
<property name="editable">True</property>
|
||||||
<property name="visibility">False</property>
|
<property name="visibility">False</property>
|
||||||
|
|
|
@ -189,8 +189,10 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
|
||||||
diffs = self.roster.getDiffs()
|
diffs = self.roster.getDiffs()
|
||||||
for key in diffs:
|
for key in diffs:
|
||||||
self.roster.setItem(key)
|
self.roster.setItem(key)
|
||||||
self.dispatch('ROSTER_INFO', (key, self.roster.getName(key), 'both', 'no', self.roster.getGroups(key)))
|
self.dispatch('ROSTER_INFO', (key, self.roster.getName(key),
|
||||||
self.dispatch('NOTIFY', (key, self.roster.getStatus(key), self.roster.getMessage(key), 'local', 0, None, 0))
|
'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
|
#XXX open chat windows don't get refreshed (full name), add that
|
||||||
return self.call_resolve_timeout
|
return self.call_resolve_timeout
|
||||||
|
|
||||||
|
@ -259,28 +261,29 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
|
||||||
# stop calling the timeout
|
# stop calling the timeout
|
||||||
self.call_resolve_timeout = False
|
self.call_resolve_timeout = False
|
||||||
self.zeroconf.disconnect()
|
self.zeroconf.disconnect()
|
||||||
|
|
||||||
def reconnect(self, new_port):
|
def reconnect(self):
|
||||||
if self.connected:
|
if self.connected:
|
||||||
txt = {}
|
txt = {}
|
||||||
txt['1st'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_first_name')
|
txt['1st'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_first_name')
|
||||||
txt['last'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_last_name')
|
txt['last'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_last_name')
|
||||||
txt['jid'] = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME, 'zeroconf_jabber_id')
|
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')
|
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.remove_announce()
|
||||||
self.zeroconf.txt = txt
|
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.username = self.username
|
||||||
self.zeroconf.announce()
|
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):
|
def change_status(self, show, msg, sync = False, auto = False):
|
||||||
if not show in STATUS_LIST:
|
if not show in STATUS_LIST:
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -3233,14 +3233,8 @@ class ZeroconfPropertiesWindow:
|
||||||
if use_custom_port:
|
if use_custom_port:
|
||||||
port = self.xml.get_widget('custom_port_entry').get_text()
|
port = self.xml.get_widget('custom_port_entry').get_text()
|
||||||
else:
|
else:
|
||||||
port = '5298'
|
port = 5298
|
||||||
|
|
||||||
# force restart of listener (because port has changed)
|
|
||||||
if port != old_port:
|
|
||||||
use_custom_port = True
|
|
||||||
else:
|
|
||||||
use_custom_port = False
|
|
||||||
|
|
||||||
config['custom_port'] = port
|
config['custom_port'] = port
|
||||||
|
|
||||||
config['keyname'] = self.xml.get_widget('gpg_name_label').get_text().decode('utf-8')
|
config['keyname'] = self.xml.get_widget('gpg_name_label').get_text().decode('utf-8')
|
||||||
|
@ -3255,11 +3249,20 @@ class ZeroconfPropertiesWindow:
|
||||||
config['gpgpassword'] = self.xml.get_widget('gpg_password_entry'
|
config['gpgpassword'] = self.xml.get_widget('gpg_password_entry'
|
||||||
).get_text().decode('utf-8')
|
).get_text().decode('utf-8')
|
||||||
|
|
||||||
for opt in config:
|
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])
|
gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, opt, config[opt])
|
||||||
|
|
||||||
if gajim.connections.has_key(gajim.ZEROCONF_ACC_NAME):
|
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()
|
self.window.destroy()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue