diff options
author | Christian Kamm <mail@ckamm.de> | 2017-09-15 15:24:34 +0300 |
---|---|---|
committer | ckamm <mail@ckamm.de> | 2017-09-19 11:51:03 +0300 |
commit | dca266470752076e8a8969072dc7153d9a760808 (patch) | |
tree | 76d451a5dce460ee06ef31e141ca88917d553997 /src/gui/sharedialog.cpp | |
parent | e1dfc38a90e93e33c427942ac972ecb2480b90b3 (diff) |
Private links: Retrieve link through propfind property #6020
* The sharing ui does a propfind anyway: use that to query the new
property as well!
* For the socket api, asynchronously query the server for the right url
when an action that needs it is triggered.
The old, manually generated URL will be used as fallback in case the
server doesn't support the new property or the property can't be
retrieved for some reason.
Depends on owncloud/core#29021
Diffstat (limited to 'src/gui/sharedialog.cpp')
-rw-r--r-- | src/gui/sharedialog.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index 24a912fdc..aa47598e9 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -46,7 +46,7 @@ ShareDialog::ShareDialog(QPointer<AccountState> accountState, , _sharePath(sharePath) , _localPath(localPath) , _maxSharingPermissions(maxSharingPermissions) - , _numericFileId(numericFileId) + , _privateLinkUrl(accountState->account()->deprecatedPrivateLinkUrl(numericFileId).toString(QUrl::FullyEncoded)) , _linkWidget(NULL) , _userGroupWidget(NULL) , _progressIndicator(NULL) @@ -130,10 +130,13 @@ ShareDialog::ShareDialog(QPointer<AccountState> accountState, // 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://open-collaboration-services.org/ns:share-permissions"); + job->setProperties( + QList<QByteArray>() + << "http://open-collaboration-services.org/ns:share-permissions" + << "http://owncloud.org/ns:privatelink"); job->setTimeout(10 * 1000); - connect(job, SIGNAL(result(QVariantMap)), SLOT(slotMaxSharingPermissionsReceived(QVariantMap))); - connect(job, SIGNAL(finishedWithError(QNetworkReply *)), SLOT(slotMaxSharingPermissionsError())); + connect(job, SIGNAL(result(QVariantMap)), SLOT(slotPropfindReceived(QVariantMap))); + connect(job, SIGNAL(finishedWithError(QNetworkReply *)), SLOT(slotPropfindError())); job->start(); } @@ -149,18 +152,23 @@ void ShareDialog::done(int r) QDialog::done(r); } -void ShareDialog::slotMaxSharingPermissionsReceived(const QVariantMap &result) +void ShareDialog::slotPropfindReceived(const QVariantMap &result) { const QVariant receivedPermissions = result["share-permissions"]; if (!receivedPermissions.toString().isEmpty()) { _maxSharingPermissions = static_cast<SharePermissions>(receivedPermissions.toInt()); qCInfo(lcSharing) << "Received sharing permissions for" << _sharePath << _maxSharingPermissions; } + auto privateLinkUrl = result["privatelink"].toString(); + if (!privateLinkUrl.isEmpty()) { + qCInfo(lcSharing) << "Received private link url for" << _sharePath << privateLinkUrl; + _privateLinkUrl = privateLinkUrl; + } showSharingUi(); } -void ShareDialog::slotMaxSharingPermissionsError() +void ShareDialog::slotPropfindError() { // 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 @@ -194,7 +202,7 @@ void ShareDialog::showSharingUi() && _accountState->account()->serverVersionInt() >= Account::makeServerVersion(8, 2, 0); if (userGroupSharing) { - _userGroupWidget = new ShareUserGroupWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _numericFileId, this); + _userGroupWidget = new ShareUserGroupWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _privateLinkUrl, this); _ui->shareWidgets->addTab(_userGroupWidget, tr("Users and Groups")); _userGroupWidget->getShares(); } |