-rw-r--r-- | kabc/resource.h | 66 |
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 | |||
@@ -1,134 +1,180 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
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 | #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 | ||
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 | /** |
77 | * Returns a pointer to the addressbook. | 86 | * Returns a pointer to the addressbook. |
78 | */ | 87 | */ |
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 | /** | 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 | /** |
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 | |||
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 |