1 | /* |
2 | SPDX-FileCopyrightText: 2021 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
5 | */ |
6 | |
7 | #ifndef OPDSPROVIDER_H |
8 | #define OPDSPROVIDER_H |
9 | |
10 | #include "provider.h" |
11 | #include "xmlloader_p.h" |
12 | #include <QMap> |
13 | #include <memory> |
14 | |
15 | /** |
16 | * OPDS provider. |
17 | * |
18 | * The OPDS provider loads OPDS feeds: |
19 | * https://specs.opds.io/opds-1.2 |
20 | * |
21 | * These feeds are most common with online book providers, but the format itself is agnostic. |
22 | * For loading feeds, these, as with other providers, need to have a KNSRC file pointed |
23 | * at a Provider.xml, with the "type" element containing "opds" as text. |
24 | * |
25 | * Supports: |
26 | * - Loads a given feed, it's images, and loads it's download links. |
27 | * - Opensearch for the search, if available. |
28 | * - Should load full entries, if possible. |
29 | * - Navigation feed entries can be selected. |
30 | * |
31 | * TODO: |
32 | * - We need a better handling of non-free items (requires authentication). |
33 | * - entry navigation links are not supported. |
34 | * - pagination support (together with the navigation links) |
35 | * - No Sorting |
36 | * |
37 | * Would-be-nice, but requires a lot of rewiring in knewstuff: |
38 | * - We could get authenticated feeds going by using basic http authentiation(in spec), or have bearer token uris (oauth bearcaps). |
39 | * - Autodiscovery or protocol based discovery of opds catalogs, this does not gel with the provider xml system used by knewstuff. |
40 | * |
41 | * @since 5.83 |
42 | */ |
43 | |
44 | namespace KNSCore |
45 | { |
46 | class OPDSProviderPrivate; |
47 | class OPDSProvider : public Provider |
48 | { |
49 | Q_OBJECT |
50 | public: |
51 | typedef QList<Provider *> List; |
52 | |
53 | OPDSProvider(); |
54 | ~OPDSProvider() override; |
55 | |
56 | // Unique ID, url of the feed. |
57 | QString id() const override; |
58 | |
59 | // Name of the feed. |
60 | QString name() const override; |
61 | |
62 | // Feed icon |
63 | QUrl icon() const override; |
64 | |
65 | void loadEntries(const KNSCore::Provider::SearchRequest &request) override; |
66 | void loadEntryDetails(const KNSCore::Entry &entry) override; |
67 | void loadPayloadLink(const KNSCore::Entry &entry, int linkNumber) override; |
68 | |
69 | bool setProviderXML(const QDomElement &xmldata) override; |
70 | bool isInitialized() const override; |
71 | void setCachedEntries(const KNSCore::Entry::List &cachedEntries) override; |
72 | |
73 | const std::unique_ptr<OPDSProviderPrivate> d; |
74 | |
75 | Q_DISABLE_COPY(OPDSProvider) |
76 | }; |
77 | |
78 | } |
79 | |
80 | #endif // OPDSPROVIDER_H |
81 | |