commit a22ae33a818a0fb8015f90f7c2164900473cd135
parent 7a5b8a6202c38f14404d1840f313c859998f96bb
Author: ThomasV <thomasv@gitorious>
Date: Wed, 2 Oct 2013 12:13:07 +0200
set_server: resend subscriptions
Diffstat:
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/gui/qt/network_dialog.py b/gui/qt/network_dialog.py
@@ -238,7 +238,8 @@ class NetworkDialog(QDialog):
self.config.set_key("proxy", proxy, True)
self.config.set_key("server", server, True)
- self.network.set_server(server, proxy)
+ self.network.set_proxy(proxy)
+ self.network.set_server(server)
self.config.set_key('auto_cycle', self.autocycle_cb.isChecked(), True)
return True
diff --git a/lib/network.py b/lib/network.py
@@ -129,17 +129,26 @@ class Network(threading.Thread):
return self.interface.is_connected
- def set_server(self, server, proxy):
+ def set_proxy(self, proxy):
+ self.proxy = proxy
+
+
+ def set_server(self, server):
if self.default_server == server:
return
- i = self.interface
+ # stop the interface in order to terminate subscriptions
+ subscriptions = self.interface.subscriptions
+ self.interface.stop()
+ # notify gui
+ self.trigger_callback('disconnecting')
+ # start interface
self.default_server = server
- self.proxy = proxy
self.start_interface(server)
self.interface = self.interfaces[server]
- i.stop_subscriptions() # fixme: it should not stop all subscriptions, and send 'unsubscribe'
- self.trigger_callback('disconnecting') # for actively disconnecting
+ # send subscriptions
+ for cb, sub in subscriptions.items():
+ self.interface.send(sub, cb)
def run(self):