File 4_1_BRANCH.diff of Package kdepim4

package: kdepim-4.1.3.tar.bz2
kdemod: kdepim
--- BRANCH_STATUS
+++ BRANCH_STATUS
@@ -0,0 +1,2 @@
+current HEAD: 878038
+svn di between //tags/KDE/4.1.3/kdepim and //branches/KDE/4.1/kdepim
--- kleopatra/kgpgconf/mainwindow.cpp	
+++ kleopatra/kgpgconf/mainwindow.cpp	
@@ -204,7 +204,7 @@
 
 void MainWindow::saveToFile( const QString& fileName )
 {
-    if ( fileName.isNull() )
+    if ( fileName.isEmpty() )
         return;
 
     QTemporaryFile tmp( fileName );
--- kleopatra/uiserver/signcommand.cpp	
+++ kleopatra/uiserver/signcommand.cpp	
@@ -126,12 +126,9 @@
 
     try {
         const QString sessionTitle = q->sessionTitle();
-        if ( !sessionTitle.isNull() ) {
+        if ( !sessionTitle.isEmpty() )
             Q_FOREACH ( const shared_ptr<Input> & i, q->inputs() )
                 i->setLabel( sessionTitle );
-            Q_FOREACH ( const shared_ptr<Output> & i, q->outputs() )
-                i->setLabel( sessionTitle );
-        }
 
         controller->setDetachedSignature( q->hasOption("detached" ) );
         controller->setInputsAndOutputs( q->inputs(), q->outputs() );
--- kleopatra/uiserver/decryptverifycommandemailbase.cpp	
+++ kleopatra/uiserver/decryptverifycommandemailbase.cpp	
@@ -112,14 +112,12 @@
     d->controller.reset( new DecryptVerifyEMailController( shared_from_this() ) );
 
     const QString st = sessionTitle();
-    if ( !st.isNull() ) {
+    if ( !st.isEmpty() )
         Q_FOREACH ( const shared_ptr<Input> & i, inputs() )
             i->setLabel( st );
-        Q_FOREACH ( const shared_ptr<Output> & i, outputs() )
-            i->setLabel( st );
-    }
 
     d->controller->setOperation( operation() );
+    d->controller->setVerificationMode( messages().empty() ? Opaque : Detached );
     d->controller->setInputs( inputs() );
     d->controller->setSignedData( messages() );
     d->controller->setOutputs( outputs() );
--- kleopatra/uiserver/assuanserverconnection.cpp	
+++ kleopatra/uiserver/assuanserverconnection.cpp	
@@ -205,6 +205,32 @@
     return result;
 }
 
+static WId wid_from_string( const QString & winIdStr, bool * ok=0 ) {
+    return
+#ifdef Q_OS_WIN32
+        reinterpret_cast<WId>
+#else
+        static_cast<WId>
+#endif
+             ( winIdStr.toULongLong( ok, 16 ) );
+}
+
+static void apply_window_id( QWidget * widget, const QString & winIdStr ) {
+    if ( !widget || winIdStr.isEmpty() )
+        return;
+    bool ok = false;
+    const WId wid = wid_from_string( winIdStr, &ok );
+    if ( !ok ) {
+        qDebug() << "window-id value" << wid << "doesn't look like a number";
+        return;
+    }
+    if ( QWidget * pw = QWidget::find( wid ) )
+        widget->setParent( pw, widget->windowFlags() );
+    else {
+        KWindowSystem::setMainWindow( widget, wid );
+    }
+}
+
 //
 //
 // AssuanServerConnection:
@@ -423,7 +449,7 @@
 #endif
                 }
 
-                io = Input_or_Output<in>::type::createFromPipeDevice( fd, i18n( "Message #%1", (conn.*which).size() + 1 ) );
+                io = Input_or_Output<in>::type::createFromPipeDevice( fd, in ? i18n( "Message #%1", (conn.*which).size() + 1 ) : QString() );
 
                 options.erase( "FD" );
 
