kitchensync

addressbooksyncee.h

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2002,2004 Cornelius Schumacher <schumacher@kde.org>
00005     Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 #ifndef KSYNC_ADDRESSBOOKSYNCEE_H
00023 #define KSYNC_ADDRESSBOOKSYNCEE_H
00024 
00025 #include "syncentry.h"
00026 #include "syncee.h"
00027 
00028 #include <kabc/addressbook.h>
00029 
00030 namespace KSync {
00031 
00032 class AddressBookMerger;
00033 class KDE_EXPORT AddressBookSyncEntry : public SyncEntry
00034 {
00035     friend class AddressBookMerger;
00036     friend class AddressBookSyncee;
00037   public:
00038     typedef QPtrList<AddressBookSyncEntry> PtrList;
00039 
00040     AddressBookSyncEntry( Syncee* parent );
00041     AddressBookSyncEntry( const KABC::Addressee &, Syncee *parent );
00042     AddressBookSyncEntry( const AddressBookSyncEntry & );
00043 
00044     QString name();
00045     QString id();
00046     void setId( const QString &id );
00047     QString timestamp();
00048     bool mergeWith( SyncEntry * );
00049 
00050     AddressBookSyncEntry *clone();
00051     bool equals( SyncEntry *entry );
00052 
00053     KABC::Addressee addressee() { return mAddressee; }
00054     QString resource() const;
00055     void setResource( const QString &str );
00056 
00057     KPIM::DiffAlgo* diffAlgo( SyncEntry*, SyncEntry* );
00058 
00059   private:
00060     void setAddressee( const KABC::Addressee& addr );
00061     KABC::Addressee mAddressee;
00062     QString m_res;
00063     struct Data;
00064     Data *data;
00065 };
00066 
00071 class KDE_EXPORT AddressBookSyncee : public Syncee
00072 {
00073   public:
00074 
00075     AddressBookSyncee( AddressBookMerger* m = 0);
00076     AddressBookSyncee( KABC::AddressBook *, AddressBookMerger* m = 0 );
00077     ~AddressBookSyncee();
00078 
00079     void reset();
00080 
00081     AddressBookSyncEntry *firstEntry();
00082     AddressBookSyncEntry *nextEntry();
00083 
00084 
00085     void addEntry( SyncEntry * );
00086     void removeEntry( SyncEntry * );
00087 
00088     QString type() const;
00089     QString generateNewId() const;
00090 
00091     bool writeBackup( const QString & ) { return false; }
00092     bool restoreBackup( const QString & ) { return false; }
00093 
00094   private:
00095     AddressBookSyncEntry *createEntry( const KABC::Addressee & );
00096     SyncEntry::PtrList find( int state );
00097 
00098     QPtrList<AddressBookSyncEntry> mEntries;
00099 
00100     KABC::AddressBook *mAddressBook;
00101     bool mOwnAddressBook : 1;
00102 };
00103 
00104 }
00105 
00106 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys