Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/gui/filedetails/sharemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@
switch (role) {
case LinkRole:
return linkShare->getLink();
case LinkShareNameRole:
return linkShare->getName();
case LinkShareLabelRole:
return linkShare->getLabel();
case NoteEnabledRole:
Expand Down Expand Up @@ -184,7 +182,6 @@
case HideDownloadEnabledRole:
return false;
case LinkRole:
case LinkShareNameRole:
case LinkShareLabelRole:
case NoteRole:
case ExpireDateRole:
Expand Down Expand Up @@ -323,9 +320,9 @@
auto job = new PropfindJob(_accountState->account(), _sharePath);
job->setProperties(QList<QByteArray>() << "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"

Check warning on line 323 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Using HTTP is insecure. Use HTTPS instead.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddp&open=AZ9LuEUMjjr2Jzoybddp&pullRequest=10348
<< "http://owncloud.org/ns:owner-id"

Check warning on line 324 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Using HTTP is insecure. Use HTTPS instead.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddq&open=AZ9LuEUMjjr2Jzoybddq&pullRequest=10348
<< "http://owncloud.org/ns:owner-display-name");

Check warning on line 325 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Using HTTP is insecure. Use HTTPS instead.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddr&open=AZ9LuEUMjjr2Jzoybddr&pullRequest=10348
job->setTimeout(10 * 1000);
connect(job, &PropfindJob::result, this, &ShareModel::slotPropfindReceived);
connect(job, &PropfindJob::finishedWithError, this, [&](const QNetworkReply *reply) {
Expand Down Expand Up @@ -522,7 +519,7 @@

for (auto j = i + 1; j < shareCount; ++j) {
const auto otherSharee = _shares.at(j)->getShareWith();
if (otherSharee == nullptr || sharee->format() != otherSharee->format()) {

Check warning on line 522 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "otherSharee" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybdds&open=AZ9LuEUMjjr2Jzoybdds&pullRequest=10348
continue;
}
handleDuplicateIndex(j);
Expand Down Expand Up @@ -569,9 +566,9 @@
Q_EMIT sharedWithMeExpiresChanged();
_sharedWithMeRemainingTimeString = daysToExpire > 1
? tr("%1 days").arg(daysToExpire)
: daysToExpire == 1
? tr("%1 day").arg(daysToExpire)
: tr("Today");

Check warning on line 571 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested conditional operator into an independent statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddt&open=AZ9LuEUMjjr2Jzoybddt&pullRequest=10348
Q_EMIT sharedWithMeRemainingTimeStringChanged();
}
}
Expand All @@ -587,7 +584,7 @@
return;
}

beginInsertRows({}, _shares.count(), _shares.count());

Check warning on line 587 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddj&open=AZ9LuEUMjjr2Jzoybddj&pullRequest=10348

Check warning on line 587 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddk&open=AZ9LuEUMjjr2Jzoybddk&pullRequest=10348
_shares.append(_internalLinkShare);
endInsertRows();
Q_EMIT internalLinkReady();
Expand Down Expand Up @@ -637,19 +634,19 @@
} else {
const auto shareIndex = _shares.count();

beginInsertRows({}, _shares.count(), _shares.count());

Check warning on line 637 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddl&open=AZ9LuEUMjjr2Jzoybddl&pullRequest=10348

Check warning on line 637 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddm&open=AZ9LuEUMjjr2Jzoybddm&pullRequest=10348
_shares.append(share);
endInsertRows();

slotAddSharee(share->getShareWith());

shareModelIndex = index(shareIndex);

Check warning on line 643 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'const qsizetype' (aka 'const long long') to 'int'

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddn&open=AZ9LuEUMjjr2Jzoybddn&pullRequest=10348
}

const QPersistentModelIndex sharePersistentIndex(shareModelIndex);
_shareIdIndexHash.insert(shareId, sharePersistentIndex);

connect(share.data(), &Share::serverError, this, [this] (int code, const QString &message) {

Check warning on line 649 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "code" of type "int" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddu&open=AZ9LuEUMjjr2Jzoybddu&pullRequest=10348
qCWarning(lcShareModel) << "Error from server from Share class" << code << message;
Q_EMIT serverError(code, message);
});
Expand All @@ -666,7 +663,6 @@

