readonly property bool isLinkShare: model.shareType === ShareModel.ShareTypeLink
readonly property bool isPlaceholderLinkShare: model.shareType === ShareModel.ShareTypePlaceholderLink
+ readonly property bool isInternalLinkShare: model.shareType === ShareModel.ShareTypeInternalLink
readonly property string text: model.display ?? ""
readonly property string detailText: model.detailText ?? ""
icon.width: 16
icon.height: 16
- visible: root.isLinkShare
+ visible: root.isLinkShare || root.isInternalLinkShare
enabled: visible
onClicked: {
imageSource: "image://svgimage-custom-color/more.svg/" + Style.ncTextColor
- visible: !root.isPlaceholderLinkShare
+ visible: !root.isPlaceholderLinkShare && !root.isInternalLinkShare
enabled: visible
onClicked: root.rootStackView.push(shareDetailsPageComponent, {}, StackView.PushTransition)
namespace {
-static const QString placeholderLinkShareId = QStringLiteral("__placeholderLinkShareId__");
+static const auto placeholderLinkShareId = QStringLiteral("__placeholderLinkShareId__");
+static const auto internalLinkShareId = QStringLiteral("__internalLinkShareId__");
QString createRandomPassword()
{
return startOfExpireDayUTC.toMSecsSinceEpoch();
}
}
+ } else if (share->getShareType() == Share::TypeInternalLink) {
+ switch(role) {
+ case LinkRole:
+ return _privateLinkUrl;
+ }
}
switch(role) {
_sharePath.clear();
_maxSharingPermissions = {};
_numericFileId.clear();
+ _privateLinkUrl.clear();
+ _filelockState = {};
_manager.clear();
_shares.clear();
_fetchOngoing = false;
_sharePath,
Share::TypePlaceholderLink));
+ _internalLinkShare.reset(new Share(_accountState->account(),
+ internalLinkShareId,
+ _accountState->account()->id(),
+ _accountState->account()->davDisplayName(),
+ _sharePath,
+ Share::TypeInternalLink));
+
auto job = new PropfindJob(_accountState->account(), _sharePath);
job->setProperties(
QList<QByteArray>()
- << "https://open-collaboration-services.org/ns:share-permissions"
- << "https://owncloud.org/ns:fileid" // numeric file id for fallback private link generation
- << "https://owncloud.org/ns:privatelink");
+ << "http://open-collaboration-services.org/ns:share-permissions"
+ << "http://owncloud.org/ns:fileid" // numeric file id for fallback private link generation
+ << "http://owncloud.org/ns:privatelink");
job->setTimeout(10 * 1000);
connect(job, &PropfindJob::result, this, &ShareModel::slotPropfindReceived);
connect(job, &PropfindJob::finishedWithError, this, [&](const QNetworkReply *reply) {
qCInfo(lcShareModel) << "Received numeric file id for" << _sharePath << numericFileId;
_privateLinkUrl = _accountState->account()->deprecatedPrivateLinkUrl(numericFileId).toString(QUrl::FullyEncoded);
}
+
+ setupInternalLinkShare();
}
void ShareModel::slotSharesFetched(const QList<SharePtr> &shares)
handlePlaceholderLinkShare();
}
+void ShareModel::setupInternalLinkShare()
+{
+ if (!_accountState ||
+ _accountState->account().isNull() ||
+ _localPath.isEmpty() ||
+ _privateLinkUrl.isEmpty()) {
+ return;
+ }
+
+ beginInsertRows({}, _shares.count(), _shares.count());
+ _shares.append(_internalLinkShare);
+ endInsertRows();
+ Q_EMIT internalLinkReady();
+}
+
void ShareModel::slotAddShare(const SharePtr &share)
{
if (share.isNull()) {
return displayString;
} else if (share->getShareType() == Share::TypePlaceholderLink) {
return tr("Link share");
+ } else if (share->getShareType() == Share::TypeInternalLink) {
+ return tr("Internal link");
} else if (share->getShareWith()) {
return share->getShareWith()->format();
}
const auto iconsPath = QStringLiteral("image://svgimage-custom-color/");
switch(share->getShareType()) {
+ case Share::TypeInternalLink:
+ return QString(iconsPath + QStringLiteral("external.svg"));
case Share::TypePlaceholderLink:
case Share::TypeLink:
return QString(iconsPath + QStringLiteral("public.svg"));
ShareTypeCircle = Share::TypeCircle,
ShareTypeRoom = Share::TypeRoom,
ShareTypePlaceholderLink = Share::TypePlaceholderLink,
+ ShareTypeInternalLink = Share::TypeInternalLink,
};
Q_ENUM(ShareType);
void fetchOngoingChanged();
void hasInitialShareFetchCompletedChanged();
void shareesChanged();
+ void internalLinkReady();
void serverError(const int code, const QString &message);
void passwordSetError(const QString &shareId, const int code, const QString &message);
void updateData();
void initShareManager();
void handlePlaceholderLinkShare();
+ void setupInternalLinkShare();
void slotPropfindReceived(const QVariantMap &result);
void slotServerError(const int code, const QString &message);
bool _fetchOngoing = false;
bool _hasInitialShareFetchCompleted = false;
SharePtr _placeholderLinkShare;
+ SharePtr _internalLinkShare;
// DO NOT USE QSHAREDPOINTERS HERE.
// QSharedPointers MUST NOT be used with pointers already assigned to other shared pointers.
const auto leftShareType = leftShare->getShareType();
// Placeholder link shares always go at top
- if(leftShareType == Share::TypePlaceholderLink) {
+ if (leftShareType == Share::TypePlaceholderLink) {
return true;
+ } else if (leftShareType == Share::TypeInternalLink) {
+ // Internal links always at bottom
+ return false;
}
const auto rightShareType = rightShare->getShareType();
+ // Placeholder link shares always go at top
+ if (rightShareType == Share::TypePlaceholderLink) {
+ return false;
+ } else if (rightShareType == Share::TypeInternalLink) {
+ // Internal links always at bottom
+ return true;
+ }
+
// We want to place link shares at the top
if (leftShareType == Share::TypeLink && rightShareType != Share::TypeLink) {
return true;