| 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 "providerbase_p.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 authentication(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 ProviderBase |
| 48 | { |
| 49 | Q_OBJECT |
| 50 | public: |
| 51 | OPDSProvider(); |
| 52 | ~OPDSProvider() override; |
| 53 | |
| 54 | // Unique ID, url of the feed. |
| 55 | QString id() const override; |
| 56 | |
| 57 | // Name of the feed. |
| 58 | QString name() const override; |
| 59 | |
| 60 | // Feed icon |
| 61 | QUrl icon() const override; |
| 62 | |
| 63 | [[nodiscard]] QString version() override; |
| 64 | [[nodiscard]] QUrl website() override; |
| 65 | [[nodiscard]] QUrl host() override; |
| 66 | [[nodiscard]] QString contactEmail() override; |
| 67 | [[nodiscard]] bool supportsSsl() override; |
| 68 | |
| 69 | void loadEntries(const KNSCore::SearchRequest &request) override; |
| 70 | void loadEntryDetails(const KNSCore::Entry &entry) override; |
| 71 | void loadPayloadLink(const KNSCore::Entry &entry, int linkNumber) override; |
| 72 | |
| 73 | bool setProviderXML(const QDomElement &xmldata) override; |
| 74 | bool isInitialized() const override; |
| 75 | void setCachedEntries(const KNSCore::Entry::List &cachedEntries) override; |
| 76 | |
| 77 | const std::unique_ptr<OPDSProviderPrivate> d; |
| 78 | |
| 79 | Q_DISABLE_COPY(OPDSProvider) |
| 80 | }; |
| 81 | |
| 82 | } |
| 83 | |
| 84 | #endif // OPDSPROVIDER_H |
| 85 | |