[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/network/smb4k/core
From:       Alexander Reinholdt <alexander.reinholdt () kdemail ! net>
Date:       2013-01-01 9:01:08
Message-ID: 20130101090108.1CFD7AC80E () svn ! kde ! org
[Download RAW message or body]

SVN commit 1330267 by areinholdt:

- Fix insufficiant if mounting of a share is already running.
- Fix crash bug in Smb4KMounter::slotAuthError(). Smb4KMOuntJOb sent the
  authError() signal while it was processing the mounted shares and not
  after it finished with that. This led to invalid data at some point and
  made the application crash.
- Added Smb4KPasswordDialog class.
- Rewrote Smb4KWalletManager::showPasswordDialog() function.


 M  +1 -0      CMakeLists.txt  
 M  +9 -1      smb4kmounter.cpp  
 M  +20 -5     smb4kmounter_p.cpp  
 M  +17 -91    smb4kwalletmanager.cpp  
 M  +5 -2      smb4kwalletmanager.h  
 A             smb4kwalletmanager_p.cpp   [License: GPL (v2+)]
 A             smb4kwalletmanager_p.h   [License: GPL (v2+)]


--- trunk/playground/network/smb4k/core/CMakeLists.txt #1330266:1330267
@@ -39,6 +39,7 @@
   smb4ksynchronizer.cpp
   smb4ksynchronizer_p.cpp
   smb4kwalletmanager.cpp
+  smb4kwalletmanager_p.cpp
   smb4kworkgroup.cpp )
 
 kde4_add_kcfg_files( smb4kcore_LIB_SRCS smb4ksettings.kcfgc )
--- trunk/playground/network/smb4k/core/smb4kmounter.cpp #1330266:1330267
@@ -876,7 +876,10 @@
       
         if ( QString::compare( job->objectName(), QString( "MountJob_%1" ).arg( unc \
), Qt::CaseInsensitive ) == 0 )  {
-          // Already running
+          // Make sure that we do not get false rejections when mounting is
+          // retried due to an authentication error.
+          if ( static_cast<Smb4KMountJob *>( job )->authErrors().isEmpty() )
+          {
           running = true;
           break;
         }
@@ -885,6 +888,11 @@
           continue;
         }
       }
