Merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-ui-05 into lp:ubuntu-filemanager-app

Proposed by Carlos Jose Mazieri on 2015-09-07
Status: Merged
Approved by: Arto Jalkanen on 2015-09-15
Approved revision: 464
Merged at revision: 470
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-ui-05
Merge into: lp:ubuntu-filemanager-app
Prerequisite: lp:~carlos-mazieri/ubuntu-filemanager-app/samba-ui-04
Diff against target: 292 lines (+210/-3)
5 files modified
src/app/qml/components/NetAuthenticationHandler.qml (+41/-0)
src/app/qml/ui/FolderListPage.qml (+16/-3)
src/app/qml/ui/NetAuthenticationDialog.qml (+123/-0)
src/plugin/folderlistmodel/dirmodel.cpp (+22/-0)
src/plugin/folderlistmodel/dirmodel.h (+8/-0)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/samba-ui-05
Reviewer Review Type Date Requested Status
Arto Jalkanen 2015-09-07 Approve on 2015-09-15
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2015-09-14
Review via email: mp+270339@code.launchpad.net

Commit message

Implemented a dialog for Authentication when remote locations requires user/password to access them

Description of the change

Implemented a dialog for Authentication when remote locations requires user/password to access them

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

I had to promote a modification to fix a bug about generating the signal which will activate the Authentication dialog.