if (const auto linkShare = share.objectCast<LinkShare>()) {
connect(linkShare.data(), &LinkShare::noteSet, this, [this, shareId]{ slotShareNoteSet(shareId); });
connect(linkShare.data(), &LinkShare::nameSet, this, [this, shareId]{ slotShareNameSet(shareId); });
connect(linkShare.data(), &LinkShare::labelSet, this, [this, shareId]{ slotShareLabelSet(shareId); });
connect(linkShare.data(), &LinkShare::expireDateSet, this, [this, shareId]{ slotShareExpireDateSet(shareId); });
connect(linkShare.data(), &LinkShare::hideDownloadSet, this, [this, shareId] { slotHideDownloadSet(shareId); });
Expand Down Expand Up @@ -707,7 +703,7 @@
// check if this removal means the remaining index in the bucket is no longer a duplicate.
// If this is the case then handle the update for this item too.
const auto duplicateShares = _duplicateDisplayNameShareIndices.value(shareRow);
if (duplicateShares) {

Check warning on line 706 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "duplicateShares" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddv&open=AZ9LuEUMjjr2Jzoybddv&pullRequest=10348
duplicateShares->remove(shareRow);
if (duplicateShares->count() == 1) {
const auto noLongerDuplicateIndex = *(duplicateShares->begin());
Expand Down Expand Up @@ -908,17 +904,6 @@
Q_EMIT dataChanged(shareModelIndex, shareModelIndex, { NoteEnabledRole, NoteRole });
}

void ShareModel::slotShareNameSet(const QString &shareId)
{
if (shareId.isEmpty() || !_shareIdIndexHash.contains(shareId)) {
return;
}

const auto sharePersistentModelIndex = _shareIdIndexHash.value(shareId);
const auto shareModelIndex = index(sharePersistentModelIndex.row());
Q_EMIT dataChanged(shareModelIndex, shareModelIndex, { LinkShareNameRole });
}

void ShareModel::slotShareLabelSet(const QString &shareId)
{
if (shareId.isEmpty() || !_shareIdIndexHash.contains(shareId)) {
Expand Down Expand Up @@ -955,7 +940,7 @@
}
}

auto folder = FolderMan::instance()->folder(folderAlias);

Check warning on line 943 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "folder" of type "class OCC::Folder *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddw&open=AZ9LuEUMjjr2Jzoybddw&pullRequest=10348
if (!folder || !folder->journalDb()) {
emit serverError(404, tr("Could not find local folder for %1").arg(share->path()));
return;
Expand All @@ -972,7 +957,7 @@
share->getShareWith()->shareWith());
removeE2eeShareJob->setParent(_manager.data());
removeE2eeShareJob->start();
connect(removeE2eeShareJob, &UpdateE2eeFolderUsersMetadataJob::finished, this, [share, this](int code, const QString &message) {

Check warning on line 960 in src/gui/filedetails/sharemodel.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "code" of type "int" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEUMjjr2Jzoybddx&open=AZ9LuEUMjjr2Jzoybddx&pullRequest=10348
if (code != 200) {
qCWarning(lcShareModel) << "Could not remove share from E2EE folder's metadata!";
emit serverError(code, message);
Expand Down
1 change: 0 additions & 1 deletion src/gui/filedetails/sharemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
void publicLinkSharesEnabledChanged();
void userGroupSharingEnabledChanged();
void sharePermissionsChanged();
void isShareDisabledEncryptedFolderChanged();

Check warning on line 141 in src/gui/filedetails/sharemodel.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuESYjjr2Jzoybdde&open=AZ9LuESYjjr2Jzoybdde&pullRequest=10348
void lockExpireStringChanged();
void fetchOngoingChanged();
void hasInitialShareFetchCompletedChanged();
Expand All @@ -149,7 +149,7 @@
void shareOwnerDisplayNameChanged();
void shareOwnerAvatarChanged();
void sharedWithMeExpiresChanged();
void sharedWithMeRemainingTimeStringChanged();

Check warning on line 152 in src/gui/filedetails/sharemodel.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuESYjjr2Jzoybddf&open=AZ9LuESYjjr2Jzoybddf&pullRequest=10348

void serverError(const int code, const QString &message) const;
void passwordSetError(const QString &shareId, const int code, const QString &message);
Expand Down Expand Up @@ -216,7 +216,6 @@
void slotSharePasswordSet(const QString &shareId);
void slotShareNoteSet(const QString &shareId);
void slotHideDownloadSet(const QString &shareId);
void slotShareNameSet(const QString &shareId);
void slotShareLabelSet(const QString &shareId);
void slotShareExpireDateSet(const QString &shareId);
void slotDeleteE2EeShare(const OCC::SharePtr &share) const;
Expand Down Expand Up @@ -264,7 +263,7 @@
QHash<QString, QString> _shareIdRecentlySetPasswords;
QVector<ShareePtr> _sharees;
// Buckets of sharees with the same display name
QHash<unsigned int, QSharedPointer<QSet<unsigned int>>> _duplicateDisplayNameShareIndices;

Check warning on line 266 in src/gui/filedetails/sharemodel.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this identifier to be shorter or equal to 31 characters.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuESYjjr2Jzoybddh&open=AZ9LuESYjjr2Jzoybddh&pullRequest=10348
};

} // namespace OCC
22 changes: 0 additions & 22 deletions src/gui/ocssharejob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,6 @@ void OcsShareJob::setNote(const QString &shareId, const QString &note)
start();
}

void OcsShareJob::setPublicUpload(const QString &shareId, bool publicUpload)
{
appendPath(shareId);
setVerb("PUT");

const QString value = QString::fromLatin1(publicUpload ? "true" : "false");
addParam(QString::fromLatin1("publicUpload"), value);
_value = publicUpload;

start();
}

void OcsShareJob::setName(const QString &shareId, const QString &name)
{
appendPath(shareId);
setVerb("PUT");
addParam(QString::fromLatin1("name"), name);
_value = name;

start();
}

void OcsShareJob::setPermissions(const QString &shareId,
const Share::Permissions permissions)
{
Expand Down
12 changes: 0 additions & 12 deletions src/gui/ocssharejob.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,6 @@ class OcsShareJob : public OcsJob
*/
void setPassword(const QString &shareId, const QString &password);

/**
* Set the share to be public upload
*
* @param publicUpload Set or remove public upload
*/
void setPublicUpload(const QString &shareId, bool publicUpload);

/**
* Change the name of a share
*/
void setName(const QString &shareId, const QString &name);

/**
* Set the permissions
*
Expand Down
19 changes: 0 additions & 19 deletions src/gui/sharemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* When a share is modified, we need to tell the folders so they can adjust overlay icons
*/
static void updateFolder(const AccountPtr &account, QStringView path)

Check warning on line 29 in src/gui/sharemanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "path" of type "class QStringView" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEDejjr2JzoybddK&open=AZ9LuEDejjr2JzoybddK&pullRequest=10348
{
for (auto f : std::as_const(FolderMan::instance()->map())) {
if (f->accountState()->account() != account)
Expand All @@ -35,7 +35,7 @@
if (path.startsWith(folderPath) && (path == folderPath || folderPath.endsWith('/') || path[folderPath.size()] == '/')) {
// Workaround the fact that the server does not invalidate the etags of parent directories
// when something is shared.
auto relative = path.mid(f->remotePathTrailingSlash().length());

Check warning on line 38 in src/gui/sharemanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "relative" of type "class QStringView" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEDejjr2JzoybddM&open=AZ9LuEDejjr2JzoybddM&pullRequest=10348
f->journalDb()->schedulePathForRemoteDiscovery(relative.toString());

// Schedule a sync so it can update the remote permission flag and let the socket API
Expand Down Expand Up @@ -200,7 +200,6 @@
const QString &uidFileOwner,
const QString &ownerDisplayName,
const QString &path,
const QString &name,
const QString &token,
Permissions permissions,
bool isPasswordSet,
Expand All @@ -210,7 +209,6 @@
const QString &label,
const bool hideDownload)
: Share(account, id, uidOwner, uidFileOwner, ownerDisplayName, path, Share::TypeLink, isPasswordSet, permissions)
, _name(name)
, _token(token)
, _note(note)
, _expireDate(expireDate)
Expand All @@ -230,11 +228,6 @@
return _permissions & SharePermissionRead;
}

QString LinkShare::getName() const
{
return _name;
}

QString LinkShare::getNote() const
{
return _note;
Expand All @@ -250,11 +243,6 @@
return _hideDownload;
}

void LinkShare::setName(const QString &name)
{
createShareJob(&LinkShare::slotNameSet)->setName(getId(), name);
}

void LinkShare::setNote(const QString &note)
{
createShareJob(&LinkShare::slotNoteSet)->setNote(getId(), note);
Expand Down Expand Up @@ -296,13 +284,13 @@

void LinkShare::slotExpireDateSet(const QJsonDocument &reply, const QVariant &value)
{
auto data = reply.object().value("ocs"_L1).toObject().value("data"_L1).toObject();

Check warning on line 287 in src/gui/sharemanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "data" of type "class QJsonObject" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEDejjr2JzoybddO&open=AZ9LuEDejjr2JzoybddO&pullRequest=10348

/*
* If the reply provides a data back (more REST style)
* they use this date.
*/
if (data.value("expiration"_L1).isString()) {

Check warning on line 293 in src/gui/sharemanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "data" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEDejjr2JzoybddN&open=AZ9LuEDejjr2JzoybddN&pullRequest=10348
_expireDate = QDateTime::fromString(data.value("expiration"_L1).toString(), "yyyy-MM-dd hh:mm:ss").date();
} else {
_expireDate = value.toDate();
Expand All @@ -310,12 +298,6 @@
emit expireDateSet();
}

void LinkShare::slotNameSet(const QJsonDocument &, const QVariant &value)
{
_name = value.toString();
emit nameSet();
}

void LinkShare::slotLabelSet(const QJsonDocument &, const QVariant &label)
{
if (_label != label.toString()) {
Expand Down Expand Up @@ -393,13 +375,13 @@

void UserGroupShare::slotExpireDateSet(const QJsonDocument &reply, const QVariant &value)
{
auto data = reply.object().value("ocs"_L1).toObject().value("data"_L1).toObject();

Check warning on line 378 in src/gui/sharemanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "data" of type "class QJsonObject" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEDejjr2JzoybddQ&open=AZ9LuEDejjr2JzoybddQ&pullRequest=10348

/*
* If the reply provides a data back (more REST style)
* they use this date.
*/
if (data.value("expiration"_L1).isString()) {

Check warning on line 384 in src/gui/sharemanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "data" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEDejjr2JzoybddP&open=AZ9LuEDejjr2JzoybddP&pullRequest=10348
_expireDate = QDateTime::fromString(data.value("expiration"_L1).toString(), "yyyy-MM-dd hh:mm:ss").date();
} else {
_expireDate = value.toDate();
Expand Down Expand Up @@ -464,7 +446,7 @@
auto job = new OcsShareJob(_account);
connect(job, &OcsJob::ocsError, this, &ShareManager::slotOcsError);
connect(job, &OcsShareJob::shareJobFinished, this,
[=, this](const QJsonDocument &reply) {

Check failure on line 449 in src/gui/sharemanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Explicitly capture the required scope variables.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEDejjr2JzoybddR&open=AZ9LuEDejjr2JzoybddR&pullRequest=10348

Check failure on line 449 in src/gui/sharemanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Explicitly capture all local variables required in this lambda.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEDejjr2JzoybddS&open=AZ9LuEDejjr2JzoybddS&pullRequest=10348
// Find existing share permissions (if this was shared with us)
Share::Permissions existingPermissions = SharePermissionAll;
const auto &replyObject = reply.object();
Expand Down Expand Up @@ -557,7 +539,7 @@
sharedWithMeJob->getSharedWithMe(path);
}

const QList<SharePtr> ShareManager::parseShares(const QJsonDocument &reply) const

Check warning on line 542 in src/gui/sharemanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this "const" qualifier from the return type in all declarations.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEDejjr2JzoybddY&open=AZ9LuEDejjr2JzoybddY&pullRequest=10348
{
qDebug() << reply;
const auto tmpShares = reply.object().value("ocs"_L1).toObject().value("data"_L1).toArray();
Expand All @@ -569,7 +551,7 @@
for (const auto &share : tmpShares) {
auto data = share.toObject();

auto shareType = data.value("share_type"_L1).toInt();

Check warning on line 554 in src/gui/sharemanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "shareType" of type "int" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEDejjr2JzoybddZ&open=AZ9LuEDejjr2JzoybddZ&pullRequest=10348

SharePtr newShare;

Expand Down Expand Up @@ -663,7 +645,6 @@
data.value("uid_file_owner"_L1).toString(),
data.value("displayname_owner"_L1).toString(),
data.value("path"_L1).toString(),
data.value("name"_L1).toString(),
data.value("token"_L1).toString(),
(Share::Permissions)data.value("permissions"_L1).toInt(),
data.value("share_with"_L1).isString(), // has password?
Expand Down Expand Up @@ -698,7 +679,7 @@
}


void ShareManager::slotCreateE2eeShareJobFinised(int statusCode, const QString &message)

Check warning on line 682 in src/gui/sharemanager.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "statusCode" of type "int" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEDejjr2Jzoybddc&open=AZ9LuEDejjr2Jzoybddc&pullRequest=10348
{
const auto job = qobject_cast<UpdateE2eeFolderUsersMetadataJob *>(sender());
Q_ASSERT(job);
Expand Down
17 changes: 0 additions & 17 deletions src/gui/sharemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@
Q_PROPERTY(QUrl directDownloadLink READ getDirectDownloadLink CONSTANT)
Q_PROPERTY(bool publicCanUpload READ getPublicUpload CONSTANT)
Q_PROPERTY(bool publicCanReadDirectory READ getShowFileListing CONSTANT)
Q_PROPERTY(QString name READ getName WRITE setName NOTIFY nameSet)
Q_PROPERTY(QString note READ getNote WRITE setNote NOTIFY noteSet)
Q_PROPERTY(QString label READ getLabel WRITE setLabel NOTIFY labelSet)
Q_PROPERTY(bool hideDownload READ getHideDownload WRITE setHideDownload NOTIFY hideDownloadSet)
Expand All @@ -210,7 +209,6 @@
const QString &uidFileOwner,
const QString &ownerDisplayName,
const QString &path,
const QString &name,
const QString &token,
const Permissions permissions,
bool isPasswordSet,
Expand Down Expand Up @@ -240,11 +238,6 @@
*/
[[nodiscard]] bool getShowFileListing() const;

/*
* Returns the name of the link share. Can be empty.
*/
[[nodiscard]] QString getName() const;

/*
* Returns the note of the link share.
*/
Expand Down Expand Up @@ -277,13 +270,6 @@
OcsShareJob *createShareJob(const LinkShareSlot slotFunction);

public slots:
/*
* Set the name of the link share.
*
* Emits either nameSet() or serverError().
*/
void setName(const QString &name);

/*
* Set the note of the link share.
*/
Expand All @@ -310,18 +296,15 @@
signals:
void expireDateSet();
void noteSet();
void nameSet();
void labelSet();

private slots:
void slotNoteSet(const QJsonDocument &, const QVariant &value);
void slotExpireDateSet(const QJsonDocument &reply, const QVariant &value);
void slotNameSet(const QJsonDocument &, const QVariant &value);
void slotLabelSet(const QJsonDocument &, const QVariant &value);
void slotHideDownloadSet(const QJsonDocument &jsonDoc, const QVariant &hideDownload);

private:
QString _name;
QString _token;
QString _note;
QDate _expireDate;
Expand Down Expand Up @@ -431,24 +414,24 @@
const Share::Permissions permissions,
const QString &password = "");

/**
* Fetch all the shares for path
*
* @param path The path to get the shares for relative to the users folder on the server
*
* On success the sharesFetched signal is emitted
* In case of a server error the serverError signal is emitted
*/

Check warning on line 424 in src/gui/sharemanager.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Edit this comment to use the C++ format, i.e. "//".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEX2jjr2JzoybdeQ&open=AZ9LuEX2jjr2JzoybdeQ&pullRequest=10348
void fetchShares(const QString &path);

/**
* Fetch shares with the current user for path
*
* @param path The path to get the shares for relative to the users folder on the server
*
* On success the sharedWithMeFetched signal is emitted
* In case of a server error the serverError signal is emitted
*/

Check warning on line 434 in src/gui/sharemanager.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Edit this comment to use the C++ format, i.e. "//".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEX2jjr2JzoybdeR&open=AZ9LuEX2jjr2JzoybdeR&pullRequest=10348
void fetchSharedWithMe(const QString &path);

signals:
Expand Down
2 changes: 1 addition & 1 deletion src/gui/socketapi/socketapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
const int argPos = line.indexOf(QLatin1Char(':'));
const QByteArray command = line.mid(0, argPos).toUtf8().toUpper();
const int indexOfMethod = [&] {
QByteArray functionWithArguments = QByteArrayLiteral("command_");

Check warning on line 397 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the redundant type with "auto".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2Jzoybdd3&open=AZ9LuEWRjjr2Jzoybdd3&pullRequest=10348
if (command.startsWith("ASYNC_")) {
functionWithArguments += command + QByteArrayLiteral("(QSharedPointer<SocketApiJob>)");
} else {
Expand All @@ -418,7 +418,7 @@

auto json = QJsonDocument::fromJson(arguments[1].toUtf8()).object();

auto jobId = arguments[0];

Check warning on line 421 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid this unnecessary copy by using a "const" reference.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2Jzoybdd4&open=AZ9LuEWRjjr2Jzoybdd4&pullRequest=10348

auto socketApiJob = QSharedPointer<SocketApiJob>(
new SocketApiJob(jobId, listener, json), &QObject::deleteLater);
Expand Down Expand Up @@ -474,8 +474,8 @@
return;
}

auto folder = FolderMan::instance()->folder(alias);

Check warning on line 477 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "folder" of type "class OCC::Folder *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2Jzoybdd6&open=AZ9LuEWRjjr2Jzoybdd6&pullRequest=10348
if (folder) {

Check warning on line 478 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "folder" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2Jzoybdd5&open=AZ9LuEWRjjr2Jzoybdd5&pullRequest=10348
broadcastMessage(buildMessage(QLatin1String("UNREGISTER_PATH"),
removeTrailingSlash(folder->path()),
QString()));
Expand Down Expand Up @@ -565,7 +565,7 @@
// But EncryptFolderJob expects directory path Foo/Bar convention
const auto choppedPath = Utility::noTrailingSlashPath(Utility::noLeadingSlashPath(path));

auto job = new OCC::EncryptFolderJob(account, folder->journalDb(), choppedPath, choppedPath, folder->remotePath(), rec.numericFileId());

Check warning on line 568 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "job" of type "class OCC::EncryptFolderJob *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2Jzoybdd9&open=AZ9LuEWRjjr2Jzoybdd9&pullRequest=10348
job->setParent(this);
connect(job, &OCC::EncryptFolderJob::finished, this, [fileData, job](const int status) {
if (status == OCC::EncryptFolderJob::Error) {
Expand Down Expand Up @@ -653,7 +653,7 @@
{
QString msg = buildMessage(QLatin1String("STATUS"), systemPath, fileStatus.toSocketAPIString());
Q_ASSERT(!systemPath.endsWith('/'));
uint directoryHash = qHash(systemPath.left(systemPath.lastIndexOf('/')));

Check warning on line 656 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'uint' (aka 'unsigned int')

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2Jzoybdd0&open=AZ9LuEWRjjr2Jzoybdd0&pullRequest=10348
for (const auto &listener : std::as_const(_listeners)) {
listener->sendMessageIfDirectoryMonitored(msg, directoryHash);
}
Expand Down Expand Up @@ -758,8 +758,8 @@
job->setVerb(JsonApiJob::Verb::Post);

QObject::connect(job, &JsonApiJob::jsonReceived, [](const QJsonDocument &json){
auto data = json.object().value("ocs"_L1).toObject().value("data"_L1).toObject();

Check warning on line 761 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "data" of type "class QJsonObject" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2Jzoybdd-&open=AZ9LuEWRjjr2Jzoybdd-&pullRequest=10348
auto url = QUrl(data.value("url"_L1).toString());

Check warning on line 762 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "url" of type "class QUrl" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2Jzoybdd_&open=AZ9LuEWRjjr2Jzoybdd_&pullRequest=10348

if(!url.isEmpty())
Utility::openBrowser(url);
Expand All @@ -767,7 +767,7 @@
job->start();
}

void SocketApi::command_FILE_ACTIONS(const QString &localFile, SocketListener *listener)

Check warning on line 770 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "listener" is "class OCC::SocketListener *".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeA&open=AZ9LuEWRjjr2JzoybdeA&pullRequest=10348
{
Q_UNUSED(listener);

Expand Down Expand Up @@ -816,7 +816,7 @@
if (!linkShare)
continue;

if (linkShare->getName() == shareName) {
if (linkShare->getLabel() == shareName) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we not also rename shareName to shareLabel ?

qCDebug(lcPublicLink) << "Found existing share, reusing";
return success(linkShare->getLink().toString());
}
Expand Down Expand Up @@ -1021,7 +1021,7 @@
void SocketApi::command_DELETE_ITEM(const QString &localFile, SocketListener *)
{
const auto fileData = FileData::get(localFile);
if (!fileData.folder) {

Check warning on line 1024 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "fileData" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeE&open=AZ9LuEWRjjr2JzoybdeE&pullRequest=10348
qCWarning(lcSocketApi) << "Ignoring DELETE_ITEM request for path outside sync root:" << localFile;
return;
}
Expand All @@ -1048,8 +1048,8 @@
// If the parent doesn't accept new files, go to the root of the sync folder
QFileInfo fileInfo(localFile);
const auto parentRecord = parentDir.journalRecord();
if ((FileSystem::isFile(localFile) && !parentRecord._remotePerm.hasPermission(RemotePermissions::CanAddFile))
|| (FileSystem::isDir(localFile) && !parentRecord._remotePerm.hasPermission(RemotePermissions::CanAddSubDirectories))) {

Check warning on line 1052 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "parentRecord" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeF&open=AZ9LuEWRjjr2JzoybdeF&pullRequest=10348
defaultDirAndName = QFileInfo(defaultDirAndName).fileName();
}

Expand Down Expand Up @@ -1139,15 +1139,15 @@

void SocketApi::command_GET_STRINGS(const QString &argument, SocketListener *listener)
{
static std::array<std::pair<const char *, QString>, 7> strings { {
{ "SHARE_MENU_TITLE", tr("Share options") },
{ "FILE_ACTIONS_MENU_TITLE", tr("File actions") },
{ "FILE_ACTIVITY_MENU_TITLE", tr("Activity") },
{ "CONTEXT_MENU_TITLE", Theme::instance()->appNameGUI() },
{ "COPY_PRIVATE_LINK_MENU_TITLE", tr("Copy private link to clipboard") },
{ "EMAIL_PRIVATE_LINK_MENU_TITLE", tr("Send private link by email …") },
{ "CONTEXT_MENU_ICON", APPLICATION_ICON_NAME },
} };

Check warning on line 1150 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "strings" of type "struct std::array<struct std::pair<const char *, class QString>, 7>" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeG&open=AZ9LuEWRjjr2JzoybdeG&pullRequest=10348
listener->sendMessage(QStringLiteral("GET_STRINGS:BEGIN"));
for (const auto& key_value : strings) {
if (argument.isEmpty() || argument == QLatin1String(key_value.first)) {
Expand All @@ -1166,7 +1166,7 @@

auto capabilities = fileData.folder->accountState()->account()->capabilities();
auto theme = Theme::instance();
if (!capabilities.shareAPI() || !(theme->userGroupSharing() || (theme->linkSharing() && capabilities.sharePublicLink())))

Check warning on line 1169 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "theme" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeH&open=AZ9LuEWRjjr2JzoybdeH&pullRequest=10348
return;

if (record._isShared && !record._sharedByMe && itemEncryptionFlag == SharingContextItemEncryptedFlag::NotEncryptedItem) {
Expand All @@ -1190,7 +1190,7 @@
//listener->sendMessage(QLatin1String("MENU_ITEM:EMAIL_PRIVATE_LINK") + flagString + tr("Send private link by email …"));
}

void SocketApi::sendFileActionsContextMenuOptions(const FileData &fileData, SocketListener *listener)

Check warning on line 1193 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeJ&open=AZ9LuEWRjjr2JzoybdeJ&pullRequest=10348

Check warning on line 1193 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "listener" is "class OCC::SocketListener *".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeK&open=AZ9LuEWRjjr2JzoybdeK&pullRequest=10348

Check warning on line 1193 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unmodified variable "listener" of type "class OCC::SocketListener *" should be const-qualified.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeL&open=AZ9LuEWRjjr2JzoybdeL&pullRequest=10348
{
const auto record = fileData.journalRecord();
const auto isOnTheServer = record.isValid();
Expand Down Expand Up @@ -1242,7 +1242,7 @@
}

void SocketApi::sendLockFileCommandMenuEntries(const QFileInfo &fileInfo,
Folder* const syncFolder,

Check warning on line 1245 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "syncFolder" is "class OCC::Folder *const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeM&open=AZ9LuEWRjjr2JzoybdeM&pullRequest=10348
const FileData &fileData,
const OCC::SocketListener* const listener) const
{
Expand All @@ -1258,7 +1258,7 @@
}

void SocketApi::sendLockFileInfoMenuEntries(const QFileInfo &fileInfo,
Folder * const syncFolder,

Check warning on line 1261 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make the type of this parameter a pointer-to-const. The current type of "syncFolder" is "class OCC::Folder *const".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeN&open=AZ9LuEWRjjr2JzoybdeN&pullRequest=10348
const FileData &fileData,
const SocketListener * const listener,
const SyncJournalFileRecord &record) const
Expand Down Expand Up @@ -1289,7 +1289,7 @@

data.folderRelativePath = data.localPath.mid(data.folder->cleanPath().length() + 1);
data.serverRelativePath = QDir(data.folder->remotePath()).filePath(data.folderRelativePath);
QString virtualFileExt = QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX);

Check warning on line 1292 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the redundant type with "auto".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeO&open=AZ9LuEWRjjr2JzoybdeO&pullRequest=10348
if (data.serverRelativePath.endsWith(virtualFileExt)) {
data.serverRelativePath.chop(virtualFileExt.size());
}
Expand All @@ -1299,7 +1299,7 @@
QString SocketApi::FileData::folderRelativePathNoVfsSuffix() const
{
auto result = folderRelativePath;
QString virtualFileExt = QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX);

Check warning on line 1302 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the redundant type with "auto".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ9LuEWRjjr2JzoybdeP&open=AZ9LuEWRjjr2JzoybdeP&pullRequest=10348
if (result.endsWith(virtualFileExt)) {
result.chop(virtualFileExt.size());
}
Expand Down
20 changes: 0 additions & 20 deletions src/libsync/capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ bool Capabilities::shareAPI() const
}
}

bool Capabilities::shareEmailPasswordEnabled() const
{
return _capabilities["files_sharing"].toMap()["sharebymail"].toMap()["password"].toMap()["enabled"].toBool();
}

bool Capabilities::shareEmailPasswordEnforced() const
{
return _capabilities["files_sharing"].toMap()["sharebymail"].toMap()["password"].toMap()["enforced"].toBool();
Expand All @@ -53,16 +48,6 @@ bool Capabilities::sharePublicLink() const
}
}

bool Capabilities::sharePublicLinkAllowUpload() const
{
return _capabilities["files_sharing"].toMap()["public"].toMap()["upload"].toBool();
}

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();
Expand Down Expand Up @@ -103,11 +88,6 @@ 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 Capabilities::shareResharing() const
{
return _capabilities["files_sharing"].toMap()["resharing"].toBool();
Expand Down
4 changes: 0 additions & 4 deletions src/libsync/capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ class OWNCLOUDSYNC_EXPORT Capabilities
Capabilities(const QVariantMap &capabilities);

[[nodiscard]] bool shareAPI() const;
[[nodiscard]] bool shareEmailPasswordEnabled() const;
[[nodiscard]] bool shareEmailPasswordEnforced() const;
[[nodiscard]] bool sharePublicLink() const;
[[nodiscard]] bool sharePublicLinkAllowUpload() const;
[[nodiscard]] bool sharePublicLinkSupportsUploadOnly() const;
[[nodiscard]] bool sharePublicLinkAskOptionalPassword() const;
[[nodiscard]] bool sharePublicLinkEnforcePassword() const;
[[nodiscard]] bool sharePublicLinkEnforceExpireDate() const;
Expand All @@ -51,7 +48,6 @@ class OWNCLOUDSYNC_EXPORT Capabilities
[[nodiscard]] int shareInternalExpireDateDays() const;
[[nodiscard]] bool shareRemoteEnforceExpireDate() const;
[[nodiscard]] int shareRemoteExpireDateDays() const;
[[nodiscard]] bool sharePublicLinkMultiple() const;
[[nodiscard]] bool shareResharing() const;
[[nodiscard]] int shareDefaultPermissions() const;
[[nodiscard]] bool chunkingNg() const;
Expand Down
Loading