summaryrefslogtreecommitdiffstats
path: root/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3
diff options
context:
space:
mode:
Diffstat (limited to 'kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3')
-rw-r--r--kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/Makefile.am14
-rw-r--r--kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportfz3plugin.cpp166
-rw-r--r--kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportfz3plugin.h82
-rw-r--r--kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportplugin_filezilla3.desktop38
4 files changed, 300 insertions, 0 deletions
diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/Makefile.am b/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/Makefile.am
new file mode 100644
index 0000000..737df95
--- /dev/null
+++ b/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/Makefile.am
@@ -0,0 +1,14 @@
+INCLUDES = -I$(srcdir)/../../../interfaces \
+ $(all_includes)
+METASOURCES = AUTO
+
+kde_module_LTLIBRARIES = kftpimportplugin_filezilla3.la
+kftpimportplugin_filezilla3_la_SOURCES = kftpimportfz3plugin.cpp
+kftpimportplugin_filezilla3_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KPARTS) ../../../interfaces/libkftpinterfaces.la
+kftpimportplugin_filezilla3_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+
+kde_services_DATA = kftpimportplugin_filezilla3.desktop
+noinst_HEADERS = kftpimportfz3plugin.h
+
+pluginsdir = $(kde_datadir)/kftpimportplugin_filezilla3
+
diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportfz3plugin.cpp b/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportfz3plugin.cpp
new file mode 100644
index 0000000..0928c79
--- /dev/null
+++ b/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportfz3plugin.cpp
@@ -0,0 +1,166 @@
+/*
+ * This file is part of the KFTPGrabber project
+ *
+ * Copyright (C) 2004 by the KFTPGrabber developers
+ * Copyright (C) 2004 Jernej Kos <kostko@jweb-network.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and
+ * NON-INFRINGEMENT. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * In addition, as a special exception, the copyright holders give
+ * permission to link the code of portions of this program with the
+ * OpenSSL library under certain conditions as described in each
+ * individual source file, and distribute linked combinations
+ * including the two.
+ * You must obey the GNU General Public License in all respects
+ * for all of the code used other than OpenSSL. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you
+ * do not wish to do so, delete this exception statement from your
+ * version. If you delete this exception statement from all source
+ * files in the program, then also delete it here.
+ */
+
+#include "kftpimportfz3plugin.h"
+
+#include <qdir.h>
+#include <qfile.h>
+
+#include <kgenericfactory.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <kmdcodec.h>
+
+K_EXPORT_COMPONENT_FACTORY(kftpimportplugin_filezilla3,
+ KGenericFactory<KFTPImportFz3Plugin>("kftpimportplugin_filezilla3"))
+
+KFTPImportFz3Plugin::KFTPImportFz3Plugin(QObject *parent, const char *name, const QStringList&)
+ : KFTPBookmarkImportPlugin(parent, name)
+{
+ KGlobal::locale()->insertCatalogue("kftpgrabber");
+}
+
+QDomDocument KFTPImportFz3Plugin::getImportedXml()
+{
+ return m_domDocument;
+}
+
+void KFTPImportFz3Plugin::import(const QString &fileName)
+{
+ m_domDocument.setContent(QString("<category name=\"%1\"/>").arg(i18n("FileZilla 3 import")));
+
+ QFile file(fileName);
+ if (!file.open(IO_ReadOnly)) {
+ emit progress(100);
+ return;
+ }
+
+ m_workDocument.setContent(&file);
+ file.close();
+
+ // Import categories recursively
+ importCategory(m_domDocument.documentElement(), m_workDocument.documentElement().firstChild());
+
+ emit progress(100);
+}
+
+void KFTPImportFz3Plugin::importCategory(QDomNode parent, const QDomNode &node)
+{
+ QDomNode n = node.firstChild();
+
+ while (!n.isNull()) {
+ if (!n.isElement()) {
+ n = n.nextSibling();
+ continue;
+ }
+
+ QDomElement e = n.toElement();
+
+ if (e.tagName() == "Folder") {
+ QDomElement categoryElement = m_domDocument.createElement("category");
+ categoryElement.setAttribute("name", e.firstChild().nodeValue().stripWhiteSpace());
+ parent.appendChild(categoryElement);
+
+ importCategory(categoryElement, n);
+ } else if (e.tagName() == "Server") {
+ QString name = e.lastChild().nodeValue().stripWhiteSpace();
+ QString host = e.namedItem("Host").toElement().text();
+ QString port = e.namedItem("Port").toElement().text();
+ QString localDir = e.namedItem("LocalDir").toElement().text();
+ QString remoteDir = e.namedItem("RemoteDir").toElement().text();
+ QString username = e.namedItem("User").toElement().text();
+ QString password = e.namedItem("Pass").toElement().text();
+
+ // Set name
+ QDomElement siteElement = m_domDocument.createElement("server");
+ siteElement.setAttribute("name", name);
+ parent.appendChild(siteElement);
+
+ // Set host
+ QDomElement tmpElement = m_domDocument.createElement("host");
+ QDomText txtNode = m_domDocument.createTextNode(host);
+ tmpElement.appendChild(txtNode);
+ siteElement.appendChild(tmpElement);
+
+ // Set port
+ tmpElement = m_domDocument.createElement("port");
+ txtNode = m_domDocument.createTextNode(port);
+ tmpElement.appendChild(txtNode);
+ siteElement.appendChild(tmpElement);
+
+ // Set remote directory
+ tmpElement = m_domDocument.createElement("defremotepath");
+ txtNode = m_domDocument.createTextNode(remoteDir);
+ tmpElement.appendChild(txtNode);
+ siteElement.appendChild(tmpElement);
+
+ // Set local directory
+ tmpElement = m_domDocument.createElement("deflocalpath");
+ txtNode = m_domDocument.createTextNode(localDir);
+ tmpElement.appendChild(txtNode);
+ siteElement.appendChild(tmpElement);
+
+ // Set username
+ if (username.isNull()) {
+ username = "anonymous";
+
+ tmpElement = m_domDocument.createElement("anonlogin");
+ txtNode = m_domDocument.createTextNode("1");
+ tmpElement.appendChild(txtNode);
+ siteElement.appendChild(tmpElement);
+ }
+
+ tmpElement = m_domDocument.createElement("username");
+ txtNode = m_domDocument.createTextNode(username);
+ tmpElement.appendChild(txtNode);
+ siteElement.appendChild(tmpElement);
+
+ // Set password
+ tmpElement = m_domDocument.createElement("password");
+ txtNode = m_domDocument.createTextNode(KCodecs::base64Encode(password.ascii(), true).data());
+ tmpElement.appendChild(txtNode);
+ siteElement.appendChild(tmpElement);
+ }
+
+ n = n.nextSibling();
+ }
+}
+
+QString KFTPImportFz3Plugin::getDefaultPath()
+{
+ return QString(".filezilla/sitemanager.xml");
+}
+
+#include "kftpimportfz3plugin.moc"
diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportfz3plugin.h b/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportfz3plugin.h
new file mode 100644
index 0000000..c340ef5
--- /dev/null
+++ b/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportfz3plugin.h
@@ -0,0 +1,82 @@
+/*
+ * This file is part of the KFTPGrabber project
+ *
+ * Copyright (C) 2004 by the KFTPGrabber developers
+ * Copyright (C) 2004 Jernej Kos <kostko@jweb-network.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and
+ * NON-INFRINGEMENT. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * In addition, as a special exception, the copyright holders give
+ * permission to link the code of portions of this program with the
+ * OpenSSL library under certain conditions as described in each
+ * individual source file, and distribute linked combinations
+ * including the two.
+ * You must obey the GNU General Public License in all respects
+ * for all of the code used other than OpenSSL. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you
+ * do not wish to do so, delete this exception statement from your
+ * version. If you delete this exception statement from all source
+ * files in the program, then also delete it here.
+ */
+
+#ifndef KFTPIMPORTFZ3PLUGIN_H
+#define KFTPIMPORTFZ3PLUGIN_H
+
+#include <qdom.h>
+#include <kftpbookmarkimportplugin.h>
+
+/**
+ * This plugin enables importing of FileZilla 3 bookmark files into KFTPGrabber.
+ *
+ * @author Jernej Kos
+ */
+class KFTPImportFz3Plugin : public KFTPBookmarkImportPlugin
+{
+Q_OBJECT
+public:
+ KFTPImportFz3Plugin(QObject *parent, const char *name, const QStringList&);
+
+ /**
+ * This method should return the properly formated XML for KFTPGrabber
+ * bookmarks that is generated from the import.
+ *
+ * @return The @ref QDomDocument representation of XML
+ */
+ QDomDocument getImportedXml();
+
+ /**
+ * This method should start the import procedure.
+ *
+ * @param fileName is the path to the file that will be imported
+ */
+ void import(const QString &fileName);
+
+ /**
+ * This method should return the default path where the bookmarks could
+ * be located. The path must be relative to the user's home directory.
+ *
+ * @return The default path where bookmarks are located
+ */
+ QString getDefaultPath();
+private:
+ QDomDocument m_domDocument;
+ QDomDocument m_workDocument;
+
+ void importCategory(QDomNode parent, const QDomNode &node);
+};
+
+#endif
diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportplugin_filezilla3.desktop b/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportplugin_filezilla3.desktop
new file mode 100644
index 0000000..f3b91ae
--- /dev/null
+++ b/kftpgrabber/src/misc/plugins/bookmarkimport/filezilla3/kftpimportplugin_filezilla3.desktop
@@ -0,0 +1,38 @@
+[Desktop Entry]
+Name=FileZilla 3 Import plugin
+Name[ar]=قابس الإستيراد FileZilla 3
+Name[bg]=Приставка за импортиране на FileZilla 3
+Name[da]=Import-plugin
+Name[de]=FileZilla3-Importmodul
+Name[el]=Πρόσθετο εισαγωγής FileZilla 3
+Name[es]=Complemento de importación de FileZilla 3
+Name[et]=FileZilla 3 impordiplugin
+Name[ga]=Breiseán Iompórtála FileZilla 3
+Name[it]=Plugin di importazione FileZilla 3
+Name[ja]=FileZilla 3 インポートプラグイン
+Name[nl]=FileZilla 3-importplugin
+Name[pt]='Plugin' de Importação do FileZilla 3
+Name[pt_BR]=Plug-in de importação do FileZilla 3
+Name[sv]=FileZilla 3-importinsticksprogram
+Name[uk]=Втулок імпорту FileZilla 3
+Name[zh_CN]=FileZilla 3 导入插件
+Comment=FileZilla 3 bookmarks import plugin
+Comment[ar]=قابس FileZilla 3 لإستيراد علامات المواقع
+Comment[bg]=Приставка за импортиране на FileZilla 3 отметки в KFTPGrabber
+Comment[da]=Filezilla 3 bogmærkeimport-plugin
+Comment[de]=FileZilla3-Lesezeichenimportmodul
+Comment[el]=Πρόσθετο εισαγωγής σελιδοδεικτών FileZilla 3
+Comment[es]=Complemento de importación de marcadores de FileZilla 3
+Comment[et]=FileZilla 3 järjehoidjate impordiplugin
+Comment[ga]=Breiseán iompórtála leabharmharcanna FileZilla 3
+Comment[it]=Plugin di importazione dei segnalibri di FileZilla 3
+Comment[ja]=FileZilla 3 ブックマークをインポートするプラグイン
+Comment[nl]=FileZilla 3-bladwijzers importplugin
+Comment[pt]='Plugin' de importação de favoritos do FileZilla 3
+Comment[pt_BR]=Plug-in de importação de favoritos do FileZilla 3
+Comment[sv]=Insticksprogram för FileZilla 3-bokmärkesimport
+Comment[uk]=Втулок імпортування закладок FileZilla 3
+ServiceTypes=KFTPGrabber/BookmarkImportPlugin
+Type=Service
+X-KDE-Library=kftpimportplugin_filezilla3
+