author | zautrix <zautrix> | 2004-10-13 05:15:03 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-13 05:15:03 (UTC) |
commit | f08cf9044213a60c87e2bf299665d13a335feff5 (patch) (side-by-side diff) | |
tree | c9c0e8b0f7f7a48dcee8fbdd5b9a467985c78fdd /kabc/vcardparser/vcardtool.cpp | |
parent | 308bc78a3ab0d27718070a5ebdf3f019ac570c6b (diff) | |
download | kdepimpi-f08cf9044213a60c87e2bf299665d13a335feff5.zip kdepimpi-f08cf9044213a60c87e2bf299665d13a335feff5.tar.gz kdepimpi-f08cf9044213a60c87e2bf299665d13a335feff5.tar.bz2 |
fixed some newline probs
Diffstat (limited to 'kabc/vcardparser/vcardtool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kabc/vcardparser/vcardtool.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp index 3fb212e..d1f823b 100644 --- a/kabc/vcardparser/vcardtool.cpp +++ b/kabc/vcardparser/vcardtool.cpp @@ -623,276 +623,276 @@ Picture VCardTool::parsePicture( const VCardLine &line ) VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pic ) { // LR fixed VCardLine line( identifier ); if ( pic.isIntern() ) { if ( !pic.data().isNull() ) { #if 0 QByteArray input; QDataStream s( input, IO_WriteOnly ); s.setVersion( 4 ); s << pic.data(); line.setValue( input ); #else QCString input; QDataStream s( input, IO_WriteOnly ); s.setVersion( 4 ); s << pic.data(); //QCString cs(line.value().asCString()); //QImage qi(cs); line.setValue( input ); #endif line.addParameter( "encoding", "b" ); line.addParameter( "type", "image/png" ); } } else if ( !pic.url().isEmpty() ) { line.setValue( pic.url() ); line.addParameter( "value", "URI" ); } return line; } Sound VCardTool::parseSound( const VCardLine &line ) { Sound snd; QStringList params = line.parameterList(); if ( params.contains( "encoding" ) ) { qDebug("VCardTool::parseSound has to be verified"); //US snd.setData( line.value().asByteArray() ); //US I am not sure if this is correct QCString cs(line.value().asCString()); snd.setData( cs ); } else if ( params.contains( "value" ) ) { if ( line.parameter( "value" ).lower() == "uri" ) snd.setUrl( line.value().asString() ); } /* TODO: support sound types if ( params.contains( "type" ) ) snd.setType( line.parameter( "type" ) ); */ return snd; } VCardLine VCardTool::createSound( const Sound &snd ) { VCardLine line( "SOUND" ); if ( snd.isIntern() ) { if ( !snd.data().isEmpty() ) { qDebug("VCardTool::createSound has to be verified"); //US line.setValue( snd.data() ); //US I am not sure if this is correct QCString cs(snd.data()); line.setValue( cs ); line.addParameter( "encoding", "b" ); // TODO: need to store sound type!!! } } else if ( !snd.url().isEmpty() ) { line.setValue( snd.url() ); line.addParameter( "value", "URI" ); } return line; } Key VCardTool::parseKey( const VCardLine &line ) { Key key; QStringList params = line.parameterList(); if ( params.contains( "encoding" ) ) { qDebug("VCardTool::parseKey has to be verified"); //US key.setBinaryData( line.value().asByteArray() ); //US I am not sure if this is correct QCString cs( line.value().asCString() ); key.setBinaryData( cs ); } else key.setTextData( line.value().asString() ); if ( params.contains( "type" ) ) { if ( line.parameter( "type" ).lower() == "x509" ) key.setType( Key::X509 ); else if ( line.parameter( "type" ).lower() == "pgp" ) key.setType( Key::PGP ); else { key.setType( Key::Custom ); key.setCustomTypeString( line.parameter( "type" ) ); } } return key; } VCardLine VCardTool::createKey( const Key &key ) { VCardLine line( "KEY" ); if ( key.isBinary() ) { if ( !key.binaryData().isEmpty() ) { qDebug("VCardTool::createKey has to be verified"); //US line.setValue( key.binaryData() ); //US I am not sure if this is correct QCString cs(key.binaryData()); line.setValue( cs ); line.addParameter( "encoding", "b" ); } } else if ( !key.textData().isEmpty() ) line.setValue( key.textData() ); if ( key.type() == Key::X509 ) line.addParameter( "type", "X509" ); else if ( key.type() == Key::PGP ) line.addParameter( "type", "PGP" ); else if ( key.type() == Key::Custom ) line.addParameter( "type", key.customTypeString() ); return line; } Secrecy VCardTool::parseSecrecy( const VCardLine &line ) { Secrecy secrecy; if ( line.value().asString().lower() == "public" ) secrecy.setType( Secrecy::Public ); if ( line.value().asString().lower() == "private" ) secrecy.setType( Secrecy::Private ); if ( line.value().asString().lower() == "confidential" ) secrecy.setType( Secrecy::Confidential ); return secrecy; } VCardLine VCardTool::createSecrecy( const Secrecy &secrecy ) { VCardLine line( "CLASS" ); int type = secrecy.type(); if ( type == Secrecy::Public ) line.setValue( "PUBLIC" ); else if ( type == Secrecy::Private ) line.setValue( "PRIVATE" ); else if ( type == Secrecy::Confidential ) line.setValue( "CONFIDENTIAL" ); return line; } Agent VCardTool::parseAgent( const VCardLine &line ) { Agent agent; QStringList params = line.parameterList(); if ( params.contains( "value" ) ) { if ( line.parameter( "value" ).lower() == "uri" ) agent.setUrl( line.value().asString() ); } else { QString str = line.value().asString(); //US using the old implementation instead qDebug("VCardTool::parseAgent has to be verified"); /*US str.replace( "\\n", "\r\n" ); str.replace( "\\N", "\r\n" ); str.replace( "\\;", ";" ); str.replace( "\\:", ":" ); str.replace( "\\,", "," ); */ - str.replace( QRegExp("\\n") , "\r\n" ); - str.replace( QRegExp("\\N") , "\r\n" ); - str.replace( QRegExp("\\;") , ";" ); - str.replace( QRegExp("\\:") , ":" ); - str.replace( QRegExp("\\,") , "," ); + str.replace( QRegExp("\\\\n") , "\r\n" ); + str.replace( QRegExp("\\\\N") , "\r\n" ); + str.replace( QRegExp("\\\\;") , ";" ); + str.replace( QRegExp("\\\\:") , ":" ); + str.replace( QRegExp("\\\\,") , "," ); Addressee::List list = parseVCards( str ); if ( list.count() > 0 ) { Addressee *addr = new Addressee; *addr = list[ 0 ]; agent.setAddressee( addr ); } } return agent; } VCardLine VCardTool::createAgent( VCard::Version version, const Agent &agent ) { VCardLine line( "AGENT" ); if ( agent.isIntern() ) { if ( agent.addressee() != 0 ) { Addressee::List list; list.append( *agent.addressee() ); QString str = createVCards( list, version ); //US using the old implementation instead qDebug("VCardTool::createAgent has to be verified"); /*US str.replace( "\r\n", "\\n" ); str.replace( ";", "\\;" ); str.replace( ":", "\\:" ); str.replace( ",", "\\," ); */ str.replace( QRegExp("\r\n"), "\\n" ); str.replace( QRegExp(";"), "\\;" ); str.replace( QRegExp(":"), "\\:" ); str.replace( QRegExp(","), "\\," ); line.setValue( str ); } } else if ( !agent.url().isEmpty() ) { line.setValue( agent.url() ); line.addParameter( "value", "URI" ); } return line; } QStringList VCardTool::splitString( const QChar &sep, const QString &str ) { QStringList list; QString value( str ); int start = 0; int pos = value.find( sep, start ); while ( pos != -1 ) { if ( value[ pos - 1 ] != '\\' ) { if ( pos > start && pos <= (int)value.length() ) list << value.mid( start, pos - start ); else list << QString::null; start = pos + 1; pos = value.find( sep, start ); } else { if ( pos != 0 ) { value.replace( pos - 1, 2, sep ); pos = value.find( sep, pos ); } else pos = value.find( sep, pos + 1 ); } } int l = value.length() - 1; if ( value.mid( start, l - start + 1 ).length() > 0 ) list << value.mid( start, l - start + 1 ); else list << QString::null; return list; } |