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 "providerbase_p.h" |
14 | #include <QDomDocument> |
15 | #include <QMap> |
16 | |
17 | namespace KNSCore |
18 | { |
19 | class 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 | */ |
33 | class StaticXmlProvider : public ProviderBase |
34 | { |
35 | Q_OBJECT |
36 | public: |
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::SearchRequest &request) override; |
55 | void loadPayloadLink(const KNSCore::Entry &entry, int) override; |
56 | |
57 | [[nodiscard]] QString name() const override; |
58 | [[nodiscard]] QUrl icon() const override; |
59 | [[nodiscard]] QString version() override; |
60 | [[nodiscard]] QUrl website() override; |
61 | [[nodiscard]] QUrl host() override; |
62 | [[nodiscard]] QString contactEmail() override; |
63 | [[nodiscard]] bool supportsSsl() override; |
64 | |
65 | private Q_SLOTS: |
66 | void slotFeedFileLoaded(const KNSCore::SearchRequest &request, const QDomDocument &); |
67 | |
68 | private: |
69 | bool searchIncludesEntry(const KNSCore::SearchRequest &request, const Entry &entry) const; |
70 | QUrl downloadUrl(SortMode mode) const; |
71 | Entry::List installedEntries() const; |
72 | |
73 | // map of download urls to their feed name |
74 | QMap<QString, QUrl> mDownloadUrls; |
75 | QUrl mUploadUrl; |
76 | QUrl mNoUploadUrl; |
77 | |
78 | // cache of all entries known from this provider so far, mapped by their id |
79 | Entry::List mCachedEntries; |
80 | QString mId; |
81 | bool mInitialized; |
82 | QUrl m_iconUrl; |
83 | QString m_name; |
84 | |
85 | Q_DISABLE_COPY(StaticXmlProvider) |
86 | }; |
87 | |
88 | } |
89 | |
90 | #endif |
91 | |