[Pkg-owncloud-commits] [owncloud-client] 67/484: Allow setting op public upload on link shares

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:14 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 2fdae6d72fe939716c7af62e689a99ad1c63be8a
Author: Roeland Jago Douma <roeland at famdouma.nl>
Date:   Thu Aug 20 13:40:10 2015 +0200

    Allow setting op public upload on link shares
---
 src/gui/sharedialog.cpp |  76 ++++++++++++++++++++++++++++++++-
 src/gui/sharedialog.h   |   5 +++
 src/gui/sharedialog.ui  | 111 +++++++++++++++++++++++++++++-------------------
 3 files changed, 147 insertions(+), 45 deletions(-)

diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp
index f1775fe..c4ac51a 100644
--- a/src/gui/sharedialog.cpp
+++ b/src/gui/sharedialog.cpp
@@ -29,11 +29,21 @@
 #include <QBuffer>
 #include <QFileIconProvider>
 #include <QClipboard>
+#include <QFileInfo>
 
 namespace {
     int SHARETYPE_PUBLIC = 3;
+
+//    int PERMISSION_READ = 1;
+    int PERMISSION_UPDATE = 2;
+    int PERMISSION_CREATE = 4;
+//    int PERMISSION_DELETE = 8;
+//    int PERMISSION_SHARE = 16;
+//    int PERMISSION_ALL = 31;
 }
 
+
+
 namespace OCC {
 
 ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QString &localPath, bool resharingAllowed, QWidget *parent) :
@@ -50,6 +60,10 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
     setObjectName("SharingDialog"); // required as group for saveGeometry call
 
     _ui->setupUi(this);
+
+    //Is this a file or folder?
+    _isFile = QFileInfo(localPath).isFile();
+
     _ui->pushButton_copy->setIcon(QIcon::fromTheme("edit-copy"));
     _ui->pushButton_copy->setEnabled(false);
     connect(_ui->pushButton_copy, SIGNAL(clicked(bool)), SLOT(slotPushButtonCopyLinkPressed()));
@@ -64,8 +78,10 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
     _pi_link     = new QProgressIndicator();
     _pi_password = new QProgressIndicator();
     _pi_date     = new QProgressIndicator();
+    _pi_editing  = new QProgressIndicator();
     _ui->horizontalLayout_shareLink->addWidget(_pi_link);
     _ui->horizontalLayout_password->addWidget(_pi_password);
+    _ui->horizontalLayout_editing->addWidget(_pi_editing);
     // _ui->horizontalLayout_expire->addWidget(_pi_date);
 
     connect(_ui->checkBox_shareLink, SIGNAL(clicked()), this, SLOT(slotCheckBoxShareLinkClicked()));
@@ -75,6 +91,7 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
     connect(_ui->pushButton_setPassword, SIGNAL(clicked(bool)), SLOT(slotPasswordReturnPressed()));
     connect(_ui->checkBox_expire, SIGNAL(clicked()), this, SLOT(slotCheckBoxExpireClicked()));
     connect(_ui->calendar, SIGNAL(dateChanged(QDate)), SLOT(slotCalendarClicked(QDate)));
+    connect(_ui->checkBox_editing, SIGNAL(clicked()), this, SLOT(slotCheckBoxEditingClicked()));
 
     //Disable checkbox
     _ui->checkBox_shareLink->setEnabled(false);
@@ -154,6 +171,15 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
             _account->capabilities().sharePublicLinkExpireDateDays()
             ));
     }
+
+    // File can't have public upload set.
+    if (_isFile) {
+        _ui->checkBox_editing->setEnabled(false);
+    } else {
+        if (!_account->capabilities().sharePublicLinkAllowUpload()) {
+            _ui->checkBox_editing->setEnabled(false);
+        }
+    }
 }
 
 void ShareDialog::done( int r ) {
@@ -355,6 +381,17 @@ void ShareDialog::slotSharesFetched(const QVariantMap &reply)
                 _ui->checkBox_expire->setChecked(false);
             }
 
