1/*
2 knewstuff3/provider.h
3 This file is part of KNewStuff2.
4 SPDX-FileCopyrightText: 2009 Jeremy Whiting <jpwhiting@kde.org>
5 SPDX-FileCopyrightText: 2009-2010 Frederik Gladhorn <gladhorn@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.1-or-later
8*/
9
10#ifndef KNEWSTUFF3_STATICXMLPROVIDER_P_H
11#define KNEWSTUFF3_STATICXMLPROVIDER_P_H
12
13#include "provider.h"
14#include <QDomDocument>
15#include <QMap>
16
17namespace KNSCore
18{
19class XmlLoader;
20
21/**
22 * @short KNewStuff Base Provider class.
23 *
24 * This class provides accessors for the provider object.
25 * It should not be used directly by the application.
26 * This class is the base class and will be instantiated for
27 * static website providers.
28 *
29 * @author Jeremy Whiting <jpwhiting@kde.org>
30 *
31 * @internal
32 */
33class StaticXmlProvider : public Provider
34{
35 Q_OBJECT
36public:
37 typedef QList<Provider *> List;
38 /**
39 * Constructor.
40 */
41 StaticXmlProvider();
42
43 QString id() const override;
44
45 /**
46 * set the provider data xml, to initialize the provider
47 */
48 bool setProviderXML(const QDomElement &xmldata) override;
49
50 bool isInitialized() const override;
51
52 void setCachedEntries(const KNSCore::Entry::List &cachedEntries) override;
53
54 void loadEntries(const KNSCore::Provider::SearchRequest &request) override;
55 void loadPayloadLink(const KNSCore::Entry &entry, int) override;
56
57private Q_SLOTS:
58 void slotEmitProviderInitialized();
59 void slotFeedFileLoaded(const QDomDocument &);
60 void slotFeedFailed();
61
62private:
63 bool searchIncludesEntry(const Entry &entry) const;
64 QUrl downloadUrl(SortMode mode) const;
65 Entry::List installedEntries() const;
66
67 // map of download urls to their feed name
68 QMap<QString, QUrl> mDownloadUrls;
69 QUrl mUploadUrl;
70 QUrl mNoUploadUrl;
71
72 // cache of all entries known from this provider so far, mapped by their id
73 Entry::List mCachedEntries;
74 QMap<Provider::SortMode, XmlLoader *> mFeedLoaders;
75 Provider::SearchRequest mCurrentRequest;
76 QString mId;
77 bool mInitialized;
78
79 Q_DISABLE_COPY(StaticXmlProvider)
80};
81
82}
83
84#endif
85

source code of knewstuff/src/staticxml/staticxmlprovider_p.h