summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2005-11-12 23:42:08 (UTC)
committer zautrix <zautrix>2005-11-12 23:42:08 (UTC)
commit4145dc4a513d5899d8a2b9e4573d8140d871b386 (patch) (unidiff)
tree11bb2010757a65d90c2ed7e4d40d4e72d218eeb9 /kabc
parent9e47202fd38512cc523c09cf8878f4c5d836e777 (diff)
downloadkdepimpi-4145dc4a513d5899d8a2b9e4573d8140d871b386.zip
kdepimpi-4145dc4a513d5899d8a2b9e4573d8140d871b386.tar.gz
kdepimpi-4145dc4a513d5899d8a2b9e4573d8140d871b386.tar.bz2
fix
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardformatimpl.cpp20
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
@@ -808,130 +808,134 @@ void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent )
808 } else 808 } else
809 return; 809 return;
810 } else { 810 } else {
811 cl.setValue( new TextValue( agent.url().utf8() ) ); 811 cl.setValue( new TextValue( agent.url().utf8() ) );
812 params.append( new Param( "VALUE", "uri" ) ); 812 params.append( new Param( "VALUE", "uri" ) );
813 } 813 }
814 814
815 cl.setParamList( params ); 815 cl.setParamList( params );
816 vcard->add( cl ); 816 vcard->add( cl );
817} 817}
818 818
819Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl ) 819Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl )
820{ 820{
821 Agent agent; 821 Agent agent;
822 bool isIntern = true; 822 bool isIntern = true;
823 TextValue *v = (TextValue *)cl->value(); 823 TextValue *v = (TextValue *)cl->value();
824 824
825 ParamList params = cl->paramList(); 825 ParamList params = cl->paramList();
826 ParamListIterator it( params ); 826 ParamListIterator it( params );
827 for( ; it.current(); ++it ) { 827 for( ; it.current(); ++it ) {
828 if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" ) 828 if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" )
829 isIntern = false; 829 isIntern = false;
830 } 830 }
831 831
832 if ( isIntern ) { 832 if ( isIntern ) {
833 QString vstr = QString::fromUtf8( v->asString() ); 833 QString vstr = QString::fromUtf8( v->asString() );
834 qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct"); 834 qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct");
835/*US 835/*US
836 vstr.replace( "\\n", "\r\n" ); 836 vstr.replace( "\\n", "\r\n" );
837 vstr.replace( "\\:", ":" ); 837 vstr.replace( "\\:", ":" );
838 vstr.replace( "\\,", "," ); 838 vstr.replace( "\\,", "," );
839 vstr.replace( "\\;", ";" ); 839 vstr.replace( "\\;", ";" );
840*/ 840*/
841 vstr.replace( QRegExp("\\\\n"), "\r\n" ); 841 vstr.replace( QRegExp("\\\\n"), "\r\n" );
842 vstr.replace( QRegExp("\\\\:"), ":" ); 842 vstr.replace( QRegExp("\\\\:"), ":" );
843 vstr.replace( QRegExp("\\\\,"), "," ); 843 vstr.replace( QRegExp("\\\\,"), "," );
844 vstr.replace( QRegExp("\\\\;"), ";" ); 844 vstr.replace( QRegExp("\\\\;"), ";" );
845 845
846 Addressee *addr = new Addressee; 846 Addressee *addr = new Addressee;
847 readFromString( vstr, *addr ); 847 readFromString( vstr, *addr );
848 agent.setAddressee( addr ); 848 agent.setAddressee( addr );
849 } else { 849 } else {
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>
856void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern ) 857void 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
867 ParamList params; 868 ParamList params;
868 if ( pic.isIntern() ) { 869 if ( pic.isIntern() ) {
869 QImage img = pic.data(); 870 QImage img = pic.data();
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
896 cl.setParamList( params ); 900 cl.setParamList( params );
897 vcard->add( cl ); 901 vcard->add( cl );
898} 902}
899 903
900Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type, const Addressee &addr ) 904Picture VCardFormatImpl::readPictureValue( VCARD::ContentLine *cl, VCARD::EntityType type, const Addressee &addr )
901{ 905{
902 Picture pic; 906 Picture pic;
903 bool isInline = false; 907 bool isInline = false;
904 QString picType; 908 QString picType;
905 TextValue *v = (TextValue *)cl->value(); 909 TextValue *v = (TextValue *)cl->value();
906 910
907 ParamList params = cl->paramList(); 911 ParamList params = cl->paramList();
908 ParamListIterator it( params ); 912 ParamListIterator it( params );
909 for( ; it.current(); ++it ) { 913 for( ; it.current(); ++it ) {
910 if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" ) 914 if ( (*it)->name() == "ENCODING" && (*it)->value() == "b" )
911 isInline = true; 915 isInline = true;
912 if ( (*it)->name() == "TYPE" && !(*it)->value().isEmpty() ) 916 if ( (*it)->name() == "TYPE" && !(*it)->value().isEmpty() )
913 picType = QString::fromUtf8( (*it)->value() ); 917 picType = QString::fromUtf8( (*it)->value() );
914 } 918 }
915 919
916 if ( isInline ) { 920 if ( isInline ) {
917 QImage img; 921 QImage img;
918 if ( v->asString() == "<dummy>" ) { // no picture inline stored => picture is in cache 922 if ( v->asString() == "<dummy>" ) { // no picture inline stored => picture is in cache
919 QString dir; 923 QString dir;
920 if ( type == EntityPhoto ) 924 if ( type == EntityPhoto )
921 dir = "photos"; 925 dir = "photos";
922 if ( type == EntityLogo ) 926 if ( type == EntityLogo )
923 dir = "logos"; 927 dir = "logos";
924 928
925 img.load( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ) ); 929 img.load( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ) );
926 } else { 930 } else {
927 QByteArray data; 931 QByteArray data;
928 KCodecs::base64Decode( v->asString(), data ); 932 KCodecs::base64Decode( v->asString(), data );
929 img.loadFromData( data ); 933 img.loadFromData( data );
930 } 934 }
931 pic.setData( img ); 935 pic.setData( img );
932 pic.setType( picType ); 936 pic.setType( picType );
933 } else { 937 } else {
934 pic.setUrl( QString::fromUtf8( v->asString() ) ); 938 pic.setUrl( QString::fromUtf8( v->asString() ) );
935 } 939 }
936 940
937 return pic; 941 return pic;