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

shellextensionutils.cpp « common « src - github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d6f4b244c6009b5f1f0081e78cb11ddcc13058ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "shellextensionutils.h"
#include <QJsonDocument>
#include <QLoggingCategory>

namespace VfsShellExtensions {

Q_LOGGING_CATEGORY(lcShellExtensionUtils, "nextcloud.gui.shellextensionutils", QtInfoMsg)

QString VfsShellExtensions::serverNameForApplicationName(const QString &applicationName)
{
    return applicationName + QStringLiteral(":VfsShellExtensionsServer");
}

QString VfsShellExtensions::serverNameForApplicationNameDefault()
{
    return serverNameForApplicationName(APPLICATION_NAME);
}
namespace Protocol {
    QByteArray createJsonMessage(const QVariantMap &message)
    {
        QVariantMap messageCopy = message;
        messageCopy[QStringLiteral("version")] = Version;
        return QJsonDocument::fromVariant((messageCopy)).toJson(QJsonDocument::Compact);
    }

    bool validateProtocolVersion(const QVariantMap &message)
    {
        const auto valid = message.value(QStringLiteral("version")) == Version;
        if (!valid) {
            qCWarning(lcShellExtensionUtils) << "Invalid shell extensions IPC protocol: " << message.value(QStringLiteral("version")) << " vs " << Version;
        }
        Q_ASSERT(valid);
        return valid;
    }
}
}