[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenetwork/kopete/libkopete
From: Will Stephenson <lists () stevello ! free-online ! co ! uk>
Date: 2004-07-31 19:47:42
Message-ID: 20040731194742.1850F99F5 () office ! kde ! org
[Download RAW message or body]
CVS commit by wstephens:
Merge our data with any existing data when writing a kabc field
Solves a couple of ancient FIXMEs and makes Kopete play nicely now that Konversation is joining the \
addressbook integration game.
M +26 -5 kopetemetacontact.cpp 1.221
--- kdenetwork/kopete/libkopete/kopetemetacontact.cpp #1.220:1.221
@@ -67,4 +67,19 @@ KABC::AddressBook* KopeteMetaContact::m_
bool KopeteMetaContactPrivate::s_addrBookWritePending = false;
+/**
+ * utility function to merge two QStrings containing individual elements separated by 0xE000
+ */
+QString unionContents( QString arg1, QString arg2 )
+{
+ QChar separator( 0xE000 );
+ QStringList outList = QStringList::split( separator, arg1 );
+ QStringList arg2List = QStringList::split( separator, arg2 );
+ for ( QStringList::iterator it = arg2List.begin(); it != arg2List.end(); ++it )
+ if ( !outList.contains( *it ) )
+ outList.append( *it );
+ QString out = outList.join( separator );
+ return out;
+}
+
KopeteMetaContact::KopeteMetaContact()
: KopetePluginDataObject( KopeteContactList::contactList() ), KopeteNotifyDataObject()
@@ -827,4 +842,7 @@ void KopeteMetaContact::setMetaContactId
// 5) Is called when reading the saved contact list
+ // only remove kabc data if we are changing contacts; other programs may have written that data,
+ // and kopete will not pick up on it if no other MC is associated with the data left behind
+ if ( !newMetaContactId.isNull() )
removeKABC();
d->metaContactId = newMetaContactId;
@@ -853,5 +871,4 @@ void KopeteMetaContact::updateKABC()
// (inherited from Kopete < 0.8, where all metacontacts had random ids)
- // FIXME: this no longer gets called when reading all contacts but we need something \
similar to update from 0.7 if ( theAddressee.isEmpty() )
{
@@ -869,8 +886,12 @@ void KopeteMetaContact::updateKABC()
for( ; addrIt != appIt.data().end(); ++addrIt )
{
- // FIXME: This assumes Kopete is the only app writing these \
fields + // read existing data for this key
+ QString currentCustom = theAddressee.custom( appIt.key(), \
addrIt.key() ); + // merge without duplicating
+ QString toWrite = unionContents( currentCustom, addrIt.data() );
+ // write the result
// Note if nothing ends up in the KABC data, this is because \
insertCustom does nothing if any param is empty.
- kdDebug( 14010 ) << k_funcinfo << "Writing: " << appIt.key() << \
", " << addrIt.key() << ", " << addrIt.data() << endl;
- theAddressee.insertCustom( appIt.key(), addrIt.key(), \
addrIt.data() ); + kdDebug( 14010 ) << k_funcinfo << "Writing: " \
<< appIt.key() << ", " << addrIt.key() << ", " << toWrite << endl; + \
theAddressee.insertCustom( appIt.key(), addrIt.key(), toWrite ); }
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic