File indexing completed on 2024-05-05 05:50:42

0001 /*
0002     SPDX-FileCopyrightText: 2016 Elvis Angelaccio <elvis.angelaccio@kde.org>
0003 
0004     SPDX-License-Identifier: BSD-2-Clause
0005 */
0006 
0007 #ifndef OPTIONS_H
0008 #define OPTIONS_H
0009 
0010 #include "kerfuffle_export.h"
0011 
0012 #include <QDebug>
0013 
0014 namespace Kerfuffle
0015 {
0016 class KERFUFFLE_EXPORT Options
0017 {
0018 public:
0019     bool encryptedArchiveHint() const;
0020     void setEncryptedArchiveHint(bool encrypted);
0021 
0022 private:
0023     bool m_encryptedArchiveHint = false;
0024 };
0025 
0026 class KERFUFFLE_EXPORT CompressionOptions : public Options
0027 {
0028 public:
0029     /**
0030      * @return Whether a custom compression level has been set in the options.
0031      * If false, the default level from the ArchiveFormat should be used instead.
0032      * @see compressionLevel()
0033      */
0034     bool isCompressionLevelSet() const;
0035 
0036     /**
0037      * @return Whether a custom volume size has been set in the options.
0038      * If false, the default size from the ArchiveFormat should be used instead.
0039      * @see compressionLevel()
0040      */
0041     bool isVolumeSizeSet() const;
0042 
0043     int compressionLevel() const;
0044     void setCompressionLevel(int level);
0045     ulong volumeSize() const;
0046     void setVolumeSize(ulong size);
0047     QString compressionMethod() const;
0048     void setCompressionMethod(const QString &method);
0049     QString encryptionMethod() const;
0050     void setEncryptionMethod(const QString &method);
0051 
0052     /**
0053      * The working directory of an AddJob.
0054      * All the path names of new files will be relative to this directory.
0055      */
0056     QString globalWorkDir() const;
0057 
0058     /**
0059      * Sets the global working directory to @p workDir.
0060      * All interfaces should set this before an AddJob or CreateJob.
0061      */
0062     void setGlobalWorkDir(const QString &workDir);
0063 
0064 private:
0065     int m_compressionLevel = -1;
0066     ulong m_volumeSize = 0;
0067     QString m_compressionMethod;
0068     QString m_encryptionMethod;
0069     QString m_globalWorkDir;
0070 };
0071 
0072 class KERFUFFLE_EXPORT ExtractionOptions : public Options
0073 {
0074 public:
0075     bool preservePaths() const;
0076     void setPreservePaths(bool preservePaths);
0077     bool isDragAndDropEnabled() const;
0078     void setDragAndDropEnabled(bool enabled);
0079     bool alwaysUseTempDir() const;
0080     void setAlwaysUseTempDir(bool alwaysUseTempDir);
0081 
0082 private:
0083     bool m_preservePaths = true;
0084     bool m_dragAndDrop = false;
0085     bool m_alwaysUseTempDir = false;
0086 };
0087 
0088 QDebug KERFUFFLE_EXPORT operator<<(QDebug d, const CompressionOptions &options);
0089 QDebug KERFUFFLE_EXPORT operator<<(QDebug d, ExtractionOptions options);
0090 
0091 }
0092 
0093 Q_DECLARE_METATYPE(Kerfuffle::CompressionOptions)
0094 Q_DECLARE_METATYPE(Kerfuffle::ExtractionOptions)
0095 
0096 #endif