File indexing completed on 2024-04-14 03:54:09

0001 /*
0002     SPDX-FileCopyrightText: 2021 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef OPDSPROVIDER_H
0008 #define OPDSPROVIDER_H
0009 
0010 #include "provider.h"
0011 #include "xmlloader_p.h"
0012 #include <QMap>
0013 #include <memory>
0014 
0015 /**
0016  * OPDS provider.
0017  *
0018  * The OPDS provider loads OPDS feeds:
0019  * https://specs.opds.io/opds-1.2
0020  *
0021  * These feeds are most common with online book providers, but the format itself is agnostic.
0022  * For loading feeds, these, as with other providers, need to have a KNSRC file pointed
0023  * at a Provider.xml, with the "type" element containing "opds" as text.
0024  *
0025  * Supports:
0026  * - Loads a given feed, it's images, and loads it's download links.
0027  * - Opensearch for the search, if available.
0028  * - Should load full entries, if possible.
0029  * - Navigation feed entries can be selected.
0030  *
0031  * TODO:
0032  * - We need a better handling of non-free items (requires authentication).
0033  * - entry navigation links are not supported.
0034  * - pagination support (together with the navigation links)
0035  * - No Sorting
0036  *
0037  * Would-be-nice, but requires a lot of rewiring in knewstuff:
0038  * - We could get authenticated feeds going by using basic http authentiation(in spec), or have bearer token uris (oauth bearcaps).
0039  * - Autodiscovery or protocol based discovery of opds catalogs, this does not gel with the provider xml system used by knewstuff.
0040  *
0041  * @since 5.83
0042  */
0043 
0044 namespace KNSCore
0045 {
0046 class OPDSProviderPrivate;
0047 class OPDSProvider : public Provider
0048 {
0049     Q_OBJECT
0050 public:
0051     typedef QList<Provider *> List;
0052 
0053     OPDSProvider();
0054     ~OPDSProvider() override;
0055 
0056     // Unique ID, url of the feed.
0057     QString id() const override;
0058 
0059     // Name of the feed.
0060     QString name() const override;
0061 
0062     // Feed icon
0063     QUrl icon() const override;
0064 
0065     void loadEntries(const KNSCore::Provider::SearchRequest &request) override;
0066     void loadEntryDetails(const KNSCore::Entry &entry) override;
0067     void loadPayloadLink(const KNSCore::Entry &entry, int linkNumber) override;
0068 
0069     bool setProviderXML(const QDomElement &xmldata) override;
0070     bool isInitialized() const override;
0071     void setCachedEntries(const KNSCore::Entry::List &cachedEntries) override;
0072 
0073     const std::unique_ptr<OPDSProviderPrivate> d;
0074 
0075     Q_DISABLE_COPY(OPDSProvider)
0076 };
0077 
0078 }
0079 
0080 #endif // OPDSPROVIDER_H