summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-08 09:57:16 (UTC)
committer zautrix <zautrix>2004-09-08 09:57:16 (UTC)
commit848c77f86b7105095b27a6034a0fefac8a7a0891 (patch) (side-by-side diff)
tree2816ee9a05000ccabc43d3c9be4558053bfc8c0b
parent6650dd66dd13498a6d28844770d9d8c291335ad4 (diff)
downloadkdepimpi-848c77f86b7105095b27a6034a0fefac8a7a0891.zip
kdepimpi-848c77f86b7105095b27a6034a0fefac8a7a0891.tar.gz
kdepimpi-848c77f86b7105095b27a6034a0fefac8a7a0891.tar.bz2
Beam vcard fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp52
1 files changed, 32 insertions, 20 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 6538295..d1d385c 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -644,12 +644,7 @@ void KABCore::beamVCard(const QStringList& uids)
- QFile outFile(fileName);
+
KABC::VCardConverter converter;
QString description;
-
- if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
-
- QTextStream t( &outFile ); // use a text stream
- t.setEncoding( QTextStream::UnicodeUTF8 );
-
- for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
+ QString datastream;
+ for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
KABC::Addressee a = mAddressBook->findByUid( *it );
@@ -657,6 +652,6 @@ void KABCore::beamVCard(const QStringList& uids)
if ( a.isEmpty() )
- continue;
+ continue;
if (description.isEmpty())
- description = a.formattedName();
+ description = a.formattedName();
@@ -664,5 +659,29 @@ void KABCore::beamVCard(const QStringList& uids)
converter.addresseeToVCard( a, vcard );
- t << vcard;
-
- }
+ int start = 0;
+ int next;
+ while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
+ int semi = vcard.find(";", next);
+ int dopp = vcard.find(":", next);
+ int sep;
+ if ( semi < dopp && semi >= 0 )
+ sep = semi ;
+ else
+ sep = dopp;
+ datastream +=vcard.mid( start, next - start);
+ datastream +=vcard.mid( next+5,sep -next -5 ).upper();
+ start = sep;
+ }
+ datastream += vcard.mid( start,vcard.length() );
+ }
+#ifndef DESKTOP_VERSION
+ QFile outFile(fileName);
+ if ( outFile.open(IO_WriteOnly) ) {
+ datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
+ QTextStream t( &outFile ); // use a text stream
+ t.setEncoding( QTextStream::UnicodeUTF8 );
+ t <<datastream;
+ outFile.close();
+ Ir *ir = new Ir( this );
+ connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
+ ir->send( fileName, description, "text/x-vCard" );
} else {
@@ -671,9 +690,2 @@ void KABCore::beamVCard(const QStringList& uids)
}
-
- outFile.close();
-
-#ifndef DESKTOP_VERSION
- Ir *ir = new Ir( this );
- connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
- ir->send( fileName, description, "text/x-vCard" );
#endif