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

Proposed by Carlos Jose Mazieri on 2015-10-04
Status: Merged
Approved by: Arto Jalkanen on 2015-10-20
Approved revision: 476
Merged at revision: 485
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-02
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-01
Diff against target: 136 lines (+50/-20)
5 files modified
src/plugin/folderlistmodel/location.cpp (+1/-1)
src/plugin/folderlistmodel/locationsfactory.cpp (+31/-18)
src/plugin/folderlistmodel/net/netauthenticationdata.cpp (+12/-0)
src/plugin/folderlistmodel/net/netauthenticationdata.h (+2/-0)
src/plugin/folderlistmodel/smb/smblocation.cpp (+4/-1)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-improvements-02
Reviewer Review Type Date Requested Status
Arto Jalkanen 2015-10-04 Approve on 2015-10-20
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2015-10-05
Review via email: mp+273334@code.launchpad.net

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.

Description of the change

    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.

To post a comment you must log in.
review: Approve (continuous-integration)
Arto Jalkanen (ajalkane) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/folderlistmodel/location.cpp'
2--- src/plugin/folderlistmodel/location.cpp 2015-07-11 21:21:16 +0000
3+++ src/plugin/folderlistmodel/location.cpp 2015-10-04 15:45:50 +0000
4@@ -173,7 +173,7 @@
5 */
6 QString Location::currentAuthenticationUser()
7 {
8- return QString(::qgetenv("USER"));
9+ return NetAuthenticationData::currentUser();
10 }
11
12 /*!
13
14=== modified file 'src/plugin/folderlistmodel/locationsfactory.cpp'
15--- src/plugin/folderlistmodel/locationsfactory.cpp 2015-07-13 20:41:48 +0000
16+++ src/plugin/folderlistmodel/locationsfactory.cpp 2015-10-04 15:45:50 +0000
17@@ -194,31 +194,44 @@
18
19
20 DirItemInfo * LocationsFactory::validateCurrentUrl(Location *location, const NetAuthenticationData &authData)
21-{
22+{
23 //when there is authentication data, set the authentication before validating an item
24- if (!authData.isEmpty())
25+ if (location->isRemote())
26 {
27- location->setAuthentication(authData.user, authData.password);
28+ if (!authData.isEmpty())
29+ {
30+ location->setAuthentication(authData.user, authData.password);
31+ }
32+ else
33+ {
34+ //reset the password even it was set before, it is necessary to browse other items
35+ location->setAuthentication(NetAuthenticationData::currentUser(),
36+ NetAuthenticationData::noPassword());
37+ }
38 }
39
40 DirItemInfo *item = location->validateUrlPath(m_tmpPath);
41
42 //for remote loacations, authentication might have failed
43- //if so try to use a stored authentication data and autenticate again
44- if ( item && item->needsAuthentication()
45- && location->useAuthenticationDataIfExists(*item))
46- {
47- delete item;
48- item = location->validateUrlPath(m_tmpPath);
49- }
50- //if failed it is necessary to ask the user to provide user/password
51- if ( item && item->needsAuthentication() )
52- {
53- location->notifyItemNeedsAuthentication(item);
54- delete item;
55- item = 0;
56- }
57- if (item && !item->isContentReadable())
58+ //if so try to use a stored authentication data and authenticate it again
59+ if (location->isRemote() && item != 0)
60+ {
61+ if ( item->needsAuthentication()
62+ && location->useAuthenticationDataIfExists(*item))
63+ {
64+ delete item;
65+ item = location->validateUrlPath(m_tmpPath);
66+ }
67+ //if failed it is necessary to ask the user to provide user/password
68+ if ( item != 0 && item->needsAuthentication() )
69+ {
70+ location->notifyItemNeedsAuthentication(item);
71+ delete item;
72+ item = 0;
73+ }
74+ }
75+ //now just see if the item is readable
76+ if (item != 0 && !item->isContentReadable())
77 {
78 delete item;
79 item = 0;
80
81=== modified file 'src/plugin/folderlistmodel/net/netauthenticationdata.cpp'
82--- src/plugin/folderlistmodel/net/netauthenticationdata.cpp 2015-10-04 15:45:50 +0000
83+++ src/plugin/folderlistmodel/net/netauthenticationdata.cpp 2015-10-04 15:45:50 +0000
84@@ -33,6 +33,18 @@
85 void * NetAuthenticationDataList::m_parent = 0;
86
87
88+const QString& NetAuthenticationData::currentUser()
89+{
90+ static QString curUser(::qgetenv("USER"));
91+ return curUser;
92+}
93+
94+const QString& NetAuthenticationData::noPassword()
95+{
96+ static QString emptyPassword;
97+ return emptyPassword;
98+}
99+
100 NetAuthenticationDataList::NetAuthenticationDataList(): m_savedAuths(0)
101 {
102 //settings file does not need to open all the time
103
104=== modified file 'src/plugin/folderlistmodel/net/netauthenticationdata.h'
105--- src/plugin/folderlistmodel/net/netauthenticationdata.h 2015-03-01 15:32:42 +0000
106+++ src/plugin/folderlistmodel/net/netauthenticationdata.h 2015-10-04 15:45:50 +0000
107@@ -42,6 +42,8 @@
108 inline bool isEmpty() const { return user.isEmpty(); }
109 QString user;
110 QString password;
111+ static const QString& currentUser();
112+ static const QString& noPassword();
113 };
114
115
116
117=== modified file 'src/plugin/folderlistmodel/smb/smblocation.cpp'
118--- src/plugin/folderlistmodel/smb/smblocation.cpp 2015-09-07 18:40:47 +0000
119+++ src/plugin/folderlistmodel/smb/smblocation.cpp 2015-10-04 15:45:50 +0000
120@@ -29,6 +29,8 @@
121 #include "locationurl.h"
122 #include "smblocationitemfile.h"
123 #include "smblocationitemdir.h"
124+#include "netauthenticationdata.h"
125+
126
127
128 #if defined(Q_OS_UNIX)
129@@ -40,7 +42,8 @@
130 , SmbLocationAuthentication()
131 {
132 m_smb = new SmbUtil(suitableAuthenticationFunction());
133- setAuthentication(::qgetenv("USER"), QString());
134+ setAuthentication(NetAuthenticationData::currentUser(),
135+ NetAuthenticationData::noPassword());
136 }
137
138

Subscribers

People subscribed via source and target branches