Displays the uid_owner of a shared file.
authorCamila San <hello@camila.codes>
Fri, 21 Jun 2019 16:36:45 +0000 (18:36 +0200)
committerCamila San <hello@camila.codes>
Fri, 21 Jun 2019 16:36:45 +0000 (18:36 +0200)
Also displays the sharees that reshared it via share link.

Signed-off-by: Camila San <hello@camila.codes>
src/gui/sharedialog.cpp
src/gui/sharelinkwidget.ui
src/gui/sharemanager.cpp
src/gui/sharemanager.h
src/gui/shareusergroupwidget.cpp
src/gui/shareusergroupwidget.ui

index 57126988bfca3a0a8290b7bf2aaf226f0850c8e4..bc45eed20ab642f112586bbe557ef2b66707025b 100644 (file)
@@ -194,7 +194,7 @@ void ShareDialog::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
     const QString versionString = _accountState->account()->serverVersion();
     qCInfo(lcSharing) << versionString << "Fetched" << shares.count() << "shares";
     foreach (auto share, shares) {
-        if (share->getShareType() != Share::TypeLink) {
+        if (share->getShareType() != Share::TypeLink || share->getUidOwner() != share->account()->davUser()) {
             continue;
         }
 
index c0b85261f668de99ff0795262348a2e17c66faf2..c2fe47103f5f17dcc4016ccb3f9a6d8fd4154ad6 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>350</width>
-    <height>136</height>
+    <height>160</height>
    </rect>
   </property>
   <property name="sizePolicy">
    <property name="bottomMargin">
     <number>0</number>
    </property>
+   <item row="2" column="1">
+    <widget class="QDateEdit" name="calendar">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+       <horstretch>1</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="passwordLabel">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+       <horstretch>1</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="text">
+      <string>Password:</string>
+     </property>
+     <property name="indent">
+      <number>20</number>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="3">
+    <widget class="QToolButton" name="shareLinkToolButton">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
+     <property name="icon">
+      <iconset resource="../../client.qrc">
+       <normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset>
+     </property>
+     <property name="popupMode">
+      <enum>QToolButton::InstantPopup</enum>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0" colspan="4">
+    <widget class="QLabel" name="errorLabel">
+     <property name="palette">
+      <palette>
+       <active>
+        <colorrole role="WindowText">
+         <brush brushstyle="SolidPattern">
+          <color alpha="255">
+           <red>255</red>
+           <green>0</green>
+           <blue>0</blue>
+          </color>
+         </brush>
+        </colorrole>
+       </active>
+       <inactive>
+        <colorrole role="WindowText">
+         <brush brushstyle="SolidPattern">
+          <color alpha="255">
+           <red>255</red>
+           <green>0</green>
+           <blue>0</blue>
+          </color>
+         </brush>
+        </colorrole>
+       </inactive>
+       <disabled>
+        <colorrole role="WindowText">
+         <brush brushstyle="SolidPattern">
+          <color alpha="255">
+           <red>123</red>
+           <green>121</green>
+           <blue>134</blue>
+          </color>
+         </brush>
+        </colorrole>
+       </disabled>
+      </palette>
+     </property>
+     <property name="text">
+      <string>TextLabel</string>
+     </property>
+     <property name="textFormat">
+      <enum>Qt::PlainText</enum>
+     </property>
+     <property name="wordWrap">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="QLineEdit" name="lineEdit_password">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+       <horstretch>1</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="echoMode">
+      <enum>QLineEdit::Password</enum>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="2">
+    <widget class="QToolButton" name="confirmPassword">
+     <property name="icon">
+      <iconset resource="../../client.qrc">
+       <normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
+     </property>
+     <property name="autoRaise">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="2">
+    <widget class="QToolButton" name="confirmExpirationDate">
+     <property name="icon">
+      <iconset resource="../../client.qrc">
+       <normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
+     </property>
+     <property name="autoRaise">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
    <item row="0" column="0" colspan="3">
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
      </item>
     </layout>
    </item>
-   <item row="0" column="3">
-    <widget class="QToolButton" name="shareLinkToolButton">
-     <property name="enabled">
-      <bool>false</bool>
-     </property>
-     <property name="icon">
-      <iconset resource="../../client.qrc">
-       <normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset>
-     </property>
-     <property name="popupMode">
-      <enum>QToolButton::InstantPopup</enum>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="0">
-    <widget class="QLabel" name="passwordLabel">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-       <horstretch>1</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="text">
-      <string>Password:</string>
-     </property>
-     <property name="indent">
-      <number>20</number>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="1">
-    <widget class="QLineEdit" name="lineEdit_password">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-       <horstretch>1</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="echoMode">
-      <enum>QLineEdit::Password</enum>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="2">
-    <widget class="QToolButton" name="confirmPassword">
-     <property name="icon">
-      <iconset resource="../../client.qrc">
-       <normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
-     </property>
-     <property name="autoRaise">
-      <bool>true</bool>
-     </property>
-    </widget>
-   </item>
    <item row="2" column="0">
     <widget class="QLabel" name="expirationLabel">
      <property name="sizePolicy">
      </property>
     </widget>
    </item>
-   <item row="2" column="1">
-    <widget class="QDateEdit" name="calendar">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
-       <horstretch>1</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="2">
-    <widget class="QToolButton" name="confirmExpirationDate">
-     <property name="icon">
-      <iconset resource="../../client.qrc">
-       <normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
-     </property>
-     <property name="autoRaise">
-      <bool>true</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="0" colspan="4">
-    <widget class="QLabel" name="errorLabel">
-     <property name="palette">
-      <palette>
-       <active>
-        <colorrole role="WindowText">
-         <brush brushstyle="SolidPattern">
-          <color alpha="255">
-           <red>255</red>
-           <green>0</green>
-           <blue>0</blue>
-          </color>
-         </brush>
-        </colorrole>
-       </active>
-       <inactive>
-        <colorrole role="WindowText">
-         <brush brushstyle="SolidPattern">
-          <color alpha="255">
-           <red>255</red>
-           <green>0</green>
-           <blue>0</blue>
-          </color>
-         </brush>
-        </colorrole>
-       </inactive>
-       <disabled>
-        <colorrole role="WindowText">
-         <brush brushstyle="SolidPattern">
-          <color alpha="255">
-           <red>123</red>
-           <green>121</green>
-           <blue>134</blue>
-          </color>
-         </brush>
-        </colorrole>
-       </disabled>
-      </palette>
-     </property>
-     <property name="text">
-      <string>TextLabel</string>
-     </property>
-     <property name="textFormat">
-      <enum>Qt::PlainText</enum>
-     </property>
-     <property name="wordWrap">
-      <bool>true</bool>
-     </property>
-    </widget>
-   </item>
   </layout>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
index 4bc32182aec9ca936c58e1d91c8a39e979847550..1f96f2c6fae148f1135f8f7969c1f463092564cf 100644 (file)
@@ -52,12 +52,16 @@ static void updateFolder(const AccountPtr &account, const QString &path)
 
 Share::Share(AccountPtr account,
     const QString &id,
+    const QString &uidowner,
+    const QString &ownerDisplayName,
     const QString &path,
     const ShareType shareType,
     const Permissions permissions,
     const QSharedPointer<Sharee> shareWith)
     : _account(account)
     , _id(id)
+    , _uidowner(uidowner)
+    , _ownerDisplayName(ownerDisplayName)
     , _path(path)
     , _shareType(shareType)
     , _permissions(permissions)
@@ -80,6 +84,16 @@ QString Share::getId() const
     return _id;
 }
 
+QString Share::getUidOwner() const
+{
+    return _uidowner;
+}
+
+QString Share::getOwnerDisplayName() const
+{
+    return _ownerDisplayName;
+}
+
 Share::ShareType Share::getShareType() const
 {
     return _shareType;
@@ -153,6 +167,8 @@ bool LinkShare::isPasswordSet() const
 
 LinkShare::LinkShare(AccountPtr account,
     const QString &id,
+    const QString &uidowner,
+    const QString &ownerDisplayName,
     const QString &path,
     const QString &name,
     const QString &token,
@@ -160,7 +176,7 @@ LinkShare::LinkShare(AccountPtr account,
     bool passwordSet,
     const QUrl &url,
     const QDate &expireDate)
-    : Share(account, id, path, Share::TypeLink, permissions)
+    : Share(account, id, uidowner, ownerDisplayName, path, Share::TypeLink, permissions)
     , _name(name)
     , _token(token)
     , _passwordSet(passwordSet)
@@ -393,6 +409,8 @@ QSharedPointer<LinkShare> ShareManager::parseLinkShare(const QJsonObject &data)
 
     return QSharedPointer<LinkShare>(new LinkShare(_account,
         data.value("id").toVariant().toString(), // "id" used to be an integer, support both
+        data.value("uid_owner").toString(),
+        data.value("displayname_owner").toString(),
         data.value("path").toString(),
         data.value("name").toString(),
         data.value("token").toString(),
@@ -410,6 +428,8 @@ QSharedPointer<Share> ShareManager::parseShare(const QJsonObject &data)
 
     return QSharedPointer<Share>(new Share(_account,
         data.value("id").toVariant().toString(), // "id" used to be an integer, support both
+        data.value("uid_owner").toVariant().toString(),
+        data.value("displayname_owner").toVariant().toString(),
         data.value("path").toString(),
         (Share::ShareType)data.value("share_type").toInt(),
         (Share::Permissions)data.value("permissions").toInt(),
index 18d060bae8ad435ba78d72ace37cac239b8bc454..db48771b18ce5be7bf428de39ebc5525069884a6 100644 (file)
@@ -54,6 +54,8 @@ public:
      */
     explicit Share(AccountPtr account,
         const QString &id,
+        const QString &owner,
+        const QString &ownerDisplayName,
         const QString &path,
         const ShareType shareType,
         const Permissions permissions = SharePermissionDefault,
@@ -71,6 +73,16 @@ public:
      */
     QString getId() const;
 
+    /*
+     * Get the uid_owner
+     */
+    QString getUidOwner() const;
+
+    /*
+     * Get the owner display name
+     */
+    QString getOwnerDisplayName() const;
+
     /*
      * Get the shareType
      */
@@ -110,6 +122,8 @@ signals:
 protected:
     AccountPtr _account;
     QString _id;
+    QString _uidowner;
+    QString _ownerDisplayName;
     QString _path;
     ShareType _shareType;
     Permissions _permissions;
@@ -134,6 +148,8 @@ class LinkShare : public Share
 public:
     explicit LinkShare(AccountPtr account,
         const QString &id,
+        const QString &uidowner,
+        const QString &ownerDisplayName,
         const QString &path,
         const QString &name,
         const QString &token,
index d576b1edb1678aa39dae7c8c8a53630792551520..bb0ebad6585374feff41e2dc297c8cc5406e6a53 100644 (file)
@@ -190,13 +190,23 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
     layout->setContentsMargins(0, 0, 0, 0);
     int x = 0;
     int height = 0;
+    QList<QString> linkOwners({});
 
     foreach (const auto &share, shares) {
         // We don't handle link shares, only TypeUser or TypeGroup
         if (share->getShareType() == Share::TypeLink) {
+            if(!share->getUidOwner().isEmpty() &&
+                    share->getUidOwner() != share->account()->davUser()){
+                linkOwners.append(share->getOwnerDisplayName());
+             }
             continue;
         }
 
+        // the owner of the file that shared it first
+        if(x == 0 && !share->getUidOwner().isEmpty()){
+            _ui->mainOwnerLabel->setText(QString("Shared with you by ").append(share->getOwnerDisplayName()));
+        }
+
         ShareUserLine *s = new ShareUserLine(share, _maxSharingPermissions, _isFile, _parentScrollArea);
         connect(s, &ShareUserLine::resizeRequested, this, &ShareUserGroupWidget::slotAdjustScrollWidgetSize);
         connect(s, &ShareUserLine::visualDeletionDone, this, &ShareUserGroupWidget::getShares);
@@ -210,7 +220,18 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
         }
     }
 
-    scrollArea->setFrameShape(x > 3 ? QFrame::StyledPanel : QFrame::NoFrame);
+    foreach (const QString &owner, linkOwners) {
+        auto ownerLabel = new QLabel(QString(owner + " shared via link"));
+        layout->addWidget(ownerLabel);
+        ownerLabel->setVisible(true);
+
+        x++;
+        if (x <= 6) {
+            height = newViewPort->sizeHint().height();
+        }
+    }
+
+    scrollArea->setFrameShape(x > 6 ? QFrame::StyledPanel : QFrame::NoFrame);
     scrollArea->setVisible(!shares.isEmpty());
     scrollArea->setFixedHeight(height);
     scrollArea->setWidget(newViewPort);
index 51682bb05601784c19de172969015d6ce4c97d5a..ed1e43e7f79902dc048858850ef791c72b078eb3 100644 (file)
    <property name="bottomMargin">
     <number>0</number>
    </property>
+   <item>
+    <widget class="QLabel" name="mainOwnerLabel">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
    <item>
     <layout class="QHBoxLayout" name="shareeHorizontalLayout">
      <property name="leftMargin">