summaryrefslogtreecommitdiffabout
path: root/kabc/vcardparser/vcardparser.cpp
Side-by-side diff
Diffstat (limited to 'kabc/vcardparser/vcardparser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardparser/vcardparser.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/kabc/vcardparser/vcardparser.cpp b/kabc/vcardparser/vcardparser.cpp
index 7fae011..11622a0 100644
--- a/kabc/vcardparser/vcardparser.cpp
+++ b/kabc/vcardparser/vcardparser.cpp
@@ -97,144 +97,144 @@ VCard::List VCardParser::parseVCards( const QString& text )
}
// This is pretty much a faster pair[1].contains( ',' )...
if ( pair[1].find( ',' ) != -1 ) { // parameter in type=x,y,z format
const QStringList args = QStringList::split( ',', pair[ 1 ] );
QStringList::ConstIterator argIt;
for ( argIt = args.begin(); argIt != args.end(); ++argIt )
vCardLine.addParameter( pair[0].lower(), *argIt );
} else
vCardLine.addParameter( pair[0].lower(), pair[1] );
}
}
params = vCardLine.parameterList();
if ( params.findIndex( "encoding" ) != -1 ) { // have to decode the data
QByteArray input, output;
if ( vCardLine.parameter( "encoding" ).lower() == "b" ||
vCardLine.parameter( "encoding" ).lower() == "base64" ) {
input = value.local8Bit();
KCodecs::base64Decode( input, output );
} else if ( vCardLine.parameter( "encoding" ).lower() == "quoted-printable" ) {
// join any qp-folded lines
while ( value.mid(value.length()-1,1) == "=" && it != linesEnd ) {
value = value.remove( value.length()-1, 1 ) + (*it);
++it;
}
input = value.local8Bit();
KCodecs::quotedPrintableDecode( input, output );
}
//PP our vcards are *supposed* to be in UTF-8
// if ( vCardLine.parameter( "charset" ).lower() == "utf-8" ) {
// vCardLine.setValue( QString::fromUtf8( output.data(), output.size() ) );
// } else
- vCardLine.setValue( output );
+ vCardLine.setValueBytes( output );
//PP our vcards are *supposed* to be in UTF-8
// } else if ( vCardLine.parameter( "charset" ).lower() == "utf-8" ) {
// vCardLine.setValue( QString::fromUtf8( value.ascii() ) );
} else
- vCardLine.setValue( value.replace( QRegExp("\\\\n"), "\n" ) );
+ vCardLine.setValueString( value.replace( QRegExp("\\\\n"), "\n" ) );
currentVCard.addLine( vCardLine );
}
// we do not save the start and end tag as vcardline
if ( (*it).lower().startsWith( "begin:vcard" ) ) {
inVCard = true;
currentLine = "";
currentVCard.clear(); // flush vcard
continue;
}
if ( (*it).lower().startsWith( "end:vcard" ) ) {
inVCard = false;
vCardList.append( currentVCard );
currentLine = "";
currentVCard.clear(); // flush vcard
continue;
}
currentLine = (*it);
}
}
return vCardList;
}
QString VCardParser::createVCards( const VCard::List& list )
{
QString text;
QString textLine;
QString encodingType;
QStringList idents;
QStringList params;
QStringList values;
QStringList::ConstIterator identIt;
QStringList::Iterator paramIt;
QStringList::ConstIterator valueIt;
VCardLine::List lines;
VCardLine::List::ConstIterator lineIt;
VCard::List::ConstIterator cardIt;
bool hasEncoding;
// iterate over the cards
VCard::List::ConstIterator listEnd( list.end() );
for ( cardIt = list.begin(); cardIt != listEnd; ++cardIt ) {
text.append( "BEGIN:VCARD\r\n" );
idents = (*cardIt).identifiers();
for ( identIt = idents.begin(); identIt != idents.end(); ++identIt ) {
lines = (*cardIt).lines( (*identIt) );
// iterate over the lines
for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) {
- if ( !(*lineIt).value().asString().isEmpty() ) {
+ if ( !(*lineIt).valueString().isEmpty() ) {
if ( (*lineIt).hasGroup() )
textLine = (*lineIt).group() + "." + (*lineIt).identifier();
else
textLine = (*lineIt).identifier();
params = (*lineIt).parameterList();
hasEncoding = false;
if ( params.count() > 0 ) { // we have parameters
for ( paramIt = params.begin(); paramIt != params.end(); ++paramIt ) {
if ( (*paramIt) == "encoding" ) {
hasEncoding = true;
encodingType = (*lineIt).parameter( "encoding" ).lower();
}
values = (*lineIt).parameters( *paramIt );
for ( valueIt = values.begin(); valueIt != values.end(); ++valueIt ) {
textLine.append( ";" + (*paramIt).upper() );
if ( !(*valueIt).isEmpty() )
textLine.append( "=" + (*valueIt) );
}
}
}
if ( hasEncoding ) { // have to encode the data
QByteArray input, output;
input = (*lineIt).valueBytes();
if ( encodingType == "b" )
KCodecs::base64Encode( input, output );
else if ( encodingType == "quoted-printable" )
KCodecs::quotedPrintableEncode( input, output );
textLine.append( ":" + QString( output ) );
} else
- textLine.append( ":" + (*lineIt).value().asString().replace( QRegExp("\n"), "\\n" ) );
+ textLine.append( ":" + (*lineIt).valueString().replace( QRegExp("\n"), "\\n" ) );
if ( textLine.length() > FOLD_WIDTH ) { // we have to fold the line
for ( uint i = 0; i <= ( textLine.length() / FOLD_WIDTH ); ++i )
text.append( ( i == 0 ? "" : " " ) + textLine.mid( i * FOLD_WIDTH, FOLD_WIDTH ) + "\r\n" );
} else
text.append( textLine + "\r\n" );
}
}
}
text.append( "END:VCARD\r\n" );
text.append( "\r\n" );
}
return text;
}