summaryrefslogtreecommitdiffstats
path: root/konqueror/remoteencodingplugin
diff options
context:
space:
mode:
Diffstat (limited to 'konqueror/remoteencodingplugin')
-rw-r--r--konqueror/remoteencodingplugin/Makefile.am13
-rw-r--r--konqueror/remoteencodingplugin/kremoteencodingplugin.cpp266
-rw-r--r--konqueror/remoteencodingplugin/kremoteencodingplugin.desktop135
-rw-r--r--konqueror/remoteencodingplugin/kremoteencodingplugin.h63
-rw-r--r--konqueror/remoteencodingplugin/kremoteencodingplugin.rc8
5 files changed, 485 insertions, 0 deletions
diff --git a/konqueror/remoteencodingplugin/Makefile.am b/konqueror/remoteencodingplugin/Makefile.am
new file mode 100644
index 000000000..e80195dcb
--- /dev/null
+++ b/konqueror/remoteencodingplugin/Makefile.am
@@ -0,0 +1,13 @@
+INCLUDES= -I$(top_srcdir)/libkonq $(all_includes)
+METASOURCES=AUTO
+
+kde_module_LTLIBRARIES = konq_remoteencoding.la
+konq_remoteencoding_la_SOURCES = kremoteencodingplugin.cpp
+konq_remoteencoding_la_LIBADD = $(top_builddir)/libkonq/libkonq.la
+konq_remoteencoding_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+iconviewdir = $(kde_datadir)/konqiconview/kpartplugins
+iconview_DATA = kremoteencodingplugin.rc kremoteencodingplugin.desktop
+
+listviewdir = $(kde_datadir)/konqlistview/kpartplugins
+listview_DATA = kremoteencodingplugin.rc kremoteencodingplugin.desktop
diff --git a/konqueror/remoteencodingplugin/kremoteencodingplugin.cpp b/konqueror/remoteencodingplugin/kremoteencodingplugin.cpp
new file mode 100644
index 000000000..b771b0a09
--- /dev/null
+++ b/konqueror/remoteencodingplugin/kremoteencodingplugin.cpp
@@ -0,0 +1,266 @@
+/*
+ Copyright (c) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License (LGPL) 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.
+*/
+
+/*
+ * This code is largely based on the UserAgent changer plugin (uachanger)
+ * Copyright © 2001 Dawit Alemayehu <adawit@kde.org>
+ * Distributed under the same terms.
+ */
+
+#include <kdebug.h>
+#include <kaction.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kconfig.h>
+#include <kcharsets.h>
+#include <kpopupmenu.h>
+#include <dcopclient.h>
+#include <kgenericfactory.h>
+#include <kprotocolmanager.h>
+#include <kprotocolinfo.h>
+#include <kio/slaveconfig.h>
+#include <konq_dirpart.h>
+#include <kparts/browserextension.h>
+
+#include "kremoteencodingplugin.h"
+
+#define DATA_KEY QString::fromLatin1("Charset")
+
+KRemoteEncodingPlugin::KRemoteEncodingPlugin(QObject * parent,
+ const char *name,
+ const QStringList &)
+ : KParts::Plugin(parent, name), m_loaded(false), m_idDefault(0)
+{
+ m_menu = new KActionMenu(i18n("Select Remote Charset"), "charset",
+ actionCollection(), "changeremoteencoding");
+ connect(m_menu->popupMenu(), SIGNAL(aboutToShow()),
+ this, SLOT(slotAboutToShow()));
+ m_menu->setEnabled(false);
+ m_menu->setDelayed(false);
+
+ m_part = dynamic_cast<KonqDirPart*>(parent);
+ if (m_part)
+ // if parent is not a KonqDirPart, our menu will never show
+ QObject::connect(m_part, SIGNAL(aboutToOpenURL()),
+ this, SLOT(slotAboutToOpenURL()));
+}
+
+KRemoteEncodingPlugin::~KRemoteEncodingPlugin()
+{
+}
+
+void
+KRemoteEncodingPlugin::slotReload()
+{
+ loadSettings();
+}
+
+void
+KRemoteEncodingPlugin::loadSettings()
+{
+ m_loaded = true;
+
+ m_encodingDescriptions = KGlobal::charsets()->descriptiveEncodingNames();
+
+ fillMenu();
+}
+
+void
+KRemoteEncodingPlugin::slotAboutToOpenURL()
+{
+ KURL oldURL = m_currentURL;
+ m_currentURL = m_part->url();
+
+ if (m_currentURL.protocol() != oldURL.protocol())
+ {
+ // This plugin works on ftp, fish, etc.
+ // everything whose type is T_FILESYSTEM except for local files
+ if (!m_currentURL.isLocalFile() &&
+ KProtocolInfo::outputType(m_currentURL) == KProtocolInfo::T_FILESYSTEM)
+ {
+ m_menu->setEnabled(true);
+ loadSettings();
+ }
+ else
+ m_menu->setEnabled(false);
+
+ return;
+ }
+
+ if (m_currentURL.host() != oldURL.host())
+ updateMenu();
+}
+
+void
+KRemoteEncodingPlugin::fillMenu()
+{
+ KPopupMenu *menu = m_menu->popupMenu();
+ menu->clear();
+
+ QStringList::ConstIterator it;
+ int count = 0;
+ for (it = m_encodingDescriptions.begin(); it != m_encodingDescriptions.end(); ++it)
+ menu->insertItem(*it, this, SLOT(slotItemSelected(int)), 0, ++count);
+ menu->insertSeparator();
+
+ menu->insertItem(i18n("Reload"), this, SLOT(slotReload()), 0, ++count);
+ menu->insertItem(i18n("Default"), this, SLOT(slotDefault()), 0, ++count);
+ m_idDefault = count;
+}
+
+void
+KRemoteEncodingPlugin::updateMenu()
+{
+ if (!m_loaded)
+ loadSettings();
+
+ // uncheck everything
+ for (unsigned i = 0; i < m_menu->popupMenu()->count(); i++)
+ m_menu->popupMenu()->setItemChecked(m_menu->popupMenu()->idAt(i), false);
+
+ QString charset = KIO::SlaveConfig::self()->configData(m_currentURL.protocol(), m_currentURL.host(),
+ DATA_KEY);
+ if (!charset.isEmpty())
+ {
+ int id = 1;
+ QStringList::Iterator it;
+ for (it = m_encodingDescriptions.begin(); it != m_encodingDescriptions.end(); ++it, ++id)
+ if ((*it).find(charset) != -1)
+ break;
+
+ kdDebug() << k_funcinfo << "URL=" << m_currentURL << " charset=" << charset << endl;
+
+ if (it == m_encodingDescriptions.end())
+ kdWarning() << k_funcinfo << "could not find entry for charset=" << charset << endl;
+ else
+ m_menu->popupMenu()->setItemChecked(id, true);
+ }
+ else
+ m_menu->popupMenu()->setItemChecked(m_idDefault, true);
+}
+
+void
+KRemoteEncodingPlugin::slotAboutToShow()
+{
+ if (!m_loaded)
+ loadSettings();
+ updateMenu();
+}
+
+void
+KRemoteEncodingPlugin::slotItemSelected(int id)
+{
+ KConfig config(("kio_" + m_currentURL.protocol() + "rc").latin1());
+ QString host = m_currentURL.host();
+
+ if (!m_menu->popupMenu()->isItemChecked(id))
+ {
+ QString charset = KGlobal::charsets()->encodingForName(m_encodingDescriptions[id - 1]);
+
+ config.setGroup(host);
+ config.writeEntry(DATA_KEY, charset);
+ config.sync();
+
+ // Update the io-slaves...
+ updateBrowser();
+ }
+}
+
+void
+KRemoteEncodingPlugin::slotDefault()
+{
+ // We have no choice but delete all higher domain level
+ // settings here since it affects what will be matched.
+ KConfig config(("kio_" + m_currentURL.protocol() + "rc").latin1());
+
+ QStringList partList = QStringList::split('.', m_currentURL.host(), false);
+ if (!partList.isEmpty())
+ {
+ partList.remove(partList.begin());
+
+ QStringList domains;
+ // Remove the exact name match...
+ domains << m_currentURL.host();
+
+ while (partList.count())
+ {
+ if (partList.count() == 2)
+ if (partList[0].length() <= 2 && partList[1].length() == 2)
+ break;
+
+ if (partList.count() == 1)
+ break;
+
+ domains << partList.join(".");
+ partList.remove(partList.begin());
+ }
+
+ for (QStringList::Iterator it = domains.begin(); it != domains.end();
+ it++)
+ {
+ kdDebug() << k_funcinfo << "Domain to remove: " << *it << endl;
+ if (config.hasGroup(*it))
+ config.deleteGroup(*it);
+ else if (config.hasKey(*it))
+ config.deleteEntry(*it);
+ }
+ }
+ config.sync();
+
+ // Update the io-slaves.
+ updateBrowser();
+}
+
+void
+KRemoteEncodingPlugin::updateBrowser()
+{
+ // Inform running io-slaves about the change...
+ DCOPClient *client = new DCOPClient();
+
+ if (!client->attach())
+ kdDebug() << "Can't connect with DCOP server." << endl;
+
+ QByteArray data;
+ QDataStream stream(data, IO_WriteOnly);
+ stream << QString::null;
+ // use call to make sure reparsing is done before reloading the url
+ QCStringList apps = client->registeredApplications();
+ for( QCStringList::ConstIterator it = apps.begin();
+ it != apps.end();
+ ++it )
+ {
+ QCString rtype;
+ QByteArray rdata;
+ client->call( *it, "KIO::Scheduler", "reparseSlaveConfiguration(QString)",
+ data, rtype, rdata);
+ }
+ delete client;
+
+ // Reload the page with the new charset
+ KParts::URLArgs args = m_part->extension()->urlArgs();
+ args.reload = true;
+ m_part->extension()->setURLArgs(args);
+ m_part->openURL(m_currentURL);
+}
+
+typedef KGenericFactory < KRemoteEncodingPlugin > KRemoteEncodingPluginFactory;
+K_EXPORT_COMPONENT_FACTORY(konq_remoteencoding,
+ KRemoteEncodingPluginFactory("kremoteencodingplugin"))
+#include "kremoteencodingplugin.moc"
diff --git a/konqueror/remoteencodingplugin/kremoteencodingplugin.desktop b/konqueror/remoteencodingplugin/kremoteencodingplugin.desktop
new file mode 100644
index 000000000..397654bef
--- /dev/null
+++ b/konqueror/remoteencodingplugin/kremoteencodingplugin.desktop
@@ -0,0 +1,135 @@
+[Desktop Entry]
+Type=Service
+X-KDE-PluginInfo-Author=Thiago Macieira
+X-KDE-PluginInfo-Email=thiago.macieira@kdemail.net
+X-KDE-PluginInfo-Name=kremoteencodingplugin
+X-KDE-PluginInfo-Version=3.4
+X-KDE-PluginInfo-Website=
+X-KDE-PluginInfo-Category=Tools
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=LGPL
+X-KDE-PluginInfo-EnabledByDefault=true
+X-KDE-ParentApp=konqueror
+Icon=charset
+Name=Remote Encoding Plugin
+Name[af]=Afgeleë Enkodering Inprop Module
+Name[ar]=قابس الترميز البعيد
+Name[be]=Утулка аддаленага знаказбору
+Name[bg]=Отдалечена кодова таблица
+Name[bn]=দূরবর্তী এনকোডিং প্লাগ-ইন
+Name[bs]=Dodatak za udaljeno kodiranje
+Name[ca]=Endollable de codificació remota
+Name[cs]=Modul vzdáleného kódování
+Name[csb]=Plugins daleczégò kòdowaniô
+Name[da]=Plugin for fjernkodning
+Name[de]=Modul für entfernte Kodierung
+Name[el]=Πρόσθετο απομακρυσμένης κωδικοποίησης
+Name[eo]=Fora kodoprezento Kromaĵo
+Name[es]=Complemento de codificación remota
+Name[et]=Võrgukodeeringu plugin
+Name[eu]=Urruneko kodeketa plugina
+Name[fa]=وصلۀ کدبندی دور
+Name[fi]=Etämerkinmuunnosliitännäinen
+Name[fr]=Module d'encodage distant
+Name[fy]=Eksterne-kodearringsplugin
+Name[gl]=Plugin de Codificación Remota
+Name[he]=תוסף קידוד מרוחק
+Name[hr]=Dodatak za udaljeno kodiranje
+Name[hu]=Távoli kódolás modul
+Name[is]=Fjarlægt kóðunaríforrit
+Name[it]=Plugin codifica remota
+Name[ja]=リモートエンコーディングプラグイン
+Name[ka]=კოდირების დაშორებული მოდული
+Name[kk]=Қашықтан баптау
+Name[km]=កម្មវិធី​ជំនួយ​ការ​អ៊ិនកូដ​ពី​ចម្ងាយ
+Name[ko]=원격 인코딩 플러그인
+Name[lt]=Nutolusių vietų koduotės priedas
+Name[mk]=Приклучок за оддалечено кодирање
+Name[ms]=Plugin Pengekodan Jauh
+Name[nb]=Eksterne kodingsprogramtillegg
+Name[nds]=Plugin för feern Koderen
+Name[ne]=टाढा सङ्केतन प्लगइन
+Name[nl]=Externe-coderingsplugin
+Name[nn]=Eksterne kodingsprogramtillegg
+Name[pa]=ਰਿਮੋਟ ਇੰਕੋਡਿੰਗ ਪਲੱਗਇਨ
+Name[pl]=Wtyczka zdalnego kodowania
+Name[pt]='Plugin' de Codificação Remota
+Name[pt_BR]=Plug-in de Codificação Remota
+Name[ro]=Plugin de încodare la distanță
+Name[ru]=Кодировка имён файлов на сервере
+Name[rw]=Icomeka Gusobeka bya Kure
+Name[se]=Gáiddus koden lassemoduvla
+Name[sk]=Modul pre šifrovanie
+Name[sl]=Vstavek Oddaljeno kodiranje
+Name[sr]=Прикључак за удаљено кодирање
+Name[sr@Latn]=Priključak za udaljeno kodiranje
+Name[sv]=Insticksprogram för fjärrkodning
+Name[ta]=தொலைதூர குறியீட்டு சொருகுப்பொருள்
+Name[th]=ปลั๊กอินเข้ารหัสทางไกล
+Name[tr]=Uzaktan Şifreleme Eklentisi
+Name[uk]=Втулок віддаленого кодування
+Name[vi]=Trình bổ sung Mã hoá Trên mạng
+Name[wa]=Tchôke-divins d' ecôdaedje å lon
+Name[zh_CN]=远程编码插件
+Name[zh_TW]=遠端編碼外掛程式
+Comment=Remote Encoding Plugin for Konqueror
+Comment[af]=Afgeë enkodering inprop module vir Konqueror
+Comment[ar]=قابس الترميز البعيد لِــ Konqueror
+Comment[be]=Утулка аддаленага знаказбору для Konqueror
+Comment[bg]=Приставка за отдалечена кодова таблица на браузъра
+Comment[bn]=কনকরার-এর জন্য দূরবর্তী এনকোডিং প্লাগ-ইন
+Comment[bs]=Dodatak za udaljeno kodiranje za Konqueror
+Comment[ca]=Endollable de codificació remota per a Konqueror
+Comment[cs]=Modul vzdáleného kódování pro Konqueror
+Comment[csb]=Plugins daleczégò kòdowaniô dlô Konquerora
+Comment[da]=Plugin for fjernkodning i Konqueror
+Comment[de]=Modul zum Einstellen der Kodierung einer entfernten Gegenstelle
+Comment[el]=Πρόσθετο απομακρυσμένης κωδικοποίησης για τον Konqueror
+Comment[eo]=Fora kodoprezento Kromaĵo por Konkeranto
+Comment[es]=Complemento de codificación remota para Konqueror
+Comment[et]=Konquerori võrgukodeeringu plugin
+Comment[eu]=Konquerorren urruneko kodeketa plugina
+Comment[fa]=وصلۀ کدبندی دور برای Konqueror
+Comment[fi]=Etämerkinmuunnosliitännäinen Konquerorille
+Comment[fr]=Module d'encodage distant pour Konqueror
+Comment[fy]=Eksterne-kodearringsplugin foar Konqueror
+Comment[gl]=Plugin de codificación remota para Konqueror
+Comment[he]=תוסף קידוד מרוחק עבור Konqueror
+Comment[hr]=Dodatak za udaljeno kodiranje namijenjen Konqueroru
+Comment[hu]=Távoli kódolás bővítőmodul a Konqueror böngészőhöz
+Comment[is]=Fjarlægt kóðunaríforrit fyrir Konqueror
+Comment[it]=Plugin per la codifica remota di Konqueror
+Comment[ja]=Konqueror 用のリモートエンコーディングプラグイン
+Comment[ka]=კოდირების დაშორებული მოდული Konqueror-ისთვის
+Comment[kk]=Қашықтан баптау модулі
+Comment[km]=កម្មវិធី​ជំនួយ​​ការ​អ៊ិនកូដ​សម្រាប់ Konqueror
+Comment[ko]=Konqueror 원격 인코딩 플러그인
+Comment[lt]=Nutolusių vietų koduotės Konqueror priedas
+Comment[mk]=Приклучок за оддалечено кодирање за Konqueror
+Comment[ms]=Plugin Pengekodan Jauh untuk Konqueror
+Comment[nb]=Eksterne kodingsprogramtillegg for Konqueror
+Comment[nds]=Konqueror-Plugin för feern Koderen
+Comment[ne]=कन्क्वेररका लागि टाढा सङ्केतन प्लगइन
+Comment[nl]=Externe-coderingsplugin voor Konqueror
+Comment[nn]=Eksterne kodingsprogramtillegg for Konqueror
+Comment[pa]=ਕੋਨਕਿਉਰੋਰ ਲਈ ਰਿਮੋਟ ਇੰਕੋਡਿੰਗ ਪਲੱਗਇਨ
+Comment[pl]=Wtyczka zdalnego kodowania dla Konquerora
+Comment[pt]=Um 'Plugin' de Codificação Remota para o Konqueror
+Comment[pt_BR]=Plug-in de Codificação Remota para o Konqueror
+Comment[ro]=Plugin de încodare la distanță pentru Konqueror
+Comment[ru]=Выбор кодировки для файлов на сервере
+Comment[rw]=Icomeka Gusobeka rya Kure rijyanye na Konqueror
+Comment[sk]=Modul pre šifrovanie pre Konqueror
+Comment[sl]=Vstavek Oddaljeno kodiranje za Konqueror
+Comment[sr]=Прикључак за удаљено кодирање за Konqueror
+Comment[sr@Latn]=Priključak za udaljeno kodiranje za Konqueror
+Comment[sv]=Insticksprogram för fjärrkodning i Konqueror
+Comment[ta]=கான்கொரர்க்கான தொலைதூர குறியீட்டு சொருகுப்பொருள்
+Comment[th]=ปลั้กอินเข้ารหัสทางไกลสำหรับคอนเควอร์เรอร์
+Comment[tr]=Konqueror için uzaktan şifreleme eklentisi
+Comment[tt]=Konqueror öçen Remote Encoding Plugin
+Comment[uk]=Втулок віддаленого кодування для Konqueror
+Comment[vi]=Trình bổ sung Mã hoá Trên mạng cho Konqueror
+Comment[wa]=Tchôke-divins d' ecôdaedje å lon po Konqueror
+Comment[zh_CN]=Konqueror 的远程编码插件
+Comment[zh_TW]=Konqueror 的編碼外掛程式
diff --git a/konqueror/remoteencodingplugin/kremoteencodingplugin.h b/konqueror/remoteencodingplugin/kremoteencodingplugin.h
new file mode 100644
index 000000000..85c77efa3
--- /dev/null
+++ b/konqueror/remoteencodingplugin/kremoteencodingplugin.h
@@ -0,0 +1,63 @@
+/*
+ Copyright (c) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License (LGPL) 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.
+*/
+
+#ifndef REMOTEENCODING_PLUGIN_H
+#define REMOTEENCODING_PLUGIN_H
+
+#include <qstringlist.h>
+#include <kurl.h>
+#include <klibloader.h>
+#include <kparts/plugin.h>
+
+class KActionMenu;
+class KConfig;
+class KonqDirPart;
+
+class KRemoteEncodingPlugin: public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ KRemoteEncodingPlugin(QObject * parent, const char *name,
+ const QStringList &);
+ ~KRemoteEncodingPlugin();
+
+protected slots:
+ void slotAboutToOpenURL();
+ void slotAboutToShow();
+ void slotItemSelected(int);
+ void slotReload();
+ void slotDefault();
+
+private:
+ void updateBrowser();
+ void loadSettings();
+ void fillMenu();
+ void updateMenu();
+
+ KonqDirPart *m_part;
+ KActionMenu *m_menu;
+ QStringList m_encodingDescriptions;
+ KURL m_currentURL;
+
+ bool m_loaded;
+ int m_idDefault;
+};
+
+#endif
diff --git a/konqueror/remoteencodingplugin/kremoteencodingplugin.rc b/konqueror/remoteencodingplugin/kremoteencodingplugin.rc
new file mode 100644
index 000000000..29a283b4a
--- /dev/null
+++ b/konqueror/remoteencodingplugin/kremoteencodingplugin.rc
@@ -0,0 +1,8 @@
+<!DOCTYPE kpartplugin>
+<kpartplugin library="konq_remoteencoding">
+<MenuBar>
+ <Menu name="tools"><text>&amp;Tools</text>
+ <Action name="changeremoteencoding"/>
+ </Menu>
+</MenuBar>
+</kpartplugin>