-rw-r--r-- | kaddressbook/kabcore.cpp | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 6538295..d1d385c 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -642,15 +642,10 @@ void KABCore::beamVCard(const QStringList& uids) | |||
642 | 642 | ||
643 | //QDir().mkdir( dirName, true ); | 643 | //QDir().mkdir( dirName, true ); |
644 | 644 | ||
645 | QFile outFile(fileName); | 645 | |
646 | KABC::VCardConverter converter; | 646 | KABC::VCardConverter converter; |
647 | QString description; | 647 | QString description; |
648 | 648 | QString datastream; | |
649 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | ||
650 | |||
651 | QTextStream t( &outFile ); // use a text stream | ||
652 | t.setEncoding( QTextStream::UnicodeUTF8 ); | ||
653 | |||
654 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 649 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
655 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 650 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
656 | 651 | ||
@@ -662,20 +657,37 @@ void KABCore::beamVCard(const QStringList& uids) | |||
662 | 657 | ||
663 | QString vcard; | 658 | QString vcard; |
664 | converter.addresseeToVCard( a, vcard ); | 659 | converter.addresseeToVCard( a, vcard ); |
665 | t << vcard; | 660 | int start = 0; |
666 | 661 | int next; | |
662 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | ||
663 | int semi = vcard.find(";", next); | ||
664 | int dopp = vcard.find(":", next); | ||
665 | int sep; | ||
666 | if ( semi < dopp && semi >= 0 ) | ||
667 | sep = semi ; | ||
668 | else | ||
669 | sep = dopp; | ||
670 | datastream +=vcard.mid( start, next - start); | ||
671 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | ||
672 | start = sep; | ||
667 | } | 673 | } |
668 | } else { | 674 | datastream += vcard.mid( start,vcard.length() ); |
669 | qDebug("Error open temp beam file "); | ||
670 | return; | ||
671 | } | 675 | } |
672 | |||
673 | outFile.close(); | ||
674 | |||
675 | #ifndef DESKTOP_VERSION | 676 | #ifndef DESKTOP_VERSION |
677 | QFile outFile(fileName); | ||
678 | if ( outFile.open(IO_WriteOnly) ) { | ||
679 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | ||
680 | QTextStream t( &outFile ); // use a text stream | ||
681 | t.setEncoding( QTextStream::UnicodeUTF8 ); | ||
682 | t <<datastream; | ||
683 | outFile.close(); | ||
676 | Ir *ir = new Ir( this ); | 684 | Ir *ir = new Ir( this ); |
677 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 685 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
678 | ir->send( fileName, description, "text/x-vCard" ); | 686 | ir->send( fileName, description, "text/x-vCard" ); |
687 | } else { | ||
688 | qDebug("Error open temp beam file "); | ||
689 | return; | ||
690 | } | ||
679 | #endif | 691 | #endif |
680 | 692 | ||
681 | } | 693 | } |