File indexing completed on 2024-04-14 03:52:51

0001 /*
0002     This file is part of KIO.
0003     SPDX-FileCopyrightText: 2016 David Faure <faure@kde.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #ifndef FAVICONSCACHE_P_H
0009 #define FAVICONSCACHE_P_H
0010 
0011 #include <QObject>
0012 
0013 #include <memory>
0014 
0015 #include <kiocore_export.h>
0016 
0017 namespace KIO
0018 {
0019 class FavIconsCachePrivate;
0020 
0021 /**
0022  * @internal
0023  * Singleton handling the cache (memory + disk) for favicons.
0024  * Exported for KIOGui's FavIconsManager
0025  */
0026 class KIOCORE_EXPORT FavIconsCache : public QObject
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     static FavIconsCache *instance();
0032 
0033     // Fast cache lookup, used by KIO::favIconForUrl
0034     QString iconForUrl(const QUrl &url);
0035 
0036     // Look for a custom icon URL in the cache, otherwise assemble default host icon URL
0037     QUrl iconUrlForUrl(const QUrl &url);
0038 
0039     // Remember association to a custom icon URL
0040     void setIconForUrl(const QUrl &url, const QUrl &iconUrl);
0041 
0042     QString cachePathForIconUrl(const QUrl &iconUrl) const;
0043 
0044     void ensureCacheExists();
0045 
0046     void addFailedDownload(const QUrl &url);
0047     void removeFailedDownload(const QUrl &url);
0048     bool isFailedDownload(const QUrl &url) const;
0049 
0050 Q_SIGNALS:
0051 
0052 private:
0053     KIOCORE_NO_EXPORT FavIconsCache();
0054     KIOCORE_NO_EXPORT ~FavIconsCache() override;
0055     std::unique_ptr<FavIconsCachePrivate> const d;
0056 };
0057 
0058 }
0059 
0060 #endif // FAVICONSCACHE_H