summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
Side-by-side diff
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 70eda1b..9332e21 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,92 +1,93 @@
/*
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$
*/
/*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;
}
AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
{
d = new IteratorData;
d->mIt = i.d->mIt;
}
AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
{
if( this == &i ) return *this; // guard against self assignment
delete d; // delete the old data the Iterator was completely constructed before
d = new IteratorData;
d->mIt = i.d->mIt;
return *this;
}
AddressBook::Iterator::~Iterator()
@@ -467,96 +468,122 @@ void AddressBook::insertAddressee( const Addressee &a )
}
}
d->mAddressees.append( a );
Addressee& addr = d->mAddressees.last();
if ( addr.resource() == 0 )
addr.setResource( standardResource() );
addr.setChanged( true );
}
void AddressBook::removeAddressee( const Addressee &a )
{
Iterator it;
for ( it = begin(); it != end(); ++it ) {
if ( a.uid() == (*it).uid() ) {
removeAddressee( it );
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 );
}
}
}
return results;
}
Addressee::List AddressBook::findByCategory( const QString &category )
{
Addressee::List results;
Iterator it;
for ( it = begin(); it != end(); ++it ) {
if ( (*it).hasCategory( category) ) {
results.append( *it );
}
}