29 #include <QtCore/QTimer>
46 kDebug(550) <<
"setting provider xml";
48 if (xmldata.tagName() !=
"provider")
51 mUploadUrl = xmldata.attribute(
"uploadurl");
52 mNoUploadUrl = xmldata.attribute(
"nouploadurl");
54 QString url = xmldata.attribute(
"downloadurl");
59 url = xmldata.attribute(
"downloadurl-latest");
61 mDownloadUrls.insert(
"latest",
KUrl(url));
64 url = xmldata.attribute(
"downloadurl-score");
66 mDownloadUrls.insert(
"score",
KUrl(url));
69 url = xmldata.attribute(
"downloadurl-downloads");
71 mDownloadUrls.insert(
"downloads",
KUrl(url));
77 KUrl iconurl(xmldata.attribute(
"icon"));
78 if (!iconurl.isValid())
79 iconurl.
setPath(xmldata.attribute(
"icon"));
83 for (n = xmldata.firstChild(); !n.isNull(); n = n.nextSibling()) {
84 QDomElement e = n.toElement();
85 if (e.tagName() ==
"title") {
87 mName = e.text().trimmed();
88 kDebug() <<
"add name for provider ("<<
this <<
"): " << e.text();
93 if ((mNoUploadUrl.isValid()) && (mUploadUrl.isValid())) {
94 kWarning(550) <<
"StaticXmlProvider: both uploadurl and nouploadurl given";
98 if ((!mNoUploadUrl.isValid()) && (!mUploadUrl.isValid())) {
99 kWarning(550) <<
"StaticXmlProvider: neither uploadurl nor nouploadurl given";
103 mId = mDownloadUrls[
QString()].url();
105 mId = mDownloadUrls[mDownloadUrls.keys().first()].url();
108 QTimer::singleShot(0,
this, SLOT(slotEmitProviderInitialized()));
113 void StaticXmlProvider::slotEmitProviderInitialized()
126 kDebug() <<
"Set cached entries " << cachedEntries.size();
127 mCachedEntries.append(cachedEntries);
132 mCurrentRequest = request;
135 if (request.
page > 0) {
141 kDebug() <<
"Installed entries: " << mId << installedEntries().size();
147 if (!url.isEmpty()) {
151 connect(loader, SIGNAL(signalLoaded(QDomDocument)), SLOT(slotFeedFileLoaded(QDomDocument)));
152 connect(loader, SIGNAL(signalFailed()), SLOT(slotFeedFailed()));
154 mFeedLoaders.insert(request.
sortMode, loader);
162 KUrl StaticXmlProvider::downloadUrl(SortMode mode)
const
168 url = mDownloadUrls.value(
"score");
171 url = mDownloadUrls.value(
QString());
175 url = mDownloadUrls.value(
"latest");
178 url = mDownloadUrls.value(
"downloads");
182 url = mDownloadUrls.value(
QString());
187 void StaticXmlProvider::slotFeedFileLoaded(
const QDomDocument& doc)
201 element = doc.documentElement();
203 for (n = element.firstChildElement(); !n.isNull(); n = n.nextSiblingElement()) {
205 entry.setEntryXML(n.toElement());
207 entry.setProviderId(mId);
209 int index = mCachedEntries.indexOf(entry);
212 EntryInternal cacheEntry = mCachedEntries.takeAt(index);
215 ((cacheEntry.version() != entry.version()) || (cacheEntry.releaseDate() != entry.releaseDate()))) {
217 entry.setUpdateVersion(entry.version());
218 entry.setVersion(cacheEntry.version());
219 entry.setUpdateReleaseDate(entry.releaseDate());
220 entry.setReleaseDate(cacheEntry.releaseDate());
222 entry.setStatus(cacheEntry.status());
226 mCachedEntries.append(entry);
228 if (searchIncludesEntry(entry)) {
235 void StaticXmlProvider::slotFeedFailed()
252 if (entry.
name().contains(search, Qt::CaseInsensitive) ||
253 entry.
summary().contains(search, Qt::CaseInsensitive) ||
254 entry.
author().
name().contains(search, Qt::CaseInsensitive)
273 entries.append(entry);
282 #include "staticxmlprovider.moc"