summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardformatimpl.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp
index c31af46..b9fe6ff 100644
--- a/kabc/vcardformatimpl.cpp
+++ b/kabc/vcardformatimpl.cpp
@@ -1,1045 +1,1045 @@
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/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <qfile.h> 28#include <qfile.h>
29#include <qregexp.h> 29#include <qregexp.h>
30 30
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kmdcodec.h> 32#include <kmdcodec.h>
33#include <kstandarddirs.h> 33#include <kstandarddirs.h>
34#include <ktempfile.h> 34#include <ktempfile.h>
35 35
36#include <VCard.h> 36#include <VCard.h>
37 37
38#include "addressbook.h" 38#include "addressbook.h"
39#include "vcardformatimpl.h" 39#include "vcardformatimpl.h"
40 40
41using namespace KABC; 41using namespace KABC;
42using namespace VCARD; 42using namespace VCARD;
43 43
44int VCardFormatImpl::debug = -1; 44int VCardFormatImpl::debug = -1;
45 45
46VCardFormatImpl::VCardFormatImpl() 46VCardFormatImpl::VCardFormatImpl()
47{ 47{
48 debug = (getenv("KABC_DEBUG") != 0); 48 debug = (getenv("KABC_DEBUG") != 0);
49} 49}
50 50
51bool VCardFormatImpl::load( Addressee &addressee, QFile *file ) 51bool VCardFormatImpl::load( Addressee &addressee, QFile *file )
52{ 52{
53 kdDebug(5700) << "VCardFormat::load()" << endl; 53 kdDebug(5700) << "VCardFormat::load()" << endl;
54 54
55 QByteArray fdata = file->readAll(); 55 QByteArray fdata = file->readAll();
56 QCString data(fdata.data(), fdata.size()+1); 56 QCString data(fdata.data(), fdata.size()+1);
57 57
58 VCardEntity e( data ); 58 VCardEntity e( data );
59 59
60 VCardListIterator it( e.cardList() ); 60 VCardListIterator it( e.cardList() );
61 61
62 if ( it.current() ) { 62 if ( it.current() ) {
63//US VCard v(*it.current()); 63//US VCard v(*it.current());
64//US loadAddressee( addressee, v ); 64//US loadAddressee( addressee, v );
65 loadAddressee( addressee, it.current() ); 65 loadAddressee( addressee, it.current() );
66 return true; 66 return true;
67 } 67 }
68 68
69 return false; 69 return false;
70} 70}
71 71
72bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file ) 72bool VCardFormatImpl::loadAll( AddressBook *addressBook, Resource *resource, QFile *file )
73{ 73{
74 kdDebug(5700) << "VCardFormat::loadAll()" << endl; 74 kdDebug(5700) << "VCardFormat::loadAll()" << endl;
75 75
76 QByteArray fdata = file->readAll(); 76 QByteArray fdata = file->readAll();
77 QCString data(fdata.data(), fdata.size()+1); 77 QCString data(fdata.data(), fdata.size()+1);
78 78
79 VCardEntity e( data ); 79 VCardEntity e( data );
80 80
81 VCardListIterator it( e.cardList() ); 81 VCardListIterator it( e.cardList() );
82 82
83 for (; it.current(); ++it) { 83 for (; it.current(); ++it) {
84//US VCard v(*it.current()); 84//US VCard v(*it.current());
85 Addressee addressee; 85 Addressee addressee;
86//US loadAddressee( addressee, v ); 86//US loadAddressee( addressee, v );
87 loadAddressee( addressee, it.current() ); 87 loadAddressee( addressee, it.current() );
88 addressee.setResource( resource ); 88 addressee.setResource( resource );
89 addressBook->insertAddressee( addressee ); 89 addressBook->insertAddressee( addressee );
90 if (debug == true) 90 if (debug == true)
91 { 91 {
92 printf("address %s loaded successfully\n", addressee.formattedName().latin1()); 92 printf("address %s loaded successfully\n", addressee.formattedName().latin1());
93 } 93 }
94 } 94 }
95 95
96 return true; 96 return true;
97} 97}
98 98
99void VCardFormatImpl::save( const Addressee &addressee, QFile *file ) 99void VCardFormatImpl::save( const Addressee &addressee, QFile *file )
100{ 100{
101 VCardEntity vcards; 101 VCardEntity vcards;
102 VCardList vcardlist; 102 VCardList vcardlist;
103 vcardlist.setAutoDelete( true ); 103 vcardlist.setAutoDelete( true );
104 104
105 VCard *v = new VCard; 105 VCard *v = new VCard;
106 106
107 saveAddressee( addressee, v, false ); 107 saveAddressee( addressee, v, false );
108 108
109 vcardlist.append( v ); 109 vcardlist.append( v );
110 vcards.setCardList( vcardlist ); 110 vcards.setCardList( vcardlist );
111 111
112 QCString vcardData = vcards.asString(); 112 QCString vcardData = vcards.asString();
113 file->writeBlock( (const char*)vcardData, vcardData.length() ); 113 file->writeBlock( (const char*)vcardData, vcardData.length() );
114} 114}
115 115
116void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file ) 116void VCardFormatImpl::saveAll( AddressBook *ab, Resource *resource, QFile *file )
117{ 117{
118 VCardEntity vcards; 118 VCardEntity vcards;
119 VCardList vcardlist; 119 VCardList vcardlist;
120 vcardlist.setAutoDelete( true ); 120 vcardlist.setAutoDelete( true );
121 121
122 AddressBook::Iterator it; 122 AddressBook::Iterator it;
123 for ( it = ab->begin(); it != ab->end(); ++it ) { 123 for ( it = ab->begin(); it != ab->end(); ++it ) {
124 if ( (*it).resource() == resource ) { 124 if ( (*it).resource() == resource ) {
125 VCard *v = new VCard; 125 VCard *v = new VCard;
126 saveAddressee( (*it), v, false ); 126 saveAddressee( (*it), v, true );
127 (*it).setChanged( false ); 127 (*it).setChanged( false );
128 vcardlist.append( v ); 128 vcardlist.append( v );
129 } 129 }
130 } 130 }
131 131
132 vcards.setCardList( vcardlist ); 132 vcards.setCardList( vcardlist );
133 133
134 QCString vcardData = vcards.asString(); 134 QCString vcardData = vcards.asString();
135 file->writeBlock( (const char*)vcardData, vcardData.length() ); 135 file->writeBlock( (const char*)vcardData, vcardData.length() );
136} 136}
137 137
138bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v ) 138bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v )
139{ 139{
140 QPtrList<ContentLine> contentLines = v->contentLineList(); 140 QPtrList<ContentLine> contentLines = v->contentLineList();
141 ContentLine *cl; 141 ContentLine *cl;
142 142
143 for( cl = contentLines.first(); cl; cl = contentLines.next() ) { 143 for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
144 QCString n = cl->name(); 144 QCString n = cl->name();
145 if ( n.left( 2 ) == "X-" ) { 145 if ( n.left( 2 ) == "X-" ) {
146 n = n.mid( 2 ); 146 n = n.mid( 2 );
147 int posDash = n.find( "-" ); 147 int posDash = n.find( "-" );
148 addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ), 148 addressee.insertCustom( QString::fromUtf8( n.left( posDash ) ),
149 QString::fromUtf8( n.mid( posDash + 1 ) ), 149 QString::fromUtf8( n.mid( posDash + 1 ) ),
150 QString::fromUtf8( cl->value()->asString() ) ); 150 QString::fromUtf8( cl->value()->asString() ) );
151 continue; 151 continue;
152 } 152 }
153 153
154 EntityType type = cl->entityType(); 154 EntityType type = cl->entityType();
155 switch( type ) { 155 switch( type ) {
156 156
157 case EntityUID: 157 case EntityUID:
158 addressee.setUid( readTextValue( cl ) ); 158 addressee.setUid( readTextValue( cl ) );
159 break; 159 break;
160 160
161 case EntityEmail: 161 case EntityEmail:
162 addressee.insertEmail( readTextValue( cl ) ); 162 addressee.insertEmail( readTextValue( cl ) );
163 break; 163 break;
164 164
165 case EntityName: 165 case EntityName:
166 addressee.setName( readTextValue( cl ) ); 166 addressee.setName( readTextValue( cl ) );
167 break; 167 break;
168 168
169 case EntityFullName: 169 case EntityFullName:
170 addressee.setFormattedName( readTextValue( cl ) ); 170 addressee.setFormattedName( readTextValue( cl ) );
171 break; 171 break;
172 172
173 case EntityURL: 173 case EntityURL:
174 addressee.setUrl( KURL( readTextValue( cl ) ) ); 174 addressee.setUrl( KURL( readTextValue( cl ) ) );
175 break; 175 break;
176 176
177 case EntityNickname: 177 case EntityNickname:
178 addressee.setNickName( readTextValue( cl ) ); 178 addressee.setNickName( readTextValue( cl ) );
179 break; 179 break;
180 180
181 case EntityLabel: 181 case EntityLabel:
182 // not yet supported by kabc 182 // not yet supported by kabc
183 break; 183 break;
184 184
185 case EntityMailer: 185 case EntityMailer:
186 addressee.setMailer( readTextValue( cl ) ); 186 addressee.setMailer( readTextValue( cl ) );
187 break; 187 break;
188 188
189 case EntityTitle: 189 case EntityTitle:
190 addressee.setTitle( readTextValue( cl ) ); 190 addressee.setTitle( readTextValue( cl ) );
191 break; 191 break;
192 192
193 case EntityRole: 193 case EntityRole:
194 addressee.setRole( readTextValue( cl ) ); 194 addressee.setRole( readTextValue( cl ) );
195 break; 195 break;
196 196
197 case EntityOrganisation: 197 case EntityOrganisation:
198 addressee.setOrganization( readTextValue( cl ) ); 198 addressee.setOrganization( readTextValue( cl ) );
199 break; 199 break;
200 200
201 case EntityNote: 201 case EntityNote:
202 addressee.setNote( readTextValue( cl ) ); 202 addressee.setNote( readTextValue( cl ) );
203 break; 203 break;
204 204
205 case EntityProductID: 205 case EntityProductID:
206 addressee.setProductId( readTextValue( cl ) ); 206 addressee.setProductId( readTextValue( cl ) );
207 break; 207 break;
208 208
209 case EntitySortString: 209 case EntitySortString:
210 addressee.setSortString( readTextValue( cl ) ); 210 addressee.setSortString( readTextValue( cl ) );
211 break; 211 break;
212 212
213 case EntityN: 213 case EntityN:
214 readNValue( cl, addressee ); 214 readNValue( cl, addressee );
215 break; 215 break;
216 216
217 case EntityAddress: 217 case EntityAddress:
218 addressee.insertAddress( readAddressValue( cl ) ); 218 addressee.insertAddress( readAddressValue( cl ) );
219 break; 219 break;
220 220
221 case EntityTelephone: 221 case EntityTelephone:
222 addressee.insertPhoneNumber( readTelephoneValue( cl ) ); 222 addressee.insertPhoneNumber( readTelephoneValue( cl ) );
223 break; 223 break;
224 224
225 case EntityCategories: 225 case EntityCategories:
226 addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); 226 addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) );
227 break; 227 break;
228 228
229 case EntityBirthday: 229 case EntityBirthday:
230 addressee.setBirthday( readDateValue( cl ) ); 230 addressee.setBirthday( readDateValue( cl ) );
231 break; 231 break;
232 232
233 case EntityRevision: 233 case EntityRevision:
234 addressee.setRevision( readDateTimeValue( cl ) ); 234 addressee.setRevision( readDateTimeValue( cl ) );
235 break; 235 break;
236 236
237 case EntityGeo: 237 case EntityGeo:
238 addressee.setGeo( readGeoValue( cl ) ); 238 addressee.setGeo( readGeoValue( cl ) );
239 break; 239 break;
240 240
241 case EntityTimeZone: 241 case EntityTimeZone:
242 addressee.setTimeZone( readUTCValue( cl ) ); 242 addressee.setTimeZone( readUTCValue( cl ) );
243 break; 243 break;
244 244
245 case EntityVersion: 245 case EntityVersion:
246 break; 246 break;
247 247
248 case EntityClass: 248 case EntityClass:
249 addressee.setSecrecy( readClassValue( cl ) ); 249 addressee.setSecrecy( readClassValue( cl ) );
250 break; 250 break;
251 251
252 case EntityKey: 252 case EntityKey:
253 addressee.insertKey( readKeyValue( cl ) ); 253 addressee.insertKey( readKeyValue( cl ) );
254 break; 254 break;
255 255
256 case EntityPhoto: 256 case EntityPhoto:
257 addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); 257 addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) );
258 break; 258 break;
259 259
260 case EntityLogo: 260 case EntityLogo:
261 addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); 261 addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) );
262 break; 262 break;
263 263
264 case EntityAgent: 264 case EntityAgent:
265 addressee.setAgent( readAgentValue( cl ) ); 265 addressee.setAgent( readAgentValue( cl ) );
266 break; 266 break;
267 267
268 case EntitySound: 268 case EntitySound:
269 addressee.setSound( readSoundValue( cl, addressee ) ); 269 addressee.setSound( readSoundValue( cl, addressee ) );
270 break; 270 break;
271 271
272 default: 272 default:
273 kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " 273 kdDebug(5700) << "VCardFormat::load(): Unsupported entity: "
274 << int( type ) << ": " << cl->asString() << endl; 274 << int( type ) << ": " << cl->asString() << endl;
275 qDebug("VCardFormat::load(): Unsupported entity: %i: %s ", int(type), (const char*)cl->asString()); 275 qDebug("VCardFormat::load(): Unsupported entity: %i: %s ", int(type), (const char*)cl->asString());
276 break; 276 break;
277 } 277 }
278 } 278 }
279 279
280 for( cl = contentLines.first(); cl; cl = contentLines.next() ) { 280 for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
281 EntityType type = cl->entityType(); 281 EntityType type = cl->entityType();
282 if ( type == EntityLabel ) { 282 if ( type == EntityLabel ) {
283 int type = readAddressParam( cl ); 283 int type = readAddressParam( cl );
284 Address address = addressee.address( type ); 284 Address address = addressee.address( type );
285 if ( address.isEmpty() ) 285 if ( address.isEmpty() )
286 address.setType( type ); 286 address.setType( type );
287 287
288 address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); 288 address.setLabel( QString::fromUtf8( cl->value()->asString() ) );
289 addressee.insertAddress( address ); 289 addressee.insertAddress( address );
290 } 290 }
291 } 291 }
292 292
293 return true; 293 return true;
294} 294}
295 295
296void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) 296void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern )
297{ 297{
298//US ContentLine cl; 298//US ContentLine cl;
299//US QString value; 299//US QString value;
300 300
301 addTextValue( v, EntityName, addressee.name() ); 301 addTextValue( v, EntityName, addressee.name() );
302 addTextValue( v, EntityUID, addressee.uid() ); 302 addTextValue( v, EntityUID, addressee.uid() );
303 addTextValue( v, EntityFullName, addressee.formattedName() ); 303 addTextValue( v, EntityFullName, addressee.formattedName() );
304 304
305 QStringList emails = addressee.emails(); 305 QStringList emails = addressee.emails();
306 QStringList::ConstIterator it4; 306 QStringList::ConstIterator it4;
307 for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { 307 for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) {
308 addTextValue( v, EntityEmail, *it4 ); 308 addTextValue( v, EntityEmail, *it4 );
309 } 309 }
310 310
311 QStringList customs = addressee.customs(); 311 QStringList customs = addressee.customs();
312 QStringList::ConstIterator it5; 312 QStringList::ConstIterator it5;
313 for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { 313 for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) {
314 addCustomValue( v, *it5 ); 314 addCustomValue( v, *it5 );
315 } 315 }
316 316
317 addTextValue( v, EntityURL, addressee.url().url() ); 317 addTextValue( v, EntityURL, addressee.url().url() );
318 318
319 addNValue( v, addressee ); 319 addNValue( v, addressee );
320 320
321 addTextValue( v, EntityNickname, addressee.nickName() ); 321 addTextValue( v, EntityNickname, addressee.nickName() );
322 addTextValue( v, EntityMailer, addressee.mailer() ); 322 addTextValue( v, EntityMailer, addressee.mailer() );
323 addTextValue( v, EntityTitle, addressee.title() ); 323 addTextValue( v, EntityTitle, addressee.title() );
324 addTextValue( v, EntityRole, addressee.role() ); 324 addTextValue( v, EntityRole, addressee.role() );
325 addTextValue( v, EntityOrganisation, addressee.organization() ); 325 addTextValue( v, EntityOrganisation, addressee.organization() );
326 addTextValue( v, EntityNote, addressee.note() ); 326 addTextValue( v, EntityNote, addressee.note() );
327 addTextValue( v, EntityProductID, addressee.productId() ); 327 addTextValue( v, EntityProductID, addressee.productId() );
328 addTextValue( v, EntitySortString, addressee.sortString() ); 328 addTextValue( v, EntitySortString, addressee.sortString() );
329 329
330 Address::List addresses = addressee.addresses(); 330 Address::List addresses = addressee.addresses();
331 Address::List::ConstIterator it3; 331 Address::List::ConstIterator it3;
332 for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) { 332 for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) {
333 addAddressValue( v, *it3 ); 333 addAddressValue( v, *it3 );
334 addLabelValue( v, *it3 ); 334 addLabelValue( v, *it3 );
335 } 335 }
336 336
337 PhoneNumber::List phoneNumbers = addressee.phoneNumbers(); 337 PhoneNumber::List phoneNumbers = addressee.phoneNumbers();
338 PhoneNumber::List::ConstIterator it2; 338 PhoneNumber::List::ConstIterator it2;
339 for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) { 339 for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) {
340 addTelephoneValue( v, *it2 ); 340 addTelephoneValue( v, *it2 );
341 } 341 }
342 342
343 Key::List keys = addressee.keys(); 343 Key::List keys = addressee.keys();
344 Key::List::ConstIterator it6; 344 Key::List::ConstIterator it6;
345 for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) { 345 for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) {
346 addKeyValue( v, *it6 ); 346 addKeyValue( v, *it6 );
347 } 347 }
348 348
349 addTextValue( v, EntityCategories, addressee.categories().join(",") ); 349 addTextValue( v, EntityCategories, addressee.categories().join(",") );
350 350
351 addDateValue( v, EntityBirthday, addressee.birthday().date() ); 351 addDateValue( v, EntityBirthday, addressee.birthday().date() );
352 addDateTimeValue( v, EntityRevision, addressee.revision() ); 352 addDateTimeValue( v, EntityRevision, addressee.revision() );
353 addGeoValue( v, addressee.geo() ); 353 addGeoValue( v, addressee.geo() );
354 addUTCValue( v, addressee.timeZone() ); 354 addUTCValue( v, addressee.timeZone() );
355 355
356 addClassValue( v, addressee.secrecy() ); 356 addClassValue( v, addressee.secrecy() );
357 357
358 addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern ); 358 addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern );
359 addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern ); 359 addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern );
360 360
361 addAgentValue( v, addressee.agent() ); 361 addAgentValue( v, addressee.agent() );
362 362
363 addSoundValue( v, addressee.sound(), addressee, intern ); 363 addSoundValue( v, addressee.sound(), addressee, intern );
364} 364}
365 365
366void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt ) 366void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt )
367{ 367{
368 if ( txt.isEmpty() ) return; 368 if ( txt.isEmpty() ) return;
369 369
370 ContentLine cl; 370 ContentLine cl;
371 cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() ); 371 cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() );
372 QString value = txt.mid( txt.find( ":" ) + 1 ); 372 QString value = txt.mid( txt.find( ":" ) + 1 );
373 if ( value.isEmpty() ) 373 if ( value.isEmpty() )
374 return; 374 return;
375 cl.setValue( new TextValue( value.utf8() ) ); 375 cl.setValue( new TextValue( value.utf8() ) );
376 v->add(cl); 376 v->add(cl);
377} 377}
378 378
379void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt ) 379void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt )
380{ 380{
381 if ( txt.isEmpty() ) return; 381 if ( txt.isEmpty() ) return;
382 382
383 ContentLine cl; 383 ContentLine cl;
384 cl.setName( EntityTypeToParamName( type ) ); 384 cl.setName( EntityTypeToParamName( type ) );
385 cl.setValue( new TextValue( txt.utf8() ) ); 385 cl.setValue( new TextValue( txt.utf8() ) );
386 v->add(cl); 386 v->add(cl);
387} 387}
388 388
389void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type, 389void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type,
390 const QDate &date ) 390 const QDate &date )
391{ 391{
392 if ( !date.isValid() ) return; 392 if ( !date.isValid() ) return;
393 393
394 ContentLine cl; 394 ContentLine cl;
395 cl.setName( EntityTypeToParamName( type ) ); 395 cl.setName( EntityTypeToParamName( type ) );
396 396
397 DateValue *v = new DateValue( date ); 397 DateValue *v = new DateValue( date );
398 cl.setValue( v ); 398 cl.setValue( v );
399 vcard->add(cl); 399 vcard->add(cl);
400} 400}
401 401
402void VCardFormatImpl::addDateTimeValue( VCard *vcard, EntityType type, 402void VCardFormatImpl::addDateTimeValue( VCard *vcard, EntityType type,
403 const QDateTime &dateTime ) 403 const QDateTime &dateTime )
404{ 404{
405 if ( !dateTime.isValid() ) return; 405 if ( !dateTime.isValid() ) return;
406 406
407 ContentLine cl; 407 ContentLine cl;
408 cl.setName( EntityTypeToParamName( type ) ); 408 cl.setName( EntityTypeToParamName( type ) );
409 409
410 DateValue *v = new DateValue( dateTime ); 410 DateValue *v = new DateValue( dateTime );
411 cl.setValue( v ); 411 cl.setValue( v );
412 vcard->add(cl); 412 vcard->add(cl);
413} 413}
414 414
415void VCardFormatImpl::addAddressValue( VCard *vcard, const Address &a ) 415void VCardFormatImpl::addAddressValue( VCard *vcard, const Address &a )
416{ 416{
417 if ( a.isEmpty() ) 417 if ( a.isEmpty() )
418 return; 418 return;
419 419
420 ContentLine cl; 420 ContentLine cl;
421 cl.setName( EntityTypeToParamName( EntityAddress ) ); 421 cl.setName( EntityTypeToParamName( EntityAddress ) );
422 422
423 AdrValue *v = new AdrValue; 423 AdrValue *v = new AdrValue;
424 v->setPOBox( a.postOfficeBox().utf8() ); 424 v->setPOBox( a.postOfficeBox().utf8() );
425 v->setExtAddress( a.extended().utf8() ); 425 v->setExtAddress( a.extended().utf8() );
426 v->setStreet( a.street().utf8() ); 426 v->setStreet( a.street().utf8() );
427 v->setLocality( a.locality().utf8() ); 427 v->setLocality( a.locality().utf8() );
428 v->setRegion( a.region().utf8() ); 428 v->setRegion( a.region().utf8() );
429 v->setPostCode( a.postalCode().utf8() ); 429 v->setPostCode( a.postalCode().utf8() );
430 v->setCountryName( a.country().utf8() ); 430 v->setCountryName( a.country().utf8() );
431 cl.setValue( v ); 431 cl.setValue( v );
432 432
433 addAddressParam( &cl, a.type() ); 433 addAddressParam( &cl, a.type() );
434 434
435 vcard->add( cl ); 435 vcard->add( cl );
436} 436}
437 437
438void VCardFormatImpl::addLabelValue( VCard *vcard, const Address &a ) 438void VCardFormatImpl::addLabelValue( VCard *vcard, const Address &a )
439{ 439{
440 if ( a.label().isEmpty() ) return; 440 if ( a.label().isEmpty() ) return;
441 441
442 ContentLine cl; 442 ContentLine cl;
443 cl.setName( EntityTypeToParamName( EntityLabel ) ); 443 cl.setName( EntityTypeToParamName( EntityLabel ) );
444 cl.setValue( new TextValue( a.label().utf8() ) ); 444 cl.setValue( new TextValue( a.label().utf8() ) );
445 445
446 addAddressParam( &cl, a.type() ); 446 addAddressParam( &cl, a.type() );
447 447
448 vcard->add( cl ); 448 vcard->add( cl );
449} 449}
450 450
451void VCardFormatImpl::addAddressParam( ContentLine *cl, int type ) 451void VCardFormatImpl::addAddressParam( ContentLine *cl, int type )
452{ 452{
453 ParamList params; 453 ParamList params;
454 if ( type & Address::Dom ) params.append( new Param( "TYPE", "dom" ) ); 454 if ( type & Address::Dom ) params.append( new Param( "TYPE", "dom" ) );
455 if ( type & Address::Intl ) params.append( new Param( "TYPE", "intl" ) ); 455 if ( type & Address::Intl ) params.append( new Param( "TYPE", "intl" ) );
456 if ( type & Address::Parcel ) params.append( new Param( "TYPE", "parcel" ) ); 456 if ( type & Address::Parcel ) params.append( new Param( "TYPE", "parcel" ) );
457 if ( type & Address::Postal ) params.append( new Param( "TYPE", "postal" ) ); 457 if ( type & Address::Postal ) params.append( new Param( "TYPE", "postal" ) );
458 if ( type & Address::Work ) params.append( new Param( "TYPE", "work" ) ); 458 if ( type & Address::Work ) params.append( new Param( "TYPE", "work" ) );
459 if ( type & Address::Home ) params.append( new Param( "TYPE", "home" ) ); 459 if ( type & Address::Home ) params.append( new Param( "TYPE", "home" ) );
460 if ( type & Address::Pref ) params.append( new Param( "TYPE", "pref" ) ); 460 if ( type & Address::Pref ) params.append( new Param( "TYPE", "pref" ) );
461 cl->setParamList( params ); 461 cl->setParamList( params );
462} 462}
463 463
464void VCardFormatImpl::addGeoValue( VCard *vcard, const Geo &geo ) 464void VCardFormatImpl::addGeoValue( VCard *vcard, const Geo &geo )
465{ 465{
466 if ( !geo.isValid() ) return; 466 if ( !geo.isValid() ) return;
467 467
468 ContentLine cl; 468 ContentLine cl;
469 cl.setName( EntityTypeToParamName( EntityGeo ) ); 469 cl.setName( EntityTypeToParamName( EntityGeo ) );
470 470
471 GeoValue *v = new GeoValue; 471 GeoValue *v = new GeoValue;
472 v->setLatitude( geo.latitude() ); 472 v->setLatitude( geo.latitude() );
473 v->setLongitude( geo.longitude() ); 473 v->setLongitude( geo.longitude() );
474 474
475 cl.setValue( v ); 475 cl.setValue( v );
476 vcard->add(cl); 476 vcard->add(cl);
477} 477}
478 478
479void VCardFormatImpl::addUTCValue( VCard *vcard, const TimeZone &tz ) 479void VCardFormatImpl::addUTCValue( VCard *vcard, const TimeZone &tz )
480{ 480{
481 if ( !tz.isValid() ) return; 481 if ( !tz.isValid() ) return;
482 482
483 ContentLine cl; 483 ContentLine cl;
484 cl.setName( EntityTypeToParamName( EntityTimeZone ) ); 484 cl.setName( EntityTypeToParamName( EntityTimeZone ) );
485 485
486 UTCValue *v = new UTCValue; 486 UTCValue *v = new UTCValue;
487 487
488 v->setPositive( tz.offset() >= 0 ); 488 v->setPositive( tz.offset() >= 0 );
489 v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); 489 v->setHour( (tz.offset() / 60) * ( tz.offset() >= 0 ? 1 : -1 ) );
490 v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) ); 490 v->setMinute( (tz.offset() % 60) * ( tz.offset() >= 0 ? 1 : -1 ) );
491 491
492 cl.setValue( v ); 492 cl.setValue( v );
493 vcard->add(cl); 493 vcard->add(cl);
494} 494}
495 495
496void VCardFormatImpl::addClassValue( VCard *vcard, const Secrecy &secrecy ) 496void VCardFormatImpl::addClassValue( VCard *vcard, const Secrecy &secrecy )
497{ 497{
498 ContentLine cl; 498 ContentLine cl;
499 cl.setName( EntityTypeToParamName( EntityClass ) ); 499 cl.setName( EntityTypeToParamName( EntityClass ) );
500 500
501 ClassValue *v = new ClassValue; 501 ClassValue *v = new ClassValue;
502 switch ( secrecy.type() ) { 502 switch ( secrecy.type() ) {
503 case Secrecy::Public: 503 case Secrecy::Public:
504 v->setType( (int)ClassValue::Public ); 504 v->setType( (int)ClassValue::Public );
505 break; 505 break;
506 case Secrecy::Private: 506 case Secrecy::Private:
507 v->setType( (int)ClassValue::Private ); 507 v->setType( (int)ClassValue::Private );
508 break; 508 break;
509 case Secrecy::Confidential: 509 case Secrecy::Confidential:
510 v->setType( (int)ClassValue::Confidential ); 510 v->setType( (int)ClassValue::Confidential );
511 break; 511 break;
512 } 512 }
513 513
514 cl.setValue( v ); 514 cl.setValue( v );
515 vcard->add(cl); 515 vcard->add(cl);
516} 516}
517 517
518 518
519Address VCardFormatImpl::readAddressValue( ContentLine *cl ) 519Address VCardFormatImpl::readAddressValue( ContentLine *cl )
520{ 520{
521 Address a; 521 Address a;
522 AdrValue *v = (AdrValue *)cl->value(); 522 AdrValue *v = (AdrValue *)cl->value();
523 a.setPostOfficeBox( QString::fromUtf8( v->poBox() ) ); 523 a.setPostOfficeBox( QString::fromUtf8( v->poBox() ) );
524 a.setExtended( QString::fromUtf8( v->extAddress() ) ); 524 a.setExtended( QString::fromUtf8( v->extAddress() ) );
525 a.setStreet( QString::fromUtf8( v->street() ) ); 525 a.setStreet( QString::fromUtf8( v->street() ) );
526 a.setLocality( QString::fromUtf8( v->locality() ) ); 526 a.setLocality( QString::fromUtf8( v->locality() ) );
527 a.setRegion( QString::fromUtf8( v->region() ) ); 527 a.setRegion( QString::fromUtf8( v->region() ) );
528 a.setPostalCode( QString::fromUtf8( v->postCode() ) ); 528 a.setPostalCode( QString::fromUtf8( v->postCode() ) );
529 a.setCountry( QString::fromUtf8( v->countryName() ) ); 529 a.setCountry( QString::fromUtf8( v->countryName() ) );
530 530
531 a.setType( readAddressParam( cl ) ); 531 a.setType( readAddressParam( cl ) );
532 532
533 return a; 533 return a;
534} 534}
535 535
536int VCardFormatImpl::readAddressParam( ContentLine *cl ) 536int VCardFormatImpl::readAddressParam( ContentLine *cl )
537{ 537{
538 int type = 0; 538 int type = 0;
539 ParamList params = cl->paramList(); 539 ParamList params = cl->paramList();
540 ParamListIterator it( params ); 540 ParamListIterator it( params );
541 QCString tmpStr; 541 QCString tmpStr;
542 for( ; it.current(); ++it ) { 542 for( ; it.current(); ++it ) {
543 if ( (*it)->name().upper() == "TYPE" ) { 543 if ( (*it)->name().upper() == "TYPE" ) {
544 tmpStr = (*it)->value().lower(); 544 tmpStr = (*it)->value().lower();
545 if ( tmpStr == "dom" ) type |= Address::Dom; 545 if ( tmpStr == "dom" ) type |= Address::Dom;
546 else if ( tmpStr == "intl" ) type |= Address::Intl; 546 else if ( tmpStr == "intl" ) type |= Address::Intl;
547 else if ( tmpStr == "parcel" ) type |= Address::Parcel; 547 else if ( tmpStr == "parcel" ) type |= Address::Parcel;
548 else if ( tmpStr == "postal" ) type |= Address::Postal; 548 else if ( tmpStr == "postal" ) type |= Address::Postal;
549 else if ( tmpStr == "work" ) type |= Address::Work; 549 else if ( tmpStr == "work" ) type |= Address::Work;
550 else if ( tmpStr == "home" ) type |= Address::Home; 550 else if ( tmpStr == "home" ) type |= Address::Home;
551 else if ( tmpStr == "pref" ) type |= Address::Pref; 551 else if ( tmpStr == "pref" ) type |= Address::Pref;
552 } 552 }
553 } 553 }
554 return type; 554 return type;
555} 555}
556 556
557void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a ) 557void VCardFormatImpl::addNValue( VCard *vcard, const Addressee &a )
558{ 558{
559 ContentLine cl; 559 ContentLine cl;
560 cl.setName(EntityTypeToParamName( EntityN ) ); 560 cl.setName(EntityTypeToParamName( EntityN ) );
561 NValue *v = new NValue; 561 NValue *v = new NValue;
562 v->setFamily( a.familyName().utf8() ); 562 v->setFamily( a.familyName().utf8() );
563 v->setGiven( a.givenName().utf8() ); 563 v->setGiven( a.givenName().utf8() );
564 v->setMiddle( a.additionalName().utf8() ); 564 v->setMiddle( a.additionalName().utf8() );
565 v->setPrefix( a.prefix().utf8() ); 565 v->setPrefix( a.prefix().utf8() );
566 v->setSuffix( a.suffix().utf8() ); 566 v->setSuffix( a.suffix().utf8() );
567 567
568 cl.setValue( v ); 568 cl.setValue( v );
569 vcard->add(cl); 569 vcard->add(cl);
570} 570}
571 571
572void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a ) 572void VCardFormatImpl::readNValue( ContentLine *cl, Addressee &a )
573{ 573{
574 NValue *v = (NValue *)cl->value(); 574 NValue *v = (NValue *)cl->value();
575 a.setFamilyName( QString::fromUtf8( v->family() ) ); 575 a.setFamilyName( QString::fromUtf8( v->family() ) );
576 a.setGivenName( QString::fromUtf8( v->given() ) ); 576 a.setGivenName( QString::fromUtf8( v->given() ) );
577 a.setAdditionalName( QString::fromUtf8( v->middle() ) ); 577 a.setAdditionalName( QString::fromUtf8( v->middle() ) );
578 a.setPrefix( QString::fromUtf8( v->prefix() ) ); 578 a.setPrefix( QString::fromUtf8( v->prefix() ) );
579 a.setSuffix( QString::fromUtf8( v->suffix() ) ); 579 a.setSuffix( QString::fromUtf8( v->suffix() ) );
580} 580}
581 581
582void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p ) 582void VCardFormatImpl::addTelephoneValue( VCard *v, const PhoneNumber &p )
583{ 583{
584 if ( p.number().isEmpty() ) 584 if ( p.number().isEmpty() )
585 return; 585 return;
586 586
587 ContentLine cl; 587 ContentLine cl;
588 cl.setName(EntityTypeToParamName(EntityTelephone)); 588 cl.setName(EntityTypeToParamName(EntityTelephone));
589 cl.setValue(new TelValue( p.number().utf8() )); 589 cl.setValue(new TelValue( p.number().utf8() ));
590 590
591 ParamList params; 591 ParamList params;
592 if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) ); 592 if( p.type() & PhoneNumber::Home ) params.append( new Param( "TYPE", "home" ) );
593 if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) ); 593 if( p.type() & PhoneNumber::Work ) params.append( new Param( "TYPE", "work" ) );
594 if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) ); 594 if( p.type() & PhoneNumber::Msg ) params.append( new Param( "TYPE", "msg" ) );
595 if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) ); 595 if( p.type() & PhoneNumber::Pref ) params.append( new Param( "TYPE", "pref" ) );
596 if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) ); 596 if( p.type() & PhoneNumber::Voice ) params.append( new Param( "TYPE", "voice" ) );
597 if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) ); 597 if( p.type() & PhoneNumber::Fax ) params.append( new Param( "TYPE", "fax" ) );
598 if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) ); 598 if( p.type() & PhoneNumber::Cell ) params.append( new Param( "TYPE", "cell" ) );
599 if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) ); 599 if( p.type() & PhoneNumber::Video ) params.append( new Param( "TYPE", "video" ) );
600 if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) ); 600 if( p.type() & PhoneNumber::Bbs ) params.append( new Param( "TYPE", "bbs" ) );
601 if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) ); 601 if( p.type() & PhoneNumber::Modem ) params.append( new Param( "TYPE", "modem" ) );
602 if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) ); 602 if( p.type() & PhoneNumber::Car ) params.append( new Param( "TYPE", "car" ) );
603 if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) ); 603 if( p.type() & PhoneNumber::Isdn ) params.append( new Param( "TYPE", "isdn" ) );
604 if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) ); 604 if( p.type() & PhoneNumber::Pcs ) params.append( new Param( "TYPE", "pcs" ) );
605 if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) ); 605 if( p.type() & PhoneNumber::Pager ) params.append( new Param( "TYPE", "pager" ) );
606 if( p.type() & PhoneNumber::Sip ) params.append( new Param( "TYPE", "sip" ) ); 606 if( p.type() & PhoneNumber::Sip ) params.append( new Param( "TYPE", "sip" ) );
607 cl.setParamList( params ); 607 cl.setParamList( params );
608 608
609 v->add(cl); 609 v->add(cl);
610} 610}
611 611
612PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl ) 612PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl )
613{ 613{
614 PhoneNumber p; 614 PhoneNumber p;
615 TelValue *value = (TelValue *)cl->value(); 615 TelValue *value = (TelValue *)cl->value();
616 p.setNumber( QString::fromUtf8( value->asString() ) ); 616 p.setNumber( QString::fromUtf8( value->asString() ) );
617 617
618 int type = 0; 618 int type = 0;
619 ParamList params = cl->paramList(); 619 ParamList params = cl->paramList();
620 ParamListIterator it( params ); 620 ParamListIterator it( params );
621 QCString tmpStr; 621 QCString tmpStr;
622 for( ; it.current(); ++it ) { 622 for( ; it.current(); ++it ) {
623 if ( (*it)->name() == "TYPE" ) { 623 if ( (*it)->name() == "TYPE" ) {
624 tmpStr = (*it)->value().lower(); 624 tmpStr = (*it)->value().lower();
625 if ( tmpStr == "home" ) type |= PhoneNumber::Home; 625 if ( tmpStr == "home" ) type |= PhoneNumber::Home;
626 else if ( tmpStr == "work" ) type |= PhoneNumber::Work; 626 else if ( tmpStr == "work" ) type |= PhoneNumber::Work;
627 else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg; 627 else if ( tmpStr == "msg" ) type |= PhoneNumber::Msg;
628 else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref; 628 else if ( tmpStr == "pref" ) type |= PhoneNumber::Pref;
629 else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice; 629 else if ( tmpStr == "voice" ) type |= PhoneNumber::Voice;
630 else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax; 630 else if ( tmpStr == "fax" ) type |= PhoneNumber::Fax;
631 else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell; 631 else if ( tmpStr == "cell" ) type |= PhoneNumber::Cell;
632 else if ( tmpStr == "video" ) type |= PhoneNumber::Video; 632 else if ( tmpStr == "video" ) type |= PhoneNumber::Video;
633 else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs; 633 else if ( tmpStr == "bbs" ) type |= PhoneNumber::Bbs;
634 else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem; 634 else if ( tmpStr == "modem" ) type |= PhoneNumber::Modem;
635 else if ( tmpStr == "car" ) type |= PhoneNumber::Car; 635 else if ( tmpStr == "car" ) type |= PhoneNumber::Car;
636 else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn; 636 else if ( tmpStr == "isdn" ) type |= PhoneNumber::Isdn;
637 else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs; 637 else if ( tmpStr == "pcs" ) type |= PhoneNumber::Pcs;
638 else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager; 638 else if ( tmpStr == "pager" ) type |= PhoneNumber::Pager;
639 else if ( tmpStr == "sip" ) type |= PhoneNumber::Sip; 639 else if ( tmpStr == "sip" ) type |= PhoneNumber::Sip;
640 } 640 }
641 } 641 }
642 p.setType( type ); 642 p.setType( type );
643 643
644 return p; 644 return p;
645} 645}
646 646
647QString VCardFormatImpl::readTextValue( ContentLine *cl ) 647QString VCardFormatImpl::readTextValue( ContentLine *cl )
648{ 648{
649 VCARD::Value *value = cl->value(); 649 VCARD::Value *value = cl->value();
650 if ( value ) { 650 if ( value ) {
651 return QString::fromUtf8( value->asString() ); 651 return QString::fromUtf8( value->asString() );
652 } else { 652 } else {
653 kdDebug(5700) << "No value: " << cl->asString() << endl; 653 kdDebug(5700) << "No value: " << cl->asString() << endl;
654 qDebug("No value: %s", (const char*)(cl->asString())); 654 qDebug("No value: %s", (const char*)(cl->asString()));
655 return QString::null; 655 return QString::null;
656 } 656 }
657} 657}
658 658
659QDate VCardFormatImpl::readDateValue( ContentLine *cl ) 659QDate VCardFormatImpl::readDateValue( ContentLine *cl )
660{ 660{
661 DateValue *dateValue = (DateValue *)cl->value(); 661 DateValue *dateValue = (DateValue *)cl->value();
662 if ( dateValue ) 662 if ( dateValue )
663 return dateValue->qdate(); 663 return dateValue->qdate();
664 else 664 else
665 return QDate(); 665 return QDate();
666} 666}
667 667
668QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl ) 668QDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl )
669{ 669{
670 DateValue *dateValue = (DateValue *)cl->value(); 670 DateValue *dateValue = (DateValue *)cl->value();
671 if ( dateValue ) 671 if ( dateValue )
672 return dateValue->qdt(); 672 return dateValue->qdt();
673 else 673 else
674 return QDateTime(); 674 return QDateTime();
675} 675}
676 676
677Geo VCardFormatImpl::readGeoValue( ContentLine *cl ) 677Geo VCardFormatImpl::readGeoValue( ContentLine *cl )
678{ 678{
679 GeoValue *geoValue = (GeoValue *)cl->value(); 679 GeoValue *geoValue = (GeoValue *)cl->value();
680 if ( geoValue ) { 680 if ( geoValue ) {
681 Geo geo( geoValue->latitude(), geoValue->longitude() ); 681 Geo geo( geoValue->latitude(), geoValue->longitude() );
682 return geo; 682 return geo;
683 } else 683 } else
684 return Geo(); 684 return Geo();
685} 685}
686 686
687TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl ) 687TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl )
688{ 688{
689 UTCValue *utcValue = (UTCValue *)cl->value(); 689 UTCValue *utcValue = (UTCValue *)cl->value();
690 if ( utcValue ) { 690 if ( utcValue ) {
691 TimeZone tz; 691 TimeZone tz;
692 tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1)); 692 tz.setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1));
693 return tz; 693 return tz;
694 } else 694 } else
695 return TimeZone(); 695 return TimeZone();
696} 696}
697 697
698Secrecy VCardFormatImpl::readClassValue( ContentLine *cl ) 698Secrecy VCardFormatImpl::readClassValue( ContentLine *cl )
699{ 699{
700 ClassValue *classValue = (ClassValue *)cl->value(); 700 ClassValue *classValue = (ClassValue *)cl->value();
701 if ( classValue ) { 701 if ( classValue ) {
702 Secrecy secrecy; 702 Secrecy secrecy;
703 switch ( classValue->type() ) { 703 switch ( classValue->type() ) {
704 case ClassValue::Public: 704 case ClassValue::Public:
705 secrecy.setType( Secrecy::Public ); 705 secrecy.setType( Secrecy::Public );
706 break; 706 break;
707 case ClassValue::Private: 707 case ClassValue::Private:
708 secrecy.setType( Secrecy::Private ); 708 secrecy.setType( Secrecy::Private );
709 break; 709 break;
710 case ClassValue::Confidential: 710 case ClassValue::Confidential:
711 secrecy.setType( Secrecy::Confidential ); 711 secrecy.setType( Secrecy::Confidential );
712 break; 712 break;
713 } 713 }
714 714
715 return secrecy; 715 return secrecy;
716 } else 716 } else
717 return Secrecy(); 717 return Secrecy();
718} 718}
719 719
720void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard, const Key &key ) 720void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard, const Key &key )
721{ 721{
722 ContentLine cl; 722 ContentLine cl;
723 cl.setName( EntityTypeToParamName( EntityKey ) ); 723 cl.setName( EntityTypeToParamName( EntityKey ) );
724 724
725 ParamList params; 725 ParamList params;
726 if ( key.isBinary() ) { 726 if ( key.isBinary() ) {
727 cl.setValue( new TextValue( KCodecs::base64Encode( key.binaryData() ) ) ); 727 cl.setValue( new TextValue( KCodecs::base64Encode( key.binaryData() ) ) );
728 params.append( new Param( "ENCODING", "b" ) ); 728 params.append( new Param( "ENCODING", "b" ) );
729 } else { 729 } else {
730 cl.setValue( new TextValue( key.textData().utf8() ) ); 730 cl.setValue( new TextValue( key.textData().utf8() ) );
731 } 731 }
732 732
733 switch ( key.type() ) { 733 switch ( key.type() ) {
734 case Key::X509: 734 case Key::X509:
735 params.append( new Param( "TYPE", "X509" ) ); 735 params.append( new Param( "TYPE", "X509" ) );
736 break; 736 break;
737 case Key::PGP: 737 case Key::PGP:
738 params.append( new Param( "TYPE", "PGP" ) ); 738 params.append( new Param( "TYPE", "PGP" ) );
739 break; 739 break;
740 case Key::Custom: 740 case Key::Custom:
741 params.append( new Param( "TYPE", key.customTypeString().utf8() ) ); 741 params.append( new Param( "TYPE", key.customTypeString().utf8() ) );
742 break; 742 break;
743 } 743 }
744 744
745 cl.setParamList( params ); 745 cl.setParamList( params );
746 vcard->add( cl ); 746 vcard->add( cl );
747} 747}
748 748
749Key VCardFormatImpl::readKeyValue( VCARD::ContentLine *cl ) 749Key VCardFormatImpl::readKeyValue( VCARD::ContentLine *cl )
750{ 750{
751 Key key; 751 Key key;
752 bool isBinary = false; 752 bool isBinary = false;
753 TextValue *v = (TextValue *)cl->value(); 753 TextValue *v = (TextValue *)cl->value();
754 754
755 ParamList params = cl->paramList(); 755 ParamList params = cl->paramList();
756 ParamListIterator it( params ); 756 ParamListIterator it( params );
757 for( ; it.current(); ++it ) { 757 for( ; it.current(); ++it ) {
758 if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) 758 if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" )
759 isBinary = true; 759 isBinary = true;
760 if ( (*it)->name() == "TYPE" ) { 760 if ( (*it)->name() == "TYPE" ) {
761 if ( (*it)->value().isEmpty() ) 761 if ( (*it)->value().isEmpty() )
762 continue; 762 continue;
763 if ( (*it)->value() == "X509" ) 763 if ( (*it)->value() == "X509" )
764 key.setType( Key::X509 ); 764 key.setType( Key::X509 );
765 else if ( (*it)->value() == "PGP" ) 765 else if ( (*it)->value() == "PGP" )
766 key.setType( Key::PGP ); 766 key.setType( Key::PGP );
767 else { 767 else {
768 key.setType( Key::Custom ); 768 key.setType( Key::Custom );
769 key.setCustomTypeString( QString::fromUtf8( (*it)->value() ) ); 769 key.setCustomTypeString( QString::fromUtf8( (*it)->value() ) );
770 } 770 }
771 } 771 }
772 } 772 }
773 773
774 774
775 if ( isBinary ) { 775 if ( isBinary ) {
776 QByteArray data; 776 QByteArray data;
777 KCodecs::base64Decode( v->asString().stripWhiteSpace(), data ); 777 KCodecs::base64Decode( v->asString().stripWhiteSpace(), data );
778 key.setBinaryData( data ); 778 key.setBinaryData( data );
779 } else { 779 } else {
780 key.setTextData( QString::fromUtf8( v->asString() ) ); 780 key.setTextData( QString::fromUtf8( v->asString() ) );
781 } 781 }
782 782
783 return key; 783 return key;
784} 784}
785 785
786 786
787void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent ) 787void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent )
788{ 788{
789 if ( agent.isIntern() && !agent.addressee() ) 789 if ( agent.isIntern() && !agent.addressee() )
790 return; 790 return;
791 791
792 if ( !agent.isIntern() && agent.url().isEmpty() ) 792 if ( !agent.isIntern() && agent.url().isEmpty() )
793 return; 793 return;
794 794
795 ContentLine cl; 795 ContentLine cl;
796 cl.setName( EntityTypeToParamName( EntityAgent ) ); 796 cl.setName( EntityTypeToParamName( EntityAgent ) );
797 797
798 ParamList params; 798 ParamList params;
799 if ( agent.isIntern() ) { 799 if ( agent.isIntern() ) {
800 QString vstr; 800 QString vstr;
801 Addressee *addr = agent.addressee(); 801 Addressee *addr = agent.addressee();
802 if ( addr ) { 802 if ( addr ) {
803 writeToString( (*addr), vstr ); 803 writeToString( (*addr), vstr );
804 804
805 qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); 805 qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct");
806/*US 806/*US
807 vstr.replace( ":", "\\:" ); 807 vstr.replace( ":", "\\:" );
808 vstr.replace( ",", "\\," ); 808 vstr.replace( ",", "\\," );
809 vstr.replace( ";", "\\;" ); 809 vstr.replace( ";", "\\;" );
810 vstr.replace( "\r\n", "\\n" ); 810 vstr.replace( "\r\n", "\\n" );
811*/ 811*/
812 vstr.replace( QRegExp(":"), "\\:" ); 812 vstr.replace( QRegExp(":"), "\\:" );
813 vstr.replace( QRegExp(","), "\\," ); 813 vstr.replace( QRegExp(","), "\\," );
814 vstr.replace( QRegExp(";"), "\\;" ); 814 vstr.replace( QRegExp(";"), "\\;" );
815 vstr.replace( QRegExp("\r\n"), "\\n" ); 815 vstr.replace( QRegExp("\r\n"), "\\n" );
816 816
817 cl.setValue( new TextValue( vstr.utf8() ) ); 817 cl.setValue( new TextValue( vstr.utf8() ) );
818 } else 818 } else
819 return; 819 return;
820 } else { 820 } else {
821 cl.setValue( new TextValue( agent.url().utf8() ) ); 821 cl.setValue( new TextValue( agent.url().utf8() ) );
822 params.append( new Param( "VALUE", "uri" ) ); 822 params.append( new Param( "VALUE", "uri" ) );
823 } 823 }
824 824
825 cl.setParamList( params ); 825 cl.setParamList( params );
826 vcard->add( cl ); 826 vcard->add( cl );
827} 827}
828 828
829Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) 829Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl )
830{ 830{
831 Agent agent; 831 Agent agent;
832 bool isIntern = true; 832 bool isIntern = true;
833 TextValue *v = (TextValue *)cl->value(); 833 TextValue *v = (TextValue *)cl->value();
834 834
835 ParamList params = cl->paramList(); 835 ParamList params = cl->paramList();
836 ParamListIterator it( params ); 836 ParamListIterator it( params );
837 for( ; it.current(); ++it ) { 837 for( ; it.current(); ++it ) {
838 if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" ) 838 if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" )
839 isIntern = false; 839 isIntern = false;
840 } 840 }
841 841
842 if ( isIntern ) { 842 if ( isIntern ) {
843 QString vstr = QString::fromUtf8( v->asString() ); 843 QString vstr = QString::fromUtf8( v->asString() );
844 qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); 844 qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct");
845/*US 845/*US
846 vstr.replace( "\\n", "\r\n" ); 846 vstr.replace( "\\n", "\r\n" );
847 vstr.replace( "\\:", ":" ); 847 vstr.replace( "\\:", ":" );
848 vstr.replace( "\\,", "," ); 848 vstr.replace( "\\,", "," );
849 vstr.replace( "\\;", ";" ); 849 vstr.replace( "\\;", ";" );
850*/ 850*/
851 vstr.replace( QRegExp("\\\\n"), "\r\n" ); 851 vstr.replace( QRegExp("\\\\n"), "\r\n" );
852 vstr.replace( QRegExp("\\\\:"), ":" ); 852 vstr.replace( QRegExp("\\\\:"), ":" );
853 vstr.replace( QRegExp("\\\\,"), "," ); 853 vstr.replace( QRegExp("\\\\,"), "," );
854 vstr.replace( QRegExp("\\\\;"), ";" ); 854 vstr.replace( QRegExp("\\\\;"), ";" );
855 855
856 Addressee *addr = new Addressee; 856 Addressee *addr = new Addressee;
857 readFromString( vstr, *addr ); 857 readFromString( vstr, *addr );
858 agent.setAddressee( addr ); 858 agent.setAddressee( addr );
859 } else { 859 } else {
860 agent.setUrl( QString::fromUtf8( v->asString() ) ); 860 agent.setUrl( QString::fromUtf8( v->asString() ) );
861 } 861 }
862 862
863 return agent; 863 return agent;
864} 864}
865 865
866void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) 866void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern )
867{ 867{
868 ContentLine cl; 868 ContentLine cl;
869 cl.setName( EntityTypeToParamName( type ) ); 869 cl.setName( EntityTypeToParamName( type ) );
870 870
871 if ( pic.isIntern() && pic.data().isNull() ) 871 if ( pic.isIntern() && pic.data().isNull() )
872 return; 872 return;
873 873
874 if ( !pic.isIntern() && pic.url().isEmpty() ) 874 if ( !pic.isIntern() && pic.url().isEmpty() )
875 return; 875 return;
876 876
877 ParamList params; 877 ParamList params;
878 if ( pic.isIntern() ) { 878 if ( pic.isIntern() ) {
879 QImage img = pic.data(); 879 QImage img = pic.data();
880 if ( intern ) { // only for vCard export we really write the data inline 880 if ( intern ) { // only for vCard export we really write the data inline
881 QByteArray data; 881 QByteArray data;
882 QDataStream s( data, IO_WriteOnly ); 882 QDataStream s( data, IO_WriteOnly );
883 s.setVersion( 4 ); // to produce valid png files 883 s.setVersion( 4 ); // to produce valid png files
884 s << img; 884 s << img;
885 cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); 885 cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) );
886 886
887 } else { // save picture in cache 887 } else { // save picture in cache
888 QString dir; 888 QString dir;
889 if ( type == EntityPhoto ) 889 if ( type == EntityPhoto )
890 dir = "photos"; 890 dir = "photos";
891 if ( type == EntityLogo ) 891 if ( type == EntityLogo )
892 dir = "logos"; 892 dir = "logos";
893 893
894 img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() ); 894 img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() );
895 cl.setValue( new TextValue( "<dummy>" ) ); 895 cl.setValue( new TextValue( "<dummy>" ) );
896 } 896 }
897 params.append( new Param( "ENCODING", "b" ) ); 897 params.append( new Param( "ENCODING", "b" ) );
898 if ( !pic.type().isEmpty() ) 898 if ( !pic.type().isEmpty() )
899 params.append( new Param( "TYPE", pic.type().utf8() ) ); 899 params.append( new Param( "TYPE", pic.type().utf8() ) );
900 } else { 900 } else {
901 901
902 cl.setValue( new TextValue( pic.url().utf8() ) ); 902 cl.setValue( new TextValue( pic.url().utf8() ) );
903 params.append( new Param( "VALUE", "uri" ) ); 903 params.append( new Param( "VALUE", "uri" ) );
904 } 904 }
905 905
906 cl.setParamList( params ); 906 cl.setParamList( params );
907 vcard->add( cl ); 907 vcard->add( cl );
908} 908}
909 909
910Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type, const Addressee &addr ) 910Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type, const Addressee &addr )
911{ 911{
912 Picture pic; 912 Picture pic;
913 bool isInline = false; 913 bool isInline = false;
914 QString picType; 914 QString picType;
915 TextValue *v = (TextValue *)cl->value(); 915 TextValue *v = (TextValue *)cl->value();
916 916
917 ParamList params = cl->paramList(); 917 ParamList params = cl->paramList();
918 ParamListIterator it( params ); 918 ParamListIterator it( params );
919 for( ; it.current(); ++it ) { 919 for( ; it.current(); ++it ) {
920 if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) 920 if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" )
921 isInline = true; 921 isInline = true;
922 if ( (*it)->name() == "TYPE" && !(*it)->value().isEmpty() ) 922 if ( (*it)->name() == "TYPE" && !(*it)->value().isEmpty() )
923 picType = QString::fromUtf8( (*it)->value() ); 923 picType = QString::fromUtf8( (*it)->value() );
924 } 924 }
925 925
926 if ( isInline ) { 926 if ( isInline ) {
927 QImage img; 927 QImage img;
928 if ( v->asString() == "<dummy>" ) { // no picture inline stored => picture is in cache 928 if ( v->asString() == "<dummy>" ) { // no picture inline stored => picture is in cache
929 QString dir; 929 QString dir;
930 if ( type == EntityPhoto ) 930 if ( type == EntityPhoto )
931 dir = "photos"; 931 dir = "photos";
932 if ( type == EntityLogo ) 932 if ( type == EntityLogo )
933 dir = "logos"; 933 dir = "logos";
934 934
935 img.load( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ) ); 935 img.load( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ) );
936 } else { 936 } else {
937 QByteArray data; 937 QByteArray data;
938 KCodecs::base64Decode( v->asString(), data ); 938 KCodecs::base64Decode( v->asString(), data );
939 img.loadFromData( data ); 939 img.loadFromData( data );
940 } 940 }
941 pic.setData( img ); 941 pic.setData( img );
942 pic.setType( picType ); 942 pic.setType( picType );
943 } else { 943 } else {
944 pic.setUrl( QString::fromUtf8( v->asString() ) ); 944 pic.setUrl( QString::fromUtf8( v->asString() ) );
945 } 945 }
946 946
947 return pic; 947 return pic;
948} 948}
949 949
950void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard, const Sound &sound, const Addressee &addr, bool intern ) 950void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard, const Sound &sound, const Addressee &addr, bool intern )
951{ 951{
952 ContentLine cl; 952 ContentLine cl;
953 cl.setName( EntityTypeToParamName( EntitySound ) ); 953 cl.setName( EntityTypeToParamName( EntitySound ) );
954 954
955 if ( sound.isIntern() && sound.data().isNull() ) 955 if ( sound.isIntern() && sound.data().isNull() )
956 return; 956 return;
957 957
958 if ( !sound.isIntern() && sound.url().isEmpty() ) 958 if ( !sound.isIntern() && sound.url().isEmpty() )
959 return; 959 return;
960 960
961 ParamList params; 961 ParamList params;
962 if ( sound.isIntern() ) { 962 if ( sound.isIntern() ) {
963 QByteArray data = sound.data(); 963 QByteArray data = sound.data();
964 if ( intern ) { // only for vCard export we really write the data inline 964 if ( intern ) { // only for vCard export we really write the data inline
965 cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); 965 cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) );
966 } else { // save sound in cache 966 } else { // save sound in cache
967 QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); 967 QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) );
968 if ( file.open( IO_WriteOnly ) ) { 968 if ( file.open( IO_WriteOnly ) ) {
969 file.writeBlock( data ); 969 file.writeBlock( data );
970 } 970 }
971 cl.setValue( new TextValue( "<dummy>" ) ); 971 cl.setValue( new TextValue( "<dummy>" ) );
972 } 972 }
973 params.append( new Param( "ENCODING", "b" ) ); 973 params.append( new Param( "ENCODING", "b" ) );
974 } else { 974 } else {
975 cl.setValue( new TextValue( sound.url().utf8() ) ); 975 cl.setValue( new TextValue( sound.url().utf8() ) );
976 params.append( new Param( "VALUE", "uri" ) ); 976 params.append( new Param( "VALUE", "uri" ) );
977 } 977 }
978 978
979 cl.setParamList( params ); 979 cl.setParamList( params );
980 vcard->add( cl ); 980 vcard->add( cl );
981} 981}
982 982
983Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl, const Addressee &addr ) 983Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl, const Addressee &addr )
984{ 984{
985 Sound sound; 985 Sound sound;
986 bool isInline = false; 986 bool isInline = false;
987 TextValue *v = (TextValue *)cl->value(); 987 TextValue *v = (TextValue *)cl->value();
988 988
989 ParamList params = cl->paramList(); 989 ParamList params = cl->paramList();
990 ParamListIterator it( params ); 990 ParamListIterator it( params );
991 for( ; it.current(); ++it ) { 991 for( ; it.current(); ++it ) {
992 if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) 992 if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" )
993 isInline = true; 993 isInline = true;
994 } 994 }
995 995
996 if ( isInline ) { 996 if ( isInline ) {
997 QByteArray data; 997 QByteArray data;
998 if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache 998 if ( v->asString() == "<dummy>" ) { // no sound inline stored => sound is in cache
999 QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) ); 999 QFile file( locateLocal( "data", "kabc/sounds/" + addr.uid() ) );
1000 if ( file.open( IO_ReadOnly ) ) { 1000 if ( file.open( IO_ReadOnly ) ) {
1001 data = file.readAll(); 1001 data = file.readAll();
1002 file.close(); 1002 file.close();
1003 } 1003 }
1004 } else { 1004 } else {
1005 KCodecs::base64Decode( v->asString(), data ); 1005 KCodecs::base64Decode( v->asString(), data );
1006 } 1006 }
1007 sound.setData( data ); 1007 sound.setData( data );
1008 } else { 1008 } else {
1009 sound.setUrl( QString::fromUtf8( v->asString() ) ); 1009 sound.setUrl( QString::fromUtf8( v->asString() ) );
1010 } 1010 }
1011 1011
1012 return sound; 1012 return sound;
1013} 1013}
1014 1014
1015bool VCardFormatImpl::readFromString( const QString &vcard, Addressee &addressee ) 1015bool VCardFormatImpl::readFromString( const QString &vcard, Addressee &addressee )
1016{ 1016{
1017 VCardEntity e( vcard.utf8() ); 1017 VCardEntity e( vcard.utf8() );
1018 VCardListIterator it( e.cardList() ); 1018 VCardListIterator it( e.cardList() );
1019 1019
1020 if ( it.current() ) { 1020 if ( it.current() ) {
1021//US VCard v(*it.current()); 1021//US VCard v(*it.current());
1022//US loadAddressee( addressee, v ); 1022//US loadAddressee( addressee, v );
1023 loadAddressee( addressee, it.current() ); 1023 loadAddressee( addressee, it.current() );
1024 return true; 1024 return true;
1025 } 1025 }
1026 1026
1027 return false; 1027 return false;
1028} 1028}
1029 1029
1030bool VCardFormatImpl::writeToString( const Addressee &addressee, QString &vcard ) 1030bool VCardFormatImpl::writeToString( const Addressee &addressee, QString &vcard )
1031{ 1031{
1032 VCardEntity vcards; 1032 VCardEntity vcards;
1033 VCardList vcardlist; 1033 VCardList vcardlist;
1034 vcardlist.setAutoDelete( true ); 1034 vcardlist.setAutoDelete( true );
1035 1035
1036 VCard *v = new VCard; 1036 VCard *v = new VCard;
1037 1037
1038 saveAddressee( addressee, v, true ); 1038 saveAddressee( addressee, v, true );
1039 1039
1040 vcardlist.append( v ); 1040 vcardlist.append( v );
1041 vcards.setCardList( vcardlist ); 1041 vcards.setCardList( vcardlist );
1042 vcard = QString::fromUtf8( vcards.asString() ); 1042 vcard = QString::fromUtf8( vcards.asString() );
1043 1043
1044 return true; 1044 return true;
1045} 1045}