-rw-r--r-- | kabc/addressbook.cpp | 4 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 10 | ||||
-rw-r--r-- | kabc/addressee.h | 10 |
4 files changed, 13 insertions, 13 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 4de7da2..9e61261 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,1266 +1,1266 @@ | |||
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 | /*US | 28 | /*US |
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kinstance.h> | 35 | #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | #include "errorhandler.h" | 38 | #include "errorhandler.h" |
39 | */ | 39 | */ |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | 44 | ||
45 | #include <kglobal.h> | 45 | #include <kglobal.h> |
46 | #include <klocale.h> | 46 | #include <klocale.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kdebug.h> | 48 | #include <kdebug.h> |
49 | #include <libkcal/syncdefines.h> | 49 | #include <libkcal/syncdefines.h> |
50 | #include <libkdepim/phoneaccess.h> | 50 | #include <libkdepim/phoneaccess.h> |
51 | #include "addressbook.h" | 51 | #include "addressbook.h" |
52 | #include "resource.h" | 52 | #include "resource.h" |
53 | #include "vcardconverter.h" | 53 | #include "vcardconverter.h" |
54 | #include "vcardparser/vcardtool.h" | 54 | #include "vcardparser/vcardtool.h" |
55 | 55 | ||
56 | //US #include "addressbook.moc" | 56 | //US #include "addressbook.moc" |
57 | 57 | ||
58 | using namespace KABC; | 58 | using namespace KABC; |
59 | 59 | ||
60 | struct AddressBook::AddressBookData | 60 | struct AddressBook::AddressBookData |
61 | { | 61 | { |
62 | Addressee::List mAddressees; | 62 | Addressee::List mAddressees; |
63 | Addressee::List mRemovedAddressees; | 63 | Addressee::List mRemovedAddressees; |
64 | Field::List mAllFields; | 64 | Field::List mAllFields; |
65 | KConfig *mConfig; | 65 | KConfig *mConfig; |
66 | KRES::Manager<Resource> *mManager; | 66 | KRES::Manager<Resource> *mManager; |
67 | //US ErrorHandler *mErrorHandler; | 67 | //US ErrorHandler *mErrorHandler; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | struct AddressBook::Iterator::IteratorData | 70 | struct AddressBook::Iterator::IteratorData |
71 | { | 71 | { |
72 | Addressee::List::Iterator mIt; | 72 | Addressee::List::Iterator mIt; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | struct AddressBook::ConstIterator::ConstIteratorData | 75 | struct AddressBook::ConstIterator::ConstIteratorData |
76 | { | 76 | { |
77 | Addressee::List::ConstIterator mIt; | 77 | Addressee::List::ConstIterator mIt; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | AddressBook::Iterator::Iterator() | 80 | AddressBook::Iterator::Iterator() |
81 | { | 81 | { |
82 | d = new IteratorData; | 82 | d = new IteratorData; |
83 | } | 83 | } |
84 | 84 | ||
85 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 85 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
86 | { | 86 | { |
87 | d = new IteratorData; | 87 | d = new IteratorData; |
88 | d->mIt = i.d->mIt; | 88 | d->mIt = i.d->mIt; |
89 | } | 89 | } |
90 | 90 | ||
91 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 91 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
92 | { | 92 | { |
93 | if( this == &i ) return *this; // guard against self assignment | 93 | if( this == &i ) return *this; // guard against self assignment |
94 | delete d; // delete the old data the Iterator was completely constructed before | 94 | delete d; // delete the old data the Iterator was completely constructed before |
95 | d = new IteratorData; | 95 | d = new IteratorData; |
96 | d->mIt = i.d->mIt; | 96 | d->mIt = i.d->mIt; |
97 | return *this; | 97 | return *this; |
98 | } | 98 | } |
99 | 99 | ||
100 | AddressBook::Iterator::~Iterator() | 100 | AddressBook::Iterator::~Iterator() |
101 | { | 101 | { |
102 | delete d; | 102 | delete d; |
103 | } | 103 | } |
104 | 104 | ||
105 | const Addressee &AddressBook::Iterator::operator*() const | 105 | const Addressee &AddressBook::Iterator::operator*() const |
106 | { | 106 | { |
107 | return *(d->mIt); | 107 | return *(d->mIt); |
108 | } | 108 | } |
109 | 109 | ||
110 | Addressee &AddressBook::Iterator::operator*() | 110 | Addressee &AddressBook::Iterator::operator*() |
111 | { | 111 | { |
112 | return *(d->mIt); | 112 | return *(d->mIt); |
113 | } | 113 | } |
114 | 114 | ||
115 | Addressee *AddressBook::Iterator::operator->() | 115 | Addressee *AddressBook::Iterator::operator->() |
116 | { | 116 | { |
117 | return &(*(d->mIt)); | 117 | return &(*(d->mIt)); |
118 | } | 118 | } |
119 | 119 | ||
120 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 120 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
121 | { | 121 | { |
122 | (d->mIt)++; | 122 | (d->mIt)++; |
123 | return *this; | 123 | return *this; |
124 | } | 124 | } |
125 | 125 | ||
126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
127 | { | 127 | { |
128 | (d->mIt)++; | 128 | (d->mIt)++; |
129 | return *this; | 129 | return *this; |
130 | } | 130 | } |
131 | 131 | ||
132 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 132 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
133 | { | 133 | { |
134 | (d->mIt)--; | 134 | (d->mIt)--; |
135 | return *this; | 135 | return *this; |
136 | } | 136 | } |
137 | 137 | ||
138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
139 | { | 139 | { |
140 | (d->mIt)--; | 140 | (d->mIt)--; |
141 | return *this; | 141 | return *this; |
142 | } | 142 | } |
143 | 143 | ||
144 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 144 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
145 | { | 145 | { |
146 | return ( d->mIt == it.d->mIt ); | 146 | return ( d->mIt == it.d->mIt ); |
147 | } | 147 | } |
148 | 148 | ||
149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
150 | { | 150 | { |
151 | return ( d->mIt != it.d->mIt ); | 151 | return ( d->mIt != it.d->mIt ); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | AddressBook::ConstIterator::ConstIterator() | 155 | AddressBook::ConstIterator::ConstIterator() |
156 | { | 156 | { |
157 | d = new ConstIteratorData; | 157 | d = new ConstIteratorData; |
158 | } | 158 | } |
159 | 159 | ||
160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
161 | { | 161 | { |
162 | d = new ConstIteratorData; | 162 | d = new ConstIteratorData; |
163 | d->mIt = i.d->mIt; | 163 | d->mIt = i.d->mIt; |
164 | } | 164 | } |
165 | 165 | ||
166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
167 | { | 167 | { |
168 | if( this == &i ) return *this; // guard for self assignment | 168 | if( this == &i ) return *this; // guard for self assignment |
169 | delete d; // delete the old data because the Iterator was really constructed before | 169 | delete d; // delete the old data because the Iterator was really constructed before |
170 | d = new ConstIteratorData; | 170 | d = new ConstIteratorData; |
171 | d->mIt = i.d->mIt; | 171 | d->mIt = i.d->mIt; |
172 | return *this; | 172 | return *this; |
173 | } | 173 | } |
174 | 174 | ||
175 | AddressBook::ConstIterator::~ConstIterator() | 175 | AddressBook::ConstIterator::~ConstIterator() |
176 | { | 176 | { |
177 | delete d; | 177 | delete d; |
178 | } | 178 | } |
179 | 179 | ||
180 | const Addressee &AddressBook::ConstIterator::operator*() const | 180 | const Addressee &AddressBook::ConstIterator::operator*() const |
181 | { | 181 | { |
182 | return *(d->mIt); | 182 | return *(d->mIt); |
183 | } | 183 | } |
184 | 184 | ||
185 | const Addressee* AddressBook::ConstIterator::operator->() const | 185 | const Addressee* AddressBook::ConstIterator::operator->() const |
186 | { | 186 | { |
187 | return &(*(d->mIt)); | 187 | return &(*(d->mIt)); |
188 | } | 188 | } |
189 | 189 | ||
190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
191 | { | 191 | { |
192 | (d->mIt)++; | 192 | (d->mIt)++; |
193 | return *this; | 193 | return *this; |
194 | } | 194 | } |
195 | 195 | ||
196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
197 | { | 197 | { |
198 | (d->mIt)++; | 198 | (d->mIt)++; |
199 | return *this; | 199 | return *this; |
200 | } | 200 | } |
201 | 201 | ||
202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
203 | { | 203 | { |
204 | (d->mIt)--; | 204 | (d->mIt)--; |
205 | return *this; | 205 | return *this; |
206 | } | 206 | } |
207 | 207 | ||
208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
209 | { | 209 | { |
210 | (d->mIt)--; | 210 | (d->mIt)--; |
211 | return *this; | 211 | return *this; |
212 | } | 212 | } |
213 | 213 | ||
214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
215 | { | 215 | { |
216 | return ( d->mIt == it.d->mIt ); | 216 | return ( d->mIt == it.d->mIt ); |
217 | } | 217 | } |
218 | 218 | ||
219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
220 | { | 220 | { |
221 | return ( d->mIt != it.d->mIt ); | 221 | return ( d->mIt != it.d->mIt ); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | AddressBook::AddressBook() | 225 | AddressBook::AddressBook() |
226 | { | 226 | { |
227 | init(0, "contact"); | 227 | init(0, "contact"); |
228 | } | 228 | } |
229 | 229 | ||
230 | AddressBook::AddressBook( const QString &config ) | 230 | AddressBook::AddressBook( const QString &config ) |
231 | { | 231 | { |
232 | init(config, "contact"); | 232 | init(config, "contact"); |
233 | } | 233 | } |
234 | 234 | ||
235 | AddressBook::AddressBook( const QString &config, const QString &family ) | 235 | AddressBook::AddressBook( const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | init(config, family); | 237 | init(config, family); |
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | // the default family is "contact" | 241 | // the default family is "contact" |
242 | void AddressBook::init(const QString &config, const QString &family ) | 242 | void AddressBook::init(const QString &config, const QString &family ) |
243 | { | 243 | { |
244 | blockLSEchange = false; | 244 | blockLSEchange = false; |
245 | d = new AddressBookData; | 245 | d = new AddressBookData; |
246 | QString fami = family; | 246 | QString fami = family; |
247 | if (config != 0) { | 247 | if (config != 0) { |
248 | if ( family == "syncContact" ) { | 248 | if ( family == "syncContact" ) { |
249 | qDebug("creating sync config "); | 249 | qDebug("creating sync config "); |
250 | fami = "contact"; | 250 | fami = "contact"; |
251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
252 | con->setGroup( "General" ); | 252 | con->setGroup( "General" ); |
253 | con->writeEntry( "ResourceKeys", QString("sync") ); | 253 | con->writeEntry( "ResourceKeys", QString("sync") ); |
254 | con->writeEntry( "Standard", QString("sync") ); | 254 | con->writeEntry( "Standard", QString("sync") ); |
255 | con->setGroup( "Resource_sync" ); | 255 | con->setGroup( "Resource_sync" ); |
256 | con->writeEntry( "FileName", config ); | 256 | con->writeEntry( "FileName", config ); |
257 | con->writeEntry( "FileFormat", QString("vcard") ); | 257 | con->writeEntry( "FileFormat", QString("vcard") ); |
258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
259 | con->writeEntry( "ResourceName", QString("sync_res") ); | 259 | con->writeEntry( "ResourceName", QString("sync_res") ); |
260 | if ( config.right(4) == ".xml" ) | 260 | if ( config.right(4) == ".xml" ) |
261 | con->writeEntry( "ResourceType", QString("qtopia") ); | 261 | con->writeEntry( "ResourceType", QString("qtopia") ); |
262 | else if ( config == "sharp" ) { | 262 | else if ( config == "sharp" ) { |
263 | con->writeEntry( "ResourceType", QString("sharp") ); | 263 | con->writeEntry( "ResourceType", QString("sharp") ); |
264 | } else { | 264 | } else { |
265 | con->writeEntry( "ResourceType", QString("file") ); | 265 | con->writeEntry( "ResourceType", QString("file") ); |
266 | } | 266 | } |
267 | //con->sync(); | 267 | //con->sync(); |
268 | d->mConfig = con; | 268 | d->mConfig = con; |
269 | } | 269 | } |
270 | else | 270 | else |
271 | d->mConfig = new KConfig( locateLocal("config", config) ); | 271 | d->mConfig = new KConfig( locateLocal("config", config) ); |
272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
273 | } | 273 | } |
274 | else { | 274 | else { |
275 | d->mConfig = 0; | 275 | d->mConfig = 0; |
276 | // qDebug("AddressBook::init 1 config=0"); | 276 | // qDebug("AddressBook::init 1 config=0"); |
277 | } | 277 | } |
278 | 278 | ||
279 | //US d->mErrorHandler = 0; | 279 | //US d->mErrorHandler = 0; |
280 | d->mManager = new KRES::Manager<Resource>( fami ); | 280 | d->mManager = new KRES::Manager<Resource>( fami ); |
281 | d->mManager->readConfig( d->mConfig ); | 281 | d->mManager->readConfig( d->mConfig ); |
282 | if ( family == "syncContact" ) { | 282 | if ( family == "syncContact" ) { |
283 | KRES::Manager<Resource> *manager = d->mManager; | 283 | KRES::Manager<Resource> *manager = d->mManager; |
284 | KRES::Manager<Resource>::ActiveIterator it; | 284 | KRES::Manager<Resource>::ActiveIterator it; |
285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
286 | (*it)->setAddressBook( this ); | 286 | (*it)->setAddressBook( this ); |
287 | if ( !(*it)->open() ) | 287 | if ( !(*it)->open() ) |
288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
289 | } | 289 | } |
290 | Resource *res = standardResource(); | 290 | Resource *res = standardResource(); |
291 | if ( !res ) { | 291 | if ( !res ) { |
292 | qDebug("ERROR: no standard resource"); | 292 | qDebug("ERROR: no standard resource"); |
293 | res = manager->createResource( "file" ); | 293 | res = manager->createResource( "file" ); |
294 | if ( res ) | 294 | if ( res ) |
295 | { | 295 | { |
296 | addResource( res ); | 296 | addResource( res ); |
297 | } | 297 | } |
298 | else | 298 | else |
299 | qDebug(" No resource available!!!"); | 299 | qDebug(" No resource available!!!"); |
300 | } | 300 | } |
301 | setStandardResource( res ); | 301 | setStandardResource( res ); |
302 | manager->writeConfig(); | 302 | manager->writeConfig(); |
303 | } | 303 | } |
304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
305 | "X-Department", "KADDRESSBOOK" ); | 305 | "X-Department", "KADDRESSBOOK" ); |
306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
307 | "X-Profession", "KADDRESSBOOK" ); | 307 | "X-Profession", "KADDRESSBOOK" ); |
308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
309 | "X-AssistantsName", "KADDRESSBOOK" ); | 309 | "X-AssistantsName", "KADDRESSBOOK" ); |
310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
311 | "X-ManagersName", "KADDRESSBOOK" ); | 311 | "X-ManagersName", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
313 | "X-SpousesName", "KADDRESSBOOK" ); | 313 | "X-SpousesName", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
315 | "X-Office", "KADDRESSBOOK" ); | 315 | "X-Office", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
317 | "X-IMAddress", "KADDRESSBOOK" ); | 317 | "X-IMAddress", "KADDRESSBOOK" ); |
318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
319 | "X-Anniversary", "KADDRESSBOOK" ); | 319 | "X-Anniversary", "KADDRESSBOOK" ); |
320 | 320 | ||
321 | //US added this field to become compatible with Opie/qtopia addressbook | 321 | //US added this field to become compatible with Opie/qtopia addressbook |
322 | // values can be "female" or "male" or "". An empty field represents undefined. | 322 | // values can be "female" or "male" or "". An empty field represents undefined. |
323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
324 | "X-Gender", "KADDRESSBOOK" ); | 324 | "X-Gender", "KADDRESSBOOK" ); |
325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
326 | "X-Children", "KADDRESSBOOK" ); | 326 | "X-Children", "KADDRESSBOOK" ); |
327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
330 | "X-ExternalID", "KADDRESSBOOK" ); | 330 | "X-ExternalID", "KADDRESSBOOK" ); |
331 | } | 331 | } |
332 | 332 | ||
333 | AddressBook::~AddressBook() | 333 | AddressBook::~AddressBook() |
334 | { | 334 | { |
335 | delete d->mConfig; d->mConfig = 0; | 335 | delete d->mConfig; d->mConfig = 0; |
336 | delete d->mManager; d->mManager = 0; | 336 | delete d->mManager; d->mManager = 0; |
337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
338 | delete d; d = 0; | 338 | delete d; d = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | bool AddressBook::load() | 341 | bool AddressBook::load() |
342 | { | 342 | { |
343 | 343 | ||
344 | clear(); | 344 | clear(); |
345 | KRES::Manager<Resource>::ActiveIterator it; | 345 | KRES::Manager<Resource>::ActiveIterator it; |
346 | bool ok = true; | 346 | bool ok = true; |
347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
348 | if ( !(*it)->load() ) { | 348 | if ( !(*it)->load() ) { |
349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } else { | 351 | } else { |
352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); | 352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); |
353 | } | 353 | } |
354 | // mark all addressees as unchanged | 354 | // mark all addressees as unchanged |
355 | Addressee::List::Iterator addrIt; | 355 | Addressee::List::Iterator addrIt; |
356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
357 | (*addrIt).setChanged( false ); | 357 | (*addrIt).setChanged( false ); |
358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
359 | if ( !id.isEmpty() ) { | 359 | if ( !id.isEmpty() ) { |
360 | //qDebug("setId aa %s ", id.latin1()); | 360 | //qDebug("setId aa %s ", id.latin1()); |
361 | (*addrIt).setIDStr(id ); | 361 | (*addrIt).setIDStr(id ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | blockLSEchange = true; | 364 | blockLSEchange = true; |
365 | return ok; | 365 | return ok; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool AddressBook::save( Ticket *ticket ) | 368 | bool AddressBook::save( Ticket *ticket ) |
369 | { | 369 | { |
370 | kdDebug(5700) << "AddressBook::save()"<< endl; | 370 | kdDebug(5700) << "AddressBook::save()"<< endl; |
371 | 371 | ||
372 | if ( ticket->resource() ) { | 372 | if ( ticket->resource() ) { |
373 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
374 | return ticket->resource()->save( ticket ); | 374 | return ticket->resource()->save( ticket ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return false; | 377 | return false; |
378 | } | 378 | } |
379 | // exports all Addressees, which are syncable | 379 | // exports all Addressees, which are syncable |
380 | void AddressBook::export2File( QString fileName ) | 380 | void AddressBook::export2File( QString fileName ) |
381 | { | 381 | { |
382 | 382 | ||
383 | QFile outFile( fileName ); | 383 | QFile outFile( fileName ); |
384 | if ( !outFile.open( IO_WriteOnly ) ) { | 384 | if ( !outFile.open( IO_WriteOnly ) ) { |
385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
386 | KMessageBox::error( 0, text.arg( fileName ) ); | 386 | KMessageBox::error( 0, text.arg( fileName ) ); |
387 | return ; | 387 | return ; |
388 | } | 388 | } |
389 | QTextStream t( &outFile ); | 389 | QTextStream t( &outFile ); |
390 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 390 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
391 | Iterator it; | 391 | Iterator it; |
392 | KABC::VCardConverter::Version version; | 392 | KABC::VCardConverter::Version version; |
393 | version = KABC::VCardConverter::v3_0; | 393 | version = KABC::VCardConverter::v3_0; |
394 | for ( it = begin(); it != end(); ++it ) { | 394 | for ( it = begin(); it != end(); ++it ) { |
395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { | 395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { |
396 | if ( !(*it).IDStr().isEmpty() ) { | 396 | if ( !(*it).IDStr().isEmpty() ) { |
397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
398 | } | 398 | } |
399 | KABC::VCardConverter converter; | 399 | KABC::VCardConverter converter; |
400 | QString vcard; | 400 | QString vcard; |
401 | //Resource *resource() const; | 401 | //Resource *resource() const; |
402 | converter.addresseeToVCard( *it, vcard, version ); | 402 | converter.addresseeToVCard( *it, vcard, version ); |
403 | t << vcard << "\r\n"; | 403 | t << vcard << "\r\n"; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | t << "\r\n\r\n"; | 406 | t << "\r\n\r\n"; |
407 | outFile.close(); | 407 | outFile.close(); |
408 | } | 408 | } |
409 | // if QStringList uids is empty, all are exported | 409 | // if QStringList uids is empty, all are exported |
410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | 410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) |
411 | { | 411 | { |
412 | KABC::VCardConverter converter; | 412 | KABC::VCardConverter converter; |
413 | QString datastream; | 413 | QString datastream; |
414 | Iterator it; | 414 | Iterator it; |
415 | bool all = uids.isEmpty(); | 415 | bool all = uids.isEmpty(); |
416 | for ( it = begin(); it != end(); ++it ) { | 416 | for ( it = begin(); it != end(); ++it ) { |
417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
418 | if ( ! all ) { | 418 | if ( ! all ) { |
419 | if ( ! ( uids.contains((*it).uid() ) )) | 419 | if ( ! ( uids.contains((*it).uid() ) )) |
420 | continue; | 420 | continue; |
421 | } | 421 | } |
422 | KABC::Addressee a = ( *it ); | 422 | KABC::Addressee a = ( *it ); |
423 | if ( a.isEmpty() ) | 423 | if ( a.isEmpty() ) |
424 | continue; | 424 | continue; |
425 | if ( all && a.resource() && !a.resource()->includeInSync() ) | 425 | if ( all && a.resource() && !a.resource()->includeInSync() ) |
426 | continue; | 426 | continue; |
427 | a.simplifyEmails(); | 427 | a.simplifyEmails(); |
428 | a.simplifyPhoneNumbers(); | 428 | a.simplifyPhoneNumbers(); |
429 | a.simplifyPhoneNumberTypes(); | 429 | a.simplifyPhoneNumberTypes(); |
430 | a.simplifyAddresses(); | 430 | a.simplifyAddresses(); |
431 | 431 | ||
432 | QString vcard; | 432 | QString vcard; |
433 | QString vcardnew; | 433 | QString vcardnew; |
434 | converter.addresseeToVCard( a, vcard ); | 434 | converter.addresseeToVCard( a, vcard ); |
435 | int start = 0; | 435 | int start = 0; |
436 | int next; | 436 | int next; |
437 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 437 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
438 | int semi = vcard.find(";", next); | 438 | int semi = vcard.find(";", next); |
439 | int dopp = vcard.find(":", next); | 439 | int dopp = vcard.find(":", next); |
440 | int sep; | 440 | int sep; |
441 | if ( semi < dopp && semi >= 0 ) | 441 | if ( semi < dopp && semi >= 0 ) |
442 | sep = semi ; | 442 | sep = semi ; |
443 | else | 443 | else |
444 | sep = dopp; | 444 | sep = dopp; |
445 | vcardnew +=vcard.mid( start, next - start); | 445 | vcardnew +=vcard.mid( start, next - start); |
446 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); | 446 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
447 | start = sep; | 447 | start = sep; |
448 | } | 448 | } |
449 | vcardnew += vcard.mid( start,vcard.length() ); | 449 | vcardnew += vcard.mid( start,vcard.length() ); |
450 | vcard = ""; | 450 | vcard = ""; |
451 | start = 0; | 451 | start = 0; |
452 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | 452 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { |
453 | int sep = vcardnew.find(":", next); | 453 | int sep = vcardnew.find(":", next); |
454 | vcard +=vcardnew.mid( start, next - start+3); | 454 | vcard +=vcardnew.mid( start, next - start+3); |
455 | start = sep; | 455 | start = sep; |
456 | } | 456 | } |
457 | vcard += vcardnew.mid( start,vcardnew.length() ); | 457 | vcard += vcardnew.mid( start,vcardnew.length() ); |
458 | vcard.replace ( QRegExp(";;;") , "" ); | 458 | vcard.replace ( QRegExp(";;;") , "" ); |
459 | vcard.replace ( QRegExp(";;") , "" ); | 459 | vcard.replace ( QRegExp(";;") , "" ); |
460 | datastream += vcard; | 460 | datastream += vcard; |
461 | 461 | ||
462 | } | 462 | } |
463 | 463 | ||
464 | QFile outFile(fileName); | 464 | QFile outFile(fileName); |
465 | if ( outFile.open(IO_WriteOnly) ) { | 465 | if ( outFile.open(IO_WriteOnly) ) { |
466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
467 | QTextStream t( &outFile ); // use a text stream | 467 | QTextStream t( &outFile ); // use a text stream |
468 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 468 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
469 | t <<datastream; | 469 | t <<datastream; |
470 | t << "\r\n\r\n"; | 470 | t << "\r\n\r\n"; |
471 | outFile.close(); | 471 | outFile.close(); |
472 | 472 | ||
473 | } else { | 473 | } else { |
474 | qDebug("Error open temp file "); | 474 | qDebug("Error open temp file "); |
475 | return false; | 475 | return false; |
476 | } | 476 | } |
477 | return true; | 477 | return true; |
478 | 478 | ||
479 | } | 479 | } |
480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) | 480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) |
481 | { | 481 | { |
482 | 482 | ||
483 | if ( removeOld ) | 483 | if ( removeOld ) |
484 | setUntagged( true ); | 484 | setUntagged( true ); |
485 | KABC::Addressee::List list; | 485 | KABC::Addressee::List list; |
486 | QFile file( fileName ); | 486 | QFile file( fileName ); |
487 | file.open( IO_ReadOnly ); | 487 | file.open( IO_ReadOnly ); |
488 | QByteArray rawData = file.readAll(); | 488 | QByteArray rawData = file.readAll(); |
489 | file.close(); | 489 | file.close(); |
490 | QString data; | 490 | QString data; |
491 | if ( replaceLabel ) { | 491 | if ( replaceLabel ) { |
492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
493 | data.replace ( QRegExp("LABEL") , "ADR" ); | 493 | data.replace ( QRegExp("LABEL") , "ADR" ); |
494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
495 | } else | 495 | } else |
496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
497 | KABC::VCardTool tool; | 497 | KABC::VCardTool tool; |
498 | list = tool.parseVCards( data ); | 498 | list = tool.parseVCards( data ); |
499 | KABC::Addressee::List::Iterator it; | 499 | KABC::Addressee::List::Iterator it; |
500 | for ( it = list.begin(); it != list.end(); ++it ) { | 500 | for ( it = list.begin(); it != list.end(); ++it ) { |
501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
502 | if ( !id.isEmpty() ) | 502 | if ( !id.isEmpty() ) |
503 | (*it).setIDStr(id ); | 503 | (*it).setIDStr(id ); |
504 | (*it).setResource( 0 ); | 504 | (*it).setResource( 0 ); |
505 | if ( replaceLabel ) | 505 | if ( replaceLabel ) |
506 | (*it).removeVoice(); | 506 | (*it).removeVoice(); |
507 | if ( removeOld ) | 507 | if ( removeOld ) |
508 | (*it).setTagged( true ); | 508 | (*it).setTagged( true ); |
509 | insertAddressee( (*it), false, true ); | 509 | insertAddressee( (*it), false, true ); |
510 | } | 510 | } |
511 | if ( removeOld ) | 511 | if ( removeOld ) |
512 | removeUntagged(); | 512 | removeUntagged(); |
513 | return list.count(); | 513 | return list.count(); |
514 | } | 514 | } |
515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) | 515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) |
516 | { | 516 | { |
517 | Iterator ait; | 517 | Iterator ait; |
518 | for ( ait = begin(); ait != end(); ++ait ) { | 518 | for ( ait = begin(); ait != end(); ++ait ) { |
519 | if ( setNonSyncTagged ) { | 519 | if ( setNonSyncTagged ) { |
520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { | 520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { |
521 | (*ait).setTagged( true ); | 521 | (*ait).setTagged( true ); |
522 | } else | 522 | } else |
523 | (*ait).setTagged( false ); | 523 | (*ait).setTagged( false ); |
524 | } else | 524 | } else |
525 | (*ait).setTagged( false ); | 525 | (*ait).setTagged( false ); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | void AddressBook::removeUntagged() | 528 | void AddressBook::removeUntagged() |
529 | { | 529 | { |
530 | Iterator ait; | 530 | Iterator ait; |
531 | bool todelete = false; | 531 | bool todelete = false; |
532 | Iterator todel; | 532 | Iterator todel; |
533 | for ( ait = begin(); ait != end(); ++ait ) { | 533 | for ( ait = begin(); ait != end(); ++ait ) { |
534 | if ( todelete ) | 534 | if ( todelete ) |
535 | removeAddressee( todel ); | 535 | removeAddressee( todel ); |
536 | if (!(*ait).tagged()) { | 536 | if (!(*ait).tagged()) { |
537 | todelete = true; | 537 | todelete = true; |
538 | todel = ait; | 538 | todel = ait; |
539 | } else | 539 | } else |
540 | todelete = false; | 540 | todelete = false; |
541 | } | 541 | } |
542 | if ( todelete ) | 542 | if ( todelete ) |
543 | removeAddressee( todel ); | 543 | removeAddressee( todel ); |
544 | deleteRemovedAddressees(); | 544 | deleteRemovedAddressees(); |
545 | } | 545 | } |
546 | void AddressBook::smplifyAddressees() | 546 | void AddressBook::smplifyAddressees() |
547 | { | 547 | { |
548 | Iterator ait; | 548 | Iterator ait; |
549 | for ( ait = begin(); ait != end(); ++ait ) { | 549 | for ( ait = begin(); ait != end(); ++ait ) { |
550 | (*ait).simplifyEmails(); | 550 | (*ait).simplifyEmails(); |
551 | (*ait).simplifyPhoneNumbers(); | 551 | (*ait).simplifyPhoneNumbers(); |
552 | (*ait).simplifyPhoneNumberTypes(); | 552 | (*ait).simplifyPhoneNumberTypes(); |
553 | (*ait).simplifyAddresses(); | 553 | (*ait).simplifyAddresses(); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | void AddressBook::removeSyncInfo( QString syncProfile) | 556 | void AddressBook::removeSyncInfo( QString syncProfile) |
557 | { | 557 | { |
558 | Iterator ait; | 558 | Iterator ait; |
559 | for ( ait = begin(); ait != end(); ++ait ) { | 559 | for ( ait = begin(); ait != end(); ++ait ) { |
560 | (*ait).removeID( syncProfile ); | 560 | (*ait).removeID( syncProfile ); |
561 | } | 561 | } |
562 | if ( syncProfile.isEmpty() ) { | 562 | if ( syncProfile.isEmpty() ) { |
563 | Iterator it = begin(); | 563 | Iterator it = begin(); |
564 | Iterator it2 ; | 564 | Iterator it2 ; |
565 | while ( it != end() ) { | 565 | while ( it != end() ) { |
566 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 566 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
567 | it2 = it; | 567 | it2 = it; |
568 | //qDebug("removing %s ",(*it).uid().latin1() ); | 568 | //qDebug("removing %s ",(*it).uid().latin1() ); |
569 | ++it; | 569 | ++it; |
570 | removeAddressee( it2 ); | 570 | removeAddressee( it2 ); |
571 | } else { | 571 | } else { |
572 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 572 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
573 | ++it; | 573 | ++it; |
574 | } | 574 | } |
575 | } | 575 | } |
576 | } else { | 576 | } else { |
577 | Addressee lse; | 577 | Addressee lse; |
578 | lse = findByUid( "last-syncAddressee-"+ syncProfile ); | 578 | lse = findByUid( "last-syncAddressee-"+ syncProfile ); |
579 | if ( ! lse.isEmpty() ) | 579 | if ( ! lse.isEmpty() ) |
580 | removeAddressee( lse ); | 580 | removeAddressee( lse ); |
581 | } | 581 | } |
582 | 582 | ||
583 | } | 583 | } |
584 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) | 584 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) |
585 | { | 585 | { |
586 | Iterator ait; | 586 | Iterator ait; |
587 | for ( ait = begin(); ait != end(); ++ait ) { | 587 | for ( ait = begin(); ait != end(); ++ait ) { |
588 | QString id = (*ait).IDStr(); | 588 | QString id = (*ait).IDStr(); |
589 | (*ait).setIDStr( ":"); | 589 | (*ait).setIDStr( ":"); |
590 | (*ait).setExternalUID( id ); | 590 | (*ait).setExternalUID( id ); |
591 | (*ait).setOriginalExternalUID( id ); | 591 | (*ait).setOriginalExternalUID( id ); |
592 | if ( isPreSync ) | 592 | if ( isPreSync ) |
593 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 593 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
594 | else { | 594 | else { |
595 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 595 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
596 | (*ait).setID( currentSyncDevice,id ); | 596 | (*ait).setID( currentSyncDevice,id ); |
597 | 597 | ||
598 | } | 598 | } |
599 | } | 599 | } |
600 | } | 600 | } |
601 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) | 601 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) |
602 | { | 602 | { |
603 | 603 | ||
604 | setUntagged(); | 604 | setUntagged(); |
605 | KABC::Addressee::List list; | 605 | KABC::Addressee::List list; |
606 | QFile file( fileName ); | 606 | QFile file( fileName ); |
607 | file.open( IO_ReadOnly ); | 607 | file.open( IO_ReadOnly ); |
608 | QByteArray rawData = file.readAll(); | 608 | QByteArray rawData = file.readAll(); |
609 | file.close(); | 609 | file.close(); |
610 | QString data; | 610 | QString data; |
611 | 611 | ||
612 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 612 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
613 | KABC::VCardTool tool; | 613 | KABC::VCardTool tool; |
614 | list = tool.parseVCards( data ); | 614 | list = tool.parseVCards( data ); |
615 | KABC::Addressee::List::Iterator it; | 615 | KABC::Addressee::List::Iterator it; |
616 | for ( it = list.begin(); it != list.end(); ++it ) { | 616 | for ( it = list.begin(); it != list.end(); ++it ) { |
617 | Iterator ait; | 617 | Iterator ait; |
618 | for ( ait = begin(); ait != end(); ++ait ) { | 618 | for ( ait = begin(); ait != end(); ++ait ) { |
619 | if ( !(*ait).tagged() ) { | 619 | if ( !(*ait).tagged() ) { |
620 | if ( (*ait).containsAdr(*it)) { | 620 | if ( (*ait).containsAdr(*it)) { |
621 | (*ait).setTagged(true); | 621 | (*ait).setTagged(true); |
622 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 622 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
623 | (*it).setIDStr( ":"); | 623 | (*it).setIDStr( ":"); |
624 | (*it).setID( currentSyncDevice,id ); | 624 | (*it).setID( currentSyncDevice,id ); |
625 | (*it).setExternalUID( id ); | 625 | (*it).setExternalUID( id ); |
626 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 626 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
627 | (*it).setUid( ( (*ait).uid() )); | 627 | (*it).setUid( ( (*ait).uid() )); |
628 | break; | 628 | break; |
629 | } | 629 | } |
630 | } | 630 | } |
631 | 631 | ||
632 | } | 632 | } |
633 | if ( ait == end() ) | 633 | if ( ait == end() ) |
634 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); | 634 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); |
635 | } | 635 | } |
636 | clear(); | 636 | clear(); |
637 | for ( it = list.begin(); it != list.end(); ++it ) { | 637 | for ( it = list.begin(); it != list.end(); ++it ) { |
638 | insertAddressee( (*it) ); | 638 | insertAddressee( (*it) ); |
639 | } | 639 | } |
640 | } | 640 | } |
641 | 641 | ||
642 | bool AddressBook::saveABphone( QString fileName ) | 642 | bool AddressBook::saveABphone( QString fileName ) |
643 | { | 643 | { |
644 | //smplifyAddressees(); | 644 | //smplifyAddressees(); |
645 | qDebug("saveABphone:: saving AB... "); | 645 | qDebug("saveABphone:: saving AB... "); |
646 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) | 646 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) |
647 | return false; | 647 | return false; |
648 | qDebug("saveABphone:: writing to phone... "); | 648 | qDebug("saveABphone:: writing to phone... "); |
649 | if ( !PhoneAccess::writeToPhone( fileName) ) { | 649 | if ( !PhoneAccess::writeToPhone( fileName) ) { |
650 | return false; | 650 | return false; |
651 | } | 651 | } |
652 | qDebug("saveABphone:: re-reading from phone... "); | 652 | qDebug("saveABphone:: re-reading from phone... "); |
653 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 653 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
654 | return false; | 654 | return false; |
655 | } | 655 | } |
656 | return true; | 656 | return true; |
657 | } | 657 | } |
658 | bool AddressBook::saveAB() | 658 | bool AddressBook::saveAB() |
659 | { | 659 | { |
660 | bool ok = true; | 660 | bool ok = true; |
661 | 661 | ||
662 | deleteRemovedAddressees(); | 662 | deleteRemovedAddressees(); |
663 | Iterator ait; | 663 | Iterator ait; |
664 | for ( ait = begin(); ait != end(); ++ait ) { | 664 | for ( ait = begin(); ait != end(); ++ait ) { |
665 | if ( !(*ait).IDStr().isEmpty() ) { | 665 | if ( !(*ait).IDStr().isEmpty() ) { |
666 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 666 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
667 | } | 667 | } |
668 | } | 668 | } |
669 | KRES::Manager<Resource>::ActiveIterator it; | 669 | KRES::Manager<Resource>::ActiveIterator it; |
670 | KRES::Manager<Resource> *manager = d->mManager; | 670 | KRES::Manager<Resource> *manager = d->mManager; |
671 | qDebug("SaveAB::saving..." ); | 671 | qDebug("SaveAB::saving..." ); |
672 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 672 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
673 | qDebug("SaveAB::checking resource..." ); | 673 | qDebug("SaveAB::checking resource..." ); |
674 | if ( (*it)->readOnly() ) | 674 | if ( (*it)->readOnly() ) |
675 | qDebug("resource is readonly." ); | 675 | qDebug("resource is readonly." ); |
676 | if ( (*it)->isOpen() ) | 676 | if ( (*it)->isOpen() ) |
677 | qDebug("resource is open" ); | 677 | qDebug("resource is open" ); |
678 | 678 | ||
679 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 679 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
680 | Ticket *ticket = requestSaveTicket( *it ); | 680 | Ticket *ticket = requestSaveTicket( *it ); |
681 | qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 681 | qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
682 | if ( !ticket ) { | 682 | if ( !ticket ) { |
683 | qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) | 683 | qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) |
684 | .arg( (*it)->resourceName() ) ); | 684 | .arg( (*it)->resourceName() ) ); |
685 | return false; | 685 | return false; |
686 | } | 686 | } |
687 | 687 | ||
688 | //if ( !save( ticket ) ) | 688 | //if ( !save( ticket ) ) |
689 | if ( ticket->resource() ) { | 689 | if ( ticket->resource() ) { |
690 | QString name = ticket->resource()->resourceName(); | 690 | QString name = ticket->resource()->resourceName(); |
691 | if ( ! ticket->resource()->save( ticket ) ) | 691 | if ( ! ticket->resource()->save( ticket ) ) |
692 | ok = false; | 692 | ok = false; |
693 | else | 693 | else |
694 | qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); | 694 | qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); |
695 | 695 | ||
696 | } else | 696 | } else |
697 | ok = false; | 697 | ok = false; |
698 | 698 | ||
699 | } | 699 | } |
700 | } | 700 | } |
701 | return ok; | 701 | return ok; |
702 | } | 702 | } |
703 | 703 | ||
704 | AddressBook::Iterator AddressBook::begin() | 704 | AddressBook::Iterator AddressBook::begin() |
705 | { | 705 | { |
706 | Iterator it = Iterator(); | 706 | Iterator it = Iterator(); |
707 | it.d->mIt = d->mAddressees.begin(); | 707 | it.d->mIt = d->mAddressees.begin(); |
708 | return it; | 708 | return it; |
709 | } | 709 | } |
710 | 710 | ||
711 | AddressBook::ConstIterator AddressBook::begin() const | 711 | AddressBook::ConstIterator AddressBook::begin() const |
712 | { | 712 | { |
713 | ConstIterator it = ConstIterator(); | 713 | ConstIterator it = ConstIterator(); |
714 | it.d->mIt = d->mAddressees.begin(); | 714 | it.d->mIt = d->mAddressees.begin(); |
715 | return it; | 715 | return it; |
716 | } | 716 | } |
717 | 717 | ||
718 | AddressBook::Iterator AddressBook::end() | 718 | AddressBook::Iterator AddressBook::end() |
719 | { | 719 | { |
720 | Iterator it = Iterator(); | 720 | Iterator it = Iterator(); |
721 | it.d->mIt = d->mAddressees.end(); | 721 | it.d->mIt = d->mAddressees.end(); |
722 | return it; | 722 | return it; |
723 | } | 723 | } |
724 | 724 | ||
725 | AddressBook::ConstIterator AddressBook::end() const | 725 | AddressBook::ConstIterator AddressBook::end() const |
726 | { | 726 | { |
727 | ConstIterator it = ConstIterator(); | 727 | ConstIterator it = ConstIterator(); |
728 | it.d->mIt = d->mAddressees.end(); | 728 | it.d->mIt = d->mAddressees.end(); |
729 | return it; | 729 | return it; |
730 | } | 730 | } |
731 | 731 | ||
732 | void AddressBook::clear() | 732 | void AddressBook::clear() |
733 | { | 733 | { |
734 | d->mAddressees.clear(); | 734 | d->mAddressees.clear(); |
735 | } | 735 | } |
736 | 736 | ||
737 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 737 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
738 | { | 738 | { |
739 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 739 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
740 | 740 | ||
741 | if ( !resource ) | 741 | if ( !resource ) |
742 | { | 742 | { |
743 | qDebug("AddressBook::requestSaveTicket no resource" ); | 743 | qDebug("AddressBook::requestSaveTicket no resource" ); |
744 | resource = standardResource(); | 744 | resource = standardResource(); |
745 | } | 745 | } |
746 | 746 | ||
747 | KRES::Manager<Resource>::ActiveIterator it; | 747 | KRES::Manager<Resource>::ActiveIterator it; |
748 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 748 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
749 | if ( (*it) == resource ) { | 749 | if ( (*it) == resource ) { |
750 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 750 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
751 | return 0; | 751 | return 0; |
752 | else | 752 | else |
753 | return (*it)->requestSaveTicket(); | 753 | return (*it)->requestSaveTicket(); |
754 | } | 754 | } |
755 | } | 755 | } |
756 | 756 | ||
757 | return 0; | 757 | return 0; |
758 | } | 758 | } |
759 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 759 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
760 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 760 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
761 | { | 761 | { |
762 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 762 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
763 | //qDebug("block insert "); | 763 | //qDebug("block insert "); |
764 | return; | 764 | return; |
765 | } | 765 | } |
766 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 766 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
767 | bool found = false; | 767 | bool found = false; |
768 | Addressee::List::Iterator it; | 768 | Addressee::List::Iterator it; |
769 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 769 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
770 | if ( a.uid() == (*it).uid() ) { | 770 | if ( a.uid() == (*it).uid() ) { |
771 | 771 | ||
772 | bool changed = false; | 772 | bool changed = false; |
773 | Addressee addr = a; | 773 | Addressee addr = a; |
774 | if ( addr != (*it) ) | 774 | if ( addr != (*it) ) |
775 | changed = true; | 775 | changed = true; |
776 | 776 | ||
777 | if ( takeResource ) { | 777 | if ( takeResource ) { |
778 | Resource * res = (*it).resource(); | 778 | Resource * res = (*it).resource(); |
779 | (*it) = a; | 779 | (*it) = a; |
780 | (*it).setResource( res ); | 780 | (*it).setResource( res ); |
781 | } else { | 781 | } else { |
782 | (*it) = a; | 782 | (*it) = a; |
783 | if ( (*it).resource() == 0 ) | 783 | if ( (*it).resource() == 0 ) |
784 | (*it).setResource( standardResource() ); | 784 | (*it).setResource( standardResource() ); |
785 | } | 785 | } |
786 | if ( changed ) { | 786 | if ( changed ) { |
787 | if ( setRev ) { | 787 | if ( setRev ) { |
788 | (*it).setRevision( QDateTime::currentDateTime() ); | 788 | (*it).setRevision( QDateTime::currentDateTime() ); |
789 | } | 789 | } |
790 | (*it).setChanged( true ); | 790 | (*it).setChanged( true ); |
791 | } | 791 | } |
792 | 792 | ||
793 | found = true; | 793 | found = true; |
794 | } else { | 794 | } else { |
795 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 795 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
796 | QString name = (*it).uid().mid( 19 ); | 796 | QString name = (*it).uid().mid( 19 ); |
797 | Addressee b = a; | 797 | Addressee b = a; |
798 | QString id = b.getID( name ); | 798 | QString id = b.getID( name ); |
799 | if ( ! id.isEmpty() ) { | 799 | if ( ! id.isEmpty() ) { |
800 | QString des = (*it).note(); | 800 | QString des = (*it).note(); |
801 | int startN; | 801 | int startN; |
802 | if( (startN = des.find( id ) ) >= 0 ) { | 802 | if( (startN = des.find( id ) ) >= 0 ) { |
803 | int endN = des.find( ",", startN+1 ); | 803 | int endN = des.find( ",", startN+1 ); |
804 | des = des.left( startN ) + des.mid( endN+1 ); | 804 | des = des.left( startN ) + des.mid( endN+1 ); |
805 | (*it).setNote( des ); | 805 | (*it).setNote( des ); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | } | 808 | } |
809 | } | 809 | } |
810 | } | 810 | } |
811 | if ( found ) | 811 | if ( found ) |
812 | return; | 812 | return; |
813 | 813 | ||
814 | d->mAddressees.append( a ); | 814 | d->mAddressees.append( a ); |
815 | Addressee& addr = d->mAddressees.last(); | 815 | Addressee& addr = d->mAddressees.last(); |
816 | if ( addr.resource() == 0 ) | 816 | if ( addr.resource() == 0 ) |
817 | addr.setResource( standardResource() ); | 817 | addr.setResource( standardResource() ); |
818 | addr.setChanged( true ); | 818 | addr.setChanged( true ); |
819 | } | 819 | } |
820 | 820 | ||
821 | void AddressBook::removeAddressee( const Addressee &a ) | 821 | void AddressBook::removeAddressee( const Addressee &a ) |
822 | { | 822 | { |
823 | Iterator it; | 823 | Iterator it; |
824 | Iterator it2; | 824 | Iterator it2; |
825 | bool found = false; | 825 | bool found = false; |
826 | for ( it = begin(); it != end(); ++it ) { | 826 | for ( it = begin(); it != end(); ++it ) { |
827 | if ( a.uid() == (*it).uid() ) { | 827 | if ( a.uid() == (*it).uid() ) { |
828 | found = true; | 828 | found = true; |
829 | it2 = it; | 829 | it2 = it; |
830 | } else { | 830 | } else { |
831 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 831 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
832 | QString name = (*it).uid().mid( 19 ); | 832 | QString name = (*it).uid().mid( 19 ); |
833 | Addressee b = a; | 833 | Addressee b = a; |
834 | QString id = b.getID( name ); | 834 | QString id = b.getID( name ); |
835 | if ( ! id.isEmpty() ) { | 835 | if ( ! id.isEmpty() ) { |
836 | QString des = (*it).note(); | 836 | QString des = (*it).note(); |
837 | if( des.find( id ) < 0 ) { | 837 | if( des.find( id ) < 0 ) { |
838 | des += id + ","; | 838 | des += id + ","; |
839 | (*it).setNote( des ); | 839 | (*it).setNote( des ); |
840 | } | 840 | } |
841 | } | 841 | } |
842 | } | 842 | } |
843 | 843 | ||
844 | } | 844 | } |
845 | } | 845 | } |
846 | 846 | ||
847 | if ( found ) | 847 | if ( found ) |
848 | removeAddressee( it2 ); | 848 | removeAddressee( it2 ); |
849 | 849 | ||
850 | } | 850 | } |
851 | 851 | ||
852 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 852 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
853 | { | 853 | { |
854 | Iterator it = begin(); | 854 | Iterator it = begin(); |
855 | Iterator it2 ; | 855 | Iterator it2 ; |
856 | QDateTime dt ( QDate( 2003,1,1) ); | 856 | QDateTime dt ( QDate( 2003,1,1) ); |
857 | while ( it != end() ) { | 857 | while ( it != end() ) { |
858 | (*it).setRevision( dt ); | 858 | (*it).setRevision( dt ); |
859 | if (( *it).IDStr() != "changed" ) { | 859 | if (( *it).IDStr() != "changed" ) { |
860 | // "changed" is used for tagging changed addressees when syncing with KDE or OL | 860 | // "changed" is used for tagging changed addressees when syncing with KDE or OL |
861 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 861 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
862 | (*it).setIDStr(":"); | 862 | (*it).setIDStr(":"); |
863 | } | 863 | } |
864 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 864 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
865 | it2 = it; | 865 | it2 = it; |
866 | //qDebug("removing %s ",(*it).uid().latin1() ); | 866 | //qDebug("removing %s ",(*it).uid().latin1() ); |
867 | ++it; | 867 | ++it; |
868 | removeAddressee( it2 ); | 868 | removeAddressee( it2 ); |
869 | } else { | 869 | } else { |
870 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 870 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
871 | if ( removeDeleted ) { | 871 | if ( removeDeleted ) { |
872 | // we have no postprocessing in the resource, we have to do it here | 872 | // we have no postprocessing in the resource, we have to do it here |
873 | // we have to compute csum for all, because it could be the first sync | 873 | // we have to compute csum for all, because it could be the first sync |
874 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 874 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
875 | } | 875 | } |
876 | ++it; | 876 | ++it; |
877 | } | 877 | } |
878 | } | 878 | } |
879 | deleteRemovedAddressees(); | 879 | deleteRemovedAddressees(); |
880 | } | 880 | } |
881 | 881 | ||
882 | void AddressBook::removeAddressee( const Iterator &it ) | 882 | void AddressBook::removeAddressee( const Iterator &it ) |
883 | { | 883 | { |
884 | d->mRemovedAddressees.append( (*it) ); | 884 | d->mRemovedAddressees.append( (*it) ); |
885 | d->mAddressees.remove( it.d->mIt ); | 885 | d->mAddressees.remove( it.d->mIt ); |
886 | } | 886 | } |
887 | 887 | ||
888 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 888 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
889 | { | 889 | { |
890 | Iterator it; | 890 | Iterator it; |
891 | for ( it = begin(); it != end(); ++it ) { | 891 | for ( it = begin(); it != end(); ++it ) { |
892 | if ( a.uid() == (*it).uid() ) { | 892 | if ( a.uid() == (*it).uid() ) { |
893 | return it; | 893 | return it; |
894 | } | 894 | } |
895 | } | 895 | } |
896 | return end(); | 896 | return end(); |
897 | } | 897 | } |
898 | 898 | ||
899 | Addressee AddressBook::findByUid( const QString &uid ) | 899 | Addressee AddressBook::findByUid( const QString &uid ) |
900 | { | 900 | { |
901 | Iterator it; | 901 | Iterator it; |
902 | for ( it = begin(); it != end(); ++it ) { | 902 | for ( it = begin(); it != end(); ++it ) { |
903 | if ( uid == (*it).uid() ) { | 903 | if ( uid == (*it).uid() ) { |
904 | return *it; | 904 | return *it; |
905 | } | 905 | } |
906 | } | 906 | } |
907 | return Addressee(); | 907 | return Addressee(); |
908 | } | 908 | } |
909 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 909 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
910 | { | 910 | { |
911 | //qDebug("AddressBook::preExternSync "); | 911 | //qDebug("AddressBook::preExternSync "); |
912 | AddressBook::Iterator it; | 912 | AddressBook::Iterator it; |
913 | for ( it = begin(); it != end(); ++it ) { | 913 | for ( it = begin(); it != end(); ++it ) { |
914 | (*it).setID( csd, (*it).externalUID() ); | 914 | (*it).setID( csd, (*it).externalUID() ); |
915 | (*it).computeCsum( csd ); | 915 | (*it).computeCsum( csd ); |
916 | } | 916 | } |
917 | mergeAB( aBook ,csd, isSubset ); | 917 | mergeAB( aBook ,csd, isSubset ); |
918 | } | 918 | } |
919 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) | 919 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) |
920 | { | 920 | { |
921 | //qDebug("AddressBook::postExternSync "); | 921 | //qDebug("AddressBook::postExternSync "); |
922 | AddressBook::Iterator it; | 922 | AddressBook::Iterator it; |
923 | int foundEmpty = 0; | 923 | int foundEmpty = 0; |
924 | for ( it = begin(); it != end(); ++it ) { | 924 | for ( it = begin(); it != end(); ++it ) { |
925 | //qDebug("check uid %s ", (*it).uid().latin1() ); | 925 | //qDebug("check uid %s ", (*it).uid().latin1() ); |
926 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 926 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || | 927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || |
928 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { | 928 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { |
929 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 929 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
930 | if ( ad.isEmpty() ) { | 930 | if ( ad.isEmpty() ) { |
931 | ++foundEmpty; | 931 | ++foundEmpty; |
932 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); | 932 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); |
933 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); | 933 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); |
934 | } else { | 934 | } else { |
935 | (*it).setIDStr(":"); | 935 | (*it).setIDStr(":"); |
936 | if ( setID ) { | 936 | if ( setID ) { |
937 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 937 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
938 | ad.setID( csd, (*it).externalUID() ); | 938 | ad.setID( csd, (*it).externalUID() ); |
939 | } else | 939 | } else |
940 | ad.setID( csd, (*it).uid() ); | 940 | ad.setID( csd, (*it).uid() ); |
941 | (*it).computeCsum( csd ); | 941 | (*it).computeCsum( csd ); |
942 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 942 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
943 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); | 943 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); |
944 | aBook->insertAddressee( ad , false); | 944 | aBook->insertAddressee( ad , false); |
945 | } | 945 | } |
946 | } | 946 | } |
947 | } | 947 | } |
948 | if ( foundEmpty ) { | 948 | if ( foundEmpty ) { |
949 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); | 949 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); |
950 | } | 950 | } |
951 | 951 | ||
952 | } | 952 | } |
953 | 953 | ||
954 | bool AddressBook::containsExternalUid( const QString& uid ) | 954 | bool AddressBook::containsExternalUid( const QString& uid ) |
955 | { | 955 | { |
956 | Iterator it; | 956 | Iterator it; |
957 | for ( it = begin(); it != end(); ++it ) { | 957 | for ( it = begin(); it != end(); ++it ) { |
958 | if ( uid == (*it).externalUID( ) ) | 958 | if ( uid == (*it).externalUID( ) ) |
959 | return true; | 959 | return true; |
960 | } | 960 | } |
961 | return false; | 961 | return false; |
962 | } | 962 | } |
963 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 963 | const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const |
964 | { | 964 | { |
965 | Iterator it; | 965 | ConstIterator it; |
966 | for ( it = begin(); it != end(); ++it ) { | 966 | for ( it = begin(); it != end(); ++it ) { |
967 | if ( uid == (*it).getID( profile ) ) | 967 | if ( uid == (*it).getID( profile ) ) |
968 | return (*it); | 968 | return (*it); |
969 | } | 969 | } |
970 | return Addressee(); | 970 | return Addressee(); |
971 | } | 971 | } |
972 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) | 972 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) |
973 | { | 973 | { |
974 | Iterator it; | 974 | Iterator it; |
975 | Addressee ad; | 975 | Addressee ad; |
976 | for ( it = begin(); it != end(); ++it ) { | 976 | for ( it = begin(); it != end(); ++it ) { |
977 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 977 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
978 | if ( !ad.isEmpty() ) { | 978 | if ( !ad.isEmpty() ) { |
979 | (*it).mergeContact( ad ,isSubset); | 979 | (*it).mergeContact( ad ,isSubset); |
980 | } | 980 | } |
981 | } | 981 | } |
982 | #if 0 | 982 | #if 0 |
983 | // test only | 983 | // test only |
984 | for ( it = begin(); it != end(); ++it ) { | 984 | for ( it = begin(); it != end(); ++it ) { |
985 | 985 | ||
986 | qDebug("uid %s ", (*it).uid().latin1()); | 986 | qDebug("uid %s ", (*it).uid().latin1()); |
987 | } | 987 | } |
988 | #endif | 988 | #endif |
989 | } | 989 | } |
990 | 990 | ||
991 | #if 0 | 991 | #if 0 |
992 | Addressee::List AddressBook::getExternLastSyncAddressees() | 992 | Addressee::List AddressBook::getExternLastSyncAddressees() |
993 | { | 993 | { |
994 | Addressee::List results; | 994 | Addressee::List results; |
995 | 995 | ||
996 | Iterator it; | 996 | Iterator it; |
997 | for ( it = begin(); it != end(); ++it ) { | 997 | for ( it = begin(); it != end(); ++it ) { |
998 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 998 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
999 | if ( (*it).familyName().left(4) == "!E: " ) | 999 | if ( (*it).familyName().left(4) == "!E: " ) |
1000 | results.append( *it ); | 1000 | results.append( *it ); |
1001 | } | 1001 | } |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | return results; | 1004 | return results; |
1005 | } | 1005 | } |
1006 | #endif | 1006 | #endif |
1007 | void AddressBook::resetTempSyncStat() | 1007 | void AddressBook::resetTempSyncStat() |
1008 | { | 1008 | { |
1009 | Iterator it; | 1009 | Iterator it; |
1010 | for ( it = begin(); it != end(); ++it ) { | 1010 | for ( it = begin(); it != end(); ++it ) { |
1011 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 1011 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | QStringList AddressBook:: uidList() | 1016 | QStringList AddressBook:: uidList() |
1017 | { | 1017 | { |
1018 | QStringList results; | 1018 | QStringList results; |
1019 | Iterator it; | 1019 | Iterator it; |
1020 | for ( it = begin(); it != end(); ++it ) { | 1020 | for ( it = begin(); it != end(); ++it ) { |
1021 | results.append( (*it).uid() ); | 1021 | results.append( (*it).uid() ); |
1022 | } | 1022 | } |
1023 | return results; | 1023 | return results; |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | 1026 | ||
1027 | Addressee::List AddressBook::allAddressees() | 1027 | Addressee::List AddressBook::allAddressees() |
1028 | { | 1028 | { |
1029 | return d->mAddressees; | 1029 | return d->mAddressees; |
1030 | 1030 | ||
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | Addressee::List AddressBook::findByName( const QString &name ) | 1033 | Addressee::List AddressBook::findByName( const QString &name ) |
1034 | { | 1034 | { |
1035 | Addressee::List results; | 1035 | Addressee::List results; |
1036 | 1036 | ||
1037 | Iterator it; | 1037 | Iterator it; |
1038 | for ( it = begin(); it != end(); ++it ) { | 1038 | for ( it = begin(); it != end(); ++it ) { |
1039 | if ( name == (*it).realName() ) { | 1039 | if ( name == (*it).realName() ) { |
1040 | results.append( *it ); | 1040 | results.append( *it ); |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | return results; | 1044 | return results; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | Addressee::List AddressBook::findByEmail( const QString &email ) | 1047 | Addressee::List AddressBook::findByEmail( const QString &email ) |
1048 | { | 1048 | { |
1049 | Addressee::List results; | 1049 | Addressee::List results; |
1050 | QStringList mailList; | 1050 | QStringList mailList; |
1051 | 1051 | ||
1052 | Iterator it; | 1052 | Iterator it; |
1053 | for ( it = begin(); it != end(); ++it ) { | 1053 | for ( it = begin(); it != end(); ++it ) { |
1054 | mailList = (*it).emails(); | 1054 | mailList = (*it).emails(); |
1055 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 1055 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
1056 | if ( email == (*ite) ) { | 1056 | if ( email == (*ite) ) { |
1057 | results.append( *it ); | 1057 | results.append( *it ); |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | return results; | 1062 | return results; |
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | Addressee::List AddressBook::findByCategory( const QString &category ) | 1065 | Addressee::List AddressBook::findByCategory( const QString &category ) |
1066 | { | 1066 | { |
1067 | Addressee::List results; | 1067 | Addressee::List results; |
1068 | 1068 | ||
1069 | Iterator it; | 1069 | Iterator it; |
1070 | for ( it = begin(); it != end(); ++it ) { | 1070 | for ( it = begin(); it != end(); ++it ) { |
1071 | if ( (*it).hasCategory( category) ) { | 1071 | if ( (*it).hasCategory( category) ) { |
1072 | results.append( *it ); | 1072 | results.append( *it ); |
1073 | } | 1073 | } |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | return results; | 1076 | return results; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | void AddressBook::dump() const | 1079 | void AddressBook::dump() const |
1080 | { | 1080 | { |
1081 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 1081 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
1082 | 1082 | ||
1083 | ConstIterator it; | 1083 | ConstIterator it; |
1084 | for( it = begin(); it != end(); ++it ) { | 1084 | for( it = begin(); it != end(); ++it ) { |
1085 | (*it).dump(); | 1085 | (*it).dump(); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 1088 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | QString AddressBook::identifier() | 1091 | QString AddressBook::identifier() |
1092 | { | 1092 | { |
1093 | QStringList identifier; | 1093 | QStringList identifier; |
1094 | 1094 | ||
1095 | 1095 | ||
1096 | KRES::Manager<Resource>::ActiveIterator it; | 1096 | KRES::Manager<Resource>::ActiveIterator it; |
1097 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1097 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1098 | if ( !(*it)->identifier().isEmpty() ) | 1098 | if ( !(*it)->identifier().isEmpty() ) |
1099 | identifier.append( (*it)->identifier() ); | 1099 | identifier.append( (*it)->identifier() ); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | return identifier.join( ":" ); | 1102 | return identifier.join( ":" ); |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | Field::List AddressBook::fields( int category ) | 1105 | Field::List AddressBook::fields( int category ) |
1106 | { | 1106 | { |
1107 | if ( d->mAllFields.isEmpty() ) { | 1107 | if ( d->mAllFields.isEmpty() ) { |
1108 | d->mAllFields = Field::allFields(); | 1108 | d->mAllFields = Field::allFields(); |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | if ( category == Field::All ) return d->mAllFields; | 1111 | if ( category == Field::All ) return d->mAllFields; |
1112 | 1112 | ||
1113 | Field::List result; | 1113 | Field::List result; |
1114 | Field::List::ConstIterator it; | 1114 | Field::List::ConstIterator it; |
1115 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 1115 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
1116 | if ( (*it)->category() & category ) result.append( *it ); | 1116 | if ( (*it)->category() & category ) result.append( *it ); |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | return result; | 1119 | return result; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | bool AddressBook::addCustomField( const QString &label, int category, | 1122 | bool AddressBook::addCustomField( const QString &label, int category, |
1123 | const QString &key, const QString &app ) | 1123 | const QString &key, const QString &app ) |
1124 | { | 1124 | { |
1125 | if ( d->mAllFields.isEmpty() ) { | 1125 | if ( d->mAllFields.isEmpty() ) { |
1126 | d->mAllFields = Field::allFields(); | 1126 | d->mAllFields = Field::allFields(); |
1127 | } | 1127 | } |
1128 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 1128 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
1129 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 1129 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
1130 | 1130 | ||
1131 | QString k = key.isNull() ? label : key; | 1131 | QString k = key.isNull() ? label : key; |
1132 | 1132 | ||
1133 | Field *field = Field::createCustomField( label, category, k, a ); | 1133 | Field *field = Field::createCustomField( label, category, k, a ); |
1134 | 1134 | ||
1135 | if ( !field ) return false; | 1135 | if ( !field ) return false; |
1136 | 1136 | ||
1137 | d->mAllFields.append( field ); | 1137 | d->mAllFields.append( field ); |
1138 | 1138 | ||
1139 | return true; | 1139 | return true; |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 1142 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
1143 | { | 1143 | { |
1144 | if (!ab.d) return s; | 1144 | if (!ab.d) return s; |
1145 | 1145 | ||
1146 | return s << ab.d->mAddressees; | 1146 | return s << ab.d->mAddressees; |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 1149 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
1150 | { | 1150 | { |
1151 | if (!ab.d) return s; | 1151 | if (!ab.d) return s; |
1152 | 1152 | ||
1153 | s >> ab.d->mAddressees; | 1153 | s >> ab.d->mAddressees; |
1154 | 1154 | ||
1155 | return s; | 1155 | return s; |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | bool AddressBook::addResource( Resource *resource ) | 1158 | bool AddressBook::addResource( Resource *resource ) |
1159 | { | 1159 | { |
1160 | if ( !resource->open() ) { | 1160 | if ( !resource->open() ) { |
1161 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 1161 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
1162 | return false; | 1162 | return false; |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | resource->setAddressBook( this ); | 1165 | resource->setAddressBook( this ); |
1166 | 1166 | ||
1167 | d->mManager->add( resource ); | 1167 | d->mManager->add( resource ); |
1168 | return true; | 1168 | return true; |
1169 | } | 1169 | } |
1170 | void AddressBook::removeResources() | 1170 | void AddressBook::removeResources() |
1171 | { | 1171 | { |
1172 | //remove all possible resources. This should cleanup the configfile. | 1172 | //remove all possible resources. This should cleanup the configfile. |
1173 | QPtrList<KABC::Resource> mResources = resources(); | 1173 | QPtrList<KABC::Resource> mResources = resources(); |
1174 | 1174 | ||
1175 | QPtrListIterator<KABC::Resource> it(mResources); | 1175 | QPtrListIterator<KABC::Resource> it(mResources); |
1176 | for ( ; it.current(); ++it ) { | 1176 | for ( ; it.current(); ++it ) { |
1177 | KABC::Resource *res = it.current(); | 1177 | KABC::Resource *res = it.current(); |
1178 | removeResource(res); | 1178 | removeResource(res); |
1179 | } | 1179 | } |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | bool AddressBook::removeResource( Resource *resource ) | 1182 | bool AddressBook::removeResource( Resource *resource ) |
1183 | { | 1183 | { |
1184 | resource->close(); | 1184 | resource->close(); |
1185 | 1185 | ||
1186 | if ( resource == standardResource() ) | 1186 | if ( resource == standardResource() ) |
1187 | d->mManager->setStandardResource( 0 ); | 1187 | d->mManager->setStandardResource( 0 ); |
1188 | 1188 | ||
1189 | resource->setAddressBook( 0 ); | 1189 | resource->setAddressBook( 0 ); |
1190 | 1190 | ||
1191 | d->mManager->remove( resource ); | 1191 | d->mManager->remove( resource ); |
1192 | return true; | 1192 | return true; |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | QPtrList<Resource> AddressBook::resources() | 1195 | QPtrList<Resource> AddressBook::resources() |
1196 | { | 1196 | { |
1197 | QPtrList<Resource> list; | 1197 | QPtrList<Resource> list; |
1198 | 1198 | ||
1199 | // qDebug("AddressBook::resources() 1"); | 1199 | // qDebug("AddressBook::resources() 1"); |
1200 | 1200 | ||
1201 | KRES::Manager<Resource>::ActiveIterator it; | 1201 | KRES::Manager<Resource>::ActiveIterator it; |
1202 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 1202 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
1203 | list.append( *it ); | 1203 | list.append( *it ); |
1204 | 1204 | ||
1205 | return list; | 1205 | return list; |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | /*US | 1208 | /*US |
1209 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 1209 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
1210 | { | 1210 | { |
1211 | delete d->mErrorHandler; | 1211 | delete d->mErrorHandler; |
1212 | d->mErrorHandler = handler; | 1212 | d->mErrorHandler = handler; |
1213 | } | 1213 | } |
1214 | */ | 1214 | */ |
1215 | 1215 | ||
1216 | void AddressBook::error( const QString& msg ) | 1216 | void AddressBook::error( const QString& msg ) |
1217 | { | 1217 | { |
1218 | /*US | 1218 | /*US |
1219 | if ( !d->mErrorHandler ) // create default error handler | 1219 | if ( !d->mErrorHandler ) // create default error handler |
1220 | d->mErrorHandler = new ConsoleErrorHandler; | 1220 | d->mErrorHandler = new ConsoleErrorHandler; |
1221 | 1221 | ||
1222 | if ( d->mErrorHandler ) | 1222 | if ( d->mErrorHandler ) |
1223 | d->mErrorHandler->error( msg ); | 1223 | d->mErrorHandler->error( msg ); |
1224 | else | 1224 | else |
1225 | kdError(5700) << "no error handler defined" << endl; | 1225 | kdError(5700) << "no error handler defined" << endl; |
1226 | */ | 1226 | */ |
1227 | kdDebug(5700) << "msg" << endl; | 1227 | kdDebug(5700) << "msg" << endl; |
1228 | qDebug(msg); | 1228 | qDebug(msg); |
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | void AddressBook::deleteRemovedAddressees() | 1231 | void AddressBook::deleteRemovedAddressees() |
1232 | { | 1232 | { |
1233 | Addressee::List::Iterator it; | 1233 | Addressee::List::Iterator it; |
1234 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 1234 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
1235 | Resource *resource = (*it).resource(); | 1235 | Resource *resource = (*it).resource(); |
1236 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 1236 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
1237 | resource->removeAddressee( *it ); | 1237 | resource->removeAddressee( *it ); |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | d->mRemovedAddressees.clear(); | 1240 | d->mRemovedAddressees.clear(); |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | void AddressBook::setStandardResource( Resource *resource ) | 1243 | void AddressBook::setStandardResource( Resource *resource ) |
1244 | { | 1244 | { |
1245 | // qDebug("AddressBook::setStandardResource 1"); | 1245 | // qDebug("AddressBook::setStandardResource 1"); |
1246 | d->mManager->setStandardResource( resource ); | 1246 | d->mManager->setStandardResource( resource ); |
1247 | } | 1247 | } |
1248 | 1248 | ||
1249 | Resource *AddressBook::standardResource() | 1249 | Resource *AddressBook::standardResource() |
1250 | { | 1250 | { |
1251 | return d->mManager->standardResource(); | 1251 | return d->mManager->standardResource(); |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | KRES::Manager<Resource> *AddressBook::resourceManager() | 1254 | KRES::Manager<Resource> *AddressBook::resourceManager() |
1255 | { | 1255 | { |
1256 | return d->mManager; | 1256 | return d->mManager; |
1257 | } | 1257 | } |
1258 | 1258 | ||
1259 | void AddressBook::cleanUp() | 1259 | void AddressBook::cleanUp() |
1260 | { | 1260 | { |
1261 | KRES::Manager<Resource>::ActiveIterator it; | 1261 | KRES::Manager<Resource>::ActiveIterator it; |
1262 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1262 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1263 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 1263 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
1264 | (*it)->cleanUp(); | 1264 | (*it)->cleanUp(); |
1265 | } | 1265 | } |
1266 | } | 1266 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 2351add..18c03b5 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,350 +1,350 @@ | |||
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_ADDRESSBOOK_H | 28 | #ifndef KABC_ADDRESSBOOK_H |
29 | #define KABC_ADDRESSBOOK_H | 29 | #define KABC_ADDRESSBOOK_H |
30 | 30 | ||
31 | #include <qobject.h> | 31 | #include <qobject.h> |
32 | 32 | ||
33 | #include <kresources/manager.h> | 33 | #include <kresources/manager.h> |
34 | #include <qptrlist.h> | 34 | #include <qptrlist.h> |
35 | 35 | ||
36 | #include "addressee.h" | 36 | #include "addressee.h" |
37 | #include "field.h" | 37 | #include "field.h" |
38 | 38 | ||
39 | namespace KABC { | 39 | namespace KABC { |
40 | 40 | ||
41 | class ErrorHandler; | 41 | class ErrorHandler; |
42 | class Resource; | 42 | class Resource; |
43 | class Ticket; | 43 | class Ticket; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | @short Address Book | 46 | @short Address Book |
47 | 47 | ||
48 | This class provides access to a collection of address book entries. | 48 | This class provides access to a collection of address book entries. |
49 | */ | 49 | */ |
50 | class AddressBook : public QObject | 50 | class AddressBook : public QObject |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); | 54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); |
55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
56 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
57 | 57 | ||
58 | public: | 58 | public: |
59 | /** | 59 | /** |
60 | @short Address Book Iterator | 60 | @short Address Book Iterator |
61 | 61 | ||
62 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
63 | */ | 63 | */ |
64 | class Iterator | 64 | class Iterator |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | Iterator(); | 67 | Iterator(); |
68 | Iterator( const Iterator & ); | 68 | Iterator( const Iterator & ); |
69 | ~Iterator(); | 69 | ~Iterator(); |
70 | 70 | ||
71 | Iterator &operator=( const Iterator & ); | 71 | Iterator &operator=( const Iterator & ); |
72 | const Addressee &operator*() const; | 72 | const Addressee &operator*() const; |
73 | Addressee &operator*(); | 73 | Addressee &operator*(); |
74 | Addressee* operator->(); | 74 | Addressee* operator->(); |
75 | Iterator &operator++(); | 75 | Iterator &operator++(); |
76 | Iterator &operator++(int); | 76 | Iterator &operator++(int); |
77 | Iterator &operator--(); | 77 | Iterator &operator--(); |
78 | Iterator &operator--(int); | 78 | Iterator &operator--(int); |
79 | bool operator==( const Iterator &it ); | 79 | bool operator==( const Iterator &it ); |
80 | bool operator!=( const Iterator &it ); | 80 | bool operator!=( const Iterator &it ); |
81 | 81 | ||
82 | struct IteratorData; | 82 | struct IteratorData; |
83 | IteratorData *d; | 83 | IteratorData *d; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | @short Address Book Const Iterator | 87 | @short Address Book Const Iterator |
88 | 88 | ||
89 | This class provides a const iterator for address book entries. | 89 | This class provides a const iterator for address book entries. |
90 | */ | 90 | */ |
91 | class ConstIterator | 91 | class ConstIterator |
92 | { | 92 | { |
93 | public: | 93 | public: |
94 | ConstIterator(); | 94 | ConstIterator(); |
95 | ConstIterator( const ConstIterator & ); | 95 | ConstIterator( const ConstIterator & ); |
96 | ~ConstIterator(); | 96 | ~ConstIterator(); |
97 | 97 | ||
98 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
99 | const Addressee &operator*() const; | 99 | const Addressee &operator*() const; |
100 | const Addressee* operator->() const; | 100 | const Addressee* operator->() const; |
101 | ConstIterator &operator++(); | 101 | ConstIterator &operator++(); |
102 | ConstIterator &operator++(int); | 102 | ConstIterator &operator++(int); |
103 | ConstIterator &operator--(); | 103 | ConstIterator &operator--(); |
104 | ConstIterator &operator--(int); | 104 | ConstIterator &operator--(int); |
105 | bool operator==( const ConstIterator &it ); | 105 | bool operator==( const ConstIterator &it ); |
106 | bool operator!=( const ConstIterator &it ); | 106 | bool operator!=( const ConstIterator &it ); |
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 | AddressBook( const QString &config, const QString &family ); |
120 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
121 | 121 | ||
122 | /** | 122 | /** |
123 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
124 | 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 |
125 | 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 |
126 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
127 | 127 | ||
128 | @see save() | 128 | @see save() |
129 | */ | 129 | */ |
130 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
131 | 131 | ||
132 | /** | 132 | /** |
133 | Load address book from file. | 133 | Load address book from file. |
134 | */ | 134 | */ |
135 | bool load(); | 135 | bool load(); |
136 | 136 | ||
137 | /** | 137 | /** |
138 | Save address book. The address book is saved to the file, the Ticket | 138 | Save address book. The address book is saved to the file, the Ticket |
139 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
140 | 140 | ||
141 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
142 | */ | 142 | */ |
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
144 | bool saveAB( ); | 144 | bool saveAB( ); |
145 | bool saveABphone( QString fileName ); | 145 | bool saveABphone( QString fileName ); |
146 | void smplifyAddressees(); | 146 | void smplifyAddressees(); |
147 | void removeSyncInfo( QString syncProfile); | 147 | void removeSyncInfo( QString syncProfile); |
148 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); | 148 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); |
149 | void export2File( QString fileName ); | 149 | void export2File( QString fileName ); |
150 | bool export2PhoneFormat( QStringList uids ,QString fileName ); | 150 | bool export2PhoneFormat( QStringList uids ,QString fileName ); |
151 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); | 151 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); |
152 | void setUntagged( bool setNonSyncTagged = false ); | 152 | void setUntagged( bool setNonSyncTagged = false ); |
153 | void removeUntagged(); | 153 | void removeUntagged(); |
154 | void findNewExtIds( QString fileName, QString currentSyncDevice ); | 154 | void findNewExtIds( QString fileName, QString currentSyncDevice ); |
155 | /** | 155 | /** |
156 | Returns a iterator for first entry of address book. | 156 | Returns a iterator for first entry of address book. |
157 | */ | 157 | */ |
158 | Iterator begin(); | 158 | Iterator begin(); |
159 | 159 | ||
160 | /** | 160 | /** |
161 | Returns a const iterator for first entry of address book. | 161 | Returns a const iterator for first entry of address book. |
162 | */ | 162 | */ |
163 | ConstIterator begin() const; | 163 | ConstIterator begin() const; |
164 | 164 | ||
165 | /** | 165 | /** |
166 | Returns a iterator for first entry of address book. | 166 | Returns a iterator for first entry of address book. |
167 | */ | 167 | */ |
168 | Iterator end(); | 168 | Iterator end(); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | Returns a const iterator for first entry of address book. | 171 | Returns a const iterator for first entry of address book. |
172 | */ | 172 | */ |
173 | ConstIterator end() const; | 173 | ConstIterator end() const; |
174 | 174 | ||
175 | /** | 175 | /** |
176 | Removes all entries from address book. | 176 | Removes all entries from address book. |
177 | */ | 177 | */ |
178 | void clear(); | 178 | void clear(); |
179 | 179 | ||
180 | /** | 180 | /** |
181 | Insert an Addressee object into address book. If an object with the same | 181 | Insert an Addressee object into address book. If an object with the same |
182 | unique id already exists in the address book it it replaced by the new | 182 | unique id already exists in the address book it it replaced by the new |
183 | one. If not the new object is appended to the address book. | 183 | one. If not the new object is appended to the address book. |
184 | */ | 184 | */ |
185 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 185 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
186 | 186 | ||
187 | /** | 187 | /** |
188 | Removes entry from the address book. | 188 | Removes entry from the address book. |
189 | */ | 189 | */ |
190 | void removeAddressee( const Addressee & ); | 190 | void removeAddressee( const Addressee & ); |
191 | 191 | ||
192 | /** | 192 | /** |
193 | This is like @ref removeAddressee() just above, with the difference that | 193 | This is like @ref removeAddressee() just above, with the difference that |
194 | the first element is a iterator, returned by @ref begin(). | 194 | the first element is a iterator, returned by @ref begin(). |
195 | */ | 195 | */ |
196 | void removeAddressee( const Iterator & ); | 196 | void removeAddressee( const Iterator & ); |
197 | 197 | ||
198 | /** | 198 | /** |
199 | Find the specified entry in address book. Returns end(), if the entry | 199 | Find the specified entry in address book. Returns end(), if the entry |
200 | couldn't be found. | 200 | couldn't be found. |
201 | */ | 201 | */ |
202 | Iterator find( const Addressee & ); | 202 | Iterator find( const Addressee & ); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | Find the entry specified by an unique id. Returns an empty Addressee | 205 | Find the entry specified by an unique id. Returns an empty Addressee |
206 | object, if the address book does not contain an entry with this id. | 206 | object, if the address book does not contain an entry with this id. |
207 | */ | 207 | */ |
208 | Addressee findByUid( const QString & ); | 208 | Addressee findByUid( const QString & ); |
209 | 209 | ||
210 | 210 | ||
211 | /** | 211 | /** |
212 | Returns a list of all addressees in the address book. This list can | 212 | Returns a list of all addressees in the address book. This list can |
213 | be sorted with @ref KABC::AddresseeList for example. | 213 | be sorted with @ref KABC::AddresseeList for example. |
214 | */ | 214 | */ |
215 | Addressee::List allAddressees(); | 215 | Addressee::List allAddressees(); |
216 | 216 | ||
217 | /** | 217 | /** |
218 | Find all entries with the specified name in the address book. Returns | 218 | Find all entries with the specified name in the address book. Returns |
219 | an empty list, if no entries could be found. | 219 | an empty list, if no entries could be found. |
220 | */ | 220 | */ |
221 | Addressee::List findByName( const QString & ); | 221 | Addressee::List findByName( const QString & ); |
222 | 222 | ||
223 | /** | 223 | /** |
224 | Find all entries with the specified email address in the address book. | 224 | Find all entries with the specified email address in the address book. |
225 | Returns an empty list, if no entries could be found. | 225 | Returns an empty list, if no entries could be found. |
226 | */ | 226 | */ |
227 | Addressee::List findByEmail( const QString & ); | 227 | Addressee::List findByEmail( const QString & ); |
228 | 228 | ||
229 | /** | 229 | /** |
230 | Find all entries wich have the specified category in the address book. | 230 | Find all entries wich have the specified category in the address book. |
231 | Returns an empty list, if no entries could be found. | 231 | Returns an empty list, if no entries could be found. |
232 | */ | 232 | */ |
233 | Addressee::List findByCategory( const QString & ); | 233 | Addressee::List findByCategory( const QString & ); |
234 | 234 | ||
235 | /** | 235 | /** |
236 | Return a string identifying this addressbook. | 236 | Return a string identifying this addressbook. |
237 | */ | 237 | */ |
238 | virtual QString identifier(); | 238 | virtual QString identifier(); |
239 | 239 | ||
240 | /** | 240 | /** |
241 | Used for debug output. | 241 | Used for debug output. |
242 | */ | 242 | */ |
243 | void dump() const; | 243 | void dump() const; |
244 | 244 | ||
245 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 245 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
246 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 246 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
247 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 247 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
248 | 248 | ||
249 | /** | 249 | /** |
250 | Return list of all Fields known to the address book which are associated | 250 | Return list of all Fields known to the address book which are associated |
251 | with the given field category. | 251 | with the given field category. |
252 | */ | 252 | */ |
253 | Field::List fields( int category = Field::All ); | 253 | Field::List fields( int category = Field::All ); |
254 | 254 | ||
255 | /** | 255 | /** |
256 | Add custom field to address book. | 256 | Add custom field to address book. |
257 | 257 | ||
258 | @param label User visible label of the field. | 258 | @param label User visible label of the field. |
259 | @param category Ored list of field categories. | 259 | @param category Ored list of field categories. |
260 | @param key Identifier used as key for reading and writing the field. | 260 | @param key Identifier used as key for reading and writing the field. |
261 | @param app String used as application key for reading and writing | 261 | @param app String used as application key for reading and writing |
262 | the field. | 262 | the field. |
263 | */ | 263 | */ |
264 | bool addCustomField( const QString &label, int category = Field::All, | 264 | bool addCustomField( const QString &label, int category = Field::All, |
265 | const QString &key = QString::null, | 265 | const QString &key = QString::null, |
266 | const QString &app = QString::null ); | 266 | const QString &app = QString::null ); |
267 | 267 | ||
268 | 268 | ||
269 | /** | 269 | /** |
270 | Add address book resource. | 270 | Add address book resource. |
271 | */ | 271 | */ |
272 | bool addResource( Resource * ); | 272 | bool addResource( Resource * ); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | Remove address book resource. | 275 | Remove address book resource. |
276 | */ | 276 | */ |
277 | void removeResources(); | 277 | void removeResources(); |
278 | bool removeResource( Resource * ); | 278 | bool removeResource( Resource * ); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | Return pointer list of all resources. | 281 | Return pointer list of all resources. |
282 | */ | 282 | */ |
283 | QPtrList<Resource> resources(); | 283 | QPtrList<Resource> resources(); |
284 | 284 | ||
285 | /** | 285 | /** |
286 | Set the @p ErrorHandler, that is used by @ref error() to | 286 | Set the @p ErrorHandler, that is used by @ref error() to |
287 | provide gui-independend error messages. | 287 | provide gui-independend error messages. |
288 | */ | 288 | */ |
289 | void setErrorHandler( ErrorHandler * ); | 289 | void setErrorHandler( ErrorHandler * ); |
290 | 290 | ||
291 | /** | 291 | /** |
292 | Shows gui independend error messages. | 292 | Shows gui independend error messages. |
293 | */ | 293 | */ |
294 | void error( const QString& ); | 294 | void error( const QString& ); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | Query all resources to clean up their lock files | 297 | Query all resources to clean up their lock files |
298 | */ | 298 | */ |
299 | void cleanUp(); | 299 | void cleanUp(); |
300 | 300 | ||
301 | // sync stuff | 301 | // sync stuff |
302 | //Addressee::List getExternLastSyncAddressees(); | 302 | //Addressee::List getExternLastSyncAddressees(); |
303 | void resetTempSyncStat(); | 303 | void resetTempSyncStat(); |
304 | QStringList uidList(); | 304 | QStringList uidList(); |
305 | void removeSyncAddressees( bool removeDeleted = false ); | 305 | void removeSyncAddressees( bool removeDeleted = false ); |
306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); | 306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); |
307 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 307 | const Addressee findByExternUid( const QString& uid , const QString& profile ) const; |
308 | bool containsExternalUid( const QString& uid ); | 308 | bool containsExternalUid( const QString& uid ); |
309 | 309 | ||
310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); | 310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); |
311 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); | 311 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); |
312 | signals: | 312 | signals: |
313 | /** | 313 | /** |
314 | Emitted, when the address book has changed on disk. | 314 | Emitted, when the address book has changed on disk. |
315 | */ | 315 | */ |
316 | void addressBookChanged( AddressBook * ); | 316 | void addressBookChanged( AddressBook * ); |
317 | 317 | ||
318 | /** | 318 | /** |
319 | Emitted, when the address book has been locked for writing. | 319 | Emitted, when the address book has been locked for writing. |
320 | */ | 320 | */ |
321 | void addressBookLocked( AddressBook * ); | 321 | void addressBookLocked( AddressBook * ); |
322 | 322 | ||
323 | /** | 323 | /** |
324 | Emitted, when the address book has been unlocked. | 324 | Emitted, when the address book has been unlocked. |
325 | */ | 325 | */ |
326 | void addressBookUnlocked( AddressBook * ); | 326 | void addressBookUnlocked( AddressBook * ); |
327 | 327 | ||
328 | protected: | 328 | protected: |
329 | void deleteRemovedAddressees(); | 329 | void deleteRemovedAddressees(); |
330 | void setStandardResource( Resource * ); | 330 | void setStandardResource( Resource * ); |
331 | Resource *standardResource(); | 331 | Resource *standardResource(); |
332 | KRES::Manager<Resource> *resourceManager(); | 332 | KRES::Manager<Resource> *resourceManager(); |
333 | 333 | ||
334 | void init(const QString &config, const QString &family); | 334 | void init(const QString &config, const QString &family); |
335 | 335 | ||
336 | private: | 336 | private: |
337 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 337 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
338 | 338 | ||
339 | 339 | ||
340 | struct AddressBookData; | 340 | struct AddressBookData; |
341 | AddressBookData *d; | 341 | AddressBookData *d; |
342 | bool blockLSEchange; | 342 | bool blockLSEchange; |
343 | }; | 343 | }; |
344 | 344 | ||
345 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 345 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
346 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 346 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | #endif | 350 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index d60cd6b..3b238f5 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,2141 +1,2141 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
260 | int find = t[iii].find (':')+1; | 260 | int find = t[iii].find (':')+1; |
261 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 261 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
262 | if ( find < t[iii].length()) | 262 | if ( find < t[iii].length()) |
263 | l.append( t[iii] ); | 263 | l.append( t[iii] ); |
264 | 264 | ||
265 | } | 265 | } |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
273 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | 275 | ||
276 | #if 0 | 276 | #if 0 |
277 | for ( iii = 0; iii < l.count(); ++iii) | 277 | for ( iii = 0; iii < l.count(); ++iii) |
278 | qDebug("%d***%s***",iii,l[iii].latin1()); | 278 | qDebug("%d***%s***",iii,l[iii].latin1()); |
279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
280 | #endif | 280 | #endif |
281 | 281 | ||
282 | setCsum( dev, QString::number (cs )); | 282 | setCsum( dev, QString::number (cs )); |
283 | } | 283 | } |
284 | 284 | ||
285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
286 | { | 286 | { |
287 | 287 | ||
288 | detach(); | 288 | detach(); |
289 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 289 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
290 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 290 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
291 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 291 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
292 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 292 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
293 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 293 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
294 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 294 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
295 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 295 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
296 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 296 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
297 | if ( !mData->birthday.isValid() ) | 297 | if ( !mData->birthday.isValid() ) |
298 | if ( ad.mData->birthday.isValid()) | 298 | if ( ad.mData->birthday.isValid()) |
299 | mData->birthday = ad.mData->birthday; | 299 | mData->birthday = ad.mData->birthday; |
300 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 300 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
301 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 301 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
302 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 302 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
303 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 303 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
304 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 304 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
305 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 305 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
306 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 306 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
307 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 307 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
308 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 308 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
309 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 309 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
310 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 310 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
311 | QStringList t; | 311 | QStringList t; |
312 | QStringList tAD; | 312 | QStringList tAD; |
313 | uint iii; | 313 | uint iii; |
314 | 314 | ||
315 | // ********** phone numbers | 315 | // ********** phone numbers |
316 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 316 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
317 | PhoneNumber::List::Iterator phoneItAD; | 317 | PhoneNumber::List::Iterator phoneItAD; |
318 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 318 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
319 | bool found = false; | 319 | bool found = false; |
320 | PhoneNumber::List::Iterator it; | 320 | PhoneNumber::List::Iterator it; |
321 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 321 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
322 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 322 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
323 | found = true; | 323 | found = true; |
324 | (*it).setType( ( *phoneItAD ).type() ); | 324 | (*it).setType( ( *phoneItAD ).type() ); |
325 | (*it).setNumber( ( *phoneItAD ).number() ); | 325 | (*it).setNumber( ( *phoneItAD ).number() ); |
326 | break; | 326 | break; |
327 | } | 327 | } |
328 | } | 328 | } |
329 | // if ( isSubSet && ! found ) | 329 | // if ( isSubSet && ! found ) |
330 | if ( ! found ) // LR try this one... | 330 | if ( ! found ) // LR try this one... |
331 | mData->phoneNumbers.append( *phoneItAD ); | 331 | mData->phoneNumbers.append( *phoneItAD ); |
332 | } | 332 | } |
333 | if ( isSubSet ) { | 333 | if ( isSubSet ) { |
334 | // ************* emails; | 334 | // ************* emails; |
335 | t = mData->emails; | 335 | t = mData->emails; |
336 | tAD = ad.mData->emails; | 336 | tAD = ad.mData->emails; |
337 | for ( iii = 0; iii < tAD.count(); ++iii) | 337 | for ( iii = 0; iii < tAD.count(); ++iii) |
338 | if ( !t.contains(tAD[iii] ) ) | 338 | if ( !t.contains(tAD[iii] ) ) |
339 | mData->emails.append( tAD[iii] ); | 339 | mData->emails.append( tAD[iii] ); |
340 | } | 340 | } |
341 | 341 | ||
342 | // ************* categories; | 342 | // ************* categories; |
343 | t = mData->categories; | 343 | t = mData->categories; |
344 | tAD = ad.mData->categories; | 344 | tAD = ad.mData->categories; |
345 | for ( iii = 0; iii < tAD.count(); ++iii) | 345 | for ( iii = 0; iii < tAD.count(); ++iii) |
346 | if ( !t.contains(tAD[iii] ) ) | 346 | if ( !t.contains(tAD[iii] ) ) |
347 | mData->categories.append( tAD[iii] ); | 347 | mData->categories.append( tAD[iii] ); |
348 | QStringList::ConstIterator it; | 348 | QStringList::ConstIterator it; |
349 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 349 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
350 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 350 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
351 | bool found = false; | 351 | bool found = false; |
352 | QStringList::ConstIterator itL; | 352 | QStringList::ConstIterator itL; |
353 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 353 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
354 | if ( (*itL).startsWith( qualifiedName ) ) { | 354 | if ( (*itL).startsWith( qualifiedName ) ) { |
355 | found = true; | 355 | found = true; |
356 | break; | 356 | break; |
357 | } | 357 | } |
358 | } | 358 | } |
359 | if ( ! found ) { | 359 | if ( ! found ) { |
360 | mData->custom.append( *it ); | 360 | mData->custom.append( *it ); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 363 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
364 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 364 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
365 | if ( !mData->sound.isIntern() ) { | 365 | if ( !mData->sound.isIntern() ) { |
366 | if ( mData->sound.url().isEmpty() ) { | 366 | if ( mData->sound.url().isEmpty() ) { |
367 | mData->sound = ad.mData->sound; | 367 | mData->sound = ad.mData->sound; |
368 | } | 368 | } |
369 | } | 369 | } |
370 | if ( !mData->agent.isIntern() ) { | 370 | if ( !mData->agent.isIntern() ) { |
371 | if ( mData->agent.url().isEmpty() ) { | 371 | if ( mData->agent.url().isEmpty() ) { |
372 | mData->agent = ad.mData->agent; | 372 | mData->agent = ad.mData->agent; |
373 | } | 373 | } |
374 | } | 374 | } |
375 | { | 375 | { |
376 | Key::List::Iterator itA; | 376 | Key::List::Iterator itA; |
377 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 377 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
378 | bool found = false; | 378 | bool found = false; |
379 | Key::List::Iterator it; | 379 | Key::List::Iterator it; |
380 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 380 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
381 | if ( (*it) == (*itA)) { | 381 | if ( (*it) == (*itA)) { |
382 | found = true; | 382 | found = true; |
383 | break; | 383 | break; |
384 | 384 | ||
385 | } | 385 | } |
386 | } | 386 | } |
387 | if ( ! found ) { | 387 | if ( ! found ) { |
388 | mData->keys.append( *itA ); | 388 | mData->keys.append( *itA ); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | KABC::Address::List::Iterator addressIterA; | 392 | KABC::Address::List::Iterator addressIterA; |
393 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 393 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
394 | bool found = false; | 394 | bool found = false; |
395 | KABC::Address::List::Iterator addressIter; | 395 | KABC::Address::List::Iterator addressIter; |
396 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 396 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
397 | ++addressIter ) { | 397 | ++addressIter ) { |
398 | if ( (*addressIter) == (*addressIterA)) { | 398 | if ( (*addressIter) == (*addressIterA)) { |
399 | found = true; | 399 | found = true; |
400 | (*addressIter).setType( (*addressIterA).type() ); | 400 | (*addressIter).setType( (*addressIterA).type() ); |
401 | break; | 401 | break; |
402 | } | 402 | } |
403 | 403 | ||
404 | } | 404 | } |
405 | if ( isSubSet && ! found ) { | 405 | if ( isSubSet && ! found ) { |
406 | mData->addresses.append( *addressIterA ); | 406 | mData->addresses.append( *addressIterA ); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | //qDebug("merge contact %s ", ad.uid().latin1()); | 409 | //qDebug("merge contact %s ", ad.uid().latin1()); |
410 | setUid( ad.uid() ); | 410 | setUid( ad.uid() ); |
411 | setRevision( ad.revision() ); | 411 | setRevision( ad.revision() ); |
412 | } | 412 | } |
413 | 413 | ||
414 | bool Addressee::removeVoice() | 414 | bool Addressee::removeVoice() |
415 | { | 415 | { |
416 | PhoneNumber::List phoneN = phoneNumbers(); | 416 | PhoneNumber::List phoneN = phoneNumbers(); |
417 | PhoneNumber::List::Iterator phoneIt; | 417 | PhoneNumber::List::Iterator phoneIt; |
418 | bool found = false; | 418 | bool found = false; |
419 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 419 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
420 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 420 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
421 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 421 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
422 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 422 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
423 | insertPhoneNumber( (*phoneIt) ); | 423 | insertPhoneNumber( (*phoneIt) ); |
424 | found = true; | 424 | found = true; |
425 | } | 425 | } |
426 | } | 426 | } |
427 | 427 | ||
428 | } | 428 | } |
429 | return found; | 429 | return found; |
430 | } | 430 | } |
431 | 431 | ||
432 | bool Addressee::containsAdr(const Addressee& ad ) | 432 | bool Addressee::containsAdr(const Addressee& ad ) |
433 | { | 433 | { |
434 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 434 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
435 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 435 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
436 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 436 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
437 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 437 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
438 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 438 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
439 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 439 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
440 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 440 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
441 | 441 | ||
442 | // compare phone numbers | 442 | // compare phone numbers |
443 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 443 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
444 | PhoneNumber::List::Iterator phoneIt; | 444 | PhoneNumber::List::Iterator phoneIt; |
445 | bool found = false; | 445 | bool found = false; |
446 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 446 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
447 | bool found = false; | 447 | bool found = false; |
448 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 448 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
449 | PhoneNumber::List::Iterator phoneItL; | 449 | PhoneNumber::List::Iterator phoneItL; |
450 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 450 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
451 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 451 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
452 | found = true; | 452 | found = true; |
453 | break; | 453 | break; |
454 | } | 454 | } |
455 | } | 455 | } |
456 | if ( ! found ) | 456 | if ( ! found ) |
457 | return false; | 457 | return false; |
458 | } | 458 | } |
459 | return true; | 459 | return true; |
460 | 460 | ||
461 | } | 461 | } |
462 | void Addressee::simplifyAddresses() | 462 | void Addressee::simplifyAddresses() |
463 | { | 463 | { |
464 | 464 | ||
465 | 465 | ||
466 | Address::List list; | 466 | Address::List list; |
467 | Address::List::Iterator it; | 467 | Address::List::Iterator it; |
468 | Address::List::Iterator it2; | 468 | Address::List::Iterator it2; |
469 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 469 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
470 | it2 = it; | 470 | it2 = it; |
471 | ++it2; | 471 | ++it2; |
472 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 472 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
473 | if ( (*it) == (*it2) ) { | 473 | if ( (*it) == (*it2) ) { |
474 | list.append( *it ); | 474 | list.append( *it ); |
475 | break; | 475 | break; |
476 | } | 476 | } |
477 | } | 477 | } |
478 | } | 478 | } |
479 | for( it = list.begin(); it != list.end(); ++it ) { | 479 | for( it = list.begin(); it != list.end(); ++it ) { |
480 | removeAddress( (*it) ); | 480 | removeAddress( (*it) ); |
481 | } | 481 | } |
482 | 482 | ||
483 | list.clear(); | 483 | list.clear(); |
484 | int max = 2; | 484 | int max = 2; |
485 | if ( mData->url.isValid() ) | 485 | if ( mData->url.isValid() ) |
486 | max = 1; | 486 | max = 1; |
487 | if ( mData->addresses.count() <= max ) return ; | 487 | if ( mData->addresses.count() <= max ) return ; |
488 | int count = 0; | 488 | int count = 0; |
489 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 489 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
490 | if ( count >= max ) | 490 | if ( count >= max ) |
491 | list.append( *it ); | 491 | list.append( *it ); |
492 | ++count; | 492 | ++count; |
493 | } | 493 | } |
494 | for( it = list.begin(); it != list.end(); ++it ) { | 494 | for( it = list.begin(); it != list.end(); ++it ) { |
495 | removeAddress( (*it) ); | 495 | removeAddress( (*it) ); |
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
499 | // removes all emails but the first | 499 | // removes all emails but the first |
500 | // needed by phone sync | 500 | // needed by phone sync |
501 | void Addressee::simplifyEmails() | 501 | void Addressee::simplifyEmails() |
502 | { | 502 | { |
503 | if ( mData->emails.count() == 0 ) return ; | 503 | if ( mData->emails.count() == 0 ) return ; |
504 | QString email = mData->emails.first(); | 504 | QString email = mData->emails.first(); |
505 | detach(); | 505 | detach(); |
506 | mData->emails.clear(); | 506 | mData->emails.clear(); |
507 | mData->emails.append( email ); | 507 | mData->emails.append( email ); |
508 | } | 508 | } |
509 | 509 | ||
510 | void Addressee::simplifyPhoneNumbers() | 510 | void Addressee::simplifyPhoneNumbers() |
511 | { | 511 | { |
512 | int max = 4; | 512 | int max = 4; |
513 | int inList = mData->phoneNumbers.count(); | 513 | int inList = mData->phoneNumbers.count(); |
514 | KABC::PhoneNumber::List removeNumbers; | 514 | KABC::PhoneNumber::List removeNumbers; |
515 | KABC::PhoneNumber::List::Iterator phoneIter; | 515 | KABC::PhoneNumber::List::Iterator phoneIter; |
516 | if ( inList > max ) { | 516 | if ( inList > max ) { |
517 | // delete non-preferred numbers | 517 | // delete non-preferred numbers |
518 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 518 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
519 | ++phoneIter ) { | 519 | ++phoneIter ) { |
520 | if ( inList > max ) { | 520 | if ( inList > max ) { |
521 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 521 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
522 | removeNumbers.append( ( *phoneIter ) ); | 522 | removeNumbers.append( ( *phoneIter ) ); |
523 | --inList; | 523 | --inList; |
524 | } | 524 | } |
525 | } else | 525 | } else |
526 | break; | 526 | break; |
527 | } | 527 | } |
528 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 528 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
529 | ++phoneIter ) { | 529 | ++phoneIter ) { |
530 | removePhoneNumber(( *phoneIter )); | 530 | removePhoneNumber(( *phoneIter )); |
531 | } | 531 | } |
532 | // delete preferred numbers | 532 | // delete preferred numbers |
533 | if ( inList > max ) { | 533 | if ( inList > max ) { |
534 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 534 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
535 | ++phoneIter ) { | 535 | ++phoneIter ) { |
536 | if ( inList > max ) { | 536 | if ( inList > max ) { |
537 | removeNumbers.append( ( *phoneIter ) ); | 537 | removeNumbers.append( ( *phoneIter ) ); |
538 | --inList; | 538 | --inList; |
539 | } else | 539 | } else |
540 | break; | 540 | break; |
541 | } | 541 | } |
542 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 542 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
543 | ++phoneIter ) { | 543 | ++phoneIter ) { |
544 | removePhoneNumber(( *phoneIter )); | 544 | removePhoneNumber(( *phoneIter )); |
545 | } | 545 | } |
546 | } | 546 | } |
547 | } | 547 | } |
548 | // remove non-numeric characters | 548 | // remove non-numeric characters |
549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
550 | ++phoneIter ) { | 550 | ++phoneIter ) { |
551 | if ( ! ( *phoneIter ).simplifyNumber() ) | 551 | if ( ! ( *phoneIter ).simplifyNumber() ) |
552 | removeNumbers.append( ( *phoneIter ) ); | 552 | removeNumbers.append( ( *phoneIter ) ); |
553 | } | 553 | } |
554 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 554 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
555 | ++phoneIter ) { | 555 | ++phoneIter ) { |
556 | removePhoneNumber(( *phoneIter )); | 556 | removePhoneNumber(( *phoneIter )); |
557 | } | 557 | } |
558 | } | 558 | } |
559 | void Addressee::simplifyPhoneNumberTypes() | 559 | void Addressee::simplifyPhoneNumberTypes() |
560 | { | 560 | { |
561 | KABC::PhoneNumber::List::Iterator phoneIter; | 561 | KABC::PhoneNumber::List::Iterator phoneIter; |
562 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 562 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
563 | ++phoneIter ) | 563 | ++phoneIter ) |
564 | ( *phoneIter ).simplifyType(); | 564 | ( *phoneIter ).simplifyType(); |
565 | } | 565 | } |
566 | void Addressee::removeID(const QString &prof) | 566 | void Addressee::removeID(const QString &prof) |
567 | { | 567 | { |
568 | detach(); | 568 | detach(); |
569 | if ( prof.isEmpty() ) | 569 | if ( prof.isEmpty() ) |
570 | mData->mExternalId = ":"; | 570 | mData->mExternalId = ":"; |
571 | else | 571 | else |
572 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 572 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
573 | 573 | ||
574 | } | 574 | } |
575 | void Addressee::setID( const QString & prof , const QString & id ) | 575 | void Addressee::setID( const QString & prof , const QString & id ) |
576 | { | 576 | { |
577 | detach(); | 577 | detach(); |
578 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 578 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
579 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 579 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
580 | } | 580 | } |
581 | void Addressee::setTempSyncStat( int id ) | 581 | void Addressee::setTempSyncStat( int id ) |
582 | { | 582 | { |
583 | if ( mData->mTempSyncStat == id ) return; | 583 | if ( mData->mTempSyncStat == id ) return; |
584 | detach(); | 584 | detach(); |
585 | mData->mTempSyncStat = id; | 585 | mData->mTempSyncStat = id; |
586 | } | 586 | } |
587 | int Addressee::tempSyncStat() const | 587 | int Addressee::tempSyncStat() const |
588 | { | 588 | { |
589 | return mData->mTempSyncStat; | 589 | return mData->mTempSyncStat; |
590 | } | 590 | } |
591 | 591 | ||
592 | QString Addressee::getID( const QString & prof) | 592 | const QString Addressee::getID( const QString & prof) const |
593 | { | 593 | { |
594 | return KIdManager::getId ( mData->mExternalId, prof ); | 594 | return KIdManager::getId ( mData->mExternalId, prof ); |
595 | } | 595 | } |
596 | 596 | ||
597 | void Addressee::setCsum( const QString & prof , const QString & id ) | 597 | void Addressee::setCsum( const QString & prof , const QString & id ) |
598 | { | 598 | { |
599 | detach(); | 599 | detach(); |
600 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 600 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
601 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 601 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
602 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 602 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
603 | } | 603 | } |
604 | 604 | ||
605 | QString Addressee::getCsum( const QString & prof) | 605 | const QString Addressee::getCsum( const QString & prof) const |
606 | { | 606 | { |
607 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 607 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
608 | } | 608 | } |
609 | 609 | ||
610 | void Addressee::setIDStr( const QString & s ) | 610 | void Addressee::setIDStr( const QString & s ) |
611 | { | 611 | { |
612 | detach(); | 612 | detach(); |
613 | mData->mExternalId = s; | 613 | mData->mExternalId = s; |
614 | } | 614 | } |
615 | 615 | ||
616 | QString Addressee::IDStr() const | 616 | const QString Addressee::IDStr() const |
617 | { | 617 | { |
618 | return mData->mExternalId; | 618 | return mData->mExternalId; |
619 | } | 619 | } |
620 | 620 | ||
621 | void Addressee::setExternalUID( const QString &id ) | 621 | void Addressee::setExternalUID( const QString &id ) |
622 | { | 622 | { |
623 | if ( id == mData->externalUID ) return; | 623 | if ( id == mData->externalUID ) return; |
624 | detach(); | 624 | detach(); |
625 | mData->empty = false; | 625 | mData->empty = false; |
626 | mData->externalUID = id; | 626 | mData->externalUID = id; |
627 | } | 627 | } |
628 | 628 | ||
629 | QString Addressee::externalUID() const | 629 | const QString Addressee::externalUID() const |
630 | { | 630 | { |
631 | return mData->externalUID; | 631 | return mData->externalUID; |
632 | } | 632 | } |
633 | void Addressee::setOriginalExternalUID( const QString &id ) | 633 | void Addressee::setOriginalExternalUID( const QString &id ) |
634 | { | 634 | { |
635 | if ( id == mData->originalExternalUID ) return; | 635 | if ( id == mData->originalExternalUID ) return; |
636 | detach(); | 636 | detach(); |
637 | mData->empty = false; | 637 | mData->empty = false; |
638 | //qDebug("*******Set orig uid %s ", id.latin1()); | 638 | //qDebug("*******Set orig uid %s ", id.latin1()); |
639 | mData->originalExternalUID = id; | 639 | mData->originalExternalUID = id; |
640 | } | 640 | } |
641 | 641 | ||
642 | QString Addressee::originalExternalUID() const | 642 | QString Addressee::originalExternalUID() const |
643 | { | 643 | { |
644 | return mData->originalExternalUID; | 644 | return mData->originalExternalUID; |
645 | } | 645 | } |
646 | 646 | ||
647 | void Addressee::setUid( const QString &id ) | 647 | void Addressee::setUid( const QString &id ) |
648 | { | 648 | { |
649 | if ( id == mData->uid ) return; | 649 | if ( id == mData->uid ) return; |
650 | detach(); | 650 | detach(); |
651 | //qDebug("****setuid %s ", id.latin1()); | 651 | //qDebug("****setuid %s ", id.latin1()); |
652 | mData->empty = false; | 652 | mData->empty = false; |
653 | mData->uid = id; | 653 | mData->uid = id; |
654 | } | 654 | } |
655 | 655 | ||
656 | QString Addressee::uid() const | 656 | const QString Addressee::uid() const |
657 | { | 657 | { |
658 | if ( mData->uid.isEmpty() ) | 658 | if ( mData->uid.isEmpty() ) |
659 | mData->uid = KApplication::randomString( 10 ); | 659 | mData->uid = KApplication::randomString( 10 ); |
660 | 660 | ||
661 | return mData->uid; | 661 | return mData->uid; |
662 | } | 662 | } |
663 | 663 | ||
664 | QString Addressee::uidLabel() | 664 | QString Addressee::uidLabel() |
665 | { | 665 | { |
666 | return i18n("Unique Identifier"); | 666 | return i18n("Unique Identifier"); |
667 | } | 667 | } |
668 | 668 | ||
669 | void Addressee::setName( const QString &name ) | 669 | void Addressee::setName( const QString &name ) |
670 | { | 670 | { |
671 | if ( name == mData->name ) return; | 671 | if ( name == mData->name ) return; |
672 | detach(); | 672 | detach(); |
673 | mData->empty = false; | 673 | mData->empty = false; |
674 | mData->name = name; | 674 | mData->name = name; |
675 | } | 675 | } |
676 | 676 | ||
677 | QString Addressee::name() const | 677 | QString Addressee::name() const |
678 | { | 678 | { |
679 | return mData->name; | 679 | return mData->name; |
680 | } | 680 | } |
681 | 681 | ||
682 | QString Addressee::nameLabel() | 682 | QString Addressee::nameLabel() |
683 | { | 683 | { |
684 | return i18n("Name"); | 684 | return i18n("Name"); |
685 | } | 685 | } |
686 | 686 | ||
687 | 687 | ||
688 | void Addressee::setFormattedName( const QString &formattedName ) | 688 | void Addressee::setFormattedName( const QString &formattedName ) |
689 | { | 689 | { |
690 | if ( formattedName == mData->formattedName ) return; | 690 | if ( formattedName == mData->formattedName ) return; |
691 | detach(); | 691 | detach(); |
692 | mData->empty = false; | 692 | mData->empty = false; |
693 | mData->formattedName = formattedName; | 693 | mData->formattedName = formattedName; |
694 | } | 694 | } |
695 | 695 | ||
696 | QString Addressee::formattedName() const | 696 | QString Addressee::formattedName() const |
697 | { | 697 | { |
698 | return mData->formattedName; | 698 | return mData->formattedName; |
699 | } | 699 | } |
700 | 700 | ||
701 | QString Addressee::formattedNameLabel() | 701 | QString Addressee::formattedNameLabel() |
702 | { | 702 | { |
703 | return i18n("Formatted Name"); | 703 | return i18n("Formatted Name"); |
704 | } | 704 | } |
705 | 705 | ||
706 | 706 | ||
707 | void Addressee::setFamilyName( const QString &familyName ) | 707 | void Addressee::setFamilyName( const QString &familyName ) |
708 | { | 708 | { |
709 | if ( familyName == mData->familyName ) return; | 709 | if ( familyName == mData->familyName ) return; |
710 | detach(); | 710 | detach(); |
711 | mData->empty = false; | 711 | mData->empty = false; |
712 | mData->familyName = familyName; | 712 | mData->familyName = familyName; |
713 | } | 713 | } |
714 | 714 | ||
715 | QString Addressee::familyName() const | 715 | QString Addressee::familyName() const |
716 | { | 716 | { |
717 | return mData->familyName; | 717 | return mData->familyName; |
718 | } | 718 | } |
719 | 719 | ||
720 | QString Addressee::familyNameLabel() | 720 | QString Addressee::familyNameLabel() |
721 | { | 721 | { |
722 | return i18n("Family Name"); | 722 | return i18n("Family Name"); |
723 | } | 723 | } |
724 | 724 | ||
725 | 725 | ||
726 | void Addressee::setGivenName( const QString &givenName ) | 726 | void Addressee::setGivenName( const QString &givenName ) |
727 | { | 727 | { |
728 | if ( givenName == mData->givenName ) return; | 728 | if ( givenName == mData->givenName ) return; |
729 | detach(); | 729 | detach(); |
730 | mData->empty = false; | 730 | mData->empty = false; |
731 | mData->givenName = givenName; | 731 | mData->givenName = givenName; |
732 | } | 732 | } |
733 | 733 | ||
734 | QString Addressee::givenName() const | 734 | QString Addressee::givenName() const |
735 | { | 735 | { |
736 | return mData->givenName; | 736 | return mData->givenName; |
737 | } | 737 | } |
738 | 738 | ||
739 | QString Addressee::givenNameLabel() | 739 | QString Addressee::givenNameLabel() |
740 | { | 740 | { |
741 | return i18n("Given Name"); | 741 | return i18n("Given Name"); |
742 | } | 742 | } |
743 | 743 | ||
744 | 744 | ||
745 | void Addressee::setAdditionalName( const QString &additionalName ) | 745 | void Addressee::setAdditionalName( const QString &additionalName ) |
746 | { | 746 | { |
747 | if ( additionalName == mData->additionalName ) return; | 747 | if ( additionalName == mData->additionalName ) return; |
748 | detach(); | 748 | detach(); |
749 | mData->empty = false; | 749 | mData->empty = false; |
750 | mData->additionalName = additionalName; | 750 | mData->additionalName = additionalName; |
751 | } | 751 | } |
752 | 752 | ||
753 | QString Addressee::additionalName() const | 753 | QString Addressee::additionalName() const |
754 | { | 754 | { |
755 | return mData->additionalName; | 755 | return mData->additionalName; |
756 | } | 756 | } |
757 | 757 | ||
758 | QString Addressee::additionalNameLabel() | 758 | QString Addressee::additionalNameLabel() |
759 | { | 759 | { |
760 | return i18n("Additional Names"); | 760 | return i18n("Additional Names"); |
761 | } | 761 | } |
762 | 762 | ||
763 | 763 | ||
764 | void Addressee::setPrefix( const QString &prefix ) | 764 | void Addressee::setPrefix( const QString &prefix ) |
765 | { | 765 | { |
766 | if ( prefix == mData->prefix ) return; | 766 | if ( prefix == mData->prefix ) return; |
767 | detach(); | 767 | detach(); |
768 | mData->empty = false; | 768 | mData->empty = false; |
769 | mData->prefix = prefix; | 769 | mData->prefix = prefix; |
770 | } | 770 | } |
771 | 771 | ||
772 | QString Addressee::prefix() const | 772 | QString Addressee::prefix() const |
773 | { | 773 | { |
774 | return mData->prefix; | 774 | return mData->prefix; |
775 | } | 775 | } |
776 | 776 | ||
777 | QString Addressee::prefixLabel() | 777 | QString Addressee::prefixLabel() |
778 | { | 778 | { |
779 | return i18n("Honorific Prefixes"); | 779 | return i18n("Honorific Prefixes"); |
780 | } | 780 | } |
781 | 781 | ||
782 | 782 | ||
783 | void Addressee::setSuffix( const QString &suffix ) | 783 | void Addressee::setSuffix( const QString &suffix ) |
784 | { | 784 | { |
785 | if ( suffix == mData->suffix ) return; | 785 | if ( suffix == mData->suffix ) return; |
786 | detach(); | 786 | detach(); |
787 | mData->empty = false; | 787 | mData->empty = false; |
788 | mData->suffix = suffix; | 788 | mData->suffix = suffix; |
789 | } | 789 | } |
790 | 790 | ||
791 | QString Addressee::suffix() const | 791 | QString Addressee::suffix() const |
792 | { | 792 | { |
793 | return mData->suffix; | 793 | return mData->suffix; |
794 | } | 794 | } |
795 | 795 | ||
796 | QString Addressee::suffixLabel() | 796 | QString Addressee::suffixLabel() |
797 | { | 797 | { |
798 | return i18n("Honorific Suffixes"); | 798 | return i18n("Honorific Suffixes"); |
799 | } | 799 | } |
800 | 800 | ||
801 | 801 | ||
802 | void Addressee::setNickName( const QString &nickName ) | 802 | void Addressee::setNickName( const QString &nickName ) |
803 | { | 803 | { |
804 | if ( nickName == mData->nickName ) return; | 804 | if ( nickName == mData->nickName ) return; |
805 | detach(); | 805 | detach(); |
806 | mData->empty = false; | 806 | mData->empty = false; |
807 | mData->nickName = nickName; | 807 | mData->nickName = nickName; |
808 | } | 808 | } |
809 | 809 | ||
810 | QString Addressee::nickName() const | 810 | QString Addressee::nickName() const |
811 | { | 811 | { |
812 | return mData->nickName; | 812 | return mData->nickName; |
813 | } | 813 | } |
814 | 814 | ||
815 | QString Addressee::nickNameLabel() | 815 | QString Addressee::nickNameLabel() |
816 | { | 816 | { |
817 | return i18n("Nick Name"); | 817 | return i18n("Nick Name"); |
818 | } | 818 | } |
819 | 819 | ||
820 | 820 | ||
821 | void Addressee::setBirthday( const QDateTime &birthday ) | 821 | void Addressee::setBirthday( const QDateTime &birthday ) |
822 | { | 822 | { |
823 | if ( birthday == mData->birthday ) return; | 823 | if ( birthday == mData->birthday ) return; |
824 | detach(); | 824 | detach(); |
825 | mData->empty = false; | 825 | mData->empty = false; |
826 | mData->birthday = birthday; | 826 | mData->birthday = birthday; |
827 | } | 827 | } |
828 | 828 | ||
829 | QDateTime Addressee::birthday() const | 829 | QDateTime Addressee::birthday() const |
830 | { | 830 | { |
831 | return mData->birthday; | 831 | return mData->birthday; |
832 | } | 832 | } |
833 | 833 | ||
834 | QString Addressee::birthdayLabel() | 834 | QString Addressee::birthdayLabel() |
835 | { | 835 | { |
836 | return i18n("Birthday"); | 836 | return i18n("Birthday"); |
837 | } | 837 | } |
838 | 838 | ||
839 | 839 | ||
840 | QString Addressee::homeAddressStreetLabel() | 840 | QString Addressee::homeAddressStreetLabel() |
841 | { | 841 | { |
842 | return i18n("Home Address Street"); | 842 | return i18n("Home Address Street"); |
843 | } | 843 | } |
844 | 844 | ||
845 | 845 | ||
846 | QString Addressee::homeAddressLocalityLabel() | 846 | QString Addressee::homeAddressLocalityLabel() |
847 | { | 847 | { |
848 | return i18n("Home Address Locality"); | 848 | return i18n("Home Address Locality"); |
849 | } | 849 | } |
850 | 850 | ||
851 | 851 | ||
852 | QString Addressee::homeAddressRegionLabel() | 852 | QString Addressee::homeAddressRegionLabel() |
853 | { | 853 | { |
854 | return i18n("Home Address Region"); | 854 | return i18n("Home Address Region"); |
855 | } | 855 | } |
856 | 856 | ||
857 | 857 | ||
858 | QString Addressee::homeAddressPostalCodeLabel() | 858 | QString Addressee::homeAddressPostalCodeLabel() |
859 | { | 859 | { |
860 | return i18n("Home Address Postal Code"); | 860 | return i18n("Home Address Postal Code"); |
861 | } | 861 | } |
862 | 862 | ||
863 | 863 | ||
864 | QString Addressee::homeAddressCountryLabel() | 864 | QString Addressee::homeAddressCountryLabel() |
865 | { | 865 | { |
866 | return i18n("Home Address Country"); | 866 | return i18n("Home Address Country"); |
867 | } | 867 | } |
868 | 868 | ||
869 | 869 | ||
870 | QString Addressee::homeAddressLabelLabel() | 870 | QString Addressee::homeAddressLabelLabel() |
871 | { | 871 | { |
872 | return i18n("Home Address Label"); | 872 | return i18n("Home Address Label"); |
873 | } | 873 | } |
874 | 874 | ||
875 | 875 | ||
876 | QString Addressee::businessAddressStreetLabel() | 876 | QString Addressee::businessAddressStreetLabel() |
877 | { | 877 | { |
878 | return i18n("Business Address Street"); | 878 | return i18n("Business Address Street"); |
879 | } | 879 | } |
880 | 880 | ||
881 | 881 | ||
882 | QString Addressee::businessAddressLocalityLabel() | 882 | QString Addressee::businessAddressLocalityLabel() |
883 | { | 883 | { |
884 | return i18n("Business Address Locality"); | 884 | return i18n("Business Address Locality"); |
885 | } | 885 | } |
886 | 886 | ||
887 | 887 | ||
888 | QString Addressee::businessAddressRegionLabel() | 888 | QString Addressee::businessAddressRegionLabel() |
889 | { | 889 | { |
890 | return i18n("Business Address Region"); | 890 | return i18n("Business Address Region"); |
891 | } | 891 | } |
892 | 892 | ||
893 | 893 | ||
894 | QString Addressee::businessAddressPostalCodeLabel() | 894 | QString Addressee::businessAddressPostalCodeLabel() |
895 | { | 895 | { |
896 | return i18n("Business Address Postal Code"); | 896 | return i18n("Business Address Postal Code"); |
897 | } | 897 | } |
898 | 898 | ||
899 | 899 | ||
900 | QString Addressee::businessAddressCountryLabel() | 900 | QString Addressee::businessAddressCountryLabel() |
901 | { | 901 | { |
902 | return i18n("Business Address Country"); | 902 | return i18n("Business Address Country"); |
903 | } | 903 | } |
904 | 904 | ||
905 | 905 | ||
906 | QString Addressee::businessAddressLabelLabel() | 906 | QString Addressee::businessAddressLabelLabel() |
907 | { | 907 | { |
908 | return i18n("Business Address Label"); | 908 | return i18n("Business Address Label"); |
909 | } | 909 | } |
910 | 910 | ||
911 | 911 | ||
912 | QString Addressee::homePhoneLabel() | 912 | QString Addressee::homePhoneLabel() |
913 | { | 913 | { |
914 | return i18n("Home Phone"); | 914 | return i18n("Home Phone"); |
915 | } | 915 | } |
916 | 916 | ||
917 | 917 | ||
918 | QString Addressee::businessPhoneLabel() | 918 | QString Addressee::businessPhoneLabel() |
919 | { | 919 | { |
920 | return i18n("Business Phone"); | 920 | return i18n("Business Phone"); |
921 | } | 921 | } |
922 | 922 | ||
923 | 923 | ||
924 | QString Addressee::mobilePhoneLabel() | 924 | QString Addressee::mobilePhoneLabel() |
925 | { | 925 | { |
926 | return i18n("Mobile Phone"); | 926 | return i18n("Mobile Phone"); |
927 | } | 927 | } |
928 | 928 | ||
929 | 929 | ||
930 | QString Addressee::homeFaxLabel() | 930 | QString Addressee::homeFaxLabel() |
931 | { | 931 | { |
932 | return i18n("Home Fax"); | 932 | return i18n("Home Fax"); |
933 | } | 933 | } |
934 | 934 | ||
935 | 935 | ||
936 | QString Addressee::businessFaxLabel() | 936 | QString Addressee::businessFaxLabel() |
937 | { | 937 | { |
938 | return i18n("Business Fax"); | 938 | return i18n("Business Fax"); |
939 | } | 939 | } |
940 | 940 | ||
941 | 941 | ||
942 | QString Addressee::carPhoneLabel() | 942 | QString Addressee::carPhoneLabel() |
943 | { | 943 | { |
944 | return i18n("Car Phone"); | 944 | return i18n("Car Phone"); |
945 | } | 945 | } |
946 | 946 | ||
947 | 947 | ||
948 | QString Addressee::isdnLabel() | 948 | QString Addressee::isdnLabel() |
949 | { | 949 | { |
950 | return i18n("ISDN"); | 950 | return i18n("ISDN"); |
951 | } | 951 | } |
952 | 952 | ||
953 | 953 | ||
954 | QString Addressee::pagerLabel() | 954 | QString Addressee::pagerLabel() |
955 | { | 955 | { |
956 | return i18n("Pager"); | 956 | return i18n("Pager"); |
957 | } | 957 | } |
958 | 958 | ||
959 | QString Addressee::sipLabel() | 959 | QString Addressee::sipLabel() |
960 | { | 960 | { |
961 | return i18n("SIP"); | 961 | return i18n("SIP"); |
962 | } | 962 | } |
963 | 963 | ||
964 | QString Addressee::emailLabel() | 964 | QString Addressee::emailLabel() |
965 | { | 965 | { |
966 | return i18n("Email Address"); | 966 | return i18n("Email Address"); |
967 | } | 967 | } |
968 | 968 | ||
969 | 969 | ||
970 | void Addressee::setMailer( const QString &mailer ) | 970 | void Addressee::setMailer( const QString &mailer ) |
971 | { | 971 | { |
972 | if ( mailer == mData->mailer ) return; | 972 | if ( mailer == mData->mailer ) return; |
973 | detach(); | 973 | detach(); |
974 | mData->empty = false; | 974 | mData->empty = false; |
975 | mData->mailer = mailer; | 975 | mData->mailer = mailer; |
976 | } | 976 | } |
977 | 977 | ||
978 | QString Addressee::mailer() const | 978 | QString Addressee::mailer() const |
979 | { | 979 | { |
980 | return mData->mailer; | 980 | return mData->mailer; |
981 | } | 981 | } |
982 | 982 | ||
983 | QString Addressee::mailerLabel() | 983 | QString Addressee::mailerLabel() |
984 | { | 984 | { |
985 | return i18n("Mail Client"); | 985 | return i18n("Mail Client"); |
986 | } | 986 | } |
987 | 987 | ||
988 | 988 | ||
989 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 989 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
990 | { | 990 | { |
991 | if ( timeZone == mData->timeZone ) return; | 991 | if ( timeZone == mData->timeZone ) return; |
992 | detach(); | 992 | detach(); |
993 | mData->empty = false; | 993 | mData->empty = false; |
994 | mData->timeZone = timeZone; | 994 | mData->timeZone = timeZone; |
995 | } | 995 | } |
996 | 996 | ||
997 | TimeZone Addressee::timeZone() const | 997 | TimeZone Addressee::timeZone() const |
998 | { | 998 | { |
999 | return mData->timeZone; | 999 | return mData->timeZone; |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | QString Addressee::timeZoneLabel() | 1002 | QString Addressee::timeZoneLabel() |
1003 | { | 1003 | { |
1004 | return i18n("Time Zone"); | 1004 | return i18n("Time Zone"); |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | 1007 | ||
1008 | void Addressee::setGeo( const Geo &geo ) | 1008 | void Addressee::setGeo( const Geo &geo ) |
1009 | { | 1009 | { |
1010 | if ( geo == mData->geo ) return; | 1010 | if ( geo == mData->geo ) return; |
1011 | detach(); | 1011 | detach(); |
1012 | mData->empty = false; | 1012 | mData->empty = false; |
1013 | mData->geo = geo; | 1013 | mData->geo = geo; |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | Geo Addressee::geo() const | 1016 | Geo Addressee::geo() const |
1017 | { | 1017 | { |
1018 | return mData->geo; | 1018 | return mData->geo; |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | QString Addressee::geoLabel() | 1021 | QString Addressee::geoLabel() |
1022 | { | 1022 | { |
1023 | return i18n("Geographic Position"); | 1023 | return i18n("Geographic Position"); |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | 1026 | ||
1027 | void Addressee::setTitle( const QString &title ) | 1027 | void Addressee::setTitle( const QString &title ) |
1028 | { | 1028 | { |
1029 | if ( title == mData->title ) return; | 1029 | if ( title == mData->title ) return; |
1030 | detach(); | 1030 | detach(); |
1031 | mData->empty = false; | 1031 | mData->empty = false; |
1032 | mData->title = title; | 1032 | mData->title = title; |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | QString Addressee::title() const | 1035 | QString Addressee::title() const |
1036 | { | 1036 | { |
1037 | return mData->title; | 1037 | return mData->title; |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | QString Addressee::titleLabel() | 1040 | QString Addressee::titleLabel() |
1041 | { | 1041 | { |
1042 | return i18n("Title"); | 1042 | return i18n("Title"); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | 1045 | ||
1046 | void Addressee::setRole( const QString &role ) | 1046 | void Addressee::setRole( const QString &role ) |
1047 | { | 1047 | { |
1048 | if ( role == mData->role ) return; | 1048 | if ( role == mData->role ) return; |
1049 | detach(); | 1049 | detach(); |
1050 | mData->empty = false; | 1050 | mData->empty = false; |
1051 | mData->role = role; | 1051 | mData->role = role; |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | QString Addressee::role() const | 1054 | QString Addressee::role() const |
1055 | { | 1055 | { |
1056 | return mData->role; | 1056 | return mData->role; |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | QString Addressee::roleLabel() | 1059 | QString Addressee::roleLabel() |
1060 | { | 1060 | { |
1061 | return i18n("Role"); | 1061 | return i18n("Role"); |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | 1064 | ||
1065 | void Addressee::setOrganization( const QString &organization ) | 1065 | void Addressee::setOrganization( const QString &organization ) |
1066 | { | 1066 | { |
1067 | if ( organization == mData->organization ) return; | 1067 | if ( organization == mData->organization ) return; |
1068 | detach(); | 1068 | detach(); |
1069 | mData->empty = false; | 1069 | mData->empty = false; |
1070 | mData->organization = organization; | 1070 | mData->organization = organization; |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | QString Addressee::organization() const | 1073 | QString Addressee::organization() const |
1074 | { | 1074 | { |
1075 | return mData->organization; | 1075 | return mData->organization; |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | QString Addressee::organizationLabel() | 1078 | QString Addressee::organizationLabel() |
1079 | { | 1079 | { |
1080 | return i18n("Organization"); | 1080 | return i18n("Organization"); |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | 1083 | ||
1084 | void Addressee::setNote( const QString ¬e ) | 1084 | void Addressee::setNote( const QString ¬e ) |
1085 | { | 1085 | { |
1086 | if ( note == mData->note ) return; | 1086 | if ( note == mData->note ) return; |
1087 | detach(); | 1087 | detach(); |
1088 | mData->empty = false; | 1088 | mData->empty = false; |
1089 | mData->note = note; | 1089 | mData->note = note; |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | QString Addressee::note() const | 1092 | QString Addressee::note() const |
1093 | { | 1093 | { |
1094 | return mData->note; | 1094 | return mData->note; |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | QString Addressee::noteLabel() | 1097 | QString Addressee::noteLabel() |
1098 | { | 1098 | { |
1099 | return i18n("Note"); | 1099 | return i18n("Note"); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | 1102 | ||
1103 | void Addressee::setProductId( const QString &productId ) | 1103 | void Addressee::setProductId( const QString &productId ) |
1104 | { | 1104 | { |
1105 | if ( productId == mData->productId ) return; | 1105 | if ( productId == mData->productId ) return; |
1106 | detach(); | 1106 | detach(); |
1107 | mData->empty = false; | 1107 | mData->empty = false; |
1108 | mData->productId = productId; | 1108 | mData->productId = productId; |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | QString Addressee::productId() const | 1111 | QString Addressee::productId() const |
1112 | { | 1112 | { |
1113 | return mData->productId; | 1113 | return mData->productId; |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | QString Addressee::productIdLabel() | 1116 | QString Addressee::productIdLabel() |
1117 | { | 1117 | { |
1118 | return i18n("Product Identifier"); | 1118 | return i18n("Product Identifier"); |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | 1121 | ||
1122 | void Addressee::setRevision( const QDateTime &revision ) | 1122 | void Addressee::setRevision( const QDateTime &revision ) |
1123 | { | 1123 | { |
1124 | if ( revision == mData->revision ) return; | 1124 | if ( revision == mData->revision ) return; |
1125 | detach(); | 1125 | detach(); |
1126 | mData->empty = false; | 1126 | mData->empty = false; |
1127 | mData->revision = QDateTime( revision.date(), | 1127 | mData->revision = QDateTime( revision.date(), |
1128 | QTime (revision.time().hour(), | 1128 | QTime (revision.time().hour(), |
1129 | revision.time().minute(), | 1129 | revision.time().minute(), |
1130 | revision.time().second())); | 1130 | revision.time().second())); |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | QDateTime Addressee::revision() const | 1133 | QDateTime Addressee::revision() const |
1134 | { | 1134 | { |
1135 | return mData->revision; | 1135 | return mData->revision; |
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | QString Addressee::revisionLabel() | 1138 | QString Addressee::revisionLabel() |
1139 | { | 1139 | { |
1140 | return i18n("Revision Date"); | 1140 | return i18n("Revision Date"); |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | 1143 | ||
1144 | void Addressee::setSortString( const QString &sortString ) | 1144 | void Addressee::setSortString( const QString &sortString ) |
1145 | { | 1145 | { |
1146 | if ( sortString == mData->sortString ) return; | 1146 | if ( sortString == mData->sortString ) return; |
1147 | detach(); | 1147 | detach(); |
1148 | mData->empty = false; | 1148 | mData->empty = false; |
1149 | mData->sortString = sortString; | 1149 | mData->sortString = sortString; |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | QString Addressee::sortString() const | 1152 | QString Addressee::sortString() const |
1153 | { | 1153 | { |
1154 | return mData->sortString; | 1154 | return mData->sortString; |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | QString Addressee::sortStringLabel() | 1157 | QString Addressee::sortStringLabel() |
1158 | { | 1158 | { |
1159 | return i18n("Sort String"); | 1159 | return i18n("Sort String"); |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | 1162 | ||
1163 | void Addressee::setUrl( const KURL &url ) | 1163 | void Addressee::setUrl( const KURL &url ) |
1164 | { | 1164 | { |
1165 | if ( url == mData->url ) return; | 1165 | if ( url == mData->url ) return; |
1166 | detach(); | 1166 | detach(); |
1167 | mData->empty = false; | 1167 | mData->empty = false; |
1168 | mData->url = url; | 1168 | mData->url = url; |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | KURL Addressee::url() const | 1171 | KURL Addressee::url() const |
1172 | { | 1172 | { |
1173 | return mData->url; | 1173 | return mData->url; |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | QString Addressee::urlLabel() | 1176 | QString Addressee::urlLabel() |
1177 | { | 1177 | { |
1178 | return i18n("URL"); | 1178 | return i18n("URL"); |
1179 | } | 1179 | } |
1180 | 1180 | ||
1181 | 1181 | ||
1182 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1182 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
1183 | { | 1183 | { |
1184 | if ( secrecy == mData->secrecy ) return; | 1184 | if ( secrecy == mData->secrecy ) return; |
1185 | detach(); | 1185 | detach(); |
1186 | mData->empty = false; | 1186 | mData->empty = false; |
1187 | mData->secrecy = secrecy; | 1187 | mData->secrecy = secrecy; |
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | Secrecy Addressee::secrecy() const | 1190 | Secrecy Addressee::secrecy() const |
1191 | { | 1191 | { |
1192 | return mData->secrecy; | 1192 | return mData->secrecy; |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | QString Addressee::secrecyLabel() | 1195 | QString Addressee::secrecyLabel() |
1196 | { | 1196 | { |
1197 | return i18n("Security Class"); | 1197 | return i18n("Security Class"); |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | 1200 | ||
1201 | void Addressee::setLogo( const Picture &logo ) | 1201 | void Addressee::setLogo( const Picture &logo ) |
1202 | { | 1202 | { |
1203 | if ( logo == mData->logo ) return; | 1203 | if ( logo == mData->logo ) return; |
1204 | detach(); | 1204 | detach(); |
1205 | mData->empty = false; | 1205 | mData->empty = false; |
1206 | mData->logo = logo; | 1206 | mData->logo = logo; |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | Picture Addressee::logo() const | 1209 | Picture Addressee::logo() const |
1210 | { | 1210 | { |
1211 | return mData->logo; | 1211 | return mData->logo; |
1212 | } | 1212 | } |
1213 | 1213 | ||
1214 | QString Addressee::logoLabel() | 1214 | QString Addressee::logoLabel() |
1215 | { | 1215 | { |
1216 | return i18n("Logo"); | 1216 | return i18n("Logo"); |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | 1219 | ||
1220 | void Addressee::setPhoto( const Picture &photo ) | 1220 | void Addressee::setPhoto( const Picture &photo ) |
1221 | { | 1221 | { |
1222 | if ( photo == mData->photo ) return; | 1222 | if ( photo == mData->photo ) return; |
1223 | detach(); | 1223 | detach(); |
1224 | mData->empty = false; | 1224 | mData->empty = false; |
1225 | mData->photo = photo; | 1225 | mData->photo = photo; |
1226 | } | 1226 | } |
1227 | 1227 | ||
1228 | Picture Addressee::photo() const | 1228 | Picture Addressee::photo() const |
1229 | { | 1229 | { |
1230 | return mData->photo; | 1230 | return mData->photo; |
1231 | } | 1231 | } |
1232 | 1232 | ||
1233 | QString Addressee::photoLabel() | 1233 | QString Addressee::photoLabel() |
1234 | { | 1234 | { |
1235 | return i18n("Photo"); | 1235 | return i18n("Photo"); |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | 1238 | ||
1239 | void Addressee::setSound( const Sound &sound ) | 1239 | void Addressee::setSound( const Sound &sound ) |
1240 | { | 1240 | { |
1241 | if ( sound == mData->sound ) return; | 1241 | if ( sound == mData->sound ) return; |
1242 | detach(); | 1242 | detach(); |
1243 | mData->empty = false; | 1243 | mData->empty = false; |
1244 | mData->sound = sound; | 1244 | mData->sound = sound; |
1245 | } | 1245 | } |
1246 | 1246 | ||
1247 | Sound Addressee::sound() const | 1247 | Sound Addressee::sound() const |
1248 | { | 1248 | { |
1249 | return mData->sound; | 1249 | return mData->sound; |
1250 | } | 1250 | } |
1251 | 1251 | ||
1252 | QString Addressee::soundLabel() | 1252 | QString Addressee::soundLabel() |
1253 | { | 1253 | { |
1254 | return i18n("Sound"); | 1254 | return i18n("Sound"); |
1255 | } | 1255 | } |
1256 | 1256 | ||
1257 | 1257 | ||
1258 | void Addressee::setAgent( const Agent &agent ) | 1258 | void Addressee::setAgent( const Agent &agent ) |
1259 | { | 1259 | { |
1260 | if ( agent == mData->agent ) return; | 1260 | if ( agent == mData->agent ) return; |
1261 | detach(); | 1261 | detach(); |
1262 | mData->empty = false; | 1262 | mData->empty = false; |
1263 | mData->agent = agent; | 1263 | mData->agent = agent; |
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | Agent Addressee::agent() const | 1266 | Agent Addressee::agent() const |
1267 | { | 1267 | { |
1268 | return mData->agent; | 1268 | return mData->agent; |
1269 | } | 1269 | } |
1270 | 1270 | ||
1271 | QString Addressee::agentLabel() | 1271 | QString Addressee::agentLabel() |
1272 | { | 1272 | { |
1273 | return i18n("Agent"); | 1273 | return i18n("Agent"); |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | 1276 | ||
1277 | 1277 | ||
1278 | void Addressee::setNameFromString( const QString &str ) | 1278 | void Addressee::setNameFromString( const QString &str ) |
1279 | { | 1279 | { |
1280 | setFormattedName( str ); | 1280 | setFormattedName( str ); |
1281 | setName( str ); | 1281 | setName( str ); |
1282 | 1282 | ||
1283 | static bool first = true; | 1283 | static bool first = true; |
1284 | static QStringList titles; | 1284 | static QStringList titles; |
1285 | static QStringList suffixes; | 1285 | static QStringList suffixes; |
1286 | static QStringList prefixes; | 1286 | static QStringList prefixes; |
1287 | 1287 | ||
1288 | if ( first ) { | 1288 | if ( first ) { |
1289 | first = false; | 1289 | first = false; |
1290 | titles += i18n( "Dr." ); | 1290 | titles += i18n( "Dr." ); |
1291 | titles += i18n( "Miss" ); | 1291 | titles += i18n( "Miss" ); |
1292 | titles += i18n( "Mr." ); | 1292 | titles += i18n( "Mr." ); |
1293 | titles += i18n( "Mrs." ); | 1293 | titles += i18n( "Mrs." ); |
1294 | titles += i18n( "Ms." ); | 1294 | titles += i18n( "Ms." ); |
1295 | titles += i18n( "Prof." ); | 1295 | titles += i18n( "Prof." ); |
1296 | 1296 | ||
1297 | suffixes += i18n( "I" ); | 1297 | suffixes += i18n( "I" ); |
1298 | suffixes += i18n( "II" ); | 1298 | suffixes += i18n( "II" ); |
1299 | suffixes += i18n( "III" ); | 1299 | suffixes += i18n( "III" ); |
1300 | suffixes += i18n( "Jr." ); | 1300 | suffixes += i18n( "Jr." ); |
1301 | suffixes += i18n( "Sr." ); | 1301 | suffixes += i18n( "Sr." ); |
1302 | 1302 | ||
1303 | prefixes += "van"; | 1303 | prefixes += "van"; |
1304 | prefixes += "von"; | 1304 | prefixes += "von"; |
1305 | prefixes += "de"; | 1305 | prefixes += "de"; |
1306 | 1306 | ||
1307 | KConfig config( locateLocal( "config", "kabcrc") ); | 1307 | KConfig config( locateLocal( "config", "kabcrc") ); |
1308 | config.setGroup( "General" ); | 1308 | config.setGroup( "General" ); |
1309 | titles += config.readListEntry( "Prefixes" ); | 1309 | titles += config.readListEntry( "Prefixes" ); |
1310 | titles.remove( "" ); | 1310 | titles.remove( "" ); |
1311 | prefixes += config.readListEntry( "Inclusions" ); | 1311 | prefixes += config.readListEntry( "Inclusions" ); |
1312 | prefixes.remove( "" ); | 1312 | prefixes.remove( "" ); |
1313 | suffixes += config.readListEntry( "Suffixes" ); | 1313 | suffixes += config.readListEntry( "Suffixes" ); |
1314 | suffixes.remove( "" ); | 1314 | suffixes.remove( "" ); |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | // clear all name parts | 1317 | // clear all name parts |
1318 | setPrefix( "" ); | 1318 | setPrefix( "" ); |
1319 | setGivenName( "" ); | 1319 | setGivenName( "" ); |
1320 | setAdditionalName( "" ); | 1320 | setAdditionalName( "" ); |
1321 | setFamilyName( "" ); | 1321 | setFamilyName( "" ); |
1322 | setSuffix( "" ); | 1322 | setSuffix( "" ); |
1323 | 1323 | ||
1324 | if ( str.isEmpty() ) | 1324 | if ( str.isEmpty() ) |
1325 | return; | 1325 | return; |
1326 | 1326 | ||
1327 | int i = str.find(','); | 1327 | int i = str.find(','); |
1328 | if( i < 0 ) { | 1328 | if( i < 0 ) { |
1329 | QStringList parts = QStringList::split( " ", str ); | 1329 | QStringList parts = QStringList::split( " ", str ); |
1330 | int leftOffset = 0; | 1330 | int leftOffset = 0; |
1331 | int rightOffset = parts.count() - 1; | 1331 | int rightOffset = parts.count() - 1; |
1332 | 1332 | ||
1333 | QString suffix; | 1333 | QString suffix; |
1334 | while ( rightOffset >= 0 ) { | 1334 | while ( rightOffset >= 0 ) { |
1335 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1335 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1336 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1336 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1337 | rightOffset--; | 1337 | rightOffset--; |
1338 | } else | 1338 | } else |
1339 | break; | 1339 | break; |
1340 | } | 1340 | } |
1341 | setSuffix( suffix ); | 1341 | setSuffix( suffix ); |
1342 | 1342 | ||
1343 | if ( rightOffset < 0 ) | 1343 | if ( rightOffset < 0 ) |
1344 | return; | 1344 | return; |
1345 | 1345 | ||
1346 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1346 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1347 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1347 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1348 | rightOffset--; | 1348 | rightOffset--; |
1349 | } else | 1349 | } else |
1350 | setFamilyName( parts[ rightOffset ] ); | 1350 | setFamilyName( parts[ rightOffset ] ); |
1351 | 1351 | ||
1352 | QString prefix; | 1352 | QString prefix; |
1353 | while ( leftOffset < rightOffset ) { | 1353 | while ( leftOffset < rightOffset ) { |
1354 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1354 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1355 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1355 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1356 | leftOffset++; | 1356 | leftOffset++; |
1357 | } else | 1357 | } else |
1358 | break; | 1358 | break; |
1359 | } | 1359 | } |
1360 | setPrefix( prefix ); | 1360 | setPrefix( prefix ); |
1361 | 1361 | ||
1362 | if ( leftOffset < rightOffset ) { | 1362 | if ( leftOffset < rightOffset ) { |
1363 | setGivenName( parts[ leftOffset ] ); | 1363 | setGivenName( parts[ leftOffset ] ); |
1364 | leftOffset++; | 1364 | leftOffset++; |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | QString additionalName; | 1367 | QString additionalName; |
1368 | while ( leftOffset < rightOffset ) { | 1368 | while ( leftOffset < rightOffset ) { |
1369 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1369 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1370 | leftOffset++; | 1370 | leftOffset++; |
1371 | } | 1371 | } |
1372 | setAdditionalName( additionalName ); | 1372 | setAdditionalName( additionalName ); |
1373 | } else { | 1373 | } else { |
1374 | QString part1 = str.left( i ); | 1374 | QString part1 = str.left( i ); |
1375 | QString part2 = str.mid( i + 1 ); | 1375 | QString part2 = str.mid( i + 1 ); |
1376 | 1376 | ||
1377 | QStringList parts = QStringList::split( " ", part1 ); | 1377 | QStringList parts = QStringList::split( " ", part1 ); |
1378 | int leftOffset = 0; | 1378 | int leftOffset = 0; |
1379 | int rightOffset = parts.count() - 1; | 1379 | int rightOffset = parts.count() - 1; |
1380 | 1380 | ||
1381 | QString suffix; | 1381 | QString suffix; |
1382 | while ( rightOffset >= 0 ) { | 1382 | while ( rightOffset >= 0 ) { |
1383 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1383 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1384 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1384 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1385 | rightOffset--; | 1385 | rightOffset--; |
1386 | } else | 1386 | } else |
1387 | break; | 1387 | break; |
1388 | } | 1388 | } |
1389 | setSuffix( suffix ); | 1389 | setSuffix( suffix ); |
1390 | 1390 | ||
1391 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1391 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1392 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1392 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1393 | rightOffset--; | 1393 | rightOffset--; |
1394 | } else | 1394 | } else |
1395 | setFamilyName( parts[ rightOffset ] ); | 1395 | setFamilyName( parts[ rightOffset ] ); |
1396 | 1396 | ||
1397 | QString prefix; | 1397 | QString prefix; |
1398 | while ( leftOffset < rightOffset ) { | 1398 | while ( leftOffset < rightOffset ) { |
1399 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1399 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1400 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1400 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1401 | leftOffset++; | 1401 | leftOffset++; |
1402 | } else | 1402 | } else |
1403 | break; | 1403 | break; |
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | parts = QStringList::split( " ", part2 ); | 1406 | parts = QStringList::split( " ", part2 ); |
1407 | 1407 | ||
1408 | leftOffset = 0; | 1408 | leftOffset = 0; |
1409 | rightOffset = parts.count(); | 1409 | rightOffset = parts.count(); |
1410 | 1410 | ||
1411 | while ( leftOffset < rightOffset ) { | 1411 | while ( leftOffset < rightOffset ) { |
1412 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1412 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1413 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1413 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1414 | leftOffset++; | 1414 | leftOffset++; |
1415 | } else | 1415 | } else |
1416 | break; | 1416 | break; |
1417 | } | 1417 | } |
1418 | setPrefix( prefix ); | 1418 | setPrefix( prefix ); |
1419 | 1419 | ||
1420 | if ( leftOffset < rightOffset ) { | 1420 | if ( leftOffset < rightOffset ) { |
1421 | setGivenName( parts[ leftOffset ] ); | 1421 | setGivenName( parts[ leftOffset ] ); |
1422 | leftOffset++; | 1422 | leftOffset++; |
1423 | } | 1423 | } |
1424 | 1424 | ||
1425 | QString additionalName; | 1425 | QString additionalName; |
1426 | while ( leftOffset < rightOffset ) { | 1426 | while ( leftOffset < rightOffset ) { |
1427 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1427 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1428 | leftOffset++; | 1428 | leftOffset++; |
1429 | } | 1429 | } |
1430 | setAdditionalName( additionalName ); | 1430 | setAdditionalName( additionalName ); |
1431 | } | 1431 | } |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | QString Addressee::realName() const | 1434 | QString Addressee::realName() const |
1435 | { | 1435 | { |
1436 | if ( !formattedName().isEmpty() ) | 1436 | if ( !formattedName().isEmpty() ) |
1437 | return formattedName(); | 1437 | return formattedName(); |
1438 | 1438 | ||
1439 | QString n = assembledName(); | 1439 | QString n = assembledName(); |
1440 | 1440 | ||
1441 | if ( n.isEmpty() ) | 1441 | if ( n.isEmpty() ) |
1442 | n = name(); | 1442 | n = name(); |
1443 | 1443 | ||
1444 | return n; | 1444 | return n; |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | QString Addressee::assembledName() const | 1447 | QString Addressee::assembledName() const |
1448 | { | 1448 | { |
1449 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1449 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1450 | familyName() + " " + suffix(); | 1450 | familyName() + " " + suffix(); |
1451 | 1451 | ||
1452 | return name.simplifyWhiteSpace(); | 1452 | return name.simplifyWhiteSpace(); |
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | QString Addressee::fullEmail( const QString &email ) const | 1455 | QString Addressee::fullEmail( const QString &email ) const |
1456 | { | 1456 | { |
1457 | QString e; | 1457 | QString e; |
1458 | if ( email.isNull() ) { | 1458 | if ( email.isNull() ) { |
1459 | e = preferredEmail(); | 1459 | e = preferredEmail(); |
1460 | } else { | 1460 | } else { |
1461 | e = email; | 1461 | e = email; |
1462 | } | 1462 | } |
1463 | if ( e.isEmpty() ) return QString::null; | 1463 | if ( e.isEmpty() ) return QString::null; |
1464 | 1464 | ||
1465 | QString text; | 1465 | QString text; |
1466 | if ( realName().isEmpty() ) | 1466 | if ( realName().isEmpty() ) |
1467 | text = e; | 1467 | text = e; |
1468 | else | 1468 | else |
1469 | text = assembledName() + " <" + e + ">"; | 1469 | text = assembledName() + " <" + e + ">"; |
1470 | 1470 | ||
1471 | return text; | 1471 | return text; |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1474 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1475 | { | 1475 | { |
1476 | detach(); | 1476 | detach(); |
1477 | 1477 | ||
1478 | QStringList::Iterator it = mData->emails.find( email ); | 1478 | QStringList::Iterator it = mData->emails.find( email ); |
1479 | 1479 | ||
1480 | if ( it != mData->emails.end() ) { | 1480 | if ( it != mData->emails.end() ) { |
1481 | if ( !preferred || it == mData->emails.begin() ) return; | 1481 | if ( !preferred || it == mData->emails.begin() ) return; |
1482 | mData->emails.remove( it ); | 1482 | mData->emails.remove( it ); |
1483 | mData->emails.prepend( email ); | 1483 | mData->emails.prepend( email ); |
1484 | } else { | 1484 | } else { |
1485 | if ( preferred ) { | 1485 | if ( preferred ) { |
1486 | mData->emails.prepend( email ); | 1486 | mData->emails.prepend( email ); |
1487 | } else { | 1487 | } else { |
1488 | mData->emails.append( email ); | 1488 | mData->emails.append( email ); |
1489 | } | 1489 | } |
1490 | } | 1490 | } |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | void Addressee::removeEmail( const QString &email ) | 1493 | void Addressee::removeEmail( const QString &email ) |
1494 | { | 1494 | { |
1495 | detach(); | 1495 | detach(); |
1496 | 1496 | ||
1497 | QStringList::Iterator it = mData->emails.find( email ); | 1497 | QStringList::Iterator it = mData->emails.find( email ); |
1498 | if ( it == mData->emails.end() ) return; | 1498 | if ( it == mData->emails.end() ) return; |
1499 | 1499 | ||
1500 | mData->emails.remove( it ); | 1500 | mData->emails.remove( it ); |
1501 | } | 1501 | } |
1502 | 1502 | ||
1503 | QString Addressee::preferredEmail() const | 1503 | QString Addressee::preferredEmail() const |
1504 | { | 1504 | { |
1505 | if ( mData->emails.count() == 0 ) return QString::null; | 1505 | if ( mData->emails.count() == 0 ) return QString::null; |
1506 | else return mData->emails.first(); | 1506 | else return mData->emails.first(); |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | QStringList Addressee::emails() const | 1509 | QStringList Addressee::emails() const |
1510 | { | 1510 | { |
1511 | return mData->emails; | 1511 | return mData->emails; |
1512 | } | 1512 | } |
1513 | void Addressee::setEmails( const QStringList& emails ) { | 1513 | void Addressee::setEmails( const QStringList& emails ) { |
1514 | detach(); | 1514 | detach(); |
1515 | mData->emails = emails; | 1515 | mData->emails = emails; |
1516 | } | 1516 | } |
1517 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1517 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1518 | { | 1518 | { |
1519 | detach(); | 1519 | detach(); |
1520 | mData->empty = false; | 1520 | mData->empty = false; |
1521 | 1521 | ||
1522 | PhoneNumber::List::Iterator it; | 1522 | PhoneNumber::List::Iterator it; |
1523 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1523 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1524 | if ( (*it).id() == phoneNumber.id() ) { | 1524 | if ( (*it).id() == phoneNumber.id() ) { |
1525 | *it = phoneNumber; | 1525 | *it = phoneNumber; |
1526 | return; | 1526 | return; |
1527 | } | 1527 | } |
1528 | } | 1528 | } |
1529 | mData->phoneNumbers.append( phoneNumber ); | 1529 | mData->phoneNumbers.append( phoneNumber ); |
1530 | } | 1530 | } |
1531 | 1531 | ||
1532 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1532 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1533 | { | 1533 | { |
1534 | detach(); | 1534 | detach(); |
1535 | 1535 | ||
1536 | PhoneNumber::List::Iterator it; | 1536 | PhoneNumber::List::Iterator it; |
1537 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1537 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1538 | if ( (*it).id() == phoneNumber.id() ) { | 1538 | if ( (*it).id() == phoneNumber.id() ) { |
1539 | mData->phoneNumbers.remove( it ); | 1539 | mData->phoneNumbers.remove( it ); |
1540 | return; | 1540 | return; |
1541 | } | 1541 | } |
1542 | } | 1542 | } |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | PhoneNumber Addressee::phoneNumber( int type ) const | 1545 | PhoneNumber Addressee::phoneNumber( int type ) const |
1546 | { | 1546 | { |
1547 | PhoneNumber phoneNumber( "", type ); | 1547 | PhoneNumber phoneNumber( "", type ); |
1548 | PhoneNumber::List::ConstIterator it; | 1548 | PhoneNumber::List::ConstIterator it; |
1549 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1549 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1550 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1550 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1551 | if ( (*it).type() & PhoneNumber::Pref ) | 1551 | if ( (*it).type() & PhoneNumber::Pref ) |
1552 | return (*it); | 1552 | return (*it); |
1553 | else if ( phoneNumber.number().isEmpty() ) | 1553 | else if ( phoneNumber.number().isEmpty() ) |
1554 | phoneNumber = (*it); | 1554 | phoneNumber = (*it); |
1555 | } | 1555 | } |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | return phoneNumber; | 1558 | return phoneNumber; |
1559 | } | 1559 | } |
1560 | 1560 | ||
1561 | PhoneNumber::List Addressee::phoneNumbers() const | 1561 | PhoneNumber::List Addressee::phoneNumbers() const |
1562 | { | 1562 | { |
1563 | return mData->phoneNumbers; | 1563 | return mData->phoneNumbers; |
1564 | } | 1564 | } |
1565 | 1565 | ||
1566 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1566 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1567 | { | 1567 | { |
1568 | PhoneNumber::List list; | 1568 | PhoneNumber::List list; |
1569 | 1569 | ||
1570 | PhoneNumber::List::ConstIterator it; | 1570 | PhoneNumber::List::ConstIterator it; |
1571 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1571 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1572 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1572 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1573 | list.append( *it ); | 1573 | list.append( *it ); |
1574 | } | 1574 | } |
1575 | } | 1575 | } |
1576 | return list; | 1576 | return list; |
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1579 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1580 | { | 1580 | { |
1581 | PhoneNumber::List::ConstIterator it; | 1581 | PhoneNumber::List::ConstIterator it; |
1582 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1582 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1583 | if ( (*it).id() == id ) { | 1583 | if ( (*it).id() == id ) { |
1584 | return *it; | 1584 | return *it; |
1585 | } | 1585 | } |
1586 | } | 1586 | } |
1587 | return PhoneNumber(); | 1587 | return PhoneNumber(); |
1588 | } | 1588 | } |
1589 | 1589 | ||
1590 | void Addressee::insertKey( const Key &key ) | 1590 | void Addressee::insertKey( const Key &key ) |
1591 | { | 1591 | { |
1592 | detach(); | 1592 | detach(); |
1593 | mData->empty = false; | 1593 | mData->empty = false; |
1594 | 1594 | ||
1595 | Key::List::Iterator it; | 1595 | Key::List::Iterator it; |
1596 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1596 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1597 | if ( (*it).id() == key.id() ) { | 1597 | if ( (*it).id() == key.id() ) { |
1598 | *it = key; | 1598 | *it = key; |
1599 | return; | 1599 | return; |
1600 | } | 1600 | } |
1601 | } | 1601 | } |
1602 | mData->keys.append( key ); | 1602 | mData->keys.append( key ); |
1603 | } | 1603 | } |
1604 | 1604 | ||
1605 | void Addressee::removeKey( const Key &key ) | 1605 | void Addressee::removeKey( const Key &key ) |
1606 | { | 1606 | { |
1607 | detach(); | 1607 | detach(); |
1608 | 1608 | ||
1609 | Key::List::Iterator it; | 1609 | Key::List::Iterator it; |
1610 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1610 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1611 | if ( (*it).id() == key.id() ) { | 1611 | if ( (*it).id() == key.id() ) { |
1612 | mData->keys.remove( key ); | 1612 | mData->keys.remove( key ); |
1613 | return; | 1613 | return; |
1614 | } | 1614 | } |
1615 | } | 1615 | } |
1616 | } | 1616 | } |
1617 | 1617 | ||
1618 | Key Addressee::key( int type, QString customTypeString ) const | 1618 | Key Addressee::key( int type, QString customTypeString ) const |
1619 | { | 1619 | { |
1620 | Key::List::ConstIterator it; | 1620 | Key::List::ConstIterator it; |
1621 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1621 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1622 | if ( (*it).type() == type ) { | 1622 | if ( (*it).type() == type ) { |
1623 | if ( type == Key::Custom ) { | 1623 | if ( type == Key::Custom ) { |
1624 | if ( customTypeString.isEmpty() ) { | 1624 | if ( customTypeString.isEmpty() ) { |
1625 | return *it; | 1625 | return *it; |
1626 | } else { | 1626 | } else { |
1627 | if ( (*it).customTypeString() == customTypeString ) | 1627 | if ( (*it).customTypeString() == customTypeString ) |
1628 | return (*it); | 1628 | return (*it); |
1629 | } | 1629 | } |
1630 | } else { | 1630 | } else { |
1631 | return *it; | 1631 | return *it; |
1632 | } | 1632 | } |
1633 | } | 1633 | } |
1634 | } | 1634 | } |
1635 | return Key( QString(), type ); | 1635 | return Key( QString(), type ); |
1636 | } | 1636 | } |
1637 | void Addressee::setKeys( const Key::List& list ) { | 1637 | void Addressee::setKeys( const Key::List& list ) { |
1638 | detach(); | 1638 | detach(); |
1639 | mData->keys = list; | 1639 | mData->keys = list; |
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | Key::List Addressee::keys() const | 1642 | Key::List Addressee::keys() const |
1643 | { | 1643 | { |
1644 | return mData->keys; | 1644 | return mData->keys; |
1645 | } | 1645 | } |
1646 | 1646 | ||
1647 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1647 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1648 | { | 1648 | { |
1649 | Key::List list; | 1649 | Key::List list; |
1650 | 1650 | ||
1651 | Key::List::ConstIterator it; | 1651 | Key::List::ConstIterator it; |
1652 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1652 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1653 | if ( (*it).type() == type ) { | 1653 | if ( (*it).type() == type ) { |
1654 | if ( type == Key::Custom ) { | 1654 | if ( type == Key::Custom ) { |
1655 | if ( customTypeString.isEmpty() ) { | 1655 | if ( customTypeString.isEmpty() ) { |
1656 | list.append(*it); | 1656 | list.append(*it); |
1657 | } else { | 1657 | } else { |
1658 | if ( (*it).customTypeString() == customTypeString ) | 1658 | if ( (*it).customTypeString() == customTypeString ) |
1659 | list.append(*it); | 1659 | list.append(*it); |
1660 | } | 1660 | } |
1661 | } else { | 1661 | } else { |
1662 | list.append(*it); | 1662 | list.append(*it); |
1663 | } | 1663 | } |
1664 | } | 1664 | } |
1665 | } | 1665 | } |
1666 | return list; | 1666 | return list; |
1667 | } | 1667 | } |
1668 | 1668 | ||
1669 | Key Addressee::findKey( const QString &id ) const | 1669 | Key Addressee::findKey( const QString &id ) const |
1670 | { | 1670 | { |
1671 | Key::List::ConstIterator it; | 1671 | Key::List::ConstIterator it; |
1672 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1672 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1673 | if ( (*it).id() == id ) { | 1673 | if ( (*it).id() == id ) { |
1674 | return *it; | 1674 | return *it; |
1675 | } | 1675 | } |
1676 | } | 1676 | } |
1677 | return Key(); | 1677 | return Key(); |
1678 | } | 1678 | } |
1679 | 1679 | ||
1680 | QString Addressee::asString() const | 1680 | QString Addressee::asString() const |
1681 | { | 1681 | { |
1682 | return "Smith, agent Smith..."; | 1682 | return "Smith, agent Smith..."; |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | void Addressee::dump() const | 1685 | void Addressee::dump() const |
1686 | { | 1686 | { |
1687 | return; | 1687 | return; |
1688 | #if 0 | 1688 | #if 0 |
1689 | kdDebug(5700) << "Addressee {" << endl; | 1689 | kdDebug(5700) << "Addressee {" << endl; |
1690 | 1690 | ||
1691 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1691 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1692 | 1692 | ||
1693 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1693 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1694 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1694 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1695 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1695 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1696 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1696 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1697 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1697 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1698 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1698 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1699 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1699 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1700 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1700 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1701 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1701 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1702 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1702 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1703 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1703 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1704 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1704 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1705 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1705 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1706 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1706 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1707 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1707 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1708 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1708 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1709 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1709 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1710 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1710 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1711 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1711 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1712 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1712 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1713 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1713 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1714 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1714 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1715 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1715 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1716 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1716 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1717 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1717 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1718 | 1718 | ||
1719 | kdDebug(5700) << " Emails {" << endl; | 1719 | kdDebug(5700) << " Emails {" << endl; |
1720 | QStringList e = emails(); | 1720 | QStringList e = emails(); |
1721 | QStringList::ConstIterator it; | 1721 | QStringList::ConstIterator it; |
1722 | for( it = e.begin(); it != e.end(); ++it ) { | 1722 | for( it = e.begin(); it != e.end(); ++it ) { |
1723 | kdDebug(5700) << " " << (*it) << endl; | 1723 | kdDebug(5700) << " " << (*it) << endl; |
1724 | } | 1724 | } |
1725 | kdDebug(5700) << " }" << endl; | 1725 | kdDebug(5700) << " }" << endl; |
1726 | 1726 | ||
1727 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1727 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1728 | PhoneNumber::List p = phoneNumbers(); | 1728 | PhoneNumber::List p = phoneNumbers(); |
1729 | PhoneNumber::List::ConstIterator it2; | 1729 | PhoneNumber::List::ConstIterator it2; |
1730 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1730 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1731 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1731 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1732 | } | 1732 | } |
1733 | kdDebug(5700) << " }" << endl; | 1733 | kdDebug(5700) << " }" << endl; |
1734 | 1734 | ||
1735 | Address::List a = addresses(); | 1735 | Address::List a = addresses(); |
1736 | Address::List::ConstIterator it3; | 1736 | Address::List::ConstIterator it3; |
1737 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1737 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1738 | (*it3).dump(); | 1738 | (*it3).dump(); |
1739 | } | 1739 | } |
1740 | 1740 | ||
1741 | kdDebug(5700) << " Keys {" << endl; | 1741 | kdDebug(5700) << " Keys {" << endl; |
1742 | Key::List k = keys(); | 1742 | Key::List k = keys(); |
1743 | Key::List::ConstIterator it4; | 1743 | Key::List::ConstIterator it4; |
1744 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1744 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1745 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1745 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1746 | " Key: " << (*it4).textData() << | 1746 | " Key: " << (*it4).textData() << |
1747 | " CustomString: " << (*it4).customTypeString() << endl; | 1747 | " CustomString: " << (*it4).customTypeString() << endl; |
1748 | } | 1748 | } |
1749 | kdDebug(5700) << " }" << endl; | 1749 | kdDebug(5700) << " }" << endl; |
1750 | 1750 | ||
1751 | kdDebug(5700) << "}" << endl; | 1751 | kdDebug(5700) << "}" << endl; |
1752 | #endif | 1752 | #endif |
1753 | } | 1753 | } |
1754 | 1754 | ||
1755 | 1755 | ||
1756 | void Addressee::insertAddress( const Address &address ) | 1756 | void Addressee::insertAddress( const Address &address ) |
1757 | { | 1757 | { |
1758 | detach(); | 1758 | detach(); |
1759 | mData->empty = false; | 1759 | mData->empty = false; |
1760 | 1760 | ||
1761 | Address::List::Iterator it; | 1761 | Address::List::Iterator it; |
1762 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1762 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1763 | if ( (*it).id() == address.id() ) { | 1763 | if ( (*it).id() == address.id() ) { |
1764 | *it = address; | 1764 | *it = address; |
1765 | return; | 1765 | return; |
1766 | } | 1766 | } |
1767 | } | 1767 | } |
1768 | mData->addresses.append( address ); | 1768 | mData->addresses.append( address ); |
1769 | } | 1769 | } |
1770 | 1770 | ||
1771 | void Addressee::removeAddress( const Address &address ) | 1771 | void Addressee::removeAddress( const Address &address ) |
1772 | { | 1772 | { |
1773 | detach(); | 1773 | detach(); |
1774 | 1774 | ||
1775 | Address::List::Iterator it; | 1775 | Address::List::Iterator it; |
1776 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1776 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1777 | if ( (*it).id() == address.id() ) { | 1777 | if ( (*it).id() == address.id() ) { |
1778 | mData->addresses.remove( it ); | 1778 | mData->addresses.remove( it ); |
1779 | return; | 1779 | return; |
1780 | } | 1780 | } |
1781 | } | 1781 | } |
1782 | } | 1782 | } |
1783 | 1783 | ||
1784 | Address Addressee::address( int type ) const | 1784 | Address Addressee::address( int type ) const |
1785 | { | 1785 | { |
1786 | Address address( type ); | 1786 | Address address( type ); |
1787 | Address::List::ConstIterator it; | 1787 | Address::List::ConstIterator it; |
1788 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1788 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1789 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1789 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1790 | if ( (*it).type() & Address::Pref ) | 1790 | if ( (*it).type() & Address::Pref ) |
1791 | return (*it); | 1791 | return (*it); |
1792 | else if ( address.isEmpty() ) | 1792 | else if ( address.isEmpty() ) |
1793 | address = (*it); | 1793 | address = (*it); |
1794 | } | 1794 | } |
1795 | } | 1795 | } |
1796 | 1796 | ||
1797 | return address; | 1797 | return address; |
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | Address::List Addressee::addresses() const | 1800 | Address::List Addressee::addresses() const |
1801 | { | 1801 | { |
1802 | return mData->addresses; | 1802 | return mData->addresses; |
1803 | } | 1803 | } |
1804 | 1804 | ||
1805 | Address::List Addressee::addresses( int type ) const | 1805 | Address::List Addressee::addresses( int type ) const |
1806 | { | 1806 | { |
1807 | Address::List list; | 1807 | Address::List list; |
1808 | 1808 | ||
1809 | Address::List::ConstIterator it; | 1809 | Address::List::ConstIterator it; |
1810 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1810 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1811 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1811 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1812 | list.append( *it ); | 1812 | list.append( *it ); |
1813 | } | 1813 | } |
1814 | } | 1814 | } |
1815 | 1815 | ||
1816 | return list; | 1816 | return list; |
1817 | } | 1817 | } |
1818 | 1818 | ||
1819 | Address Addressee::findAddress( const QString &id ) const | 1819 | Address Addressee::findAddress( const QString &id ) const |
1820 | { | 1820 | { |
1821 | Address::List::ConstIterator it; | 1821 | Address::List::ConstIterator it; |
1822 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1822 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1823 | if ( (*it).id() == id ) { | 1823 | if ( (*it).id() == id ) { |
1824 | return *it; | 1824 | return *it; |
1825 | } | 1825 | } |
1826 | } | 1826 | } |
1827 | return Address(); | 1827 | return Address(); |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | void Addressee::insertCategory( const QString &c ) | 1830 | void Addressee::insertCategory( const QString &c ) |
1831 | { | 1831 | { |
1832 | detach(); | 1832 | detach(); |
1833 | mData->empty = false; | 1833 | mData->empty = false; |
1834 | 1834 | ||
1835 | if ( mData->categories.contains( c ) ) return; | 1835 | if ( mData->categories.contains( c ) ) return; |
1836 | 1836 | ||
1837 | mData->categories.append( c ); | 1837 | mData->categories.append( c ); |
1838 | } | 1838 | } |
1839 | 1839 | ||
1840 | void Addressee::removeCategory( const QString &c ) | 1840 | void Addressee::removeCategory( const QString &c ) |
1841 | { | 1841 | { |
1842 | detach(); | 1842 | detach(); |
1843 | 1843 | ||
1844 | QStringList::Iterator it = mData->categories.find( c ); | 1844 | QStringList::Iterator it = mData->categories.find( c ); |
1845 | if ( it == mData->categories.end() ) return; | 1845 | if ( it == mData->categories.end() ) return; |
1846 | 1846 | ||
1847 | mData->categories.remove( it ); | 1847 | mData->categories.remove( it ); |
1848 | } | 1848 | } |
1849 | 1849 | ||
1850 | bool Addressee::hasCategory( const QString &c ) const | 1850 | bool Addressee::hasCategory( const QString &c ) const |
1851 | { | 1851 | { |
1852 | return ( mData->categories.contains( c ) ); | 1852 | return ( mData->categories.contains( c ) ); |
1853 | } | 1853 | } |
1854 | 1854 | ||
1855 | void Addressee::setCategories( const QStringList &c ) | 1855 | void Addressee::setCategories( const QStringList &c ) |
1856 | { | 1856 | { |
1857 | detach(); | 1857 | detach(); |
1858 | mData->empty = false; | 1858 | mData->empty = false; |
1859 | 1859 | ||
1860 | mData->categories = c; | 1860 | mData->categories = c; |
1861 | } | 1861 | } |
1862 | 1862 | ||
1863 | QStringList Addressee::categories() const | 1863 | QStringList Addressee::categories() const |
1864 | { | 1864 | { |
1865 | return mData->categories; | 1865 | return mData->categories; |
1866 | } | 1866 | } |
1867 | 1867 | ||
1868 | void Addressee::insertCustom( const QString &app, const QString &name, | 1868 | void Addressee::insertCustom( const QString &app, const QString &name, |
1869 | const QString &value ) | 1869 | const QString &value ) |
1870 | { | 1870 | { |
1871 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1871 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1872 | 1872 | ||
1873 | detach(); | 1873 | detach(); |
1874 | mData->empty = false; | 1874 | mData->empty = false; |
1875 | 1875 | ||
1876 | QString qualifiedName = app + "-" + name + ":"; | 1876 | QString qualifiedName = app + "-" + name + ":"; |
1877 | 1877 | ||
1878 | QStringList::Iterator it; | 1878 | QStringList::Iterator it; |
1879 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1879 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1880 | if ( (*it).startsWith( qualifiedName ) ) { | 1880 | if ( (*it).startsWith( qualifiedName ) ) { |
1881 | (*it) = qualifiedName + value; | 1881 | (*it) = qualifiedName + value; |
1882 | return; | 1882 | return; |
1883 | } | 1883 | } |
1884 | } | 1884 | } |
1885 | mData->custom.append( qualifiedName + value ); | 1885 | mData->custom.append( qualifiedName + value ); |
1886 | } | 1886 | } |
1887 | 1887 | ||
1888 | void Addressee::removeCustom( const QString &app, const QString &name) | 1888 | void Addressee::removeCustom( const QString &app, const QString &name) |
1889 | { | 1889 | { |
1890 | detach(); | 1890 | detach(); |
1891 | 1891 | ||
1892 | QString qualifiedName = app + "-" + name + ":"; | 1892 | QString qualifiedName = app + "-" + name + ":"; |
1893 | 1893 | ||
1894 | QStringList::Iterator it; | 1894 | QStringList::Iterator it; |
1895 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1895 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1896 | if ( (*it).startsWith( qualifiedName ) ) { | 1896 | if ( (*it).startsWith( qualifiedName ) ) { |
1897 | mData->custom.remove( it ); | 1897 | mData->custom.remove( it ); |
1898 | return; | 1898 | return; |
1899 | } | 1899 | } |
1900 | } | 1900 | } |
1901 | } | 1901 | } |
1902 | 1902 | ||
1903 | QString Addressee::custom( const QString &app, const QString &name ) const | 1903 | QString Addressee::custom( const QString &app, const QString &name ) const |
1904 | { | 1904 | { |
1905 | QString qualifiedName = app + "-" + name + ":"; | 1905 | QString qualifiedName = app + "-" + name + ":"; |
1906 | QString value; | 1906 | QString value; |
1907 | 1907 | ||
1908 | QStringList::ConstIterator it; | 1908 | QStringList::ConstIterator it; |
1909 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1909 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1910 | if ( (*it).startsWith( qualifiedName ) ) { | 1910 | if ( (*it).startsWith( qualifiedName ) ) { |
1911 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1911 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1912 | break; | 1912 | break; |
1913 | } | 1913 | } |
1914 | } | 1914 | } |
1915 | 1915 | ||
1916 | return value; | 1916 | return value; |
1917 | } | 1917 | } |
1918 | 1918 | ||
1919 | void Addressee::setCustoms( const QStringList &l ) | 1919 | void Addressee::setCustoms( const QStringList &l ) |
1920 | { | 1920 | { |
1921 | detach(); | 1921 | detach(); |
1922 | mData->empty = false; | 1922 | mData->empty = false; |
1923 | 1923 | ||
1924 | mData->custom = l; | 1924 | mData->custom = l; |
1925 | } | 1925 | } |
1926 | 1926 | ||
1927 | QStringList Addressee::customs() const | 1927 | QStringList Addressee::customs() const |
1928 | { | 1928 | { |
1929 | return mData->custom; | 1929 | return mData->custom; |
1930 | } | 1930 | } |
1931 | 1931 | ||
1932 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1932 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1933 | QString &email) | 1933 | QString &email) |
1934 | { | 1934 | { |
1935 | int startPos, endPos, len; | 1935 | int startPos, endPos, len; |
1936 | QString partA, partB, result; | 1936 | QString partA, partB, result; |
1937 | char endCh = '>'; | 1937 | char endCh = '>'; |
1938 | 1938 | ||
1939 | startPos = rawEmail.find('<'); | 1939 | startPos = rawEmail.find('<'); |
1940 | if (startPos < 0) | 1940 | if (startPos < 0) |
1941 | { | 1941 | { |
1942 | startPos = rawEmail.find('('); | 1942 | startPos = rawEmail.find('('); |
1943 | endCh = ')'; | 1943 | endCh = ')'; |
1944 | } | 1944 | } |
1945 | if (startPos < 0) | 1945 | if (startPos < 0) |
1946 | { | 1946 | { |
1947 | // We couldn't find any separators, so we assume the whole string | 1947 | // We couldn't find any separators, so we assume the whole string |
1948 | // is the email address | 1948 | // is the email address |
1949 | email = rawEmail; | 1949 | email = rawEmail; |
1950 | fullName = ""; | 1950 | fullName = ""; |
1951 | } | 1951 | } |
1952 | else | 1952 | else |
1953 | { | 1953 | { |
1954 | // We have a start position, try to find an end | 1954 | // We have a start position, try to find an end |
1955 | endPos = rawEmail.find(endCh, startPos+1); | 1955 | endPos = rawEmail.find(endCh, startPos+1); |
1956 | 1956 | ||
1957 | if (endPos < 0) | 1957 | if (endPos < 0) |
1958 | { | 1958 | { |
1959 | // We couldn't find the end of the email address. We can only | 1959 | // We couldn't find the end of the email address. We can only |
1960 | // assume the entire string is the email address. | 1960 | // assume the entire string is the email address. |
1961 | email = rawEmail; | 1961 | email = rawEmail; |
1962 | fullName = ""; | 1962 | fullName = ""; |
1963 | } | 1963 | } |
1964 | else | 1964 | else |
1965 | { | 1965 | { |
1966 | // We have a start and end to the email address | 1966 | // We have a start and end to the email address |
1967 | 1967 | ||
1968 | // Grab the name part | 1968 | // Grab the name part |
1969 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1969 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1970 | 1970 | ||
1971 | // grab the email part | 1971 | // grab the email part |
1972 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1972 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1973 | 1973 | ||
1974 | // Check that we do not have any extra characters on the end of the | 1974 | // Check that we do not have any extra characters on the end of the |
1975 | // strings | 1975 | // strings |
1976 | len = fullName.length(); | 1976 | len = fullName.length(); |
1977 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1977 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1978 | fullName = fullName.mid(1, len-2); | 1978 | fullName = fullName.mid(1, len-2); |
1979 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1979 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1980 | fullName = fullName.mid(1, len-2); | 1980 | fullName = fullName.mid(1, len-2); |
1981 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1981 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1982 | fullName = fullName.mid(1, len-2); | 1982 | fullName = fullName.mid(1, len-2); |
1983 | } | 1983 | } |
1984 | } | 1984 | } |
1985 | } | 1985 | } |
1986 | 1986 | ||
1987 | void Addressee::setResource( Resource *resource ) | 1987 | void Addressee::setResource( Resource *resource ) |
1988 | { | 1988 | { |
1989 | detach(); | 1989 | detach(); |
1990 | mData->resource = resource; | 1990 | mData->resource = resource; |
1991 | } | 1991 | } |
1992 | 1992 | ||
1993 | Resource *Addressee::resource() const | 1993 | Resource *Addressee::resource() const |
1994 | { | 1994 | { |
1995 | return mData->resource; | 1995 | return mData->resource; |
1996 | } | 1996 | } |
1997 | 1997 | ||
1998 | //US | 1998 | //US |
1999 | QString Addressee::resourceLabel() | 1999 | QString Addressee::resourceLabel() |
2000 | { | 2000 | { |
2001 | return i18n("Resource"); | 2001 | return i18n("Resource"); |
2002 | } | 2002 | } |
2003 | QString Addressee::categoryLabel() | 2003 | QString Addressee::categoryLabel() |
2004 | { | 2004 | { |
2005 | return i18n("Category"); | 2005 | return i18n("Category"); |
2006 | } | 2006 | } |
2007 | 2007 | ||
2008 | void Addressee::setChanged( bool value ) | 2008 | void Addressee::setChanged( bool value ) |
2009 | { | 2009 | { |
2010 | detach(); | 2010 | detach(); |
2011 | mData->changed = value; | 2011 | mData->changed = value; |
2012 | } | 2012 | } |
2013 | 2013 | ||
2014 | bool Addressee::changed() const | 2014 | bool Addressee::changed() const |
2015 | { | 2015 | { |
2016 | return mData->changed; | 2016 | return mData->changed; |
2017 | } | 2017 | } |
2018 | 2018 | ||
2019 | void Addressee::setTagged( bool value ) | 2019 | void Addressee::setTagged( bool value ) |
2020 | { | 2020 | { |
2021 | detach(); | 2021 | detach(); |
2022 | mData->tagged = value; | 2022 | mData->tagged = value; |
2023 | } | 2023 | } |
2024 | 2024 | ||
2025 | bool Addressee::tagged() const | 2025 | bool Addressee::tagged() const |
2026 | { | 2026 | { |
2027 | return mData->tagged; | 2027 | return mData->tagged; |
2028 | } | 2028 | } |
2029 | 2029 | ||
2030 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 2030 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
2031 | { | 2031 | { |
2032 | if (!a.mData) return s; | 2032 | if (!a.mData) return s; |
2033 | 2033 | ||
2034 | s << a.uid(); | 2034 | s << a.uid(); |
2035 | 2035 | ||
2036 | s << a.mData->name; | 2036 | s << a.mData->name; |
2037 | s << a.mData->formattedName; | 2037 | s << a.mData->formattedName; |
2038 | s << a.mData->familyName; | 2038 | s << a.mData->familyName; |
2039 | s << a.mData->givenName; | 2039 | s << a.mData->givenName; |
2040 | s << a.mData->additionalName; | 2040 | s << a.mData->additionalName; |
2041 | s << a.mData->prefix; | 2041 | s << a.mData->prefix; |
2042 | s << a.mData->suffix; | 2042 | s << a.mData->suffix; |
2043 | s << a.mData->nickName; | 2043 | s << a.mData->nickName; |
2044 | s << a.mData->birthday; | 2044 | s << a.mData->birthday; |
2045 | s << a.mData->mailer; | 2045 | s << a.mData->mailer; |
2046 | s << a.mData->timeZone; | 2046 | s << a.mData->timeZone; |
2047 | s << a.mData->geo; | 2047 | s << a.mData->geo; |
2048 | s << a.mData->title; | 2048 | s << a.mData->title; |
2049 | s << a.mData->role; | 2049 | s << a.mData->role; |
2050 | s << a.mData->organization; | 2050 | s << a.mData->organization; |
2051 | s << a.mData->note; | 2051 | s << a.mData->note; |
2052 | s << a.mData->productId; | 2052 | s << a.mData->productId; |
2053 | s << a.mData->revision; | 2053 | s << a.mData->revision; |
2054 | s << a.mData->sortString; | 2054 | s << a.mData->sortString; |
2055 | s << a.mData->url; | 2055 | s << a.mData->url; |
2056 | s << a.mData->secrecy; | 2056 | s << a.mData->secrecy; |
2057 | s << a.mData->logo; | 2057 | s << a.mData->logo; |
2058 | s << a.mData->photo; | 2058 | s << a.mData->photo; |
2059 | s << a.mData->sound; | 2059 | s << a.mData->sound; |
2060 | s << a.mData->agent; | 2060 | s << a.mData->agent; |
2061 | s << a.mData->phoneNumbers; | 2061 | s << a.mData->phoneNumbers; |
2062 | s << a.mData->addresses; | 2062 | s << a.mData->addresses; |
2063 | s << a.mData->emails; | 2063 | s << a.mData->emails; |
2064 | s << a.mData->categories; | 2064 | s << a.mData->categories; |
2065 | s << a.mData->custom; | 2065 | s << a.mData->custom; |
2066 | s << a.mData->keys; | 2066 | s << a.mData->keys; |
2067 | return s; | 2067 | return s; |
2068 | } | 2068 | } |
2069 | 2069 | ||
2070 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 2070 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
2071 | { | 2071 | { |
2072 | if (!a.mData) return s; | 2072 | if (!a.mData) return s; |
2073 | 2073 | ||
2074 | s >> a.mData->uid; | 2074 | s >> a.mData->uid; |
2075 | 2075 | ||
2076 | s >> a.mData->name; | 2076 | s >> a.mData->name; |
2077 | s >> a.mData->formattedName; | 2077 | s >> a.mData->formattedName; |
2078 | s >> a.mData->familyName; | 2078 | s >> a.mData->familyName; |
2079 | s >> a.mData->givenName; | 2079 | s >> a.mData->givenName; |
2080 | s >> a.mData->additionalName; | 2080 | s >> a.mData->additionalName; |
2081 | s >> a.mData->prefix; | 2081 | s >> a.mData->prefix; |
2082 | s >> a.mData->suffix; | 2082 | s >> a.mData->suffix; |
2083 | s >> a.mData->nickName; | 2083 | s >> a.mData->nickName; |
2084 | s >> a.mData->birthday; | 2084 | s >> a.mData->birthday; |
2085 | s >> a.mData->mailer; | 2085 | s >> a.mData->mailer; |
2086 | s >> a.mData->timeZone; | 2086 | s >> a.mData->timeZone; |
2087 | s >> a.mData->geo; | 2087 | s >> a.mData->geo; |
2088 | s >> a.mData->title; | 2088 | s >> a.mData->title; |
2089 | s >> a.mData->role; | 2089 | s >> a.mData->role; |
2090 | s >> a.mData->organization; | 2090 | s >> a.mData->organization; |
2091 | s >> a.mData->note; | 2091 | s >> a.mData->note; |
2092 | s >> a.mData->productId; | 2092 | s >> a.mData->productId; |
2093 | s >> a.mData->revision; | 2093 | s >> a.mData->revision; |
2094 | s >> a.mData->sortString; | 2094 | s >> a.mData->sortString; |
2095 | s >> a.mData->url; | 2095 | s >> a.mData->url; |
2096 | s >> a.mData->secrecy; | 2096 | s >> a.mData->secrecy; |
2097 | s >> a.mData->logo; | 2097 | s >> a.mData->logo; |
2098 | s >> a.mData->photo; | 2098 | s >> a.mData->photo; |
2099 | s >> a.mData->sound; | 2099 | s >> a.mData->sound; |
2100 | s >> a.mData->agent; | 2100 | s >> a.mData->agent; |
2101 | s >> a.mData->phoneNumbers; | 2101 | s >> a.mData->phoneNumbers; |
2102 | s >> a.mData->addresses; | 2102 | s >> a.mData->addresses; |
2103 | s >> a.mData->emails; | 2103 | s >> a.mData->emails; |
2104 | s >> a.mData->categories; | 2104 | s >> a.mData->categories; |
2105 | s >> a.mData->custom; | 2105 | s >> a.mData->custom; |
2106 | s >> a.mData->keys; | 2106 | s >> a.mData->keys; |
2107 | 2107 | ||
2108 | a.mData->empty = false; | 2108 | a.mData->empty = false; |
2109 | 2109 | ||
2110 | return s; | 2110 | return s; |
2111 | } | 2111 | } |
2112 | bool matchBinaryPattern( int value, int pattern ) | 2112 | bool matchBinaryPattern( int value, int pattern ) |
2113 | { | 2113 | { |
2114 | /** | 2114 | /** |
2115 | We want to match all telephonnumbers/addresses which have the bits in the | 2115 | We want to match all telephonnumbers/addresses which have the bits in the |
2116 | pattern set. More are allowed. | 2116 | pattern set. More are allowed. |
2117 | if pattern == 0 we have a special handling, then we want only those with | 2117 | if pattern == 0 we have a special handling, then we want only those with |
2118 | exactly no bit set. | 2118 | exactly no bit set. |
2119 | */ | 2119 | */ |
2120 | if ( pattern == 0 ) | 2120 | if ( pattern == 0 ) |
2121 | return ( value == 0 ); | 2121 | return ( value == 0 ); |
2122 | else | 2122 | else |
2123 | return ( pattern == ( pattern & value ) ); | 2123 | return ( pattern == ( pattern & value ) ); |
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | bool matchBinaryPatternP( int value, int pattern ) | 2126 | bool matchBinaryPatternP( int value, int pattern ) |
2127 | { | 2127 | { |
2128 | 2128 | ||
2129 | if ( pattern == 0 ) | 2129 | if ( pattern == 0 ) |
2130 | return ( value == 0 ); | 2130 | return ( value == 0 ); |
2131 | else | 2131 | else |
2132 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | 2132 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); |
2133 | } | 2133 | } |
2134 | bool matchBinaryPatternA( int value, int pattern ) | 2134 | bool matchBinaryPatternA( int value, int pattern ) |
2135 | { | 2135 | { |
2136 | 2136 | ||
2137 | if ( pattern == 0 ) | 2137 | if ( pattern == 0 ) |
2138 | return ( value == 0 ); | 2138 | return ( value == 0 ); |
2139 | else | 2139 | else |
2140 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); | 2140 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); |
2141 | } | 2141 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 08d2f56..8051fec 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,853 +1,853 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | // sync stuff | 99 | // sync stuff |
100 | void setTempSyncStat(int id); | 100 | void setTempSyncStat(int id); |
101 | int tempSyncStat() const; | 101 | int tempSyncStat() const; |
102 | void setIDStr( const QString & ); | 102 | void setIDStr( const QString & ); |
103 | QString IDStr() const; | 103 | const QString IDStr() const; |
104 | void setID( const QString &, const QString & ); | 104 | void setID( const QString &, const QString & ); |
105 | QString getID( const QString & ); | 105 | const QString getID( const QString & ) const; |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | const QString getCsum( const QString & ) const ; |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | QString externalUID() const; | 116 | const QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad, bool isSubSet ); | 119 | void mergeContact( const Addressee& ad, bool isSubSet ); |
120 | void simplifyEmails(); | 120 | void simplifyEmails(); |
121 | void simplifyAddresses(); | 121 | void simplifyAddresses(); |
122 | void simplifyPhoneNumbers(); | 122 | void simplifyPhoneNumbers(); |
123 | void simplifyPhoneNumberTypes(); | 123 | void simplifyPhoneNumberTypes(); |
124 | bool removeVoice(); | 124 | bool removeVoice(); |
125 | bool containsAdr(const Addressee& addr ); | 125 | bool containsAdr(const Addressee& addr ); |
126 | 126 | ||
127 | /** | 127 | /** |
128 | Set unique identifier. | 128 | Set unique identifier. |
129 | */ | 129 | */ |
130 | void setUid( const QString &uid ); | 130 | void setUid( const QString &uid ); |
131 | /** | 131 | /** |
132 | Return unique identifier. | 132 | Return unique identifier. |
133 | */ | 133 | */ |
134 | QString uid() const; | 134 | const QString uid() const; |
135 | /** | 135 | /** |
136 | Return translated label for uid field. | 136 | Return translated label for uid field. |
137 | */ | 137 | */ |
138 | static QString uidLabel(); | 138 | static QString uidLabel(); |
139 | 139 | ||
140 | /** | 140 | /** |
141 | Set name. | 141 | Set name. |
142 | */ | 142 | */ |
143 | void setName( const QString &name ); | 143 | void setName( const QString &name ); |
144 | /** | 144 | /** |
145 | Return name. | 145 | Return name. |
146 | */ | 146 | */ |
147 | QString name() const; | 147 | QString name() const; |
148 | /** | 148 | /** |
149 | Return translated label for name field. | 149 | Return translated label for name field. |
150 | */ | 150 | */ |
151 | static QString nameLabel(); | 151 | static QString nameLabel(); |
152 | 152 | ||
153 | /** | 153 | /** |
154 | Set formatted name. | 154 | Set formatted name. |
155 | */ | 155 | */ |
156 | void setFormattedName( const QString &formattedName ); | 156 | void setFormattedName( const QString &formattedName ); |
157 | /** | 157 | /** |
158 | Return formatted name. | 158 | Return formatted name. |
159 | */ | 159 | */ |
160 | QString formattedName() const; | 160 | QString formattedName() const; |
161 | /** | 161 | /** |
162 | Return translated label for formattedName field. | 162 | Return translated label for formattedName field. |
163 | */ | 163 | */ |
164 | static QString formattedNameLabel(); | 164 | static QString formattedNameLabel(); |
165 | 165 | ||
166 | /** | 166 | /** |
167 | Set family name. | 167 | Set family name. |
168 | */ | 168 | */ |
169 | void setFamilyName( const QString &familyName ); | 169 | void setFamilyName( const QString &familyName ); |
170 | /** | 170 | /** |
171 | Return family name. | 171 | Return family name. |
172 | */ | 172 | */ |
173 | QString familyName() const; | 173 | QString familyName() const; |
174 | /** | 174 | /** |
175 | Return translated label for familyName field. | 175 | Return translated label for familyName field. |
176 | */ | 176 | */ |
177 | static QString familyNameLabel(); | 177 | static QString familyNameLabel(); |
178 | 178 | ||
179 | /** | 179 | /** |
180 | Set given name. | 180 | Set given name. |
181 | */ | 181 | */ |
182 | void setGivenName( const QString &givenName ); | 182 | void setGivenName( const QString &givenName ); |
183 | /** | 183 | /** |
184 | Return given name. | 184 | Return given name. |
185 | */ | 185 | */ |
186 | QString givenName() const; | 186 | QString givenName() const; |
187 | /** | 187 | /** |
188 | Return translated label for givenName field. | 188 | Return translated label for givenName field. |
189 | */ | 189 | */ |
190 | static QString givenNameLabel(); | 190 | static QString givenNameLabel(); |
191 | 191 | ||
192 | /** | 192 | /** |
193 | Set additional names. | 193 | Set additional names. |
194 | */ | 194 | */ |
195 | void setAdditionalName( const QString &additionalName ); | 195 | void setAdditionalName( const QString &additionalName ); |
196 | /** | 196 | /** |
197 | Return additional names. | 197 | Return additional names. |
198 | */ | 198 | */ |
199 | QString additionalName() const; | 199 | QString additionalName() const; |
200 | /** | 200 | /** |
201 | Return translated label for additionalName field. | 201 | Return translated label for additionalName field. |
202 | */ | 202 | */ |
203 | static QString additionalNameLabel(); | 203 | static QString additionalNameLabel(); |
204 | 204 | ||
205 | /** | 205 | /** |
206 | Set honorific prefixes. | 206 | Set honorific prefixes. |
207 | */ | 207 | */ |
208 | void setPrefix( const QString &prefix ); | 208 | void setPrefix( const QString &prefix ); |
209 | /** | 209 | /** |
210 | Return honorific prefixes. | 210 | Return honorific prefixes. |
211 | */ | 211 | */ |
212 | QString prefix() const; | 212 | QString prefix() const; |
213 | /** | 213 | /** |
214 | Return translated label for prefix field. | 214 | Return translated label for prefix field. |
215 | */ | 215 | */ |
216 | static QString prefixLabel(); | 216 | static QString prefixLabel(); |
217 | 217 | ||
218 | /** | 218 | /** |
219 | Set honorific suffixes. | 219 | Set honorific suffixes. |
220 | */ | 220 | */ |
221 | void setSuffix( const QString &suffix ); | 221 | void setSuffix( const QString &suffix ); |
222 | /** | 222 | /** |
223 | Return honorific suffixes. | 223 | Return honorific suffixes. |
224 | */ | 224 | */ |
225 | QString suffix() const; | 225 | QString suffix() const; |
226 | /** | 226 | /** |
227 | Return translated label for suffix field. | 227 | Return translated label for suffix field. |
228 | */ | 228 | */ |
229 | static QString suffixLabel(); | 229 | static QString suffixLabel(); |
230 | 230 | ||
231 | /** | 231 | /** |
232 | Set nick name. | 232 | Set nick name. |
233 | */ | 233 | */ |
234 | void setNickName( const QString &nickName ); | 234 | void setNickName( const QString &nickName ); |
235 | /** | 235 | /** |
236 | Return nick name. | 236 | Return nick name. |
237 | */ | 237 | */ |
238 | QString nickName() const; | 238 | QString nickName() const; |
239 | /** | 239 | /** |
240 | Return translated label for nickName field. | 240 | Return translated label for nickName field. |
241 | */ | 241 | */ |
242 | static QString nickNameLabel(); | 242 | static QString nickNameLabel(); |
243 | 243 | ||
244 | /** | 244 | /** |
245 | Set birthday. | 245 | Set birthday. |
246 | */ | 246 | */ |
247 | void setBirthday( const QDateTime &birthday ); | 247 | void setBirthday( const QDateTime &birthday ); |
248 | /** | 248 | /** |
249 | Return birthday. | 249 | Return birthday. |
250 | */ | 250 | */ |
251 | QDateTime birthday() const; | 251 | QDateTime birthday() const; |
252 | /** | 252 | /** |
253 | Return translated label for birthday field. | 253 | Return translated label for birthday field. |
254 | */ | 254 | */ |
255 | static QString birthdayLabel(); | 255 | static QString birthdayLabel(); |
256 | 256 | ||
257 | /** | 257 | /** |
258 | Return translated label for homeAddressStreet field. | 258 | Return translated label for homeAddressStreet field. |
259 | */ | 259 | */ |
260 | static QString homeAddressStreetLabel(); | 260 | static QString homeAddressStreetLabel(); |
261 | 261 | ||
262 | /** | 262 | /** |
263 | Return translated label for homeAddressLocality field. | 263 | Return translated label for homeAddressLocality field. |
264 | */ | 264 | */ |
265 | static QString homeAddressLocalityLabel(); | 265 | static QString homeAddressLocalityLabel(); |
266 | 266 | ||
267 | /** | 267 | /** |
268 | Return translated label for homeAddressRegion field. | 268 | Return translated label for homeAddressRegion field. |
269 | */ | 269 | */ |
270 | static QString homeAddressRegionLabel(); | 270 | static QString homeAddressRegionLabel(); |
271 | 271 | ||
272 | /** | 272 | /** |
273 | Return translated label for homeAddressPostalCode field. | 273 | Return translated label for homeAddressPostalCode field. |
274 | */ | 274 | */ |
275 | static QString homeAddressPostalCodeLabel(); | 275 | static QString homeAddressPostalCodeLabel(); |
276 | 276 | ||
277 | /** | 277 | /** |
278 | Return translated label for homeAddressCountry field. | 278 | Return translated label for homeAddressCountry field. |
279 | */ | 279 | */ |
280 | static QString homeAddressCountryLabel(); | 280 | static QString homeAddressCountryLabel(); |
281 | 281 | ||
282 | /** | 282 | /** |
283 | Return translated label for homeAddressLabel field. | 283 | Return translated label for homeAddressLabel field. |
284 | */ | 284 | */ |
285 | static QString homeAddressLabelLabel(); | 285 | static QString homeAddressLabelLabel(); |
286 | 286 | ||
287 | /** | 287 | /** |
288 | Return translated label for businessAddressStreet field. | 288 | Return translated label for businessAddressStreet field. |
289 | */ | 289 | */ |
290 | static QString businessAddressStreetLabel(); | 290 | static QString businessAddressStreetLabel(); |
291 | 291 | ||
292 | /** | 292 | /** |
293 | Return translated label for businessAddressLocality field. | 293 | Return translated label for businessAddressLocality field. |
294 | */ | 294 | */ |
295 | static QString businessAddressLocalityLabel(); | 295 | static QString businessAddressLocalityLabel(); |
296 | 296 | ||
297 | /** | 297 | /** |
298 | Return translated label for businessAddressRegion field. | 298 | Return translated label for businessAddressRegion field. |
299 | */ | 299 | */ |
300 | static QString businessAddressRegionLabel(); | 300 | static QString businessAddressRegionLabel(); |
301 | 301 | ||
302 | /** | 302 | /** |
303 | Return translated label for businessAddressPostalCode field. | 303 | Return translated label for businessAddressPostalCode field. |
304 | */ | 304 | */ |
305 | static QString businessAddressPostalCodeLabel(); | 305 | static QString businessAddressPostalCodeLabel(); |
306 | 306 | ||
307 | /** | 307 | /** |
308 | Return translated label for businessAddressCountry field. | 308 | Return translated label for businessAddressCountry field. |
309 | */ | 309 | */ |
310 | static QString businessAddressCountryLabel(); | 310 | static QString businessAddressCountryLabel(); |
311 | 311 | ||
312 | /** | 312 | /** |
313 | Return translated label for businessAddressLabel field. | 313 | Return translated label for businessAddressLabel field. |
314 | */ | 314 | */ |
315 | static QString businessAddressLabelLabel(); | 315 | static QString businessAddressLabelLabel(); |
316 | 316 | ||
317 | /** | 317 | /** |
318 | Return translated label for homePhone field. | 318 | Return translated label for homePhone field. |
319 | */ | 319 | */ |
320 | static QString homePhoneLabel(); | 320 | static QString homePhoneLabel(); |
321 | 321 | ||
322 | /** | 322 | /** |
323 | Return translated label for businessPhone field. | 323 | Return translated label for businessPhone field. |
324 | */ | 324 | */ |
325 | static QString businessPhoneLabel(); | 325 | static QString businessPhoneLabel(); |
326 | 326 | ||
327 | /** | 327 | /** |
328 | Return translated label for mobilePhone field. | 328 | Return translated label for mobilePhone field. |
329 | */ | 329 | */ |
330 | static QString mobilePhoneLabel(); | 330 | static QString mobilePhoneLabel(); |
331 | 331 | ||
332 | /** | 332 | /** |
333 | Return translated label for homeFax field. | 333 | Return translated label for homeFax field. |
334 | */ | 334 | */ |
335 | static QString homeFaxLabel(); | 335 | static QString homeFaxLabel(); |
336 | 336 | ||
337 | /** | 337 | /** |
338 | Return translated label for businessFax field. | 338 | Return translated label for businessFax field. |
339 | */ | 339 | */ |
340 | static QString businessFaxLabel(); | 340 | static QString businessFaxLabel(); |
341 | 341 | ||
342 | /** | 342 | /** |
343 | Return translated label for carPhone field. | 343 | Return translated label for carPhone field. |
344 | */ | 344 | */ |
345 | static QString carPhoneLabel(); | 345 | static QString carPhoneLabel(); |
346 | 346 | ||
347 | /** | 347 | /** |
348 | Return translated label for isdn field. | 348 | Return translated label for isdn field. |
349 | */ | 349 | */ |
350 | static QString isdnLabel(); | 350 | static QString isdnLabel(); |
351 | 351 | ||
352 | /** | 352 | /** |
353 | Return translated label for pager field. | 353 | Return translated label for pager field. |
354 | */ | 354 | */ |
355 | static QString pagerLabel(); | 355 | static QString pagerLabel(); |
356 | 356 | ||
357 | /** | 357 | /** |
358 | Return translated label for sip field. | 358 | Return translated label for sip field. |
359 | */ | 359 | */ |
360 | static QString sipLabel(); | 360 | static QString sipLabel(); |
361 | 361 | ||
362 | /** | 362 | /** |
363 | Return translated label for email field. | 363 | Return translated label for email field. |
364 | */ | 364 | */ |
365 | static QString emailLabel(); | 365 | static QString emailLabel(); |
366 | 366 | ||
367 | /** | 367 | /** |
368 | Set mail client. | 368 | Set mail client. |
369 | */ | 369 | */ |
370 | void setMailer( const QString &mailer ); | 370 | void setMailer( const QString &mailer ); |
371 | /** | 371 | /** |
372 | Return mail client. | 372 | Return mail client. |
373 | */ | 373 | */ |
374 | QString mailer() const; | 374 | QString mailer() const; |
375 | /** | 375 | /** |
376 | Return translated label for mailer field. | 376 | Return translated label for mailer field. |
377 | */ | 377 | */ |
378 | static QString mailerLabel(); | 378 | static QString mailerLabel(); |
379 | 379 | ||
380 | /** | 380 | /** |
381 | Set time zone. | 381 | Set time zone. |
382 | */ | 382 | */ |
383 | void setTimeZone( const TimeZone &timeZone ); | 383 | void setTimeZone( const TimeZone &timeZone ); |
384 | /** | 384 | /** |
385 | Return time zone. | 385 | Return time zone. |
386 | */ | 386 | */ |
387 | TimeZone timeZone() const; | 387 | TimeZone timeZone() const; |
388 | /** | 388 | /** |
389 | Return translated label for timeZone field. | 389 | Return translated label for timeZone field. |
390 | */ | 390 | */ |
391 | static QString timeZoneLabel(); | 391 | static QString timeZoneLabel(); |
392 | 392 | ||
393 | /** | 393 | /** |
394 | Set geographic position. | 394 | Set geographic position. |
395 | */ | 395 | */ |
396 | void setGeo( const Geo &geo ); | 396 | void setGeo( const Geo &geo ); |
397 | /** | 397 | /** |
398 | Return geographic position. | 398 | Return geographic position. |
399 | */ | 399 | */ |
400 | Geo geo() const; | 400 | Geo geo() const; |
401 | /** | 401 | /** |
402 | Return translated label for geo field. | 402 | Return translated label for geo field. |
403 | */ | 403 | */ |
404 | static QString geoLabel(); | 404 | static QString geoLabel(); |
405 | 405 | ||
406 | /** | 406 | /** |
407 | Set title. | 407 | Set title. |
408 | */ | 408 | */ |
409 | void setTitle( const QString &title ); | 409 | void setTitle( const QString &title ); |
410 | /** | 410 | /** |
411 | Return title. | 411 | Return title. |
412 | */ | 412 | */ |
413 | QString title() const; | 413 | QString title() const; |
414 | /** | 414 | /** |
415 | Return translated label for title field. | 415 | Return translated label for title field. |
416 | */ | 416 | */ |
417 | static QString titleLabel(); | 417 | static QString titleLabel(); |
418 | 418 | ||
419 | /** | 419 | /** |
420 | Set role. | 420 | Set role. |
421 | */ | 421 | */ |
422 | void setRole( const QString &role ); | 422 | void setRole( const QString &role ); |
423 | /** | 423 | /** |
424 | Return role. | 424 | Return role. |
425 | */ | 425 | */ |
426 | QString role() const; | 426 | QString role() const; |
427 | /** | 427 | /** |
428 | Return translated label for role field. | 428 | Return translated label for role field. |
429 | */ | 429 | */ |
430 | static QString roleLabel(); | 430 | static QString roleLabel(); |
431 | 431 | ||
432 | /** | 432 | /** |
433 | Set organization. | 433 | Set organization. |
434 | */ | 434 | */ |
435 | void setOrganization( const QString &organization ); | 435 | void setOrganization( const QString &organization ); |
436 | /** | 436 | /** |
437 | Return organization. | 437 | Return organization. |
438 | */ | 438 | */ |
439 | QString organization() const; | 439 | QString organization() const; |
440 | /** | 440 | /** |
441 | Return translated label for organization field. | 441 | Return translated label for organization field. |
442 | */ | 442 | */ |
443 | static QString organizationLabel(); | 443 | static QString organizationLabel(); |
444 | 444 | ||
445 | /** | 445 | /** |
446 | Set note. | 446 | Set note. |
447 | */ | 447 | */ |
448 | void setNote( const QString ¬e ); | 448 | void setNote( const QString ¬e ); |
449 | /** | 449 | /** |
450 | Return note. | 450 | Return note. |
451 | */ | 451 | */ |
452 | QString note() const; | 452 | QString note() const; |
453 | /** | 453 | /** |
454 | Return translated label for note field. | 454 | Return translated label for note field. |
455 | */ | 455 | */ |
456 | static QString noteLabel(); | 456 | static QString noteLabel(); |
457 | 457 | ||
458 | /** | 458 | /** |
459 | Set product identifier. | 459 | Set product identifier. |
460 | */ | 460 | */ |
461 | void setProductId( const QString &productId ); | 461 | void setProductId( const QString &productId ); |
462 | /** | 462 | /** |
463 | Return product identifier. | 463 | Return product identifier. |
464 | */ | 464 | */ |
465 | QString productId() const; | 465 | QString productId() const; |
466 | /** | 466 | /** |
467 | Return translated label for productId field. | 467 | Return translated label for productId field. |
468 | */ | 468 | */ |
469 | static QString productIdLabel(); | 469 | static QString productIdLabel(); |
470 | 470 | ||
471 | /** | 471 | /** |
472 | Set revision date. | 472 | Set revision date. |
473 | */ | 473 | */ |
474 | void setRevision( const QDateTime &revision ); | 474 | void setRevision( const QDateTime &revision ); |
475 | /** | 475 | /** |
476 | Return revision date. | 476 | Return revision date. |
477 | */ | 477 | */ |
478 | QDateTime revision() const; | 478 | QDateTime revision() const; |
479 | /** | 479 | /** |
480 | Return translated label for revision field. | 480 | Return translated label for revision field. |
481 | */ | 481 | */ |
482 | static QString revisionLabel(); | 482 | static QString revisionLabel(); |
483 | 483 | ||
484 | /** | 484 | /** |
485 | Set sort string. | 485 | Set sort string. |
486 | */ | 486 | */ |
487 | void setSortString( const QString &sortString ); | 487 | void setSortString( const QString &sortString ); |
488 | /** | 488 | /** |
489 | Return sort string. | 489 | Return sort string. |
490 | */ | 490 | */ |
491 | QString sortString() const; | 491 | QString sortString() const; |
492 | /** | 492 | /** |
493 | Return translated label for sortString field. | 493 | Return translated label for sortString field. |
494 | */ | 494 | */ |
495 | static QString sortStringLabel(); | 495 | static QString sortStringLabel(); |
496 | 496 | ||
497 | /** | 497 | /** |
498 | Set URL. | 498 | Set URL. |
499 | */ | 499 | */ |
500 | void setUrl( const KURL &url ); | 500 | void setUrl( const KURL &url ); |
501 | /** | 501 | /** |
502 | Return URL. | 502 | Return URL. |
503 | */ | 503 | */ |
504 | KURL url() const; | 504 | KURL url() const; |
505 | /** | 505 | /** |
506 | Return translated label for url field. | 506 | Return translated label for url field. |
507 | */ | 507 | */ |
508 | static QString urlLabel(); | 508 | static QString urlLabel(); |
509 | 509 | ||
510 | /** | 510 | /** |
511 | Set security class. | 511 | Set security class. |
512 | */ | 512 | */ |
513 | void setSecrecy( const Secrecy &secrecy ); | 513 | void setSecrecy( const Secrecy &secrecy ); |
514 | /** | 514 | /** |
515 | Return security class. | 515 | Return security class. |
516 | */ | 516 | */ |
517 | Secrecy secrecy() const; | 517 | Secrecy secrecy() const; |
518 | /** | 518 | /** |
519 | Return translated label for secrecy field. | 519 | Return translated label for secrecy field. |
520 | */ | 520 | */ |
521 | static QString secrecyLabel(); | 521 | static QString secrecyLabel(); |
522 | 522 | ||
523 | /** | 523 | /** |
524 | Set logo. | 524 | Set logo. |
525 | */ | 525 | */ |
526 | void setLogo( const Picture &logo ); | 526 | void setLogo( const Picture &logo ); |
527 | /** | 527 | /** |
528 | Return logo. | 528 | Return logo. |
529 | */ | 529 | */ |
530 | Picture logo() const; | 530 | Picture logo() const; |
531 | /** | 531 | /** |
532 | Return translated label for logo field. | 532 | Return translated label for logo field. |
533 | */ | 533 | */ |
534 | static QString logoLabel(); | 534 | static QString logoLabel(); |
535 | 535 | ||
536 | /** | 536 | /** |
537 | Set photo. | 537 | Set photo. |
538 | */ | 538 | */ |
539 | void setPhoto( const Picture &photo ); | 539 | void setPhoto( const Picture &photo ); |
540 | /** | 540 | /** |
541 | Return photo. | 541 | Return photo. |
542 | */ | 542 | */ |
543 | Picture photo() const; | 543 | Picture photo() const; |
544 | /** | 544 | /** |
545 | Return translated label for photo field. | 545 | Return translated label for photo field. |
546 | */ | 546 | */ |
547 | static QString photoLabel(); | 547 | static QString photoLabel(); |
548 | 548 | ||
549 | /** | 549 | /** |
550 | Set sound. | 550 | Set sound. |
551 | */ | 551 | */ |
552 | void setSound( const Sound &sound ); | 552 | void setSound( const Sound &sound ); |
553 | /** | 553 | /** |
554 | Return sound. | 554 | Return sound. |
555 | */ | 555 | */ |
556 | Sound sound() const; | 556 | Sound sound() const; |
557 | /** | 557 | /** |
558 | Return translated label for sound field. | 558 | Return translated label for sound field. |
559 | */ | 559 | */ |
560 | static QString soundLabel(); | 560 | static QString soundLabel(); |
561 | 561 | ||
562 | /** | 562 | /** |
563 | Set agent. | 563 | Set agent. |
564 | */ | 564 | */ |
565 | void setAgent( const Agent &agent ); | 565 | void setAgent( const Agent &agent ); |
566 | /** | 566 | /** |
567 | Return agent. | 567 | Return agent. |
568 | */ | 568 | */ |
569 | Agent agent() const; | 569 | Agent agent() const; |
570 | /** | 570 | /** |
571 | Return translated label for agent field. | 571 | Return translated label for agent field. |
572 | */ | 572 | */ |
573 | static QString agentLabel(); | 573 | static QString agentLabel(); |
574 | 574 | ||
575 | /** | 575 | /** |
576 | Set name fields by parsing the given string and trying to associate the | 576 | Set name fields by parsing the given string and trying to associate the |
577 | parts of the string with according fields. This function should probably | 577 | parts of the string with according fields. This function should probably |
578 | be a bit more clever. | 578 | be a bit more clever. |
579 | */ | 579 | */ |
580 | void setNameFromString( const QString & ); | 580 | void setNameFromString( const QString & ); |
581 | 581 | ||
582 | /** | 582 | /** |
583 | Return the name of the addressee. This is calculated from all the name | 583 | Return the name of the addressee. This is calculated from all the name |
584 | fields. | 584 | fields. |
585 | */ | 585 | */ |
586 | QString realName() const; | 586 | QString realName() const; |
587 | 587 | ||
588 | /** | 588 | /** |
589 | Return the name that consists of all name parts. | 589 | Return the name that consists of all name parts. |
590 | */ | 590 | */ |
591 | QString assembledName() const; | 591 | QString assembledName() const; |
592 | 592 | ||
593 | /** | 593 | /** |
594 | Return email address including real name. | 594 | Return email address including real name. |
595 | 595 | ||
596 | @param email Email address to be used to construct the full email string. | 596 | @param email Email address to be used to construct the full email string. |
597 | If this is QString::null the preferred email address is used. | 597 | If this is QString::null the preferred email address is used. |
598 | */ | 598 | */ |
599 | QString fullEmail( const QString &email=QString::null ) const; | 599 | QString fullEmail( const QString &email=QString::null ) const; |
600 | 600 | ||
601 | /** | 601 | /** |
602 | Insert an email address. If the email address already exists in this | 602 | Insert an email address. If the email address already exists in this |
603 | addressee it is not duplicated. | 603 | addressee it is not duplicated. |
604 | 604 | ||
605 | @param email Email address | 605 | @param email Email address |
606 | @param preferred Set to true, if this is the preferred email address of | 606 | @param preferred Set to true, if this is the preferred email address of |
607 | the addressee. | 607 | the addressee. |
608 | */ | 608 | */ |
609 | void insertEmail( const QString &email, bool preferred=false ); | 609 | void insertEmail( const QString &email, bool preferred=false ); |
610 | 610 | ||
611 | /** | 611 | /** |
612 | Remove email address. If the email address doesn't exist, nothing happens. | 612 | Remove email address. If the email address doesn't exist, nothing happens. |
613 | */ | 613 | */ |
614 | void removeEmail( const QString &email ); | 614 | void removeEmail( const QString &email ); |
615 | 615 | ||
616 | /** | 616 | /** |
617 | Return preferred email address. This is the first email address or the | 617 | Return preferred email address. This is the first email address or the |
618 | last one added with @ref insertEmail() with a set preferred parameter. | 618 | last one added with @ref insertEmail() with a set preferred parameter. |
619 | */ | 619 | */ |
620 | QString preferredEmail() const; | 620 | QString preferredEmail() const; |
621 | 621 | ||
622 | /** | 622 | /** |
623 | Return list of all email addresses. | 623 | Return list of all email addresses. |
624 | */ | 624 | */ |
625 | QStringList emails() const; | 625 | QStringList emails() const; |
626 | 626 | ||
627 | /** | 627 | /** |
628 | Set the emails to @param. | 628 | Set the emails to @param. |
629 | The first email address gets the preferred one! | 629 | The first email address gets the preferred one! |
630 | @param list The list of email addresses. | 630 | @param list The list of email addresses. |
631 | */ | 631 | */ |
632 | void setEmails( const QStringList& list); | 632 | void setEmails( const QStringList& list); |
633 | 633 | ||
634 | /** | 634 | /** |
635 | Insert a phone number. If a phone number with the same id already exists | 635 | Insert a phone number. If a phone number with the same id already exists |
636 | in this addressee it is not duplicated. | 636 | in this addressee it is not duplicated. |
637 | */ | 637 | */ |
638 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 638 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
639 | 639 | ||
640 | /** | 640 | /** |
641 | Remove phone number. If no phone number with the given id exists for this | 641 | Remove phone number. If no phone number with the given id exists for this |
642 | addresse nothing happens. | 642 | addresse nothing happens. |
643 | */ | 643 | */ |
644 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 644 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
645 | 645 | ||
646 | /** | 646 | /** |
647 | Return phone number, which matches the given type. | 647 | Return phone number, which matches the given type. |
648 | */ | 648 | */ |
649 | PhoneNumber phoneNumber( int type ) const; | 649 | PhoneNumber phoneNumber( int type ) const; |
650 | 650 | ||
651 | /** | 651 | /** |
652 | Return list of all phone numbers. | 652 | Return list of all phone numbers. |
653 | */ | 653 | */ |
654 | PhoneNumber::List phoneNumbers() const; | 654 | PhoneNumber::List phoneNumbers() const; |
655 | 655 | ||
656 | /** | 656 | /** |
657 | Return list of phone numbers with a special type. | 657 | Return list of phone numbers with a special type. |
658 | */ | 658 | */ |
659 | PhoneNumber::List phoneNumbers( int type ) const; | 659 | PhoneNumber::List phoneNumbers( int type ) const; |
660 | 660 | ||
661 | /** | 661 | /** |
662 | Return phone number with the given id. | 662 | Return phone number with the given id. |
663 | */ | 663 | */ |
664 | PhoneNumber findPhoneNumber( const QString &id ) const; | 664 | PhoneNumber findPhoneNumber( const QString &id ) const; |
665 | 665 | ||
666 | /** | 666 | /** |
667 | Insert a key. If a key with the same id already exists | 667 | Insert a key. If a key with the same id already exists |
668 | in this addressee it is not duplicated. | 668 | in this addressee it is not duplicated. |
669 | */ | 669 | */ |
670 | void insertKey( const Key &key ); | 670 | void insertKey( const Key &key ); |
671 | 671 | ||
672 | /** | 672 | /** |
673 | Remove a key. If no key with the given id exists for this | 673 | Remove a key. If no key with the given id exists for this |
674 | addresse nothing happens. | 674 | addresse nothing happens. |
675 | */ | 675 | */ |
676 | void removeKey( const Key &key ); | 676 | void removeKey( const Key &key ); |
677 | 677 | ||
678 | /** | 678 | /** |
679 | Return key, which matches the given type. | 679 | Return key, which matches the given type. |
680 | If @p type == Key::Custom you can specify a string | 680 | If @p type == Key::Custom you can specify a string |
681 | that should match. If you leave the string empty, the first | 681 | that should match. If you leave the string empty, the first |
682 | key with a custom value is returned. | 682 | key with a custom value is returned. |
683 | */ | 683 | */ |
684 | Key key( int type, QString customTypeString = QString::null ) const; | 684 | Key key( int type, QString customTypeString = QString::null ) const; |
685 | 685 | ||
686 | /** | 686 | /** |
687 | Return list of all keys. | 687 | Return list of all keys. |
688 | */ | 688 | */ |
689 | Key::List keys() const; | 689 | Key::List keys() const; |
690 | 690 | ||
691 | /** | 691 | /** |
692 | Set the list of keys | 692 | Set the list of keys |
693 | @param keys The keys to be set. | 693 | @param keys The keys to be set. |
694 | */ | 694 | */ |
695 | void setKeys( const Key::List& keys); | 695 | void setKeys( const Key::List& keys); |
696 | 696 | ||
697 | /** | 697 | /** |
698 | Return list of keys with a special type. | 698 | Return list of keys with a special type. |
699 | If @p type == Key::Custom you can specify a string | 699 | If @p type == Key::Custom you can specify a string |
700 | that should match. If you leave the string empty, all custom | 700 | that should match. If you leave the string empty, all custom |
701 | keys will be returned. | 701 | keys will be returned. |
702 | */ | 702 | */ |
703 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 703 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
704 | 704 | ||
705 | /** | 705 | /** |
706 | Return key with the given id. | 706 | Return key with the given id. |
707 | */ | 707 | */ |
708 | Key findKey( const QString &id ) const; | 708 | Key findKey( const QString &id ) const; |
709 | 709 | ||
710 | /** | 710 | /** |
711 | Insert an address. If an address with the same id already exists | 711 | Insert an address. If an address with the same id already exists |
712 | in this addressee it is not duplicated. | 712 | in this addressee it is not duplicated. |
713 | */ | 713 | */ |
714 | void insertAddress( const Address &address ); | 714 | void insertAddress( const Address &address ); |
715 | 715 | ||
716 | /** | 716 | /** |
717 | Remove address. If no address with the given id exists for this | 717 | Remove address. If no address with the given id exists for this |
718 | addresse nothing happens. | 718 | addresse nothing happens. |
719 | */ | 719 | */ |
720 | void removeAddress( const Address &address ); | 720 | void removeAddress( const Address &address ); |
721 | 721 | ||
722 | /** | 722 | /** |
723 | Return address, which matches the given type. | 723 | Return address, which matches the given type. |
724 | */ | 724 | */ |
725 | Address address( int type ) const; | 725 | Address address( int type ) const; |
726 | 726 | ||
727 | /** | 727 | /** |
728 | Return list of all addresses. | 728 | Return list of all addresses. |
729 | */ | 729 | */ |
730 | Address::List addresses() const; | 730 | Address::List addresses() const; |
731 | 731 | ||
732 | /** | 732 | /** |
733 | Return list of addresses with a special type. | 733 | Return list of addresses with a special type. |
734 | */ | 734 | */ |
735 | Address::List addresses( int type ) const; | 735 | Address::List addresses( int type ) const; |
736 | 736 | ||
737 | /** | 737 | /** |
738 | Return address with the given id. | 738 | Return address with the given id. |
739 | */ | 739 | */ |
740 | Address findAddress( const QString &id ) const; | 740 | Address findAddress( const QString &id ) const; |
741 | 741 | ||
742 | /** | 742 | /** |
743 | Insert category. If the category already exists it is not duplicated. | 743 | Insert category. If the category already exists it is not duplicated. |
744 | */ | 744 | */ |
745 | void insertCategory( const QString & ); | 745 | void insertCategory( const QString & ); |
746 | 746 | ||
747 | /** | 747 | /** |
748 | Remove category. | 748 | Remove category. |
749 | */ | 749 | */ |
750 | void removeCategory( const QString & ); | 750 | void removeCategory( const QString & ); |
751 | 751 | ||
752 | /** | 752 | /** |
753 | Return, if addressee has the given category. | 753 | Return, if addressee has the given category. |
754 | */ | 754 | */ |
755 | bool hasCategory( const QString & ) const; | 755 | bool hasCategory( const QString & ) const; |
756 | 756 | ||
757 | /** | 757 | /** |
758 | Set categories to given value. | 758 | Set categories to given value. |
759 | */ | 759 | */ |
760 | void setCategories( const QStringList & ); | 760 | void setCategories( const QStringList & ); |
761 | 761 | ||
762 | /** | 762 | /** |
763 | Return list of all set categories. | 763 | Return list of all set categories. |
764 | */ | 764 | */ |
765 | QStringList categories() const; | 765 | QStringList categories() const; |
766 | 766 | ||
767 | /** | 767 | /** |
768 | Insert custom entry. The entry is identified by the name of the inserting | 768 | Insert custom entry. The entry is identified by the name of the inserting |
769 | application and a unique name. If an entry with the given app and name | 769 | application and a unique name. If an entry with the given app and name |
770 | already exists its value is replaced with the new given value. | 770 | already exists its value is replaced with the new given value. |
771 | */ | 771 | */ |
772 | void insertCustom( const QString &app, const QString &name, | 772 | void insertCustom( const QString &app, const QString &name, |
773 | const QString &value ); | 773 | const QString &value ); |
774 | 774 | ||
775 | /** | 775 | /** |
776 | Remove custom entry. | 776 | Remove custom entry. |
777 | */ | 777 | */ |
778 | void removeCustom( const QString &app, const QString &name ); | 778 | void removeCustom( const QString &app, const QString &name ); |
779 | 779 | ||
780 | /** | 780 | /** |
781 | Return value of custom entry, identified by app and entry name. | 781 | Return value of custom entry, identified by app and entry name. |
782 | */ | 782 | */ |
783 | QString custom( const QString &app, const QString &name ) const; | 783 | QString custom( const QString &app, const QString &name ) const; |
784 | 784 | ||
785 | /** | 785 | /** |
786 | Set all custom entries. | 786 | Set all custom entries. |
787 | */ | 787 | */ |
788 | void setCustoms( const QStringList & ); | 788 | void setCustoms( const QStringList & ); |
789 | 789 | ||
790 | /** | 790 | /** |
791 | Return list of all custom entries. | 791 | Return list of all custom entries. |
792 | */ | 792 | */ |
793 | QStringList customs() const; | 793 | QStringList customs() const; |
794 | 794 | ||
795 | /** | 795 | /** |
796 | Parse full email address. The result is given back in fullName and email. | 796 | Parse full email address. The result is given back in fullName and email. |
797 | */ | 797 | */ |
798 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 798 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
799 | QString &email ); | 799 | QString &email ); |
800 | 800 | ||
801 | /** | 801 | /** |
802 | Debug output. | 802 | Debug output. |
803 | */ | 803 | */ |
804 | void dump() const; | 804 | void dump() const; |
805 | 805 | ||
806 | /** | 806 | /** |
807 | Returns string representation of the addressee. | 807 | Returns string representation of the addressee. |
808 | */ | 808 | */ |
809 | QString asString() const; | 809 | QString asString() const; |
810 | 810 | ||
811 | /** | 811 | /** |
812 | Set resource where the addressee is from. | 812 | Set resource where the addressee is from. |
813 | */ | 813 | */ |
814 | void setResource( Resource *resource ); | 814 | void setResource( Resource *resource ); |
815 | 815 | ||
816 | /** | 816 | /** |
817 | Return pointer to resource. | 817 | Return pointer to resource. |
818 | */ | 818 | */ |
819 | Resource *resource() const; | 819 | Resource *resource() const; |
820 | 820 | ||
821 | /** | 821 | /** |
822 | Return resourcelabel. | 822 | Return resourcelabel. |
823 | */ | 823 | */ |
824 | //US | 824 | //US |
825 | static QString resourceLabel(); | 825 | static QString resourceLabel(); |
826 | static QString categoryLabel(); | 826 | static QString categoryLabel(); |
827 | /** | 827 | /** |
828 | Mark addressee as changed. | 828 | Mark addressee as changed. |
829 | */ | 829 | */ |
830 | void setChanged( bool value ); | 830 | void setChanged( bool value ); |
831 | 831 | ||
832 | /** | 832 | /** |
833 | Return whether the addressee is changed. | 833 | Return whether the addressee is changed. |
834 | */ | 834 | */ |
835 | bool changed() const; | 835 | bool changed() const; |
836 | 836 | ||
837 | void setTagged( bool value ); | 837 | void setTagged( bool value ); |
838 | bool tagged() const; | 838 | bool tagged() const; |
839 | 839 | ||
840 | private: | 840 | private: |
841 | Addressee copy(); | 841 | Addressee copy(); |
842 | void detach(); | 842 | void detach(); |
843 | 843 | ||
844 | struct AddresseeData; | 844 | struct AddresseeData; |
845 | mutable KSharedPtr<AddresseeData> mData; | 845 | mutable KSharedPtr<AddresseeData> mData; |
846 | }; | 846 | }; |
847 | 847 | ||
848 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 848 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
849 | QDataStream &operator>>( QDataStream &, Addressee & ); | 849 | QDataStream &operator>>( QDataStream &, Addressee & ); |
850 | 850 | ||
851 | } | 851 | } |
852 | 852 | ||
853 | #endif | 853 | #endif |