mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 05:25:50 +03:00
Merge pull request #4673 from ckamm/shareperm
Disable unavailable sharing permissions #4383
This commit is contained in:
commit
48e594ebbf
12 changed files with 201 additions and 95 deletions
|
@ -122,7 +122,7 @@ void OcsShareJob::createShare(const QString& path,
|
|||
addParam(QString::fromLatin1("path"), path);
|
||||
addParam(QString::fromLatin1("shareType"), QString::number(shareType));
|
||||
addParam(QString::fromLatin1("shareWith"), shareWith);
|
||||
if (!(permissions & Share::PermissionDefault)) {
|
||||
if (!(permissions & SharePermissionDefault)) {
|
||||
addParam(QString::fromLatin1("permissions"), QString::number(permissions));
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
void createShare(const QString& path,
|
||||
const Share::ShareType shareType,
|
||||
const QString& shareWith = "",
|
||||
const Share::Permissions permissions = Share::PermissionRead);
|
||||
const Share::Permissions permissions = SharePermissionRead);
|
||||
|
||||
/**
|
||||
* Returns information on the items shared with the current user.
|
||||
|
|
|
@ -870,14 +870,27 @@ void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &l
|
|||
|
||||
const auto accountState = folder->accountState();
|
||||
|
||||
// As a first approximation, set the set of permissions that can be granted
|
||||
// either to everything (resharing allowed) or nothing (no resharing).
|
||||
//
|
||||
// The correct value will be found with a propfind from ShareDialog.
|
||||
// (we want to show the dialog directly, not wait for the propfind first)
|
||||
SharePermissions maxSharingPermissions =
|
||||
SharePermissionRead
|
||||
| SharePermissionUpdate | SharePermissionCreate | SharePermissionDelete
|
||||
| SharePermissionShare;
|
||||
if (!resharingAllowed) {
|
||||
maxSharingPermissions = 0;
|
||||
}
|
||||
|
||||
|
||||
ShareDialog *w = 0;
|
||||
if (_shareDialogs.contains(localPath) && _shareDialogs[localPath]) {
|
||||
qDebug() << Q_FUNC_INFO << "Raising share dialog" << sharePath << localPath;
|
||||
w = _shareDialogs[localPath];
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "Opening share dialog" << sharePath << localPath;
|
||||
w = new ShareDialog(accountState, sharePath, localPath, resharingAllowed);
|
||||
w->getShares();
|
||||
qDebug() << Q_FUNC_INFO << "Opening share dialog" << sharePath << localPath << maxSharingPermissions;
|
||||
w = new ShareDialog(accountState, sharePath, localPath, maxSharingPermissions);
|
||||
w->setAttribute( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
_shareDialogs[localPath] = w;
|
||||
|
|
|
@ -135,8 +135,8 @@ LinkShare::LinkShare(AccountPtr account,
|
|||
|
||||
bool LinkShare::getPublicUpload()
|
||||
{
|
||||
return ((_permissions & PermissionUpdate) &&
|
||||
(_permissions & PermissionCreate));
|
||||
return ((_permissions & SharePermissionUpdate) &&
|
||||
(_permissions & SharePermissionCreate));
|
||||
}
|
||||
|
||||
void LinkShare::setPublicUpload(bool publicUpload)
|
||||
|
@ -150,9 +150,9 @@ void LinkShare::setPublicUpload(bool publicUpload)
|
|||
void LinkShare::slotPublicUploadSet(const QVariantMap&, const QVariant &value)
|
||||
{
|
||||
if (value.toBool()) {
|
||||
_permissions = PermissionRead | PermissionUpdate | PermissionCreate;
|
||||
_permissions = SharePermissionRead | SharePermissionUpdate | SharePermissionCreate;
|
||||
} else {
|
||||
_permissions = PermissionRead;
|
||||
_permissions = SharePermissionRead;
|
||||
}
|
||||
|
||||
emit publicUploadSet();
|
||||
|
@ -260,7 +260,7 @@ void ShareManager::slotCreateShare(const QVariantMap &reply)
|
|||
_jobContinuation.remove(sender());
|
||||
|
||||
// Find existing share permissions (if this was shared with us)
|
||||
Share::Permissions existingPermissions = Share::PermissionDefault;
|
||||
Share::Permissions existingPermissions = SharePermissionDefault;
|
||||
foreach (const QVariant & element, reply["ocs"].toMap()["data"].toList()) {
|
||||
QVariantMap map = element.toMap();
|
||||
if (map["file_target"] == cont.path)
|
||||
|
@ -269,9 +269,9 @@ void ShareManager::slotCreateShare(const QVariantMap &reply)
|
|||
|
||||
// Limit the permissions we request for a share to the ones the item
|
||||
// was shared with initially.
|
||||
if (cont.permissions == Share::PermissionDefault) {
|
||||
if (cont.permissions == SharePermissionDefault) {
|
||||
cont.permissions = existingPermissions;
|
||||
} else if (existingPermissions != Share::PermissionDefault) {
|
||||
} else if (existingPermissions != SharePermissionDefault) {
|
||||
cont.permissions &= existingPermissions;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "accountfwd.h"
|
||||
#include "sharee.h"
|
||||
#include "sharepermissions.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QDate>
|
||||
|
@ -43,18 +44,7 @@ public:
|
|||
TypeRemote = Sharee::Federated
|
||||
};
|
||||
|
||||
/**
|
||||
* Possible permissions
|
||||
*/
|
||||
enum Permission {
|
||||
PermissionRead = 1,
|
||||
PermissionUpdate = 2,
|
||||
PermissionCreate = 4,
|
||||
PermissionDelete = 8,
|
||||
PermissionShare = 16,
|
||||
PermissionDefault = 1 << 30
|
||||
};
|
||||
Q_DECLARE_FLAGS(Permissions, Permission)
|
||||
typedef SharePermissions Permissions;
|
||||
|
||||
/*
|
||||
* Constructor for shares
|
||||
|
@ -63,7 +53,7 @@ public:
|
|||
const QString& id,
|
||||
const QString& path,
|
||||
const ShareType shareType,
|
||||
const Permissions permissions = PermissionDefault,
|
||||
const Permissions permissions = SharePermissionDefault,
|
||||
const QSharedPointer<Sharee> shareWith = QSharedPointer<Sharee>(NULL));
|
||||
|
||||
/**
|
||||
|
@ -208,7 +198,6 @@ private:
|
|||
QDate _expireDate;
|
||||
QUrl _url;
|
||||
};
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Share::Permissions)
|
||||
|
||||
/**
|
||||
* The share manager allows for creating, retrieving and deletion
|
||||
|
|
|
@ -31,15 +31,20 @@
|
|||
|
||||
namespace OCC {
|
||||
|
||||
ShareDialog::ShareDialog(QPointer<AccountState> accountState, const QString &sharePath, const QString &localPath, bool resharingAllowed, QWidget *parent) :
|
||||
ShareDialog::ShareDialog(QPointer<AccountState> accountState,
|
||||
const QString &sharePath,
|
||||
const QString &localPath,
|
||||
SharePermissions maxSharingPermissions,
|
||||
QWidget *parent) :
|
||||
QDialog(parent),
|
||||
_ui(new Ui::ShareDialog),
|
||||
_accountState(accountState),
|
||||
_sharePath(sharePath),
|
||||
_localPath(localPath),
|
||||
_resharingAllowed(resharingAllowed),
|
||||
_maxSharingPermissions(maxSharingPermissions),
|
||||
_linkWidget(NULL),
|
||||
_userGroupWidget(NULL)
|
||||
_userGroupWidget(NULL),
|
||||
_progressIndicator(NULL)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setObjectName("SharingDialog"); // required as group for saveGeometry call
|
||||
|
@ -97,32 +102,25 @@ ShareDialog::ShareDialog(QPointer<AccountState> accountState, const QString &sha
|
|||
return;
|
||||
}
|
||||
|
||||
auto theme = Theme::instance();
|
||||
bool autoShare = true;
|
||||
|
||||
// We only do user/group sharing from 8.2.0
|
||||
if (theme->userGroupSharing() && accountState->account()->serverVersionInt() >= ((8 << 16) + (2 << 8))) {
|
||||
_userGroupWidget = new ShareUserGroupWidget(accountState->account(), sharePath, localPath, resharingAllowed, this);
|
||||
_ui->shareWidgetsLayout->addWidget(_userGroupWidget);
|
||||
|
||||
|
||||
QFrame *hline = new QFrame(this);
|
||||
hline->setFrameShape(QFrame::HLine);
|
||||
QPalette p = palette();
|
||||
// Make the line softer:
|
||||
p.setColor(QPalette::Foreground, QColor::fromRgba((p.color(QPalette::Foreground).rgba() & 0x00ffffff) | 0x50000000));
|
||||
hline->setPalette(p);
|
||||
_ui->shareWidgetsLayout->addWidget(hline);
|
||||
|
||||
|
||||
autoShare = false;
|
||||
if (QFileInfo(_localPath).isFile()) {
|
||||
ThumbnailJob *job = new ThumbnailJob(_sharePath, _accountState->account(), this);
|
||||
connect(job, SIGNAL(jobFinished(int, QByteArray)), SLOT(slotThumbnailFetched(int, QByteArray)));
|
||||
job->start();
|
||||
}
|
||||
|
||||
if (theme->linkSharing()) {
|
||||
_linkWidget = new ShareLinkWidget(accountState->account(), sharePath, localPath, resharingAllowed, autoShare, this);
|
||||
_linkWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
_ui->shareWidgetsLayout->addWidget(_linkWidget);
|
||||
}
|
||||
_progressIndicator = new QProgressIndicator(this);
|
||||
_progressIndicator->startAnimation();
|
||||
_progressIndicator->setToolTip(tr("Retrieving maximum possible sharing permissions from server..."));
|
||||
_ui->shareWidgetsLayout->addWidget(_progressIndicator);
|
||||
|
||||
// Server versions >= 9.1 support the "share-permissions" property
|
||||
// older versions will just return share-permissions: ""
|
||||
auto job = new PropfindJob(accountState->account(), _sharePath);
|
||||
job->setProperties(QList<QByteArray>() << "http://owncloud.org/ns:share-permissions");
|
||||
job->setTimeout(10 * 1000);
|
||||
connect(job, SIGNAL(result(QVariantMap)), SLOT(slotMaxSharingPermissionsReceived(QVariantMap)));
|
||||
connect(job, SIGNAL(finishedWithError(QNetworkReply*)), SLOT(slotMaxSharingPermissionsError()));
|
||||
job->start();
|
||||
}
|
||||
|
||||
ShareDialog::~ShareDialog()
|
||||
|
@ -136,20 +134,62 @@ void ShareDialog::done( int r ) {
|
|||
QDialog::done(r);
|
||||
}
|
||||
|
||||
void ShareDialog::getShares()
|
||||
void ShareDialog::slotMaxSharingPermissionsReceived(const QVariantMap & result)
|
||||
{
|
||||
if (QFileInfo(_localPath).isFile()) {
|
||||
ThumbnailJob *job = new ThumbnailJob(_sharePath, _accountState->account(), this);
|
||||
connect(job, SIGNAL(jobFinished(int, QByteArray)), SLOT(slotThumbnailFetched(int, QByteArray)));
|
||||
job->start();
|
||||
const QVariant receivedPermissions = result["share-permissions"];
|
||||
if (!receivedPermissions.toString().isEmpty()) {
|
||||
_maxSharingPermissions = static_cast<SharePermissions>(receivedPermissions.toInt());
|
||||
qDebug() << "Received sharing permissions for" << _sharePath << _maxSharingPermissions;
|
||||
}
|
||||
|
||||
if (_linkWidget) {
|
||||
_linkWidget->getShares();
|
||||
showSharingUi();
|
||||
}
|
||||
if (_userGroupWidget != NULL) {
|
||||
|
||||
void ShareDialog::slotMaxSharingPermissionsError()
|
||||
{
|
||||
// On error show the share ui anyway. The user can still see shares,
|
||||
// delete them and so on, even though adding new shares or granting
|
||||
// some of the permissions might fail.
|
||||
|
||||
showSharingUi();
|
||||
}
|
||||
|
||||
void ShareDialog::showSharingUi()
|
||||
{
|
||||
_progressIndicator->stopAnimation();
|
||||
|
||||
auto theme = Theme::instance();
|
||||
|
||||
// We only do user/group sharing from 8.2.0
|
||||
bool userGroupSharing =
|
||||
theme->userGroupSharing()
|
||||
&& _accountState->account()->serverVersionInt() >= ((8 << 16) + (2 << 8));
|
||||
|
||||
bool autoShare = !userGroupSharing;
|
||||
|
||||
|
||||
if (userGroupSharing) {
|
||||
_userGroupWidget = new ShareUserGroupWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, this);
|
||||
_ui->shareWidgetsLayout->addWidget(_userGroupWidget);
|
||||
_userGroupWidget->getShares();
|
||||
}
|
||||
|
||||
if (theme->linkSharing()) {
|
||||
if (userGroupSharing) {
|
||||
QFrame *hline = new QFrame(this);
|
||||
hline->setFrameShape(QFrame::HLine);
|
||||
QPalette p = palette();
|
||||
// Make the line softer:
|
||||
p.setColor(QPalette::Foreground, QColor::fromRgba((p.color(QPalette::Foreground).rgba() & 0x00ffffff) | 0x50000000));
|
||||
hline->setPalette(p);
|
||||
_ui->shareWidgetsLayout->addWidget(hline);
|
||||
}
|
||||
|
||||
_linkWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, autoShare, this);
|
||||
_linkWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
_ui->shareWidgetsLayout->addWidget(_linkWidget);
|
||||
_linkWidget->getShares();
|
||||
}
|
||||
}
|
||||
|
||||
void ShareDialog::slotThumbnailFetched(const int &statusCode, const QByteArray &reply)
|
||||
|
|
|
@ -15,12 +15,15 @@
|
|||
#define SHAREDIALOG_H
|
||||
|
||||
#include "accountstate.h"
|
||||
#include "sharepermissions.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
|
||||
class QProgressIndicator;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
namespace Ui {
|
||||
|
@ -38,27 +41,31 @@ public:
|
|||
explicit ShareDialog(QPointer<AccountState> accountState,
|
||||
const QString &sharePath,
|
||||
const QString &localPath,
|
||||
bool resharingAllowed,
|
||||
SharePermissions maxSharingPermissions,
|
||||
QWidget *parent = 0);
|
||||
~ShareDialog();
|
||||
|
||||
void getShares();
|
||||
|
||||
private slots:
|
||||
void done( int r );
|
||||
void slotMaxSharingPermissionsReceived(const QVariantMap &result);
|
||||
void slotMaxSharingPermissionsError();
|
||||
void slotThumbnailFetched(const int &statusCode, const QByteArray &reply);
|
||||
void slotAccountStateChanged(int state);
|
||||
|
||||
private:
|
||||
|
||||
void showSharingUi();
|
||||
|
||||
Ui::ShareDialog *_ui;
|
||||
QPointer<AccountState> _accountState;
|
||||
QString _sharePath;
|
||||
QString _localPath;
|
||||
|
||||
bool _resharingAllowed;
|
||||
SharePermissions _maxSharingPermissions;
|
||||
|
||||
ShareLinkWidget *_linkWidget;
|
||||
ShareUserGroupWidget *_userGroupWidget;
|
||||
QProgressIndicator *_progressIndicator;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace OCC {
|
|||
ShareLinkWidget::ShareLinkWidget(AccountPtr account,
|
||||
const QString &sharePath,
|
||||
const QString &localPath,
|
||||
bool resharingAllowed,
|
||||
SharePermissions maxSharingPermissions,
|
||||
bool autoShare,
|
||||
QWidget *parent) :
|
||||
QWidget(parent),
|
||||
|
@ -40,7 +40,7 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
|
|||
_passwordJobRunning(false),
|
||||
_manager(NULL),
|
||||
_share(NULL),
|
||||
_resharingAllowed(resharingAllowed),
|
||||
_maxSharingPermissions(maxSharingPermissions),
|
||||
_autoShare(autoShare),
|
||||
_passwordRequired(false)
|
||||
{
|
||||
|
@ -292,7 +292,7 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
|
|||
setShareCheckBoxTitle(true);
|
||||
} else {
|
||||
// If its clear that resharing is not allowed, display an error
|
||||
if( !_resharingAllowed ) {
|
||||
if( _maxSharingPermissions == 0 ) {
|
||||
displayError(tr("The file can not be shared because it was shared without sharing permission."));
|
||||
_ui->checkBox_shareLink->setEnabled(false);
|
||||
} else if (_autoShare && _ui->checkBox_shareLink->isEnabled()) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define SHARELINKWIDGET_H
|
||||
|
||||
#include "accountfwd.h"
|
||||
#include "sharepermissions.h"
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QDialog>
|
||||
#include <QVariantMap>
|
||||
|
@ -47,7 +48,7 @@ public:
|
|||
explicit ShareLinkWidget(AccountPtr account,
|
||||
const QString &sharePath,
|
||||
const QString &localPath,
|
||||
bool resharingAllowed,
|
||||
SharePermissions maxSharingPermissions,
|
||||
bool autoShare = false,
|
||||
QWidget *parent = 0);
|
||||
~ShareLinkWidget();
|
||||
|
@ -104,7 +105,7 @@ private:
|
|||
ShareManager *_manager;
|
||||
QSharedPointer<LinkShare> _share;
|
||||
|
||||
bool _resharingAllowed;
|
||||
SharePermissions _maxSharingPermissions;
|
||||
bool _isFile;
|
||||
bool _autoShare;
|
||||
bool _passwordRequired;
|
||||
|
|
37
src/gui/sharepermissions.h
Normal file
37
src/gui/sharepermissions.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) by Roeland Jago Douma <rullzer@owncloud.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef SHAREPERMISSIONS_H
|
||||
#define SHAREPERMISSIONS_H
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
/**
|
||||
* Possible permissions, must match the server permission constants
|
||||
*/
|
||||
enum SharePermission {
|
||||
SharePermissionRead = 1,
|
||||
SharePermissionUpdate = 2,
|
||||
SharePermissionCreate = 4,
|
||||
SharePermissionDelete = 8,
|
||||
SharePermissionShare = 16,
|
||||
SharePermissionDefault = 1 << 30
|
||||
};
|
||||
Q_DECLARE_FLAGS(SharePermissions, SharePermission)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(SharePermissions)
|
||||
|
||||
} // namespace OCC
|
||||
|
||||
#endif
|
|
@ -42,13 +42,17 @@
|
|||
|
||||
namespace OCC {
|
||||
|
||||
ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, const QString &sharePath, const QString &localPath, bool resharingAllowed, QWidget *parent) :
|
||||
ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account,
|
||||
const QString &sharePath,
|
||||
const QString &localPath,
|
||||
SharePermissions maxSharingPermissions,
|
||||
QWidget *parent) :
|
||||
QWidget(parent),
|
||||
_ui(new Ui::ShareUserGroupWidget),
|
||||
_account(account),
|
||||
_sharePath(sharePath),
|
||||
_localPath(localPath),
|
||||
_resharingAllowed(resharingAllowed),
|
||||
_maxSharingPermissions(maxSharingPermissions),
|
||||
_disableCompleterActivated(false)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
@ -178,7 +182,7 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
|
|||
continue;
|
||||
}
|
||||
|
||||
ShareWidget *s = new ShareWidget(share, _isFile, _ui->scrollArea);
|
||||
ShareWidget *s = new ShareWidget(share, _maxSharingPermissions, _isFile, _ui->scrollArea);
|
||||
connect(s, SIGNAL(resizeRequested()), this, SLOT(slotAdjustScrollWidgetSize()));
|
||||
layout->addWidget(s);
|
||||
|
||||
|
@ -246,15 +250,15 @@ void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex & index)
|
|||
* https://github.com/owncloud/core/issues/22122#issuecomment-185637344
|
||||
*/
|
||||
if (sharee->type() == Sharee::Federated) {
|
||||
int permissions = Share::PermissionRead | Share::PermissionUpdate;
|
||||
int permissions = SharePermissionRead | SharePermissionUpdate;
|
||||
if (!_isFile) {
|
||||
permissions |= Share::PermissionCreate | Share::PermissionDelete;
|
||||
permissions |= SharePermissionCreate | SharePermissionDelete;
|
||||
}
|
||||
_manager->createShare(_sharePath, Share::ShareType(sharee->type()),
|
||||
sharee->shareWith(), Share::Permission(permissions));
|
||||
sharee->shareWith(), SharePermission(permissions));
|
||||
} else {
|
||||
_manager->createShare(_sharePath, Share::ShareType(sharee->type()),
|
||||
sharee->shareWith(), Share::PermissionDefault);
|
||||
sharee->shareWith(), SharePermissionDefault);
|
||||
}
|
||||
|
||||
_ui->shareeLineEdit->setEnabled(false);
|
||||
|
@ -276,6 +280,7 @@ void ShareUserGroupWidget::displayError(int code, const QString& message)
|
|||
}
|
||||
|
||||
ShareWidget::ShareWidget(QSharedPointer<Share> share,
|
||||
SharePermissions maxSharingPermissions,
|
||||
bool isFile,
|
||||
QWidget *parent) :
|
||||
QWidget(parent),
|
||||
|
@ -291,10 +296,13 @@ ShareWidget::ShareWidget(QSharedPointer<Share> share,
|
|||
QMenu *menu = new QMenu(this);
|
||||
_permissionCreate = new QAction(tr("create"), this);
|
||||
_permissionCreate->setCheckable(true);
|
||||
_permissionCreate->setEnabled(maxSharingPermissions & SharePermissionCreate);
|
||||
_permissionUpdate = new QAction(tr("change"), this);
|
||||
_permissionUpdate->setCheckable(true);
|
||||
_permissionUpdate->setEnabled(maxSharingPermissions & SharePermissionUpdate);
|
||||
_permissionDelete = new QAction(tr("delete"), this);
|
||||
_permissionDelete->setCheckable(true);
|
||||
_permissionDelete->setEnabled(maxSharingPermissions & SharePermissionDelete);
|
||||
|
||||
menu->addAction(_permissionUpdate);
|
||||
/*
|
||||
|
@ -313,6 +321,10 @@ ShareWidget::ShareWidget(QSharedPointer<Share> share,
|
|||
// Set the permissions checkboxes
|
||||
displayPermissions();
|
||||
|
||||
_ui->permissionShare->setEnabled(maxSharingPermissions & SharePermissionShare);
|
||||
_ui->permissionsEdit->setEnabled(maxSharingPermissions
|
||||
& (SharePermissionCreate | SharePermissionUpdate | SharePermissionDelete));
|
||||
|
||||
connect(_permissionUpdate, SIGNAL(triggered(bool)), SLOT(slotPermissionsChanged()));
|
||||
connect(_permissionCreate, SIGNAL(triggered(bool)), SLOT(slotPermissionsChanged()));
|
||||
connect(_permissionDelete, SIGNAL(triggered(bool)), SLOT(slotPermissionsChanged()));
|
||||
|
@ -354,21 +366,24 @@ void ShareWidget::slotEditPermissionsChanged()
|
|||
{
|
||||
setEnabled(false);
|
||||
|
||||
Share::Permissions permissions = Share::PermissionRead;
|
||||
Share::Permissions permissions = SharePermissionRead;
|
||||
|
||||
if (_ui->permissionShare->checkState() == Qt::Checked) {
|
||||
permissions |= Share::PermissionShare;
|
||||
permissions |= SharePermissionShare;
|
||||
}
|
||||
|
||||
if (_ui->permissionsEdit->checkState() == Qt::Checked) {
|
||||
permissions |= Share::PermissionUpdate;
|
||||
if (_permissionUpdate->isEnabled())
|
||||
permissions |= SharePermissionUpdate;
|
||||
|
||||
/*
|
||||
* Files can't have create or delete permisisons
|
||||
*/
|
||||
if (!_isFile) {
|
||||
permissions |= Share::PermissionCreate;
|
||||
permissions |= Share::PermissionDelete;
|
||||
if (_permissionCreate->isEnabled())
|
||||
permissions |= SharePermissionCreate;
|
||||
if (_permissionDelete->isEnabled())
|
||||
permissions |= SharePermissionDelete;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,22 +394,22 @@ void ShareWidget::slotPermissionsChanged()
|
|||
{
|
||||
setEnabled(false);
|
||||
|
||||
Share::Permissions permissions = Share::PermissionRead;
|
||||
Share::Permissions permissions = SharePermissionRead;
|
||||
|
||||
if (_permissionUpdate->isChecked()) {
|
||||
permissions |= Share::PermissionUpdate;
|
||||
permissions |= SharePermissionUpdate;
|
||||
}
|
||||
|
||||
if (_permissionCreate->isChecked()) {
|
||||
permissions |= Share::PermissionCreate;
|
||||
permissions |= SharePermissionCreate;
|
||||
}
|
||||
|
||||
if (_permissionDelete->isChecked()) {
|
||||
permissions |= Share::PermissionDelete;
|
||||
permissions |= SharePermissionDelete;
|
||||
}
|
||||
|
||||
if (_ui->permissionShare->checkState() == Qt::Checked) {
|
||||
permissions |= Share::PermissionShare;
|
||||
permissions |= SharePermissionShare;
|
||||
}
|
||||
|
||||
_share->setPermissions(permissions);
|
||||
|
@ -444,19 +459,19 @@ void ShareWidget::displayPermissions()
|
|||
_ui->permissionShare->setCheckState(Qt::Unchecked);
|
||||
_permissionUpdate->setChecked(false);
|
||||
|
||||
if (_share->getPermissions() & Share::PermissionUpdate) {
|
||||
if (_share->getPermissions() & SharePermissionUpdate) {
|
||||
_permissionUpdate->setChecked(true);
|
||||
_ui->permissionsEdit->setCheckState(Qt::Checked);
|
||||
}
|
||||
if (!_isFile && _share->getPermissions() & Share::PermissionCreate) {
|
||||
if (!_isFile && _share->getPermissions() & SharePermissionCreate) {
|
||||
_permissionCreate->setChecked(true);
|
||||
_ui->permissionsEdit->setCheckState(Qt::Checked);
|
||||
}
|
||||
if (!_isFile && _share->getPermissions() & Share::PermissionDelete) {
|
||||
if (!_isFile && _share->getPermissions() & SharePermissionDelete) {
|
||||
_permissionDelete->setChecked(true);
|
||||
_ui->permissionsEdit->setCheckState(Qt::Checked);
|
||||
}
|
||||
if (_share->getPermissions() & Share::PermissionShare) {
|
||||
if (_share->getPermissions() & SharePermissionShare) {
|
||||
_ui->permissionShare->setCheckState(Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#define SHAREUSERGROUPWIDGET_H
|
||||
|
||||
#include "accountfwd.h"
|
||||
#include "sharepermissions.h"
|
||||
#include "QProgressIndicator.h"
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
|
@ -48,7 +49,10 @@ class ShareWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShareWidget(QSharedPointer<Share> Share, bool isFile, QWidget *parent = 0);
|
||||
explicit ShareWidget(QSharedPointer<Share> Share,
|
||||
SharePermissions maxSharingPermissions,
|
||||
bool isFile,
|
||||
QWidget *parent = 0);
|
||||
~ShareWidget();
|
||||
|
||||
QSharedPointer<Share> share() const;
|
||||
|
@ -90,7 +94,7 @@ public:
|
|||
explicit ShareUserGroupWidget(AccountPtr account,
|
||||
const QString &sharePath,
|
||||
const QString &localPath,
|
||||
bool resharingAllowed,
|
||||
SharePermissions maxSharingPermissions,
|
||||
QWidget *parent = 0);
|
||||
~ShareUserGroupWidget();
|
||||
|
||||
|
@ -121,7 +125,7 @@ private:
|
|||
ShareeModel *_completerModel;
|
||||
QTimer _completionTimer;
|
||||
|
||||
bool _resharingAllowed;
|
||||
SharePermissions _maxSharingPermissions;
|
||||
bool _isFile;
|
||||
bool _disableCompleterActivated; // in order to avoid that we share the contents twice
|
||||
ShareManager *_manager;
|
||||
|
|
Loading…
Reference in a new issue