Skip to content
Merged
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
2 changes: 0 additions & 2 deletions src/gui/macOS/findersyncservice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ - (void)executeMenuCommand:(NSString *)command
static const QSet<QString> allowedCommands = {
QStringLiteral("SHARE"),
QStringLiteral("LEAVESHARE"),
QStringLiteral("COPY_SECUREFILEDROP_LINK"),
QStringLiteral("COPY_PRIVATE_LINK"),
QStringLiteral("EMAIL_PRIVATE_LINK"),
QStringLiteral("OPEN_PRIVATE_LINK"),
Expand Down Expand Up @@ -449,4 +448,3 @@ void sendMessage(const QString &message, bool = false) const override

} // namespace OCC


14 changes: 0 additions & 14 deletions src/gui/socketapi/socketapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
return msg;
}

static QString sanitizeSocketApiMenuText(QString text)

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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the redundant "static" specifier.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ1sSqqajEVdSavzL96w&open=AZ1sSqqajEVdSavzL96w&pullRequest=9808
{
text.replace(QLatin1Char('\n'), QLatin1Char(' '));
text.replace(QLatin1Char('\r'), QLatin1Char(' '));
Expand Down Expand Up @@ -391,10 +391,10 @@
// make sure that the path will match, especially on OS X.
const QString line = QString::fromUtf8(socket->readLine().trimmed()).normalized(QString::NormalizationForm_C);
qCDebug(lcSocketApi) << "Received SocketAPI message <--" << line << "from" << socket;
const int argPos = line.indexOf(QLatin1Char(':'));

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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ1sSqqajEVdSavzL96t&open=AZ1sSqqajEVdSavzL96t&pullRequest=9808
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=AZ1sSqqajEVdSavzL96x&open=AZ1sSqqajEVdSavzL96x&pullRequest=9808
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=AZ1sSqqajEVdSavzL96y&open=AZ1sSqqajEVdSavzL96y&pullRequest=9808

auto socketApiJob = QSharedPointer<SocketApiJob>(
new SocketApiJob(jobId, listener, json), &QObject::deleteLater);
Expand Down Expand Up @@ -480,7 +480,7 @@
_registeredAliases.remove(alias);
}

void SocketApi::slotUpdateFolderView(Folder *f)