The modification was:
         if (model.isBrowsable) {
79 - if (model.isReadable && model.isExecutable) {
80 + console.log("browsable path="+model.filePath+" isRemote="+model.isRemote+" needsAuthentication="+model.needsAuthentication)
81 + if ((model.isReadable && model.isExecutable) ||
82 + (model.isRemote && model.needsAuthentication) //in this case it is necessary to generate the signal needsAuthentication()
83

Also added the properties on the model:
    * isRemote
    * isLocal
    * needsAuthentication

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=== added file 'src/app/qml/components/NetAuthenticationHandler.qml'
2--- src/app/qml/components/NetAuthenticationHandler.qml 1970-01-01 00:00:00 +0000
3+++ src/app/qml/components/NetAuthenticationHandler.qml 2015-09-13 14:29:00 +0000
4@@ -0,0 +1,41 @@
5+import QtQuick 2.3
6+import Ubuntu.Components 1.1
7+import "../ui"
8+
9+Item {
10+ id: netAuthenticatinHandler
11+ objectName: "netAuthenticatinHandler"
12+
13+ property bool savePassword: true
14+ function showDialog(urlPath,user) {
15+ console.log("needsAuthenticationHandler::showDialog()")
16+ netAuthenticationDialog.showDialog(urlPath,user)
17+ }
18+
19+ Timer {
20+ id: authTimer
21+ interval: 200
22+ repeat: false
23+ onTriggered: {
24+ pageModel.setPathWithAuthentication(
25+ netAuthenticationDialog.currentPath,
26+ netAuthenticationDialog.currentUserName,
27+ netAuthenticationDialog.currentPassword,
28+ netAuthenticatinHandler.savePassword
29+ )
30+ }
31+ }
32+
33+ NetAuthenticationDialog {
34+ id: netAuthenticationDialog
35+ onSavePasswordChanged: {
36+ savePassword = check
37+ console.log("NetAuthenticationHandler savePassword="+savePassword)
38+ }
39+ onOk: {
40+ if (!authTimer.running) {
41+ authTimer.start()
42+ }
43+ }
44+ }
45+}
46
47=== modified file 'src/app/qml/ui/FolderListPage.qml'
48--- src/app/qml/ui/FolderListPage.qml 2015-09-13 14:29:00 +0000
49+++ src/app/qml/ui/FolderListPage.qml 2015-09-13 14:29:00 +0000
50@@ -194,6 +194,10 @@
51 }
52 }
53
54+ NetAuthenticationHandler {
55+ id: authenticationHandler
56+ }
57+
58 FolderListModel {
59 id: pageModel
60 path: folderListPage.folder
61@@ -215,6 +219,10 @@
62 addAllowedDirectory(userplaces.locationPictures)
63 addAllowedDirectory(userplaces.locationVideos)
64 }
65+ onNeedsAuthentication: {
66+ console.log("FolderListModel needsAuthentication() signal arrived")
67+ authenticationHandler.showDialog(urlPath,user)
68+ }
69 }
70
71 FolderListModel {
72@@ -880,11 +888,16 @@
73 }
74 }
75
76- function itemClicked(model) {
77+ function itemClicked(model) {
78 if (model.isBrowsable) {
79- if (model.isReadable && model.isExecutable) {
80+ console.log("browsable path="+model.filePath+" isRemote="+model.isRemote+" needsAuthentication="+model.needsAuthentication)
81+ if ((model.isReadable && model.isExecutable) ||
82+ (model.isRemote && model.needsAuthentication) //in this case it is necessary to generate the signal needsAuthentication()
83+ ) {
84 console.log("Changing to dir", model.filePath)
85- goTo(model.filePath)
86+ //prefer pageModel.cdIntoIndex() because it is not necessary to parse the path
87+ //goTo(model.filePath)
88+ pageModel.cdIntoIndex(model.index)
89 } else {
90 PopupUtils.open(Qt.resolvedUrl("NotifyDialog.qml"), delegate,
91 {
92
93=== added file 'src/app/qml/ui/NetAuthenticationDialog.qml'
94--- src/app/qml/ui/NetAuthenticationDialog.qml 1970-01-01 00:00:00 +0000
95+++ src/app/qml/ui/NetAuthenticationDialog.qml 2015-09-13 14:29:00 +0000
96@@ -0,0 +1,123 @@
97+/*
98+ * Copyright (C) 2015 Canonical Ltd
99+ *
100+ * This program is free software: you can redistribute it and/or modify
101+ * it under the terms of the GNU General Public License version 3 as
102+ * published by the Free Software Foundation.
103+ *
104+ * This program is distributed in the hope that it will be useful,
105+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
106+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
107+ * GNU General Public License for more details.
108+ *
109+ * You should have received a copy of the GNU General Public License
110+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
111+ *
112+ * Authored by: Carlos Jose Mazieri <carlos.mazieri@gmail.com>
113+ */
114+import QtQuick 2.3
115+import Ubuntu.Components 1.1
116+import Ubuntu.Components.Popups 1.0
117+import Ubuntu.Components.ListItems 1.0
118+
119+Dialog {
120+ id: authenticationDialog
121+ objectName: "authenticationDialog"
122+ title: i18n.tr("Authentication required")
123+
124+ property alias currentPath: authCurrentPath.text
125+ property alias currentUserName: authUserName.text
126+ property alias currentPassword: authPassword.text
127+
128+ signal ok()
129+ signal savePasswordChanged(bool check)
130+
131+ function showDialog(path,user) {
132+ currentPath = path
133+ currentUserName = user
134+ autcheckSavePassword.checked = true
135+ authenticationDialog.show()
136+ }
137+
138+ Component.onCompleted: {
139+ authUserName.forceActiveFocus()
140+ authUserName.cursorPosition = authUserName.text.length
141+ }
142+
143+ Text {
144+ id: authCurrentPath
145+ anchors.horizontalCenter: parent.horizontalCenter
146+ font.italic: true
147+ elide: Text.ElideMiddle
148+ }
149+
150+ Text {
151+ text: i18n.tr("User")
152+ }
153+
154+ TextField {
155+ id: authUserName
156+ objectName: "authUserName"
157+ visible: true
158+ focus: true
159+ }
160+
161+ Text {
162+ text: i18n.tr("Password")
163+ }
164+
165+ TextField {
166+ id: authPassword
167+ objectName: "authPassword"
168+ echoMode: TextInput.Password
169+ focus: true
170+ onAccepted: authOkButton.clicked()
171+ }
172+
173+ Standard {
174+ Label {
175+ text: i18n.tr("Save password")
176+ color: Theme.palette.normal.overlayText
177+ anchors.left: parent.left
178+ anchors.verticalCenter: parent.verticalCenter
179+ }
180+ control: CheckBox {
181+ id: autcheckSavePassword
182+ objectName: "autcheckSavePassword"
183+ anchors.verticalCenter: parent.verticalCenter
184+ onCheckedChanged: {
185+ console.log("NetAuthenticationDialog::onCheckedChanged() checked="+checked)
186+ savePasswordChanged(checked)
187+ }
188+ }
189+ }
190+
191+ Button {
192+ id: authOkButton
193+ objectName: "authOkButton"
194+ text: i18n.tr("Ok")
195+ onClicked: {
196+ ok()
197+ PopupUtils.close(authenticationDialog)
198+ }
199+ }
200+
201+ Button {
202+ id: authCancelButton
203+ objectName: "authCancelButton"
204+ text: i18n.tr("Cancel")
205+ gradient: Gradient {
206+ GradientStop {
207+ position: 0
208+ color: "gray"
209+ }
210+ GradientStop {
211+ position: 1
212+ color: "lightgray"
213+ }
214+ }
215+ onClicked: {
216+ PopupUtils.close(authenticationDialog)
217+ }
218+ }//authCancelButton
219+}
220
221=== modified file 'src/plugin/folderlistmodel/dirmodel.cpp'
222--- src/plugin/folderlistmodel/dirmodel.cpp 2015-09-13 14:29:00 +0000
223+++ src/plugin/folderlistmodel/dirmodel.cpp 2015-09-13 14:29:00 +0000
224@@ -221,6 +221,9 @@
225 roles.insert(FilePathRole, QByteArray("filePath"));
226 roles.insert(IsDirRole, QByteArray("isDir"));
227 roles.insert(IsHostRole, QByteArray("isHost"));
228+ roles.insert(IsRemoteRole,QByteArray("isRemote"));
229+ roles.insert(IsLocalRole,QByteArray("isLocal"));
230+ roles.insert(NeedsAuthenticationRole,QByteArray("needsAuthentication"));
231 roles.insert(IsSmbWorkgroupRole, QByteArray("isSmbWorkgroup"));
232 roles.insert(IsSmbShareRole, QByteArray("isSmbShare"));
233 roles.insert(IsSharedDirRole, QByteArray("isSharedDir"));
234@@ -400,6 +403,12 @@
235 return fi.isSelected();
236 case IsHostRole:
237 return fi.isHost();
238+ case IsRemoteRole:
239+ return fi.isRemote();
240+ case IsLocalRole:
241+ return fi.isLocal();
242+ case NeedsAuthenticationRole:
243+ return fi.needsAuthentication();
244 case IsSmbWorkgroupRole:
245 return fi.isWorkGroup();
246 case IsSmbShareRole:
247@@ -440,6 +449,19 @@
248 }
249
250
251+/*!
252+ * \brief DirModel::setPathWithAuthentication() It is just a QML entry point as setPath is a QML property and cannot be called as a function
253+ * \param path
254+ * \param user
255+ * \param password
256+ * \param savePassword
257+ */
258+void DirModel::setPathWithAuthentication(const QString &path, const QString &user, const QString &password, bool savePassword)
259+{
260+ setPath(path,user,password,savePassword);
261+}
262+
263+
264 void DirModel::setPath(const QString &pathName, const QString& user, const QString &password, bool savePassword)
265 {
266 if (pathName.isEmpty())
267
268=== modified file 'src/plugin/folderlistmodel/dirmodel.h'
269--- src/plugin/folderlistmodel/dirmodel.h 2015-07-15 18:26:36 +0000
270+++ src/plugin/folderlistmodel/dirmodel.h 2015-09-13 14:29:00 +0000
271@@ -64,6 +64,9 @@
272 FilePathRole,
273 IsDirRole,
274 IsHostRole, //!< it can also be used for other protocols than smb/cifs
275+ IsRemoteRole,
276+ IsLocalRole,
277+ NeedsAuthenticationRole,
278 IsSmbWorkgroupRole,
279 IsSmbShareRole,
280 IsSharedDirRole, //!< it can also be used for other protocols than smb/cifs
281@@ -309,6 +312,11 @@
282 Q_INVOKABLE void restoreIndexFromTrash(int index);
283 void restoreIndexesFromTrash(const QList<int>&);
284
285+ Q_INVOKABLE void setPathWithAuthentication(const QString& path,
286+ const QString& user,
287+ const QString& password,
288+ bool savePassword);
289+
290 public slots:
291 /*!
292 * \brief copySelection() copy selected items to the clipboard

Subscribers

People subscribed via source and target branches