-rw-r--r-- | kabc/resource.h | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/kabc/resource.h b/kabc/resource.h index db806a6..7d42f81 100644 --- a/kabc/resource.h +++ b/kabc/resource.h | |||
@@ -4,177 +4,166 @@ | |||
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (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 | ||
34 | #include "addressbook.h" | 34 | #include "addressbook.h" |
35 | 35 | ||
36 | class KSyncProfile; | 36 | class KSyncProfile; |
37 | 37 | ||
38 | namespace KABC { | 38 | namespace KABC { |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * @short Helper class for handling coordinated save of address books. | 41 | * @short Helper class for handling coordinated save of address books. |
42 | * | 42 | * |
43 | * This class is used as helper class for saving address book. | 43 | * This class is used as helper class for saving address book. |
44 | * @see requestSaveTicket(), save(). | 44 | * @see requestSaveTicket(), save(). |
45 | */ | 45 | */ |
46 | class Ticket | 46 | class Ticket |
47 | { | 47 | { |
48 | friend class Resource; | 48 | friend class Resource; |
49 | public: | 49 | public: |
50 | Resource *resource() { return mResource; } | 50 | Resource *resource() { return mResource; } |
51 | 51 | ||
52 | private: | 52 | private: |
53 | Ticket( Resource *resource ) : mResource( resource ) {} | 53 | Ticket( Resource *resource ) : mResource( resource ) {} |
54 | 54 | ||
55 | Resource *mResource; | 55 | Resource *mResource; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * @internal | 59 | * @internal |
60 | */ | 60 | */ |
61 | class Resource : public KRES::Resource | 61 | class Resource : public KRES::Resource |
62 | { | 62 | { |
63 | private: | 63 | private: |
64 | /** | 64 | /** |
65 | * make this constructor private to force everybody to use the other one | 65 | * make this constructor private to force everybody to use the other one |
66 | */ | 66 | */ |
67 | Resource( const KConfig *config); | 67 | Resource( const KConfig *config); |
68 | 68 | ||
69 | public: | 69 | public: |
70 | /** | 70 | /** |
71 | * Constructor | 71 | * Constructor |
72 | */ | 72 | */ |
73 | Resource( const KConfig *config, bool syncable ); | 73 | Resource( const KConfig *config, bool syncable ); |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Destructor. | 76 | * Destructor. |
77 | */ | 77 | */ |
78 | virtual ~Resource(); | 78 | virtual ~Resource(); |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * Sets the address book of the resource. | 81 | * Sets the address book of the resource. |
82 | */ | 82 | */ |
83 | void setAddressBook( AddressBook* ); | 83 | void setAddressBook( AddressBook* ); |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Returns a pointer to the addressbook. | 86 | * Returns a pointer to the addressbook. |
87 | */ | 87 | */ |
88 | AddressBook *addressBook(); | 88 | AddressBook *addressBook(); |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Writes the resource specific config to file. | 91 | * Writes the resource specific config to file. |
92 | */ | 92 | */ |
93 | virtual void writeConfig( KConfig *config ); | 93 | virtual void writeConfig( KConfig *config ); |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * Open the resource and returns if it was successfully | 96 | * Open the resource and returns if it was successfully |
97 | */ | 97 | */ |
98 | virtual bool doOpen(); | 98 | virtual bool doOpen(); |
99 | 99 | ||
100 | 100 | ||
101 | /** | 101 | /** |
102 | * Request a ticket, you have to pass through @ref save() to | 102 | * Request a ticket, you have to pass through @ref save() to |
103 | * allow locking. | 103 | * allow locking. |
104 | */ | 104 | */ |
105 | virtual Ticket *requestSaveTicket(); | 105 | virtual Ticket *requestSaveTicket(); |
106 | 106 | ||
107 | /** | 107 | /** |
108 | * Load all addressees to the addressbook | 108 | * Load all addressees to the addressbook |
109 | */ | 109 | */ |
110 | virtual bool load(); | 110 | virtual bool load(); |
111 | 111 | ||
112 | /** | 112 | /** |
113 | * Save all addressees to the addressbook. | 113 | * Save all addressees to the addressbook. |
114 | * | 114 | * |
115 | * @param ticket The ticket you get by @ref requestSaveTicket() | 115 | * @param ticket The ticket you get by @ref requestSaveTicket() |
116 | */ | 116 | */ |
117 | virtual bool save( Ticket *ticket ); | 117 | virtual bool save( Ticket *ticket ); |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * Removes a addressee from resource. This method is mainly | 120 | * Removes a addressee from resource. This method is mainly |
121 | * used by record-based resources like LDAP or SQL. | 121 | * used by record-based resources like LDAP or SQL. |
122 | */ | 122 | */ |
123 | virtual void removeAddressee( const Addressee& addr ); | 123 | virtual void removeAddressee( const Addressee& addr ); |
124 | 124 | ||
125 | 125 | ||
126 | /** | 126 | /** |
127 | * This method is called by an error handler if the application | 127 | * This method is called by an error handler if the application |
128 | * crashed | 128 | * crashed |
129 | */ | 129 | */ |
130 | virtual void cleanUp(); | 130 | virtual void cleanUp(); |
131 | 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 | /** | 132 | /** |
144 | * Set name of file to be used for saving. | 133 | * Set name of file to be used for saving. |
145 | */ | 134 | */ |
146 | virtual void setFileName( const QString & ); | 135 | virtual void setFileName( const QString & ); |
147 | 136 | ||
148 | /** | 137 | /** |
149 | * Return name of file used for loading and saving the address book. | 138 | * Return name of file used for loading and saving the address book. |
150 | */ | 139 | */ |
151 | virtual QString fileName() const; | 140 | virtual QString fileName() const; |
152 | 141 | ||
153 | 142 | ||
154 | virtual bool isSyncable() const; | 143 | virtual bool isSyncable() const; |
155 | 144 | ||
156 | /** | 145 | /** |
157 | * Set the name of resource.You can override this method, | 146 | * Set the name of resource.You can override this method, |
158 | * but also remember to call Resource::setResourceName(). | 147 | * but also remember to call Resource::setResourceName(). |
159 | */ | 148 | */ |
160 | virtual void setResourceName( const QString &name ); | 149 | virtual void setResourceName( const QString &name ); |
161 | 150 | ||
162 | 151 | ||
163 | 152 | ||
164 | protected: | 153 | protected: |
165 | Ticket *createTicket( Resource * ); | 154 | Ticket *createTicket( Resource * ); |
166 | virtual void doClose(); | 155 | virtual void doClose(); |
167 | 156 | ||
168 | private: | 157 | private: |
169 | AddressBook *mAddressBook; | 158 | AddressBook *mAddressBook; |
170 | KSyncProfile *mSyncProfile; | 159 | KSyncProfile *mSyncProfile; |
171 | QString mFileName; | 160 | QString mFileName; |
172 | 161 | ||
173 | }; | 162 | }; |
174 | 163 | ||
175 | 164 | ||
176 | } | 165 | } |
177 | 166 | ||
178 | 167 | ||
179 | 168 | ||
180 | #endif | 169 | #endif |