File indexing completed on 2024-04-21 05:50:21

0001 /* This file is part of the KDE project
0002    Copyright (C) 2003 Alexander Kellett <lypanov@kde.org>
0003 
0004    This program is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU General Public License as
0006    published by the Free Software Foundation; either version 2 of
0007    the License, or (at your option) version 3.
0008 
0009    This program is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012    GNU General Public License for more details.
0013 
0014    You should have received a copy of the GNU General Public License
0015    along with this program.  If not, see <http://www.gnu.org/licenses/>
0016 */
0017 
0018 #ifndef FAVICONUPDATER_H
0019 #define FAVICONUPDATER_H
0020 
0021 #include <KBookmark>
0022 
0023 #include <KIO/Job>
0024 #include <KParts/ReadOnlyPart>
0025 #include <QUrl>
0026 #include <kparts/part.h>
0027 
0028 class FavIconWebGrabber : public QObject
0029 {
0030     Q_OBJECT
0031 public:
0032     FavIconWebGrabber(KParts::ReadOnlyPart *part, const QUrl &url);
0033     ~FavIconWebGrabber() override
0034     {
0035     }
0036 
0037 Q_SIGNALS:
0038     void done(bool succeeded, const QString &errorString);
0039 
0040 private Q_SLOTS:
0041     void slotMimetype(KIO::Job *job, const QString &_type);
0042     void slotFinished(KJob *job);
0043     void slotCanceled(const QString &errorString);
0044     void slotCompleted();
0045 
0046 private:
0047     KParts::ReadOnlyPart *m_part;
0048     QUrl m_url;
0049 };
0050 
0051 class FavIconUpdater : public QObject
0052 {
0053     Q_OBJECT
0054 
0055 public:
0056     explicit FavIconUpdater(QObject *parent);
0057     ~FavIconUpdater() override;
0058     void downloadIcon(const KBookmark &bk);
0059     void downloadIconUsingWebBrowser(const KBookmark &bk, const QString &currentError);
0060 
0061 private Q_SLOTS:
0062     void setIconUrl(const QUrl &iconURL);
0063     void slotResult(KJob *job);
0064 
0065 Q_SIGNALS:
0066     void done(bool succeeded, const QString &error);
0067 
0068 private:
0069     KParts::ReadOnlyPart *m_part;
0070     FavIconWebGrabber *m_webGrabber;
0071     KBookmark m_bk;
0072     bool webupdate;
0073 };
0074 
0075 #endif