File indexing completed on 2024-04-28 03:56:34

0001 /*
0002     SPDX-FileCopyrightText: 2009 Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KPACKAGE_PACKAGE_P_H
0008 #define KPACKAGE_PACKAGE_P_H
0009 
0010 #include "../package.h"
0011 
0012 #include <QCryptographicHash>
0013 #include <QDir>
0014 #include <QHash>
0015 #include <QPointer>
0016 #include <QSharedData>
0017 #include <QString>
0018 #include <optional>
0019 namespace KPackage
0020 {
0021 class ContentStructure
0022 {
0023 public:
0024     ContentStructure()
0025     {
0026     }
0027 
0028     ContentStructure(const ContentStructure &other)
0029     {
0030         paths = other.paths;
0031         mimeTypes = other.mimeTypes;
0032         directory = other.directory;
0033         required = other.required;
0034     }
0035 
0036     ContentStructure &operator=(const ContentStructure &) = default;
0037 
0038     QStringList paths;
0039     QStringList mimeTypes;
0040     bool directory = false;
0041     bool required = false;
0042 };
0043 
0044 class PackagePrivate : public QSharedData
0045 {
0046 public:
0047     PackagePrivate();
0048     PackagePrivate(const PackagePrivate &other);
0049     ~PackagePrivate();
0050 
0051     PackagePrivate &operator=(const PackagePrivate &rhs);
0052 
0053     void createPackageMetadata(const QString &path);
0054     QString unpack(const QString &filePath);
0055     void updateHash(const QString &basePath, const QString &subPath, const QDir &dir, QCryptographicHash &hash);
0056     QString fallbackFilePath(const QByteArray &key, const QString &filename = QString()) const;
0057     bool hasCycle(const KPackage::Package &package);
0058     bool isInsidePackageDir(const QString &canonicalPath) const;
0059 
0060     QPointer<PackageStructure> structure;
0061     QString path;
0062     QString tempRoot;
0063     QStringList contentsPrefixPaths;
0064     QString defaultPackageRoot;
0065     QHash<QString, QString> discoveries;
0066     QHash<QByteArray, ContentStructure> contents;
0067     std::unique_ptr<Package> fallbackPackage;
0068     QStringList mimeTypes;
0069     std::optional<KPluginMetaData> metadata;
0070     bool externalPaths = false;
0071     bool valid = false;
0072     bool checkedValid = false;
0073 };
0074 
0075 }
0076 
0077 #endif