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.cpp86
1 files changed, 43 insertions, 43 deletions
diff --git a/kabc/vcardparser/vcardtool.cpp b/kabc/vcardparser/vcardtool.cpp
index 0cf72c0..c3d92b6 100644
--- a/kabc/vcardparser/vcardtool.cpp
+++ b/kabc/vcardparser/vcardtool.cpp
@@ -364,13 +364,13 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
// iterate over the lines
for ( lineIt = lines.begin(); lineIt != lines.end(); ++lineIt ) {
identifier = (*lineIt).identifier().lower();
// ADR
if ( identifier == "adr" ) {
Address address;
- const QStringList addrParts = splitString( semicolonSep, (*lineIt).value().asString() );
+ const QStringList addrParts = splitString( semicolonSep, (*lineIt).valueString() );
if ( addrParts.count() > 0 )
address.setPostOfficeBox( addrParts[ 0 ] );
if ( addrParts.count() > 1 )
address.setExtended( addrParts[ 1 ] );
if ( addrParts.count() > 2 )
address.setStreet( addrParts[ 2 ] );
@@ -396,39 +396,39 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
// AGENT
else if ( identifier == "agent" )
addr.setAgent( parseAgent( *lineIt ) );
// BDAY
else if ( identifier == "bday" )
- addr.setBirthday( parseDateTime( (*lineIt).value().asString() ) );
+ addr.setBirthday( parseDateTime( (*lineIt).valueString() ) );
// CATEGORIES
else if ( identifier == "categories" ) {
- const QStringList categories = splitString( commaSep, (*lineIt).value().asString() );
+ const QStringList categories = splitString( commaSep, (*lineIt).valueString() );
addr.setCategories( categories );
}
// CLASS
else if ( identifier == "class" )
addr.setSecrecy( parseSecrecy( *lineIt ) );
// EMAIL
else if ( identifier == "email" ) {
const QStringList types = (*lineIt).parameters( "type" );
- addr.insertEmail( (*lineIt).value().asString(), types.findIndex( "PREF" ) != -1 );
+ addr.insertEmail( (*lineIt).valueString(), types.findIndex( "PREF" ) != -1 );
}
// FN
else if ( identifier == "fn" )
- addr.setFormattedName( (*lineIt).value().asString() );
+ addr.setFormattedName( (*lineIt).valueString() );
// GEO
else if ( identifier == "geo" ) {
Geo geo;
- const QStringList geoParts = QStringList::split( ';', (*lineIt).value().asString(), true );
+ const QStringList geoParts = QStringList::split( ';', (*lineIt).valueString(), true );
geo.setLatitude( geoParts[ 0 ].toFloat() );
geo.setLongitude( geoParts[ 1 ].toFloat() );
addr.setGeo( geo );
}
@@ -446,37 +446,37 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
bool available = false;
KABC::Address::List addressList = addr.addresses();
KABC::Address::List::Iterator it;
for ( it = addressList.begin(); it != addressList.end(); ++it ) {
if ( (*it).type() == type ) {
- (*it).setLabel( (*lineIt).value().asString() );
+ (*it).setLabel( (*lineIt).valueString() );
addr.insertAddress( *it );
available = true;
break;
}
}
if ( !available ) { // a standalone LABEL tag
KABC::Address address( type );
- address.setLabel( (*lineIt).value().asString() );
+ address.setLabel( (*lineIt).valueString() );
addr.insertAddress( address );
}
}
// LOGO
else if ( identifier == "logo" )
addr.setLogo( parsePicture( *lineIt ) );
// MAILER
else if ( identifier == "mailer" )
- addr.setMailer( (*lineIt).value().asString() );
+ addr.setMailer( (*lineIt).valueString() );
// N
else if ( identifier == "n" ) {
- const QStringList nameParts = splitString( semicolonSep, (*lineIt).value().asString() );
+ const QStringList nameParts = splitString( semicolonSep, (*lineIt).valueString() );
if ( nameParts.count() > 0 )
addr.setFamilyName( nameParts[ 0 ] );
if ( nameParts.count() > 1 )
addr.setGivenName( nameParts[ 1 ] );
if ( nameParts.count() > 2 )
addr.setAdditionalName( nameParts[ 2 ] );
@@ -485,54 +485,54 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
if ( nameParts.count() > 4 )
addr.setSuffix( nameParts[ 4 ] );
}
// NAME
else if ( identifier == "name" )
- addr.setName( (*lineIt).value().asString() );
+ addr.setName( (*lineIt).valueString() );
// NICKNAME
else if ( identifier == "nickname" )
- addr.setNickName( (*lineIt).value().asString() );
+ addr.setNickName( (*lineIt).valueString() );
// NOTE
else if ( identifier == "note" )
- addr.setNote( (*lineIt).value().asString() );
+ addr.setNote( (*lineIt).valueString() );
// ORGANIZATION
else if ( identifier == "org" )
- addr.setOrganization( (*lineIt).value().asString() );
+ addr.setOrganization( (*lineIt).valueString() );
// PHOTO
else if ( identifier == "photo" )
addr.setPhoto( parsePicture( *lineIt ) );
// PROID
else if ( identifier == "prodid" )
- addr.setProductId( (*lineIt).value().asString() );
+ addr.setProductId( (*lineIt).valueString() );
// REV
else if ( identifier == "rev" )
- addr.setRevision( parseDateTime( (*lineIt).value().asString() ) );
+ addr.setRevision( parseDateTime( (*lineIt).valueString() ) );
// ROLE
else if ( identifier == "role" )
- addr.setRole( (*lineIt).value().asString() );
+ addr.setRole( (*lineIt).valueString() );
// SORT-STRING
else if ( identifier == "sort-string" )
- addr.setSortString( (*lineIt).value().asString() );
+ addr.setSortString( (*lineIt).valueString() );
// SOUND
else if ( identifier == "sound" )
addr.setSound( parseSound( *lineIt ) );
// TEL
else if ( identifier == "tel" ) {
PhoneNumber phone;
- phone.setNumber( (*lineIt).value().asString() );
+ phone.setNumber( (*lineIt).valueString() );
int type = 0;
const QStringList types = (*lineIt).parameters( "type" );
for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it )
type += mPhoneTypeMap[(*it).upper()];
@@ -541,41 +541,41 @@ Addressee::List VCardTool::parseVCards( const QString& vcard )
addr.insertPhoneNumber( phone );
}
// TITLE
else if ( identifier == "title" )
- addr.setTitle( (*lineIt).value().asString() );
+ addr.setTitle( (*lineIt).valueString() );
// TZ
else if ( identifier == "tz" ) {
TimeZone tz;
- const QString date = (*lineIt).value().asString();
+ const QString date = (*lineIt).valueString();
int hours = date.mid( 1, 2).toInt();
int minutes = date.mid( 4, 2 ).toInt();
int offset = ( hours * 60 ) + minutes;
offset = offset * ( date[ 0 ] == '+' ? 1 : -1 );
tz.setOffset( offset );
addr.setTimeZone( tz );
}
// UID
else if ( identifier == "uid" )
- addr.setUid( (*lineIt).value().asString() );
+ addr.setUid( (*lineIt).valueString() );
// URL
else if ( identifier == "url" )
- addr.setUrl( KURL( (*lineIt).value().asString() ) );
+ 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).value().asString() );
+ addr.insertCustom( key.left( dash ), key.mid( dash + 1 ), (*lineIt).valueString() );
}
}
}
addrList.append( addr );
}
@@ -633,13 +633,13 @@ Picture VCardTool::parsePicture( const VCardLine &line )
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.value().asString() );
+ pic.setUrl( line.valueString() );
}
if ( params.findIndex( "type" ) != -1 )
pic.setType( line.parameter( "type" ) );
return pic;
@@ -652,19 +652,19 @@ VCardLine VCardTool::createPicture( const QString &identifier, const Picture &pi
if ( pic.isIntern() ) {
if ( !pic.data().isNull() ) {
QByteArray input;
QDataStream s( input, IO_WriteOnly );
s.setVersion( 4 );
s << pic.data();
- line.setValue( input );
+ line.setValueBytes( input );
line.addParameter( "encoding", "b" );
line.addParameter( "type", "image/png" );
}
} else if ( !pic.url().isEmpty() ) {
QByteArray ba;
- line.setValue( pic.url() );
+ line.setValueString( pic.url() );
line.addParameter( "value", "URI" );
}
return line;
}
@@ -674,13 +674,13 @@ Sound VCardTool::parseSound( const VCardLine &line )
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.value().asString() );
+ snd.setUrl( line.valueString() );
}
/* TODO: support sound types
if ( params.contains( "type" ) )
snd.setType( line.parameter( "type" ) );
*/
@@ -691,18 +691,18 @@ Sound VCardTool::parseSound( const VCardLine &line )
VCardLine VCardTool::createSound( const Sound &snd )
{
VCardLine line( "SOUND" );
if ( snd.isIntern() ) {
if ( !snd.data().isEmpty() ) {
- line.setValue( snd.data() );
+ line.setValueBytes( snd.data() );
line.addParameter( "encoding", "b" );
// TODO: need to store sound type!!!
}
} else if ( !snd.url().isEmpty() ) {
- line.setValue( snd.url() );
+ line.setValueString( snd.url() );
line.addParameter( "value", "URI" );
}
return line;
}
@@ -711,13 +711,13 @@ 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.value().asString() );
+ 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 );
@@ -733,17 +733,17 @@ Key VCardTool::parseKey( const VCardLine &line )
VCardLine VCardTool::createKey( const Key &key )
{
VCardLine line( "KEY" );
if ( key.isBinary() ) {
if ( !key.binaryData().isEmpty() ) {
- line.setValue( key.binaryData() );
+ line.setValueBytes( key.binaryData() );
line.addParameter( "encoding", "b" );
}
} else if ( !key.textData().isEmpty() )
- line.setValue( key.textData() );
+ 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 )
@@ -753,48 +753,48 @@ VCardLine VCardTool::createKey( const Key &key )
}
Secrecy VCardTool::parseSecrecy( const VCardLine &line )
{
Secrecy secrecy;
- if ( line.value().asString().lower() == "public" )
+ if ( line.valueString().lower() == "public" )
secrecy.setType( Secrecy::Public );
- if ( line.value().asString().lower() == "private" )
+ if ( line.valueString().lower() == "private" )
secrecy.setType( Secrecy::Private );
- if ( line.value().asString().lower() == "confidential" )
+ if ( line.valueString().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" );
+ line.setValueString( "PUBLIC" );
else if ( type == Secrecy::Private )
- line.setValue( "PRIVATE" );
+ line.setValueString( "PRIVATE" );
else if ( type == Secrecy::Confidential )
- line.setValue( "CONFIDENTIAL" );
+ line.setValueString( "CONFIDENTIAL" );
return line;
}
Agent VCardTool::parseAgent( const VCardLine &line )
{
Agent agent;
const QStringList params = line.parameterList();
if ( params.findIndex( "value" ) != -1 ) {
if ( line.parameter( "value" ).lower() == "uri" )
- agent.setUrl( line.value().asString() );
+ agent.setUrl( line.valueString() );
} else {
- QString str = line.value().asString();
+ QString str = line.valueString();
str.replace( QRegExp("\\\\n"), "\r\n" );
str.replace( QRegExp("\\\\N"), "\r\n" );
str.replace( QRegExp("\\\\;"), ";" );
str.replace( QRegExp("\\\\:"), ":" );
str.replace( QRegExp("\\\\,"), "," );
@@ -820,16 +820,16 @@ VCardLine VCardTool::createAgent( VCard::Version version, const Agent &agent )
QString str = createVCards( list, version );
str.replace( QRegExp("\\r\\n"), "\\n" );
str.replace( QRegExp(";"), "\\;" );
str.replace( QRegExp(":"), "\\:" );
str.replace( QRegExp(","), "\\," );
- line.setValue( str );
+ line.setValueString( str );
}
} else if ( !agent.url().isEmpty() ) {
- line.setValue( agent.url() );
+ line.setValueString( agent.url() );
line.addParameter( "value", "URI" );
}
return line;
}