ntroduce the concept of package fallback
This commit is contained in:
parent
2b7d633687
commit
d369782ae1
@ -49,6 +49,7 @@ Package::Package(PackageStructure *structure)
|
|||||||
: d(new PackagePrivate())
|
: d(new PackagePrivate())
|
||||||
{
|
{
|
||||||
d->structure = structure;
|
d->structure = structure;
|
||||||
|
d->fallbackPackage = Package(structure);
|
||||||
if (d->structure) {
|
if (d->structure) {
|
||||||
d->structure.data()->initPackage(this);
|
d->structure.data()->initPackage(this);
|
||||||
}
|
}
|
||||||
@ -290,7 +291,7 @@ QString Package::filePath(const char *fileType, const QString &filename) const
|
|||||||
{
|
{
|
||||||
if (!d->valid) {
|
if (!d->valid) {
|
||||||
//qDebug() << "package is not valid";
|
//qDebug() << "package is not valid";
|
||||||
return QString();
|
return d->fallbackFilePath(fileType, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString discoveryKey(fileType + filename);
|
const QString discoveryKey(fileType + filename);
|
||||||
@ -305,7 +306,7 @@ QString Package::filePath(const char *fileType, const QString &filename) const
|
|||||||
//qDebug()<<d->contents.keys();
|
//qDebug()<<d->contents.keys();
|
||||||
if (!d->contents.contains(fileType)) {
|
if (!d->contents.contains(fileType)) {
|
||||||
//qDebug() << "package does not contain" << fileType << filename;
|
//qDebug() << "package does not contain" << fileType << filename;
|
||||||
return QString();
|
return d->fallbackFilePath(fileType, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
paths = d->contents[fileType].paths;
|
paths = d->contents[fileType].paths;
|
||||||
@ -313,7 +314,7 @@ QString Package::filePath(const char *fileType, const QString &filename) const
|
|||||||
if (paths.isEmpty()) {
|
if (paths.isEmpty()) {
|
||||||
//qDebug() << "no matching path came of it, while looking for" << fileType << filename;
|
//qDebug() << "no matching path came of it, while looking for" << fileType << filename;
|
||||||
d->discoveries.insert(discoveryKey, QString());
|
d->discoveries.insert(discoveryKey, QString());
|
||||||
return QString();
|
return d->fallbackFilePath(fileType, filename);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//when filetype is empty paths is always empty, so try with an empty string
|
//when filetype is empty paths is always empty, so try with an empty string
|
||||||
@ -356,7 +357,7 @@ QString Package::filePath(const char *fileType, const QString &filename) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << fileType << filename << "does not exist in" << prefixes << "at root" << d->path;
|
//qDebug() << fileType << filename << "does not exist in" << prefixes << "at root" << d->path;
|
||||||
return QString();
|
return d->fallbackFilePath(fileType, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Package::entryList(const char *key) const
|
QStringList Package::entryList(const char *key) const
|
||||||
@ -792,6 +793,7 @@ PackagePrivate &PackagePrivate::operator=(const PackagePrivate &rhs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
structure = rhs.structure;
|
structure = rhs.structure;
|
||||||
|
fallbackPackage = Package(structure.data());
|
||||||
path = rhs.path;
|
path = rhs.path;
|
||||||
contentsPrefixPaths = rhs.contentsPrefixPaths;
|
contentsPrefixPaths = rhs.contentsPrefixPaths;
|
||||||
servicePrefix = rhs.servicePrefix;
|
servicePrefix = rhs.servicePrefix;
|
||||||
@ -871,4 +873,13 @@ void PackagePrivate::createPackageMetadata(const QString &path)
|
|||||||
metadata = new KPluginInfo(metadataPath);
|
metadata = new KPluginInfo(metadataPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PackagePrivate::fallbackFilePath(const char *key, const QString &filename) const
|
||||||
|
{
|
||||||
|
if (fallbackPackage.isValid()) {
|
||||||
|
return fallbackPackage.filePath(key, filename);
|
||||||
|
} else {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
@ -73,6 +73,7 @@ public:
|
|||||||
void createPackageMetadata(const QString &path);
|
void createPackageMetadata(const QString &path);
|
||||||
QString unpack(const QString &filePath);
|
QString unpack(const QString &filePath);
|
||||||
void updateHash(const QString &basePath, const QString &subPath, const QDir &dir, QCryptographicHash &hash);
|
void updateHash(const QString &basePath, const QString &subPath, const QDir &dir, QCryptographicHash &hash);
|
||||||
|
QString fallbackFilePath(const char *key, const QString &filename = QString()) const;
|
||||||
|
|
||||||
QWeakPointer<PackageStructure> structure;
|
QWeakPointer<PackageStructure> structure;
|
||||||
QString path;
|
QString path;
|
||||||
@ -82,6 +83,7 @@ public:
|
|||||||
QString servicePrefix;
|
QString servicePrefix;
|
||||||
QHash<QString, QString> discoveries;
|
QHash<QString, QString> discoveries;
|
||||||
QHash<QByteArray, ContentStructure> contents;
|
QHash<QByteArray, ContentStructure> contents;
|
||||||
|
Package fallbackPackage;
|
||||||
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
|
#ifndef PLASMA_NO_PACKAGE_EXTRADATA
|
||||||
QStringList mimeTypes;
|
QStringList mimeTypes;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user