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