summaryrefslogtreecommitdiffabout
path: root/kabc/resource.h
authorulf69 <ulf69>2004-08-02 18:33:07 (UTC)
committer ulf69 <ulf69>2004-08-02 18:33:07 (UTC)
commit60a6886f06be31ec690df34dc8e3b8931c2d3bd7 (patch) (unidiff)
treec4c7c15cfd3753a3342806a11fb8f5c20bb4f923 /kabc/resource.h
parent863c4c3678e59ef125c08c00e9532ded5b540f67 (diff)
downloadkdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.zip
kdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.tar.gz
kdepimpi-60a6886f06be31ec690df34dc8e3b8931c2d3bd7.tar.bz2
added support for syncable resources
Diffstat (limited to 'kabc/resource.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/resource.h66
1 files changed, 56 insertions, 10 deletions
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
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:
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 */
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
@@ -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
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