https://bugs.kde.org/show_bug.cgi?id=259054


Tobias Koenig <to...@kde.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #1 from Tobias Koenig <tokoe kde org>  2010-12-31 13:16:32 ---
commit 54bb70b59ffa11c80a2cc9bac6e217932ce3a6ed
branch master
Author: Tobias Koenig <to...@kde.org>
Date:   Fri Dec 31 13:19:25 2010 +0100

    Store the transport id in identity transport field

    Storing the transport name in the identity transport
    field causes trouble if the name is empty.

    BUG: 259054

diff --git a/kalarm/kamail.cpp b/kalarm/kamail.cpp
index 9e25a5f..8c1a159 100644
--- a/kalarm/kamail.cpp
+++ b/kalarm/kamail.cpp
@@ -188,7 +188,8 @@ int KAMail::send(JobData& jobdata, QStringList& errmsgs)
     else
     {
         kDebug() << "Sending via KDE";
-        transport = manager->transportByName(identity.transport(), true);
+        const int transportId = identity.transport().isEmpty() ? -1 :
identity.transport().toInt();
+        transport = manager->transportById( transportId, true );
         if (!transport)
         {
             kError() << "No mail transport found for identity" <<
identity.identityName() << "uoid" << identity.uoid();
diff --git a/kmail/identitydialog.cpp b/kmail/identitydialog.cpp
index 96549d2..0535966 100644
--- a/kmail/identitydialog.cpp
+++ b/kmail/identitydialog.cpp
@@ -730,11 +730,10 @@ namespace KMail {
     // "Advanced" tab:
     mReplyToEdit->setText( ident.replyToAddr() );
     mBccEdit->setText( ident.bcc() );
-    QString transportName = ident.transport();
-    Transport *transport =
-              TransportManager::self()->transportByName( transportName, false
);
-    mTransportCheck->setChecked( transport != 0 );
-    mTransportCombo->setEnabled( transport != 0 );
+    const int transportId = ident.transport().isEmpty() ? -1 :
ident.transport().toInt();
+    const Transport *transport = TransportManager::self()->transportById(
transportId, true );
+    mTransportCheck->setChecked( transportId != -1 );
+    mTransportCombo->setEnabled( transportId != -1 );
     if ( transport )
       mTransportCombo->setCurrentTransport( transport->id() );
     mDictionaryCombo->setCurrentByDictionaryName( ident.dictionary() );
@@ -810,8 +809,8 @@ namespace KMail {
     // "Advanced" tab:
     ident.setReplyToAddr( mReplyToEdit->text() );
     ident.setBcc( mBccEdit->text() );
-    ident.setTransport( ( mTransportCheck->isChecked() ) ?
-                          mTransportCombo->currentText() : QString() );
+    ident.setTransport( mTransportCheck->isChecked() ? QString::number(
mTransportCombo->currentTransportId() )
+                                                     : QString() );
     ident.setDictionary( mDictionaryCombo->currentDictionaryName() );
     Akonadi::Collection collection = mFccCombo->folderCollection();
     if ( collection.isValid() ) {
diff --git a/kmail/kmcomposewin.cpp b/kmail/kmcomposewin.cpp
index 06013b2..17af19a 100644
--- a/kmail/kmcomposewin.cpp
+++ b/kmail/kmcomposewin.cpp
@@ -547,7 +547,7 @@ void KMComposeWin::readConfig( bool reload /* = false */ )
   }
   mBtnFcc->setChecked( GlobalSettings::self()->stickyFcc() );
   mBtnTransport->setChecked( GlobalSettings::self()->stickyTransport() );
-  QString currentTransport = GlobalSettings::self()->currentTransport();
+  const int currentTransport =
GlobalSettings::self()->currentTransport().isEmpty() ? -1 :
GlobalSettings::self()->currentTransport().toInt();
   mBtnDictionary->setChecked( GlobalSettings::self()->stickyDictionary() );

   mEdtFrom->setCompletionMode(
(KGlobalSettings::Completion)GlobalSettings::self()->completionMode() );
@@ -591,9 +591,8 @@ void KMComposeWin::readConfig( bool reload /* = false */ )
   const KPIMIdentities::Identity & ident =
     kmkernel->identityManager()->identityForUoid( mId );

-  if ( mBtnTransport->isChecked() && !currentTransport.isEmpty() ) {
-    Transport *transport =
-        TransportManager::self()->transportByName( currentTransport );
+  if ( mBtnTransport->isChecked() && currentTransport != -1 ) {
+    const Transport *transport = TransportManager::self()->transportById(
currentTransport );
     if ( transport )
       mComposerBase->transportComboBox()->setCurrentTransport( transport->id()
);
   }
@@ -1043,17 +1042,16 @@ void KMComposeWin::setQuotePrefix( uint uoid )

//-----------------------------------------------------------------------------
 void KMComposeWin::getTransportMenu()
 {
-  QStringList availTransports;
-
   mActNowMenu->clear();
   mActLaterMenu->clear();
-  availTransports = TransportManager::self()->transportNames();
-  QStringList::Iterator it;
-  for ( it = availTransports.begin(); it != availTransports.end() ; ++it ) {
-    QAction *action1 = new QAction( (*it).replace( '&', "&&" ), mActNowMenu );
-    QAction *action2 = new QAction( (*it).replace( '&', "&&" ), mActLaterMenu
);
-    action1->setData( TransportManager::self()->transportByName( *it )->id()
);
-    action2->setData( TransportManager::self()->transportByName( *it )->id()
);
+
+  const QList<Transport*> transports = TransportManager::self()->transports();
+  foreach ( Transport *transport, transports ) {
+    const QString name = transport->name().replace( '&', "&&" );
+    QAction *action1 = new QAction( name, mActNowMenu );
+    QAction *action2 = new QAction( name, mActLaterMenu );
+    action1->setData( transport->id() );
+    action2->setData( transport->id() );
     mActNowMenu->addAction( action1 );
     mActLaterMenu->addAction( action2 );
   }
@@ -2789,16 +2787,13 @@ void KMComposeWin::slotIdentityChanged( uint uoid, bool
initalChange )
   // If the transport sticky checkbox is not checked, set the transport
   // from the new identity
   if ( !mBtnTransport->isChecked() && !mIgnoreStickyFields ) {
-    QString transportName = ident.transport();
-    Transport *transport =
-        TransportManager::self()->transportByName( transportName, false );
+    const int transportId = ident.transport().isEmpty() ? -1 :
ident.transport().toInt();
+    const Transport *transport = TransportManager::self()->transportById(
transportId, true );
     if ( !transport ) {
       mMsg->removeHeader( "X-KMail-Transport" );
-      mComposerBase->transportComboBox()->setCurrentTransport(
-                               TransportManager::self()->defaultTransportId()
);
-    }
-    else {
-      KMime::Headers::Generic *header = new KMime::Headers::Generic(
"X-KMail-Transport", mMsg.get(), transportName, "utf-8" );
+      mComposerBase->transportComboBox()->setCurrentTransport(
TransportManager::self()->defaultTransportId() );
+    } else {
+      KMime::Headers::Generic *header = new KMime::Headers::Generic(
"X-KMail-Transport", mMsg.get(), QString::number( transport->id() ), "utf-8" );
       mMsg->setHeader( header );
       mComposerBase->transportComboBox()->setCurrentTransport( transport->id()
);
     }
diff --git a/messagecomposer/akonadisender.cpp
b/messagecomposer/akonadisender.cpp
index be01f98..fd85e41 100644
--- a/messagecomposer/akonadisender.cpp
+++ b/messagecomposer/akonadisender.cpp
@@ -125,19 +125,16 @@ void AkonadiSender::sendOrQueueMessage( const
KMime::Message::Ptr &message, Mess
   qjob->setMessage( message );

   // Get transport.
-  QString transportName = mCustomTransport;
-  kDebug() << "Custom transportName:" << mCustomTransport;
-  if( transportName.isEmpty() ) {
-    transportName = message->headerByType( "X-KMail-Transport"  ) ?
message->headerByType( "X-KMail-Transport" )->asUnicodeString() : QString();
-    kDebug() << "TransportName from headers:" << transportName;
-  }
-  if( transportName.isEmpty() ) {
-    transportName = TransportManager::self()->defaultTransportName();
-    kDebug() << "Default transport" <<
TransportManager::self()->defaultTransportName();
+  int transportId = -1;
+  if ( !mCustomTransport.isEmpty() ) {
+    transportId = TransportManager::self()->transportByName( mCustomTransport,
true )->id();
+  } else {
+    transportId = message->headerByType( "X-KMail-Transport"  ) ?
message->headerByType( "X-KMail-Transport" )->asUnicodeString().toInt() : -1;
   }
-  Transport *transport = TransportManager::self()->transportByName(
transportName );
+
+  const Transport *transport = TransportManager::self()->transportById(
transportId );
   Q_ASSERT( transport );
-  kDebug() << "Using transport (" << transportName << "," << transport->id()
<< ")";
+  kDebug() << "Using transport (" << transport->name() << "," <<
transport->id() << ")";
   qjob->transportAttribute().setTransportId( transport->id() );

   // if we want to manually queue it for sending later, then do it
diff --git a/messagecomposer/composerviewbase.cpp
b/messagecomposer/composerviewbase.cpp
index 68ce2dd..22020ac 100644
--- a/messagecomposer/composerviewbase.cpp
+++ b/messagecomposer/composerviewbase.cpp
@@ -178,15 +178,14 @@ void Message::ComposerViewBase::setMessage ( const
KMime::Message::Ptr& msg )
         it != ac.attachments().end() ; ++it ) {
     addAttachmentPart( *it );
   }
-  
-  QString transportName;
-  if( m_msg->headerByType( "X-KMail-Transport" ) )
-    transportName =
m_msg->headerByType("X-KMail-Transport")->asUnicodeString();
-  if ( !transportName.isEmpty() ) {
-    MailTransport::Transport *transport =
MailTransport::TransportManager::self()->transportByName( transportName );
-    if ( transport )
-      m_transport->setCurrentTransport( transport->id() );
-  }
+
+  int transportId = -1;
+  if ( m_msg->headerByType( "X-KMail-Transport" ) )
+    transportId = m_msg->headerByType( "X-KMail-Transport"
)->asUnicodeString().toInt();
+
+  const MailTransport::Transport *transport =
MailTransport::TransportManager::self()->transportById( transportId );
+  if ( transport )
+    m_transport->setCurrentTransport( transport->id() );

   // Set the HTML text and collect HTML images
   if ( isHTMLMail( m_msg.get() ) ) {

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Kdepim-bugs mailing list
Kdepim-bugs@kde.org
https://mail.kde.org/mailman/listinfo/kdepim-bugs

Reply via email to