Check warning on line 483 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 "f" is "class OCC::Folder *".

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ1sSqqajEVdSavzL96z&open=AZ1sSqqajEVdSavzL96z&pullRequest=9808
{
if (_listeners.isEmpty()) {
return;
Expand Down Expand Up @@ -556,12 +556,12 @@
return;
}

auto path = rec._path;

Check warning on line 559 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=AZ1sSqqajEVdSavzL960&open=AZ1sSqqajEVdSavzL960&pullRequest=9808
// Folder records have directory paths in Foo/Bar/ convention...
// 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 failure on line 564 in src/gui/socketapi/socketapi.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

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

Check warning on line 564 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=AZ1sSqqajEVdSavzL961&open=AZ1sSqqajEVdSavzL961&pullRequest=9808
job->setParent(this);
connect(job, &OCC::EncryptFolderJob::finished, this, [fileData, job](const int status) {
if (status == OCC::EncryptFolderJob::Error) {
Expand Down Expand Up @@ -649,7 +649,7 @@
{
QString msg = buildMessage(QLatin1String("STATUS"), systemPath, fileStatus.toSocketAPIString());
Q_ASSERT(!systemPath.endsWith('/'));
uint directoryHash = qHash(systemPath.left(systemPath.lastIndexOf('/')));

Check warning on line 652 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=AZ1sSqqajEVdSavzL96u&open=AZ1sSqqajEVdSavzL96u&pullRequest=9808
for (const auto &listener : std::as_const(_listeners)) {
listener->sendMessageIfDirectoryMonitored(msg, directoryHash);
}
Expand Down Expand Up @@ -683,7 +683,7 @@
// The user probably visited this directory in the file shell.
// Let the listener know that it should now send status pushes for sibblings of this file.
QString directory = fileData.localPath.left(fileData.localPath.lastIndexOf('/'));
listener->registerMonitoredDirectory(qHash(directory));

Check warning on line 686 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=AZ1sSqqajEVdSavzL96v&open=AZ1sSqqajEVdSavzL96v&pullRequest=9808

SyncFileStatus fileStatus = fileData.syncFileStatus();
statusString = fileStatus.toSocketAPIString();
Expand Down Expand Up @@ -754,8 +754,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 757 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=AZ1sSqqajEVdSavzL963&open=AZ1sSqqajEVdSavzL963&pullRequest=9808
auto url = QUrl(data.value("url"_L1).toString());

Check warning on line 758 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=AZ1sSqqajEVdSavzL964&open=AZ1sSqqajEVdSavzL964&pullRequest=9808

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

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

Check warning on line 766 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=AZ1sSqqajEVdSavzL966&open=AZ1sSqqajEVdSavzL966&pullRequest=9808

Check warning on line 766 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=AZ1sSqqajEVdSavzL965&open=AZ1sSqqajEVdSavzL965&pullRequest=9808
{
Q_UNUSED(listener);

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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Modify the macro definition so that it needs to be followed by a semicolon, or remove this empty statement.

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

processFileActionsRequest(localFile);
}
Expand Down Expand Up @@ -906,20 +906,6 @@

#endif

void SocketApi::command_COPY_SECUREFILEDROP_LINK(const QString &localFile, SocketListener *)
{
const auto fileData = FileData::get(localFile);
if (!fileData.folder) {
return;
}

const auto account = fileData.folder->accountState()->account();
const auto getOrCreatePublicLinkShareJob = new GetOrCreatePublicLinkShare(account, fileData.serverRelativePath, true, this);
connect(getOrCreatePublicLinkShareJob, &GetOrCreatePublicLinkShare::done, this, [](const QString &url) { copyUrlToClipboard(url); });
connect(getOrCreatePublicLinkShareJob, &GetOrCreatePublicLinkShare::error, this, [=, this]() { emit shareCommandReceived(fileData.localPath); });
getOrCreatePublicLinkShareJob->run();
}

// Windows Shell / Explorer pinning fallbacks, see issue: https://github.com/nextcloud/desktop/issues/1599
#ifdef Q_OS_WIN
void SocketApi::command_COPYASPATH(const QString &localFile, SocketListener *)
Expand Down Expand Up @@ -1026,7 +1012,7 @@
if (!fileData.folder || !Utility::isConflictFile(fileData.folderRelativePath))
return; // should not have shown menu item

const auto conflictedRelativePath = fileData.folderRelativePath;

Check warning on line 1015 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=AZ1sSqqajEVdSavzL968&open=AZ1sSqqajEVdSavzL968&pullRequest=9808
const auto baseRelativePath = fileData.folder->journalDb()->conflictFileBaseName(fileData.folderRelativePath.toUtf8());

const auto dir = QDir(fileData.folder->path());
Expand All @@ -1049,7 +1035,7 @@
void SocketApi::command_DELETE_ITEM(const QString &localFile, SocketListener *)
{
const auto fileData = FileData::get(localFile);
if (!fileData.folder) {

Check warning on line 1038 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=AZ1sSqqajEVdSavzL969&open=AZ1sSqqajEVdSavzL969&pullRequest=9808
qCWarning(lcSocketApi) << "Ignoring DELETE_ITEM request for path outside sync root:" << localFile;
return;
}
Expand All @@ -1076,8 +1062,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 1066 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=AZ1sSqqajEVdSavzL96-&open=AZ1sSqqajEVdSavzL96-&pullRequest=9808
defaultDirAndName = QFileInfo(defaultDirAndName).fileName();
}

Expand Down Expand Up @@ -1167,15 +1153,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 1164 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=AZ1sSqqajEVdSavzL96_&open=AZ1sSqqajEVdSavzL96_&pullRequest=9808
listener->sendMessage(QStringLiteral("GET_STRINGS:BEGIN"));
for (const auto& key_value : strings) {
if (argument.isEmpty() || argument == QLatin1String(key_value.first)) {
Expand All @@ -1194,7 +1180,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 1183 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=AZ1sSqqajEVdSavzL97A&open=AZ1sSqqajEVdSavzL97A&pullRequest=9808
return;

if (record._isShared && !record._sharedByMe) {
Expand All @@ -1218,7 +1204,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 1207 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=AZ1sSqqajEVdSavzL97E&open=AZ1sSqqajEVdSavzL97E&pullRequest=9808

Check warning on line 1207 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=AZ1sSqqajEVdSavzL97C&open=AZ1sSqqajEVdSavzL97C&pullRequest=9808

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

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=AZ1sSqqajEVdSavzL97B&open=AZ1sSqqajEVdSavzL97B&pullRequest=9808

Check warning on line 1207 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=AZ1sSqqajEVdSavzL97D&open=AZ1sSqqajEVdSavzL97D&pullRequest=9808
{
const auto record = fileData.journalRecord();
const auto isOnTheServer = record.isValid();
Expand Down Expand Up @@ -1270,7 +1256,7 @@
}

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

Check warning on line 1259 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=AZ1sSqqajEVdSavzL97F&open=AZ1sSqqajEVdSavzL97F&pullRequest=9808
const FileData &fileData,
const OCC::SocketListener* const listener) const
{
Expand All @@ -1286,7 +1272,7 @@
}

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

Check warning on line 1275 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=AZ1sSqqajEVdSavzL97G&open=AZ1sSqqajEVdSavzL97G&pullRequest=9808
const FileData &fileData,
const SocketListener * const listener,
const SyncJournalFileRecord &record) const
Expand Down Expand Up @@ -1317,7 +1303,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 1306 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=AZ1sSqqajEVdSavzL97H&open=AZ1sSqqajEVdSavzL97H&pullRequest=9808
if (data.serverRelativePath.endsWith(virtualFileExt)) {
data.serverRelativePath.chop(virtualFileExt.size());
}
Expand All @@ -1327,7 +1313,7 @@
QString SocketApi::FileData::folderRelativePathNoVfsSuffix() const
{
auto result = folderRelativePath;
QString virtualFileExt = QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX);

Check warning on line 1316 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=AZ1sSqqajEVdSavzL97I&open=AZ1sSqqajEVdSavzL97I&pullRequest=9808
if (result.endsWith(virtualFileExt)) {
result.chop(virtualFileExt.size());
}
Expand Down
1 change: 0 additions & 1 deletion src/gui/socketapi/socketapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
Q_INVOKABLE void command_ENCRYPT(const QString &localFile, OCC::SocketListener *listener);
Q_INVOKABLE void command_SHARE(const QString &localFile, OCC::SocketListener *listener);
Q_INVOKABLE void command_LEAVESHARE(const QString &localFile, OCC::SocketListener *listener);
Q_INVOKABLE void command_COPY_SECUREFILEDROP_LINK(const QString &localFile, OCC::SocketListener *listener);
Q_INVOKABLE void command_COPY_PRIVATE_LINK(const QString &localFile, OCC::SocketListener *listener);
Q_INVOKABLE void command_EMAIL_PRIVATE_LINK(const QString &localFile, OCC::SocketListener *listener);
Q_INVOKABLE void command_OPEN_PRIVATE_LINK(const QString &localFile, OCC::SocketListener *listener);
Expand Down Expand Up @@ -159,7 +158,7 @@

// Sends the context menu options relating to sharing to listener
void sendSharingContextMenuOptions(const FileData &fileData, SocketListener *listener, SharingContextItemEncryptedFlag itemEncryptionFlag, SharingContextItemRootEncryptedFolderFlag rootE2eeFolderFlag);
void sendFileActionsContextMenuOptions(const FileData &fileData, SocketListener *listener);

Check warning on line 161 in src/gui/socketapi/socketapi.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=AZ1sSqmnjEVdSavzL96s&open=AZ1sSqmnjEVdSavzL96s&pullRequest=9808
void sendEncryptFolderCommandMenuEntries(const QFileInfo &fileInfo,
const FileData &fileData,
const bool isE2eEncryptedPath,
Expand Down