Displays the uid_owner of a shared file.

Also displays the sharees that reshared it via share link.

Signed-off-by: Camila San <hello@camila.codes>
This commit is contained in:
Camila San 2019-06-21 18:36:45 +02:00
parent 459a17bd7e
commit d6a0a5272a
No known key found for this signature in database
GPG Key ID: 7A4A6121E88E2AD4
6 changed files with 193 additions and 129 deletions

View 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;
}

View 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">
@ -29,6 +29,131 @@
<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>
@ -102,60 +227,6 @@
</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">
@ -172,77 +243,6 @@
</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"/>

View 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(),

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

View 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);

View File

@ -32,6 +32,13 @@
<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">