@@ -516,7 +542,8 @@
         }
     }
 
-    static bool parse_informative( const char * & begin ) {
+    static bool parse_informative( const char * & begin, GpgME::Protocol & protocol ) {
+        protocol = GpgME::UnknownProtocol;
         bool informative = false;
         const char * pos = begin;
         while ( true ) {
@@ -529,6 +556,16 @@
                     ++pos;
                     break;
                 }
+            } else if ( qstrnicmp( pos, "--protocol=", strlen("--protocol=") ) == 0 ) {
+                pos += strlen("--protocol=");
+                if ( qstrnicmp( pos, "OpenPGP", strlen("OpenPGP") ) == 0 ) {
+                    protocol = GpgME::OpenPGP;
+                    pos += strlen("OpenPGP");
+                } else if ( qstrnicmp( pos, "CMS", strlen("CMS") ) == 0 ) {
+                    protocol = GpgME::CMS;
+                    pos += strlen("CMS");
+                } else
+                    ;
             } else if ( qstrncmp( pos, "-- ", strlen("-- ") ) == 0 ) {
                 pos += 3;
                 while ( *pos == ' ' || *pos == '\t' )
@@ -550,7 +587,8 @@
             return assuan_process_done( conn.ctx.get(), gpg_error( GPG_ERR_INV_ARG ) );
         const char * begin     = line;
         const char * const end = begin + qstrlen( line );
-        const bool informative = parse_informative( begin );
+        GpgME::Protocol proto = GpgME::UnknownProtocol;
+        const bool informative = parse_informative( begin, proto );
         if ( !(conn.*mp).empty() && informative != (conn.*info) )
             return assuan_process_done_msg( conn.ctx.get(), gpg_error( GPG_ERR_CONFLICT ),
                                             i18n("Cannot mix --info with non-info SENDER or RECIPIENT").toUtf8().constData() );
@@ -577,25 +615,38 @@
             else
                 Q_FOREACH( const GpgME::Key & key, seckeys )
                     (void)assuan_write_line( conn.ctx.get(), qPrintable( QString().sprintf( "# matching %s key %s", key.protocolAsString(), key.primaryFingerprint() ) ) );
-            const bool pgp = kdtools::any( seckeys, bind( &GpgME::Key::protocol, _1 ) == GpgME::OpenPGP );
-            const bool cms = kdtools::any( seckeys, bind( &GpgME::Key::protocol, _1 ) == GpgME::CMS );
-            GpgME::Protocol proto = GpgME::UnknownProtocol;
+            const bool pgp = proto != GpgME::CMS     && kdtools::any( seckeys, bind( &GpgME::Key::protocol, _1 ) == GpgME::OpenPGP );
+            const bool cms = proto != GpgME::OpenPGP && kdtools::any( seckeys, bind( &GpgME::Key::protocol, _1 ) == GpgME::CMS );
             if ( cms != pgp )
                 proto = pgp ? GpgME::OpenPGP : GpgME::CMS ;
             if ( cms && pgp )
-                if ( conn.bias != GpgME::UnknownProtocol )
+                if ( conn.bias != GpgME::UnknownProtocol ) {
                     proto = conn.bias;
-                else
-                    proto =
-                        KMessageBox::questionYesNo( 0, i18nc("@info",
-                                                             "<para>The sender address <email>%1</email> matches more than one cryptographic format.</para>"
-                                                             "<para>Which format do you want to use?</para>", email ),
-                                                    i18nc("@title","Format Choice"),
-                                                    KGuiItem( i18nc("@action:button","Send OpenPGP-Signed") ),
-                                                    KGuiItem( i18nc("@action:button","Send S/MIME-Signed") ),
-                                                    QLatin1String("uiserver-sender-ask-protocol") ) == KMessageBox::Yes
-                        ? GpgME::OpenPGP
-                        : GpgME::CMS ;
+                } else {
+                    if ( conn.options.count("window-id") )
+                        proto =
+                            KMessageBox::questionYesNoWId( wid_from_string( conn.options["window-id"].toString() ),
+                                                           i18nc("@info",
+                                                                 "<para>The sender address <email>%1</email> matches more than one cryptographic format.</para>"
+                                                                 "<para>Which format do you want to use?</para>", email ),
+                                                           i18nc("@title","Format Choice"),
+                                                           KGuiItem( i18nc("@action:button","Send OpenPGP-Signed") ),
+                                                           KGuiItem( i18nc("@action:button","Send S/MIME-Signed") ),
+                                                           QLatin1String("uiserver-sender-ask-protocol") ) == KMessageBox::Yes
+                            ? GpgME::OpenPGP
+                            : GpgME::CMS ;
+                    else
+                        proto =
+                            KMessageBox::questionYesNo( 0, i18nc("@info",
+                                                                 "<para>The sender address <email>%1</email> matches more than one cryptographic format.</para>"
+                                                                 "<para>Which format do you want to use?</para>", email ),
+                                                        i18nc("@title","Format Choice"),
+                                                        KGuiItem( i18nc("@action:button","Send OpenPGP-Signed") ),
+                                                        KGuiItem( i18nc("@action:button","Send S/MIME-Signed") ),
+                                                        QLatin1String("uiserver-sender-ask-protocol") ) == KMessageBox::Yes
+                            ? GpgME::OpenPGP
+                            : GpgME::CMS ;
+                }
             conn.bias = proto;
             switch ( proto ) {
             case GpgME::OpenPGP:
@@ -1418,22 +1469,7 @@
 void AssuanCommand::doApplyWindowID( QWidget * widget ) const {
     if ( !widget || !hasOption( "window-id" ) )
         return;
-    const QString winIdStr = option("window-id").toString();
-    bool ok = false;
-#ifdef Q_OS_WIN32
-    const WId wid = reinterpret_cast<WId>( winIdStr.toULongLong( &ok, 16 ) );
-#else
-    const WId wid = static_cast<WId>( winIdStr.toULongLong( &ok, 16 ) );
-#endif
-    if ( !ok ) {
-        qDebug() << "window-id value" << wid << "doesn't look like a number";
-        return;
-    }
-    if ( QWidget * pw = QWidget::find( wid ) )
-        widget->setParent( pw, widget->windowFlags() );
-    else {
-        KWindowSystem::setMainWindow( widget, wid );
-    }
+    apply_window_id( widget, option("window-id").toString() );
 }
 
 static QString commonPrefix( const QString & s1, const QString & s2 ) {
--- kleopatra/uiserver/encryptcommand.cpp	
+++ kleopatra/uiserver/encryptcommand.cpp	
@@ -169,12 +169,9 @@
 
     try {
         const QString sessionTitle = q->sessionTitle();
-        if ( !sessionTitle.isNull() ) {
+        if ( !sessionTitle.isEmpty() )
             Q_FOREACH ( const shared_ptr<Input> & i, q->inputs() )
                 i->setLabel( sessionTitle );
-            Q_FOREACH ( const shared_ptr<Output> & i, q->outputs() )
-                i->setLabel( sessionTitle );
-        }
 
         cont->setInputsAndOutputs( q->inputs(), q->outputs() );
         cont->start();
--- kleopatra/main.cpp	
+++ kleopatra/main.cpp	
@@ -80,6 +80,8 @@
 
 using namespace boost;
 
+static const int SPLASHSCREEN_TIMEOUT = 5000; // 5s
+
 namespace {
     template <typename T>
     boost::shared_ptr<T> make_shared_ptr( T * t ) {
@@ -87,6 +89,28 @@
     }
 }
 
+class SplashScreen : public KSplashScreen {
+    QBasicTimer m_timer;
+public:
+    SplashScreen()
+        : KSplashScreen( UserIcon( "kleopatra_splashscreen" ), Qt::WindowStaysOnTopHint ),
+          m_timer()
+    {
+        m_timer.start( SPLASHSCREEN_TIMEOUT, this );
+    }
+
+protected:
+    void timerEvent( QTimerEvent * ev ) {
+        if ( ev->timerId() == m_timer.timerId() ) {
+            m_timer.stop();
+            hide();
+        } else {
+            KSplashScreen::timerEvent( ev );
+        }
+    }
+          
+};
+
 static bool selfCheck( KSplashScreen & splash ) {
     splash.showMessage( i18n("Performing Self-Check...") );
     Kleo::Commands::SelfTestCommand cmd( 0 );
@@ -140,7 +164,7 @@
 
   KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
-  KSplashScreen splash( UserIcon( "kleopatra_splashscreen" ), Qt::WindowStaysOnTopHint );
+  SplashScreen splash;
 
   int rc;
 #ifdef HAVE_USABLE_ASSUAN
--- kleopatra/CMakeLists.txt	
+++ kleopatra/CMakeLists.txt	
@@ -2,7 +2,7 @@
 
 include(MacroOptionalAddSubdirectory)
 
-set( kleopatra_version 2.0.0 )
+set( kleopatra_version 2.0.3 )
 if ( FALSE )
 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn")
   if ( NOT KdeSubversion_FOUND )
--- kleopatra/crypto/gui/signingcertificateselectionwidget.ui	
+++ kleopatra/crypto/gui/signingcertificateselectionwidget.ui	
@@ -11,7 +11,7 @@
   </property>
   <layout class="QGridLayout" >
    <item row="0" column="0" >
-    <widget class="QLabel" name="label" >
+    <widget class="QLabel" name="pgpLabel" >
      <property name="text" >
       <string>OpenPGP Signing Certificate</string>
      </property>
@@ -21,7 +21,7 @@
     <widget class="QComboBox" name="pgpCombo" />
    </item>
    <item row="1" column="0" >
-    <widget class="QLabel" name="label_2" >
+    <widget class="QLabel" name="cmsLabel" >
      <property name="text" >
       <string>S/MIME Signing Certificate</string>
      </property>
--- kleopatra/crypto/gui/signerresolvepage.cpp	
+++ kleopatra/crypto/gui/signerresolvepage.cpp	
@@ -379,6 +379,7 @@
     const QString customTitle = validator->customWindowTitle();
     if ( !customTitle.isEmpty() )
         emit q->windowTitleChanged( customTitle );
+    selectCertificatesButton->setEnabled(signingProtocolSelectionWidget->checkedProtocols().size()>0);
 }
 
 
@@ -434,6 +435,7 @@
 void SignerResolvePage::Private::selectCertificates()
 {
     QPointer<SigningCertificateSelectionDialog> dlg = new SigningCertificateSelectionDialog( q );
+    dlg->setAllowedProtocols( QVector<Protocol>::fromStdVector(signingProtocolSelectionWidget->checkedProtocols() ) );
     if ( dlg->exec() == QDialog::Accepted && dlg )
     {
         const QMap<Protocol, Key> certs = dlg->selectedCertificates();
--- kleopatra/crypto/gui/signingcertificateselectiondialog.h	
+++ kleopatra/crypto/gui/signingcertificateselectiondialog.h	
@@ -33,7 +33,7 @@
 #define __KLEOPATRA_CRYPTO_GUI_SIGNINGCERTIFICATESELECTIONDIALOG_H__
 
 #include <KDialog>
-    
+
 #include <gpgme++/key.h>
 
 #include <utils/pimpl_ptr.h>
@@ -49,12 +49,13 @@
             public:
         explicit SigningCertificateSelectionDialog( QWidget * parent=0, Qt::WFlags f=0 );
         ~SigningCertificateSelectionDialog();
-        
+
+        void setAllowedProtocols( const QVector<GpgME::Protocol>& allowedProtocols );
         void setSelectedCertificates( const QMap<GpgME::Protocol, GpgME::Key>& certificates );
         QMap<GpgME::Protocol, GpgME::Key> selectedCertificates() const;
 
         bool rememberAsDefault() const;
-        
+
     private:
         class Private;
         kdtools::pimpl_ptr<Private> d;
@@ -65,4 +66,4 @@
 }
 
 #endif // __KLEOPATRA_CRYPTO_GUI_SIGNINGCERTIFICATESELECTIONDIALOG_H__
- 
+
--- kleopatra/crypto/gui/objectspage.cpp	
+++ kleopatra/crypto/gui/objectspage.cpp	
@@ -96,7 +96,7 @@
 void ObjectsPage::Private::add()
 {
     const QString fname = QFileDialog::getOpenFileName( q, i18n( "Select File" ) );
-    if ( fname.isNull() )
+    if ( fname.isEmpty() )
         return;
     addFile( QFileInfo( fname ) );
     emit q->completeChanged();
--- kleopatra/crypto/gui/signingcertificateselectiondialog.cpp	
+++ kleopatra/crypto/gui/signingcertificateselectiondialog.cpp	
@@ -72,7 +72,7 @@
     q->setWindowTitle( i18n( "Select Signing Certificates" ) );
     QWidget* main = new QWidget( q );
     ui.setupUi( main );
-    q->setMainWidget( main ); 
+    q->setMainWidget( main );
     addCandidates( GpgME::CMS, ui.cmsCombo );
     addCandidates( GpgME::OpenPGP, ui.pgpCombo );
     ui.rememberCO->setChecked( true );
@@ -114,7 +114,7 @@
 {
     const std::vector<GpgME::Key> keys = candidates( prot );
     Q_FOREACH( const GpgME::Key& i, keys )
-        combo->addItem( Formatting::formatForComboBox( i ), 
+        combo->addItem( Formatting::formatForComboBox( i ),
                         QByteArray( i.primaryFingerprint() ) );
 }
 
@@ -122,7 +122,7 @@
 QMap<GpgME::Protocol, GpgME::Key> SigningCertificateSelectionDialog::selectedCertificates() const
 {
     QMap<GpgME::Protocol, GpgME::Key> res;
-    
+
     const QByteArray pgpfpr = d->ui.pgpCombo->itemData( d->ui.pgpCombo->currentIndex() ).toByteArray();
     res.insert( GpgME::OpenPGP, KeyCache::instance()->findByFingerprint( pgpfpr.constData() ) );
     const QByteArray cmsfpr = d->ui.cmsCombo->itemData( d->ui.cmsCombo->currentIndex() ).toByteArray();
@@ -134,3 +134,16 @@
 {
     return d->ui.rememberCO->isChecked();
 }
+
+void SigningCertificateSelectionDialog::setAllowedProtocols( const QVector<GpgME::Protocol>& allowedProtocols )
+{
+    assert( allowedProtocols.size() >= 1 );
+    if ( !allowedProtocols.contains( GpgME::OpenPGP ) ) {
+        d->ui.pgpLabel->hide();
+        d->ui.pgpCombo->hide();
+    }
+    if ( !allowedProtocols.contains( GpgME::CMS ) ) {
+        d->ui.cmsLabel->hide();
+        d->ui.cmsCombo->hide();
+    }
+}
--- kleopatra/crypto/decryptverifytask.cpp	
+++ kleopatra/crypto/decryptverifytask.cpp	
@@ -215,7 +215,7 @@
 }
 
 static QString renderKeyLink( const QString & fpr, const QString & text ) {
-    return QString::fromLatin1( "<a href=\"key:%1\">%2</a>" ).arg( fpr ).arg( text );
+    return QString::fromLatin1( "<a href=\"key:%1\">%2</a>" ).arg( fpr, text );
 }
 
 static QString renderKey( const Key & key ) {
@@ -228,7 +228,7 @@
     if ( key.isNull() )
         return i18n( "Unknown key" );
     const QString email = Formatting::prettyEMail( key );
-    const QString user = !email.isNull() ? email : Formatting::prettyName( key );
+    const QString user = !email.isEmpty() ? email : Formatting::prettyName( key );
     return renderKeyLink( key.primaryFingerprint(), user );
 }
 
@@ -332,7 +332,8 @@
     const Mailbox informativeSender;
     const std::vector<Key> signers;
     bool hasInformativeSender() const { return !informativeSender.addrSpec().isEmpty(); }
-    bool conflicts() const { return hasInformativeSender() && !keysContainMailbox( signers, informativeSender ); }
+    bool conflicts() const { return hasInformativeSender() && hasKeys() && !keysContainMailbox( signers, informativeSender ); }
+    bool hasKeys() const { return kdtools::any( signers, !bind( &Key::isNull, _1 ) ); }
     std::vector<Mailbox> signerMailboxes() const {return extractMailboxes( signers ); }
 };
 
@@ -386,12 +387,11 @@
     if ( sigs.size() == 1 ) {
         const Key key = DecryptVerifyResult::keyForSignature( sigs[0], signers );
         if ( key.isNull() )
-            text = i18n( "<b>Signature is valid.</b>" );
-        else
-            text = i18n( "<b>Signed by %1</b>", renderKeyEMailOnlyNameAsFallback( key ) );
+            return i18n( "<b>Signature is valid.</b>" );
+        text = i18n( "<b>Signed by %1</b>", renderKeyEMailOnlyNameAsFallback( key ) );
         if ( info.conflicts() )
             text += i18n( "<br/><b>Warning:</b> The sender's mail address is not stored in the %1 used for signing.",
-                          key.isNull() ? i18n( "certificate" ) : renderKeyLink( key.primaryFingerprint(), i18n( "certificate" ) ) );
+                          renderKeyLink( key.primaryFingerprint(), i18n( "certificate" ) ) );
     }
     else {
         text = i18np("<b>Valid signature.</b>", "<b>%1 valid signatures.</b>", sigs.size() );
@@ -425,20 +425,8 @@
         return text + formatValidSignatureWithTrustLevel( key, !id.isNull() ? id : key.userID( 0 ) ); // ### TODO handle key.isNull()?
     }
     if ( red )
-        if ( key.isNull() )
-            if ( const char * fpr = sig.fingerprint() )
-                return text + i18n("Bad signature by unknown key %1.", renderFingerprint( fpr ) );
-            else
-                return text + i18n("Bad signature by an unknown key." );
-        else
-            return text + i18n("Bad signature by %1.", renderKey( key ) );
-    if ( key.isNull() )
-        if ( const char * fpr = sig.fingerprint() )
-            return text + i18n("Invalid signature by unknown key %1: %2", renderFingerprint( fpr ), signatureSummaryToString( sig.summary() ) );
-        else
-            return text + i18n("Invalid signature by an unknown key: %1", signatureSummaryToString( sig.summary() ) );
-    else
-        return text + i18n("Invalid signature by %1: %2", renderKey( key ), signatureSummaryToString( sig.summary() ) );
+        return text + i18n("The signature is bad.");
+    return text + i18n("The signature is invalid: %1", signatureSummaryToString( sig.summary() ) );
 }
 
 static QStringList format( const std::vector<Mailbox> & mbxs ) {
--- kleopatra/dialogs/exportsecretkeydialog.cpp	
+++ kleopatra/dialogs/exportsecretkeydialog.cpp	
@@ -95,7 +95,7 @@
         const bool armor = q->useArmor();
 
         static const char * extensions[] = {
-            ".gpg", ".asc", ".der", ".pem"
+            ".gpg", ".asc", ".p12", ".pem"
         };
         const unsigned int idx = 2*x509+armor;
         const char * const extension = extensions[idx];
@@ -135,7 +135,7 @@
 
             outputFileFR->setExistingOnly( false );
             outputFileFR->setFilter( QDir::Files );
-            outputFileFR->setNameFilter( i18n("Secret Key Files (*.pem *.der *.gpg *.asc)") );
+            outputFileFR->setNameFilter( i18n("Secret Key Files (*.pem *.p12 *.gpg *.asc)") );
 
             for ( unsigned int i = 0 ; i < numCharsets ; ++i )
                 charsetCB->addItem( QString::fromLatin1( charsets[i] ) );
--- kleopatra/commands/lookupcertificatescommand.cpp	
+++ kleopatra/commands/lookupcertificatescommand.cpp	
@@ -283,6 +283,17 @@
 void LookupCertificatesCommand::Private::startDownloadJob( const Key & key ) {
     if ( key.isNull() )
         return;
+
+    QStringList fprs;
+    const char * const fpr  = key.primaryFingerprint();
+    const char * const kid  = key.keyID();
+    if ( fpr && *fpr )
+        fprs.push_back( QString::fromLatin1( fpr ) );
+    else if ( kid && *kid )
+        fprs.push_back( QString::fromLatin1( kid ) );
+    else
+        return;
+
     DownloadJob * const dlj = createDownloadJob( key.protocol() );
     if ( !dlj )
         return;
@@ -292,7 +303,8 @@
              : SLOT(slotOpenPGPDownloadResult(GpgME::Error,QByteArray)) );
     DownloadVariables var;
     var.key = key;
-    if ( const Error err = dlj->start( QStringList( key.primaryFingerprint() ) ) )
+
+    if ( const Error err = dlj->start( fprs ) )
         var.error = err;
     else
         var.job = dlj;
--- kleopatra/commands/changepassphrasecommand.cpp	
+++ kleopatra/commands/changepassphrasecommand.cpp	
@@ -70,7 +70,7 @@
 QStringList ChangePassphraseCommand::arguments() const {
     const Key key = d->key();
     if ( key.protocol() == OpenPGP )
-        return QStringList() << gpgPath() << "--batch" << "--edit-key" << key.primaryFingerprint() << "passwd";
+        return QStringList() << gpgPath() << "--batch" << "--edit-key" << key.primaryFingerprint() << "passwd" << "save" ;
     else
         return QStringList() << gpgSmPath() << "--passwd" << key.primaryFingerprint();
 }
--- kleopatra/commands/importcertificatefromfilecommand.cpp	
+++ kleopatra/commands/importcertificatefromfilecommand.cpp	
@@ -159,8 +159,8 @@
 }
 
 static QStringList get_file_name( QWidget * parent ) {
-    const QString certificateFilter = i18n("Certificates (*.asc *.cer *.cert *.crt *.der *.pem *.der *.p7c *.p12 *.pfx)");
-    const QString anyFilesFilter = i18n("Any files (*)" );
+    const QString certificateFilter = i18n("Certificates") + " (*.asc *.cer *.cert *.crt *.der *.pem *.gpg *.p7c *.p12 *.pfx)";
+    const QString anyFilesFilter = i18n("Any files") + " (*)";
     QString previousDir;
     if ( const KSharedConfig::Ptr config = KGlobal::config() ) {
         const KConfigGroup group( config, "Import Certificate" );
--- kleopatra/commands/exportcertificatecommand.cpp	
+++ kleopatra/commands/exportcertificatecommand.cpp	
@@ -79,7 +79,6 @@
     void finishedIfLastJob();
 
 private:
-    bool textArmor;
     QMap<GpgME::Protocol, QString> fileNames;
     uint jobsPending;
     QMap<QObject*, QString> outFileForSender;
@@ -95,7 +94,6 @@
 
 ExportCertificateCommand::Private::Private( ExportCertificateCommand * qq, KeyListController * c )
     : Command::Private( qq, c ),
-      textArmor( true ),
       jobsPending( 0 )
 {
     
@@ -200,9 +198,11 @@
     const QString fname = QFileDialog::getSaveFileName( parentWidgetOrView(),
                                                         i18n( "Export Certificates" ), 
                                                         QString(), 
-                                                        protocol == GpgME::OpenPGP ? i18n( "OpenPGP Certificates (.asc)" ) : i18n( "S/MIME Certificates (.pem)" ) );
+                                                        protocol == GpgME::OpenPGP
+                                                        ? i18n( "OpenPGP Certificates" ) + " (*.asc *.gpg)"
+                                                        : i18n( "S/MIME Certificates" )  + " (*.pem *.der)" );
     fileNames[protocol] = fname;
-    return !fname.isNull();
+    return !fname.isEmpty();
 }
 
 void ExportCertificateCommand::Private::startExportJob( GpgME::Protocol protocol, const std::vector<Key>& keys )
@@ -211,7 +211,11 @@
 
     const CryptoBackend::Protocol* const backend = CryptoBackendFactory::instance()->protocol( protocol );
     assert( backend );
-    std::auto_ptr<ExportJob> job( backend->publicKeyExportJob( /*armor=*/true ) );
+    const QString fileName = fileNames[protocol];
+    const bool binary = protocol == GpgME::OpenPGP
+        ? fileName.endsWith( ".gpg", Qt::CaseInsensitive )
+        : fileName.endsWith( ".der", Qt::CaseInsensitive ) ;
+    std::auto_ptr<ExportJob> job( backend->publicKeyExportJob( !binary ) );
     assert( job.get() );
 
     connect( job.get(), SIGNAL(result(GpgME::Error,QByteArray)),
@@ -234,7 +238,7 @@
     ++jobsPending;
     const QPointer<ExportJob> exportJob( job.release() );
 
-    outFileForSender[exportJob] = fileNames[protocol];
+    outFileForSender[exportJob] = fileName;
     ( protocol == CMS ? cmsJob : pgpJob ) = exportJob;
 }
 
@@ -259,6 +263,19 @@
         finished();
 }
 
+static bool write_complete( QIODevice & iod, const QByteArray & data ) {
+    qint64 total = 0;
+    qint64 toWrite = data.size();
+    while ( total < toWrite ) {
+        const qint64 written = iod.write( data.data() + total, toWrite );
+        if ( written < 0 )
+            return false;
+        total += written;
+        toWrite -= written;
+    }
+    return true;
+}
+
 void ExportCertificateCommand::Private::exportResult( const GpgME::Error& err, const QByteArray& data )
 {
     assert( jobsPending > 0 );
@@ -282,18 +299,9 @@
         finishedIfLastJob();
         return;
     }
-    if ( textArmor )
-    {
-        QTextStream out( &savefile );
-        out << data;
-    }
-    else
-    {
-        QDataStream out( &savefile );
-        out << data;
-    }
 
-    if ( !savefile.finalize() )
+    if ( !write_complete( savefile, data ) ||
+         !savefile.finalize() )
         KMessageBox::error( parentWidgetOrView(), writeErrorMsg, errorCaption );
     finishedIfLastJob();
 }
--- kmail/kmfoldermaildir.cpp	
+++ kmail/kmfoldermaildir.cpp	
@@ -717,6 +717,7 @@
       dateStr = dateStr.trimmed();
       if (!dateStr.isEmpty())
         mi->setDate(dateStr.constData());
+      uidStr = uidStr.trimmed();
       if ( !uidStr.isEmpty() )
          mi->setUID( uidStr.toULong() );
       mi->setDirty(false);

Property changes on: .
___________________________________________________________________
Deleted: svn:mergeinfo
Added: svn:externals
   + 


openSUSE Build Service is sponsored by