File indexing completed on 2023-09-24 04:11:27
0001 /* 0002 SPDX-FileCopyrightText: 2017 KDE Developers 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KATE_SECURE_TEXTBUFFER_P_H 0008 #define KATE_SECURE_TEXTBUFFER_P_H 0009 0010 #include <QCryptographicHash> 0011 #include <QObject> 0012 #include <QString> 0013 0014 #include <KAuth/ActionReply> 0015 0016 using namespace KAuth; 0017 0018 /** 0019 * Class used as KAuth helper binary. 0020 * It is supposed to be called through KAuth action. 0021 * 0022 * It also contains couple of common methods intended to be used 0023 * directly by TextBuffer as well as from helper binary. 0024 * 0025 * This class should only be used by TextBuffer. 0026 */ 0027 class SecureTextBuffer : public QObject 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 0033 /** 0034 * Common helper method 0035 */ 0036 static void setOwner(const int filedes, const uint ownerId, const uint groupId); 0037 0038 static const QCryptographicHash::Algorithm checksumAlgorithm = QCryptographicHash::Algorithm::Sha512; 0039 0040 private: 0041 /** 0042 * Saves file contents using sets permissions. 0043 */ 0044 static bool saveFileInternal(const QString &sourceFile, const QString &targetFile, const QByteArray &checksum, const uint ownerId, const uint groupId); 0045 0046 static bool moveFile(const QString &sourceFile, const QString &targetFile); 0047 0048 public Q_SLOTS: 0049 /** 0050 * KAuth action to perform both prepare or move work based on given parameters. 0051 * We keep this code in one method to prevent multiple KAuth user queries during one save action. 0052 */ 0053 static ActionReply savefile(const QVariantMap &args); 0054 }; 0055 0056 #endif