← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-02 into lp:ubuntu-filemanager-app

 

Carlos Jose Mazieri has proposed merging lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-02 into lp:ubuntu-filemanager-app with lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-01 as a prerequisite.

Commit message:
    After using a such user/password for authentication in a remote location it is necessary to reset that values for other items, without this items which do not require authentication may fail to get data.

    That means if a remote location does not need authentication the user/password is reset to initial value.


Requested reviews:
  Ubuntu File Manager Developers (ubuntu-filemanager-dev)

For more details, see:
https://code.launchpad.net/~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-02/+merge/273334

    After using a such user/password for authentication in a remote location it is necessary to reset that values for other items, without this items which do not require authentication may fail to get data.

    That means if a remote location does not need authentication the user/password is reset to initial value.

-- 
Your team Ubuntu File Manager Developers is requested to review the proposed merge of lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-02 into lp:ubuntu-filemanager-app.
=== modified file 'src/plugin/folderlistmodel/location.cpp'
--- src/plugin/folderlistmodel/location.cpp	2015-07-11 21:21:16 +0000
+++ src/plugin/folderlistmodel/location.cpp	2015-10-04 15:45:50 +0000
@@ -173,7 +173,7 @@
  */
 QString Location::currentAuthenticationUser()
 {
-    return QString(::qgetenv("USER"));
+    return NetAuthenticationData::currentUser();
 }
 
 /*!

=== modified file 'src/plugin/folderlistmodel/locationsfactory.cpp'
--- src/plugin/folderlistmodel/locationsfactory.cpp	2015-07-13 20:41:48 +0000
+++ src/plugin/folderlistmodel/locationsfactory.cpp	2015-10-04 15:45:50 +0000
@@ -194,31 +194,44 @@
 
 
 DirItemInfo * LocationsFactory::validateCurrentUrl(Location *location, const NetAuthenticationData &authData)
-{
+{   
     //when there is authentication data, set the authentication before validating an item
-    if (!authData.isEmpty())
+    if (location->isRemote())
     {
-        location->setAuthentication(authData.user, authData.password);
+        if (!authData.isEmpty())
+        {
+            location->setAuthentication(authData.user, authData.password);
+        }
+        else
+        {
+            //reset the password even it was set before, it is necessary to browse other items
+            location->setAuthentication(NetAuthenticationData::currentUser(),
+                                        NetAuthenticationData::noPassword());
+        }
     }
 
     DirItemInfo *item = location->validateUrlPath(m_tmpPath);
 
     //for remote loacations, authentication might have failed
-    //if so try to use a stored authentication data and autenticate again
-    if (   item && item->needsAuthentication()
-        && location->useAuthenticationDataIfExists(*item))
-    {
-        delete item;
-        item = location->validateUrlPath(m_tmpPath);
-    }
-    //if failed it is necessary to ask the user to provide user/password
-    if ( item && item->needsAuthentication() )
-    {
-        location->notifyItemNeedsAuthentication(item);
-        delete item;
-        item = 0;
-    }
-    if (item && !item->isContentReadable())
+    //if so try to use a stored authentication data and authenticate it again
+    if (location->isRemote() && item != 0)
+    {
+        if (    item->needsAuthentication()
+             && location->useAuthenticationDataIfExists(*item))
+        {
+            delete item;
+            item = location->validateUrlPath(m_tmpPath);
+        }
+        //if failed it is necessary to ask the user to provide user/password
+        if ( item != 0 && item->needsAuthentication() )
+        {
+            location->notifyItemNeedsAuthentication(item);
+            delete item;
+            item = 0;
+        }
+    }
+    //now just see if the item is readable
+    if (item != 0 && !item->isContentReadable())
     {
         delete item;
         item = 0;

=== modified file 'src/plugin/folderlistmodel/net/netauthenticationdata.cpp'
--- src/plugin/folderlistmodel/net/netauthenticationdata.cpp	2015-10-04 15:45:50 +0000
+++ src/plugin/folderlistmodel/net/netauthenticationdata.cpp	2015-10-04 15:45:50 +0000
@@ -33,6 +33,18 @@
 void *                       NetAuthenticationDataList::m_parent   = 0;
 
 
+const QString& NetAuthenticationData::currentUser()
+{
+    static QString curUser(::qgetenv("USER"));
+    return curUser;
+}
+
+const QString& NetAuthenticationData::noPassword()
+{
+    static QString emptyPassword;
+    return emptyPassword;
+}
+
 NetAuthenticationDataList::NetAuthenticationDataList(): m_savedAuths(0)
 {   
     //settings file does not need to open  all the time

=== modified file 'src/plugin/folderlistmodel/net/netauthenticationdata.h'
--- src/plugin/folderlistmodel/net/netauthenticationdata.h	2015-03-01 15:32:42 +0000
+++ src/plugin/folderlistmodel/net/netauthenticationdata.h	2015-10-04 15:45:50 +0000
@@ -42,6 +42,8 @@
     inline bool isEmpty() const { return user.isEmpty(); }
     QString user;
     QString password; 
+    static const QString& currentUser();
+    static const QString& noPassword();
 };
 
 

=== modified file 'src/plugin/folderlistmodel/smb/smblocation.cpp'
--- src/plugin/folderlistmodel/smb/smblocation.cpp	2015-09-07 18:40:47 +0000
+++ src/plugin/folderlistmodel/smb/smblocation.cpp	2015-10-04 15:45:50 +0000
@@ -29,6 +29,8 @@
 #include "locationurl.h"
 #include "smblocationitemfile.h"
 #include "smblocationitemdir.h"
+#include "netauthenticationdata.h"
+
 
 
 #if defined(Q_OS_UNIX)
@@ -40,7 +42,8 @@
      , SmbLocationAuthentication()
 {
      m_smb = new SmbUtil(suitableAuthenticationFunction());
-     setAuthentication(::qgetenv("USER"), QString());
+     setAuthentication(NetAuthenticationData::currentUser(),
+                       NetAuthenticationData::noPassword());
 }
 
 


Follow ups