summaryrefslogtreecommitdiffabout
path: root/kabc
Side-by-side diff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp27
-rw-r--r--kabc/addressbook.h5
-rw-r--r--kabc/addressee.cpp54
-rw-r--r--kabc/addressee.h12
4 files changed, 96 insertions, 2 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 70eda1b..9332e21 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -13,64 +13,65 @@
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$
*/
/*US
#include <qfile.h>
#include <qregexp.h>
#include <qtimer.h>
#include <kapplication.h>
#include <kinstance.h>
#include <kstandarddirs.h>
#include "errorhandler.h"
*/
#include <qptrlist.h>
#include <kglobal.h>
#include <klocale.h>
#include <kdebug.h>
+#include <libkcal/syncdefines.h>
#include "addressbook.h"
#include "resource.h"
//US #include "addressbook.moc"
using namespace KABC;
struct AddressBook::AddressBookData
{
Addressee::List mAddressees;
Addressee::List mRemovedAddressees;
Field::List mAllFields;
KConfig *mConfig;
KRES::Manager<Resource> *mManager;
//US ErrorHandler *mErrorHandler;
};
struct AddressBook::Iterator::IteratorData
{
Addressee::List::Iterator mIt;
};
struct AddressBook::ConstIterator::ConstIteratorData
{
Addressee::List::ConstIterator mIt;
};
AddressBook::Iterator::Iterator()
{
d = new IteratorData;
}
@@ -483,64 +484,90 @@ void AddressBook::removeAddressee( const Addressee &a )
return;
}
}
}
void AddressBook::removeAddressee( const Iterator &it )
{
d->mRemovedAddressees.append( (*it) );
d->mAddressees.remove( it.d->mIt );
}
AddressBook::Iterator AddressBook::find( const Addressee &a )
{
Iterator it;
for ( it = begin(); it != end(); ++it ) {
if ( a.uid() == (*it).uid() ) {
return it;
}
}
return end();
}
Addressee AddressBook::findByUid( const QString &uid )
{
Iterator it;
for ( it = begin(); it != end(); ++it ) {
if ( uid == (*it).uid() ) {
return *it;
}
}
return Addressee();
}
+Addressee::List AddressBook::getExternLastSyncAddressees()
+{
+ Addressee::List results;
+
+ Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) {
+ if ( (*it).familyName().left(3) == "E: " )
+ results.append( *it );
+ }
+ }
+
+ return results;
+}
+void AddressBook::resetTempSyncStat()
+{
+
+
+ Iterator it;
+ for ( it = begin(); it != end(); ++it ) {
+ (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
+ }
+
+}
+
+
Addressee::List AddressBook::allAddressees()
{
return d->mAddressees;
}
Addressee::List AddressBook::findByName( const QString &name )
{
Addressee::List results;
Iterator it;
for ( it = begin(); it != end(); ++it ) {
if ( name == (*it).realName() ) {
results.append( *it );
}
}
return results;
}
Addressee::List AddressBook::findByEmail( const QString &email )
{
Addressee::List results;
QStringList mailList;
Iterator it;
for ( it = begin(); it != end(); ++it ) {
mailList = (*it).emails();
for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
if ( email == (*ite) ) {
results.append( *it );
}
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index e43de31..05225f9 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -259,64 +259,69 @@ class AddressBook : public QObject
/**
Add address book resource.
*/
bool addResource( Resource * );
/**
Remove address book resource.
*/
bool removeResource( Resource * );
/**
Return pointer list of all resources.
*/
QPtrList<Resource> resources();
/**
Set the @p ErrorHandler, that is used by @ref error() to
provide gui-independend error messages.
*/
void setErrorHandler( ErrorHandler * );
/**
Shows gui independend error messages.
*/
void error( const QString& );
/**
Query all resources to clean up their lock files
*/
void cleanUp();
+ // sync stuff
+ Addressee::List getExternLastSyncAddressees();
+ void resetTempSyncStat();
+
+
signals:
/**
Emitted, when the address book has changed on disk.
*/
void addressBookChanged( AddressBook * );
/**
Emitted, when the address book has been locked for writing.
*/
void addressBookLocked( AddressBook * );
/**
Emitted, when the address book has been unlocked.
*/
void addressBookUnlocked( AddressBook * );
protected:
void deleteRemovedAddressees();
void setStandardResource( Resource * );
Resource *standardResource();
KRES::Manager<Resource> *resourceManager();
void init(const QString &config, const QString &family);
private:
//US QPtrList<Resource> mDummy; // Remove in KDE 4
struct AddressBookData;
AddressBookData *d;
};
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 4cdd5e5..fb32f6e 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -3,131 +3,136 @@
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 );
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;
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;
Resource *resource;
bool empty :1;
bool changed :1;
};
Addressee::Addressee()
{
mData = new AddresseeData;
mData->empty = true;
mData->changed = false;
mData->resource = 0;
+ mData->mExternalId = ":";
+ mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
}
Addressee::~Addressee()
{
}
Addressee::Addressee( const Addressee &a )
{
mData = a.mData;
+ mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
}
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;
@@ -139,64 +144,111 @@ bool Addressee::operator==( const Addressee &a ) const
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;
}
+void Addressee::removeID(const QString &prof)
+{
+ detach();
+ mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
+
+}
+void Addressee::setID( const QString & prof , const QString & id )
+{
+ detach();
+ mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
+}
+void Addressee::setTempSyncStat( int id )
+{
+ mTempSyncStat = id;
+}
+int Addressee::tempSyncStat() const
+{
+ return mTempSyncStat;
+}
+
+QString Addressee::getID( const QString & prof)
+{
+ return KIdManager::getId ( mData->mExternalId, prof );
+}
+
+void Addressee::setCsum( const QString & prof , const QString & id )
+{
+ detach();
+ mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
+}
+
+QString Addressee::getCsum( const QString & prof)
+{
+ return KIdManager::getCsum ( mData->mExternalId, prof );
+}
+
+void Addressee::setIDStr( const QString & s )
+{
+ detach();
+ mData->mExternalId = s;
+}
+
+QString Addressee::IDStr() const
+{
+ return mData->mExternalId;
+}
+
void Addressee::setUid( const QString &id )
{
if ( id == mData->uid ) return;
detach();
mData->empty = false;
mData->uid = id;
}
QString Addressee::uid() const
{
if ( mData->uid.isEmpty() )
mData->uid = KApplication::randomString( 10 );
return mData->uid;
}
QString Addressee::uidLabel()
{
return i18n("Unique Identifier");
}
void Addressee::setName( const QString &name )
{
if ( name == mData->name ) return;
detach();
mData->empty = false;
mData->name = name;
}
QString Addressee::name() const
{
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 27782f9..f098371 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -67,65 +67,74 @@ class Resource;
givenName() is the first name and familyName() the last name. In some
countries the family name comes first, that's the reason for the
naming. formattedName() is the full name with the correct formatting.
It is used as an override, when the correct formatting can't be generated
from the other name fields automatically.
realName() returns a fully formatted name(). It uses formattedName, if set,
otherwise it constucts the name from the name fields. As fallback, if
nothing else is set it uses name().
name() is the NAME type of RFC2426. It can be used as internal name for the
data enty, but shouldn't be used for displaying the data to the user.
*/
class Addressee
{
friend QDataStream &operator<<( QDataStream &, const Addressee & );
friend QDataStream &operator>>( QDataStream &, Addressee & );
public:
typedef QValueList<Addressee> List;
/**
Construct an empty address book entry.
*/
Addressee();
~Addressee();
Addressee( const Addressee & );
Addressee &operator=( const Addressee & );
bool operator==( const Addressee & ) const;
bool operator!=( const Addressee & ) const;
-
+ // sync stuff
+ void setTempSyncStat(int id);
+ int tempSyncStat() const;
+ void setIDStr( const QString & );
+ QString IDStr() const;
+ void setID( const QString &, const QString & );
+ QString getID( const QString & );
+ void setCsum( const QString &, const QString & );
+ QString getCsum( const QString & );
+ void removeID(const QString &);
/**
Return, if the address book entry is empty.
*/
bool isEmpty() const;
/**
Set unique identifier.
*/
void setUid( const QString &uid );
/**
Return unique identifier.
*/
QString uid() const;
/**
Return translated label for uid field.
*/
static QString uidLabel();
/**
Set name.
*/
void setName( const QString &name );
/**
Return name.
*/
QString name() const;
/**
Return translated label for name field.
*/
static QString nameLabel();
/**
@@ -786,43 +795,44 @@ class 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;
private:
Addressee copy();
void detach();
+ int mTempSyncStat;
struct AddresseeData;
mutable KSharedPtr<AddresseeData> mData;
};
QDataStream &operator<<( QDataStream &, const Addressee & );
QDataStream &operator>>( QDataStream &, Addressee & );
}
#endif