Merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-09 into lp:ubuntu-filemanager-app

Proposed by Carlos Jose Mazieri
Status: Merged
Approved by: Arto Jalkanen
Approved revision: 398
Merged at revision: 414
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-09
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-08
Diff against target: 185 lines (+50/-14)
4 files modified
src/plugin/folderlistmodel/dirmodel.cpp (+31/-10)
src/plugin/folderlistmodel/dirmodel.h (+16/-1)
src/plugin/folderlistmodel/locationsfactory.cpp (+1/-1)
src/plugin/folderlistmodel/locationsfactory.h (+2/-2)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-browsing-09
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Arto Jalkanen Approve
Review via email: mp+252979@code.launchpad.net

Commit message

Introduced authentication in DirModel class.

Description of the change

Introduced authentication in DirModel class.
The signal DirModel::needsAuthentication() is sent to the UI when a samba browsable item requires user/password
DirModel:setPath() changed to receive "user" and "password" to allow Location class handle authentication.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Arto Jalkanen (ajalkane) :
review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
398. By Carlos Jose Mazieri

removed merge conflict

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/folderlistmodel/dirmodel.cpp'
2--- src/plugin/folderlistmodel/dirmodel.cpp 2015-03-17 13:54:19 +0000
3+++ src/plugin/folderlistmodel/dirmodel.cpp 2015-05-20 23:01:18 +0000
4@@ -39,6 +39,7 @@
5 #include "locationurl.h"
6 #include "disklocation.h"
7 #include "trashlocation.h"
8+#include "netauthenticationdata.h"
9
10
11 #ifndef DO_NOT_USE_TAG_LIB
12@@ -109,6 +110,8 @@
13 , mCompareFunction(0)
14 , mExtFSWatcher(false)
15 , mClipboard(new Clipboard(this))
16+ // create global Authentication Data before mLocationFactory
17+ , mAuthData(NetAuthenticationDataList::getInstance(this))
18 , mLocationFactory(new LocationsFactory(this))
19 , mCurLocation(0)
20 , m_fsAction(new FileSystemAction(this) )
21@@ -180,6 +183,9 @@
22 connect(l, SIGNAL(extWatcherPathChanged(QString)),
23 this, SLOT(onThereAreExternalChanges(QString)));
24
25+ connect(l, SIGNAL(needsAuthentication(QString,QString)),
26+ this, SIGNAL(needsAuthentication(QString,QString)), Qt::QueuedConnection);
27+
28 connect(this, SIGNAL(enabledExternalFSWatcherChanged(bool)),
29 l, SLOT(setUsingExternalWatcher(bool)));
30 }
31@@ -189,7 +195,8 @@
32
33 DirModel::~DirModel()
34 {
35-
36+ // release global Authentication Data
37+ NetAuthenticationDataList::releaseInstance(this);
38 }
39
40
41@@ -420,7 +427,7 @@
42 }
43
44
45-void DirModel::setPath(const QString &pathName)
46+void DirModel::setPath(const QString &pathName, const QString& user, const QString &password, bool savePassword)
47 {
48 if (pathName.isEmpty())
49 return;
50@@ -432,7 +439,7 @@
51 return;
52 }
53
54- Location *location = mLocationFactory->setNewPath(pathName);
55+ Location *location = mLocationFactory->setNewPath(pathName, user, password, savePassword);
56 if (location == 0)
57 {
58 // perhaps a goBack() operation to a folder/location that was removed,
59@@ -441,8 +448,11 @@
60 {
61 mPathList.removeLast();
62 }
63- emit error(tr("path or url may not exist or cannot be read"), pathName);
64- qDebug() << Q_FUNC_INFO << this << "path or url may not exist or cannot be read:" << pathName;
65+ if (!mLocationFactory->lastUrlNeedsAuthentication())
66+ {
67+ emit error(tr("path or url may not exist or cannot be read"), pathName);
68+ qDebug() << Q_FUNC_INFO << this << "path or url may not exist or cannot be read:" << pathName;
69+ }
70 return;
71 }
72
73@@ -910,14 +920,25 @@
74 {
75 bool ret = false;
76 if (fi.isBrowsable())
77- {
78- if (fi.isContentReadable())
79+ {
80+ bool authentication = fi.needsAuthentication() &&
81+ !mCurLocation->useAuthenticationDataIfExists(fi);
82+ if (authentication)
83 {
84- mCurLocation->setInfoItem(fi);
85- setPathFromCurrentLocation();
86+ mCurLocation->notifyItemNeedsAuthentication(&fi);
87+ //return true to avoid any error message to appear
88+ //a dialog must be presented to the user asking for user/password
89 ret = true;
90 }
91-
92+ else
93+ {
94+ if (fi.isContentReadable())
95+ {
96+ mCurLocation->setInfoItem(fi);
97+ setPathFromCurrentLocation();
98+ ret = true;
99+ }
100+ }
101 }
102 return ret;
103 }
104
105=== modified file 'src/plugin/folderlistmodel/dirmodel.h'
106--- src/plugin/folderlistmodel/dirmodel.h 2015-03-01 15:32:42 +0000
107+++ src/plugin/folderlistmodel/dirmodel.h 2015-05-20 23:01:18 +0000
108@@ -48,6 +48,7 @@
109 class LocationsFactory;
110 class Location;
111 class ExternalFSWatcher;
112+class NetAuthenticationDataList;
113
114 class DirModel : public DirItemAbstractListModel
115 {
116@@ -113,7 +114,7 @@
117
118 Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
119 inline QString path() const { return mCurrentDir; }
120- void setPath(const QString &pathName);
121+ void setPath(const QString &pathName, const QString& user = QString(), const QString& password = QString(), bool savePassword = false);
122
123 Q_INVOKABLE QDateTime curPathAccessedDate() const;
124 Q_INVOKABLE QDateTime curPathCreatedDate() const;
125@@ -422,6 +423,19 @@
126
127 signals:
128 /*!
129+ * \brief needsAuthentication()
130+ * This notifies the UI that the current URL being browsed needs to set
131+ * user/password to perform an authentication
132+ *
133+ * The UI must ask for "user" and "password" for the current URL and then call
134+ * \ref setAuthentication()
135+ *
136+ * \param user current user being used
137+ * \param urlPath the current URL asked to be browsed
138+ */
139+ void needsAuthentication(const QString& user, const QString& urlPath);
140+
141+ /*!
142 * \brief insertedItem()
143 *
144 * It happens when a new file is inserted in an existent view,
145@@ -489,6 +503,7 @@
146 bool mExtFSWatcher;
147 Clipboard * mClipboard;
148 DirSelection * mSelection;
149+ NetAuthenticationDataList *mAuthData;
150 LocationsFactory * mLocationFactory;
151 Location * mCurLocation;
152 QStringList mPathList; //!< it will be used for goBack()
153
154=== modified file 'src/plugin/folderlistmodel/locationsfactory.cpp'
155--- src/plugin/folderlistmodel/locationsfactory.cpp 2015-04-29 23:23:31 +0000
156+++ src/plugin/folderlistmodel/locationsfactory.cpp 2015-05-20 23:01:18 +0000
157@@ -208,7 +208,7 @@
158 }
159
160
161-bool LocationsFactory::lastUrlNeedsAuthencation() const
162+bool LocationsFactory::lastUrlNeedsAuthentication() const
163 {
164 return m_lastUrlNeedsAuthentication;
165 }
166
167=== modified file 'src/plugin/folderlistmodel/locationsfactory.h'
168--- src/plugin/folderlistmodel/locationsfactory.h 2015-04-29 23:23:31 +0000
169+++ src/plugin/folderlistmodel/locationsfactory.h 2015-05-20 23:01:18 +0000
170@@ -122,13 +122,13 @@
171 const DirItemInfo* lastValidFileInfo() const { return m_lastValidFileInfo; }
172
173 /*!
174- * \brief lastUrlNeedsAuthencation()
175+ * \brief lastUrlNeedsAuthentication()
176 * \return true when last URL used in setNewPath() needs authentication
177 *
178 * It can be used to show a dialog to the user asking for user/password
179 * instead of showing a message saying that url does not exist
180 */
181- bool lastUrlNeedsAuthencation() const;
182+ bool lastUrlNeedsAuthentication() const;
183
184 private:
185 /*!

Subscribers

People subscribed via source and target branches