summaryrefslogtreecommitdiffabout
path: root/kabc
Side-by-side diff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/ContentLine.cpp1
-rw-r--r--kabc/vcardformatimpl.cpp8
-rw-r--r--kabc/vcardparser/vcardparser.cpp2
-rw-r--r--kabc/vcardparser/vcardtool.cpp10
4 files changed, 11 insertions, 10 deletions
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp
index f7e04a9..c368172 100644
--- a/kabc/vcard/ContentLine.cpp
+++ b/kabc/vcard/ContentLine.cpp
@@ -262,59 +262,60 @@ ContentLine::_parse()
case ValueDate: value_ = new DateValue; break;
case ValueTextList: value_ = new TextListValue; break;
case ValueGeo: value_ = new GeoValue; break;
case ValueText:
case ValueUnknown:
default: value_ = new TextValue; break;
}
*value_ = valuePart;
}
void
ContentLine::_assemble()
{
vDebug("Assemble (argl) - my name is \"" + name_ + "\"");
strRep_.truncate(0);
QCString line;
if (!group_.isEmpty())
line += group_ + '.';
line += name_;
vDebug("Adding parameters");
ParamListIterator it(paramList_);
for (; it.current(); ++it)
line += ";" + it.current()->asString();
vDebug("Adding value");
if (value_ != 0)
line += ":" + value_->asString();
else
vDebug("No value");
// Quote newlines
line = line.replace( QRegExp( "\n" ), "\\n" );
// Fold lines longer than 72 chars
const int maxLen = 72;
uint cursor = 0;
while( line.length() > ( cursor + 1 ) * maxLen ) {
strRep_ += line.mid( cursor * maxLen, maxLen );
strRep_ += "\r\n ";
++cursor;
}
strRep_ += line.mid( cursor * maxLen );
+ //qDebug("ContentLine::_assemble()\n%s*****", strRep_.data());
}
void
ContentLine::clear()
{
group_.truncate(0);
name_.truncate(0);
paramList_.clear();
delete value_;
value_ = 0;
}
diff --git a/kabc/vcardformatimpl.cpp b/kabc/vcardformatimpl.cpp
index ede5773..c31af46 100644
--- a/kabc/vcardformatimpl.cpp
+++ b/kabc/vcardformatimpl.cpp
@@ -803,100 +803,100 @@ void VCardFormatImpl::addAgentValue( VCARD::VCard *vcard, const Agent &agent )
writeToString( (*addr), vstr );
qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct");
/*US
vstr.replace( ":", "\\:" );
vstr.replace( ",", "\\," );
vstr.replace( ";", "\\;" );
vstr.replace( "\r\n", "\\n" );
*/
vstr.replace( QRegExp(":"), "\\:" );
vstr.replace( QRegExp(","), "\\," );
vstr.replace( QRegExp(";"), "\\;" );
vstr.replace( QRegExp("\r\n"), "\\n" );
cl.setValue( new TextValue( vstr.utf8() ) );
} else
return;
} else {
cl.setValue( new TextValue( agent.url().utf8() ) );
params.append( new Param( "VALUE", "uri" ) );
}
cl.setParamList( params );
vcard->add( cl );
}
Agent VCardFormatImpl::readAgentValue( VCARD::ContentLine *cl )
{
Agent agent;
bool isIntern = true;
TextValue *v = (TextValue *)cl->value();
ParamList params = cl->paramList();
ParamListIterator it( params );
for( ; it.current(); ++it ) {
if ( (*it)->name() == "VALUE" && (*it)->value() == "uri" )
isIntern = false;
}
if ( isIntern ) {
QString vstr = QString::fromUtf8( v->asString() );
qDebug("VCardFormatImpl::addAgentValue please verify if replace is correct");
/*US
vstr.replace( "\\n", "\r\n" );
vstr.replace( "\\:", ":" );
vstr.replace( "\\,", "," );
vstr.replace( "\\;", ";" );
*/
- vstr.replace( QRegExp("\\n"), "\r\n" );
- vstr.replace( QRegExp("\\:"), ":" );
- vstr.replace( QRegExp("\\,"), "," );
- vstr.replace( QRegExp("\\;"), ";" );
+ vstr.replace( QRegExp("\\\\n"), "\r\n" );
+ vstr.replace( QRegExp("\\\\:"), ":" );
+ vstr.replace( QRegExp("\\\\,"), "," );
+ vstr.replace( QRegExp("\\\\;"), ";" );
Addressee *addr = new Addressee;
readFromString( vstr, *addr );
agent.setAddressee( addr );
} else {
agent.setUrl( QString::fromUtf8( v->asString() ) );
}
return agent;
}
void VCardFormatImpl::addPictureValue( VCARD::VCard *vcard, VCARD::EntityType type, const Picture &pic, const Addressee &addr, bool intern )
{
ContentLine cl;
cl.setName( EntityTypeToParamName( type ) );
if ( pic.isIntern() && pic.data().isNull() )
return;
if ( !pic.isIntern() && pic.url().isEmpty() )
return;
ParamList params;
if ( pic.isIntern() ) {
QImage img = pic.data();
if ( intern ) { // only for vCard export we really write the data inline
QByteArray data;
QDataStream s( data, IO_WriteOnly );
s.setVersion( 4 ); // to produce valid png files
s << img;
cl.setValue( new TextValue( KCodecs::base64Encode( data ) ) );
} else { // save picture in cache
QString dir;
if ( type == EntityPhoto )
dir = "photos";
if ( type == EntityLogo )
dir = "logos";
img.save( locateLocal( "data", "kabc/" + dir + "/" + addr.uid() ), pic.type().utf8() );
cl.setValue( new TextValue( "<dummy>" ) );
}
params.append( new Param( "ENCODING", "b" ) );
if ( !pic.type().isEmpty() )
params.append( new Param( "TYPE", pic.type().utf8() ) );
} else {
cl.setValue( new TextValue( pic.url().utf8() ) );
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;