+        else
+        {
+          continue;
+        }
+      }
       
       if ( !running )
       {
--- trunk/playground/network/smb4k/core/smb4kmounter_p.cpp #1330266:1330267
@@ -778,11 +778,9 @@
       if ( QString::compare( share->canonicalPath(), \
reply.data()["mountpoint"].toString() ) == 0 && !stderr.isEmpty() )  {
 #ifndef Q_OS_FREEBSD
-        if ( stderr.contains( "mount error 13", Qt::CaseSensitive ) || \
                stderr.contains( "mount error(13)" )
-            /* authentication error */ )
+        if ( stderr.contains( "mount error 13" ) || stderr.contains( "mount \
error(13)" ) /* authentication error */ )  {
           m_auth_errors << new Smb4KShare( *share );
-          emit authError( this );
         }
         else if ( (stderr.contains( "mount error 6" ) || stderr.contains( "mount \
error(6)" )) /* bad share name */ &&  share->shareName().contains( "_", \
Qt::CaseSensitive ) ) @@ -790,7 +788,6 @@
           QString share_name = share->shareName();
           share->setShareName( share_name.replace( '_', ' ' ) );
           m_retries << new Smb4KShare( *share );
-          emit retry( this );
         }
         else if ( stderr.contains( "mount error 101" ) || stderr.contains( "mount \
error(101)" ) /* network unreachable */ )  {
@@ -800,7 +797,6 @@
         if ( stderr.contains( "Authentication error" ) )
         {
           m_auth_errors << new Smb4KShare( *share );
-          emit authError( this );
         }
 #endif
         else
@@ -832,6 +828,25 @@
 
   if ( m_processed == m_shares.size() )
   {
+    // Emit the necessary signals.
+    if ( !m_auth_errors.isEmpty() )
+    {
+      emit authError( this );
+    }
+    else
+    {
+      // Do nothing
+    }
+
+    if ( !m_retries.isEmpty() )
+    {
+      emit retry( this );
+    }
+    else
+    {
+      // Do nothing
+    }
+    
     // Give the operating system some time to process the mounts
     // before we invoke KMountPoint::currentMountPoints().
     QTimer::singleShot( 500, this, SLOT(slotFinishJob()) );
--- trunk/playground/network/smb4k/core/smb4kwalletmanager.cpp #1330266:1330267
@@ -29,6 +29,7 @@
 
 // application specific includes
 #include "smb4kwalletmanager.h"
+#include "smb4kwalletmanager_p.h"
 #include "smb4ksettings.h"
 #include "smb4kauthinfo.h"
 #include "smb4khomesshareshandler.h"
@@ -51,8 +52,6 @@
 #include <kglobal.h>
 #include <kdebug.h>
 #include <kapplication.h>
-#include <kpassworddialog.h>
-#include <klocale.h>
 #ifdef Q_OS_FREEBSD
 #include <kprocess.h>
 #include <kstandarddirs.h>
@@ -60,22 +59,6 @@
 
 using namespace Smb4KGlobal;
 
-
-class Smb4KWalletManagerPrivate
-{
-  public:
-    KWallet::Wallet *wallet;
-    Smb4KWalletManager::State state;
-    QList<Smb4KAuthInfo *> list;
-};
-
-
-class Smb4KWalletManagerStatic
-{
-  public:
-    Smb4KWalletManager instance;
-};
-
 K_GLOBAL_STATIC( Smb4KWalletManagerStatic, p );
 
 
@@ -860,110 +843,53 @@
   // Return value
   bool success = false;
 
-  // Read authentication information
-  readAuthInfo( networkItem );
+  // Get known logins if available and read the authentication
+  // information.
+  QMap<QString, QString> known_logins;
 
-  // Set up the password dialog.
-  QPointer<KPasswordDialog> dlg = new KPasswordDialog( parent, \
                KPasswordDialog::ShowUsernameLine );
-
   switch ( networkItem->type() )
   {
-    case Smb4KBasicNetworkItem::Host:
-    {
-      Smb4KHost *host = static_cast<Smb4KHost *>( networkItem );
-
-      if ( host )
-      {
-        dlg->setUsername( host->login() );
-        dlg->setPassword( host->password() );
-        dlg->setPrompt( i18n( "<qt>Please enter a username and a password for the \
                host <b>%1</b>.</qt>", host->hostName() ) );
-
-        // Execute the password dialog, retrieve the new authentication
-        // information and save it.
-        if ( (success = dlg->exec()) )
-        {
-          host->setLogin( dlg->username() );
-          host->setPassword( dlg->password() );
-          writeAuthInfo( host );
-        }
-        else
-        {
-          // Do nothing
-        }
-      }
-      else
-      {
-        // Do nothing
-      }
-      break;
-    }
     case Smb4KBasicNetworkItem::Share:
     {
       Smb4KShare *share = static_cast<Smb4KShare *>( networkItem );
 
       if ( share )
       {
-        // Get known logins in case we have a 'homes' share and the share
-        // name has not yet been changed.
-        QMap<QString,QString> logins;
         QStringList users = Smb4KHomesSharesHandler::self()->homesUsers( share );
 
         for ( int i = 0; i < users.size(); ++i )
         {
-          Smb4KShare tmp_share( *share );
-          tmp_share.setLogin( users.at( i ) );
+          Smb4KShare *tmp_share = new Smb4KShare( *share );
+          tmp_share->setLogin( users.at( i ) );
 
           // Read the authentication data for the share. If it does not
           // exist yet, login() and password() will be empty.
-          readAuthInfo( &tmp_share );
-          logins.insert( tmp_share.login(), tmp_share.password() );
-        }
+          readAuthInfo( tmp_share );
+          known_logins.insert( tmp_share->login(), tmp_share->password() );
 
-        // Enter authentication information into the dialog
-        if ( !logins.isEmpty() )
-        {
-          dlg->setKnownLogins( logins );
+          delete tmp_share;
         }
-        else
-        {
-          dlg->setUsername( share->login() );
-          dlg->setPassword( share->password() );
         }
-
-        if ( !share->isHomesShare() )
-        {
-          dlg->setPrompt( i18n( "<qt>Please enter a username and a password for the \
                share <b>%1</b>.</qt>", share->unc() ) );
-        }
         else
         {
-          dlg->setPrompt( i18n( "<qt>Please enter a username and a password for the \
                share <b>%1</b>.</qt>", share->homeUNC() ) );
-        }
-
-        // Execute the password dialog, retrieve the new authentication
-        // information and save it.
-        if ( (success = dlg->exec()) )
-        {
-          share->setLogin( dlg->username() );
-          share->setPassword( dlg->password() );
-          writeAuthInfo( share );
-        }
-        else
-        {
           // Do nothing
         }
-      }
-      else
-      {
-        // Do nothing
-      }
       break;
     }
     default:
     {
+      readAuthInfo( networkItem );
       break;
     }
   }
 
+  // Set up the password dialog and show it.
+  QPointer<Smb4KPasswordDialog> dlg = new Smb4KPasswordDialog( networkItem, \
known_logins, parent ); +  success = dlg->exec();
+
+  // Write the authentication information.
+  writeAuthInfo( networkItem );
+
   delete dlg;
 
   return success;
--- trunk/playground/network/smb4k/core/smb4kwalletmanager.h #1330266:1330267
@@ -26,12 +26,15 @@
 #ifndef SMB4KWALLETMANAGER_H
 #define SMB4KWALLETMANAGER_H
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 // Qt includes
 #include <QtCore/QList>
 #include <QtGui/QWidget>
 
 // KDE includes
-#include <kwallet.h>
 #include <kdemacros.h>
 
 // forward declarations
@@ -47,7 +50,7 @@
  * can be stored temporarily if the user does not want to use the digital wallet
  * provided by KDE.
  *
- * @author Alexander Reinholdt <dustpuppy@users.berlios.de>
+ * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net>
  */
 
 class KDE_EXPORT Smb4KWalletManager : public QObject


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic