| 1 | /* |
| 2 | This file is part of KIO. |
| 3 | SPDX-FileCopyrightText: 2016 David Faure <faure@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL |
| 6 | */ |
| 7 | |
| 8 | #ifndef FAVICONSCACHE_P_H |
| 9 | #define FAVICONSCACHE_P_H |
| 10 | |
| 11 | #include <QObject> |
| 12 | |
| 13 | #include <memory> |
| 14 | |
| 15 | #include <kiocore_export.h> |
| 16 | |
| 17 | namespace KIO |
| 18 | { |
| 19 | class FavIconsCachePrivate; |
| 20 | |
| 21 | /*! |
| 22 | * \internal |
| 23 | * Singleton handling the cache (memory + disk) for favicons. |
| 24 | * Exported for KIOGui's FavIconsManager |
| 25 | */ |
| 26 | class KIOCORE_EXPORT FavIconsCache : public QObject |
| 27 | { |
| 28 | Q_OBJECT |
| 29 | |
| 30 | public: |
| 31 | static FavIconsCache *instance(); |
| 32 | |
| 33 | // Fast cache lookup, used by KIO::favIconForUrl |
| 34 | QString iconForUrl(const QUrl &url); |
| 35 | |
| 36 | // Look for a custom icon URL in the cache, otherwise assemble default host icon URL |
| 37 | QUrl iconUrlForUrl(const QUrl &url); |
| 38 | |
| 39 | // Remember association to a custom icon URL |
| 40 | void setIconForUrl(const QUrl &url, const QUrl &iconUrl); |
| 41 | |
| 42 | QString cachePathForIconUrl(const QUrl &iconUrl) const; |
| 43 | |
| 44 | void ensureCacheExists(); |
| 45 | |
| 46 | void addFailedDownload(const QUrl &url); |
| 47 | void removeFailedDownload(const QUrl &url); |
| 48 | bool isFailedDownload(const QUrl &url) const; |
| 49 | |
| 50 | Q_SIGNALS: |
| 51 | |
| 52 | private: |
| 53 | KIOCORE_NO_EXPORT FavIconsCache(); |
| 54 | KIOCORE_NO_EXPORT ~FavIconsCache() override; |
| 55 | std::unique_ptr<FavIconsCachePrivate> const d; |
| 56 | }; |
| 57 | |
| 58 | } |
| 59 | |
| 60 | #endif // FAVICONSCACHE_H |
| 61 | |