summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/VCardEntity.cpp9
-rw-r--r--kabc/vcardformatimpl.cpp4
2 files changed, 10 insertions, 3 deletions
diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp
index 0cd2086..5fca3bc 100644
--- a/kabc/vcard/VCardEntity.cpp
+++ b/kabc/vcard/VCardEntity.cpp
@@ -24,99 +24,106 @@
24#include <qregexp.h> 24#include <qregexp.h>
25 25
26#include <VCardDefines.h> 26#include <VCardDefines.h>
27#include <VCardVCardEntity.h> 27#include <VCardVCardEntity.h>
28 28
29using namespace VCARD; 29using namespace VCARD;
30 30
31VCardEntity::VCardEntity() 31VCardEntity::VCardEntity()
32 :Entity() 32 :Entity()
33{ 33{
34 cardList_.setAutoDelete( TRUE ); 34 cardList_.setAutoDelete( TRUE );
35} 35}
36 36
37VCardEntity::VCardEntity(const VCardEntity & x) 37VCardEntity::VCardEntity(const VCardEntity & x)
38 :Entity(x) 38 :Entity(x)
39{ 39{
40 cardList_.setAutoDelete( TRUE ); 40 cardList_.setAutoDelete( TRUE );
41} 41}
42 42
43VCardEntity::VCardEntity(const QCString & s) 43VCardEntity::VCardEntity(const QCString & s)
44 :Entity(s) 44 :Entity(s)
45{ 45{
46 cardList_.setAutoDelete( TRUE ); 46 cardList_.setAutoDelete( TRUE );
47} 47}
48 48
49 VCardEntity & 49 VCardEntity &
50VCardEntity::operator = (VCardEntity & x) 50VCardEntity::operator = (VCardEntity & x)
51{ 51{
52 if (*this == x) return *this; 52 if (*this == x) return *this;
53 53
54 Entity::operator = (x); 54 Entity::operator = (x);
55 return *this; 55 return *this;
56} 56}
57 57
58 VCardEntity & 58 VCardEntity &
59VCardEntity::operator = (const QCString & s) 59VCardEntity::operator = (const QCString & s)
60{ 60{
61 Entity::operator = (s); 61 Entity::operator = (s);
62 return *this; 62 return *this;
63} 63}
64 64
65 bool 65 bool
66VCardEntity::operator == (VCardEntity & x) 66VCardEntity::operator == (VCardEntity & x)
67{ 67{
68 x.parse(); 68 x.parse();
69 return false; 69 return false;
70} 70}
71 71
72VCardEntity::~VCardEntity() 72VCardEntity::~VCardEntity()
73{ 73{
74} 74}
75 75
76 void 76 void
77VCardEntity::_parse() 77VCardEntity::_parse()
78{ 78{
79 vDebug("parse"); 79 vDebug("parse");
80 QCString s(strRep_); 80 QCString s(strRep_);
81 81
82 int i = s.find(QRegExp("BEGIN:VCARD", false)); 82 int i = s.find(QRegExp("BEGIN:VCARD", false));
83 83
84 while (i != -1) { 84 while (i != -1) {
85 85
86 i = s.find(QRegExp("BEGIN:VCARD", false), 11); 86 i = s.find(QRegExp("BEGIN:VCARD", false), 11);
87 87
88 QCString cardStr(s.left(i)); 88 QCString cardStr(s.left(i));
89 89
90 VCard * v = new VCard(cardStr); 90 VCard * v = new VCard(cardStr);
91 91
92 cardList_.append(v); 92 cardList_.append(v);
93 93
94 v->parse(); 94 v->parse();
95 95
96 s.remove(0, i); 96 s.remove(0, i);
97 } 97 }
98} 98}
99 99
100 void 100 void
101VCardEntity::_assemble() 101VCardEntity::_assemble()
102{ 102{
103 VCardListIterator it(cardList_); 103 VCardListIterator it(cardList_);
104 104
105 for (; it.current(); ++it) 105 for (; it.current(); ++it)
106 strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. 106 strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck.
107} 107}
108 108
109 VCardList & 109 VCardList &
110VCardEntity::cardList() 110VCardEntity::cardList()
111{ 111{
112 parse(); 112 parse();
113 return cardList_; 113 return cardList_;
114} 114}
115 115
116 void 116 void
117VCardEntity::setCardList(const VCardList & l) 117VCardEntity::setCardList(const VCardList & l)
118{ 118{
119 parse(); 119 parse();
120 cardList_ = l; 120 //UScardList_ = l;
121 VCardListIterator it(l);
122
123 for (; it.current(); ++it) {
124 VCard* v = new VCard(*it.current());
125 cardList_.append(v);
126 }
127
121} 128}
122 129
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp
index bd9a57b..bffaa64 100644
--- a/kabc/vcardformatimpl.cpp
+++ b/kabc/vcardformatimpl.cpp
@@ -190,194 +190,194 @@ bool VCardFormatImpl::loadAddressee( Addressee& addressee, VCard *v )
190 case EntityNote: 190 case EntityNote:
191 addressee.setNote( readTextValue( cl ) ); 191 addressee.setNote( readTextValue( cl ) );
192 break; 192 break;
193 193
194 case EntityProductID: 194 case EntityProductID:
195 addressee.setProductId( readTextValue( cl ) ); 195 addressee.setProductId( readTextValue( cl ) );
196 break; 196 break;
197 197
198 case EntitySortString: 198 case EntitySortString:
199 addressee.setSortString( readTextValue( cl ) ); 199 addressee.setSortString( readTextValue( cl ) );
200 break; 200 break;
201 201
202 case EntityN: 202 case EntityN:
203 readNValue( cl, addressee ); 203 readNValue( cl, addressee );
204 break; 204 break;
205 205
206 case EntityAddress: 206 case EntityAddress:
207 addressee.insertAddress( readAddressValue( cl ) ); 207 addressee.insertAddress( readAddressValue( cl ) );
208 break; 208 break;
209 209
210 case EntityTelephone: 210 case EntityTelephone:
211 addressee.insertPhoneNumber( readTelephoneValue( cl ) ); 211 addressee.insertPhoneNumber( readTelephoneValue( cl ) );
212 break; 212 break;
213 213
214 case EntityCategories: 214 case EntityCategories:
215 addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) ); 215 addressee.setCategories( QStringList::split( ",", readTextValue( cl ) ) );
216 break; 216 break;
217 217
218 case EntityBirthday: 218 case EntityBirthday:
219 addressee.setBirthday( readDateValue( cl ) ); 219 addressee.setBirthday( readDateValue( cl ) );
220 break; 220 break;
221 221
222 case EntityRevision: 222 case EntityRevision:
223 addressee.setRevision( readDateTimeValue( cl ) ); 223 addressee.setRevision( readDateTimeValue( cl ) );
224 break; 224 break;
225 225
226 case EntityGeo: 226 case EntityGeo:
227 addressee.setGeo( readGeoValue( cl ) ); 227 addressee.setGeo( readGeoValue( cl ) );
228 break; 228 break;
229 229
230 case EntityTimeZone: 230 case EntityTimeZone:
231 addressee.setTimeZone( readUTCValue( cl ) ); 231 addressee.setTimeZone( readUTCValue( cl ) );
232 break; 232 break;
233 233
234 case EntityVersion: 234 case EntityVersion:
235 break; 235 break;
236 236
237 case EntityClass: 237 case EntityClass:
238 addressee.setSecrecy( readClassValue( cl ) ); 238 addressee.setSecrecy( readClassValue( cl ) );
239 break; 239 break;
240 240
241 case EntityKey: 241 case EntityKey:
242 addressee.insertKey( readKeyValue( cl ) ); 242 addressee.insertKey( readKeyValue( cl ) );
243 break; 243 break;
244 244
245 case EntityPhoto: 245 case EntityPhoto:
246 addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) ); 246 addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) );
247 break; 247 break;
248 248
249 case EntityLogo: 249 case EntityLogo:
250 addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) ); 250 addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) );
251 break; 251 break;
252 252
253 case EntityAgent: 253 case EntityAgent:
254 addressee.setAgent( readAgentValue( cl ) ); 254 addressee.setAgent( readAgentValue( cl ) );
255 break; 255 break;
256 256
257 case EntitySound: 257 case EntitySound:
258 addressee.setSound( readSoundValue( cl, addressee ) ); 258 addressee.setSound( readSoundValue( cl, addressee ) );
259 break; 259 break;
260 260
261 default: 261 default:
262 kdDebug(5700) << "VCardFormat::load(): Unsupported entity: " 262 kdDebug(5700) << "VCardFormat::load(): Unsupported entity: "
263 << int( type ) << ": " << cl->asString() << endl; 263 << int( type ) << ": " << cl->asString() << endl;
264 break; 264 break;
265 } 265 }
266 } 266 }
267 267
268 for( cl = contentLines.first(); cl; cl = contentLines.next() ) { 268 for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
269 EntityType type = cl->entityType(); 269 EntityType type = cl->entityType();
270 if ( type == EntityLabel ) { 270 if ( type == EntityLabel ) {
271 int type = readAddressParam( cl ); 271 int type = readAddressParam( cl );
272 Address address = addressee.address( type ); 272 Address address = addressee.address( type );
273 if ( address.isEmpty() ) 273 if ( address.isEmpty() )
274 address.setType( type ); 274 address.setType( type );
275 275
276 address.setLabel( QString::fromUtf8( cl->value()->asString() ) ); 276 address.setLabel( QString::fromUtf8( cl->value()->asString() ) );
277 addressee.insertAddress( address ); 277 addressee.insertAddress( address );
278 } 278 }
279 } 279 }
280 280
281 return true; 281 return true;
282} 282}
283 283
284void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern ) 284void VCardFormatImpl::saveAddressee( const Addressee &addressee, VCard *v, bool intern )
285{ 285{
286 ContentLine cl; 286//US ContentLine cl;
287 QString value; 287//US QString value;
288 288
289 addTextValue( v, EntityName, addressee.name() ); 289 addTextValue( v, EntityName, addressee.name() );
290 addTextValue( v, EntityUID, addressee.uid() ); 290 addTextValue( v, EntityUID, addressee.uid() );
291 addTextValue( v, EntityFullName, addressee.formattedName() ); 291 addTextValue( v, EntityFullName, addressee.formattedName() );
292 292
293 QStringList emails = addressee.emails(); 293 QStringList emails = addressee.emails();
294 QStringList::ConstIterator it4; 294 QStringList::ConstIterator it4;
295 for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) { 295 for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) {
296 addTextValue( v, EntityEmail, *it4 ); 296 addTextValue( v, EntityEmail, *it4 );
297 } 297 }
298 298
299 QStringList customs = addressee.customs(); 299 QStringList customs = addressee.customs();
300 QStringList::ConstIterator it5; 300 QStringList::ConstIterator it5;
301 for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) { 301 for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) {
302 addCustomValue( v, *it5 ); 302 addCustomValue( v, *it5 );
303 } 303 }
304 304
305 addTextValue( v, EntityURL, addressee.url().url() ); 305 addTextValue( v, EntityURL, addressee.url().url() );
306 306
307 addNValue( v, addressee ); 307 addNValue( v, addressee );
308 308
309 addTextValue( v, EntityNickname, addressee.nickName() ); 309 addTextValue( v, EntityNickname, addressee.nickName() );
310 addTextValue( v, EntityMailer, addressee.mailer() ); 310 addTextValue( v, EntityMailer, addressee.mailer() );
311 addTextValue( v, EntityTitle, addressee.title() ); 311 addTextValue( v, EntityTitle, addressee.title() );
312 addTextValue( v, EntityRole, addressee.role() ); 312 addTextValue( v, EntityRole, addressee.role() );
313 addTextValue( v, EntityOrganisation, addressee.organization() ); 313 addTextValue( v, EntityOrganisation, addressee.organization() );
314 addTextValue( v, EntityNote, addressee.note() ); 314 addTextValue( v, EntityNote, addressee.note() );
315 addTextValue( v, EntityProductID, addressee.productId() ); 315 addTextValue( v, EntityProductID, addressee.productId() );
316 addTextValue( v, EntitySortString, addressee.sortString() ); 316 addTextValue( v, EntitySortString, addressee.sortString() );
317 317
318 Address::List addresses = addressee.addresses(); 318 Address::List addresses = addressee.addresses();
319 Address::List::ConstIterator it3; 319 Address::List::ConstIterator it3;
320 for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) { 320 for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) {
321 addAddressValue( v, *it3 ); 321 addAddressValue( v, *it3 );
322 addLabelValue( v, *it3 ); 322 addLabelValue( v, *it3 );
323 } 323 }
324 324
325 PhoneNumber::List phoneNumbers = addressee.phoneNumbers(); 325 PhoneNumber::List phoneNumbers = addressee.phoneNumbers();
326 PhoneNumber::List::ConstIterator it2; 326 PhoneNumber::List::ConstIterator it2;
327 for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) { 327 for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) {
328 addTelephoneValue( v, *it2 ); 328 addTelephoneValue( v, *it2 );
329 } 329 }
330 330
331 Key::List keys = addressee.keys(); 331 Key::List keys = addressee.keys();
332 Key::List::ConstIterator it6; 332 Key::List::ConstIterator it6;
333 for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) { 333 for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) {
334 addKeyValue( v, *it6 ); 334 addKeyValue( v, *it6 );
335 } 335 }
336 336
337 addTextValue( v, EntityCategories, addressee.categories().join(",") ); 337 addTextValue( v, EntityCategories, addressee.categories().join(",") );
338 338
339 addDateValue( v, EntityBirthday, addressee.birthday().date() ); 339 addDateValue( v, EntityBirthday, addressee.birthday().date() );
340 addDateTimeValue( v, EntityRevision, addressee.revision() ); 340 addDateTimeValue( v, EntityRevision, addressee.revision() );
341 addGeoValue( v, addressee.geo() ); 341 addGeoValue( v, addressee.geo() );
342 addUTCValue( v, addressee.timeZone() ); 342 addUTCValue( v, addressee.timeZone() );
343 343
344 addClassValue( v, addressee.secrecy() ); 344 addClassValue( v, addressee.secrecy() );
345 345
346 addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern ); 346 addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern );
347 addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern ); 347 addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern );
348 348
349 addAgentValue( v, addressee.agent() ); 349 addAgentValue( v, addressee.agent() );
350 350
351 addSoundValue( v, addressee.sound(), addressee, intern ); 351 addSoundValue( v, addressee.sound(), addressee, intern );
352} 352}
353 353
354void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt ) 354void VCardFormatImpl::addCustomValue( VCard *v, const QString &txt )
355{ 355{
356 if ( txt.isEmpty() ) return; 356 if ( txt.isEmpty() ) return;
357 357
358 ContentLine cl; 358 ContentLine cl;
359 cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() ); 359 cl.setName( "X-" + txt.left( txt.find( ":" ) ).utf8() );
360 QString value = txt.mid( txt.find( ":" ) + 1 ); 360 QString value = txt.mid( txt.find( ":" ) + 1 );
361 if ( value.isEmpty() ) 361 if ( value.isEmpty() )
362 return; 362 return;
363 cl.setValue( new TextValue( value.utf8() ) ); 363 cl.setValue( new TextValue( value.utf8() ) );
364 v->add(cl); 364 v->add(cl);
365} 365}
366 366
367void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt ) 367void VCardFormatImpl::addTextValue( VCard *v, EntityType type, const QString &txt )
368{ 368{
369 if ( txt.isEmpty() ) return; 369 if ( txt.isEmpty() ) return;
370 370
371 ContentLine cl; 371 ContentLine cl;
372 cl.setName( EntityTypeToParamName( type ) ); 372 cl.setName( EntityTypeToParamName( type ) );
373 cl.setValue( new TextValue( txt.utf8() ) ); 373 cl.setValue( new TextValue( txt.utf8() ) );
374 v->add(cl); 374 v->add(cl);
375} 375}
376 376
377void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type, 377void VCardFormatImpl::addDateValue( VCard *vcard, EntityType type,
378 const QDate &date ) 378 const QDate &date )
379{ 379{
380 if ( !date.isValid() ) return; 380 if ( !date.isValid() ) return;
381 381
382 ContentLine cl; 382 ContentLine cl;
383 cl.setName( EntityTypeToParamName( type ) ); 383 cl.setName( EntityTypeToParamName( type ) );