author | ulf69 <ulf69> | 2004-08-02 18:33:07 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-02 18:33:07 (UTC) |
commit | 60a6886f06be31ec690df34dc8e3b8931c2d3bd7 (patch) (unidiff) | |
tree | c4c7c15cfd3753a3342806a11fb8f5c20bb4f923 | |
parent | 863c4c3678e59ef125c08c00e9532ded5b540f67 (diff) | |
download | kdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.zip kdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.tar.gz kdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.tar.bz2 |
added support for syncable resources
-rw-r--r-- | kabc/addressbook.cpp | 35 | ||||
-rw-r--r-- | kabc/addressbook.h | 30 | ||||
-rw-r--r-- | kabc/kabc.pro | 4 | ||||
-rw-r--r-- | kabc/kabcE.pro | 7 | ||||
-rw-r--r-- | kabc/resource.cpp | 63 | ||||
-rw-r--r-- | kabc/resource.h | 66 |
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() | |||
218 | { | 218 | { |
219 | init(0); | 219 | init(0, "contact"); |
220 | } | 220 | } |
@@ -223,6 +223,13 @@ AddressBook::AddressBook( const QString &config ) | |||
223 | { | 223 | { |
224 | init(config); | 224 | init(config, "contact"); |
225 | } | 225 | } |
226 | 226 | ||
227 | void AddressBook::init(const QString &config) | 227 | AddressBook::AddressBook( const QString &config, const QString &family ) |
228 | { | ||
229 | init(config, family); | ||
230 | |||
231 | } | ||
232 | |||
233 | // the default family is "contact" | ||
234 | void AddressBook::init(const QString &config, const QString &family ) | ||
228 | { | 235 | { |
@@ -237,5 +244,5 @@ void AddressBook::init(const QString &config) | |||
237 | } | 244 | } |
238 | 245 | ||
239 | //US d->mErrorHandler = 0; | 246 | //US d->mErrorHandler = 0; |
240 | d->mManager = new KRES::Manager<Resource>( "contact" ); | 247 | d->mManager = new KRES::Manager<Resource>( family, false ); |
241 | d->mManager->readConfig( d->mConfig ); | 248 | d->mManager->readConfig( d->mConfig ); |
@@ -253,3 +260,3 @@ bool AddressBook::load() | |||
253 | { | 260 | { |
254 | 261 | ||
255 | 262 | ||
@@ -279,3 +286,3 @@ bool AddressBook::save( Ticket *ticket ) | |||
279 | deleteRemovedAddressees(); | 286 | deleteRemovedAddressees(); |
280 | 287 | ||
281 | return ticket->resource()->save( ticket ); | 288 | return ticket->resource()->save( ticket ); |
@@ -358,3 +365,3 @@ void AddressBook::insertAddressee( const Addressee &a ) | |||
358 | (*it).setRevision( QDateTime::currentDateTime() ); | 365 | (*it).setRevision( QDateTime::currentDateTime() ); |
359 | (*it).setChanged( true ); | 366 | (*it).setChanged( true ); |
360 | } | 367 | } |
@@ -437,3 +444,3 @@ Addressee::List AddressBook::findByEmail( const QString &email ) | |||
437 | for ( it = begin(); it != end(); ++it ) { | 444 | for ( it = begin(); it != end(); ++it ) { |
438 | mailList = (*it).emails(); | 445 | mailList = (*it).emails(); |
439 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 446 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
@@ -493,5 +500,5 @@ Field::List AddressBook::fields( int category ) | |||
493 | } | 500 | } |
494 | 501 | ||
495 | if ( category == Field::All ) return d->mAllFields; | 502 | if ( category == Field::All ) return d->mAllFields; |
496 | 503 | ||
497 | Field::List result; | 504 | Field::List result; |
@@ -501,3 +508,3 @@ Field::List AddressBook::fields( int category ) | |||
501 | } | 508 | } |
502 | 509 | ||
503 | return result; | 510 | return result; |
@@ -543,4 +550,2 @@ bool AddressBook::addResource( Resource *resource ) | |||
543 | { | 550 | { |
544 | qDebug("AddressBook::addResource 1"); | ||
545 | |||
546 | if ( !resource->open() ) { | 551 | if ( !resource->open() ) { |
@@ -574,3 +579,3 @@ QPtrList<Resource> AddressBook::resources() | |||
574 | // qDebug("AddressBook::resources() 1"); | 579 | // qDebug("AddressBook::resources() 1"); |
575 | 580 | ||
576 | KRES::Manager<Resource>::ActiveIterator it; | 581 | 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; | |||
46 | @short Address Book | 46 | @short Address Book |
47 | 47 | ||
48 | This class provides access to a collection of address book entries. | 48 | This class provides access to a collection of address book entries. |
@@ -60,3 +60,3 @@ class AddressBook : public QObject | |||
60 | @short Address Book Iterator | 60 | @short Address Book Iterator |
61 | 61 | ||
62 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
@@ -87,3 +87,3 @@ class AddressBook : public QObject | |||
87 | @short Address Book Const Iterator | 87 | @short Address Book Const Iterator |
88 | 88 | ||
89 | This class provides a const iterator for address book entries. | 89 | This class provides a const iterator for address book entries. |
@@ -96,3 +96,3 @@ class AddressBook : public QObject | |||
96 | ~ConstIterator(); | 96 | ~ConstIterator(); |
97 | 97 | ||
98 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
@@ -110,6 +110,6 @@ class AddressBook : public QObject | |||
110 | }; | 110 | }; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | Constructs a address book object. | 113 | Constructs a address book object. |
114 | 114 | ||
115 | @param format File format class. | 115 | @param format File format class. |
@@ -118,2 +118,3 @@ class AddressBook : public QObject | |||
118 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
119 | AddressBook( const QString &config, const QString &family ); | ||
119 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
@@ -125,3 +126,3 @@ class AddressBook : public QObject | |||
125 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
126 | 127 | ||
127 | @see save() | 128 | @see save() |
@@ -129,3 +130,3 @@ class AddressBook : public QObject | |||
129 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
130 | 131 | ||
131 | /** | 132 | /** |
@@ -138,3 +139,3 @@ class AddressBook : public QObject | |||
138 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
139 | 140 | ||
140 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
@@ -167,3 +168,3 @@ class AddressBook : public QObject | |||
167 | void clear(); | 168 | void clear(); |
168 | 169 | ||
169 | /** | 170 | /** |
@@ -245,3 +246,3 @@ class AddressBook : public QObject | |||
245 | Add custom field to address book. | 246 | Add custom field to address book. |
246 | 247 | ||
247 | @param label User visible label of the field. | 248 | @param label User visible label of the field. |
@@ -256,3 +257,3 @@ class AddressBook : public QObject | |||
256 | 257 | ||
257 | 258 | ||
258 | /** | 259 | /** |
@@ -310,2 +311,4 @@ class AddressBook : public QObject | |||
310 | 311 | ||
312 | void init(const QString &config, const QString &family); | ||
313 | |||
311 | private: | 314 | private: |
@@ -313,5 +316,2 @@ class AddressBook : public QObject | |||
313 | 316 | ||
314 | //US optimization | ||
315 | void init(const QString &config); | ||
316 | |||
317 | 317 | ||
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 ) | |||
9 | 9 | ||
10 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat ../microkde/kdeui | 10 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat ../microkde/kdeui |
11 | 11 | ||
@@ -50,2 +50,3 @@ formats/vcardformatplugin2.h \ | |||
50 | timezone.h \ | 50 | timezone.h \ |
51 | tmpaddressbook.h \ | ||
51 | addressee.h \ | 52 | addressee.h \ |
@@ -159,2 +160,3 @@ formatfactory.cpp \ | |||
159 | timezone.cpp \ | 160 | timezone.cpp \ |
161 | tmpaddressbook.cpp \ | ||
160 | addressee.cpp \ | 162 | 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 | |||
5 | 5 | ||
6 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat $(QPEDIR)/include | 6 | INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat $(QPEDIR)/include |
7 | OBJECTS_DIR = obj/$(PLATFORM) | 7 | OBJECTS_DIR = obj/$(PLATFORM) |
@@ -10,2 +10,3 @@ DESTDIR = $(QPEDIR)/lib | |||
10 | LIBS += -lmicrokde | 10 | LIBS += -lmicrokde |
11 | LIBS += -lmicrokdepim | ||
11 | #LIBS += -lldap | 12 | #LIBS += -lldap |
@@ -38,3 +39,5 @@ HEADERS = \ | |||
38 | stdaddressbook.h \ | 39 | stdaddressbook.h \ |
40 | syncprefwidget.h \ | ||
39 | timezone.h \ | 41 | timezone.h \ |
42 | tmpaddressbook.h \ | ||
40 | vcardconverter.h \ | 43 | vcardconverter.h \ |
@@ -140,3 +143,5 @@ SOURCES = \ | |||
140 | stdaddressbook.cpp \ | 143 | stdaddressbook.cpp \ |
144 | syncprefwidget.cpp \ | ||
141 | timezone.cpp \ | 145 | timezone.cpp \ |
146 | tmpaddressbook.cpp \ | ||
142 | vcardconverter.cpp \ | 147 | 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$ | |||
29 | 29 | ||
30 | #include <ksyncprofile.h> | ||
31 | |||
30 | #include "resource.h" | 32 | #include "resource.h" |
@@ -33,5 +35,10 @@ using namespace KABC; | |||
33 | 35 | ||
34 | Resource::Resource( const KConfig *config ) | 36 | Resource::Resource( const KConfig *config, bool syncable ) |
35 | : KRES::Resource( config ), mAddressBook( 0 ) | 37 | : KRES::Resource( config ), mAddressBook( 0 ), mSyncProfile( 0 ) |
36 | { | 38 | { |
39 | if(syncable == true) { | ||
40 | mSyncProfile = new KSyncProfile( identifier() ); | ||
41 | mSyncProfile->setName(resourceName()); | ||
42 | mSyncProfile->readConfig( (KConfig *)config ); | ||
43 | } | ||
37 | } | 44 | } |
@@ -40,2 +47,5 @@ Resource::~Resource() | |||
40 | { | 47 | { |
48 | if (mSyncProfile != 0) { | ||
49 | delete mSyncProfile; | ||
50 | } | ||
41 | } | 51 | } |
@@ -45,4 +55,8 @@ void Resource::writeConfig( KConfig *config ) | |||
45 | KRES::Resource::writeConfig( config ); | 55 | KRES::Resource::writeConfig( config ); |
56 | |||
57 | if(mSyncProfile != 0) | ||
58 | mSyncProfile->writeConfig( config ); | ||
46 | } | 59 | } |
47 | 60 | ||
61 | |||
48 | void Resource::setAddressBook( AddressBook *ab ) | 62 | void Resource::setAddressBook( AddressBook *ab ) |
@@ -95 +109,46 @@ void Resource::cleanUp() | |||
95 | } | 109 | } |
110 | |||
111 | bool Resource::isSyncable() const | ||
112 | { | ||
113 | return (mSyncProfile != 0); | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * This method returns the number of elements that are currently in the resource. | ||
118 | */ | ||
119 | int Resource::count() const | ||
120 | { | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * This method removes all elements from the resource!! (Not from the addressbook) | ||
126 | */ | ||
127 | bool Resource::clear() | ||
128 | { | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | QString Resource::fileName() const | ||
133 | { | ||
134 | return mFileName; | ||
135 | } | ||
136 | |||
137 | void Resource::setFileName( const QString &fileName ) | ||
138 | { | ||
139 | mFileName = fileName; | ||
140 | } | ||
141 | |||
142 | /** | ||
143 | * Set the name of resource.You can override this method, | ||
144 | * but also remember to call Resource::setResourceName(). | ||
145 | */ | ||
146 | void Resource::setResourceName( const QString &name ) | ||
147 | { | ||
148 | KRES::Resource::setResourceName(name); | ||
149 | if(mSyncProfile != 0) { | ||
150 | mSyncProfile->setName( name ); | ||
151 | } | ||
152 | |||
153 | } | ||
154 | |||
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$ | |||
32 | 32 | ||
33 | |||
33 | #include "addressbook.h" | 34 | #include "addressbook.h" |
34 | 35 | ||
36 | class KSyncProfile; | ||
37 | |||
35 | namespace KABC { | 38 | namespace KABC { |
@@ -38,3 +41,3 @@ namespace KABC { | |||
38 | * @short Helper class for handling coordinated save of address books. | 41 | * @short Helper class for handling coordinated save of address books. |
39 | * | 42 | * |
40 | * This class is used as helper class for saving address book. | 43 | * This class is used as helper class for saving address book. |
@@ -48,5 +51,5 @@ class Ticket | |||
48 | 51 | ||
49 | private: | 52 | private: |
50 | Ticket( Resource *resource ) : mResource( resource ) {} | 53 | Ticket( Resource *resource ) : mResource( resource ) {} |
51 | 54 | ||
52 | Resource *mResource; | 55 | Resource *mResource; |
@@ -59,2 +62,8 @@ class Resource : public KRES::Resource | |||
59 | { | 62 | { |
63 | private: | ||
64 | /** | ||
65 | * make this constructor private to force everybody to use the other one | ||
66 | */ | ||
67 | Resource( const KConfig *config); | ||
68 | |||
60 | public: | 69 | public: |
@@ -63,3 +72,3 @@ public: | |||
63 | */ | 72 | */ |
64 | Resource( const KConfig *config ); | 73 | Resource( const KConfig *config, bool syncable ); |
65 | 74 | ||
@@ -90,7 +99,3 @@ public: | |||
90 | 99 | ||
91 | /** | 100 | |
92 | * Close the resource and returns if it was successfully | ||
93 | */ | ||
94 | virtual void doClose(); | ||
95 | |||
96 | /** | 101 | /** |
@@ -100,3 +105,3 @@ public: | |||
100 | virtual Ticket *requestSaveTicket(); | 105 | virtual Ticket *requestSaveTicket(); |
101 | 106 | ||
102 | /** | 107 | /** |
@@ -119,2 +124,3 @@ public: | |||
119 | 124 | ||
125 | |||
120 | /** | 126 | /** |
@@ -125,4 +131,37 @@ public: | |||
125 | 131 | ||
132 | |||
133 | /** | ||
134 | * This method returns the number of elements that are currently in the resource. | ||
135 | */ | ||
136 | virtual int count() const; | ||
137 | |||
138 | /** | ||
139 | * This method removes all elements from the resource!! (Not from the addressbook) | ||
140 | */ | ||
141 | virtual bool clear(); | ||
142 | |||
143 | /** | ||
144 | * Set name of file to be used for saving. | ||
145 | */ | ||
146 | virtual void setFileName( const QString & ); | ||
147 | |||
148 | /** | ||
149 | * Return name of file used for loading and saving the address book. | ||
150 | */ | ||
151 | virtual QString fileName() const; | ||
152 | |||
153 | |||
154 | virtual bool isSyncable() const; | ||
155 | |||
156 | /** | ||
157 | * Set the name of resource.You can override this method, | ||
158 | * but also remember to call Resource::setResourceName(). | ||
159 | */ | ||
160 | virtual void setResourceName( const QString &name ); | ||
161 | |||
162 | |||
163 | |||
126 | protected: | 164 | protected: |
127 | Ticket *createTicket( Resource * ); | 165 | Ticket *createTicket( Resource * ); |
166 | virtual void doClose(); | ||
128 | 167 | ||
@@ -130,5 +169,12 @@ private: | |||
130 | AddressBook *mAddressBook; | 169 | AddressBook *mAddressBook; |
170 | KSyncProfile *mSyncProfile; | ||
171 | QString mFileName; | ||
172 | |||
131 | }; | 173 | }; |
132 | 174 | ||
175 | |||
133 | } | 176 | } |
177 | |||
178 | |||
179 | |||
134 | #endif | 180 | #endif |