Libkleo

checksumdefinition.h
1/* -*- mode: c++; c-basic-offset:4 -*-
2 checksumdefinition.h
3
4 This file is part of libkleopatra, the KDE keymanagement library
5 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#pragma once
11
12#include "kleo_export.h"
13
14#include <QString>
15#include <QStringList>
16
17#include <memory>
18#include <vector>
19
20class QProcess;
21
22namespace Kleo
23{
24
25class KLEO_EXPORT ChecksumDefinition
26{
27protected:
28 ChecksumDefinition(const QString &id, const QString &label, const QString &outputFileName, const QStringList &extensions);
29
30public:
31 virtual ~ChecksumDefinition();
32
33 enum ArgumentPassingMethod {
34 CommandLine,
35 NewlineSeparatedInputFile,
36 NullSeparatedInputFile,
37
38 NumArgumentPassingMethods
39 };
40
41 QString id() const
42 {
43 return m_id;
44 }
45 QString label() const
46 {
47 return m_label;
48 }
49
50 const QStringList &patterns() const
51 {
52 return m_patterns;
53 }
54 QString outputFileName() const
55 {
56 return m_outputFileName;
57 }
58
59 QString createCommand() const;
60 ArgumentPassingMethod createCommandArgumentPassingMethod() const
61 {
62 return m_createMethod;
63 }
64
65 QString verifyCommand() const;
66 ArgumentPassingMethod verifyCommandArgumentPassingMethod() const
67 {
68 return m_verifyMethod;
69 }
70
71 bool startCreateCommand(QProcess *process, const QStringList &files) const;
72 bool startVerifyCommand(QProcess *process, const QStringList &files) const;
73
74 static QString installPath();
75 static void setInstallPath(const QString &ip);
76
77 static std::vector<std::shared_ptr<ChecksumDefinition>> getChecksumDefinitions();
78 static std::vector<std::shared_ptr<ChecksumDefinition>> getChecksumDefinitions(QStringList &errors);
79
80 static std::shared_ptr<ChecksumDefinition> getDefaultChecksumDefinition(const std::vector<std::shared_ptr<ChecksumDefinition>> &available);
81 static void setDefaultChecksumDefinition(const std::shared_ptr<ChecksumDefinition> &checksumDefinition);
82
83protected:
84 void setCreateCommandArgumentPassingMethod(ArgumentPassingMethod method)
85 {
86 m_createMethod = method;
87 }
88 void setVerifyCommandArgumentPassingMethod(ArgumentPassingMethod method)
89 {
90 m_verifyMethod = method;
91 }
92
93private:
94 virtual QString doGetCreateCommand() const = 0;
95 virtual QString doGetVerifyCommand() const = 0;
96 virtual QStringList doGetCreateArguments(const QStringList &files) const = 0;
97 virtual QStringList doGetVerifyArguments(const QStringList &files) const = 0;
98
99private:
100 const QString m_id;
101 const QString m_label;
102 const QString m_outputFileName;
103 const QStringList m_patterns;
104 ArgumentPassingMethod m_createMethod = CommandLine;
105 ArgumentPassingMethod m_verifyMethod = CommandLine;
106};
107
108}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.