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