Bug 88369

Summary: when delivery-method is renamed this is not populated
Product: [Unmaintained] kmail Reporter: S. Burmeister <sven.burmeister>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Patch to update idents with renamed transports

Description S. Burmeister 2004-08-29 11:08:27 UTC
Version:            (using KDE KDE 3.3.0)
OS:                Linux

When renaming a delivery-method this is not done for the identities that use it, as a result these use invalid delivery-methods.
Comment 1 Don Sanders 2004-09-01 09:21:00 UTC
I find this report to be unintelligible. Maybe if I spent 10 minutes trying to figure out what it meant I might be able to do it, but instead I will look/wait for a more intelligible report.

I don't mean to be rude here. It's just that I spent an hour working my way through 170 reports without finding a single one with any useful information.
Comment 2 S. Burmeister 2004-09-01 15:16:49 UTC
Am Mittwoch, 1. September 2004 09:21 schrieb Don Sanders:
> ------- Additional Comments From sanders kde org  2004-09-01 09:21 -------
> I find this report to be unintelligible. Maybe if I spent 10 minutes trying
> to figure out what it meant I might be able to do it, but instead I will
> look/wait for a more intelligible report.

1. Go to kmail configuration
1.1 In case you do not have set up a delivery method, do so, name it xyz
2. Go to identities configuration
3. Create an identity, name it itsme
4. Edit that identity
5. Go to its advanced tab
6. Find box for special delivery-method at the bottom of the tab
7. Activate special-delivery using the delivery-profile xyz
8. Close configuration

2nd Part
1. Open kmail configuration
2. Go to network
3. Rename delivery-method xyz to 000

3rd Part
1. Go to identities in kmail configuration
2. Edit the itsme identity
3. Go to the advanced tab
4. Look at that special-delivery method config at the bottom of the tab
5. Notice that it still states xyz although that delivery-method was renamed, 
hence this identity uses a non-existent delivery-method!

4th Part

Solution 1: (IMHO best)
When setting a delivery-method for an identity, kmail should not save its name 
but an ID. This way when renaming the delivery-method the ID stays the same 
and only the attribute name is changed. I think Mozilla does it this way.

Solution 2:
If a delivery-mehtod is renamed, mediate this to the identity using it, making 
it rename its setting too.

Solution 3:
Complain about identities using a non-existent delivery-method.

The reason why this bug is a problem is that if you send an email with kmail 
using a non-existing delivery-method, it does not send the email but does not 
complain either, so the user does not know why the emai is not send.

Comment 3 Don Sanders 2004-09-02 11:26:58 UTC
Thanks I can understand this now.

Comment 4 Matt Douhan 2005-05-21 22:38:35 UTC
In current HEAD / Trunk there is a sanity checker that automatically removes transports that no longer exists and resets them to useful values.
Can you please test if this problem still remains with current trunk/HEAD?
Comment 5 Matt Douhan 2006-11-05 19:51:39 UTC
Created attachment 18422 [details]
Patch to update idents with renamed transports

This patch updates all transports that used the original transport and sets it
to the new name thus keeping the integrity.
Comment 6 Allen Winter 2006-11-21 16:54:30 UTC
SVN commit 606743 by winterz:

Patch from Matt, fixes "when delivery-method is renamed this is not populated".
Approved by Till.  Thanks Matt.

CCMAIL: matt.douhan@kdemail.net
BUGS: 88369


 M  +20 -0     configuredialog.cpp  


--- branches/KDE/3.5/kdepim/kmail/configuredialog.cpp #606742:606743
@@ -841,6 +841,8 @@
   QListViewItem *item = mTransportList->selectedItem();
   if ( !item ) return;
 
+  const QString& originalTransport = item->text(0);
+
   QPtrListIterator<KMTransportInfo> it( mTransportInfoList );
   for ( it.toFirst() ; it.current() ; ++it )
     if ( (*it)->name == item->text(0) ) break;
@@ -869,6 +871,24 @@
   // and insert the new name at the position of the old in the list of
   // strings; then broadcast the new list:
   transportNames.insert( transportNames.at( entryLocation ), (*it)->name );
+  const QString& newTransportName = (*it)->name;
+
+  QStringList changedIdents;
+  KPIM::IdentityManager * im = kmkernel->identityManager();
+  for ( KPIM::IdentityManager::Iterator it = im->modifyBegin(); it != im->modifyEnd(); ++it ) {
+    if ( originalTransport == (*it).transport() ) {
+      (*it).setTransport( newTransportName );
+      changedIdents += (*it).identityName();
+    }
+  }
+
+  if ( !changedIdents.isEmpty() ) {
+    QString information = i18n( "This identity has been changed to use the modified transport:",
+                          "These %n identities have been changed to use the modified transport:",
+                          changedIdents.count() );
+    KMessageBox::informationList( this, information, changedIdents );
+  }
+
   emit transportListChanged( transportNames );
   emit changed( true );
 }