summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-09 16:58:08 (UTC)
committer zautrix <zautrix>2004-10-09 16:58:08 (UTC)
commit59ed933d6c43ecb0ddd3dec53cc289ee8aa68482 (patch) (side-by-side diff)
tree8b1cbcf9c420e7dffd1e1293bcfa69e8e821f3fa
parentb80a099d9432bdc3d4eea778b1813b82b2680ecf (diff)
downloadkdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.zip
kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.tar.gz
kdepimpi-59ed933d6c43ecb0ddd3dec53cc289ee8aa68482.tar.bz2
fixed sync bug
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp72
-rw-r--r--kabc/addressbook.h4
-rw-r--r--kabc/addressee.cpp12
-rw-r--r--kabc/addressee.h5
-rw-r--r--kaddressbook/kabcore.cpp2
5 files changed, 66 insertions, 29 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 1050f55..ff05f7e 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -310,220 +310,240 @@ void AddressBook::init(const QString &config, const QString &family )
"X-ManagersName", "KADDRESSBOOK" );
addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
"X-SpousesName", "KADDRESSBOOK" );
addCustomField( i18n( "Office" ), KABC::Field::Personal,
"X-Office", "KADDRESSBOOK" );
addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
"X-IMAddress", "KADDRESSBOOK" );
addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
"X-Anniversary", "KADDRESSBOOK" );
//US added this field to become compatible with Opie/qtopia addressbook
// values can be "female" or "male" or "". An empty field represents undefined.
addCustomField( i18n( "Gender" ), KABC::Field::Personal,
"X-Gender", "KADDRESSBOOK" );
addCustomField( i18n( "Children" ), KABC::Field::Personal,
"X-Children", "KADDRESSBOOK" );
addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
"X-FreeBusyUrl", "KADDRESSBOOK" );
addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
"X-ExternalID", "KADDRESSBOOK" );
}
AddressBook::~AddressBook()
{
delete d->mConfig; d->mConfig = 0;
delete d->mManager; d->mManager = 0;
//US delete d->mErrorHandler; d->mErrorHandler = 0;
delete d; d = 0;
}
bool AddressBook::load()
{
clear();
KRES::Manager<Resource>::ActiveIterator it;
bool ok = true;
for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
if ( !(*it)->load() ) {
error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
ok = false;
}
// mark all addressees as unchanged
Addressee::List::Iterator addrIt;
for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
(*addrIt).setChanged( false );
QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
if ( !id.isEmpty() ) {
//qDebug("setId aa %s ", id.latin1());
(*addrIt).setIDStr(id );
}
}
blockLSEchange = true;
return ok;
}
bool AddressBook::save( Ticket *ticket )
{
kdDebug(5700) << "AddressBook::save()"<< endl;
if ( ticket->resource() ) {
deleteRemovedAddressees();
return ticket->resource()->save( ticket );
}
return false;
}
void AddressBook::export2File( QString fileName )
{
QFile outFile( fileName );
if ( !outFile.open( IO_WriteOnly ) ) {
QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
KMessageBox::error( 0, text.arg( fileName ) );
return ;
}
QTextStream t( &outFile );
t.setEncoding( QTextStream::UnicodeUTF8 );
Iterator it;
KABC::VCardConverter::Version version;
version = KABC::VCardConverter::v3_0;
for ( it = begin(); it != end(); ++it ) {
if ( !(*it).IDStr().isEmpty() ) {
(*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
}
KABC::VCardConverter converter;
QString vcard;
//Resource *resource() const;
converter.addresseeToVCard( *it, vcard, version );
t << vcard << "\r\n";
}
t << "\r\n\r\n";
outFile.close();
}
-void AddressBook::importFromFile( QString fileName, bool replaceLabel )
-{
-
- KABC::Addressee::List list;
- QFile file( fileName );
-
- file.open( IO_ReadOnly );
- QByteArray rawData = file.readAll();
- file.close();
- QString data;
- if ( replaceLabel ) {
- data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
- data.replace ( QRegExp("LABEL") , "ADR" );
- data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
- } else
- data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
- KABC::VCardTool tool;
- list = tool.parseVCards( data );
- KABC::Addressee::List::Iterator it;
- for ( it = list.begin(); it != list.end(); ++it ) {
- (*it).setResource( 0 );
- if ( replaceLabel )
- (*it).removeVoice();
- insertAddressee( (*it), false, true );
+void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld )
+{
+
+ if ( removeOld )
+ setUntagged();
+ KABC::Addressee::List list;
+ QFile file( fileName );
+ file.open( IO_ReadOnly );
+ QByteArray rawData = file.readAll();
+ file.close();
+ QString data;
+ if ( replaceLabel ) {
+ data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
+ data.replace ( QRegExp("LABEL") , "ADR" );
+ data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
+ } else
+ data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
+ KABC::VCardTool tool;
+ list = tool.parseVCards( data );
+ KABC::Addressee::List::Iterator it;
+ for ( it = list.begin(); it != list.end(); ++it ) {
+ (*it).setResource( 0 );
+ if ( replaceLabel )
+ (*it).removeVoice();
+ if ( removeOld )
+ (*it).setTagged( true );
+ insertAddressee( (*it), false, true );
+ }
+ if ( removeOld )
+ removeUntagged();
+}
+void AddressBook::setUntagged()
+{
+ Iterator ait;
+ for ( ait = begin(); ait != end(); ++ait ) {
+ (*ait).setTagged( false );
+ }
+}
+void AddressBook::removeUntagged()
+{
+ Iterator ait;
+ for ( ait = begin(); ait != end(); ++ait ) {
+ if (!(*ait).tagged())
+ removeAddressee( ait );
}
-
+
+ deleteRemovedAddressees();
}
-
bool AddressBook::saveAB()
{
bool ok = true;
deleteRemovedAddressees();
Iterator ait;
for ( ait = begin(); ait != end(); ++ait ) {
if ( !(*ait).IDStr().isEmpty() ) {
(*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
}
}
KRES::Manager<Resource>::ActiveIterator it;
KRES::Manager<Resource> *manager = d->mManager;
for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
if ( !(*it)->readOnly() && (*it)->isOpen() ) {
Ticket *ticket = requestSaveTicket( *it );
// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
if ( !ticket ) {
error( i18n( "Unable to save to resource '%1'. It is locked." )
.arg( (*it)->resourceName() ) );
return false;
}
//if ( !save( ticket ) )
if ( ticket->resource() ) {
if ( ! ticket->resource()->save( ticket ) )
ok = false;
} else
ok = false;
}
}
return ok;
}
AddressBook::Iterator AddressBook::begin()
{
Iterator it = Iterator();
it.d->mIt = d->mAddressees.begin();
return it;
}
AddressBook::ConstIterator AddressBook::begin() const
{
ConstIterator it = ConstIterator();
it.d->mIt = d->mAddressees.begin();
return it;
}
AddressBook::Iterator AddressBook::end()
{
Iterator it = Iterator();
it.d->mIt = d->mAddressees.end();
return it;
}
AddressBook::ConstIterator AddressBook::end() const
{
ConstIterator it = ConstIterator();
it.d->mIt = d->mAddressees.end();
return it;
}
void AddressBook::clear()
{
d->mAddressees.clear();
}
Ticket *AddressBook::requestSaveTicket( Resource *resource )
{
kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
if ( !resource )
{
qDebug("AddressBook::requestSaveTicket no resource" );
resource = standardResource();
}
KRES::Manager<Resource>::ActiveIterator it;
for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
if ( (*it) == resource ) {
if ( (*it)->readOnly() || !(*it)->isOpen() )
return 0;
else
return (*it)->requestSaveTicket();
}
}
return 0;
}
void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
{
if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
//qDebug("block insert ");
return;
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index cea1b03..532e05d 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -50,193 +50,195 @@ class Ticket;
class AddressBook : public QObject
{
Q_OBJECT
friend QDataStream &operator<<( QDataStream &, const AddressBook & );
friend QDataStream &operator>>( QDataStream &, AddressBook & );
friend class StdAddressBook;
public:
/**
@short Address Book Iterator
This class provides an iterator for address book entries.
*/
class Iterator
{
public:
Iterator();
Iterator( const Iterator & );
~Iterator();
Iterator &operator=( const Iterator & );
const Addressee &operator*() const;
Addressee &operator*();
Addressee* operator->();
Iterator &operator++();
Iterator &operator++(int);
Iterator &operator--();
Iterator &operator--(int);
bool operator==( const Iterator &it );
bool operator!=( const Iterator &it );
struct IteratorData;
IteratorData *d;
};
/**
@short Address Book Const Iterator
This class provides a const iterator for address book entries.
*/
class ConstIterator
{
public:
ConstIterator();
ConstIterator( const ConstIterator & );
~ConstIterator();
ConstIterator &operator=( const ConstIterator & );
const Addressee &operator*() const;
const Addressee* operator->() const;
ConstIterator &operator++();
ConstIterator &operator++(int);
ConstIterator &operator--();
ConstIterator &operator--(int);
bool operator==( const ConstIterator &it );
bool operator!=( const ConstIterator &it );
struct ConstIteratorData;
ConstIteratorData *d;
};
/**
Constructs a address book object.
@param format File format class.
*/
AddressBook();
AddressBook( const QString &config );
AddressBook( const QString &config, const QString &family );
virtual ~AddressBook();
/**
Requests a ticket for saving the addressbook. Calling this function locks
the addressbook for all other processes. If the address book is already
locked the function returns 0. You need the returned @ref Ticket object
for calling the @ref save() function.
@see save()
*/
Ticket *requestSaveTicket( Resource *resource=0 );
/**
Load address book from file.
*/
bool load();
/**
Save address book. The address book is saved to the file, the Ticket
object has been requested for by @ref requestSaveTicket().
@param ticket a ticket object returned by @ref requestSaveTicket()
*/
bool save( Ticket *ticket );
bool saveAB( );
void export2File( QString fileName );
- void importFromFile( QString fileName, bool replaceLabel = false );
+ void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
+ void setUntagged();
+ void removeUntagged();
/**
Returns a iterator for first entry of address book.
*/
Iterator begin();
/**
Returns a const iterator for first entry of address book.
*/
ConstIterator begin() const;
/**
Returns a iterator for first entry of address book.
*/
Iterator end();
/**
Returns a const iterator for first entry of address book.
*/
ConstIterator end() const;
/**
Removes all entries from address book.
*/
void clear();
/**
Insert an Addressee object into address book. If an object with the same
unique id already exists in the address book it it replaced by the new
one. If not the new object is appended to the address book.
*/
void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
/**
Removes entry from the address book.
*/
void removeAddressee( const Addressee & );
/**
This is like @ref removeAddressee() just above, with the difference that
the first element is a iterator, returned by @ref begin().
*/
void removeAddressee( const Iterator & );
/**
Find the specified entry in address book. Returns end(), if the entry
couldn't be found.
*/
Iterator find( const Addressee & );
/**
Find the entry specified by an unique id. Returns an empty Addressee
object, if the address book does not contain an entry with this id.
*/
Addressee findByUid( const QString & );
/**
Returns a list of all addressees in the address book. This list can
be sorted with @ref KABC::AddresseeList for example.
*/
Addressee::List allAddressees();
/**
Find all entries with the specified name in the address book. Returns
an empty list, if no entries could be found.
*/
Addressee::List findByName( const QString & );
/**
Find all entries with the specified email address in the address book.
Returns an empty list, if no entries could be found.
*/
Addressee::List findByEmail( const QString & );
/**
Find all entries wich have the specified category in the address book.
Returns an empty list, if no entries could be found.
*/
Addressee::List findByCategory( const QString & );
/**
Return a string identifying this addressbook.
*/
virtual QString identifier();
/**
Used for debug output.
*/
void dump() const;
void emitAddressBookLocked() { emit addressBookLocked( this ); }
void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
void emitAddressBookChanged() { emit addressBookChanged( this ); }
/**
Return list of all Fields known to the address book which are associated
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3f3d5c0..607ae26 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,186 +1,187 @@
/*** Warning! This file has been generated by the script makeaddressee ***/
/*
This file is part of libkabc.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <kconfig.h>
#include <ksharedptr.h>
#include <kdebug.h>
#include <kapplication.h>
#include <klocale.h>
#include <kidmanager.h>
//US
#include <kstandarddirs.h>
#include <libkcal/syncdefines.h>
//US #include "resource.h"
#include "addressee.h"
using namespace KABC;
static bool matchBinaryPattern( int value, int pattern );
static bool matchBinaryPatternA( int value, int pattern );
static bool matchBinaryPatternP( int value, int pattern );
struct Addressee::AddresseeData : public KShared
{
QString uid;
QString name;
QString formattedName;
QString familyName;
QString givenName;
QString additionalName;
QString prefix;
QString suffix;
QString nickName;
QDateTime birthday;
QString mailer;
TimeZone timeZone;
Geo geo;
QString title;
QString role;
QString organization;
QString note;
QString productId;
QDateTime revision;
QString sortString;
QString externalUID;
QString originalExternalUID;
KURL url;
Secrecy secrecy;
Picture logo;
Picture photo;
Sound sound;
Agent agent;
QString mExternalId;
PhoneNumber::List phoneNumbers;
Address::List addresses;
Key::List keys;
QStringList emails;
QStringList categories;
QStringList custom;
int mTempSyncStat;
Resource *resource;
bool empty :1;
bool changed :1;
+ bool tagged :1;
};
Addressee::Addressee()
{
mData = new AddresseeData;
mData->empty = true;
mData->changed = false;
mData->resource = 0;
mData->mExternalId = ":";
mData->revision = QDateTime ( QDate( 2003,1,1));
mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
}
Addressee::~Addressee()
{
}
Addressee::Addressee( const Addressee &a )
{
mData = a.mData;
}
Addressee &Addressee::operator=( const Addressee &a )
{
mData = a.mData;
return (*this);
}
Addressee Addressee::copy()
{
Addressee a;
*(a.mData) = *mData;
return a;
}
void Addressee::detach()
{
if ( mData.count() == 1 ) return;
*this = copy();
}
bool Addressee::operator==( const Addressee &a ) const
{
if ( uid() != a.uid() ) return false;
if ( mData->name != a.mData->name ) return false;
if ( mData->formattedName != a.mData->formattedName ) return false;
if ( mData->familyName != a.mData->familyName ) return false;
if ( mData->givenName != a.mData->givenName ) return false;
if ( mData->additionalName != a.mData->additionalName ) return false;
if ( mData->prefix != a.mData->prefix ) return false;
if ( mData->suffix != a.mData->suffix ) return false;
if ( mData->nickName != a.mData->nickName ) return false;
if ( mData->birthday != a.mData->birthday ) return false;
if ( mData->mailer != a.mData->mailer ) return false;
if ( mData->timeZone != a.mData->timeZone ) return false;
if ( mData->geo != a.mData->geo ) return false;
if ( mData->title != a.mData->title ) return false;
if ( mData->role != a.mData->role ) return false;
if ( mData->organization != a.mData->organization ) return false;
if ( mData->note != a.mData->note ) return false;
if ( mData->productId != a.mData->productId ) return false;
//if ( mData->revision != a.mData->revision ) return false;
if ( mData->sortString != a.mData->sortString ) return false;
if ( mData->secrecy != a.mData->secrecy ) return false;
if ( mData->logo != a.mData->logo ) return false;
if ( mData->photo != a.mData->photo ) return false;
if ( mData->sound != a.mData->sound ) return false;
if ( mData->agent != a.mData->agent ) return false;
if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
( mData->url != a.mData->url ) ) return false;
if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
if ( mData->addresses != a.mData->addresses ) return false;
if ( mData->keys != a.mData->keys ) return false;
if ( mData->emails != a.mData->emails ) return false;
if ( mData->categories != a.mData->categories ) return false;
if ( mData->custom != a.mData->custom ) return false;
return true;
}
bool Addressee::operator!=( const Addressee &a ) const
{
return !( a == *this );
}
bool Addressee::isEmpty() const
{
return mData->empty;
}
ulong Addressee::getCsum4List( const QStringList & attList)
{
int max = attList.count();
ulong cSum = 0;
int j,k,i;
int add;
for ( i = 0; i < max ; ++i ) {
@@ -1728,192 +1729,203 @@ QString Addressee::custom( const QString &app, const QString &name ) const
void Addressee::setCustoms( const QStringList &l )
{
detach();
mData->empty = false;
mData->custom = l;
}
QStringList Addressee::customs() const
{
return mData->custom;
}
void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
QString &email)
{
int startPos, endPos, len;
QString partA, partB, result;
char endCh = '>';
startPos = rawEmail.find('<');
if (startPos < 0)
{
startPos = rawEmail.find('(');
endCh = ')';
}
if (startPos < 0)
{
// We couldn't find any separators, so we assume the whole string
// is the email address
email = rawEmail;
fullName = "";
}
else
{
// We have a start position, try to find an end
endPos = rawEmail.find(endCh, startPos+1);
if (endPos < 0)
{
// We couldn't find the end of the email address. We can only
// assume the entire string is the email address.
email = rawEmail;
fullName = "";
}
else
{
// We have a start and end to the email address
// Grab the name part
fullName = rawEmail.left(startPos).stripWhiteSpace();
// grab the email part
email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
// Check that we do not have any extra characters on the end of the
// strings
len = fullName.length();
if (fullName[0]=='"' && fullName[len-1]=='"')
fullName = fullName.mid(1, len-2);
else if (fullName[0]=='<' && fullName[len-1]=='>')
fullName = fullName.mid(1, len-2);
else if (fullName[0]=='(' && fullName[len-1]==')')
fullName = fullName.mid(1, len-2);
}
}
}
void Addressee::setResource( Resource *resource )
{
detach();
mData->resource = resource;
}
Resource *Addressee::resource() const
{
return mData->resource;
}
//US
QString Addressee::resourceLabel()
{
return i18n("Resource");
}
void Addressee::setChanged( bool value )
{
detach();
mData->changed = value;
}
bool Addressee::changed() const
{
return mData->changed;
}
+void Addressee::setTagged( bool value )
+{
+ detach();
+ mData->tagged = value;
+}
+
+bool Addressee::tagged() const
+{
+ return mData->tagged;
+}
+
QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
{
if (!a.mData) return s;
s << a.uid();
s << a.mData->name;
s << a.mData->formattedName;
s << a.mData->familyName;
s << a.mData->givenName;
s << a.mData->additionalName;
s << a.mData->prefix;
s << a.mData->suffix;
s << a.mData->nickName;
s << a.mData->birthday;
s << a.mData->mailer;
s << a.mData->timeZone;
s << a.mData->geo;
s << a.mData->title;
s << a.mData->role;
s << a.mData->organization;
s << a.mData->note;
s << a.mData->productId;
s << a.mData->revision;
s << a.mData->sortString;
s << a.mData->url;
s << a.mData->secrecy;
s << a.mData->logo;
s << a.mData->photo;
s << a.mData->sound;
s << a.mData->agent;
s << a.mData->phoneNumbers;
s << a.mData->addresses;
s << a.mData->emails;
s << a.mData->categories;
s << a.mData->custom;
s << a.mData->keys;
return s;
}
QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
{
if (!a.mData) return s;
s >> a.mData->uid;
s >> a.mData->name;
s >> a.mData->formattedName;
s >> a.mData->familyName;
s >> a.mData->givenName;
s >> a.mData->additionalName;
s >> a.mData->prefix;
s >> a.mData->suffix;
s >> a.mData->nickName;
s >> a.mData->birthday;
s >> a.mData->mailer;
s >> a.mData->timeZone;
s >> a.mData->geo;
s >> a.mData->title;
s >> a.mData->role;
s >> a.mData->organization;
s >> a.mData->note;
s >> a.mData->productId;
s >> a.mData->revision;
s >> a.mData->sortString;
s >> a.mData->url;
s >> a.mData->secrecy;
s >> a.mData->logo;
s >> a.mData->photo;
s >> a.mData->sound;
s >> a.mData->agent;
s >> a.mData->phoneNumbers;
s >> a.mData->addresses;
s >> a.mData->emails;
s >> a.mData->categories;
s >> a.mData->custom;
s >> a.mData->keys;
a.mData->empty = false;
return s;
}
bool matchBinaryPattern( int value, int pattern )
{
/**
We want to match all telephonnumbers/addresses which have the bits in the
pattern set. More are allowed.
if pattern == 0 we have a special handling, then we want only those with
exactly no bit set.
*/
if ( pattern == 0 )
return ( value == 0 );
else
return ( pattern == ( pattern & value ) );
}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 9336edc..0aa2c51 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -738,112 +738,115 @@ class Addressee
*/
Address findAddress( const QString &id ) const;
/**
Insert category. If the category already exists it is not duplicated.
*/
void insertCategory( const QString & );
/**
Remove category.
*/
void removeCategory( const QString & );
/**
Return, if addressee has the given category.
*/
bool hasCategory( const QString & ) const;
/**
Set categories to given value.
*/
void setCategories( const QStringList & );
/**
Return list of all set categories.
*/
QStringList categories() const;
/**
Insert custom entry. The entry is identified by the name of the inserting
application and a unique name. If an entry with the given app and name
already exists its value is replaced with the new given value.
*/
void insertCustom( const QString &app, const QString &name,
const QString &value );
/**
Remove custom entry.
*/
void removeCustom( const QString &app, const QString &name );
/**
Return value of custom entry, identified by app and entry name.
*/
QString custom( const QString &app, const QString &name ) const;
/**
Set all custom entries.
*/
void setCustoms( const QStringList & );
/**
Return list of all custom entries.
*/
QStringList customs() const;
/**
Parse full email address. The result is given back in fullName and email.
*/
static void parseEmailAddress( const QString &rawEmail, QString &fullName,
QString &email );
/**
Debug output.
*/
void dump() const;
/**
Returns string representation of the addressee.
*/
QString asString() const;
/**
Set resource where the addressee is from.
*/
void setResource( Resource *resource );
/**
Return pointer to resource.
*/
Resource *resource() const;
/**
Return resourcelabel.
*/
//US
static QString resourceLabel();
/**
Mark addressee as changed.
*/
void setChanged( bool value );
/**
Return whether the addressee is changed.
*/
- bool changed() const;
+ bool changed() const;
+
+ void setTagged( bool value );
+ bool tagged() const;
private:
Addressee copy();
void detach();
struct AddresseeData;
mutable KSharedPtr<AddresseeData> mData;
};
QDataStream &operator<<( QDataStream &, const Addressee & );
QDataStream &operator>>( QDataStream &, Addressee & );
}
#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 7ec3fca..452f1bc 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2783,117 +2783,117 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
found = true;
break;
}
}
external = ! found;
}
if ( external ) {
qDebug("Setting vcf mode to external ");
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
AddressBook::Iterator it;
for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
(*it).setID( mCurrentSyncDevice, (*it).uid() );
(*it).computeCsum( mCurrentSyncDevice );
}
}
}
//AddressBook::Iterator it;
//QStringList vcards;
//for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
// qDebug("Name %s ", (*it).familyName().latin1());
//}
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
if ( syncOK ) {
if ( syncManager->mWriteBackFile )
{
if ( external )
abLocal.removeSyncAddressees( !isXML);
qDebug("Saving remote AB ");
if ( ! abLocal.saveAB())
qDebug("Error writing back AB to file ");
if ( isXML ) {
// afterwrite processing
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
}
}
}
setModified();
}
if ( syncOK )
mViewManager->refreshView();
return syncOK;
#if 0
if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
getEventViewerDialog()->setSyncMode( true );
syncOK = synchronizeCalendar( mCalendar, calendar, mode );
getEventViewerDialog()->setSyncMode( false );
if ( syncOK ) {
if ( KOPrefs::instance()->mWriteBackFile )
{
storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
storage->save();
}
}
setModified();
}
#endif
}
//this is a overwritten callbackmethods from the syncinterface
bool KABCore::syncExternal(KSyncManager* manager, QString resource)
{
QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
AddressBook abLocal( resource,"syncContact");
bool syncOK = false;
if ( abLocal.load() ) {
qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
if ( syncOK ) {
if ( syncManager->mWriteBackFile ) {
abLocal.saveAB();
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
}
}
setModified();
}
if ( syncOK )
mViewManager->refreshView();
return syncOK;
}
void KABCore::getFile( bool success )
{
QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
if ( ! success ) {
setCaption( i18n("Error receiving file. Nothing changed!") );
return;
}
- mAddressBook->importFromFile( sentSyncFile() );
+ mAddressBook->importFromFile( sentSyncFile() , false, true );
topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
mViewManager->refreshView();
}
void KABCore::syncFileRequest()
{
mAddressBook->export2File( sentSyncFile() );
}
QString KABCore::sentSyncFile()
{
#ifdef _WIN32_
return locateLocal( "tmp", "copysyncab.vcf" );
#else
return QString( "/tmp/copysyncab.vcf" );
#endif
}
void KABCore::setCaptionBack()
{
topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
}