46#include <QtXml/qdom.h>
47#include <QtCore/Q_PID>
51#define _WIN32_IE 0x0500
58 :
QObject(parent), m_uploadedentry(NULL), m_uploadprovider(NULL), m_installation(NULL), m_activefeeds(0),
59 m_initialized(false), m_cachepolicy(CacheNever), m_automationpolicy(AutomationOn)
70 kDebug() <<
"Initializing KNS::CoreEngine from '" << configfile <<
"'";
74 kError() <<
"No knsrc file named '" << configfile <<
"' was found." << endl;
82 kError() <<
"No knsrc file named '" << configfile <<
"' was found." << endl;
87 kError() <<
"A knsrc file was found but it doesn't contain a KNewStuff2 section." << endl;
92 m_providersurl =
group.readEntry(
"ProvidersUrl", QString());
99 QString uncompresssetting =
group.readEntry(
"Uncompress", QString(
"never"));
101 if (uncompresssetting ==
"true") {
102 uncompresssetting =
"always";
104 if (uncompresssetting !=
"always" && uncompresssetting !=
"archive" && uncompresssetting !=
"never") {
105 kError() <<
"invalid Uncompress setting chosen, must be one of: always, archive, or never" << endl;
110 m_installation->
setCommand(
group.readEntry(
"InstallationCommand", QString()));
118 QString checksumpolicy =
group.readEntry(
"ChecksumPolicy", QString());
119 if (!checksumpolicy.isEmpty()) {
120 if (checksumpolicy ==
"never")
122 else if (checksumpolicy ==
"ifpossible")
124 else if (checksumpolicy ==
"always")
127 kError() <<
"The checksum policy '" + checksumpolicy +
"' is unknown." << endl;
132 QString signaturepolicy =
group.readEntry(
"SignaturePolicy", QString());
133 if (!signaturepolicy.isEmpty()) {
134 if (signaturepolicy ==
"never")
136 else if (signaturepolicy ==
"ifpossible")
138 else if (signaturepolicy ==
"always")
141 kError() <<
"The signature policy '" + signaturepolicy +
"' is unknown." << endl;
146 QString scope =
group.readEntry(
"Scope", QString());
147 if (!scope.isEmpty()) {
150 else if (scope ==
"system")
153 kError() <<
"The scope '" + scope +
"' is unknown." << endl;
159 kError() <<
"System installation cannot be mixed with InstallPath." << endl;
165 QString cachePolicy =
group.readEntry(
"CachePolicy", QString());
166 if (!cachePolicy.isEmpty()) {
167 if (cachePolicy ==
"never") {
169 }
else if (cachePolicy ==
"replaceable") {
171 }
else if (cachePolicy ==
"resident") {
173 }
else if (cachePolicy ==
"only") {
176 kError() <<
"Cache policy '" + cachePolicy +
"' is unknown." << endl;
179 kDebug() <<
"cache policy: " << cachePolicy;
181 m_initialized =
true;
188 if (!m_initialized) {
192 return m_componentname;
199 if (!m_initialized) {
200 kError() <<
"Must call KNS::CoreEngine::init() first." << endl;
209 loadProvidersCache();
221 connect(provider_loader,
224 connect(provider_loader,
226 SLOT(slotProvidersFailed()));
228 provider_loader->
load(m_providersurl);
246 QStringList feeds = provider->
feeds();
247 for (
int i = 0; i < feeds.count(); i++) {
254 connect(entry_loader,
257 connect(entry_loader,
259 SLOT(slotEntriesFailed()));
260 connect(entry_loader,
262 SLOT(slotProgress(
KJob*,ulong)));
264 entry_loader->
load(provider, feed);
271 if (m_previewfiles.contains(entry)) {
280 if (!source.isValid()) {
281 kError() <<
"The entry doesn't have a preview." << endl;
291 SIGNAL(result(
KJob*)),
292 SLOT(slotPreviewResult(
KJob*)));
294 SIGNAL(progress(
KJob*,ulong)),
295 SLOT(slotProgress(
KJob*,ulong)));
297 m_entry_jobs[job] = entry;
308 if (!source.isValid()) {
309 kError() <<
"The entry doesn't have a payload." << endl;
326 kDebug() <<
"Downloading payload '" << source <<
"' to '" << destination <<
"'";
331 SIGNAL(result(
KJob*)),
332 SLOT(slotPayloadResult(
KJob*)));
334 SIGNAL(percent(
KJob*,ulong)),
335 SLOT(slotProgress(
KJob*,ulong)));
337 m_entry_jobs[job] = entry;
344 if (m_uploadedentry) {
345 kError() <<
"Another upload is in progress!" << endl;
350 kError() <<
"The provider doesn't support uploads." << endl;
357 m_uploadprovider = provider;
358 m_uploadedentry = entry;
367 SIGNAL(result(
KJob*)),
368 SLOT(slotUploadPayloadResult(
KJob*)));
379 mergeProviders(list);
382void CoreEngine::slotProvidersFailed()
384 kDebug() <<
"slotProvidersFailed";
408void CoreEngine::slotEntriesFailed()
417void CoreEngine::slotProgress(
KJob *job,
unsigned long percent)
422 if (copyJob != NULL) {
424 }
else if (transferJob != NULL) {
432void CoreEngine::slotPayloadResult(
KJob *job)
435 if (m_entry_jobs.contains(job)) {
436 Entry *entry = m_entry_jobs[job];
437 m_entry_jobs.remove(job);
440 kError() <<
"Cannot load payload file." << endl;
456void CoreEngine::slotPreviewResult(
KJob *job)
459 kError() <<
"Cannot load preview file." << endl;
462 m_entry_jobs.remove(job);
467 if (m_entry_jobs.contains(job)) {
469 Entry *entry = m_entry_jobs[job];
470 m_entry_jobs.remove(job);
480void CoreEngine::slotUploadPayloadResult(
KJob *job)
483 kError() <<
"Cannot upload payload file." << endl;
486 m_uploadedentry = NULL;
487 m_uploadprovider = NULL;
495 slotUploadPreviewResult(job);
506 SIGNAL(result(
KJob*)),
507 SLOT(slotUploadPreviewResult(
KJob*)));
510void CoreEngine::slotUploadPreviewResult(
KJob *job)
513 kError() <<
"Cannot upload preview file." << endl;
516 m_uploadedentry = NULL;
517 m_uploadprovider = NULL;
533 QDomElement exml = eh.entryXML();
536 QDomElement root = doc.createElement(
"ghnsupload");
537 root.appendChild(exml);
539 QFile f(sourcemeta.
path());
540 if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
541 kError() <<
"Cannot write meta information to '" << sourcemeta <<
"'." << endl;
543 m_uploadedentry = NULL;
544 m_uploadprovider = NULL;
549 QTextStream metastream(&f);
555 SIGNAL(result(
KJob*)),
556 SLOT(slotUploadMetaResult(
KJob*)));
559void CoreEngine::slotUploadMetaResult(
KJob *job)
562 kError() <<
"Cannot upload meta file." << endl;
565 m_uploadedentry = NULL;
566 m_uploadprovider = NULL;
571 m_uploadedentry = NULL;
572 m_uploadprovider = NULL;
579void CoreEngine::loadRegistry()
585 QString realAppName = m_componentname.split(
':')[0];
588 const QStringList
dirs = d.
findDirs(
"data",
"knewstuff2-entries.registry");
589 for (QStringList::ConstIterator it =
dirs.begin(); it !=
dirs.end(); ++it) {
592 const QStringList files =
dir.entryList(QDir::Files | QDir::Readable);
593 for (QStringList::const_iterator fit = files.begin(); fit != files.end(); ++fit) {
594 QString filepath = (*it) +
'/' + (*fit);
598 QFileInfo info(filepath);
604 QString thisAppName = QString::fromUtf8(QByteArray::fromBase64(info.baseName().toUtf8()));
608 thisAppName = thisAppName.split(
':')[0];
610 if (thisAppName != realAppName) {
614 ret = f.open(QIODevice::ReadOnly);
616 kWarning() <<
"The file could not be opened.";
621 ret = doc.setContent(&f);
623 kWarning() <<
"The file could not be parsed.";
627 QDomElement root = doc.documentElement();
628 if (root.tagName() !=
"ghnsinstall") {
629 kWarning() <<
"The file doesn't seem to be of interest.";
633 QDomElement stuff = root.firstChildElement(
"stuff");
634 if (stuff.isNull()) {
635 kWarning() <<
"Missing GHNS installation metadata.";
640 if (!handler.isValid()) {
641 kWarning() <<
"Invalid GHNS installation metadata.";
645 Entry *e = handler.entryptr();
648 m_entry_registry.insert(
id(e), e);
668void CoreEngine::loadProvidersCache()
673 QString cachefile = d.
findResource(
"cache", m_componentname +
"kns2providers.cache.xml");
674 if (cachefile.isEmpty()) {
675 kDebug() <<
"Cache not present, skip loading.";
679 kDebug() <<
"Loading provider cache from file '" + cachefile +
"'.";
684 ret = f.open(QIODevice::ReadOnly);
686 kWarning() <<
"The file could not be opened.";
692 ret = doc.setContent(&f);
694 kWarning() <<
"The file could not be parsed.";
699 QDomElement root = doc.documentElement();
700 if (root.tagName() !=
"ghnsproviders") {
701 kWarning() <<
"The file doesn't seem to be of interest.";
706 QDomElement provider = root.firstChildElement(
"provider");
707 if (provider.isNull()) {
708 kWarning() <<
"Missing provider entries in the cache.";
713 while (!provider.isNull()) {
715 if (!handler.isValid()) {
716 kWarning() <<
"Invalid provider metadata.";
720 Provider *p = handler.providerptr();
721 m_provider_cache.append(p);
722 m_provider_index[pid(p)] = p;
733 provider = provider.nextSiblingElement(
"provider");
741void CoreEngine::loadFeedCache(
Provider *provider)
745 kDebug() <<
"Loading feed cache.";
747 QStringList cachedirs = d.
findDirs(
"cache", m_componentname +
"kns2feeds.cache");
748 if (cachedirs.size() == 0) {
749 kDebug() <<
"Cache directory not present, skip loading.";
752 QString cachedir = cachedirs.first();
754 QStringList entrycachedirs = d.
findDirs(
"cache",
"knewstuff2-entries.cache/");
755 if (entrycachedirs.size() == 0) {
756 kDebug() <<
"Cache directory not present, skip loading.";
759 QString entrycachedir = entrycachedirs.first();
761 kDebug() <<
"Load from directory: " + cachedir;
763 QStringList feeds = provider->
feeds();
764 for (
int i = 0; i < feeds.count(); i++) {
766 QString feedname = feeds.at(i);
768 QString idbase64 = QString(pid(provider).toUtf8().toBase64() +
'-' + feedname);
769 QString cachefile = cachedir +
'/' + idbase64 +
".xml";
771 kDebug() <<
" + Load from file: " + cachefile;
775 ret = f.open(QIODevice::ReadOnly);
777 kWarning() <<
"The file could not be opened.";
782 ret = doc.setContent(&f);
784 kWarning() <<
"The file could not be parsed.";
788 QDomElement root = doc.documentElement();
789 if (root.tagName() !=
"ghnsfeeds") {
790 kWarning() <<
"The file doesn't seem to be of interest.";
794 QDomElement entryel = root.firstChildElement(
"entry-id");
795 if (entryel.isNull()) {
796 kWarning() <<
"Missing entries in the cache.";
800 while (!entryel.isNull()) {
801 QString idbase64 = entryel.text();
804 QString filepath = entrycachedir +
'/' + idbase64 +
".meta";
809 Entry *entry = loadEntryCache(filepath);
811 QString entryid = id(entry);
813 if (m_entry_registry.contains(entryid)) {
814 Entry * registryEntry = m_entry_registry.value(entryid);
824 entryel = entryel.nextSiblingElement(
"entry-id");
829KNS::Entry *CoreEngine::loadEntryCache(
const QString& filepath)
833 ret = f.open(QIODevice::ReadOnly);
835 kWarning() <<
"The file " << filepath <<
" could not be opened.";
840 ret = doc.setContent(&f);
842 kWarning() <<
"The file could not be parsed.";
846 QDomElement root = doc.documentElement();
847 if (root.tagName() !=
"ghnscache") {
848 kWarning() <<
"The file doesn't seem to be of interest.";
852 QDomElement stuff = root.firstChildElement(
"stuff");
853 if (stuff.isNull()) {
854 kWarning() <<
"Missing GHNS cache metadata.";
859 if (!handler.isValid()) {
860 kWarning() <<
"Invalid GHNS installation metadata.";
864 Entry *e = handler.entryptr();
866 m_entry_cache.append(e);
867 m_entry_index[id(e)] = e;
869 if (root.hasAttribute(
"previewfile")) {
870 m_previewfiles[e] = root.attribute(
"previewfile");
874 if (root.hasAttribute(
"payloadfile")) {
875 m_payloadfiles[e] = root.attribute(
"payloadfile");
886void CoreEngine::loadEntriesCache()
892 QStringList cachedirs = d.
findDirs(
"cache",
"knewstuff2-entries.cache/" + m_componentname);
893 if (cachedirs.size() == 0) {
897 QString cachedir = cachedirs.first();
902 QStringList files =
dir.entryList(QDir::Files | QDir::Readable);
903 for (QStringList::iterator fit = files.begin(); fit != files.end(); ++fit) {
904 QString filepath = cachedir +
'/' + (*fit);
907 Entry *e = loadEntryCache(filepath);
917void CoreEngine::shutdown()
919 m_entry_index.clear();
920 m_provider_index.clear();
922 qDeleteAll(m_entry_cache);
923 qDeleteAll(m_provider_cache);
925 m_entry_cache.clear();
926 m_provider_cache.clear();
928 delete m_installation;
931bool CoreEngine::providerCached(
Provider *provider)
933 if (m_cachepolicy ==
CacheNever)
return false;
935 if (m_provider_index.contains(pid(provider)))
942 QStringList oldfeeds = oldprovider->
feeds();
943 QStringList feeds = provider->
feeds();
944 if (oldfeeds.count() != feeds.count())
946 for (
int i = 0; i < feeds.count(); i++) {
959 for (Provider::List::Iterator it = providers.begin(); it != providers.end(); ++it) {
962 if (providerCached(p)) {
964 Provider *oldprovider = m_provider_index[pid(p)];
965 if (providerChanged(oldprovider, p)) {
966 kDebug() <<
"CACHE: update provider";
987 m_provider_cache.append(p);
988 m_provider_index[pid(p)] = p;
994bool CoreEngine::entryCached(
Entry *entry)
996 if (m_cachepolicy ==
CacheNever)
return false;
1000 if (m_entry_index.contains(
id(entry)) && m_entry_index[
id(entry)]->source() ==
Entry::Cache) {
1013 for (
int i = 0; i < m_entry_cache.count(); i++) {
1014 Entry *oldentry = m_entry_cache.at(i);
1015 if (
id(entry) ==
id(oldentry))
return true;
1026bool CoreEngine::entryChanged(
Entry *oldentry,
Entry *entry)
1038 for (Entry::List::Iterator it = entries.begin(); it != entries.end(); ++it) {
1042 QString thisId = id(e);
1045 if (m_entry_registry.contains(thisId)) {
1047 Entry *registryentry = m_entry_registry[thisId];
1050 if (entryChanged(registryentry, e)) {
1058 if (entryCached(e)) {
1060 Entry * cachedentry = m_entry_index[thisId];
1061 if (entryChanged(cachedentry, e)) {
1081 if (entryCached(e)) {
1084 Entry *cachedentry = m_entry_index[thisId];
1085 if (entryChanged(cachedentry, e)) {
1107 m_entry_cache.append(e);
1108 m_entry_index[thisId] = e;
1116 QStringList feeds = provider->
feeds();
1118 for (
int i = 0; i < feeds.size(); ++i) {
1120 feedname = feeds[i];
1123 cacheFeed(provider, feedname, feed, entries);
1127 if (m_activefeeds == 0) {
1132void CoreEngine::cacheProvider(
Provider *provider)
1136 kDebug() <<
"Caching provider.";
1139 QString cachefile = cachedir + m_componentname +
"kns2providers.cache.xml";
1141 kDebug() <<
" + Save to file '" + cachefile +
"'.";
1144 QDomElement root = doc.createElement(
"ghnsproviders");
1146 for (Provider::List::Iterator it = m_provider_cache.begin(); it != m_provider_cache.end(); ++it) {
1149 QDomElement pxml = ph.providerXML();
1150 root.appendChild(pxml);
1153 QDomElement pxml = ph.providerXML();
1154 root.appendChild(pxml);
1157 if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
1158 kError() <<
"Cannot write meta information to '" << cachedir <<
"'." << endl;
1162 QTextStream metastream(&f);
1173void CoreEngine::cacheFeed(
const Provider *provider,
const QString & feedname,
const Feed *feed,
Entry::List entries)
1180 QString cachedir = d.
saveLocation(
"cache", m_componentname +
"kns2feeds.cache");
1182 QString idbase64 = QString(pid(provider).toUtf8().toBase64() +
'-' + feedname);
1183 QString cachefile = idbase64 +
".xml";
1185 kDebug() <<
"Caching feed to file '" + cachefile +
"'.";
1188 QDomElement root = doc.createElement(
"ghnsfeeds");
1189 for (
int i = 0; i < entries.count(); i++) {
1190 QString idbase64 = id(entries.at(i)).toUtf8().toBase64();
1191 QDomElement entryel = doc.createElement(
"entry-id");
1192 root.appendChild(entryel);
1193 QDomText entrytext = doc.createTextNode(idbase64);
1194 entryel.appendChild(entrytext);
1197 QFile f(cachedir + cachefile);
1198 if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
1199 kError() <<
"Cannot write meta information to '" << cachedir + cachefile <<
"'." << endl;
1203 QTextStream metastream(&f);
1208void CoreEngine::cacheEntry(
Entry *entry)
1212 QString cachedir = d.
saveLocation(
"cache",
"knewstuff2-entries.cache/");
1214 kDebug() <<
"Caching entry in directory '" + cachedir +
"'.";
1218 QString idbase64 = QString(
id(entry).toUtf8().toBase64());
1219 QString cachefile = idbase64 +
".meta";
1221 kDebug() <<
"Caching to file '" + cachefile +
"'.";
1227 QDomElement exml = eh.entryXML();
1230 QDomElement root = doc.createElement(
"ghnscache");
1231 root.appendChild(exml);
1233 if (m_previewfiles.contains(entry)) {
1234 root.setAttribute(
"previewfile", m_previewfiles[entry]);
1240 QFile f(cachedir + cachefile);
1241 if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
1242 kError() <<
"Cannot write meta information to '" << cachedir + cachefile <<
"'." << endl;
1246 QTextStream metastream(&f);
1251void CoreEngine::registerEntry(
Entry *entry)
1253 m_entry_registry.insert(
id(entry), entry);
1259 QString registrydir = d.
saveLocation(
"data",
"knewstuff2-entries.registry");
1264 QString registryfile = QString(
id(entry).toUtf8().toBase64()) +
".meta";
1269 QDomElement exml = eh.entryXML();
1272 QDomElement root = doc.createElement(
"ghnsinstall");
1273 root.appendChild(exml);
1275 if (m_payloadfiles.contains(entry)) {
1276 root.setAttribute(
"payloadfile", m_payloadfiles[entry]);
1279 QFile f(registrydir + registryfile);
1280 if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
1281 kError() <<
"Cannot write meta information to '" << registrydir + registryfile <<
"'." << endl;
1285 QTextStream metastream(&f);
1290void KNS::CoreEngine::unregisterEntry(
Entry * entry)
1295 QString registrydir = d.
saveLocation(
"data",
"knewstuff2-entries.registry");
1298 QString registryfile = QString(
id(entry).toUtf8().toBase64()) +
".meta";
1300 QFile::remove(registrydir + registryfile);
1303 m_entry_registry.remove(
id(entry));
1306QString CoreEngine::id(
Entry *e)
1314QString CoreEngine::pid(
const Provider *p)
1321 QStringList feeds = p->
feeds();
1322 for (
int i = 0; i < feeds.count(); i++) {
1323 QString feedtype = feeds.at(i);
1330 return m_componentname;
1336 if (entries.size() != 1) {
1338 kError() <<
"ASSERT: payloadfile is not associated" << endl;
1341 Entry *entry = entries.first();
1356 kError() <<
"Checksum verification not possible" << endl;
1368 kError() <<
"Signature verification not possible" << endl;
1385 QStringList installedFiles;
1386 QString installpath(payloadfile);
1391 int pathcounter = 0;
1400 if (!m_installation->
targetDir().isEmpty()) {
1409#if defined(Q_WS_WIN)
1411 WCHAR wPath[MAX_PATH+1];
1412 if ( SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, wPath) == S_OK) {
1413 installdir = QString::fromUtf16((
const ushort *) wPath) + QLatin1Char(
'/') + m_installation->
installPath() + QLatin1Char(
'/');
1416 installdir = QDir::home().path() + QLatin1Char(
'/') + m_installation->
installPath() + QLatin1Char(
'/');
1421 installdir = QDir::home().path() +
'/' + m_installation->
installPath() +
'/';
1429 if (pathcounter != 1) {
1430 kError() <<
"Wrong number of installation directories given." << endl;
1434 kDebug() <<
"installdir: " << installdir;
1435 bool isarchive =
true;
1440 installpath = installdir;
1448 if (mimeType->name() ==
"application/zip") {
1449 archive =
new KZip(payloadfile);
1450 }
else if (mimeType->name() ==
"application/tar"
1451 || mimeType->name() ==
"application/x-gzip"
1452 || mimeType->name() ==
"application/x-bzip"
1453 || mimeType->name() ==
"application/x-lzma"
1454 || mimeType->name() ==
"application/x-xz") {
1455 archive =
new KTar(payloadfile);
1457 kError() <<
"Could not determine type of archive file '" << payloadfile <<
"'";
1465 bool success = archive->
open(QIODevice::ReadOnly);
1467 kError() <<
"Cannot open archive file '" << payloadfile <<
"'";
1477 dir->copyTo(installdir);
1479 installedFiles << archiveEntries(installdir,
dir);
1480 installedFiles << installdir +
'/';
1483 QFile::remove(payloadfile);
1489 kDebug() <<
"isarchive: " << isarchive;
1497 kDebug() <<
"installing non-archive from " << source.
url();
1498 QString installfile;
1499 QString ext = source.
fileName().section(
'.', -1);
1502 installfile +=
'-' + entry->
version();
1503 if (!ext.isEmpty()) installfile +=
'.' + ext;
1507 installpath = installdir +
'/' + installfile;
1515 QFile file(payloadfile);
1516 bool success =
true;
1518 if (QFile::exists(installpath) && update) {
1519 success = QFile::remove(installpath);
1522 success = file.rename(installpath);
1525 kError() <<
"Cannot move file '" << payloadfile <<
"' to destination '" << installpath <<
"'";
1528 installedFiles << installpath;
1529 installedFiles << installdir +
'/';
1535 if (!m_installation->
command().isEmpty()) {
1537 QString command(m_installation->
command());
1539 command.replace(
"%f", fileArg);
1545 int exitcode = process.
execute();
1548 kError() <<
"Command failed" << endl;
1560 SIGNAL(validityResult(
int)),
1561 SLOT(slotInstallationVerification(
int)));
1566 m_payloadfiles[entry] = installpath;
1567 registerEntry(entry);
1583 QFileInfo info(file);
1584 if (info.isFile()) {
1587 command.replace(
"%f", fileArg);
1590 int exitcode = process.
execute();
1593 kError() <<
"Command failed" << endl;
1602 if (file.endsWith(
'/')) {
1604 bool worked =
dir.rmdir(file);
1610 if (QFile::exists(file)) {
1611 bool worked = QFile::remove(file);
1613 kWarning() <<
"unable to delete file " << file;
1617 kWarning() <<
"unable to delete file " << file <<
". file does not exist.";
1623 unregisterEntry(entry);
1630void CoreEngine::slotInstallationVerification(
int result)
1642 m_automationpolicy = policy;
1647 m_cachepolicy = policy;
1650QStringList KNS::CoreEngine::archiveEntries(
const QString& path,
const KArchiveDirectory * dir)
1653 foreach(
const QString &entry,
dir->entries()) {
1654 QString childPath = path +
'/' + entry;
1655 if (
dir->entry(entry)->isFile()) {
1659 if (
dir->entry(entry)->isDirectory()) {
1661 files << archiveEntries(childPath, childDir);
1662 files << childPath +
'/';
1669#include "coreengine.moc"
virtual bool open(QIODevice::OpenMode mode)
const KArchiveDirectory * directory() const
KConfigGroup group(const char *group)
bool hasGroup(const char *group) const
AccessMode accessMode() const
virtual QString errorString() const
static Ptr findByPath(const QString &path, mode_t mode=0, bool fast_mode=false, int *accuracy=0)
void signalEntriesFinished()
QString componentName() const
void signalProviderLoaded(KNS::Provider *provider)
Indicates that the list of providers has been successfully loaded.
void signalInstallationFinished()
void signalPayloadLoaded(KUrl payload)
bool install(const QString &payloadfile)
Installs an entry's payload file.
void setCachePolicy(CachePolicy policy)
void signalInstallationFailed()
bool uploadEntry(Provider *provider, Entry *entry)
Uploads a complete entry, including its payload and preview files (if present) and all associated met...
void signalEntryUploaded()
void signalEntriesFailed()
void mergeEntries(Entry::List entries, Feed *feed, const Provider *provider)
void signalEntryLoaded(KNS::Entry *entry, const KNS::Feed *feed, const KNS::Provider *provider)
void downloadPayload(Entry *entry)
Downloads a payload file.
void signalProvidersFinished()
void signalProviderChanged(KNS::Provider *provider)
void signalEntryChanged(KNS::Entry *entry)
void signalPayloadFailed(KNS::Entry *entry)
void setAutomationPolicy(AutomationPolicy policy)
void downloadPreview(Entry *entry)
Downloads a preview file.
void signalProgress(const QString &message, int percentage)
bool uninstall(KNS::Entry *entry)
Uninstalls an entry.
void start()
Starts the engine.
bool init(const QString &configfile)
Initializes the engine.
void signalProvidersFailed()
void signalPreviewFailed()
CoreEngine(QObject *parent)
Constructor.
CachePolicy
Policy on how to cache the data received from the network.
@ CacheResident
Operate on cache files but never update them.
@ CacheReplaceable
Like CacheReplaceable, but only update if necessary.
@ CacheNever
Do not use any cache.
void signalEntriesFeedFinished(const KNS::Feed *feed)
void loadEntries(Provider *provider)
Loads all entries of all the feeds from a provider.
void signalPreviewLoaded(KUrl preview)
AutomationPolicy
Engine automation can be activated to let the engine take care by itself of all the method calls need...
Parser and dumper for KNewStuff data entries.
Feed * feed() const
Returns the feed which was used for download.
const Provider * provider() const
Returns the provider which was used for download.
void load(const Provider *provider, Feed *feed)
Starts asynchronously loading the list of entries from the given provider for the given feed.
KNewStuff data entry container.
void setInstalledFiles(const QStringList &files)
Set the files that have been installed by the install command.
KTranslatable preview() const
Retrieve the file name of an image containing a preview of the object.
QDate releaseDate() const
Retrieve the date of the object's publication.
void setUnInstalledFiles(const QStringList &files)
Set the files that have been uninstalled by the uninstall command.
QString signature() const
Returns the signature for the entry.
KTranslatable name() const
Retrieve the name of the data object.
KTranslatable payload() const
Retrieve the file name of the object.
Status status()
Retrieves the entry's status.
QString checksum() const
Returns the checksum for the entry.
void setStatus(Status status)
Sets the entry's status.
void setSource(Source source)
int release() const
Retrieve the release number of the object.
QString version() const
Retrieve the version string of the object.
QStringList installedFiles() const
Retrieve the locally installed files.
KUrl feedUrl() const
Retrieve the URL of the feed.
void addEntry(Entry *entry)
Adds an association to an entry.
void removeEntry(Entry *entry)
Removes an association to an entry.
KNewStuff entry installation.
QString installPath() const
QString absoluteInstallPath() const
Policy checksumPolicy() const
void setUninstallCommand(const QString &command)
QString standardResourceDir() const
QString uncompression() const
QString uninstallCommand() const
void setCommand(const QString &command)
void setChecksumPolicy(Policy policy)
void setScope(Scope scope)
void setTargetDir(const QString &dir)
void setSignaturePolicy(Policy policy)
void setAbsoluteInstallPath(const QString &dir)
void setStandardResourceDir(const QString &dir)
QString targetDir() const
Policy signaturePolicy() const
void setInstallPath(const QString &dir)
void setUncompression(const QString &uncompression)
void setCustomName(bool customname)
QString language() const
Returns the language which most likely resembles the current language.
QString representation() const
Returns the string which matches most closely the current language.
Parser and dumper for KNewStuff providers.
KNewStuff provider loader.
void load(const QString &providersurl)
Starts asynchronously loading the list of providers from the specified URL.
KNewStuff provider container.
Feed * downloadUrlFeed(const QString &feedtype) const
Feed to retrieve for the given feed type.
KUrl uploadUrl() const
Retrieves the upload URL.
QStringList feeds() const
Returns a list of all feeds.
KTranslatable name() const
Retrieves the common name of the provider.
KUrl webService() const
Retrieves the URL to the DXS Web Service.
Handles security related issues, like signing, verifying.
void checkValidity(const QString &fileName)
Verifies the integrity and the signature of a tarball file.
@ SIGNED_OK
The MD5 sum check is OK.
void setShellCommand(const QString &cmd)
int execute(int msecs=-1)
static QString installPath(const char *type)
QString saveLocation(const char *type, const QString &suffix=QString(), bool create=true) const
QStringList findDirs(const char *type, const QString &reldir) const
static QString locate(const char *type, const QString &filename, const KComponentData &cData=KGlobal::mainComponent())
QString findResource(const char *type, const QString &filename) const
static QString locateLocal(const char *type, const QString &filename, bool createDir, const KComponentData &cData=KGlobal::mainComponent())
QString pathOrUrl() const
static KUrl fromPath(const QString &text)
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
QString path(AdjustPathOption trailing=LeaveTrailingSlash) const
void setFileName(const QString &_txt)
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
QString i18n(const char *text)
FileCopyJob * file_copy(const KUrl &src, const KUrl &dest, int permissions=-1, JobFlags flags=DefaultFlags)
void message(KMessage::MessageType messageType, const QString &text, const QString &caption=QString())
QString randomString(int length)
QString dir(const QString &fileClass)
QString quoteArg(const QString &arg)