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

Proposed by Carlos Jose Mazieri
Status: Merged
Approved by: Arto Jalkanen
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 Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
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.
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
Carlos Jose Mazieri (carlos-mazieri) wrote :

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

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'src/app/qml/components/NetAuthenticationHandler.qml'
--- src/app/qml/components/NetAuthenticationHandler.qml 1970-01-01 00:00:00 +0000
+++ src/app/qml/components/NetAuthenticationHandler.qml 2015-09-13 14:29:00 +0000
@@ -0,0 +1,41 @@
1import QtQuick 2.3
2import Ubuntu.Components 1.1
3import "../ui"
4
5Item {
6 id: netAuthenticatinHandler
7 objectName: "netAuthenticatinHandler"
8
9 property bool savePassword: true
10 function showDialog(urlPath,user) {
11 console.log("needsAuthenticationHandler::showDialog()")
12 netAuthenticationDialog.showDialog(urlPath,user)
13 }
14
15 Timer {
16 id: authTimer
17 interval: 200
18 repeat: false
19 onTriggered: {
20 pageModel.setPathWithAuthentication(
21 netAuthenticationDialog.currentPath,
22 netAuthenticationDialog.currentUserName,
23 netAuthenticationDialog.currentPassword,
24 netAuthenticatinHandler.savePassword
25 )
26 }
27 }
28
29 NetAuthenticationDialog {
30 id: netAuthenticationDialog
31 onSavePasswordChanged: {
32 savePassword = check
33 console.log("NetAuthenticationHandler savePassword="+savePassword)
34 }
35 onOk: {
36 if (!authTimer.running) {
37 authTimer.start()
38 }
39 }
40 }
41}
042
=== modified file 'src/app/qml/ui/FolderListPage.qml'
--- src/app/qml/ui/FolderListPage.qml 2015-09-13 14:29:00 +0000
+++ src/app/qml/ui/FolderListPage.qml 2015-09-13 14:29:00 +0000
@@ -194,6 +194,10 @@
194 }194 }
195 }195 }
196196
197 NetAuthenticationHandler {
198 id: authenticationHandler
199 }
200
197 FolderListModel {201 FolderListModel {
198 id: pageModel202 id: pageModel
199 path: folderListPage.folder203 path: folderListPage.folder
@@ -215,6 +219,10 @@
215 addAllowedDirectory(userplaces.locationPictures)219 addAllowedDirectory(userplaces.locationPictures)
216 addAllowedDirectory(userplaces.locationVideos)220 addAllowedDirectory(userplaces.locationVideos)
217 }221 }
222 onNeedsAuthentication: {
223 console.log("FolderListModel needsAuthentication() signal arrived")
224 authenticationHandler.showDialog(urlPath,user)
225 }
218 }226 }
219227
220 FolderListModel {228 FolderListModel {
@@ -880,11 +888,16 @@
880 }888 }
881 }889 }
882890
883 function itemClicked(model) {891 function itemClicked(model) {
884 if (model.isBrowsable) {892 if (model.isBrowsable) {
885 if (model.isReadable && model.isExecutable) {893 console.log("browsable path="+model.filePath+" isRemote="+model.isRemote+" needsAuthentication="+model.needsAuthentication)
894 if ((model.isReadable && model.isExecutable) ||
895 (model.isRemote && model.needsAuthentication) //in this case it is necessary to generate the signal needsAuthentication()
896 ) {
886 console.log("Changing to dir", model.filePath)897 console.log("Changing to dir", model.filePath)
887 goTo(model.filePath)898 //prefer pageModel.cdIntoIndex() because it is not necessary to parse the path
899 //goTo(model.filePath)
900 pageModel.cdIntoIndex(model.index)
888 } else {901 } else {
889 PopupUtils.open(Qt.resolvedUrl("NotifyDialog.qml"), delegate,902 PopupUtils.open(Qt.resolvedUrl("NotifyDialog.qml"), delegate,
890 {903 {
891904
=== added file 'src/app/qml/ui/NetAuthenticationDialog.qml'
--- src/app/qml/ui/NetAuthenticationDialog.qml 1970-01-01 00:00:00 +0000
+++ src/app/qml/ui/NetAuthenticationDialog.qml 2015-09-13 14:29:00 +0000
@@ -0,0 +1,123 @@
1/*
2 * Copyright (C) 2015 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Carlos Jose Mazieri <carlos.mazieri@gmail.com>
17 */
18import QtQuick 2.3
19import Ubuntu.Components 1.1
20import Ubuntu.Components.Popups 1.0
21import Ubuntu.Components.ListItems 1.0
22
23Dialog {
24 id: authenticationDialog
25 objectName: "authenticationDialog"
26 title: i18n.tr("Authentication required")
27
28 property alias currentPath: authCurrentPath.text
29 property alias currentUserName: authUserName.text
30 property alias currentPassword: authPassword.text
31
32 signal ok()
33 signal savePasswordChanged(bool check)
34
35 function showDialog(path,user) {
36 currentPath = path
37 currentUserName = user
38 autcheckSavePassword.checked = true
39 authenticationDialog.show()
40 }
41
42 Component.onCompleted: {
43 authUserName.forceActiveFocus()
44 authUserName.cursorPosition = authUserName.text.length
45 }
46
47 Text {
48 id: authCurrentPath
49 anchors.horizontalCenter: parent.horizontalCenter
50 font.italic: true
51 elide: Text.ElideMiddle
52 }
53
54 Text {
55 text: i18n.tr("User")
56 }
57
58 TextField {
59 id: authUserName
60 objectName: "authUserName"
61 visible: true
62 focus: true
63 }
64
65 Text {
66 text: i18n.tr("Password")
67 }
68
69 TextField {
70 id: authPassword
71 objectName: "authPassword"
72 echoMode: TextInput.Password
73 focus: true
74 onAccepted: authOkButton.clicked()
75 }
76
77 Standard {
78 Label {
79 text: i18n.tr("Save password")
80 color: Theme.palette.normal.overlayText
81 anchors.left: parent.left
82 anchors.verticalCenter: parent.verticalCenter
83 }
84 control: CheckBox {
85 id: autcheckSavePassword
86 objectName: "autcheckSavePassword"
87 anchors.verticalCenter: parent.verticalCenter
88 onCheckedChanged: {
89 console.log("NetAuthenticationDialog::onCheckedChanged() checked="+checked)
90 savePasswordChanged(checked)
91 }
92 }
93 }
94
95 Button {
96 id: authOkButton
97 objectName: "authOkButton"
98 text: i18n.tr("Ok")
99 onClicked: {
100 ok()
101 PopupUtils.close(authenticationDialog)
102 }
103 }
104
105 Button {
106 id: authCancelButton
107 objectName: "authCancelButton"
108 text: i18n.tr("Cancel")
109 gradient: Gradient {
110 GradientStop {
111 position: 0
112 color: "gray"
113 }
114 GradientStop {
115 position: 1
116 color: "lightgray"
117 }
118 }
119 onClicked: {
120 PopupUtils.close(authenticationDialog)
121 }
122 }//authCancelButton
123}
0124
=== modified file 'src/plugin/folderlistmodel/dirmodel.cpp'
--- src/plugin/folderlistmodel/dirmodel.cpp 2015-09-13 14:29:00 +0000
+++ src/plugin/folderlistmodel/dirmodel.cpp 2015-09-13 14:29:00 +0000
@@ -221,6 +221,9 @@
221 roles.insert(FilePathRole, QByteArray("filePath"));221 roles.insert(FilePathRole, QByteArray("filePath"));
222 roles.insert(IsDirRole, QByteArray("isDir")); 222 roles.insert(IsDirRole, QByteArray("isDir"));
223 roles.insert(IsHostRole, QByteArray("isHost"));223 roles.insert(IsHostRole, QByteArray("isHost"));
224 roles.insert(IsRemoteRole,QByteArray("isRemote"));
225 roles.insert(IsLocalRole,QByteArray("isLocal"));
226 roles.insert(NeedsAuthenticationRole,QByteArray("needsAuthentication"));
224 roles.insert(IsSmbWorkgroupRole, QByteArray("isSmbWorkgroup"));227 roles.insert(IsSmbWorkgroupRole, QByteArray("isSmbWorkgroup"));
225 roles.insert(IsSmbShareRole, QByteArray("isSmbShare"));228 roles.insert(IsSmbShareRole, QByteArray("isSmbShare"));
226 roles.insert(IsSharedDirRole, QByteArray("isSharedDir"));229 roles.insert(IsSharedDirRole, QByteArray("isSharedDir"));
@@ -400,6 +403,12 @@
400 return fi.isSelected();403 return fi.isSelected();
401 case IsHostRole:404 case IsHostRole:
402 return fi.isHost();405 return fi.isHost();
406 case IsRemoteRole:
407 return fi.isRemote();
408 case IsLocalRole:
409 return fi.isLocal();
410 case NeedsAuthenticationRole:
411 return fi.needsAuthentication();
403 case IsSmbWorkgroupRole:412 case IsSmbWorkgroupRole:
404 return fi.isWorkGroup();413 return fi.isWorkGroup();
405 case IsSmbShareRole:414 case IsSmbShareRole:
@@ -440,6 +449,19 @@
440}449}
441450
442451
452/*!
453 * \brief DirModel::setPathWithAuthentication() It is just a QML entry point as setPath is a QML property and cannot be called as a function
454 * \param path
455 * \param user
456 * \param password
457 * \param savePassword
458 */
459void DirModel::setPathWithAuthentication(const QString &path, const QString &user, const QString &password, bool savePassword)
460{
461 setPath(path,user,password,savePassword);
462}
463
464
443void DirModel::setPath(const QString &pathName, const QString& user, const QString &password, bool savePassword)465void DirModel::setPath(const QString &pathName, const QString& user, const QString &password, bool savePassword)
444{466{
445 if (pathName.isEmpty())467 if (pathName.isEmpty())
446468
=== modified file 'src/plugin/folderlistmodel/dirmodel.h'
--- src/plugin/folderlistmodel/dirmodel.h 2015-07-15 18:26:36 +0000
+++ src/plugin/folderlistmodel/dirmodel.h 2015-09-13 14:29:00 +0000
@@ -64,6 +64,9 @@
64 FilePathRole,64 FilePathRole,
65 IsDirRole,65 IsDirRole,
66 IsHostRole, //!< it can also be used for other protocols than smb/cifs66 IsHostRole, //!< it can also be used for other protocols than smb/cifs
67 IsRemoteRole,
68 IsLocalRole,
69 NeedsAuthenticationRole,
67 IsSmbWorkgroupRole,70 IsSmbWorkgroupRole,
68 IsSmbShareRole,71 IsSmbShareRole,
69 IsSharedDirRole, //!< it can also be used for other protocols than smb/cifs72 IsSharedDirRole, //!< it can also be used for other protocols than smb/cifs
@@ -309,6 +312,11 @@
309 Q_INVOKABLE void restoreIndexFromTrash(int index);312 Q_INVOKABLE void restoreIndexFromTrash(int index);
310 void restoreIndexesFromTrash(const QList<int>&);313 void restoreIndexesFromTrash(const QList<int>&);
311314
315 Q_INVOKABLE void setPathWithAuthentication(const QString& path,
316 const QString& user,
317 const QString& password,
318 bool savePassword);
319
312public slots:320public slots:
313 /*!321 /*!
314 * \brief copySelection() copy selected items to the clipboard322 * \brief copySelection() copy selected items to the clipboard

Subscribers

People subscribed via source and target branches