summaryrefslogtreecommitdiffabout
path: root/kabc/vcardparser
Side-by-side diff
Diffstat (limited to 'kabc/vcardparser') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardparser/vcardparser.cpp2
-rw-r--r--kabc/vcardparser/vcardtool.cpp10
2 files changed, 6 insertions, 6 deletions
diff --git a/kabc/vcardparser/vcardparser.cpp b/kabc/vcardparser/vcardparser.cpp
index 9ea084d..bec2a0c 100644
--- a/kabc/vcardparser/vcardparser.cpp
+++ b/kabc/vcardparser/vcardparser.cpp
@@ -68,97 +68,97 @@ VCard::List VCardParser::parseVCards( const QString& text )
QStringList params = QStringList::split( ';', key );
vCardLine.setIdentifier( params[0] );
if ( params.count() > 1 ) { // find all parameters
for ( uint i = 1; i < params.count(); ++i ) {
QStringList pair = QStringList::split( '=', params[i] );
//US if ( pair.size() == 1 ) {
if ( pair.count() == 1 ) {
pair.prepend( "type" );
}
if ( pair[1].contains( ',' ) ) { // parameter in type=x,y,z format
QStringList args = QStringList::split( ',', pair[ 1 ] );
for ( uint j = 0; j < args.count(); ++j )
vCardLine.addParameter( pair[0].lower(), args[j] );
} else
vCardLine.addParameter( pair[0].lower(), pair[1] );
}
}
params = vCardLine.parameterList();
if ( params.contains( "encoding" ) ) { // have to decode the data
#if 0
QByteArray input, output;
input = value.local8Bit();
if ( vCardLine.parameter( "encoding" ).lower() == "b" )
KCodecs::base64Decode( input, output );
else if ( vCardLine.parameter( "encoding" ).lower() == "quoted-printable" )
KCodecs::quotedPrintableDecode( input, output );
//qDebug("VCardParser::parseVCards has to be verified");
//US I am not sure if this is correct
//US vCardLine.setValue( output );
QCString cs(output);
qDebug("len1 %d len2 %d ",input.size(), output.size( ));
#endif
QCString cs = value.local8Bit();
qDebug("****************************************** ");
qDebug("************* WARNING ******************** ");
qDebug("****************************************** ");
qDebug("Make sure, the decoding is done after");
qDebug("QVariant conversion!");
qDebug("Insert Line DECODING OKAY, where this is implemented");
// use for decoding the above code!
vCardLine.setValue( cs );
} else {
//qDebug("VCardParser::parseVCards has to be verified");
//US vCardLine.setValue( value.replace( "\\n", "\n" ) );
- vCardLine.setValue( value.replace( QRegExp("\\n"), "\n" ) );
+ vCardLine.setValue( 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;
//qDebug("VCardParser::parseVCards has to be verified");
//US currentLine.setLength( 0 );
currentLine = "";
currentVCard.clear(); // flush vcard
continue;
}
if ( (*it).lower().startsWith( "end:vcard" ) ) {
inVCard = false;
vCardList.append( currentVCard );
//qDebug("VCardParser::parseVCards has to be verified");
//US currentLine.setLength( 0 );
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::Iterator valueIt;
VCardLine::List lines;
VCardLine::List::Iterator lineIt;
VCard::List::ConstIterator cardIt;
bool hasEncoding;
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
@@ -767,101 +767,101 @@ 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;