[Bug 48461] kmail should remember smtp password

Allen Winter <[email protected]>
Newsgroups gmane.comp.kde.devel.kmail
Message-ID <[email protected]>
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=48461         
winter kde org changed:

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



------- Additional Comments From winter kde org  2007-04-14 16:07 -------
SVN commit 653892 by winterz:

merge SVN commit 633276 by winterz: 
 
 Make KMail remember the SMTP password. 
 Thanks for the patch Luigi. 
 
BUGS: 48461 
 



 M  +14 -0     kmsender.cpp  
 M  +2 -0      kmsender.h  


--- branches/KDE/3.5/kdepim/kmail/kmsender.cpp #653891:653892
 @ -707,6 +707,11  @
         mOutboxFolder->unGetMsg( mFailedMessages );
       mCurrentMsg = 0;
       mFailedMessages++;
+      // reset cached password
+      QMapIterator <QString,QString> pc;
+      if ( (pc = mPasswdCache.find( mMethodStr )) != mPasswdCache.end() ) {
+        mPasswdCache.erase(pc);
+      }
       // Sending of message failed.
       if (!errString.isEmpty()) {
         int res = KMessageBox::Yes;
 @ -1077,6 +1082,12  @
 
   if (ti->auth)
   {
+    QMapIterator<QString,QString> tpc = mSender->mPasswdCache.find( ti->name );
+    QString tpwd = ( tpc != mSender->mPasswdCache.end() )?(*tpc):QString::null;
+
+    if ( ti->passwd().isEmpty() )
+      ti->setPasswd( tpwd );
+
     if( (ti->user.isEmpty() || ti->passwd().isEmpty()) &&
       ti->authType != "GSSAPI" )
     {
 @ -1097,6 +1108,9  @
       if (int id = KMTransportInfo::findTransport(ti->name)) {
         ti->setPasswd( passwd );
         ti->writeConfig(id);
+
+        // save the password into the cache
+        mSender->mPasswdCache[ti->name] = passwd;
       }
     }
     destination.setUser(ti->user);
--- branches/KDE/3.5/kdepim/kmail/kmsender.h #653891:653892
 @ -30,6 +30,7  @
 #include <qcstring.h>
 #include <qstring.h>
 #include <qstringlist.h>
+#include <qmap.h>
 #include <qobject.h>
 #include <kdeversion.h>
 
 @ -167,6 +168,7  @
   int mSentMessages, mTotalMessages;
   int mSentBytes, mTotalBytes;
   int mFailedMessages;
+  QMap<QString,QString> mPasswdCache;
 };
 
 #endif /*kmsender_h*/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.