summaryrefslogtreecommitdiffstats
path: root/libkonq/favicons
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /libkonq/favicons
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkonq/favicons')
-rw-r--r--libkonq/favicons/Makefile.am15
-rw-r--r--libkonq/favicons/favicons.cpp275
-rw-r--r--libkonq/favicons/favicons.desktop148
-rw-r--r--libkonq/favicons/favicons.h105
-rw-r--r--libkonq/favicons/favicons.upd3
-rwxr-xr-xlibkonq/favicons/move_favicons.sh41
6 files changed, 587 insertions, 0 deletions
diff --git a/libkonq/favicons/Makefile.am b/libkonq/favicons/Makefile.am
new file mode 100644
index 000000000..a53c7faf1
--- /dev/null
+++ b/libkonq/favicons/Makefile.am
@@ -0,0 +1,15 @@
+kde_module_LTLIBRARIES = kded_favicons.la
+
+INCLUDES = $(all_includes)
+kded_favicons_la_SOURCES = favicons.cpp favicons.skel
+kded_favicons_la_LDFLAGS = $(all_libraries) -module -avoid-version
+kded_favicons_la_LIBADD = $(LIB_KSYCOCA)
+
+METASOURCES = AUTO
+
+servicesdir = $(kde_servicesdir)/kded
+services_DATA = favicons.desktop
+
+update_DATA = favicons.upd
+update_SCRIPTS = move_favicons.sh
+updatedir = $(kde_datadir)/kconf_update
diff --git a/libkonq/favicons/favicons.cpp b/libkonq/favicons/favicons.cpp
new file mode 100644
index 000000000..9419b4b03
--- /dev/null
+++ b/libkonq/favicons/favicons.cpp
@@ -0,0 +1,275 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Malte Starostik <malte@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <string.h>
+#include <time.h>
+
+#include <qbuffer.h>
+#include <qfile.h>
+#include <qcache.h>
+#include <qimage.h>
+#include <qtimer.h>
+
+#include <kdatastream.h> // DO NOT REMOVE, otherwise bool marshalling breaks
+#include <kicontheme.h>
+#include <kimageio.h>
+#include <ksimpleconfig.h>
+#include <kstandarddirs.h>
+#include <kio/job.h>
+
+#include "favicons.moc"
+
+struct FaviconsModulePrivate
+{
+ virtual ~FaviconsModulePrivate() { delete config; }
+
+ struct DownloadInfo
+ {
+ QString hostOrURL;
+ bool isHost;
+ QByteArray iconData;
+ };
+ QMap<KIO::Job *, DownloadInfo> downloads;
+ QStringList failedDownloads;
+ KSimpleConfig *config;
+ QPtrList<KIO::Job> killJobs;
+ KIO::MetaData metaData;
+ QString faviconsDir;
+ QCache<QString> faviconsCache;
+};
+
+FaviconsModule::FaviconsModule(const QCString &obj)
+ : KDEDModule(obj)
+{
+ // create our favicons folder so that KIconLoader knows about it
+ d = new FaviconsModulePrivate;
+ d->faviconsDir = KGlobal::dirs()->saveLocation( "cache", "favicons/" );
+ d->faviconsDir.truncate(d->faviconsDir.length()-9); // Strip off "favicons/"
+ d->metaData.insert("ssl_no_client_cert", "TRUE");
+ d->metaData.insert("ssl_militant", "TRUE");
+ d->metaData.insert("UseCache", "false");
+ d->metaData.insert("cookies", "none");
+ d->metaData.insert("no-auth", "true");
+ d->config = new KSimpleConfig(locateLocal("data", "konqueror/faviconrc"));
+ d->killJobs.setAutoDelete(true);
+ d->faviconsCache.setAutoDelete(true);
+}
+
+FaviconsModule::~FaviconsModule()
+{
+ delete d;
+}
+
+QString removeSlash(QString result)
+{
+ for (unsigned int i = result.length() - 1; i > 0; --i)
+ if (result[i] != '/')
+ {
+ result.truncate(i + 1);
+ break;
+ }
+
+ return result;
+}
+
+
+QString FaviconsModule::iconForURL(const KURL &url)
+{
+ if (url.host().isEmpty())
+ return QString::null;
+
+ QString icon;
+ QString simplifiedURL = simplifyURL(url);
+
+ QString *iconURL = d->faviconsCache.find( removeSlash(simplifiedURL) );
+ if (iconURL)
+ icon = *iconURL;
+ else
+ icon = d->config->readEntry( removeSlash(simplifiedURL) );
+
+ if (!icon.isEmpty())
+ icon = iconNameFromURL(KURL( icon ));
+ else
+ icon = url.host();
+
+ icon = "favicons/" + icon;
+
+ if (QFile::exists(d->faviconsDir+icon+".png"))
+ return icon;
+
+ return QString::null;
+}
+
+QString FaviconsModule::simplifyURL(const KURL &url)
+{
+ // splat any = in the URL so it can be safely used as a config key
+ QString result = url.host() + url.path();
+ for (unsigned int i = 0; i < result.length(); ++i)
+ if (result[i] == '=')
+ result[i] = '_';
+ return result;
+}
+
+QString FaviconsModule::iconNameFromURL(const KURL &iconURL)
+{
+ if (iconURL.path() == "/favicon.ico")
+ return iconURL.host();
+
+ QString result = simplifyURL(iconURL);
+ // splat / so it can be safely used as a file name
+ for (unsigned int i = 0; i < result.length(); ++i)
+ if (result[i] == '/')
+ result[i] = '_';
+
+ QString ext = result.right(4);
+ if (ext == ".ico" || ext == ".png" || ext == ".xpm")
+ result.remove(result.length() - 4, 4);
+
+ return result;
+}
+
+bool FaviconsModule::isIconOld(const QString &icon)
+{
+ struct stat st;
+ if (stat(QFile::encodeName(icon), &st) != 0)
+ return true; // Trigger a new download on error
+
+ return (time(0) - st.st_mtime) > 604800; // arbitrary value (one week)
+}
+
+void FaviconsModule::setIconForURL(const KURL &url, const KURL &iconURL)
+{
+ QString simplifiedURL = simplifyURL(url);
+
+ d->faviconsCache.insert(removeSlash(simplifiedURL), new QString(iconURL.url()) );
+
+ QString iconName = "favicons/" + iconNameFromURL(iconURL);
+ QString iconFile = d->faviconsDir + iconName + ".png";
+
+ if (!isIconOld(iconFile)) {
+ emit iconChanged(false, simplifiedURL, iconName);
+ return;
+ }
+
+ startDownload(simplifiedURL, false, iconURL);
+}
+
+void FaviconsModule::downloadHostIcon(const KURL &url)
+{
+ QString iconFile = d->faviconsDir + "favicons/" + url.host() + ".png";
+ if (!isIconOld(iconFile))
+ return;
+
+ startDownload(url.host(), true, KURL(url, "/favicon.ico"));
+}
+
+void FaviconsModule::startDownload(const QString &hostOrURL, bool isHost, const KURL &iconURL)
+{
+ if (d->failedDownloads.contains(iconURL.url()))
+ return;
+
+ KIO::Job *job = KIO::get(iconURL, false, false);
+ job->addMetaData(d->metaData);
+ connect(job, SIGNAL(data(KIO::Job *, const QByteArray &)), SLOT(slotData(KIO::Job *, const QByteArray &)));
+ connect(job, SIGNAL(result(KIO::Job *)), SLOT(slotResult(KIO::Job *)));
+ connect(job, SIGNAL(infoMessage(KIO::Job *, const QString &)), SLOT(slotInfoMessage(KIO::Job *, const QString &)));
+ FaviconsModulePrivate::DownloadInfo download;
+ download.hostOrURL = hostOrURL;
+ download.isHost = isHost;
+ d->downloads.insert(job, download);
+}
+
+void FaviconsModule::slotData(KIO::Job *job, const QByteArray &data)
+{
+ FaviconsModulePrivate::DownloadInfo &download = d->downloads[job];
+ unsigned int oldSize = download.iconData.size();
+ if (oldSize > 0x10000)
+ {
+ d->killJobs.append(job);
+ QTimer::singleShot(0, this, SLOT(slotKill()));
+ }
+ download.iconData.resize(oldSize + data.size());
+ memcpy(download.iconData.data() + oldSize, data.data(), data.size());
+}
+
+void FaviconsModule::slotResult(KIO::Job *job)
+{
+ FaviconsModulePrivate::DownloadInfo download = d->downloads[job];
+ d->downloads.remove(job);
+ KURL iconURL = static_cast<KIO::TransferJob *>(job)->url();
+ QString iconName;
+ if (!job->error())
+ {
+ QBuffer buffer(download.iconData);
+ buffer.open(IO_ReadOnly);
+ QImageIO io;
+ io.setIODevice(&buffer);
+ io.setParameters("size=16");
+ // Check here too, the job might have had no error, but the downloaded
+ // file contains just a 404 message sent with a 200 status.
+ // microsoft.com does that... (malte)
+ if (io.read())
+ {
+ // Some sites have nasty 32x32 icons, according to the MS docs
+ // IE ignores them, well, we scale them, otherwise the location
+ // combo / menu will look quite ugly
+ if (io.image().width() != KIcon::SizeSmall || io.image().height() != KIcon::SizeSmall)
+ io.setImage(io.image().smoothScale(KIcon::SizeSmall, KIcon::SizeSmall));
+
+ if (download.isHost)
+ iconName = download.hostOrURL;
+ else
+ iconName = iconNameFromURL(iconURL);
+
+ iconName = "favicons/" + iconName;
+
+ io.setIODevice(0);
+ io.setFileName(d->faviconsDir + iconName + ".png");
+ io.setFormat("PNG");
+ if (!io.write())
+ iconName = QString::null;
+ else if (!download.isHost)
+ d->config->writeEntry( removeSlash(download.hostOrURL), iconURL.url());
+ }
+ }
+ if (iconName.isEmpty())
+ d->failedDownloads.append(iconURL.url());
+
+ emit iconChanged(download.isHost, download.hostOrURL, iconName);
+}
+
+void FaviconsModule::slotInfoMessage(KIO::Job *job, const QString &msg)
+{
+ emit infoMessage(static_cast<KIO::TransferJob *>( job )->url(), msg);
+}
+
+void FaviconsModule::slotKill()
+{
+ d->killJobs.clear();
+}
+
+extern "C" {
+ KDE_EXPORT KDEDModule *create_favicons(const QCString &obj)
+ {
+ KImageIO::registerFormats();
+ return new FaviconsModule(obj);
+ }
+}
+
+// vim: ts=4 sw=4 et
diff --git a/libkonq/favicons/favicons.desktop b/libkonq/favicons/favicons.desktop
new file mode 100644
index 000000000..7a7042057
--- /dev/null
+++ b/libkonq/favicons/favicons.desktop
@@ -0,0 +1,148 @@
+[Desktop Entry]
+Type=Service
+Name=KDED Favicon Module
+Name[af]=Kded Favicon Module
+Name[ar]=وحدة KDED لأيقونة الموقع
+Name[az]=KDED Favikon Modulu
+Name[be]=Модуль любімай значкі KDED
+Name[bn]=KDED ফ্যাভ-আইকন মডিউল
+Name[br]=Mollad Favicon evit KDED
+Name[bs]=KDED Favicon modul
+Name[ca]=Mòdul KDED per a favicon
+Name[cs]=Modul KDEDu Favicon
+Name[csb]=Ikònczi serwerów
+Name[cy]=Modiwl KDED Favicon
+Name[da]=KDED Favicon-modul
+Name[de]=Webseitensymbol-Verwaltung
+Name[el]=KDED άρθρωμα Favicon
+Name[eo]=Modulo por interretaj piktogramoj
+Name[es]=Módulo Favicon de KDED
+Name[et]=KDED favicon moodul
+Name[eu]=KDED Favicon modulua
+Name[fa]=پیمانۀ شمایل پسندان KDED
+Name[fi]=KDED-sivustokuvakemoduuli
+Name[fr]=Icône préférée
+Name[gl]=Módulo de Faviconas de KDED
+Name[he]=מודול סמלים מועדפים של KDED
+Name[hi]=केडीईडी फेविकॉन मॉड्यूल
+Name[hr]=KDED Favicon modul
+Name[hu]=KDED favicon-kezelő
+Name[id]=Modul Favicon KDE
+Name[is]=KDED Favicon íhlutur
+Name[it]=Modulo Favicon di KDED
+Name[ja]=KDED Favicon モジュール
+Name[ka]=KDED Favicon მოდული
+Name[kk]=KDED сайт белгішілер модулі
+Name[km]=ម៉ូឌុល KDED Favicon
+Name[ko]=KDED 파비콘 모듈
+Name[lo]=ໂມດລູໄອຄອນ KDED
+Name[lt]=KDED favicon modulis
+Name[lv]=KDED Favikon Modulis
+Name[mk]=KDED Favicon Модул
+Name[mn]=Favicon-Модул
+Name[ms]=Modul KDED Favicon
+Name[mt]=Modulu "favicon" KDED
+Name[nb]=KDED favicon-modul
+Name[nds]=KDED-Moduul för Nettsiet-Lüttbiller
+Name[ne]=KDED फेभिकन मोड्युल
+Name[nn]=KDED favicon-modul
+Name[nso]=Seripa sa Favicon ya KDE
+Name[pa]=KDED ਫਾਵੀਕੋਨ ਮੋਡੁਲੀ
+Name[pl]=Ikony serwerów
+Name[pt]=Módulo Favicon do KDED
+Name[pt_BR]=Módulo Favicon do KDE
+Name[ro]=Module favicon KDED
+Name[ru]=Служба значков
+Name[rw]=Igice KDED Favicon
+Name[se]=KDED favicon-moduvla
+Name[sk]=Modul KDED Favicon
+Name[sl]=Modul KDED za favicon
+Name[sr]=Favicon модул, KDED
+Name[sr@Latn]=Favicon modul, KDED
+Name[sv]=KDED-favoritikonmodul
+Name[ta]=KDED பெவிகான் பகுதி
+Name[tg]=Бахши пиктограммаи KDED
+Name[th]=โมดูลไอคอนเว็บของ KDED
+Name[tr]=KDE Favicon Modülü
+Name[tt]=KDED İkon Module
+Name[uk]=Модуль KDED Favicon
+Name[uz]=KDED Favicon moduli
+Name[uz@cyrillic]=KDED Favicon модули
+Name[ven]=Modulu wa KDED wa Favikhono
+Name[vi]=Mô đun KDED Favicon
+Name[wa]=Module imådjetes KDED
+Name[xh]=KDED Isichatshulwa se Favicon
+Name[zh_CN]=KDED 收藏图标模块
+Name[zh_TW]=KDED Favicon 測試模組
+Name[zu]=Ingxenye ye-Favicon ye-KDED
+Comment=Shortcut icon support
+Comment[af]=Kortpad ikoon ondersteuning
+Comment[az]=Qısa yol timsal dəstəyi
+Comment[be]=Падтрымка значак скаротаў
+Comment[bg]=Поддръжка на препратки с икони
+Comment[bn]=শর্টকাট আইকন সাপোর্ট
+Comment[bs]=Podrška za ikone sa prečicama
+Comment[ca]=Suport de dreceres d'icona
+Comment[cs]=Podpora ikon zkratek
+Comment[csb]=Òbsłużënk ikònów serwerów
+Comment[da]=Genvejsikonstøtte
+Comment[de]=Unterstützung für Webseitensymbole ("Favicons") in KDE
+Comment[el]=υποστήριξη εικονιδίων Συντόμευσης
+Comment[eo]=Subteno por klavkombinaj piktogramoj
+Comment[es]=Soporte para iconos de acceso directo
+Comment[et]=Kiirkorralduse ikooni toetus
+Comment[eu]=Lasterbide-laukitxoen euskarria
+Comment[fa]=پشتیبانی شمایل میان‌بر
+Comment[fi]=Sivustojen kuvakkeet
+Comment[fr]=Gestion d'icône de raccourci
+Comment[fy]=Stipe foar byldkaikes
+Comment[gl]=Soporte para Icona de Atallo Directo
+Comment[he]=תמיכה בסמלי קיצור דרך
+Comment[hi]=शॉर्टकट प्रतीक आधार
+Comment[hr]=Podrška za ikonske prečace
+Comment[hu]=Website-ikonok támogatása
+Comment[is]=Stuðningur fyrir flýtitáknmyndir
+Comment[it]=Supporto icone scorciatoia
+Comment[ja]=ショートカットアイコンサポート
+Comment[ka]=მალმხმობი ხატულების მხარდაჭერა
+Comment[kk]=Жарлықтарды қолдау
+Comment[km]=ការ​គាំទ្រ​រូបតំណាង​ផ្លូវកាត់
+Comment[ko]=단축 아이콘 지원
+Comment[lt]=Nuorodų ženkliukų palaikymas
+Comment[lv]=Īsinājumikonu atbalsts
+Comment[mk]=Поддршка за икони за кратенки
+Comment[ms]=Sokongan ikon pintasan
+Comment[mt]=Sapport għall-ikoni "shortcut"
+Comment[nb]=Støtte for snarveisikoner
+Comment[nds]=Ünnerstütten för Link-Lüttbiller
+Comment[ne]=सर्टकट प्रतिमा समर्थन
+Comment[nl]=Ondersteuning voor pictogrammen
+Comment[nn]=Støtte for snarvegikon
+Comment[pa]=ਸ਼ਾਰਟਕੱਟ ਆਈਕਾਨ ਸਹਿਯੋਗ
+Comment[pl]=Obsługa ikon serwerów
+Comment[pt]=Suporte de ícone de atalho
+Comment[pt_BR]=Suporte ao ícone de atalho
+Comment[ro]=Suport pentru iconițe accelerator
+Comment[ru]=Показ настраиваемых значков в KDE
+Comment[rw]=Iyemera ry'Ihinanzira ry'Agashushondanga
+Comment[se]=Govašlávkestagaid doarjja
+Comment[sk]=Podpora ikon skratiek
+Comment[sl]=Podpora ikonam za bližnjice
+Comment[sr]=Подршка за икону пречице
+Comment[sr@Latn]=Podrška za ikonu prečice
+Comment[sv]=Stöd för genvägsikon
+Comment[ta]=குறுக்கு வழி சின்ன ஆதரவு
+Comment[th]=สนับสนุนไอคอนทางลัด
+Comment[tr]=Kısayol simge desteği
+Comment[tt]=KDE'da ikon kürsätü
+Comment[uk]=Підтримка скорочень піктограм
+Comment[vi]=Hỗ trợ biểu tượng giúp truy cập nhanh
+Comment[wa]=Sopoirt imådjetes rascourtis
+Comment[zh_CN]=快捷图标支持
+Comment[zh_TW]=捷徑圖示支援
+ServiceTypes=KDEDModule
+X-KDE-ModuleType=Library
+X-KDE-Library=favicons
+X-KDE-FactoryName=favicons
+X-KDE-Kded-autoload=false
+X-KDE-Kded-load-on-demand=true
diff --git a/libkonq/favicons/favicons.h b/libkonq/favicons/favicons.h
new file mode 100644
index 000000000..021ea3b9b
--- /dev/null
+++ b/libkonq/favicons/favicons.h
@@ -0,0 +1,105 @@
+/* This file is part of the KDE Project
+ Copyright (c) 2001 Malte Starostik <malte@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _FAVICONS_H_
+#define _FAVICONS_H_
+
+#include <kdedmodule.h>
+#include <kurl.h>
+
+namespace KIO { class Job; }
+
+/**
+ * KDED Module to handle shortcut icons ("favicons")
+ * FaviconsModule implements a KDED Module that handles the association of
+ * URLs and hosts with shortcut icons and the icons' downloads in a central
+ * place.
+ *
+ * After a successful download, the DCOP signal iconChanged() is emitted.
+ * It has the signature void iconChanged(bool, QString, QString);
+ * The first parameter is true if the icon is a "host" icon, that is it is
+ * the default icon for all URLs on the given host. In this case, the
+ * second parameter is a host name, otherwise the second parameter is the
+ * URL which is associated with the icon. The third parameter is the
+ * @ref KIconLoader friendly name of the downloaded icon, the same as
+ * @ref iconForURL will from now on return for any matching URL.
+ *
+ * @short KDED Module for favicons
+ * @author Malte Starostik <malte@kde.org>
+ */
+class FaviconsModule : public KDEDModule
+{
+ Q_OBJECT
+ K_DCOP
+public:
+ FaviconsModule(const QCString &obj);
+ virtual ~FaviconsModule();
+
+k_dcop:
+ /**
+ * Looks up an icon name for a given URL. This function does not
+ * initiate any download. If no icon for the URL or its host has
+ * been downloaded yet, QString::null is returned.
+ *
+ * @param url the URL for which the icon is queried
+ * @return the icon name suitable to pass to @ref KIconLoader or
+ * QString::null if no icon for this URL was found.
+ */
+ QString iconForURL(const KURL &url);
+ /**
+ * Assiciates an icon with the given URL. If the icon was not
+ * downloaded before or the downloaded was too long ago, a
+ * download attempt will be started and the iconChanged() DCOP
+ * signal is emitted after the download finished successfully.
+ *
+ * @param url the URL which will be associated with the icon
+ * @param iconURL the URL of the icon to be downloaded
+ */
+ ASYNC setIconForURL(const KURL &url, const KURL &iconURL);
+ /**
+ * Downloads the icon for a given host if it was not downloaded before
+ * or the download was too long ago. If the download finishes
+ * successfully, the iconChanged() DCOP signal is emitted.
+ *
+ * @param url any URL on the host for which the icon is to be downloaded
+ */
+ ASYNC downloadHostIcon(const KURL &url);
+
+k_dcop_signals:
+ void iconChanged(bool isHost, QString hostOrURL, QString iconName);
+ void infoMessage(KURL iconURL, QString msg);
+
+private:
+ void startDownload(const QString &, bool, const KURL &);
+ QString simplifyURL(const KURL &);
+ QString iconNameFromURL(const KURL &);
+ bool isIconOld(const QString &);
+
+private slots:
+ void slotData(KIO::Job *, const QByteArray &);
+ void slotResult(KIO::Job *);
+ void slotInfoMessage(KIO::Job *, const QString &);
+ void slotKill();
+
+private:
+ struct FaviconsModulePrivate *d;
+};
+
+#endif
+
+// vim: ts=4 sw=4 et
diff --git a/libkonq/favicons/favicons.upd b/libkonq/favicons/favicons.upd
new file mode 100644
index 000000000..b5f693b3b
--- /dev/null
+++ b/libkonq/favicons/favicons.upd
@@ -0,0 +1,3 @@
+# Move favicons from $KDEHOME/share/icons and $KDEHOME/share/cache to $KDEHOME/cache-$HOST
+Id=kde3_2
+Script=move_favicons.sh,sh
diff --git a/libkonq/favicons/move_favicons.sh b/libkonq/favicons/move_favicons.sh
new file mode 100755
index 000000000..a06d7d2bd
--- /dev/null
+++ b/libkonq/favicons/move_favicons.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+prefix=$(kde-config --localprefix)
+source1="$prefix/share/icons/favicons"
+source2="$prefix/share/cache/favicons"
+dest="$(kde-config --path cache)/favicons"
+
+if [ -n "$prefix" -a -d "$source1" ]; then
+ while [ ! -d "$dest" ]; do
+ dir="$dest"
+ while [ ! -d `dirname "$dir"` ]; do
+ dir=`dirname "$dir"`
+ done
+ mkdir "$dir" || exit 1
+ done
+
+ icons=`ls "$source1" 2>/dev/null`
+ if [ -n "$icons" ]; then
+ for i in $icons; do
+ mv -f "$source1/$i" "$dest/$i"
+ done
+ fi
+ rmdir "$source1"
+fi
+if [ -n "$prefix" -a -d "$source2" ]; then
+ while [ ! -d "$dest" ]; do
+ dir="$dest"
+ while [ ! -d `dirname "$dir"` ]; do
+ dir=`dirname "$dir"`
+ done
+ mkdir "$dir" || exit 1
+ done
+
+ icons=`ls "$source2" 2>/dev/null`
+ if [ -n "$icons" ]; then
+ for i in $icons; do
+ mv -f "$source2/$i" "$dest/$i"
+ done
+ fi
+ rmdir "$source2"
+fi