summaryrefslogtreecommitdiffabout
path: root/kabc
Side-by-side diff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp44
-rw-r--r--kabc/addressbook.h3
2 files changed, 47 insertions, 0 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 16927e2..d037d2f 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -44,12 +44,13 @@ $Id$
#include <kglobal.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kdebug.h>
#include <libkcal/syncdefines.h>
+#include <libkdepim/phoneaccess.h>
#include "addressbook.h"
#include "resource.h"
#include "vcardconverter.h"
#include "vcardparser/vcardtool.h"
//US #include "addressbook.moc"
@@ -456,12 +457,55 @@ void AddressBook::removeUntagged()
todelete = false;
}
if ( todelete )
removeAddressee( todel );
deleteRemovedAddressees();
}
+void AddressBook::smplifyAddressees()
+{
+ Iterator ait;
+ for ( ait = begin(); ait != end(); ++ait ) {
+ (*ait).simplifyEmails();
+ (*ait).simplifyPhoneNumbers();
+ (*ait).simplifyPhoneNumberTypes();
+ (*ait).simplifyAddresses();
+ }
+}
+void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync )
+{
+ Iterator ait;
+ for ( ait = begin(); ait != end(); ++ait ) {
+ QString id = (*ait).IDStr();
+ (*ait).setIDStr( ":");
+ (*ait).setExternalUID( id );
+ (*ait).setOriginalExternalUID( id );
+ if ( isPreSync )
+ (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
+ else
+ (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
+ }
+}
+bool AddressBook::saveABphone( QString fileName )
+{
+ smplifyAddressees();
+ qDebug("saveABphone:: saving AB... ");
+ if ( ! saveAB() )
+ return false;
+ qDebug("saveABphone:: writing to phone... ");
+ if ( !PhoneAccess::writeToPhone( fileName) ) {
+ return false;
+ }
+ qDebug("saveABphone:: re-reading from phone... ");
+ if ( !PhoneAccess::readFromPhone( fileName) ) {
+ return false;
+ }
+ qDebug("reloading phone book... ");
+ if ( !load() )
+ return false;
+ return true;
+}
bool AddressBook::saveAB()
{
bool ok = true;
deleteRemovedAddressees();
Iterator ait;
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 532e05d..cc755d1 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -139,12 +139,15 @@ class AddressBook : public QObject
object has been requested for by @ref requestSaveTicket().
@param ticket a ticket object returned by @ref requestSaveTicket()
*/
bool save( Ticket *ticket );
bool saveAB( );
+ bool saveABphone( QString fileName );
+ void smplifyAddressees();
+ void preparePhoneSync( QString currentSyncDevice, bool isPreSync );
void export2File( QString fileName );
void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
void setUntagged();
void removeUntagged();
/**
Returns a iterator for first entry of address book.