← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

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

 

Carlos Jose Mazieri has proposed merging lp:~carlos-mazieri/ubuntu-filemanager-app/samba-ui-05 into lp:ubuntu-filemanager-app with lp:~carlos-mazieri/ubuntu-filemanager-app/samba-ui-04 as a prerequisite.

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

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

For more details, see:
https://code.launchpad.net/~carlos-mazieri/ubuntu-filemanager-app/samba-ui-05/+merge/270339

Implemented a dialog for Authentication when remote locations requires user/password to access them
-- 
Your team Ubuntu File Manager Developers is requested to review the proposed merge of lp:~carlos-mazieri/ubuntu-filemanager-app/samba-ui-05 into lp:ubuntu-filemanager-app.
=== 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-07 21:33:03 +0000
@@ -0,0 +1,41 @@
+import QtQuick 2.3
+import Ubuntu.Components 1.1
+import "../ui"
+
+Item  {
+   id: netAuthenticatinHandler
+   objectName: "netAuthenticatinHandler"
+
+   property bool savePassword: true
+   function showDialog(urlPath,user) {
+       console.log("needsAuthenticationHandler::showDialog()")
+       netAuthenticationDialog.showDialog(urlPath,user)
+   }
+
+   Timer {
+       id: authTimer
+       interval: 200
+       repeat: false
+       onTriggered:  {           
+           pageModel.setPathWithAuthentication(
+                         netAuthenticationDialog.currentPath,
+                         netAuthenticationDialog.currentUserName,
+                         netAuthenticationDialog.currentPassword,
+                         netAuthenticatinHandler.savePassword
+                        )
+       }
+   }
+
+   NetAuthenticationDialog {
+       id: netAuthenticationDialog
+       onSavePasswordChanged: {
+           savePassword = check
+           console.log("NetAuthenticationHandler savePassword="+savePassword)
+       }
+       onOk: {
+           if (!authTimer.running) {
+               authTimer.start()
+           }
+       }
+   }
+}

=== modified file 'src/app/qml/ui/FolderListPage.qml'
--- src/app/qml/ui/FolderListPage.qml	2015-09-07 21:33:03 +0000
+++ src/app/qml/ui/FolderListPage.qml	2015-09-07 21:33:03 +0000
@@ -194,6 +194,10 @@
         }
     }
 
+    NetAuthenticationHandler {
+        id: authenticationHandler
+    }
+
     FolderListModel {
         id: pageModel
         path: folderListPage.folder
@@ -215,6 +219,10 @@
             addAllowedDirectory(userplaces.locationPictures)
             addAllowedDirectory(userplaces.locationVideos)
         }
+        onNeedsAuthentication: {
+            console.log("FolderListModel needsAuthentication() signal arrived")
+            authenticationHandler.showDialog(urlPath,user)
+        }
     }
 
     FolderListModel {
@@ -880,11 +888,13 @@
         }
     }
 