+            if (data.value("permissions").isValid()) {
+                int permissions = data.value("permissions").toInt();
+                /*
+                 * Only directories can have public upload set
+                 * For public links the server sets CREATE and UPDATE permissions.
+                 */
+                if (!_isFile && (permissions & PERMISSION_UPDATE) && (permissions & PERMISSION_CREATE)) {
+                    _ui->checkBox_editing->setChecked(true);
+                }
+            }
+
             QString url;
             // From ownCloud server 8.2 the url field is always set for public shares
             if (data.contains("url")) {
@@ -541,7 +578,7 @@ void ShareDialog::slotCheckBoxExpireClicked()
     if (_ui->checkBox_expire->checkState() == Qt::Checked)
     {
         const QDate date = QDate::currentDate().addDays(1);
-        ShareDialog::setExpireDate(date);
+        setExpireDate(date);
         _ui->calendar->setDate(date);
         _ui->calendar->setMinimumDate(date);
         _ui->calendar->setEnabled(true);
@@ -559,6 +596,43 @@ void ShareDialog::slotPushButtonCopyLinkPressed()
     clipboard->setText(_shareUrl);
 }
 
+void ShareDialog::slotCheckBoxEditingClicked()
+{
+    ShareDialog::setPublicUpload(_ui->checkBox_editing->checkState() == Qt::Checked);
+}
+
+void ShareDialog::setPublicUpload(bool publicUpload)
+{
+    _ui->checkBox_editing->setEnabled(false);
+    _pi_editing->startAnimation();
+
+    const QUrl url = Account::concatUrlPath(_account->url(), QString("ocs/v1.php/apps/files_sharing/api/v1/shares/%1").arg(_public_share_id));
+
+    QList<QPair<QString, QString> > requestParams;
+    const QString value = QString::fromLatin1(publicUpload ? "true" : "false");
+    requestParams.append(qMakePair(QString::fromLatin1("publicUpload"), value));
+
+    OcsShareJob *job = new OcsShareJob("PUT", url, _account, this);
+    job->setPostParams(requestParams);
+    connect(job, SIGNAL(jobFinished(QVariantMap)), this, SLOT(slotPublicUploadSet(QVariantMap)));
+
+    job->start();
+}
+
+void ShareDialog::slotPublicUploadSet(const QVariantMap &reply)
+{
+    QString message;
+    int code = getJsonReturnCode(reply, message);
+    if (code == 100) {
+        _ui->checkBox_editing->setEnabled(true);
+    } else {
+        qDebug() << Q_FUNC_INFO << reply;
+        displayError(code);
+    }
+
+    _pi_editing->stopAnimation();
+}
+
 void ShareDialog::setShareCheckBoxTitle(bool haveShares)
 {
     const QString noSharesTitle(tr("&Share link"));
diff --git a/src/gui/sharedialog.h b/src/gui/sharedialog.h
index 980e38d..fba05f3 100644
--- a/src/gui/sharedialog.h
+++ b/src/gui/sharedialog.h
@@ -100,6 +100,8 @@ private slots:
     void slotPasswordChanged(const QString& newText);
     void slotPushButtonCopyLinkPressed();
     void slotThumbnailFetched(const int &statusCode, const QByteArray &reply);
+    void slotCheckBoxEditingClicked();
+    void slotPublicUploadSet(const QVariantMap &reply);
 
     void done( int r );
 private:
@@ -109,6 +111,7 @@ private:
     void setShareLink( const QString& url );
     void resizeEvent(QResizeEvent *e);
     void redrawElidedUrl();
+    void setPublicUpload(bool publicUpload);
 
     Ui::ShareDialog *_ui;
     AccountPtr _account;
@@ -130,8 +133,10 @@ private:
     QProgressIndicator *_pi_link;
     QProgressIndicator *_pi_password;
     QProgressIndicator *_pi_date;
+    QProgressIndicator *_pi_editing;
 
     bool _resharingAllowed;
+    bool _isFile;
 };
 
 }
