job->deleteShare(getId());
}
+bool Share::isUserGroupShare(const ShareType type)
+{
+ return (type == Share::TypeUser || type == Share::TypeGroup || type == Share::TypeEmail || type == Share::TypeRoom
+ || type == Share::TypeRemote);
+}
+
void Share::slotDeleted()
{
updateFolder(_account, _path);
, _note(note)
, _expireDate(expireDate)
{
- Q_ASSERT(shareType == TypeUser || shareType == TypeGroup || shareType == TypeEmail || shareType == TypeRoom);
+ Q_ASSERT(Share::isUserGroupShare(shareType));
Q_ASSERT(shareWith);
}
if (shareType == Share::TypeLink) {
newShare = parseLinkShare(data);
- } else if (shareType == Share::TypeGroup || shareType == Share::TypeUser || shareType == Share::TypeEmail || shareType == Share::TypeRoom) {
+ } else if (Share::isUserGroupShare(static_cast <Share::ShareType>(shareType))) {
newShare = parseUserGroupShare(data);
} else {
newShare = parseShare(data);
*/
void deleteShare();
+ /*
+ * Is it a share with a user or group (local or remote)
+ */
+ static bool isUserGroupShare(const ShareType type);
+
signals:
void permissionsSet();
void shareDeleted();
}
- Q_ASSERT(share->getShareType() == Share::TypeUser || share->getShareType() == Share::TypeGroup || share->getShareType() == Share::TypeEmail || share->getShareType() == Share::TypeRoom);
+ Q_ASSERT(Share::isUserGroupShare(share->getShareType()));
auto userGroupShare = qSharedPointerDynamicCast<UserGroupShare>(share);
auto *s = new ShareUserLine(_account, userGroupShare, _maxSharingPermissions, _isFile, _parentScrollArea);
connect(s, &ShareUserLine::resizeRequested, this, &ShareUserGroupWidget::slotAdjustScrollWidgetSize);
_ui->calendar->setMinimumDate(QDate::currentDate().addDays(1));
_ui->calendar->setDate(initialDate.isValid() ? initialDate : _ui->calendar->minimumDate());
_ui->calendar->setFocus();
+
+ if (enforceExpirationDateForShare(_share->getShareType())) {
+ _ui->calendar->setMaximumDate(maxExpirationDateForShare(_share->getShareType(), _ui->calendar->maximumDate()));
+ _expirationDateLinkAction->setChecked(true);
+ _expirationDateLinkAction->setEnabled(false);
+ }
}
emit resizeRequested();
enableProgessIndicatorAnimation(false);
}
+QDate ShareUserLine::maxExpirationDateForShare(const Share::ShareType type, const QDate &fallbackDate) const
+{
+ auto daysToExpire = 0;
+ if (type == Share::ShareType::TypeRemote) {
+ daysToExpire = _account->capabilities().shareRemoteExpireDateDays();
+ } else if (type == Share::ShareType::TypeEmail) {
+ daysToExpire = _account->capabilities().sharePublicLinkExpireDateDays();
+ } else {
+ daysToExpire = _account->capabilities().shareInternalExpireDateDays();
+ }
+
+ if (daysToExpire > 0) {
+ return QDate::currentDate().addDays(daysToExpire);
+ }
+
+ return fallbackDate;
+}
+
+bool ShareUserLine::enforceExpirationDateForShare(const Share::ShareType type) const
+{
+ if (type == Share::ShareType::TypeRemote) {
+ return _account->capabilities().shareRemoteEnforceExpireDate();
+ } else if (type == Share::ShareType::TypeEmail) {
+ return _account->capabilities().sharePublicLinkEnforceExpireDate();
+ } else {
+ return _account->capabilities().shareInternalEnforceExpireDate();
+ }
+}
+
void ShareUserLine::setPasswordConfirmed()
{
if (_ui->lineEdit_password->text().isEmpty()) {
void enableProgessIndicatorAnimation(bool enable);
void disableProgessIndicatorAnimation();
+ QDate maxExpirationDateForShare(const Share::ShareType type, const QDate &fallbackDate) const;
+ bool enforceExpirationDateForShare(const Share::ShareType type) const;
+
Ui::ShareUserLine *_ui;
AccountPtr _account;
QSharedPointer<UserGroupShare> _share;
return _capabilities["files_sharing"].toMap()["public"].toMap()["expire_date"].toMap()["days"].toInt();
}
+bool Capabilities::shareInternalEnforceExpireDate() const
+{
+ return _capabilities["files_sharing"].toMap()["public"].toMap()["expire_date_internal"].toMap()["enforced"].toBool();
+}
+
+int Capabilities::shareInternalExpireDateDays() const
+{
+ return _capabilities["files_sharing"].toMap()["public"].toMap()["expire_date_internal"].toMap()["days"].toInt();
+}
+
+bool Capabilities::shareRemoteEnforceExpireDate() const
+{
+ return _capabilities["files_sharing"].toMap()["public"].toMap()["expire_date_remote"].toMap()["enforced"].toBool();
+}
+
+int Capabilities::shareRemoteExpireDateDays() const
+{
+ return _capabilities["files_sharing"].toMap()["public"].toMap()["expire_date_remote"].toMap()["days"].toInt();
+}
+
bool Capabilities::sharePublicLinkMultiple() const
{
return _capabilities["files_sharing"].toMap()["public"].toMap()["multiple"].toBool();
bool sharePublicLinkEnforcePassword() const;
bool sharePublicLinkEnforceExpireDate() const;
int sharePublicLinkExpireDateDays() const;
+ bool shareInternalEnforceExpireDate() const;
+ int shareInternalExpireDateDays() const;
+ bool shareRemoteEnforceExpireDate() const;
+ int shareRemoteExpireDateDays() const;
bool sharePublicLinkMultiple() const;
bool shareResharing() const;
int shareDefaultPermissions() const;