-    function itemClicked(model) {
+    function itemClicked(model) {      
         if (model.isBrowsable) {
             if (model.isReadable && model.isExecutable) {
                 console.log("Changing to dir", model.filePath)
-                goTo(model.filePath)
+                //prefer pageModel.cdIntoIndex() because it is not necessary to parse the path
+                //goTo(model.filePath)
+                pageModel.cdIntoIndex(model.index)
             } else {
                 PopupUtils.open(Qt.resolvedUrl("NotifyDialog.qml"), delegate,
                                 {

=== 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-07 21:33:03 +0000
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2015 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Carlos Jose Mazieri <carlos.mazieri@xxxxxxxxx>
+ */
+import QtQuick 2.3
+import Ubuntu.Components 1.1
+import Ubuntu.Components.Popups 1.0
+import Ubuntu.Components.ListItems 1.0
+
+Dialog {
+    id: authenticationDialog
+    objectName: "authenticationDialog"
+    title: i18n.tr("Authentication required")
+
+    property alias  currentPath:     authCurrentPath.text
+    property alias  currentUserName: authUserName.text
+    property alias  currentPassword: authPassword.text   
+
+    signal ok()
+    signal savePasswordChanged(bool check)
+
+    function showDialog(path,user) {
+        currentPath     = path
+        currentUserName = user
+        autcheckSavePassword.checked    = true
+        authenticationDialog.show()
+    }
+
+    Component.onCompleted: {
+        authUserName.forceActiveFocus()
+        authUserName.cursorPosition = authUserName.text.length
+    }
+
+    Text {
+        id: authCurrentPath
+        anchors.horizontalCenter: parent.horizontalCenter
+        font.italic: true
+        elide: Text.ElideMiddle
+    }
+
+    Text {
+        text: i18n.tr("User")
+    }
+
+    TextField {
+        id: authUserName
+        objectName: "authUserName"
+        visible: true
+        focus: true
+    }
+
+    Text {
+        text: i18n.tr("Password")
+    }
+
+    TextField {
+        id: authPassword
+        objectName: "authPassword"
+        echoMode: TextInput.Password
+        focus: true
+        onAccepted: authOkButton.clicked()
+    }
+
+    Standard {
+        Label {
+            text: i18n.tr("Save password")
+            color: Theme.palette.normal.overlayText
+            anchors.left: parent.left
+            anchors.verticalCenter: parent.verticalCenter
+        }
+        control: CheckBox {
+            id: autcheckSavePassword
+            objectName: "autcheckSavePassword"
+            anchors.verticalCenter: parent.verticalCenter
+            onCheckedChanged: {
+                console.log("NetAuthenticationDialog::onCheckedChanged() checked="+checked)
+                savePasswordChanged(checked)
+            }
+        }
+    }
+
+    Button {
+        id: authOkButton
+        objectName: "authOkButton"
+        text: i18n.tr("Ok")
+        onClicked: {
+            ok()
+            PopupUtils.close(authenticationDialog)
+        }
+    }
+
+    Button {
+        id: authCancelButton
+        objectName: "authCancelButton"
+        text: i18n.tr("Cancel")
+        gradient: Gradient {
+            GradientStop {
+                position: 0
+                color: "gray"
+            }
+            GradientStop {
+                position: 1
+                color: "lightgray"
+            }
+        }
+        onClicked: {
+            PopupUtils.close(authenticationDialog)
+        }
+    }//authCancelButton
+}

=== modified file 'src/plugin/folderlistmodel/dirmodel.cpp'
--- src/plugin/folderlistmodel/dirmodel.cpp	2015-09-07 21:33:03 +0000
+++ src/plugin/folderlistmodel/dirmodel.cpp	2015-09-07 21:33:03 +0000
@@ -440,6 +440,19 @@
 }
 
 
+/*!
+ * \brief DirModel::setPathWithAuthentication() It is just a QML entry point as setPath is a QML property and cannot be called as a function
+ * \param path
+ * \param user
+ * \param password
+ * \param savePassword
+ */
+void DirModel::setPathWithAuthentication(const QString &path, const QString &user, const QString &password, bool savePassword)
+{
+    setPath(path,user,password,savePassword);
+}
+
+
 void DirModel::setPath(const QString &pathName, const QString& user, const QString &password, bool savePassword)
 {
     if (pathName.isEmpty())

=== 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-07 21:33:03 +0000
@@ -309,6 +309,11 @@
     Q_INVOKABLE  void  restoreIndexFromTrash(int index);
                  void  restoreIndexesFromTrash(const QList<int>&);
 
+    Q_INVOKABLE  void  setPathWithAuthentication(const QString& path,
+                                                 const QString& user,
+                                                 const QString& password,
+                                                 bool  savePassword);
+
 public slots:
   /*!
      * \brief copySelection() copy selected items to the clipboard


Follow ups