Bug 85539

Summary: secrets of address completion
Product: [Applications] kmail Reporter: Ferdinand Gassauer <gassauer>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: greg.martyn, thomas.braun
Priority: NOR    
Version: 1.6.82   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: move recent address to begin

Description Ferdinand Gassauer 2004-07-20 09:36:04 UTC
Version:           1.6.82 (using KDE 3.2.3, compiled sources)
Compiler:          gcc version 3.2.2
OS:                Linux (i686) release 2.4.19-64GB-SMP

Hi!
I frequently encounter the situation, that an address, which has been available a few days before, isn't available for autocompletion any more.

As it is a very frequently used address, it shouldn't drop out of the list in any case.

BTW I recompile kmail CVS_HEAD every night.

cu
ferdinand
Comment 1 Ismail Donmez 2004-07-22 20:23:37 UTC
This looks like a normal bug not a wishlist item.
Comment 2 ian 2005-02-10 10:58:11 UTC
This bug still exists in KMail 1.7.2.  If the address isn't in the addres book or on an ldap server or something like that, after a few days the address is no longer available for autocompletion.
Comment 3 David Faure 2005-02-10 15:48:14 UTC
> This bug still exists in KMail 1.7.2.  If the address isn't in the addres book or on an ldap server or something like that, after a few days the address is no longer available for autocompletion.

The "recent addresses" list stores 40 addresses by default, you can find them in ~/.kde/share/config/kmailrc, under [General],
as "Recent Addresses=..."
Can you check that there are 40 more recent addresses there, which would explain why the
address you're expecting was pushed out?

Seems it's the last address from the list that gets removed when adding a 41st address.
New addresses are added in front of the list, so that part looks fine.

This number is configurable: you can add in that group a line saying
Maximum Recent Addresses=300
while kmail is *not* running.

I'm not saying there's no bug, merely providing hints on how to track it down, if there's one.

Comment 4 Ferdinand Gassauer 2005-02-10 18:18:08 UTC
So what you are saying is that a frequently used address can move to the end of the list if 40 other adresses are used.

IMHO a better solution would be to remove every address of an email from the list and add it immediately to the beginning of the list again.
this way frequently used addresses will never move to the end and eventually be eliminated.
Comment 5 Ferdinand Gassauer 2006-01-11 13:19:45 UTC
Hmm! 
May be someone could take care of that?
it's sort of a thing nobody will understand why it happens.
Comment 6 Maciej Pilichowski 2006-04-25 18:26:02 UTC
I think that should be introduced proper address history management. I mean options like "number of addresses to remember", or "autocompletion: sort alphabetically, by usage frequency", plus population history from folder, etc etc etc.
Comment 7 Thomas Braun 2007-05-09 12:47:47 UTC
A short term solution would be just to increase the default number of recent addresses.
40 is really low, something like 300 or 500 sounds better.

Thomas
Comment 8 Christian Schaarschmidt 2007-05-09 20:50:56 UTC
is this a dup of Bug 47333 ?
Comment 9 Ferdinand Gassauer 2007-05-09 22:09:33 UTC
NO to http://bugs.kde.org/show_bug.cgi?id=85539#c8
http://bugs.kde.org/show_bug.cgi?id=47333 is a valid feature request, this one is a bug, because it does not keep frequently used addresses but in contrary "looses" them instead of not used ones.
Comment 10 Christian Schaarschmidt 2007-05-10 23:32:32 UTC
Created attachment 20530 [details]
move recent address to begin 

there is another bug, this method is not working for multiple addresses. I'll
commit to kdepim+ once I have fixed that too
Comment 11 Christian Schaarschmidt 2007-05-11 17:43:24 UTC
SVN commit 663553 by schaarsc:

- place latest address at beginning of recent address list
- handle multiple addresses properly
CCBUG: 85539


 M  +24 -14    recentaddresses.cpp  


--- branches/work/kdepim-3.5.5+/libkdepim/recentaddresses.cpp #663552:663553
@@ -28,6 +28,7 @@
  *  your version.
  */
 #include "recentaddresses.h"
+#include "libemailfunctions/email.h"
 
 #include <kstaticdeleter.h>
 #include <kconfig.h>
