25 #include <kstandarddirs.h>
26 #include <tdetempfile.h>
30 #include "addressbook.h"
31 #include "vcardformatimpl.h"
34 using namespace VCARD;
36 bool VCardFormatImpl::load(
Addressee &addressee, TQFile *file )
40 TQByteArray fdata = file->readAll();
41 TQCString data(fdata.data(), fdata.size()+1);
43 VCardEntity e( data );
45 VCardListIterator it( e.cardList() );
48 VCARD::VCard v(*it.current());
49 loadAddressee( addressee, v );
56 bool VCardFormatImpl::loadAll(
AddressBook *addressBook, Resource *resource, TQFile *file )
60 TQByteArray fdata = file->readAll();
61 TQCString data(fdata.data(), fdata.size()+1);
63 VCardEntity e( data );
65 VCardListIterator it( e.cardList() );
67 for (; it.current(); ++it) {
68 VCARD::VCard v(*it.current());
70 loadAddressee( addressee, v );
78 void VCardFormatImpl::save(
const Addressee &addressee, TQFile *file )
82 vcardlist.setAutoDelete(
true );
84 VCARD::VCard *v =
new VCARD::VCard;
86 saveAddressee( addressee, v,
false );
88 vcardlist.append( v );
89 vcards.setCardList( vcardlist );
91 TQCString vcardData = vcards.asString();
92 file->writeBlock( (
const char*)vcardData, vcardData.length() );
95 void VCardFormatImpl::saveAll(
AddressBook *ab, Resource *resource, TQFile *file )
99 vcardlist.setAutoDelete(
true );
102 for ( it = ab->
begin(); it != ab->
end(); ++it ) {
103 if ( (*it).resource() == resource ) {
104 VCARD::VCard *v =
new VCARD::VCard;
105 saveAddressee( (*it), v,
false );
106 (*it).setChanged(
false );
107 vcardlist.append( v );
111 vcards.setCardList( vcardlist );
113 TQCString vcardData = vcards.asString();
114 file->writeBlock( (
const char*)vcardData, vcardData.length() );
117 bool VCardFormatImpl::loadAddressee(
Addressee& addressee, VCARD::VCard &v )
119 TQPtrList<ContentLine> contentLines = v.contentLineList();
122 for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
123 TQCString n = cl->name();
124 if ( n.left( 2 ) ==
"X-" ) {
126 int posDash = n.find(
"-" );
127 addressee.
insertCustom( TQString::fromUtf8( n.left( posDash ) ),
128 TQString::fromUtf8( n.mid( posDash + 1 ) ),
129 TQString::fromUtf8( cl->value()->asString() ) );
133 EntityType type = cl->entityType();
137 addressee.
setUid( readTextValue( cl ) );
141 addressee.
setUri( readTextValue( cl ) );
149 addressee.setName( readTextValue( cl ) );
153 addressee.setFormattedName( readTextValue( cl ) );
157 addressee.setUrl(
KURL( readTextValue( cl ) ) );
161 addressee.setNickName( readTextValue( cl ) );
169 addressee.setMailer( readTextValue( cl ) );
173 addressee.setTitle( readTextValue( cl ) );
177 addressee.setRole( readTextValue( cl ) );
180 case EntityOrganisation:
181 addressee.setOrganization( readTextValue( cl ) );
185 addressee.setNote( readTextValue( cl ) );
188 case EntityProductID:
189 addressee.setProductId( readTextValue( cl ) );
192 case EntitySortString:
193 addressee.setSortString( readTextValue( cl ) );
197 readNValue( cl, addressee );
204 case EntityTelephone:
208 case EntityCategories:
209 addressee.
setCategories( TQStringList::split(
",", readTextValue( cl ) ) );
213 addressee.setBirthday( readDateValue( cl ) );
217 addressee.setRevision( readDateTimeValue( cl ) );
221 addressee.setGeo( readGeoValue( cl ) );
225 addressee.setTimeZone( readUTCValue( cl ) );
232 addressee.setSecrecy( readClassValue( cl ) );
236 addressee.
insertKey( readKeyValue( cl ) );
240 addressee.setPhoto( readPictureValue( cl, EntityPhoto, addressee ) );
244 addressee.setLogo( readPictureValue( cl, EntityLogo, addressee ) );
248 addressee.setAgent( readAgentValue( cl ) );
252 addressee.setSound( readSoundValue( cl, addressee ) );
256 kdDebug(5700) <<
"VCardFormat::load(): Unsupported entity: "
257 << int( type ) <<
": " << cl->asString() <<
endl;
262 for( cl = contentLines.first(); cl; cl = contentLines.next() ) {
263 EntityType type = cl->entityType();
264 if ( type == EntityLabel ) {
265 int type = readAddressParam( cl );
270 address.
setLabel( TQString::fromUtf8( cl->value()->asString() ) );
278 void VCardFormatImpl::saveAddressee(
const Addressee &addressee, VCARD::VCard *v,
bool intern )
283 addTextValue( v, EntityName, addressee.name() );
284 addTextValue( v, EntityUID, addressee.
uid() );
285 addTextValue( v, EntityURI, addressee.
uri() );
286 addTextValue( v, EntityFullName, addressee.formattedName() );
288 TQStringList emails = addressee.
emails();
289 TQStringList::ConstIterator it4;
290 for( it4 = emails.begin(); it4 != emails.end(); ++it4 ) {
291 addTextValue( v, EntityEmail, *it4 );
294 TQStringList customs = addressee.
customs();
295 TQStringList::ConstIterator it5;
296 for( it5 = customs.begin(); it5 != customs.end(); ++it5 ) {
297 addCustomValue( v, *it5 );
300 addTextValue( v, EntityURL, addressee.url().url() );
302 addNValue( v, addressee );
304 addTextValue( v, EntityNickname, addressee.nickName() );
305 addTextValue( v, EntityMailer, addressee.mailer() );
306 addTextValue( v, EntityTitle, addressee.title() );
307 addTextValue( v, EntityRole, addressee.role() );
308 addTextValue( v, EntityOrganisation, addressee.organization() );
309 addTextValue( v, EntityNote, addressee.note() );
310 addTextValue( v, EntityProductID, addressee.productId() );
311 addTextValue( v, EntitySortString, addressee.sortString() );
314 Address::List::ConstIterator it3;
315 for( it3 = addresses.begin(); it3 != addresses.end(); ++it3 ) {
316 addAddressValue( v, *it3 );
317 addLabelValue( v, *it3 );
320 PhoneNumber::List phoneNumbers = addressee.
phoneNumbers();
321 PhoneNumber::List::ConstIterator it2;
322 for( it2 = phoneNumbers.begin(); it2 != phoneNumbers.end(); ++it2 ) {
323 addTelephoneValue( v, *it2 );
326 Key::List keys = addressee.
keys();
327 Key::List::ConstIterator it6;
328 for( it6 = keys.begin(); it6 != keys.end(); ++it6 ) {
329 addKeyValue( v, *it6 );
332 addTextValue( v, EntityCategories, addressee.
categories().join(
",") );
334 addDateValue( v, EntityBirthday, TQT_TQDATE_OBJECT(addressee.birthday().date()) );
335 addDateTimeValue( v, EntityRevision, TQT_TQDATETIME_OBJECT(addressee.revision()) );
336 addGeoValue( v, addressee.geo() );
337 addUTCValue( v, addressee.timeZone() );
339 addClassValue( v, addressee.secrecy() );
341 addPictureValue( v, EntityPhoto, addressee.photo(), addressee, intern );
342 addPictureValue( v, EntityLogo, addressee.logo(), addressee, intern );
344 addAgentValue( v, addressee.agent() );
346 addSoundValue( v, addressee.sound(), addressee, intern );
349 void VCardFormatImpl::addCustomValue( VCARD::VCard *v,
const TQString &txt )
351 if ( txt.isEmpty() )
return;
354 cl.setName(
"X-" + txt.left( txt.find(
":" ) ).utf8() );
355 TQString value = txt.mid( txt.find(
":" ) + 1 );
356 if ( value.isEmpty() )
358 cl.setValue(
new TextValue( value.utf8() ) );
362 void VCardFormatImpl::addTextValue( VCARD::VCard *v, EntityType type,
const TQString &txt )
364 if ( txt.isEmpty() )
return;
367 cl.setName( EntityTypeToParamName( type ) );
368 cl.setValue(
new TextValue( txt.utf8() ) );
372 void VCardFormatImpl::addDateValue( VCARD::VCard *vcard, EntityType type,
375 if ( !date.isValid() )
return;
378 cl.setName( EntityTypeToParamName( type ) );
380 DateValue *v =
new DateValue( date );
385 void VCardFormatImpl::addDateTimeValue( VCARD::VCard *vcard, EntityType type,
386 const TQDateTime &dateTime )
388 if ( !dateTime.isValid() )
return;
391 cl.setName( EntityTypeToParamName( type ) );
393 DateValue *v =
new DateValue( dateTime );
398 void VCardFormatImpl::addAddressValue( VCARD::VCard *vcard,
const Address &a )
404 cl.setName( EntityTypeToParamName( EntityAddress ) );
406 AdrValue *v =
new AdrValue;
408 v->setExtAddress( a.
extended().utf8() );
409 v->setStreet( a.
street().utf8() );
410 v->setLocality( a.
locality().utf8() );
411 v->setRegion( a.
region().utf8() );
413 v->setCountryName( a.
country().utf8() );
416 addAddressParam( &cl, a.
type() );
421 void VCardFormatImpl::addLabelValue( VCARD::VCard *vcard,
const Address &a )
423 if ( a.
label().isEmpty() )
return;
426 cl.setName( EntityTypeToParamName( EntityLabel ) );
427 cl.setValue(
new TextValue( a.
label().utf8() ) );
429 addAddressParam( &cl, a.
type() );
434 void VCardFormatImpl::addAddressParam( ContentLine *cl,
int type )
437 if ( type & Address::Dom ) params.append(
new Param(
"TYPE",
"dom" ) );
438 if ( type & Address::Intl ) params.append(
new Param(
"TYPE",
"intl" ) );
439 if ( type & Address::Parcel ) params.append(
new Param(
"TYPE",
"parcel" ) );
440 if ( type & Address::Postal ) params.append(
new Param(
"TYPE",
"postal" ) );
441 if ( type & Address::Work ) params.append(
new Param(
"TYPE",
"work" ) );
442 if ( type & Address::Home ) params.append(
new Param(
"TYPE",
"home" ) );
443 if ( type & Address::Pref ) params.append(
new Param(
"TYPE",
"pref" ) );
444 cl->setParamList( params );
447 void VCardFormatImpl::addGeoValue( VCARD::VCard *vcard,
const Geo &geo )
452 cl.setName( EntityTypeToParamName( EntityGeo ) );
454 GeoValue *v =
new GeoValue;
462 void VCardFormatImpl::addUTCValue( VCARD::VCard *vcard,
const TimeZone &tz )
467 cl.setName( EntityTypeToParamName( EntityTimeZone ) );
469 UTCValue *v =
new UTCValue;
471 v->setPositive( tz.
offset() >= 0 );
472 v->setHour( (tz.
offset() / 60) * ( tz.
offset() >= 0 ? 1 : -1 ) );
473 v->setMinute( (tz.
offset() % 60) * ( tz.
offset() >= 0 ? 1 : -1 ) );
479 void VCardFormatImpl::addClassValue( VCARD::VCard *vcard,
const Secrecy &secrecy )
482 cl.setName( EntityTypeToParamName( EntityClass ) );
484 ClassValue *v =
new ClassValue;
485 switch ( secrecy.type() ) {
486 case Secrecy::Public:
487 v->setType( (
int)ClassValue::Public );
489 case Secrecy::Private:
490 v->setType( (
int)ClassValue::Private );
492 case Secrecy::Confidential:
493 v->setType( (
int)ClassValue::Confidential );
502 Address VCardFormatImpl::readAddressValue( ContentLine *cl )
505 AdrValue *v = (AdrValue *)cl->value();
507 a.
setExtended( TQString::fromUtf8( v->extAddress() ) );
508 a.
setStreet( TQString::fromUtf8( v->street() ) );
509 a.
setLocality( TQString::fromUtf8( v->locality() ) );
510 a.
setRegion( TQString::fromUtf8( v->region() ) );
512 a.
setCountry( TQString::fromUtf8( v->countryName() ) );
514 a.
setType( readAddressParam( cl ) );
519 int VCardFormatImpl::readAddressParam( ContentLine *cl )
522 ParamList params = cl->paramList();
523 ParamListIterator it( params );
524 for( ; it.current(); ++it ) {
525 if ( (*it)->name() ==
"TYPE" ) {
526 if ( (*it)->value() ==
"dom" ) type |= Address::Dom;
527 else if ( (*it)->value() ==
"intl" ) type |= Address::Intl;
528 else if ( (*it)->value() ==
"parcel" ) type |= Address::Parcel;
529 else if ( (*it)->value() ==
"postal" ) type |= Address::Postal;
530 else if ( (*it)->value() ==
"work" ) type |= Address::Work;
531 else if ( (*it)->value() ==
"home" ) type |= Address::Home;
532 else if ( (*it)->value() ==
"pref" ) type |= Address::Pref;
538 void VCardFormatImpl::addNValue( VCARD::VCard *vcard,
const Addressee &a )
541 cl.setName(EntityTypeToParamName( EntityN ) );
542 NValue *v =
new NValue;
543 v->setFamily( TQString(a.familyName()).utf8() );
544 v->setGiven( TQString(a.givenName()).utf8() );
545 v->setMiddle( TQString(a.additionalName()).utf8() );
546 v->setPrefix( TQString(a.prefix()).utf8() );
547 v->setSuffix( TQString(a.suffix()).utf8() );
553 void VCardFormatImpl::readNValue( ContentLine *cl,
Addressee &a )
555 NValue *v = (NValue *)cl->value();
556 a.setFamilyName( TQString::fromUtf8( v->family() ) );
557 a.setGivenName( TQString::fromUtf8( v->given() ) );
558 a.setAdditionalName( TQString::fromUtf8( v->middle() ) );
559 a.setPrefix( TQString::fromUtf8( v->prefix() ) );
560 a.setSuffix( TQString::fromUtf8( v->suffix() ) );
563 void VCardFormatImpl::addTelephoneValue( VCARD::VCard *v,
const PhoneNumber &p )
565 if ( p.
number().isEmpty() )
569 cl.setName(EntityTypeToParamName(EntityTelephone));
570 cl.setValue(
new TelValue( p.
number().utf8() ));
573 if( p.
type() & PhoneNumber::Home ) params.append(
new Param(
"TYPE",
"home" ) );
574 if( p.
type() & PhoneNumber::Work ) params.append(
new Param(
"TYPE",
"work" ) );
575 if( p.
type() & PhoneNumber::Msg ) params.append(
new Param(
"TYPE",
"msg" ) );
576 if( p.
type() & PhoneNumber::Pref ) params.append(
new Param(
"TYPE",
"pref" ) );
577 if( p.
type() & PhoneNumber::Voice ) params.append(
new Param(
"TYPE",
"voice" ) );
578 if( p.
type() & PhoneNumber::Fax ) params.append(
new Param(
"TYPE",
"fax" ) );
579 if( p.
type() & PhoneNumber::Cell ) params.append(
new Param(
"TYPE",
"cell" ) );
580 if( p.
type() & PhoneNumber::Video ) params.append(
new Param(
"TYPE",
"video" ) );
581 if( p.
type() & PhoneNumber::Bbs ) params.append(
new Param(
"TYPE",
"bbs" ) );
582 if( p.
type() & PhoneNumber::Modem ) params.append(
new Param(
"TYPE",
"modem" ) );
583 if( p.
type() & PhoneNumber::Car ) params.append(
new Param(
"TYPE",
"car" ) );
584 if( p.
type() & PhoneNumber::Isdn ) params.append(
new Param(
"TYPE",
"isdn" ) );
585 if( p.
type() & PhoneNumber::Pcs ) params.append(
new Param(
"TYPE",
"pcs" ) );
586 if( p.
type() & PhoneNumber::Pager ) params.append(
new Param(
"TYPE",
"pager" ) );
587 cl.setParamList( params );
592 PhoneNumber VCardFormatImpl::readTelephoneValue( ContentLine *cl )
595 TelValue *value = (TelValue *)cl->value();
596 p.
setNumber( TQString::fromUtf8( value->asString() ) );
599 ParamList params = cl->paramList();
600 ParamListIterator it( params );
601 for( ; it.current(); ++it ) {
602 if ( (*it)->name() ==
"TYPE" ) {
603 if ( (*it)->value() ==
"home" ) type |= PhoneNumber::Home;
604 else if ( (*it)->value() ==
"work" ) type |= PhoneNumber::Work;
605 else if ( (*it)->value() ==
"msg" ) type |= PhoneNumber::Msg;
606 else if ( (*it)->value() ==
"pref" ) type |= PhoneNumber::Pref;
607 else if ( (*it)->value() ==
"voice" ) type |= PhoneNumber::Voice;
608 else if ( (*it)->value() ==
"fax" ) type |= PhoneNumber::Fax;
609 else if ( (*it)->value() ==
"cell" ) type |= PhoneNumber::Cell;
610 else if ( (*it)->value() ==
"video" ) type |= PhoneNumber::Video;
611 else if ( (*it)->value() ==
"bbs" ) type |= PhoneNumber::Bbs;
612 else if ( (*it)->value() ==
"modem" ) type |= PhoneNumber::Modem;
613 else if ( (*it)->value() ==
"car" ) type |= PhoneNumber::Car;
614 else if ( (*it)->value() ==
"isdn" ) type |= PhoneNumber::Isdn;
615 else if ( (*it)->value() ==
"pcs" ) type |= PhoneNumber::Pcs;
616 else if ( (*it)->value() ==
"pager" ) type |= PhoneNumber::Pager;
624 TQString VCardFormatImpl::readTextValue( ContentLine *cl )
626 VCARD::Value *value = cl->value();
628 return TQString::fromUtf8( value->asString() );
630 kdDebug(5700) <<
"No value: " << cl->asString() <<
endl;
631 return TQString::null;
635 TQDate VCardFormatImpl::readDateValue( ContentLine *cl )
637 DateValue *dateValue = (DateValue *)cl->value();
639 return dateValue->qdate();
644 TQDateTime VCardFormatImpl::readDateTimeValue( ContentLine *cl )
646 DateValue *dateValue = (DateValue *)cl->value();
648 return dateValue->qdt();
653 Geo VCardFormatImpl::readGeoValue( ContentLine *cl )
655 GeoValue *geoValue = (GeoValue *)cl->value();
657 Geo geo( geoValue->latitude(), geoValue->longitude() );
663 TimeZone VCardFormatImpl::readUTCValue( ContentLine *cl )
665 UTCValue *utcValue = (UTCValue *)cl->value();
668 tz.
setOffset(((utcValue->hour()*60)+utcValue->minute())*(utcValue->positive() ? 1 : -1));
674 Secrecy VCardFormatImpl::readClassValue( ContentLine *cl )
676 ClassValue *classValue = (ClassValue *)cl->value();
679 switch ( classValue->type() ) {
680 case ClassValue::Public:
681 secrecy.setType( Secrecy::Public );
683 case ClassValue::Private:
684 secrecy.setType( Secrecy::Private );
686 case ClassValue::Confidential:
687 secrecy.setType( Secrecy::Confidential );
696 void VCardFormatImpl::addKeyValue( VCARD::VCard *vcard,
const Key &key )
699 cl.setName( EntityTypeToParamName( EntityKey ) );
702 if (
key.isBinary() ) {
704 params.append(
new Param(
"ENCODING",
"b" ) );
706 cl.setValue(
new TextValue(
key.textData().utf8() ) );
709 switch (
key.type() ) {
711 params.append(
new Param(
"TYPE",
"X509" ) );
714 params.append(
new Param(
"TYPE",
"PGP" ) );
717 params.append(
new Param(
"TYPE",
key.customTypeString().utf8() ) );
721 cl.setParamList( params );
725 Key VCardFormatImpl::readKeyValue( VCARD::ContentLine *cl )
728 bool isBinary =
false;
729 TextValue *v = (TextValue *)cl->value();
731 ParamList params = cl->paramList();
732 ParamListIterator it( params );
733 for( ; it.current(); ++it ) {
734 if ( (*it)->name() ==
"ENCODING" && (*it)->value() ==
"b" )
736 if ( (*it)->name() ==
"TYPE" ) {
737 if ( (*it)->value().isEmpty() )
739 if ( (*it)->value() ==
"X509" )
740 key.setType( Key::X509 );
741 else if ( (*it)->value() ==
"PGP" )
742 key.setType( Key::PGP );
744 key.setType( Key::Custom );
745 key.setCustomTypeString( TQString::fromUtf8( (*it)->value() ) );
754 key.setBinaryData( data );
756 key.setTextData( TQString::fromUtf8( v->asString() ) );
763 void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard,
const Agent &agent )
772 cl.setName( EntityTypeToParamName( EntityAgent ) );
779 writeToString( (*addr), vstr );
780 vstr.replace(
":",
"\\:" );
781 vstr.replace(
",",
"\\," );
782 vstr.replace(
";",
"\\;" );
783 vstr.replace(
"\r\n",
"\\n" );
784 cl.setValue(
new TextValue( vstr.utf8() ) );
788 cl.setValue(
new TextValue( agent.
url().utf8() ) );
789 params.append(
new Param(
"VALUE",
"uri" ) );
792 cl.setParamList( params );
796 Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl )
799 bool isIntern =
true;
800 TextValue *v = (TextValue *)cl->value();
802 ParamList params = cl->paramList();
803 ParamListIterator it( params );
804 for( ; it.current(); ++it ) {
805 if ( (*it)->name() ==
"VALUE" && (*it)->value() ==
"uri" )
810 TQString vstr = TQString::fromUtf8( v->asString() );
811 vstr.replace(
"\\n",
"\r\n" );
812 vstr.replace(
"\\:",
":" );
813 vstr.replace(
"\\,",
"," );
814 vstr.replace(
"\\;",
";" );
816 readFromString( vstr, *addr );
819 agent.
setUrl( TQString::fromUtf8( v->asString() ) );
825 void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type,
const Picture &pic,
const Addressee &addr,
bool intern )
828 cl.setName( EntityTypeToParamName( type ) );
830 if ( pic.isIntern() && pic.data().isNull() )
833 if ( !pic.isIntern() && pic.url().isEmpty() )
837 if ( pic.isIntern() ) {
838 TQImage img = pic.data();
841 TQDataStream s( data, IO_WriteOnly );
847 if ( type == EntityPhoto )
849 if ( type == EntityLogo )
852 img.save(
locateLocal(
"data",
"tdeabc/" + dir +
"/" + addr.
uid() ), pic.type().utf8() );
853 cl.setValue(
new TextValue(
"<dummy>" ) );
855 params.append(
new Param(
"ENCODING",
"b" ) );
856 if ( !pic.type().isEmpty() )
857 params.append(
new Param(
"TYPE", pic.type().utf8() ) );
859 cl.setValue(
new TextValue( pic.url().utf8() ) );
860 params.append(
new Param(
"VALUE",
"uri" ) );
863 cl.setParamList( params );
867 Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type,
const Addressee &addr )
870 bool isInline =
false;
872 TextValue *v = (TextValue *)cl->value();
874 ParamList params = cl->paramList();
875 ParamListIterator it( params );
876 for( ; it.current(); ++it ) {
877 if ( (*it)->name() ==
"ENCODING" && (*it)->value() ==
"b" )
879 if ( (*it)->name() ==
"TYPE" && !(*it)->value().isEmpty() )
880 picType = TQString::fromUtf8( (*it)->value() );
885 if ( v->asString() ==
"<dummy>" ) {
887 if ( type == EntityPhoto )
889 if ( type == EntityLogo )
892 img.load(
locateLocal(
"data",
"tdeabc/" + dir +
"/" + addr.
uid() ) );
896 img.loadFromData( data );
899 pic.setType( picType );
901 pic.setUrl( TQString::fromUtf8( v->asString() ) );
907 void VCardFormatImpl::addSoundValue( VCARD::VCard *vcard,
const Sound &sound,
const Addressee &addr,
bool intern )
910 cl.setName( EntityTypeToParamName( EntitySound ) );
920 TQByteArray data = sound.
data();
924 TQFile file(
locateLocal(
"data",
"tdeabc/sounds/" + addr.
uid() ) );
925 if ( file.open( IO_WriteOnly ) ) {
926 file.writeBlock( data );
928 cl.setValue(
new TextValue(
"<dummy>" ) );
930 params.append(
new Param(
"ENCODING",
"b" ) );
932 cl.setValue(
new TextValue( sound.
url().utf8() ) );
933 params.append(
new Param(
"VALUE",
"uri" ) );
936 cl.setParamList( params );
940 Sound VCardFormatImpl::readSoundValue( VCARD::ContentLine *cl,
const Addressee &addr )
943 bool isInline =
false;
944 TextValue *v = (TextValue *)cl->value();
946 ParamList params = cl->paramList();
947 ParamListIterator it( params );
948 for( ; it.current(); ++it ) {
949 if ( (*it)->name() ==
"ENCODING" && (*it)->value() ==
"b" )
955 if ( v->asString() ==
"<dummy>" ) {
956 TQFile file(
locateLocal(
"data",
"tdeabc/sounds/" + addr.
uid() ) );
957 if ( file.open( IO_ReadOnly ) ) {
958 data = file.readAll();
966 sound.
setUrl( TQString::fromUtf8( v->asString() ) );
972 bool VCardFormatImpl::readFromString(
const TQString &vcard,
Addressee &addressee )
974 VCardEntity e( vcard.utf8() );
975 VCardListIterator it( e.cardList() );
977 if ( it.current() ) {
978 VCARD::VCard v(*it.current());
979 loadAddressee( addressee, v );
986 bool VCardFormatImpl::writeToString(
const Addressee &addressee, TQString &vcard )
990 vcardlist.setAutoDelete(
true );
992 VCARD::VCard *v =
new VCARD::VCard;
994 saveAddressee( addressee, v,
true );
996 vcardlist.append( v );
997 vcards.setCardList( vcardlist );
998 vcard = TQString::fromUtf8( vcards.asString() );