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.
22 #include <kdedmodule.h>
26 namespace KIO
{ class Job
; }
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
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
49 Q_CLASSINFO("D-Bus Interface", "org.kde.FavIcon")
52 FavIconsModule(QObject
* parent
, const QList
<QVariant
>&);
53 virtual ~FavIconsModule();
55 public Q_SLOTS
: // dbus methods, called by the adaptor
57 * Looks up an icon name for a given URL. This function does not
58 * initiate any download. If no icon for the URL or its host has
59 * been downloaded yet, QString() is returned.
61 * @param url the URL for which the icon is queried
62 * @return the icon name suitable to pass to @ref KIconLoader or
63 * QString() if no icon for this URL was found.
65 QString
iconForUrl(const KUrl
&url
);
68 * Associates an icon with the given URL. If the icon was not
69 * downloaded before or the downloaded was too long ago, a
70 * download attempt will be started and the iconChanged() DBUS
71 * signal is emitted after the download finished successfully.
73 * @param url the URL which will be associated with the icon
74 * @param iconURL the URL of the icon to be downloaded
76 void setIconForUrl(const KUrl
&url
, const KUrl
&iconURL
);
78 * Downloads the icon for a given host if it was not downloaded before
79 * or the download was too long ago. If the download finishes
80 * successfully, the iconChanged() DBUS signal is emitted.
82 * @param url any URL on the host for which the icon is to be downloaded
84 void downloadHostIcon(const KUrl
&url
);
86 signals
: // DBUS signals
88 * Emitting once a new icon is available, for a host or url
90 void iconChanged(bool isHost
, QString hostOrURL
, QString iconName
);
92 * Progress info while downloading an icon
94 void infoMessage(QString iconURL
, QString msg
);
97 void startDownload(const QString
&, bool, const KUrl
&);
98 bool isIconOld(const QString
&);
101 void slotData(KIO::Job
*, const QByteArray
&);
102 void slotResult(KJob
*);
103 void slotInfoMessage(KJob
*, const QString
&);
107 struct FavIconsModulePrivate
*d
;