[Pkg-owncloud-commits] [owncloud-client] 125/164: ShareDialog: Consider if resharing is not allowed on a share.

Sandro Knauß hefee-guest at moszumanska.debian.org
Sun Mar 22 11:57:02 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 8cc5ff0e7059709b56b3a909d5fd0a17a793a47c
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Wed Mar 11 14:09:31 2015 +0100

    ShareDialog: Consider if resharing is not allowed on a share.
    
    If a file or directory is shared without resharing permission, the
    share dialog displays an error. This is not the optimal solution, but
    best for now, as we do not have the permissions available for the file
    manager plugin.
    
    This fixes #2923
---
 src/gui/application.cpp |  4 ++--
 src/gui/owncloudgui.cpp |  4 ++--
 src/gui/owncloudgui.h   |  2 +-
 src/gui/sharedialog.cpp | 28 ++++++++++++++++++++--------
 src/gui/sharedialog.h   |  6 ++++--
 src/gui/socketapi.cpp   | 16 +++++++++++++---
 src/gui/socketapi.h     |  2 +-
 7 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/src/gui/application.cpp b/src/gui/application.cpp
index 26b15c4..734f7f1 100644
--- a/src/gui/application.cpp
+++ b/src/gui/application.cpp
@@ -149,8 +149,8 @@ Application::Application(int &argc, char **argv) :
         slotAccountStateAdded(ai);
     }
 
-    connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, QString)),
-            _gui, SLOT(slotShowShareDialog(QString, QString)));
+    connect(FolderMan::instance()->socketApi(), SIGNAL(shareCommandReceived(QString, QString, bool)),
+            _gui, SLOT(slotShowShareDialog(QString, QString, bool)));
 
     // startup procedure.
     connect(&_checkConnectionTimer, SIGNAL(timeout()), this, SLOT(slotCheckConnection()));
diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp
index bf777f8..48ec2b5 100644
--- a/src/gui/owncloudgui.cpp
+++ b/src/gui/owncloudgui.cpp
@@ -642,7 +642,7 @@ void ownCloudGui::raiseDialog( QWidget *raiseWidget )
 }
 
 
-void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &localPath)
+void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed)
 {
     AccountPtr account = AccountManager::instance()->account();
     if (!account) {
@@ -651,7 +651,7 @@ void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &l
     }
 
     qDebug() << Q_FUNC_INFO << "Opening share dialog";
-    ShareDialog *w = new ShareDialog(account, sharePath, localPath);
+    ShareDialog *w = new ShareDialog(account, sharePath, localPath, resharingAllowed);
     w->getShares();
     w->setAttribute( Qt::WA_DeleteOnClose, true );
     raiseDialog(w);
diff --git a/src/gui/owncloudgui.h b/src/gui/owncloudgui.h
index 18dccae..9dedcc6 100644
--- a/src/gui/owncloudgui.h
+++ b/src/gui/owncloudgui.h
@@ -70,7 +70,7 @@ public slots:
     void slotHelp();
     void slotOpenPath(const QString& path);
     void slotAccountStateChanged();
-    void slotShowShareDialog(const QString &sharePath, const QString &localPath);
+    void slotShowShareDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed);
 
 private slots:
     void slotDisplayIdle();
diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp
index 4fce730..ae4506c 100644
--- a/src/gui/sharedialog.cpp
+++ b/src/gui/sharedialog.cpp
@@ -33,14 +33,15 @@ namespace {
 
 namespace OCC {
 
-ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath, QWidget *parent) :
+ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath, bool resharingAllowed, QWidget *parent) :
    QDialog(parent),
     _ui(new Ui::ShareDialog),
     _account(account),
     _sharePath(sharePath),
     _localPath(localPath),
     _passwordJobRunning(false),
-    _public_share_id(0)
+    _public_share_id(0),
+    _resharingAllowed(resharingAllowed)
 {
     setAttribute(Qt::WA_DeleteOnClose);
     _ui->setupUi(this);
@@ -310,9 +311,15 @@ void ShareDialog::slotSharesFetched(const QString &reply)
     if( _shares.count()>0 ) {
         setShareCheckBoxTitle(true);
     } else {
-        // check the checkbox to create a link.
-        _ui->checkBox_shareLink->setChecked(true);
-        slotCheckBoxShareLinkClicked();
+        // If there are no shares yet, check the checkbox to create a link automatically.
+        // If its clear that resharing is not allowed, display an error
+        if( !_resharingAllowed ) {
+            displayError(tr("The file can not be shared because it was shared without sharing permission."));
+            _ui->checkBox_shareLink->setEnabled(false);
+        } else {
+            _ui->checkBox_shareLink->setChecked(true);
+            slotCheckBoxShareLinkClicked();
+        }
     }
 }
 
