summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Side-by-side diff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp86
1 files changed, 17 insertions, 69 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index a7967cb..cd261f6 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -187,4 +187,4 @@ class KAex2phonePrefs : public QDialog
lay->addWidget( temphb );
- mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
- lay->addWidget( mWriteToSim );
+ // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
+ // lay->addWidget( mWriteToSim );
lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
@@ -696,70 +696,15 @@ void KABCore::export2phone()
#ifdef _WIN32_
- QString fileName = locateLocal("tmp", "tempfile.vcf");
+ QString fileName = locateLocal("tmp", "phonefile.vcf");
#else
- QString fileName = "/tmp/kdepimtemp.vcf";
+ QString fileName = "/tmp/phonefile.vcf";
#endif
- KABC::VCardConverter converter;
- QString description;
- QString datastream;
- for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
- KABC::Addressee a = mAddressBook->findByUid( *it );
-
- if ( a.isEmpty() )
- continue;
- a.simplifyEmails();
- a.simplifyPhoneNumbers();
- a.simplifyPhoneNumberTypes();
- a.simplifyAddresses();
-
- if (description.isEmpty())
- description = a.formattedName();
- QString vcard;
- QString vcardnew;
- converter.addresseeToVCard( a, vcard );
- int start = 0;
- int next;
- while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
- int semi = vcard.find(";", next);
- int dopp = vcard.find(":", next);
- int sep;
- if ( semi < dopp && semi >= 0 )
- sep = semi ;
- else
- sep = dopp;
- vcardnew +=vcard.mid( start, next - start);
- vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
- start = sep;
- }
- vcardnew += vcard.mid( start,vcard.length() );
- vcard = "";
- start = 0;
- while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
- int sep = vcardnew.find(":", next);
- vcard +=vcardnew.mid( start, next - start+3);
- start = sep;
- }
- vcard += vcardnew.mid( start,vcardnew.length() );
- vcard.replace ( QRegExp(";;;") , "" );
- vcard.replace ( QRegExp(";;") , "" );
- datastream += vcard;
-
- }
- QFile outFile(fileName);
- if ( outFile.open(IO_WriteOnly) ) {
- datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
- QTextStream t( &outFile ); // use a text stream
- t.setEncoding( QTextStream::UnicodeUTF8 );
- t <<datastream;
- outFile.close();
- if ( PhoneAccess::writeToPhone( fileName ) )
- qDebug("Export okay ");
- else
- qDebug("Error export contacts ");
-
- } else {
- qDebug("Error open temp file ");
+ if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
return;
- }
-
+
+ if ( PhoneAccess::writeToPhone( fileName ) )
+ qDebug("Export okay ");
+ else
+ qDebug("Error export contacts ");
+
@@ -2845,2 +2790,3 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
if ( syncManager->mWriteBackFile ) {
+ abLocal.removeSyncAddressees( false );
abLocal.saveAB();
@@ -2877,3 +2823,4 @@ bool KABCore::syncPhone()
bool syncOK = false;
- if ( abLocal.load() ) {
+ {
+ abLocal.importFromFile( fileName );
qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
@@ -2885,5 +2832,6 @@ bool KABCore::syncPhone()
if ( syncManager->mWriteBackFile ) {
+ abLocal.removeSyncAddressees( true );
abLocal.saveABphone( fileName );
- abLocal.preparePhoneSync( mCurrentSyncDevice, false );
- abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
+ abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
+ //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );