summaryrefslogtreecommitdiffabout
path: root/kabc/resource.h
Unidiff
Diffstat (limited to 'kabc/resource.h') (more/less context) (show whitespace changes)
-rw-r--r--kabc/resource.h56
1 files changed, 51 insertions, 5 deletions
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