summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/addressbook.cpp17
-rw-r--r--kabc/addressbook.h6
-rw-r--r--kabc/kabc.pro4
-rw-r--r--kabc/kabcE.pro7
-rw-r--r--kabc/resource.cpp63
-rw-r--r--kabc/resource.h56
6 files changed, 135 insertions, 18 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 0838157..20310a0 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -207,46 +207,53 @@ bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
207{ 207{
208 return ( d->mIt == it.d->mIt ); 208 return ( d->mIt == it.d->mIt );
209} 209}
210 210
211bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 211bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
212{ 212{
213 return ( d->mIt != it.d->mIt ); 213 return ( d->mIt != it.d->mIt );
214} 214}
215 215
216 216
217AddressBook::AddressBook() 217AddressBook::AddressBook()
218{ 218{
219 init(0); 219 init(0, "contact");
220} 220}
221 221
222AddressBook::AddressBook( const QString &config ) 222AddressBook::AddressBook( const QString &config )
223{ 223{
224 init(config); 224 init(config, "contact");
225} 225}
226 226
227void AddressBook::init(const QString &config) 227AddressBook::AddressBook( const QString &config, const QString &family )
228{
229 init(config, family);
230
231}
232
233// the default family is "contact"
234void 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
244AddressBook::~AddressBook() 251AddressBook::~AddressBook()
245{ 252{
246 delete d->mConfig; d->mConfig = 0; 253 delete d->mConfig; d->mConfig = 0;
247 delete d->mManager; d->mManager = 0; 254 delete d->mManager; d->mManager = 0;
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
252bool AddressBook::load() 259bool AddressBook::load()
@@ -532,26 +539,24 @@ QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
532 539
533QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 540QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
534{ 541{
535 if (!ab.d) return s; 542 if (!ab.d) return s;
536 543
537 s >> ab.d->mAddressees; 544 s >> ab.d->mAddressees;
538 545
539 return s; 546 return s;
540} 547}
541 548
542bool AddressBook::addResource( Resource *resource ) 549bool 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 );
552 557
553 d->mManager->add( resource ); 558 d->mManager->add( resource );
554 return true; 559 return true;
555} 560}
556 561
557bool AddressBook::removeResource( Resource *resource ) 562bool AddressBook::removeResource( Resource *resource )
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 3a8e028..f89d7da 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -107,24 +107,25 @@ class AddressBook : public QObject
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
@@ -299,29 +300,28 @@ class AddressBook : public QObject
299 300
300 /** 301 /**
301 Emitted, when the address book has been unlocked. 302 Emitted, when the address book has been unlocked.
302 */ 303 */
303 void addressBookUnlocked( AddressBook * ); 304 void addressBookUnlocked( AddressBook * );
304 305
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
322QDataStream &operator<<( QDataStream &, const AddressBook & ); 322QDataStream &operator<<( QDataStream &, const AddressBook & );
323QDataStream &operator>>( QDataStream &, AddressBook & ); 323QDataStream &operator>>( QDataStream &, AddressBook & );
324 324
325} 325}
326 326
327#endif 327#endif
diff --git a/kabc/kabc.pro b/kabc/kabc.pro
index a8cd695..10b092c 100644
--- a/kabc/kabc.pro
+++ b/kabc/kabc.pro
@@ -1,22 +1,22 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3#release debug 3#release debug
4DESTDIR=../bin 4DESTDIR=../bin
5 5
6TARGET = microkabc 6TARGET = microkabc
7 7
8include( ../variables.pri ) 8include( ../variables.pri )
9 9
10INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat ../microkde/kdeui 10INCLUDEPATH += . ./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
13LIBS += -L$(QPEDIR)/lib 13LIBS += -L$(QPEDIR)/lib
14DEFINES += KAB_EMBEDDED DESKTOP_VERSION 14DEFINES += KAB_EMBEDDED DESKTOP_VERSION
15unix : { 15unix : {
16 16
17OBJECTS_DIR = obj/unix 17OBJECTS_DIR = obj/unix
18MOC_DIR = moc/unix 18MOC_DIR = moc/unix
19} 19}
20win32: { 20win32: {
21DEFINES += _WIN32_ 21DEFINES += _WIN32_
22OBJECTS_DIR = obj/win 22OBJECTS_DIR = obj/win
@@ -39,24 +39,25 @@ formatfactory.h \
39 formatplugin.h \ 39 formatplugin.h \
40 phonenumber.h \ 40 phonenumber.h \
41distributionlist.h \ 41distributionlist.h \
42distributionlistdialog.h \ 42distributionlistdialog.h \
43distributionlisteditor.h \ 43distributionlisteditor.h \
44vcardformatplugin.h \ 44vcardformatplugin.h \
45formats/vcardformatplugin2.h \ 45formats/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 \
57 plugins/file/resourcefileconfig.h \ 58 plugins/file/resourcefileconfig.h \
58 plugins/dir/resourcedir.h \ 59 plugins/dir/resourcedir.h \
59 plugins/dir/resourcedirconfig.h \ 60 plugins/dir/resourcedirconfig.h \
60 vcardparser/vcardline.h \ 61 vcardparser/vcardline.h \
61 vcardparser/vcard.h \ 62 vcardparser/vcard.h \
62 vcardparser/vcardtool.h \ 63 vcardparser/vcardtool.h \
@@ -148,24 +149,25 @@ formatfactory.cpp \
148 plugin.cpp \ 149 plugin.cpp \
149 agent.cpp \ 150 agent.cpp \
150 geo.cpp \ 151 geo.cpp \
151 key.cpp \ 152 key.cpp \
152 field.cpp \ 153 field.cpp \
153 address.cpp \ 154 address.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 \
166 plugins/file/resourcefile.cpp \ 168 plugins/file/resourcefile.cpp \
167 plugins/file/resourcefileconfig.cpp \ 169 plugins/file/resourcefileconfig.cpp \
168 plugins/dir/resourcedir.cpp \ 170 plugins/dir/resourcedir.cpp \
169 plugins/dir/resourcedirconfig.cpp \ 171 plugins/dir/resourcedirconfig.cpp \
170 vcardparser/vcardline.cpp \ 172 vcardparser/vcardline.cpp \
171 vcardparser/vcard.cpp \ 173 vcardparser/vcard.cpp \
diff --git a/kabc/kabcE.pro b/kabc/kabcE.pro
index bc1c0ed..598d4fc 100644
--- a/kabc/kabcE.pro
+++ b/kabc/kabcE.pro
@@ -1,22 +1,23 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3TARGET = microkabc 3TARGET = microkabc
4 4
5 5
6INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../qtcompat $(QPEDIR)/include 6INCLUDEPATH += . ./vcard/include ./vcard/include/generated ../microkde ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim ../qtcompat $(QPEDIR)/include
7OBJECTS_DIR = obj/$(PLATFORM) 7OBJECTS_DIR = obj/$(PLATFORM)
8MOC_DIR = moc/$(PLATFORM) 8MOC_DIR = moc/$(PLATFORM)
9DESTDIR = $(QPEDIR)/lib 9DESTDIR = $(QPEDIR)/lib
10LIBS += -lmicrokde 10LIBS += -lmicrokde
11LIBS += -lmicrokdepim
11#LIBS += -lldap 12#LIBS += -lldap
12LIBS += -L$(QPEDIR)/lib 13LIBS += -L$(QPEDIR)/lib
13DEFINES += KAB_EMBEDDED 14DEFINES += KAB_EMBEDDED
14 15
15INTERFACES = \ 16INTERFACES = \
16 17
17HEADERS = \ 18HEADERS = \
18 address.h \ 19 address.h \
19 addressbook.h \ 20 addressbook.h \
20 addressee.h \ 21 addressee.h \
21 addresseedialog.h \ 22 addresseedialog.h \
22 addresseelist.h \ 23 addresseelist.h \
@@ -27,25 +28,27 @@ HEADERS = \
27 field.h \ 28 field.h \
28 formatfactory.h \ 29 formatfactory.h \
29 formatplugin.h \ 30 formatplugin.h \
30 geo.h \ 31 geo.h \
31 key.h \ 32 key.h \
32 phonenumber.h \ 33 phonenumber.h \
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 \
46 vcardparser/vcardtool.h \ 49 vcardparser/vcardtool.h \
47 vcardparser/vcardparser.h \ 50 vcardparser/vcardparser.h \
48 vcard/include/VCardAdrParam.h \ 51 vcard/include/VCardAdrParam.h \
49 vcard/include/VCardAdrValue.h \ 52 vcard/include/VCardAdrValue.h \
50 vcard/include/VCardAgentParam.h \ 53 vcard/include/VCardAgentParam.h \
51 vcard/include/VCardContentLine.h \ 54 vcard/include/VCardContentLine.h \
@@ -129,25 +132,27 @@ SOURCES = \
129 distributionlisteditor.cpp \ 132 distributionlisteditor.cpp \
130 field.cpp \ 133 field.cpp \
131 formatfactory.cpp \ 134 formatfactory.cpp \
132 geo.cpp \ 135 geo.cpp \
133 key.cpp \ 136 key.cpp \
134 phonenumber.cpp \ 137 phonenumber.cpp \
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 \
148 vcardparser/vcardtool.cpp \ 153 vcardparser/vcardtool.cpp \
149 vcardparser/vcardparser.cpp \ 154 vcardparser/vcardparser.cpp \
150vcard/AdrParam.cpp \ 155vcard/AdrParam.cpp \
151vcard/AdrValue.cpp \ 156vcard/AdrValue.cpp \
152vcard/AgentParam.cpp \ 157vcard/AgentParam.cpp \
153vcard/ContentLine.cpp \ 158vcard/ContentLine.cpp \
diff --git a/kabc/resource.cpp b/kabc/resource.cpp
index 9a1a5f8..9632a3f 100644
--- a/kabc/resource.cpp
+++ b/kabc/resource.cpp
@@ -18,42 +18,56 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (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
32using namespace KABC; 34using namespace KABC;
33 35
34Resource::Resource( const KConfig *config ) 36Resource::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
39Resource::~Resource() 46Resource::~Resource()
40{ 47{
48 if (mSyncProfile != 0) {
49 delete mSyncProfile;
50 }
41} 51}
42 52
43void Resource::writeConfig( KConfig *config ) 53void 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
48void Resource::setAddressBook( AddressBook *ab ) 62void Resource::setAddressBook( AddressBook *ab )
49{ 63{
50 mAddressBook = ab; 64 mAddressBook = ab;
51} 65}
52 66
53AddressBook *Resource::addressBook() 67AddressBook *Resource::addressBook()
54{ 68{
55 return mAddressBook; 69 return mAddressBook;
56} 70}
57 71
58bool Resource::doOpen() 72bool Resource::doOpen()
59{ 73{
@@ -84,12 +98,57 @@ Ticket *Resource::createTicket( Resource *resource )
84 return new Ticket( resource ); 98 return new Ticket( resource );
85} 99}
86 100
87void Resource::removeAddressee( const Addressee& ) 101void Resource::removeAddressee( const Addressee& )
88{ 102{
89 // do nothing 103 // do nothing
90} 104}
91 105
92void Resource::cleanUp() 106void Resource::cleanUp()
93{ 107{
94 // do nothing 108 // do nothing
95} 109}
110
111bool 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 */
119int Resource::count() const
120{
121 return 0;
122}
123
124/**
125 * This method removes all elements from the resource!! (Not from the addressbook)
126 */
127bool Resource::clear()
128{
129 return false;
130}
131
132QString Resource::fileName() const
133{
134 return mFileName;
135}
136
137void 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 */
146void 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
@@ -21,26 +21,29 @@
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
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
36class KSyncProfile;
37
35namespace KABC { 38namespace 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 */
43class Ticket 46class Ticket
44{ 47{
45 friend class Resource; 48 friend class Resource;
46 public: 49 public:
@@ -48,29 +51,35 @@ 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;
53}; 56};
54 57
55/** 58/**
56 * @internal 59 * @internal
57 */ 60 */
58class Resource : public KRES::Resource 61class Resource : public KRES::Resource
59{ 62{
63private:
64 /**
65 * make this constructor private to force everybody to use the other one
66 */
67 Resource( const KConfig *config);
68
60public: 69public:
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
71 /** 80 /**
72 * Sets the address book of the resource. 81 * Sets the address book of the resource.
73 */ 82 */
74 void setAddressBook( AddressBook* ); 83 void setAddressBook( AddressBook* );
75 84
76 /** 85 /**
@@ -79,28 +88,24 @@ public:
79 AddressBook *addressBook(); 88 AddressBook *addressBook();
80 89
81 /** 90 /**
82 * Writes the resource specific config to file. 91 * Writes the resource specific config to file.
83 */ 92 */
84 virtual void writeConfig( KConfig *config ); 93 virtual void writeConfig( KConfig *config );
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 /**
92 * Close the resource and returns if it was successfully
93 */
94 virtual void doClose();
95 100
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
@@ -108,27 +113,68 @@ public:
108 * Save all addressees to the addressbook. 113 * Save all addressees to the addressbook.
109 * 114 *
110 * @param ticket The ticket you get by @ref requestSaveTicket() 115 * @param ticket The ticket you get by @ref requestSaveTicket()
111 */ 116 */
112 virtual bool save( Ticket *ticket ); 117 virtual bool save( Ticket *ticket );
113 118
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
126protected: 164protected:
127 Ticket *createTicket( Resource * ); 165 Ticket *createTicket( Resource * );
166 virtual void doClose();
128 167
129private: 168private:
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