Merge pull request #4496 from owncloud/fix_4325

Add theming options control sharing operations
This commit is contained in:
Roeland Douma 2016-03-01 15:33:04 +01:00
commit f24fa46789
4 changed files with 52 additions and 9 deletions

View file

@ -92,10 +92,11 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
return;
}
auto theme = Theme::instance();
bool autoShare = true;
// We only do user/group sharing from 8.2.0
if (account->serverVersionInt() >= ((8 << 16) + (2 << 8))) {
if (theme->userGroupSharing() && account->serverVersionInt() >= ((8 << 16) + (2 << 8))) {
_userGroupWidget = new ShareUserGroupWidget(account, sharePath, localPath, resharingAllowed, this);
_ui->shareWidgetsLayout->addWidget(_userGroupWidget);
@ -112,9 +113,11 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
autoShare = false;
}
if (theme->linkSharing()) {
_linkWidget = new ShareLinkWidget(account, sharePath, localPath, resharingAllowed, autoShare, this);
_linkWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
_ui->shareWidgetsLayout->addWidget(_linkWidget);
}
}
ShareDialog::~ShareDialog()

View file

@ -364,6 +364,8 @@ void SocketApi::command_SHARE(const QString& localFile, QIODevice* socket)
qDebug() << Q_FUNC_INFO << localFile;
auto theme = Theme::instance();
Folder *shareFolder = FolderMan::instance()->folderForPath(localFile);
if (!shareFolder) {
const QString message = QLatin1String("SHARE:NOP:")+QDir::toNativeSeparators(localFile);
@ -373,6 +375,11 @@ void SocketApi::command_SHARE(const QString& localFile, QIODevice* socket)
const QString message = QLatin1String("SHARE:NOTCONNECTED:")+QDir::toNativeSeparators(localFile);
// if the folder isn't connected, don't open the share dialog
sendMessage(socket, message);
} else if (!theme->linkSharing() && (
!theme->userGroupSharing() ||
shareFolder->accountState()->account()->serverVersionInt() < ((8 << 16) + (2 << 8)))) {
const QString message = QLatin1String("SHARE:NOP:")+QDir::toNativeSeparators(localFile);
sendMessage(socket, message);
} else {
const QString localFileClean = QDir::cleanPath(localFile);
const QString file = localFileClean.mid(shareFolder->cleanPath().length()+1);
@ -448,16 +455,30 @@ void SocketApi::command_SHARE_STATUS(const QString &localFile, QIODevice *socket
const QString message = QLatin1String("SHARE_STATUS:DISABLED:")+QDir::toNativeSeparators(localFile);
sendMessage(socket, message);
} else {
QString available = "USER,GROUP";
auto theme = Theme::instance();
QString available;
if (capabilities.sharePublicLink()) {
available += ",LINK";
if (theme->userGroupSharing()) {
available = "USER,GROUP";
}
if (theme->linkSharing() && capabilities.sharePublicLink()) {
if (available.isEmpty()) {
available = "LINK";
} else {
available += ",LINK";
}
}
if (available.isEmpty()) {
const QString message = QLatin1String("SHARE_STATUS:DISABLED") + ":" + QDir::toNativeSeparators(localFile);
sendMessage(socket, message);
} else {
const QString message = QLatin1String("SHARE_STATUS:") + available + ":" + QDir::toNativeSeparators(localFile);
sendMessage(socket, message);
}
}
}
}
void SocketApi::command_SHARE_MENU_TITLE(const QString &, QIODevice* socket)

View file

@ -417,5 +417,16 @@ QString Theme::webDavPathNonShib() const
return QLatin1String("remote.php/nonshib-webdav/");
}
bool Theme::linkSharing() const
{
return false;
}
bool Theme::userGroupSharing() const
{
return true;
}
} // end namespace client

View file

@ -229,6 +229,14 @@ public:
virtual QString webDavPath() const;
virtual QString webDavPathNonShib() const;
/**
* @brief Sharing options
*
* Allow link sharing and or user/group sharing
*/
virtual bool linkSharing() const;
virtual bool userGroupSharing() const;
protected:
#ifndef TOKEN_AUTH_ONLY
QIcon themeIcon(const QString& name, bool sysTray = false) const;