summaryrefslogtreecommitdiffabout
path: root/kabc/vcardparser/vcardtool.cpp
Side-by-side diff
Diffstat (limited to 'kabc/vcardparser/vcardtool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcardparser/vcardtool.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp
index 204326e..435c3b0 100644
--- a/kabc/vcardparser/vcardtool.cpp
+++ b/kabc/vcardparser/vcardtool.cpp
@@ -559,193 +559,193 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
tz.setOffset( offset );
addr.setTimeZone( tz );
}
// UID
else if ( identifier == "uid" )
addr.setUid( (*lineIt).valueString() );
// URL
else if ( identifier == "url" )
addr.setUrl( KURL( (*lineIt).valueString() ) );
// X-
else if ( identifier.startsWith( "x-" ) ) {
const QString key = (*lineIt).identifier().mid( 2 );
int dash = key.find( "-" );
addr.insertCustom( key.left( dash ), key.mid( dash + 1 ), (*lineIt).valueString() );
}
}
}
addr.makePhoneNumbersOLcompatible();
addrList.append( addr );
}
return addrList;
}
QDateTime VCardTool::parseDateTime( const QString &str )
{
QDateTime dateTime;
if ( str.find( '-' ) == -1 ) { // is base format (yyyymmdd)
dateTime.setDate( QDate( str.left( 4 ).toInt(), str.mid( 4, 2 ).toInt(),
str.mid( 6, 2 ).toInt() ) );
if ( str.find( 'T' ) ) // has time information yyyymmddThh:mm:ss
dateTime.setTime( QTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(),
str.mid( 17, 2 ).toInt() ) );
} else { // is extended format yyyy-mm-dd
dateTime.setDate( QDate( str.left( 4 ).toInt(), str.mid( 5, 2 ).toInt(),
str.mid( 8, 2 ).toInt() ) );
if ( str.find( 'T' ) ) // has time information yyyy-mm-ddThh:mm:ss
dateTime.setTime( QTime( str.mid( 11, 2 ).toInt(), str.mid( 14, 2 ).toInt(),
str.mid( 17, 2 ).toInt() ) );
}
return dateTime;
}
QString VCardTool::createDateTime( const QDateTime &dateTime )
{
QString str;
if ( dateTime.date().isValid() ) {
str.sprintf( "%4d-%02d-%02d", dateTime.date().year(), dateTime.date().month(),
dateTime.date().day() );
if ( dateTime.time().isValid() ) {
QString tmp;
tmp.sprintf( "T%02d:%02d:%02dZ", dateTime.time().hour(), dateTime.time().minute(),
dateTime.time().second() );
str += tmp;
}
}
return str;
}
Picture VCardTool::parsePicture( const VCardLine &line )
{
Picture pic;
const QStringList params = line.parameterList();
if ( params.findIndex( "encoding" ) != -1 ) {
QImage img;
img.loadFromData( line.valueBytes() );
pic.setData( img );
} else if ( params.findIndex( "value" ) != -1 ) {
if ( line.parameter( "value" ).lower() == "uri" )
pic.setUrl( line.valueString() );
}
if ( params.findIndex( "type" ) != -1 )
pic.setType( line.parameter( "type" ) );
return pic;
}
VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pic )
{
VCardLine line( identifier );
if ( pic.isIntern() ) {
if ( !pic.data().isNull() ) {
QByteArray input;
- QDataStream s( input, IO_WriteOnly );
+ QDataStream s( &input, QIODevice::WriteOnly );
s.setVersion( 4 );
s << pic.data();
line.setValueBytes( input );
line.addParameter( "encoding", "b" );
line.addParameter( "type", "image/png" );
}
} else if ( !pic.url().isEmpty() ) {
QByteArray ba;
line.setValueString( pic.url() );
line.addParameter( "value", "URI" );
}
return line;
}
Sound VCardTool::parseSound( const VCardLine &line )
{
Sound snd;
const QStringList params = line.parameterList();
if ( params.findIndex( "encoding" ) != -1 )
snd.setData( line.valueBytes() );
else if ( params.findIndex( "value" ) != -1 ) {
if ( line.parameter( "value" ).lower() == "uri" )
snd.setUrl( line.valueString() );
}
/* 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() ) {
line.setValueBytes( snd.data() );
line.addParameter( "encoding", "b" );
// TODO: need to store sound type!!!
}
} else if ( !snd.url().isEmpty() ) {
line.setValueString( snd.url() );
line.addParameter( "value", "URI" );
}
return line;
}
Key VCardTool::parseKey( const VCardLine &line )
{
Key key;
const QStringList params = line.parameterList();
if ( params.findIndex( "encoding" ) != -1 )
key.setBinaryData( line.valueBytes() );
else
key.setTextData( line.valueString() );
if ( params.findIndex( "type" ) != -1 ) {
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() ) {
line.setValueBytes( key.binaryData() );
line.addParameter( "encoding", "b" );
}
} else if ( !key.textData().isEmpty() )
line.setValueString( 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() );