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 /kabc | |
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 | |||
@@ -213,34 +213,41 @@ bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | |||
213 | return ( d->mIt != it.d->mIt ); | 213 | return ( d->mIt != it.d->mIt ); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | AddressBook::AddressBook() | 217 | AddressBook::AddressBook() |
218 | { | 218 | { |
219 | init(0); | 219 | init(0, "contact"); |
220 | } | 220 | } |
221 | 221 | ||
222 | AddressBook::AddressBook( const QString &config ) | 222 | 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 | { |
229 | d = new AddressBookData; | 236 | d = new AddressBookData; |
230 | if (config != 0) { | 237 | if (config != 0) { |
231 | d->mConfig = new KConfig( config ); | 238 | d->mConfig = new KConfig( config ); |
232 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 239 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
233 | } | 240 | } |
234 | else { | 241 | else { |
235 | d->mConfig = 0; | 242 | d->mConfig = 0; |
236 | // qDebug("AddressBook::init 1 config=0"); | 243 | // qDebug("AddressBook::init 1 config=0"); |
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 ); |
242 | } | 249 | } |
243 | 250 | ||
244 | AddressBook::~AddressBook() | 251 | AddressBook::~AddressBook() |
245 | { | 252 | { |
246 | delete d->mConfig; d->mConfig = 0; | 253 | delete d->mConfig; d->mConfig = 0; |
@@ -248,13 +255,13 @@ AddressBook::~AddressBook() | |||
248 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 255 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
249 | delete d; d = 0; | 256 | delete d; d = 0; |
250 | } | 257 | } |
251 | 258 | ||
252 | bool AddressBook::load() | 259 | bool AddressBook::load() |
253 | { | 260 | { |
254 | 261 | ||
255 | 262 | ||
256 | clear(); | 263 | clear(); |
257 | 264 | ||
258 | KRES::Manager<Resource>::ActiveIterator it; | 265 | KRES::Manager<Resource>::ActiveIterator it; |
259 | bool ok = true; | 266 | bool ok = true; |
260 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 267 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
@@ -274,13 +281,13 @@ bool AddressBook::load() | |||
274 | bool AddressBook::save( Ticket *ticket ) | 281 | bool AddressBook::save( Ticket *ticket ) |
275 | { | 282 | { |
276 | kdDebug(5700) << "AddressBook::save()"<< endl; | 283 | kdDebug(5700) << "AddressBook::save()"<< endl; |
277 | 284 | ||
278 | if ( ticket->resource() ) { | 285 | if ( ticket->resource() ) { |
279 | deleteRemovedAddressees(); | 286 | deleteRemovedAddressees(); |
280 | 287 | ||
281 | return ticket->resource()->save( ticket ); | 288 | return ticket->resource()->save( ticket ); |
282 | } | 289 | } |
283 | 290 | ||
284 | return false; | 291 | return false; |
285 | } | 292 | } |
286 | 293 | ||
@@ -353,13 +360,13 @@ void AddressBook::insertAddressee( const Addressee &a ) | |||
353 | (*it) = a; | 360 | (*it) = a; |
354 | if ( (*it).resource() == 0 ) | 361 | if ( (*it).resource() == 0 ) |
355 | (*it).setResource( standardResource() ); | 362 | (*it).setResource( standardResource() ); |
356 | 363 | ||
357 | if ( changed ) { | 364 | if ( changed ) { |
358 | (*it).setRevision( QDateTime::currentDateTime() ); | 365 | (*it).setRevision( QDateTime::currentDateTime() ); |
359 | (*it).setChanged( true ); | 366 | (*it).setChanged( true ); |
360 | } | 367 | } |
361 | 368 | ||
362 | return; | 369 | return; |
363 | } | 370 | } |
364 | } | 371 | } |
365 | d->mAddressees.append( a ); | 372 | d->mAddressees.append( a ); |
@@ -432,13 +439,13 @@ Addressee::List AddressBook::findByEmail( const QString &email ) | |||
432 | { | 439 | { |
433 | Addressee::List results; | 440 | Addressee::List results; |
434 | QStringList mailList; | 441 | QStringList mailList; |
435 | 442 | ||
436 | Iterator it; | 443 | Iterator it; |
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 ) { |
440 | if ( email == (*ite) ) { | 447 | if ( email == (*ite) ) { |
441 | results.append( *it ); | 448 | results.append( *it ); |
442 | } | 449 | } |
443 | } | 450 | } |
444 | } | 451 | } |
@@ -488,21 +495,21 @@ QString AddressBook::identifier() | |||
488 | 495 | ||
489 | Field::List AddressBook::fields( int category ) | 496 | Field::List AddressBook::fields( int category ) |
490 | { | 497 | { |
491 | if ( d->mAllFields.isEmpty() ) { | 498 | if ( d->mAllFields.isEmpty() ) { |
492 | d->mAllFields = Field::allFields(); | 499 | d->mAllFields = Field::allFields(); |
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; |
498 | Field::List::ConstIterator it; | 505 | Field::List::ConstIterator it; |
499 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 506 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
500 | if ( (*it)->category() & category ) result.append( *it ); | 507 | if ( (*it)->category() & category ) result.append( *it ); |
501 | } | 508 | } |
502 | 509 | ||
503 | return result; | 510 | return result; |
504 | } | 511 | } |
505 | 512 | ||
506 | bool AddressBook::addCustomField( const QString &label, int category, | 513 | bool AddressBook::addCustomField( const QString &label, int category, |
507 | const QString &key, const QString &app ) | 514 | const QString &key, const QString &app ) |
508 | { | 515 | { |
@@ -538,14 +545,12 @@ QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | |||
538 | 545 | ||
539 | return s; | 546 | return s; |
540 | } | 547 | } |
541 | 548 | ||
542 | bool AddressBook::addResource( Resource *resource ) | 549 | bool AddressBook::addResource( Resource *resource ) |
543 | { | 550 | { |
544 | qDebug("AddressBook::addResource 1"); | ||
545 | |||
546 | if ( !resource->open() ) { | 551 | if ( !resource->open() ) { |
547 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 552 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
548 | return false; | 553 | return false; |
549 | } | 554 | } |
550 | 555 | ||
551 | resource->setAddressBook( this ); | 556 | resource->setAddressBook( this ); |
@@ -569,13 +574,13 @@ bool AddressBook::removeResource( Resource *resource ) | |||
569 | 574 | ||
570 | QPtrList<Resource> AddressBook::resources() | 575 | QPtrList<Resource> AddressBook::resources() |
571 | { | 576 | { |
572 | QPtrList<Resource> list; | 577 | QPtrList<Resource> list; |
573 | 578 | ||
574 | // qDebug("AddressBook::resources() 1"); | 579 | // qDebug("AddressBook::resources() 1"); |
575 | 580 | ||
576 | KRES::Manager<Resource>::ActiveIterator it; | 581 | KRES::Manager<Resource>::ActiveIterator it; |
577 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 582 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
578 | list.append( *it ); | 583 | list.append( *it ); |
579 | 584 | ||
580 | return list; | 585 | return list; |
581 | } | 586 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 3a8e028..f89d7da 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -41,13 +41,13 @@ namespace KABC { | |||
41 | class ErrorHandler; | 41 | class ErrorHandler; |
42 | class Resource; | 42 | class Resource; |
43 | class Ticket; | 43 | class Ticket; |
44 | 44 | ||
45 | /** | 45 | /** |
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. |
49 | */ | 49 | */ |
50 | class AddressBook : public QObject | 50 | class AddressBook : public QObject |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
@@ -55,13 +55,13 @@ class AddressBook : public QObject | |||
55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
56 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
57 | 57 | ||
58 | public: | 58 | public: |
59 | /** | 59 | /** |
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. |
63 | */ | 63 | */ |
64 | class Iterator | 64 | class Iterator |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | Iterator(); | 67 | Iterator(); |
@@ -82,22 +82,22 @@ class AddressBook : public QObject | |||
82 | struct IteratorData; | 82 | struct IteratorData; |
83 | IteratorData *d; | 83 | IteratorData *d; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /** | 86 | /** |
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. |
90 | */ | 90 | */ |
91 | class ConstIterator | 91 | class ConstIterator |
92 | { | 92 | { |
93 | public: | 93 | public: |
94 | ConstIterator(); | 94 | ConstIterator(); |
95 | ConstIterator( const ConstIterator & ); | 95 | ConstIterator( const ConstIterator & ); |
96 | ~ConstIterator(); | 96 | ~ConstIterator(); |
97 | 97 | ||
98 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
99 | const Addressee &operator*() const; | 99 | const Addressee &operator*() const; |
100 | const Addressee* operator->() const; | 100 | const Addressee* operator->() const; |
101 | ConstIterator &operator++(); | 101 | ConstIterator &operator++(); |
102 | ConstIterator &operator++(int); | 102 | ConstIterator &operator++(int); |
103 | ConstIterator &operator--(); | 103 | ConstIterator &operator--(); |
@@ -105,41 +105,42 @@ class AddressBook : public QObject | |||
105 | bool operator==( const ConstIterator &it ); | 105 | bool operator==( const ConstIterator &it ); |
106 | bool operator!=( const ConstIterator &it ); | 106 | bool operator!=( const ConstIterator &it ); |
107 | 107 | ||
108 | struct ConstIteratorData; | 108 | struct ConstIteratorData; |
109 | ConstIteratorData *d; | 109 | ConstIteratorData *d; |
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. |
116 | */ | 116 | */ |
117 | AddressBook(); | 117 | AddressBook(); |
118 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
119 | AddressBook( const QString &config, const QString &family ); | ||
119 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
120 | 121 | ||
121 | /** | 122 | /** |
122 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
123 | the addressbook for all other processes. If the address book is already | 124 | the addressbook for all other processes. If the address book is already |
124 | locked the function returns 0. You need the returned @ref Ticket object | 125 | locked the function returns 0. You need the returned @ref Ticket object |
125 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
126 | 127 | ||
127 | @see save() | 128 | @see save() |
128 | */ | 129 | */ |
129 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
130 | 131 | ||
131 | /** | 132 | /** |
132 | Load address book from file. | 133 | Load address book from file. |
133 | */ | 134 | */ |
134 | bool load(); | 135 | bool load(); |
135 | 136 | ||
136 | /** | 137 | /** |
137 | Save address book. The address book is saved to the file, the Ticket | 138 | Save address book. The address book is saved to the file, the Ticket |
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() |
141 | */ | 142 | */ |
142 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
143 | 144 | ||
144 | /** | 145 | /** |
145 | Returns a iterator for first entry of address book. | 146 | Returns a iterator for first entry of address book. |
@@ -162,13 +163,13 @@ class AddressBook : public QObject | |||
162 | ConstIterator end() const; | 163 | ConstIterator end() const; |
163 | 164 | ||
164 | /** | 165 | /** |
165 | Removes all entries from address book. | 166 | Removes all entries from address book. |
166 | */ | 167 | */ |
167 | void clear(); | 168 | void clear(); |
168 | 169 | ||
169 | /** | 170 | /** |
170 | Insert an Addressee object into address book. If an object with the same | 171 | Insert an Addressee object into address book. If an object with the same |
171 | unique id already exists in the address book it it replaced by the new | 172 | unique id already exists in the address book it it replaced by the new |
172 | one. If not the new object is appended to the address book. | 173 | one. If not the new object is appended to the address book. |
173 | */ | 174 | */ |
174 | void insertAddressee( const Addressee & ); | 175 | void insertAddressee( const Addressee & ); |
@@ -240,24 +241,24 @@ class AddressBook : public QObject | |||
240 | with the given field category. | 241 | with the given field category. |
241 | */ | 242 | */ |
242 | Field::List fields( int category = Field::All ); | 243 | Field::List fields( int category = Field::All ); |
243 | 244 | ||
244 | /** | 245 | /** |
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. |
248 | @param category Ored list of field categories. | 249 | @param category Ored list of field categories. |
249 | @param key Identifier used as key for reading and writing the field. | 250 | @param key Identifier used as key for reading and writing the field. |
250 | @param app String used as application key for reading and writing | 251 | @param app String used as application key for reading and writing |
251 | the field. | 252 | the field. |
252 | */ | 253 | */ |
253 | bool addCustomField( const QString &label, int category = Field::All, | 254 | bool addCustomField( const QString &label, int category = Field::All, |
254 | const QString &key = QString::null, | 255 | const QString &key = QString::null, |
255 | const QString &app = QString::null ); | 256 | const QString &app = QString::null ); |
256 | 257 | ||
257 | 258 | ||
258 | /** | 259 | /** |
259 | Add address book resource. | 260 | Add address book resource. |
260 | */ | 261 | */ |
261 | bool addResource( Resource * ); | 262 | bool addResource( Resource * ); |
262 | 263 | ||
263 | /** | 264 | /** |
@@ -305,18 +306,17 @@ class AddressBook : public QObject | |||
305 | protected: | 306 | protected: |
306 | void deleteRemovedAddressees(); | 307 | void deleteRemovedAddressees(); |
307 | void setStandardResource( Resource * ); | 308 | void setStandardResource( Resource * ); |
308 | Resource *standardResource(); | 309 | Resource *standardResource(); |
309 | KRES::Manager<Resource> *resourceManager(); | 310 | KRES::Manager<Resource> *resourceManager(); |
310 | 311 | ||
312 | void init(const QString &config, const QString &family); | ||
313 | |||
311 | private: | 314 | private: |
312 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 315 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
313 | 316 | ||
314 | //US optimization | ||
315 | void init(const QString &config); | ||
316 | |||
317 | 317 | ||
318 | struct AddressBookData; | 318 | struct AddressBookData; |
319 | AddressBookData *d; | 319 | AddressBookData *d; |
320 | }; | 320 | }; |
321 | 321 | ||
322 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 322 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
diff --git a/kabc/kabc.pro b/kabc/kabc.pro index a8cd695..10b092c 100644 --- a/kabc/kabc.pro +++ b/kabc/kabc.pro | |||
@@ -4,13 +4,13 @@ CONFIG += qt warn_on | |||
4 | DESTDIR=../bin | 4 | DESTDIR=../bin |
5 | 5 | ||
6 | TARGET = microkabc | 6 | TARGET = microkabc |
7 | 7 | ||
8 | include( ../variables.pri ) | 8 | 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 | ||
12 | #LIBS += -lmicrokde -lldap | 12 | #LIBS += -lmicrokde -lldap |
13 | LIBS += -L$(QPEDIR)/lib | 13 | LIBS += -L$(QPEDIR)/lib |
14 | DEFINES += KAB_EMBEDDED DESKTOP_VERSION | 14 | DEFINES += KAB_EMBEDDED DESKTOP_VERSION |
15 | unix : { | 15 | unix : { |
16 | 16 | ||
@@ -45,12 +45,13 @@ vcardformatplugin.h \ | |||
45 | formats/vcardformatplugin2.h \ | 45 | formats/vcardformatplugin2.h \ |
46 | picture.h \ | 46 | picture.h \ |
47 | secrecy.h \ | 47 | secrecy.h \ |
48 | sound.h \ | 48 | sound.h \ |
49 | addressbook.h \ | 49 | addressbook.h \ |
50 | timezone.h \ | 50 | timezone.h \ |
51 | tmpaddressbook.h \ | ||
51 | addressee.h \ | 52 | addressee.h \ |
52 | addresseedialog.h \ | 53 | addresseedialog.h \ |
53 | vcardconverter.h \ | 54 | vcardconverter.h \ |
54 | vcard21parser.h \ | 55 | vcard21parser.h \ |
55 | vcardformatimpl.h \ | 56 | vcardformatimpl.h \ |
56 | plugins/file/resourcefile.h \ | 57 | plugins/file/resourcefile.h \ |
@@ -154,12 +155,13 @@ formatfactory.cpp \ | |||
154 | phonenumber.cpp \ | 155 | phonenumber.cpp \ |
155 | picture.cpp \ | 156 | picture.cpp \ |
156 | secrecy.cpp \ | 157 | secrecy.cpp \ |
157 | sound.cpp \ | 158 | sound.cpp \ |
158 | addressbook.cpp \ | 159 | addressbook.cpp \ |
159 | timezone.cpp \ | 160 | timezone.cpp \ |
161 | tmpaddressbook.cpp \ | ||
160 | addressee.cpp \ | 162 | addressee.cpp \ |
161 | addresseelist.cpp \ | 163 | addresseelist.cpp \ |
162 | addresseedialog.cpp \ | 164 | addresseedialog.cpp \ |
163 | vcardconverter.cpp \ | 165 | vcardconverter.cpp \ |
164 | vcard21parser.cpp \ | 166 | vcard21parser.cpp \ |
165 | vcardformatimpl.cpp \ | 167 | vcardformatimpl.cpp \ |
diff --git a/kabc/kabcE.pro b/kabc/kabcE.pro index bc1c0ed..598d4fc 100644 --- a/kabc/kabcE.pro +++ b/kabc/kabcE.pro | |||
@@ -1,16 +1,17 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = microkabc | 3 | TARGET = microkabc |
4 | 4 | ||
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) |
8 | MOC_DIR = moc/$(PLATFORM) | 8 | MOC_DIR = moc/$(PLATFORM) |
9 | DESTDIR = $(QPEDIR)/lib | 9 | DESTDIR = $(QPEDIR)/lib |
10 | LIBS += -lmicrokde | 10 | LIBS += -lmicrokde |
11 | LIBS += -lmicrokdepim | ||
11 | #LIBS += -lldap | 12 | #LIBS += -lldap |
12 | LIBS += -L$(QPEDIR)/lib | 13 | LIBS += -L$(QPEDIR)/lib |
13 | DEFINES += KAB_EMBEDDED | 14 | DEFINES += KAB_EMBEDDED |
14 | 15 | ||
15 | INTERFACES = \ | 16 | INTERFACES = \ |
16 | 17 | ||
@@ -33,13 +34,15 @@ HEADERS = \ | |||
33 | picture.h \ | 34 | picture.h \ |
34 | plugin.h \ | 35 | plugin.h \ |
35 | resource.h \ | 36 | resource.h \ |
36 | secrecy.h \ | 37 | secrecy.h \ |
37 | sound.h \ | 38 | sound.h \ |
38 | stdaddressbook.h \ | 39 | stdaddressbook.h \ |
40 | syncprefwidget.h \ | ||
39 | timezone.h \ | 41 | timezone.h \ |
42 | tmpaddressbook.h \ | ||
40 | vcardconverter.h \ | 43 | vcardconverter.h \ |
41 | vcard21parser.h \ | 44 | vcard21parser.h \ |
42 | vcardformatimpl.h \ | 45 | vcardformatimpl.h \ |
43 | vcardformatplugin.h \ | 46 | vcardformatplugin.h \ |
44 | vcardparser/vcardline.h \ | 47 | vcardparser/vcardline.h \ |
45 | vcardparser/vcard.h \ | 48 | vcardparser/vcard.h \ |
@@ -135,13 +138,15 @@ SOURCES = \ | |||
135 | picture.cpp \ | 138 | picture.cpp \ |
136 | plugin.cpp \ | 139 | plugin.cpp \ |
137 | resource.cpp \ | 140 | resource.cpp \ |
138 | secrecy.cpp \ | 141 | secrecy.cpp \ |
139 | sound.cpp \ | 142 | sound.cpp \ |
140 | stdaddressbook.cpp \ | 143 | stdaddressbook.cpp \ |
144 | syncprefwidget.cpp \ | ||
141 | timezone.cpp \ | 145 | timezone.cpp \ |
146 | tmpaddressbook.cpp \ | ||
142 | vcardconverter.cpp \ | 147 | vcardconverter.cpp \ |
143 | vcard21parser.cpp \ | 148 | vcard21parser.cpp \ |
144 | vcardformatimpl.cpp \ | 149 | vcardformatimpl.cpp \ |
145 | vcardformatplugin.cpp \ | 150 | vcardformatplugin.cpp \ |
146 | vcardparser/vcardline.cpp \ | 151 | vcardparser/vcardline.cpp \ |
147 | vcardparser/vcard.cpp \ | 152 | vcardparser/vcard.cpp \ |
diff --git a/kabc/resource.cpp b/kabc/resource.cpp index 9a1a5f8..9632a3f 100644 --- a/kabc/resource.cpp +++ b/kabc/resource.cpp | |||
@@ -24,30 +24,44 @@ Copyright (c) 2004 Ulf Schenk | |||
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | 29 | ||
30 | #include <ksyncprofile.h> | ||
31 | |||
30 | #include "resource.h" | 32 | #include "resource.h" |
31 | 33 | ||
32 | using namespace KABC; | 34 | 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 | } |
38 | 45 | ||
39 | Resource::~Resource() | 46 | Resource::~Resource() |
40 | { | 47 | { |
48 | if (mSyncProfile != 0) { | ||
49 | delete mSyncProfile; | ||
50 | } | ||
41 | } | 51 | } |
42 | 52 | ||
43 | void Resource::writeConfig( KConfig *config ) | 53 | void Resource::writeConfig( KConfig *config ) |
44 | { | 54 | { |
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 ) |
49 | { | 63 | { |
50 | mAddressBook = ab; | 64 | mAddressBook = ab; |
51 | } | 65 | } |
52 | 66 | ||
53 | AddressBook *Resource::addressBook() | 67 | AddressBook *Resource::addressBook() |
@@ -90,6 +104,51 @@ void Resource::removeAddressee( const Addressee& ) | |||
90 | } | 104 | } |
91 | 105 | ||
92 | void Resource::cleanUp() | 106 | void Resource::cleanUp() |
93 | { | 107 | { |
94 | // do nothing | 108 | // do nothing |
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 | |||
@@ -27,44 +27,53 @@ $Id$ | |||
27 | 27 | ||
28 | #ifndef KABC_RESOURCE_H | 28 | #ifndef KABC_RESOURCE_H |
29 | #define KABC_RESOURCE_H | 29 | #define KABC_RESOURCE_H |
30 | 30 | ||
31 | #include <kresources/resource.h> | 31 | #include <kresources/resource.h> |
32 | 32 | ||
33 | |||
33 | #include "addressbook.h" | 34 | #include "addressbook.h" |
34 | 35 | ||
36 | class KSyncProfile; | ||
37 | |||
35 | namespace KABC { | 38 | namespace KABC { |
36 | 39 | ||
37 | /** | 40 | /** |
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. |
41 | * @see requestSaveTicket(), save(). | 44 | * @see requestSaveTicket(), save(). |
42 | */ | 45 | */ |
43 | class Ticket | 46 | class Ticket |
44 | { | 47 | { |
45 | friend class Resource; | 48 | friend class Resource; |
46 | public: | 49 | public: |
47 | Resource *resource() { return mResource; } | 50 | Resource *resource() { return mResource; } |
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; |
53 | }; | 56 | }; |
54 | 57 | ||
55 | /** | 58 | /** |
56 | * @internal | 59 | * @internal |
57 | */ | 60 | */ |
58 | class Resource : public KRES::Resource | 61 | 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: |
61 | /** | 70 | /** |
62 | * Constructor | 71 | * Constructor |
63 | */ | 72 | */ |
64 | Resource( const KConfig *config ); | 73 | Resource( const KConfig *config, bool syncable ); |
65 | 74 | ||
66 | /** | 75 | /** |
67 | * Destructor. | 76 | * Destructor. |
68 | */ | 77 | */ |
69 | virtual ~Resource(); | 78 | virtual ~Resource(); |
70 | 79 | ||
@@ -85,23 +94,19 @@ public: | |||
85 | 94 | ||
86 | /** | 95 | /** |
87 | * Open the resource and returns if it was successfully | 96 | * Open the resource and returns if it was successfully |
88 | */ | 97 | */ |
89 | virtual bool doOpen(); | 98 | virtual bool doOpen(); |
90 | 99 | ||
91 | /** | 100 | |
92 | * Close the resource and returns if it was successfully | ||
93 | */ | ||
94 | virtual void doClose(); | ||
95 | |||
96 | /** | 101 | /** |
97 | * Request a ticket, you have to pass through @ref save() to | 102 | * Request a ticket, you have to pass through @ref save() to |
98 | * allow locking. | 103 | * allow locking. |
99 | */ | 104 | */ |
100 | virtual Ticket *requestSaveTicket(); | 105 | virtual Ticket *requestSaveTicket(); |
101 | 106 | ||
102 | /** | 107 | /** |
103 | * Load all addressees to the addressbook | 108 | * Load all addressees to the addressbook |
104 | */ | 109 | */ |
105 | virtual bool load(); | 110 | virtual bool load(); |
106 | 111 | ||
107 | /** | 112 | /** |
@@ -114,21 +119,62 @@ public: | |||
114 | /** | 119 | /** |
115 | * Removes a addressee from resource. This method is mainly | 120 | * Removes a addressee from resource. This method is mainly |
116 | * used by record-based resources like LDAP or SQL. | 121 | * used by record-based resources like LDAP or SQL. |
117 | */ | 122 | */ |
118 | virtual void removeAddressee( const Addressee& addr ); | 123 | virtual void removeAddressee( const Addressee& addr ); |
119 | 124 | ||
125 | |||
120 | /** | 126 | /** |
121 | * This method is called by an error handler if the application | 127 | * This method is called by an error handler if the application |
122 | * crashed | 128 | * crashed |
123 | */ | 129 | */ |
124 | virtual void cleanUp(); | 130 | virtual void cleanUp(); |
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 | ||
129 | private: | 168 | 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 |