From e8426d4cef6ce35c44d365cdef1839a566f0e135 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Mon, 20 Aug 2012 14:49:29 +0200
Subject: [PATCH] try to improve behavour with contacs connected with several
 resources

---
 src/gui_interface.py   | 2 +-
 src/message_control.py | 8 +-------
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/gui_interface.py b/src/gui_interface.py
index 0da0b779bf..736ce8d600 100644
--- a/src/gui_interface.py
+++ b/src/gui_interface.py
@@ -375,7 +375,7 @@ class Interface:
         is_highest = (highest and highest.resource == resource)
 
         ctrl = self.msg_win_mgr.get_control(jid, account)
-        if ctrl and ctrl.session and ctrl.session.resource == resource:
+        if ctrl and ctrl.session and len(obj.contact_list) > 1:
             ctrl.remove_session(ctrl.session)
 
     def handle_event_msgerror(self, obj):
diff --git a/src/message_control.py b/src/message_control.py
index e7a32fc093..3593ceac44 100644
--- a/src/message_control.py
+++ b/src/message_control.py
@@ -60,7 +60,6 @@ class MessageControl(object):
         self.resource = resource
 
         self.session = None
-        self.other_sessions = []
 
         gajim.last_message_time[self.account][self.get_full_jid()] = 0
 
@@ -203,10 +202,6 @@ class MessageControl(object):
 
         if oldsession:
             oldsession.control = None
-            self.other_sessions.append(oldsession)
-
-        if self.session in self.other_sessions:
-            self.other_sessions.remove(self.session)
 
         crypto_changed = bool(session and isinstance(session,
             EncryptedStanzaSession) and session.enable_encryption) != \
@@ -229,8 +224,7 @@ class MessageControl(object):
             last_session = self.other_sessions.pop(0)
         if session not in self.other_sessions:
             self.other_sessions.append(session)
-        if last_session:
-            self.session = last_session
+        self.session = last_session
 
     def _nec_message_outgoing(self, obj):
         # Send the given message to the active tab.
-- 
GitLab