@@ -482,19 +489,24 @@ void ShareDialog::setShareCheckBoxTitle(bool haveShares)
 
 }
 
-void ShareDialog::displayError(int code)
+void ShareDialog::displayError(const QString& errMsg)
 {
-    const QString errMsg = tr("OCS API error code: %1").arg(code);
     _ui->errorLabel->setText( errMsg );
     _ui->errorLabel->show();
 }
 
+void ShareDialog::displayError(int code)
+{
+    const QString errMsg = tr("OCS API error code: %1").arg(code);
+    displayError(errMsg);
+}
+
+#if 0
 void ShareDialog::displayInfo( const QString& msg )
 {
     _ui->label_sharePath->setText(msg);
 }
 
-#if 0
 /*
  * This code is disabled for now as we do not have answers for all the questions involved
  * here, see https://github.com/owncloud/client/issues/2732
diff --git a/src/gui/sharedialog.h b/src/gui/sharedialog.h
index 997e17e..2d86fd0 100644
--- a/src/gui/sharedialog.h
+++ b/src/gui/sharedialog.h
@@ -57,7 +57,8 @@ class ShareDialog : public QDialog
     Q_OBJECT
 
 public:
-    explicit ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath, QWidget *parent = 0);
+    explicit ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath,
+                         bool resharingAllowed, QWidget *parent = 0);
     ~ShareDialog();
     void getShares();
 
@@ -77,7 +78,7 @@ private slots:
 private:
     void setShareCheckBoxTitle(bool haveShares);
     void displayError(int code);
-    void displayInfo( const QString& msg );
+    void displayError(const QString& errMsg);
     void setShareLink( const QString& url );
 
     Ui::ShareDialog *_ui;
@@ -102,6 +103,7 @@ private:
     QProgressIndicator *_pi_password;
     QProgressIndicator *_pi_date;
 
+    bool _resharingAllowed;
 };
 
 }
diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp
index e9b62d9..fa8244f 100644
--- a/src/gui/socketapi.cpp
+++ b/src/gui/socketapi.cpp
@@ -420,12 +420,22 @@ void SocketApi::command_SHARE(const QString& localFile, SocketType* socket)
         // files that are not within a sync folder are not synced.
         sendMessage(socket, message);
     } else {
+        const QString folderForPath = shareFolder->path();
+        const QString remotePath = shareFolder->remotePath() + localFile.right(localFile.count()-folderForPath.count()+1);
+
+        SyncJournalFileRecord rec = dbFileRecord_capi(shareFolder, localFile);
+
+        bool allowReshare = true; // lets assume the good
+        if( rec.isValid() ) {
+            // check the permission: Is resharing allowed?
+            if( !rec._remotePerm.contains('R') ) {
+                allowReshare = false;
+            }
+        }
         const QString message = QLatin1String("SHARE:OK:")+QDir::toNativeSeparators(localFile);
         sendMessage(socket, message);
 
-        const QString folderForPath = shareFolder->path();
-        const QString remotePath = shareFolder->remotePath() + localFile.right(localFile.count()-folderForPath.count()+1);
-        emit shareCommandReceived(remotePath, localFile);
+        emit shareCommandReceived(remotePath, localFile, allowReshare);
     }
 }
 
diff --git a/src/gui/socketapi.h b/src/gui/socketapi.h
index 45fdb8a..b6c82d9 100644
--- a/src/gui/socketapi.h
+++ b/src/gui/socketapi.h
@@ -58,7 +58,7 @@ public slots:
     void slotClearExcludesList();
 
 signals:
-    void shareCommandReceived(const QString &sharePath, const QString &localPath);
+    void shareCommandReceived(const QString &sharePath, const QString &localPath, bool resharingAllowed);
 
 private slots:
     void slotNewConnection();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list