Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-10-27 12:05:14 +0300
committerHannah von Reth <hannah.vonreth@owncloud.com>2021-10-27 15:20:55 +0300
commit2b70834dd15c16b2b34efcc3952c5238419581da (patch)
treea3fdbf5d67adf2c071be6b3e140711ab32e7c3af /src
parentd4f52b107fe5a066662a060bdbc2e7357f8be084 (diff)
Add branding parameter to disable explorer context menu icons
Fixes: #9167
Diffstat (limited to 'src')
-rw-r--r--src/gui/socketapi/socketapi.cpp51
-rw-r--r--src/libsync/theme.cpp5
-rw-r--r--src/libsync/theme.h7
3 files changed, 39 insertions, 24 deletions
diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp
index ed9eb036e..97b3b4bb5 100644
--- a/src/gui/socketapi/socketapi.cpp
+++ b/src/gui/socketapi/socketapi.cpp
@@ -873,33 +873,36 @@ void SocketApi::command_V2_GET_CLIENT_ICON(const QSharedPointer<SocketApiJobV2>
return;
}
+ QByteArray data;
const Theme *theme = Theme::instance();
- OC_ASSERT(theme);
- const QIcon appIcon = theme->applicationIcon();
- qCDebug(lcSocketApi) << Q_FUNC_INFO << " got icon from theme: " << appIcon;
-
- // convert to pixmap (might be smaller if size is not available)
- const QPixmap pixmap = appIcon.pixmap(QSize(size.toInt(), size.toInt()));
-
- // Convert pixmap to in-memory PNG
- QByteArray png;
- QBuffer pngBuffer(&png);
- auto success = pngBuffer.open(QIODevice::WriteOnly);
- if (!success) {
- qCWarning(lcSocketApi) << "Error opening buffer for png in " << Q_FUNC_INFO;
- job->failure(QStringLiteral("cannot get client icon"));
- return;
- }
+ // return an empty answer if the end point was disabled
+ if (theme->enableSocketApiIconSupport()) {
+ const QIcon appIcon = theme->applicationIcon();
+ qCDebug(lcSocketApi) << Q_FUNC_INFO << " got icon from theme: " << appIcon;
+
+ // convert to pixmap (might be smaller if size is not available)
+ const QPixmap pixmap = appIcon.pixmap(QSize(size.toInt(), size.toInt()));
+
+ // Convert pixmap to in-memory PNG
+ QByteArray png;
+ QBuffer pngBuffer(&png);
+ auto success = pngBuffer.open(QIODevice::WriteOnly);
+ if (!success) {
+ qCWarning(lcSocketApi) << "Error opening buffer for png in " << Q_FUNC_INFO;
+ job->failure(QStringLiteral("cannot get client icon"));
+ return;
+ }
- success = pixmap.save(&pngBuffer, "PNG");
- if (!success) {
- qCWarning(lcSocketApi) << "Error saving client icon as png in " << Q_FUNC_INFO;
- job->failure(QStringLiteral("cannot get client icon"));
- return;
- }
+ success = pixmap.save(&pngBuffer, "PNG");
+ if (!success) {
+ qCWarning(lcSocketApi) << "Error saving client icon as png in " << Q_FUNC_INFO;
+ job->failure(QStringLiteral("cannot get client icon"));
+ return;
+ }
- const QByteArray pngAsBase64 = pngBuffer.data().toBase64();
- job->success({ { QStringLiteral("png"), QString::fromUtf8(pngAsBase64) } });
+ data = pngBuffer.data().toBase64();
+ }
+ job->success({ { QStringLiteral("png"), QString::fromUtf8(data) } });
}
void SocketApi::emailPrivateLink(const QString &link)
diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp
index dca5280b8..b75beb36c 100644
--- a/src/libsync/theme.cpp
+++ b/src/libsync/theme.cpp
@@ -678,4 +678,9 @@ bool Theme::connectionValidatorClearCookies() const
return false;
}
+bool Theme::enableSocketApiIconSupport() const
+{
+ return true;
+}
+
} // end namespace client
diff --git a/src/libsync/theme.h b/src/libsync/theme.h
index ff1c5d4c4..13e19bb0a 100644
--- a/src/libsync/theme.h
+++ b/src/libsync/theme.h
@@ -428,6 +428,13 @@ public:
virtual bool connectionValidatorClearCookies() const;
+ /**
+ * Enables the response of V2/GET_CLIENT_ICON, default true.
+ * See #9167
+ */
+ virtual bool enableSocketApiIconSupport() const;
+
+
protected:
#ifndef TOKEN_AUTH_ONLY
QIcon themeUniversalIcon(const QString &name, IconType iconType = IconType::BrandedIcon) const;