diff --git a/src/gui/sharedialog.ui b/src/gui/sharedialog.ui
index b38863a..dab61b8 100644
--- a/src/gui/sharedialog.ui
+++ b/src/gui/sharedialog.ui
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>372</width>
-    <height>241</height>
+    <height>277</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -92,37 +92,49 @@
       <property name="rightMargin">
        <number>0</number>
       </property>
-      <item row="0" column="0">
-       <layout class="QHBoxLayout" name="horizontalLayout_3">
-        <property name="sizeConstraint">
-         <enum>QLayout::SetDefaultConstraint</enum>
+      <item row="2" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout">
+        <property name="leftMargin">
+         <number>20</number>
         </property>
         <item>
-         <widget class="QLabel" name="_labelShareLink">
+         <widget class="QLineEdit" name="lineEdit_password">
+          <property name="echoMode">
+           <enum>QLineEdit::Password</enum>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="pushButton_setPassword">
           <property name="sizePolicy">
-           <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+           <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
             <horstretch>0</horstretch>
             <verstretch>0</verstretch>
            </sizepolicy>
           </property>
-          <property name="frameShape">
-           <enum>QFrame::NoFrame</enum>
-          </property>
           <property name="text">
-           <string/>
-          </property>
-          <property name="textFormat">
-           <enum>Qt::RichText</enum>
-          </property>
-          <property name="openExternalLinks">
-           <bool>true</bool>
+           <string>Set &password </string>
           </property>
          </widget>
         </item>
+       </layout>
+      </item>
+      <item row="4" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
         <item>
-         <widget class="QPushButton" name="pushButton_copy">
+         <widget class="QCheckBox" name="checkBox_expire">
           <property name="text">
-           <string>Copy &link</string>
+           <string>Set &expiration date</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QDateEdit" name="calendar">
+          <property name="calendarPopup">
+           <bool>true</bool>
           </property>
          </widget>
         </item>
@@ -158,51 +170,63 @@
         </item>
        </layout>
       </item>
-      <item row="2" column="0">
-       <layout class="QHBoxLayout" name="horizontalLayout">
-        <property name="leftMargin">
-         <number>20</number>
+      <item row="0" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout_3">
+        <property name="sizeConstraint">
+         <enum>QLayout::SetDefaultConstraint</enum>
         </property>
         <item>
-         <widget class="QLineEdit" name="lineEdit_password">
-          <property name="echoMode">
-           <enum>QLineEdit::Password</enum>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QPushButton" name="pushButton_setPassword">
+         <widget class="QLabel" name="_labelShareLink">
           <property name="sizePolicy">
-           <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+           <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
             <horstretch>0</horstretch>
             <verstretch>0</verstretch>
            </sizepolicy>
           </property>
+          <property name="frameShape">
+           <enum>QFrame::NoFrame</enum>
+          </property>
           <property name="text">
-           <string>Set &password </string>
+           <string/>
+          </property>
+          <property name="textFormat">
+           <enum>Qt::RichText</enum>
+          </property>
+          <property name="openExternalLinks">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QPushButton" name="pushButton_copy">
+          <property name="text">
+           <string>Copy &link</string>
           </property>
          </widget>
         </item>
        </layout>
       </item>
       <item row="3" column="0">
-       <layout class="QHBoxLayout" name="horizontalLayout_2">
-        <property name="leftMargin">
-         <number>0</number>
-        </property>
+       <layout class="QHBoxLayout" name="horizontalLayout_editing">
         <item>
-         <widget class="QCheckBox" name="checkBox_expire">
+         <widget class="QCheckBox" name="checkBox_editing">
           <property name="text">
-           <string>Set &expiration date</string>
+           <string>Allow editing</string>
           </property>
          </widget>
         </item>
         <item>
-         <widget class="QDateEdit" name="calendar">
-          <property name="calendarPopup">
-           <bool>true</bool>
+         <spacer name="horizontalSpacer">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
           </property>
-         </widget>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
         </item>
        </layout>
       </item>
@@ -252,7 +276,6 @@
   <zorder>errorLabel</zorder>
   <zorder>widget_shareLink</zorder>
   <zorder>buttonBox</zorder>
-  <zorder>checkBox_password</zorder>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>

-- 
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