Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / lib / konq / favicons / favicons.h
blob2bf0a2a0587bc57109d864520e655e46ca36506c
1 /* This file is part of the KDE Project
2 Copyright (c) 2001 Malte Starostik <malte@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #ifndef _FAVICONS_H_
20 #define _FAVICONS_H_
22 #include <kdedmodule.h>
23 #include <kurl.h>
25 class KJob;
26 namespace KIO { class Job; }
28 /**
29 * KDED Module to handle shortcut icons ("favicons")
30 * FavIconsModule implements a KDED Module that handles the association of
31 * URLs and hosts with shortcut icons and the icons' downloads in a central
32 * place.
34 * After a successful download, the DBUS signal iconChanged() is emitted.
35 * It has the signature void iconChanged(bool, QString, QString);
36 * The first parameter is true if the icon is a "host" icon, that is it is
37 * the default icon for all URLs on the given host. In this case, the
38 * second parameter is a host name, otherwise the second parameter is the
39 * URL which is associated with the icon. The third parameter is the
40 * @ref KIconLoader friendly name of the downloaded icon, the same as
41 * @ref iconForUrl will from now on return for any matching URL.
43 * @short KDED Module for favicons
44 * @author Malte Starostik <malte@kde.org>
46 class FavIconsModule : public KDEDModule
48 Q_OBJECT
49 public:
50 FavIconsModule(QObject* parent, const QList<QVariant>&);
51 virtual ~FavIconsModule();
53 public Q_SLOTS: // dbus methods, called by the adaptor
54 /**
55 * Looks up an icon name for a given URL. This function does not
56 * initiate any download. If no icon for the URL or its host has
57 * been downloaded yet, QString() is returned.
59 * @param url the URL for which the icon is queried
60 * @return the icon name suitable to pass to @ref KIconLoader or
61 * QString() if no icon for this URL was found.
63 QString iconForUrl(const KUrl &url);
65 /**
66 * Associates an icon with the given URL. If the icon was not
67 * downloaded before or the downloaded was too long ago, a
68 * download attempt will be started and the iconChanged() DBUS
69 * signal is emitted after the download finished successfully.
71 * @param url the URL which will be associated with the icon
72 * @param iconURL the URL of the icon to be downloaded
74 void setIconForUrl(const KUrl &url, const KUrl &iconURL);
75 /**
76 * Downloads the icon for a given host if it was not downloaded before
77 * or the download was too long ago. If the download finishes
78 * successfully, the iconChanged() DBUS signal is emitted.
80 * @param url any URL on the host for which the icon is to be downloaded
82 void downloadHostIcon(const KUrl &url);
84 signals: // DBUS signals
85 /**
86 * Emitting once a new icon is available, for a host or url
88 void iconChanged(bool isHost, QString hostOrURL, QString iconName);
89 /**
90 * Progress info while downloading an icon
92 void infoMessage(QString iconURL, QString msg);
94 private:
95 void startDownload(const QString &, bool, const KUrl &);
96 QString simplifyURL(const KUrl &);
97 QString iconNameFromURL(const KUrl &);
98 bool isIconOld(const QString &);
100 private Q_SLOTS:
101 void slotData(KIO::Job *, const QByteArray &);
102 void slotResult(KJob *);
103 void slotInfoMessage(KJob *, const QString &);
104 void slotKill();
106 private:
107 struct FavIconsModulePrivate *d;
110 #endif
112 // vim: ts=4 sw=4 et