@@ -98,24 +99,33 @@
 
 void RecentAddresses::add( const QString& entry )
 {
-    if ( !entry.isEmpty() && m_maxCount > 0 ) {
-        QString email;
-        QString fullName;
-        KABC::Addressee addr;
+  if ( !entry.isEmpty() && m_maxCount > 0 ) {
+    QStringList list = KPIM::splitEmailAddrList( entry );
+    for( QStringList::const_iterator e_it = list.begin(); e_it != list.end(); ++e_it ) {
+      KPIM::EmailParseResult errorCode = KPIM::isValidEmailAddress( *e_it );
+      if ( errorCode != KPIM::AddressOk ) 
+        continue;
+      QString email;
+      QString fullName;
+      KABC::Addressee addr;
 
-        KABC::Addressee::parseEmailAddress( entry, fullName, email );
+      KABC::Addressee::parseEmailAddress( *e_it, fullName, email );
 
-        for ( KABC::Addressee::List::Iterator it = m_addresseeList.begin();
-              it != m_addresseeList.end(); ++it )
-        {
-            if ( email == (*it).preferredEmail() )
-                return;//already inside
+      for ( KABC::Addressee::List::Iterator it = m_addresseeList.begin();
+          it != m_addresseeList.end(); ++it )
+      {
+        if ( email == (*it).preferredEmail() ) {
+          //already inside, remove it here and add it later at pos==1
+          m_addresseeList.remove( it );
+          break;
         }
-        addr.setNameFromString( fullName );
-        addr.insertEmail( email, true );
-        m_addresseeList.prepend( addr );
-        adjustSize();
+      }
+      addr.setNameFromString( fullName );
+      addr.insertEmail( email, true );
+      m_addresseeList.prepend( addr );
+      adjustSize();
     }
+  }
 }
 
 void RecentAddresses::setMaxCount( int count )
Comment 12 Christian Schaarschmidt 2007-06-05 21:20:18 UTC
SVN commit 671909 by schaarsc:

port r663553
- place latest address at beginning of recent address list
- handle multiple addresses properly
BUG: 85539


 M  +24 -14    recentaddresses.cpp  


--- branches/KDE/3.5/kdepim/libkdepim/recentaddresses.cpp #671908:671909
@@ -28,6 +28,7 @@
  *  your version.
  */
 #include "recentaddresses.h"
+#include "libemailfunctions/email.h"
 
 #include <kstaticdeleter.h>
 #include <kconfig.h>
@@ -98,24 +99,33 @@
 
 void RecentAddresses::add( const QString& entry )
 {
-    if ( !entry.isEmpty() && m_maxCount > 0 ) {
-        QString email;
-        QString fullName;
-        KABC::Addressee addr;
+  if ( !entry.isEmpty() && m_maxCount > 0 ) {
+    QStringList list = KPIM::splitEmailAddrList( entry );
+    for( QStringList::const_iterator e_it = list.begin(); e_it != list.end(); ++e_it ) {
+      KPIM::EmailParseResult errorCode = KPIM::isValidEmailAddress( *e_it );
+      if ( errorCode != KPIM::AddressOk ) 
+        continue;
+      QString email;
+      QString fullName;
+      KABC::Addressee addr;
 
-        KABC::Addressee::parseEmailAddress( entry, fullName, email );
+      KABC::Addressee::parseEmailAddress( *e_it, fullName, email );
 
-        for ( KABC::Addressee::List::Iterator it = m_addresseeList.begin();
-              it != m_addresseeList.end(); ++it )
-        {
-            if ( email == (*it).preferredEmail() )
-                return;//already inside
+      for ( KABC::Addressee::List::Iterator it = m_addresseeList.begin();
+          it != m_addresseeList.end(); ++it )
+      {
+        if ( email == (*it).preferredEmail() ) {
+          //already inside, remove it here and add it later at pos==1
+          m_addresseeList.remove( it );
+          break;
         }
-        addr.setNameFromString( fullName );
-        addr.insertEmail( email, true );
-        m_addresseeList.prepend( addr );
-        adjustSize();
+      }
+      addr.setNameFromString( fullName );
+      addr.insertEmail( email, true );
+      m_addresseeList.prepend( addr );
+      adjustSize();
     }
+  }
 }
 
 void RecentAddresses::setMaxCount( int count )
Comment 13 Ferdinand Gassauer 2007-06-05 22:09:34 UTC
just want to make sure that this fix does not break the meanwhile alphabetically sorted list.
one thing is the storage of the latest addresses, other thing is to display them alphabetically