mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 13:25:52 +03:00
Merge pull request #2520 from nextcloud/handle_askForOptionalPassword_capability
Handle ask for optional password capability
This commit is contained in:
commit
f90ae66d94
4 changed files with 25 additions and 1 deletions
|
@ -25,6 +25,7 @@
|
|||
#include "configfile.h"
|
||||
#include "theme.h"
|
||||
#include "thumbnailjob.h"
|
||||
#include "wordlist.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QFileIconProvider>
|
||||
|
@ -33,6 +34,20 @@
|
|||
#include <QPushButton>
|
||||
#include <QFrame>
|
||||
|
||||
namespace {
|
||||
QString createRandomPassword()
|
||||
{
|
||||
const auto words = OCC::WordList::getRandomWords(10);
|
||||
|
||||
const auto addFirstLetter = [](const QString ¤t, const QString &next) {
|
||||
return current + next.at(0);
|
||||
};
|
||||
|
||||
return std::accumulate(std::cbegin(words), std::cend(words), QString(), addFirstLetter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace OCC {
|
||||
|
||||
static const int thumbnailSize = 40;
|
||||
|
@ -303,7 +318,9 @@ void ShareDialog::showSharingUi()
|
|||
void ShareDialog::slotCreateLinkShare()
|
||||
{
|
||||
if(_manager) {
|
||||
_manager->createLinkShare(_sharePath, QString(), QString());
|
||||
const auto askOptionalPassword = _accountState->account()->capabilities().sharePublicLinkAskOptionalPassword();
|
||||
const auto password = askOptionalPassword ? createRandomPassword() : QString();
|
||||
_manager->createLinkShare(_sharePath, QString(), password);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -744,6 +744,7 @@ void SocketApi::sendSharingContextMenuOptions(const FileData &fileData, SocketLi
|
|||
// Is is possible to create a public link without user choices?
|
||||
bool canCreateDefaultPublicLink = publicLinksEnabled
|
||||
&& !capabilities.sharePublicLinkEnforceExpireDate()
|
||||
&& !capabilities.sharePublicLinkAskOptionalPassword()
|
||||
&& !capabilities.sharePublicLinkEnforcePassword();
|
||||
|
||||
if (canCreateDefaultPublicLink) {
|
||||
|
|
|
@ -59,6 +59,11 @@ bool Capabilities::sharePublicLinkSupportsUploadOnly() const
|
|||
return _capabilities["files_sharing"].toMap()["public"].toMap()["supports_upload_only"].toBool();
|
||||
}
|
||||
|
||||
bool Capabilities::sharePublicLinkAskOptionalPassword() const
|
||||
{
|
||||
return _capabilities["files_sharing"].toMap()["public"].toMap()["password"].toMap()["askForOptionalPassword"].toBool();
|
||||
}
|
||||
|
||||
bool Capabilities::sharePublicLinkEnforcePassword() const
|
||||
{
|
||||
return _capabilities["files_sharing"].toMap()["public"].toMap()["password"].toMap()["enforced"].toBool();
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
bool sharePublicLink() const;
|
||||
bool sharePublicLinkAllowUpload() const;
|
||||
bool sharePublicLinkSupportsUploadOnly() const;
|
||||
bool sharePublicLinkAskOptionalPassword() const;
|
||||
bool sharePublicLinkEnforcePassword() const;
|
||||
bool sharePublicLinkEnforceExpireDate() const;
|
||||
int sharePublicLinkExpireDateDays() const;
|
||||
|
|
Loading…
Reference in a new issue