allow installing an uncompressed package as well
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=792006
This commit is contained in:
parent
bd671a7c8a
commit
a17a25a3b3
69
package.cpp
69
package.cpp
@ -218,34 +218,50 @@ bool Package::installPackage(const QString& package,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!QFile::exists(package)) {
|
QFileInfo fileInfo(package);
|
||||||
|
if (!fileInfo.exists()) {
|
||||||
kWarning(505) << "No such file:" << package;
|
kWarning(505) << "No such file:" << package;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
KZip archive(package);
|
QString path;
|
||||||
if (!archive.open(QIODevice::ReadOnly)) {
|
|
||||||
kWarning(505) << "Could not open package file:" << package;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const KArchiveDirectory* source = archive.directory();
|
|
||||||
const KArchiveEntry* metadata = source->entry("metadata.desktop");
|
|
||||||
|
|
||||||
if (!metadata) {
|
|
||||||
kWarning(505) << "No metadata file in package" << package;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile f(package);
|
|
||||||
KTempDir tempdir;
|
KTempDir tempdir;
|
||||||
source->copyTo(tempdir.name());
|
bool archivedPackage = false;
|
||||||
|
|
||||||
QString metadataPath = tempdir.name() + "metadata.desktop";
|
if (fileInfo.isDir()) {
|
||||||
|
// we have a directory, so let's just install what is in there
|
||||||
|
path = package;
|
||||||
|
|
||||||
|
// make sure we end in a slash!
|
||||||
|
if (path[path.size() - 1] != '/') {
|
||||||
|
path.append('/');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
KZip archive(package);
|
||||||
|
if (!archive.open(QIODevice::ReadOnly)) {
|
||||||
|
kWarning(505) << "Could not open package file:" << package;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
archivedPackage = true;
|
||||||
|
const KArchiveDirectory* source = archive.directory();
|
||||||
|
const KArchiveEntry* metadata = source->entry("metadata.desktop");
|
||||||
|
|
||||||
|
if (!metadata) {
|
||||||
|
kWarning(505) << "No metadata file in package" << package;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
path = tempdir.name();
|
||||||
|
source->copyTo(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString metadataPath = path + "metadata.desktop";
|
||||||
if (!QFile::exists(metadataPath)) {
|
if (!QFile::exists(metadataPath)) {
|
||||||
kWarning(505) << "No metadata file in package" << package;
|
kWarning(505) << "No metadata file in package" << package;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageMetadata meta(metadataPath);
|
PackageMetadata meta(metadataPath);
|
||||||
QString targetName = meta.pluginName();
|
QString targetName = meta.pluginName();
|
||||||
|
|
||||||
@ -260,15 +276,26 @@ bool Package::installPackage(const QString& package,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
KIO::FileCopyJob* job = KIO::file_move(tempdir.name(), targetName, -1, KIO::HideProgressInfo);
|
KIO::FileCopyJob* job(0);
|
||||||
|
|
||||||
|
if (archivedPackage) {
|
||||||
|
// it's in a temp dir, so just move it over.
|
||||||
|
job = KIO::file_move(path, targetName, -1, KIO::HideProgressInfo);
|
||||||
|
} else {
|
||||||
|
// it's a directory containing the stuff, so copy the contents rather
|
||||||
|
// than move them
|
||||||
|
job = KIO::file_copy(path, targetName, -1, KIO::HideProgressInfo);
|
||||||
|
}
|
||||||
|
|
||||||
if (!job->exec()) {
|
if (!job->exec()) {
|
||||||
kWarning(505) << "Could not move package to destination:" << targetName;
|
kWarning(505) << "Could not move package to destination:" << targetName;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need to remove the temp dir (which has been moved)
|
if (archivedPackage) {
|
||||||
tempdir.setAutoRemove(false);
|
// no need to remove the temp dir (which has been successfully moved if it's an archive)
|
||||||
|
tempdir.setAutoRemove(false);
|
||||||
|
}
|
||||||
|
|
||||||
// and now we register it as a service =)
|
// and now we register it as a service =)
|
||||||
targetName.append("/metadata.desktop");
|
targetName.append("/metadata.desktop");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user