From a06468b846663393a5838d1362a54149873920ff Mon Sep 17 00:00:00 2001
From: Stephan Erb <steve-e@h3c.de>
Date: Mon, 19 May 2008 21:17:43 +0000
Subject: [PATCH] Always remove contacts from GUI when we receive a roster via
 xmppy.

This fixes a bug with metacontacts over different groups and should stop contact duplication in most cases.
---
 src/gajim.py         | 2 ++
 src/roster_window.py | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/src/gajim.py b/src/gajim.py
index a7203d445f..615becc463 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -652,6 +652,8 @@ class Interface:
 
 	def handle_event_roster(self, account, data):
 		#('ROSTER', account, array)
+		# FIXME: Those methods depend to highly on each other
+		# and the order in which they are called
 		self.roster.fill_contacts_and_groups_dicts(data, account)
 		self.roster.add_account_contacts(account)
 		self.roster.fire_up_unread_messages_events(account)
diff --git a/src/roster_window.py b/src/roster_window.py
index df6d0c6966..c645c1ca4c 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -1501,11 +1501,15 @@ class RosterWindow:
 
 	def fill_contacts_and_groups_dicts(self, array, account):
 		'''fill gajim.contacts and gajim.groups'''
+		# FIXME: This function needs to be splitted
+		# Most of the logic SHOULD NOT be done at GUI level
 		if account not in gajim.contacts.get_accounts():
 			gajim.contacts.add_account(account)
 		if not gajim.groups.has_key(account):
 			gajim.groups[account] = {}
 		for jid in array.keys():
+			# Remove the contact in roster. It might has changed
+			self.remove_contact(jid, account)
 			# Remove old Contact instances
 			gajim.contacts.remove_jid(account, jid, remove_meta=False)
 			jids = jid.split('/')
-- 
GitLab