1 | /* |
2 | SPDX-FileCopyrightText: 2009 Rob Scheepmaker <r.scheepmaker@student.utwente.nl> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KPACKAGE_PACKAGE_P_H |
8 | #define KPACKAGE_PACKAGE_P_H |
9 | |
10 | #include "../package.h" |
11 | |
12 | #include <QCryptographicHash> |
13 | #include <QDir> |
14 | #include <QHash> |
15 | #include <QPointer> |
16 | #include <QSharedData> |
17 | #include <QString> |
18 | #include <optional> |
19 | namespace KPackage |
20 | { |
21 | class ContentStructure |
22 | { |
23 | public: |
24 | ContentStructure() |
25 | { |
26 | } |
27 | |
28 | ContentStructure(const ContentStructure &other) |
29 | { |
30 | paths = other.paths; |
31 | mimeTypes = other.mimeTypes; |
32 | directory = other.directory; |
33 | required = other.required; |
34 | } |
35 | |
36 | ContentStructure &operator=(const ContentStructure &) = default; |
37 | |
38 | QStringList paths; |
39 | QStringList mimeTypes; |
40 | bool directory = false; |
41 | bool required = false; |
42 | }; |
43 | |
44 | class PackagePrivate : public QSharedData |
45 | { |
46 | public: |
47 | PackagePrivate(); |
48 | PackagePrivate(const PackagePrivate &other); |
49 | ~PackagePrivate(); |
50 | |
51 | PackagePrivate &operator=(const PackagePrivate &rhs); |
52 | |
53 | void createPackageMetadata(const QString &path); |
54 | QString unpack(const QString &filePath); |
55 | void updateHash(const QString &basePath, const QString &subPath, const QDir &dir, QCryptographicHash &hash); |
56 | QString fallbackFilePath(const QByteArray &key, const QString &filename = QString()) const; |
57 | bool hasCycle(const KPackage::Package &package); |
58 | bool isInsidePackageDir(const QString &canonicalPath) const; |
59 | |
60 | QPointer<PackageStructure> structure; |
61 | QString path; |
62 | QString tempRoot; |
63 | QStringList contentsPrefixPaths; |
64 | QString defaultPackageRoot; |
65 | QHash<QString, QString> discoveries; |
66 | QHash<QByteArray, ContentStructure> contents; |
67 | std::unique_ptr<Package> fallbackPackage; |
68 | QStringList mimeTypes; |
69 | std::optional<KPluginMetaData> metadata; |
70 | bool externalPaths = false; |
71 | bool valid = false; |
72 | bool checkedValid = false; |
73 | }; |
74 | |
75 | } |
76 | |
77 | #endif |
78 | |