set_server: resend subscriptions
authorThomasV <thomasv@gitorious>
Wed, 2 Oct 2013 10:13:07 +0000 (12:13 +0200)
committerThomasV <thomasv@gitorious>
Wed, 2 Oct 2013 10:13:07 +0000 (12:13 +0200)
gui/qt/network_dialog.py
lib/network.py

index d66b31c..95532d6 100644 (file)
@@ -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
index b59c36d..18015f1 100644 (file)
@@ -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):