Bug 94057 - remove contacts belonging to deleted accounts
Summary: remove contacts belonging to deleted accounts
Status: RESOLVED FIXED
Alias: None
Product: kopete
Classification: Unmaintained
Component: libkopete (other bugs)
Version First Reported In: unspecified
Platform: unspecified Linux
: VLO wishlist
Target Milestone: ---
Assignee: Kopete Developers
URL:
Keywords:
: 121317 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-11-28 00:19 UTC by Gael Beaudoin
Modified: 2006-06-17 20:28 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gael Beaudoin 2004-11-28 00:19:43 UTC
Version:           0.9.1 (using KDE KDE 3.3.1)
Installed from:    Gentoo Packages
Compiler:          gcc 3.3.4 
OS:                Linux

A friend came home and had to connect to his msn accound so I set up a new account for him.
Everythings worked fine.

But when I deleted his msn account, all of his contacts are still in my contact list. Annoying. There are more than 100 contacts :(

If I could sort the contact by account, it would be easy to delete the group.

Contacts belonging to one account should be deleted when the account is deleted.
Comment 1 Matt Rogers 2005-01-02 04:02:51 UTC
we don't do this, and i think we should, just in the interest of contact list cleanliness
Comment 2 Francis Giannaros 2005-01-06 17:27:59 UTC
I really think you guys should. Was just about to request this myself. Kopete takes ages to load initially, because it has to load so many contacts (which are never being put to use... just people who logged on once or twice). 
Comment 3 Gael Beaudoin 2005-01-07 16:34:22 UTC
Ok, but could you please add a function to manually do this ?
It's really annoying, and nearly impossible by hand.

The hability to sort the contact list by account would do the stuff as we could then delete the group.
Comment 4 Francis Giannaros 2005-07-12 13:03:36 UTC
This should be changed to a "bug" rather than a wish, since it [can] seriously hinder functionality. For example, whenever I have friends around they want to log on some time, and so it brings in all their contacts. Consequently Kopete takes almost over a minute to fully start up now. There's also around a zillion offline contacts which I really wouldn't want to appear there.

I'd delete my contactlist.xml and just start fresh, but I've recently started giving aliases to my contacts, which I imagine would all be deleted if I removed that file. Would be pretty annoying to put those back in again.
Comment 5 Matt Rogers 2006-02-04 19:10:38 UTC
*** Bug 121317 has been marked as a duplicate of this bug. ***
Comment 6 liam24 2006-04-09 01:16:45 UTC
Would like to also see this implemented. Easy way to delete unused people and protocols.
Comment 7 Mathieu Jobin 2006-04-09 03:48:00 UTC
yeah, like your niece is visiting your home and she wants to connect to MSN one time. she use your kopete and bang you got all her contact list. of course you could have created her own unix account. but only for one time ?
Comment 8 David Laban 2006-04-14 17:27:39 UTC
I tried making a little hacky script to clean it up, using the rule of "if a metacontact doesn't contain anything to do with "<plugin-data" then it must belong to a deleted account"
http://people.pwf.cam.ac.uk/dl325/media/text/kopetexmlclean.py
I no longer have any empty contacts, but there's no noticeable improvement in start-up time. 
Even $ mv kopete_statistics-0.1.db kopete_statistics-0.1.db.`date %s` 
didn't make things much better. 

Does anyone have a nice tutorial on how to use a profiler with Kopete, or should I simply leave Kopete open constantly, so startup time doesn't pose such a problem?




Note: there's also a work-around (suggested in Bug 112429 ) which sounds like a neat little hack for *all* your temporary-KDE-sharing needs:
> ------- Additional Comment #1 From Olivier Goffart 2005-09-11 16:12 -------  
>try also 
> 
> mkdir ~/.kde_guest 
> export KDEHOME=~/.kde_guest 
> kopete --nofork 
> 
> That will run another kopete, with a new config saved in ~/.kde_guest instead >of ~/.kde 
> 
> Is that a decent solution ?
Comment 9 Daniel Franke 2006-05-23 21:17:53 UTC
Same here. After deleting the one-and-only icq account used with kopete, I expected an empty contacts list. Instead, it was still cluttered with all the contacts (but empty names). 

Suggestion: If an account is deleted, ask whether its contacts should be deleted as well. 
Comment 10 Matt Rogers 2006-06-17 19:29:33 UTC
SVN commit 552390 by mattr:

Fix bug 94057. Contacts and groups for the account are now deleted from the 
contact list when the account is removed.

BUG: 94057


 M  +33 -9     kopeteaccountmanager.cpp  


--- branches/kopete/0.12/kopete/libkopete/kopeteaccountmanager.cpp #552389:552390
@@ -31,9 +31,12 @@
 #include "kopeteaway.h"
 #include "kopeteprotocol.h"
 #include "kopetecontact.h"
+#include "kopetecontactlist.h"
 #include "kopetepluginmanager.h"
 #include "kopeteonlinestatus.h"
 #include "kopeteonlinestatusmanager.h"
+#include "kopetemetacontact.h"
+#include "kopetegroup.h"
 
 namespace Kopete {
 
@@ -48,7 +51,7 @@
 			{
 				uint priority1 = static_cast<Account*>(a)->priority();
 				uint priority2 = static_cast<Account*>(b)->priority();
-	
+
 				if( a==b ) //two account are equal only if they are equal :-)
 					return 0;  // remember than an account can be only once on the list, but two account may have the same priority when loading
 				else if( priority1 > priority2 )
@@ -114,7 +117,7 @@
 			if ( it.current()->isConnected() )
 				it.current()->setAway( false, awayReason );
 		}
-		else 
+		else
 			if(!it.current()->excludeConnect())
 				it.current()->connect();
 	}
@@ -153,7 +156,7 @@
 {
 	OnlineStatusManager::Categories katgor=(OnlineStatusManager::Categories)category;
 	bool anyConnected = isAnyAccountConnected();
-	
+
 	for ( QPtrListIterator<Account> it( d->accounts ); it.current(); ++it )
 	{
 		Account *account = it.current();
@@ -219,7 +222,7 @@
 {
 	if( !account || d->accounts.contains( account ) )
 		return account;
-		
+
 	if( account->accountId().isEmpty() )
 	{
 		account->deleteLater();
@@ -236,9 +239,9 @@
 		}
 	}
 
-	d->accounts.append( account );	
+	d->accounts.append( account );
 	d->accounts.sort();
-	
+
 	// Connect to the account's status changed signal
 	connect(account->myself(), SIGNAL(onlineStatusChanged(Kopete::Contact *,
 			const Kopete::OnlineStatus &, const Kopete::OnlineStatus &)),
@@ -295,6 +298,27 @@
 
 	KConfigGroup *configgroup = account->configGroup();
 
+	// Clean up the contact list
+	QDictIterator<Kopete::Contact> it( account->contacts() );
+	for ( ; it.current(); ++it )
+	{
+		Contact* c = it.current();
+		MetaContact* mc = c->metaContact();
+		if ( mc == ContactList::self()->myself() )
+			continue;
+		mc->removeContact( c );
+		c->deleteLater();
+		if ( mc->contacts().count() == 0 ) //we can delete the metacontact
+		{
+			//get the first group and it's members
+			Group* group = mc->groups().first();
+			QPtrList<MetaContact> groupMembers = group->members();
+			ContactList::self()->removeMetaContact( mc );
+			if ( groupMembers.count() == 1 && groupMembers.findRef( mc ) != -1 )
+				ContactList::self()->removeGroup( group );
+		}
+	}
+
 	// Clean up the account list
 	d->accounts.remove( account );
 
@@ -319,11 +343,11 @@
 {
 	//kdDebug( 14010 ) << k_funcinfo << endl;
 	d->accounts.sort();
-	
+
 	for ( QPtrListIterator<Account> it( d->accounts ); it.current(); ++it )
 	{
 		KConfigBase *config = it.current()->configGroup();
-	
+
 		config->writeEntry( "Protocol", it.current()->protocol()->pluginId() );
 		config->writeEntry( "AccountId", it.current()->accountId() );
 	}
@@ -386,7 +410,7 @@
 
 		kdDebug( 14010 ) << k_funcinfo <<
 			"Creating account for '" << accountId << "'" << endl;
-		
+
 		Account *account = 0L;
 		account = registerAccount( protocol->createNewAccount( accountId ) );
 		if ( !account )
Comment 11 Gael Beaudoin 2006-06-17 20:28:41 UTC
Great ! Thanks a lot :)