summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp35
-rw-r--r--kabc/addressbook.h30
-rw-r--r--kabc/kabc.pro4
-rw-r--r--kabc/kabcE.pro7
-rw-r--r--kabc/resource.cpp63
-rw-r--r--kabc/resource.h66
6 files changed, 161 insertions, 44 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 0838157..20310a0 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -218,3 +218,3 @@ AddressBook::AddressBook()
{
- init(0);
+ init(0, "contact");
}
@@ -223,6 +223,13 @@ AddressBook::AddressBook( const QString &config )
{
- init(config);
+ init(config, "contact");
}
-void AddressBook::init(const QString &config)
+AddressBook::AddressBook( const QString &config, const QString &family )
+{
+ init(config, family);
+
+}
+
+// the default family is "contact"
+void AddressBook::init(const QString &config, const QString &family )
{
@@ -237,5 +244,5 @@ void AddressBook::init(const QString &config)
}
-
+
//US d->mErrorHandler = 0;
- d->mManager = new KRES::Manager<Resource>( "contact" );
+ d->mManager = new KRES::Manager<Resource>( family, false );
d->mManager->readConfig( d->mConfig );
@@ -253,3 +260,3 @@ bool AddressBook::load()
{
-
+
@@ -279,3 +286,3 @@ bool AddressBook::save( Ticket *ticket )
deleteRemovedAddressees();
-
+
return ticket->resource()->save( ticket );
@@ -358,3 +365,3 @@ void AddressBook::insertAddressee( const Addressee &a )
(*it).setRevision( QDateTime::currentDateTime() );
- (*it).setChanged( true );
+ (*it).setChanged( true );
}
@@ -437,3 +444,3 @@ Addressee::List AddressBook::findByEmail( const QString &email )
for ( it = begin(); it != end(); ++it ) {
- mailList = (*it).emails();
+ mailList = (*it).emails();
for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
@@ -493,5 +500,5 @@ Field::List AddressBook::fields( int category )
}
-
+
if ( category == Field::All ) return d->mAllFields;
-
+
Field::List result;
@@ -501,3 +508,3 @@ Field::List AddressBook::fields( int category )
}
-
+
return result;
@@ -543,4 +550,2 @@ bool AddressBook::addResource( Resource *resource )
{
- qDebug("AddressBook::addResource 1");
-
if ( !resource->open() ) {
@@ -574,3 +579,3 @@ QPtrList<Resource> AddressBook::resources()
// qDebug("AddressBook::resources() 1");
-
+
KRES::Manager<Resource>::ActiveIterator it;
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 3a8e028..f89d7da 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -46,3 +46,3 @@ class Ticket;
@short Address Book
-
+
This class provides access to a collection of address book entries.
@@ -60,3 +60,3 @@ class AddressBook : public QObject
@short Address Book Iterator
-
+
This class provides an iterator for address book entries.
@@ -87,3 +87,3 @@ class AddressBook : public QObject
@short Address Book Const Iterator
-
+
This class provides a const iterator for address book entries.
@@ -96,3 +96,3 @@ class AddressBook : public QObject
~ConstIterator();
-
+
ConstIterator &operator=( const ConstIterator & );
@@ -110,6 +110,6 @@ class AddressBook : public QObject
};
-
+
/**
Constructs a address book object.
-
+
@param format File format class.
@@ -118,2 +118,3 @@ class AddressBook : public QObject
AddressBook( const QString &config );
+ AddressBook( const QString &config, const QString &family );
virtual ~AddressBook();
@@ -125,3 +126,3 @@ class AddressBook : public QObject
for calling the @ref save() function.
-
+
@see save()
@@ -129,3 +130,3 @@ class AddressBook : public QObject
Ticket *requestSaveTicket( Resource *resource=0 );
-
+
/**
@@ -138,3 +139,3 @@ class AddressBook : public QObject
object has been requested for by @ref requestSaveTicket().
-
+
@param ticket a ticket object returned by @ref requestSaveTicket()
@@ -167,3 +168,3 @@ class AddressBook : public QObject
void clear();
-
+
/**
@@ -245,3 +246,3 @@ class AddressBook : public QObject
Add custom field to address book.
-
+
@param label User visible label of the field.
@@ -256,3 +257,3 @@ class AddressBook : public QObject
-
+
/**
@@ -310,2 +311,4 @@ class AddressBook : public QObject
+ void init(const QString &config, const QString &family);
+
private:
@@ -313,5 +316,2 @@ class AddressBook : public QObject
-//US optimization
- void init(const QString &config);
-
diff --git a/kabc/kabc.pro b/kabc/kabc.pro
index a8cd695..10b092c 100644
--- a/kabc/kabc.pro
+++ b/kabc/kabc.pro
@@ -9,3 +9,3 @@ include( ../variables.pri )
-INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat ../microkde/kdeui
+INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat ../microkde/kdeui
@@ -50,2 +50,3 @@ formats/vcardformatplugin2.h \
timezone.h \
+ tmpaddressbook.h \
addressee.h \
@@ -159,2 +160,3 @@ formatfactory.cpp \
timezone.cpp \
+ tmpaddressbook.cpp \
addressee.cpp \
diff --git a/kabc/kabcE.pro b/kabc/kabcE.pro
index bc1c0ed..598d4fc 100644
--- a/kabc/kabcE.pro
+++ b/kabc/kabcE.pro
@@ -5,3 +5,3 @@ TARGET = microkabc
-INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat $(QPEDIR)/include
+INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat $(QPEDIR)/include
OBJECTS_DIR = obj/$(PLATFORM)
@@ -10,2 +10,3 @@ DESTDIR = $(QPEDIR)/lib
LIBS += -lmicrokde
+LIBS += -lmicrokdepim
#LIBS += -lldap
@@ -38,3 +39,5 @@ HEADERS = \
stdaddressbook.h \
+ syncprefwidget.h \
timezone.h \
+ tmpaddressbook.h \
vcardconverter.h \
@@ -140,3 +143,5 @@ SOURCES = \
stdaddressbook.cpp \
+ syncprefwidget.cpp \
timezone.cpp \
+ tmpaddressbook.cpp \
vcardconverter.cpp \
diff --git a/kabc/resource.cpp b/kabc/resource.cpp
index 9a1a5f8..9632a3f 100644
--- a/kabc/resource.cpp
+++ b/kabc/resource.cpp
@@ -29,2 +29,4 @@ $Id$
+#include <ksyncprofile.h>
+
#include "resource.h"
@@ -33,5 +35,10 @@ using namespace KABC;
-Resource::Resource( const KConfig *config )
- : KRES::Resource( config ), mAddressBook( 0 )
+Resource::Resource( const KConfig *config, bool syncable )
+ : KRES::Resource( config ), mAddressBook( 0 ), mSyncProfile( 0 )
{
+ if(syncable == true) {
+ mSyncProfile = new KSyncProfile( identifier() );
+ mSyncProfile->setName(resourceName());
+ mSyncProfile->readConfig( (KConfig *)config );
+ }
}
@@ -40,2 +47,5 @@ Resource::~Resource()
{
+ if (mSyncProfile != 0) {
+ delete mSyncProfile;
+ }
}
@@ -45,4 +55,8 @@ void Resource::writeConfig( KConfig *config )
KRES::Resource::writeConfig( config );
+
+ if(mSyncProfile != 0)
+ mSyncProfile->writeConfig( config );
}
+
void Resource::setAddressBook( AddressBook *ab )
@@ -95 +109,46 @@ void Resource::cleanUp()
}
+
+bool Resource::isSyncable() const
+{
+ return (mSyncProfile != 0);
+}
+
+/**
+ * This method returns the number of elements that are currently in the resource.
+ */
+int Resource::count() const
+{
+ return 0;
+}
+
+/**
+ * This method removes all elements from the resource!! (Not from the addressbook)
+ */
+bool Resource::clear()
+{
+ return false;
+}
+
+QString Resource::fileName() const
+{
+ return mFileName;
+}
+
+void Resource::setFileName( const QString &fileName )
+{
+ mFileName = fileName;
+}
+
+/**
+ * Set the name of resource.You can override this method,
+ * but also remember to call Resource::setResourceName().
+ */
+void Resource::setResourceName( const QString &name )
+{
+ KRES::Resource::setResourceName(name);
+ if(mSyncProfile != 0) {
+ mSyncProfile->setName( name );
+ }
+
+}
+
diff --git a/kabc/resource.h b/kabc/resource.h
index c363125..db806a6 100644
--- a/kabc/resource.h
+++ b/kabc/resource.h
@@ -32,4 +32,7 @@ $Id$
+
#include "addressbook.h"
+class KSyncProfile;
+
namespace KABC {
@@ -38,3 +41,3 @@ namespace KABC {
* @short Helper class for handling coordinated save of address books.
- *
+ *
* This class is used as helper class for saving address book.
@@ -48,5 +51,5 @@ class Ticket
- private:
+ private:
Ticket( Resource *resource ) : mResource( resource ) {}
-
+
Resource *mResource;
@@ -59,2 +62,8 @@ class Resource : public KRES::Resource
{
+private:
+ /**
+ * make this constructor private to force everybody to use the other one
+ */
+ Resource( const KConfig *config);
+
public:
@@ -63,3 +72,3 @@ public:
*/
- Resource( const KConfig *config );
+ Resource( const KConfig *config, bool syncable );
@@ -90,7 +99,3 @@ public:
- /**
- * Close the resource and returns if it was successfully
- */
- virtual void doClose();
-
+
/**
@@ -100,3 +105,3 @@ public:
virtual Ticket *requestSaveTicket();
-
+
/**
@@ -119,2 +124,3 @@ public:
+
/**
@@ -125,4 +131,37 @@ public:
+
+ /**
+ * This method returns the number of elements that are currently in the resource.
+ */
+ virtual int count() const;
+
+ /**
+ * This method removes all elements from the resource!! (Not from the addressbook)
+ */
+ virtual bool clear();
+
+ /**
+ * Set name of file to be used for saving.
+ */
+ virtual void setFileName( const QString & );
+
+ /**
+ * Return name of file used for loading and saving the address book.
+ */
+ virtual QString fileName() const;
+
+
+ virtual bool isSyncable() const;
+
+ /**
+ * Set the name of resource.You can override this method,
+ * but also remember to call Resource::setResourceName().
+ */
+ virtual void setResourceName( const QString &name );
+
+
+
protected:
Ticket *createTicket( Resource * );
+ virtual void doClose();
@@ -130,5 +169,12 @@ private:
AddressBook *mAddressBook;
+ KSyncProfile *mSyncProfile;
+ QString mFileName;
+
};
+
}
+
+
+
#endif