-rw-r--r-- | kabc/vcardformatimpl.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp index 26fd4f0..580c28b 100644 --- a/kabc/vcardformatimpl.cpp +++ b/kabc/vcardformatimpl.cpp | |||
@@ -850,17 +850,18 @@ Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) | |||
850 | agent.setUrl( QString::fromUtf8( v->asString() ) ); | 850 | agent.setUrl( QString::fromUtf8( v->asString() ) ); |
851 | } | 851 | } |
852 | 852 | ||
853 | return agent; | 853 | return agent; |
854 | } | 854 | } |
855 | 855 | ||
856 | #include <qstringlist.h> | ||
856 | void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) | 857 | void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) |
857 | { | 858 | { |
858 | ContentLine cl; | 859 | ContentLine cl; |
859 | cl.setName( EntityTypeToParamName( type ) ); | 860 | cl.setName( EntityTypeToParamName( type ) ); |
860 | 861 | // qDebug( "IIIMMMMM %s",QImage::outputFormatList ().join("-").latin1() ); | |
861 | if ( pic.isIntern() && pic.data().isNull() ) | 862 | if ( pic.isIntern() && pic.data().isNull() ) |
862 | return; | 863 | return; |
863 | 864 | ||
864 | if ( !pic.isIntern() && pic.url().isEmpty() ) | 865 | if ( !pic.isIntern() && pic.url().isEmpty() ) |
865 | return; | 866 | return; |
866 | 867 | ||
@@ -870,26 +871,29 @@ void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType ty | |||
870 | if ( intern ) { // only for vCard export we really write the data inline | 871 | if ( intern ) { // only for vCard export we really write the data inline |
871 | QByteArray data; | 872 | QByteArray data; |
872 | QDataStream s( data, IO_WriteOnly ); | 873 | QDataStream s( data, IO_WriteOnly ); |
873 | s.setVersion( 4 ); // to produce valid png files | 874 | s.setVersion( 4 ); // to produce valid png files |
874 | s << img; | 875 | s << img; |
875 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); | 876 | cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) ); |
876 | 877 | params.append( new Param( "ENCODING", "b" ) ); | |
878 | if ( !pic.type().isEmpty() ) | ||
879 | params.append( new Param( "TYPE", pic.type().utf8() ) ); | ||
877 | } else { // save picture in cache | 880 | } else { // save picture in cache |
878 | QString dir; | 881 | QString dir; |
879 | if ( type == EntityPhoto ) | 882 | if ( type == EntityPhoto ) |
880 | dir = "photos"; | 883 | dir = "photos"; |
881 | if ( type == EntityLogo ) | 884 | if ( type == EntityLogo ) |
882 | dir = "logos"; | 885 | dir = "logos"; |
883 | 886 | QString imUrl = locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ); | |
884 | img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() ); | 887 | KABC::Picture* ppic =(KABC::Picture*) &pic; |
885 | cl.setValue( new TextValue( "<dummy>" ) ); | 888 | ppic->setUrl( imUrl ); |
889 | img.save(imUrl, "PNG" ); | ||
890 | cl.setValue( new TextValue( pic.url().utf8() ) ); | ||
891 | params.append( new Param( "VALUE", "uri" ) ); | ||
886 | } | 892 | } |
887 | params.append( new Param( "ENCODING", "b" ) ); | 893 | |
888 | if ( !pic.type().isEmpty() ) | ||
889 | params.append( new Param( "TYPE", pic.type().utf8() ) ); | ||
890 | } else { | 894 | } else { |
891 | 895 | ||
892 | cl.setValue( new TextValue( pic.url().utf8() ) ); | 896 | cl.setValue( new TextValue( pic.url().utf8() ) ); |
893 | params.append( new Param( "VALUE", "uri" ) ); | 897 | params.append( new Param( "VALUE", "uri" ) ); |
894 | } | 898 | } |
895 | 899 | ||