1/*
2 SPDX-FileCopyrightText: 2017 KDE Developers
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATE_SECURE_TEXTBUFFER_P_H
8#define KATE_SECURE_TEXTBUFFER_P_H
9
10#include <QCryptographicHash>
11#include <QObject>
12#include <QString>
13
14#include <KAuth/ActionReply>
15
16using namespace KAuth;
17
18/**
19 * Class used as KAuth helper binary.
20 * It is supposed to be called through KAuth action.
21 *
22 * It also contains couple of common methods intended to be used
23 * directly by TextBuffer as well as from helper binary.
24 *
25 * This class should only be used by TextBuffer.
26 */
27class SecureTextBuffer : public QObject
28{
29 Q_OBJECT
30
31public:
32 /**
33 * Common helper method
34 */
35 static void setOwner(const int filedes, const uint ownerId, const uint groupId);
36
37 static const QCryptographicHash::Algorithm checksumAlgorithm = QCryptographicHash::Algorithm::Sha512;
38
39private:
40 /**
41 * Saves file contents using sets permissions.
42 */
43 static bool saveFileInternal(const QString &sourceFile, const QString &targetFile, const QByteArray &checksum, const uint ownerId, const uint groupId);
44
45 static bool moveFile(const QString &sourceFile, const QString &targetFile);
46
47public Q_SLOTS:
48 /**
49 * KAuth action to perform both prepare or move work based on given parameters.
50 * We keep this code in one method to prevent multiple KAuth user queries during one save action.
51 */
52 static ActionReply savefile(const QVariantMap &args);
53};
54
55#endif
56

source code of ktexteditor/src/buffer/katesecuretextbuffer_p.h