diff options
Diffstat (limited to 'kftpgrabber/src/misc/plugins/bookmarkimport')
17 files changed, 1290 insertions, 0 deletions
diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/Makefile.am b/kftpgrabber/src/misc/plugins/bookmarkimport/Makefile.am new file mode 100644 index 0000000..54d0366 --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/Makefile.am @@ -0,0 +1,3 @@ +INCLUDES = $(all_includes) +METASOURCES = AUTO +SUBDIRS = gftp ncftp kftp filezilla3 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 + diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/Makefile.am b/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/Makefile.am new file mode 100644 index 0000000..15a7928 --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/Makefile.am @@ -0,0 +1,14 @@ +INCLUDES = -I$(srcdir)/../../../interfaces \ + $(all_includes) +METASOURCES = AUTO + +kde_module_LTLIBRARIES = kftpimportplugin_gftp.la +kftpimportplugin_gftp_la_SOURCES = kftpimportgftpplugin.cpp +kftpimportplugin_gftp_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KPARTS) ../../../interfaces/libkftpinterfaces.la +kftpimportplugin_gftp_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) + +kde_services_DATA = kftpimportplugin_gftp.desktop +noinst_HEADERS = kftpimportgftpplugin.h + +pluginsdir = $(kde_datadir)/kftpimportplugin_gftp + diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/kftpimportgftpplugin.cpp b/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/kftpimportgftpplugin.cpp new file mode 100644 index 0000000..9bd5e56 --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/kftpimportgftpplugin.cpp @@ -0,0 +1,236 @@ +/* + * 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 "kftpimportgftpplugin.h" + +#include <qdir.h> + +#include <kgenericfactory.h> +#include <klocale.h> +#include <kconfig.h> +#include <kmdcodec.h> + +K_EXPORT_COMPONENT_FACTORY(kftpimportplugin_gftp, + KGenericFactory<KFTPImportGftpPlugin>("kftpimportplugin_gftp")) + +KFTPImportGftpPlugin::KFTPImportGftpPlugin(QObject *parent, const char *name, const QStringList&) + : KFTPBookmarkImportPlugin(parent, name) +{ + KGlobal::locale()->insertCatalogue("kftpgrabber"); + m_domDocument.setContent(QString("<category name=\"%1\"/>").arg(i18n("gFTP import"))); +} + +QDomDocument KFTPImportGftpPlugin::getImportedXml() +{ + return m_domDocument; +} + +void KFTPImportGftpPlugin::import(const QString &fileName) +{ + // First we fetch some global settings + KConfig tmpConfig(userPath(".gftp/gftprc"), true, false, "HOME"); + QString email = tmpConfig.readEntry("email", "anonymous@"); + int numRetries = tmpConfig.readNumEntry("retries", -1); + int sleepTime = tmpConfig.readNumEntry("sleep_time", -1); + + // Open the bookmarks file (it has INI-like file format, so we can use the KConfig + // class to do the parsing and converting) + KConfig config(fileName, true, false, "HOME"); + QStringList groupList = config.groupList(); + + float size = (float) groupList.count(); + if (size == 0) { + // There are no bookmarks (or incorrect file), we are done + + emit progress(100); + return; + } + + int counter = 0; + QStringList::Iterator end( groupList.end() ); + for( QStringList::Iterator it( groupList.begin() ); it != end; ++it ) { + // gFTP bookmarks can have subgroups + QString groupName = *it; + QStringList groupNames = QStringList::split("/", groupName); + + QDomNode groupNode; + QDomElement parentElement = m_domDocument.documentElement(); + config.setGroup(groupName); + QString tmp = config.readEntry("hostname"); + + for (unsigned int i = 0; ! tmp.isNull() && i < groupNames.count() - 1; ++i ) { + // First see if parenElement has any sub group + groupNode = findSubGroup(parentElement, groupNames[i]); + + if( groupNode.isNull() ) { + // No, it has no subgroup, let's create one + while (i < groupNames.count() -1) { + QDomElement tmpElement = m_domDocument.createElement("category"); + tmpElement.setAttribute("name", groupNames[i]); + parentElement.appendChild(tmpElement); + parentElement = tmpElement; + + ++i; + } + } else { + // Sub group found, lets check next level + parentElement = groupNode.toElement(); + } + } + + // Now group tree is updated so lets create the site (if it has hostname) + if (!tmp.isNull()) { + // Set name + QDomElement siteElement = m_domDocument.createElement("server"); + siteElement.setAttribute("name", groupNames.last()); + parentElement.appendChild(siteElement); + + // Set host + tmp = config.readEntry("hostname"); + QDomElement tmpElement = m_domDocument.createElement("host"); + QDomText txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + // Set port + int p = config.readNumEntry("port", 21); + tmpElement = m_domDocument.createElement("port"); + txtNode = m_domDocument.createTextNode(QString::number(p)); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + // Set remote directory + tmp = config.readEntry("remote directory", "/"); + tmpElement = m_domDocument.createElement("defremotepath"); + txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + // Set local directory + tmp = config.readEntry("local directory", QDir::homeDirPath()); + tmpElement = m_domDocument.createElement("deflocalpath"); + txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + // Set username + tmp = config.readEntry("username", "anonymous"); + tmpElement = m_domDocument.createElement("username"); + txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + if (tmp == "anonymous") { + tmpElement = m_domDocument.createElement("anonlogin"); + txtNode = m_domDocument.createTextNode("1"); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + } + + // Set password + tmp = config.readEntry("password"); + tmpElement = m_domDocument.createElement("password"); + + if (tmp == "@EMAIL@" || tmp.isNull() || tmp.isEmpty()) + tmp = email; + else + tmp = decodePassword(tmp); + + // We have to encode the password + tmp = KCodecs::base64Encode(tmp.ascii(), true).data(); + txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + // Set retries + if (numRetries >= 0) { + tmpElement = m_domDocument.createElement("retrytime"); + txtNode = m_domDocument.createTextNode(QString::number(sleepTime)); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + tmpElement = m_domDocument.createElement("retrycount"); + txtNode = m_domDocument.createTextNode(QString::number(numRetries)); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + } + } + + emit progress(int(float(counter) / size * 100)); + ++counter; + } + + emit progress(100); +} + +QString KFTPImportGftpPlugin::decodePassword(const QString &password) +{ + // Leave unencoded passwords as they are + if (password[0] != '$') + return password; + + QString work = password; + work.remove(0, 1); + + QString result; + + for (uint i = 0; i < work.length() - 1; i += 2) { + char c = work.at(i).latin1(); + char n = work.at(i+1).latin1(); + + result.append( ((c & 0x3c) << 2) | ((n & 0x3c) >> 2) ); + } + + return result; +} + +QDomNode KFTPImportGftpPlugin::findSubGroup(QDomElement parent, const QString& name) +{ + QDomNodeList nodeList = parent.childNodes(); + + for(unsigned int i = 0; i < nodeList.count(); ++i) { + if(nodeList.item(i).toElement().attribute("name") == name) + return nodeList.item(i); + } + + return QDomNode(); +} + +QString KFTPImportGftpPlugin::getDefaultPath() +{ + return QString(".gftp/bookmarks"); +} + +#include "kftpimportgftpplugin.moc" diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/kftpimportgftpplugin.h b/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/kftpimportgftpplugin.h new file mode 100644 index 0000000..af2bceb --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/kftpimportgftpplugin.h @@ -0,0 +1,83 @@ +/* + * 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 KFTPIMPORTGFTPPLUGIN_H +#define KFTPIMPORTGFTPPLUGIN_H + +#include <qdom.h> +#include <kftpbookmarkimportplugin.h> + +/** +This plugin can import GFTP bookmarks into KFTPGrabber. This plugin has been ported +from "KBear by Bj�n Sahlstr� <kbjorn@users.sourceforge.net>". + +@author Jernej Kos +*/ +class KFTPImportGftpPlugin : public KFTPBookmarkImportPlugin +{ +Q_OBJECT +public: + KFTPImportGftpPlugin(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; + + QDomNode findSubGroup(QDomElement parent, const QString& name); + QString decodePassword(const QString &password); +}; + +#endif diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/kftpimportplugin_gftp.desktop b/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/kftpimportplugin_gftp.desktop new file mode 100644 index 0000000..815f1d4 --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/gftp/kftpimportplugin_gftp.desktop @@ -0,0 +1,61 @@ +[Desktop Entry] +Name=gFTP Import plugin +Name[ar]=قابس أستيراد gFTP +Name[bg]=Приставка за импортиране на gFTP +Name[br]=Lugent enporzh gFTP +Name[cs]=gFTP importní modul +Name[da]=gFTP import-plugin +Name[de]=gFTP-Importmodul +Name[el]=Πρόσθετο εισαγωγής gFTP +Name[es]=Complemento de importación de gFTP +Name[et]=gFTP impordiplugin +Name[fr]=Module d'importation de gFTP +Name[ga]=Breiseán Iompórtála gFTP +Name[gl]=Plugin de importazón de gFTP +Name[it]=Plugin di importazione gFTP +Name[ja]=gFTP インポートプラグイン +Name[ka]=gFTP-ის იმპორტის მოდული +Name[lt]=gFTP importavimo įskiepis +Name[nl]=gFTP-importplugin +Name[pa]=gFTP ਆਯਾਤ ਪਲੱਗਿੰਨ +Name[pt]='Plugin' de importação do gFTP +Name[pt_BR]=Plug-in de importação do gFTP +Name[ru]=Модуль импорта из gFTP +Name[sr]=Прикључак gFTP увоза +Name[sr@Latn]=Priključak gFTP uvoza +Name[sv]=gFTP-importinsticksprogram +Name[tr]=gFTP'den alma Eklentisi +Name[uk]=Втулок імпорту gFTP +Name[xx]=xxgFTP Import pluginxx +Name[zh_CN]=gFTP 导入插件 +Comment=gFTP bookmarks import plugin for KFTPGrabber +Comment[ar]=قابس gFTP لإستيراد علامات المواقع لِــ KFTPGrabber +Comment[bg]=Приставка за импортиране на gFTP отметки в KFTPGrabber +Comment[br]=Lugent enporzh sinedoù gFTP evit KFTPGrabber +Comment[cs]=gFTP modul importu záložek pro KFTPGrabber +Comment[da]=gFTP bogmærker import-plugin for KFTPGrabber +Comment[de]=gFTP-Lesezeichenimportmodul für KFTPGrabber +Comment[el]=Πρόσθετο εισαγωγής σελιδοδεικτών του gFTP για το KFTPGrabber +Comment[es]=Complemento de importación de marcadores de gFTP para KFTPGrabber +Comment[et]=KFTPGrabberi gFTP järjehoidjate impordiplugin +Comment[fr]=Module d'importation des signets gFTP pour KFTPGrabber +Comment[ga]=Breiseán iompórtála leabharmharcanna gFTP le haghaidh KFTPGrabber +Comment[gl]=Plugin de importazón de marcadores de gFTP para KFTPGrabber +Comment[it]=Plugin di importazione dei segnalibri di gFTP per KFTPGrabber +Comment[ja]=KFTPGrabber gFTP のブックマークをインポートするプラグイン +Comment[ka]=gFTP-ის სანიშნეების იმპორტის მოდული KFTPGrabber-თვის +Comment[lt]=gFTP žymelių importavimo į KFTPGrabber įskiepis +Comment[nl]=KFTPGrabber-plugin voor het importeren van gFTP-bladwijzers +Comment[pt]='Plugin' de importação de favoritos do gFTP para o KFTPGrabber +Comment[pt_BR]=Plug-in de importação de favoritos do gFTP para o KFTPGrabber +Comment[ru]=Импорт закладок gFTP в KFTPGrabber +Comment[sr]=KFTPGrabber-ов прикључак за увоз gFTP маркера +Comment[sr@Latn]=KFTPGrabber-ov priključak za uvoz gFTP markera +Comment[sv]=Insticksprogram för gFTP-bokmärkesimport till KFTPgrabber +Comment[tr]=KFTPGrabber için gFTP yer imlerini alma eklentisi +Comment[uk]=Втулок імпортування закладок gFTP для KFTPGrabber +Comment[xx]=xxgFTP bookmarks import plugin for KFTPGrabberxx +ServiceTypes=KFTPGrabber/BookmarkImportPlugin +Type=Service +X-KDE-Library=kftpimportplugin_gftp + diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/Makefile.am b/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/Makefile.am new file mode 100644 index 0000000..572413c --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/Makefile.am @@ -0,0 +1,14 @@ +INCLUDES = -I$(srcdir)/../../../interfaces \ + $(all_includes) +METASOURCES = AUTO + +kde_module_LTLIBRARIES = kftpimportplugin_kftp.la +kftpimportplugin_kftp_la_SOURCES = kftpimportkftpplugin.cpp +kftpimportplugin_kftp_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KPARTS) ../../../interfaces/libkftpinterfaces.la +kftpimportplugin_kftp_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) + +kde_services_DATA = kftpimportplugin_kftp.desktop +noinst_HEADERS = kftpimportkftpplugin.h + +pluginsdir = $(kde_datadir)/kftpimportplugin_kftp + diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/kftpimportkftpplugin.cpp b/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/kftpimportkftpplugin.cpp new file mode 100644 index 0000000..3ea06d8 --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/kftpimportkftpplugin.cpp @@ -0,0 +1,118 @@ +/* + * 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 "kftpimportkftpplugin.h" + +#include <qdir.h> +#include <qfile.h> + +#include <kgenericfactory.h> +#include <klocale.h> +#include <kconfig.h> +#include <kmdcodec.h> + +K_EXPORT_COMPONENT_FACTORY(kftpimportplugin_kftp, + KGenericFactory<KFTPImportKftpPlugin>("kftpimportplugin_kftp")) + +KFTPImportKftpPlugin::KFTPImportKftpPlugin(QObject *parent, const char *name, const QStringList&) + : KFTPBookmarkImportPlugin(parent, name) +{ + KGlobal::locale()->insertCatalogue("kftpgrabber"); +} + +QDomDocument KFTPImportKftpPlugin::getImportedXml() +{ + return m_domDocument; +} + +void KFTPImportKftpPlugin::import(const QString &fileName) +{ + m_domDocument.setContent(QString("<category name=\"%1\"/>").arg(i18n("KFTPGrabber import"))); + + // There is actually nothing to import, we just have to read the existing XML and + // remove site ids. + QFile file(fileName); + if (!file.open(IO_ReadOnly)) { + emit progress(100); + return; + } + + m_workDocument.setContent(&file); + file.close(); + + // Strip all ids + stripIds(); + + // Now append the bookmarks + QDomNode n = m_workDocument.documentElement().firstChild(); + + while (!n.isNull()) { + QDomNode import = m_domDocument.importNode(n, true); + m_domDocument.documentElement().appendChild(import); + + n = n.nextSibling(); + } + + emit progress(100); +} + +void KFTPImportKftpPlugin::stripIds(QDomNode node) +{ + if (node.isNull()) + node = m_workDocument.documentElement(); + + QDomNode n = node.firstChild(); + + while (!n.isNull()) { + if (n.toElement().tagName() == "category") { + if (!n.toElement().hasAttribute("id")) + n.toElement().removeAttribute("id"); + + stripIds(n); + } else if (n.toElement().tagName() == "server") { + if (n.toElement().hasAttribute("id")) + n.toElement().removeAttribute("id"); + } + + n = n.nextSibling(); + } +} + +QString KFTPImportKftpPlugin::getDefaultPath() +{ + return QString(""); +} + +#include "kftpimportkftpplugin.moc" diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/kftpimportkftpplugin.h b/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/kftpimportkftpplugin.h new file mode 100644 index 0000000..9f2e593 --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/kftpimportkftpplugin.h @@ -0,0 +1,83 @@ +/* + * 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 KFTPIMPORTKFTPPLUGIN_H +#define KFTPIMPORTKFTPPLUGIN_H + +#include <qdom.h> +#include <kftpbookmarkimportplugin.h> + +/** + * This plugin enables importing of KFTPGrabber XML bookmark files into KFTPGrabber, + * so the users can import bookmarks that were previously exported. + * + * @author Jernej Kos + */ +class KFTPImportKftpPlugin : public KFTPBookmarkImportPlugin +{ +Q_OBJECT +public: + KFTPImportKftpPlugin(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 stripIds(QDomNode node = QDomNode()); +}; + +#endif diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/kftpimportplugin_kftp.desktop b/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/kftpimportplugin_kftp.desktop new file mode 100644 index 0000000..0cb42ba --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/kftp/kftpimportplugin_kftp.desktop @@ -0,0 +1,57 @@ +[Desktop Entry] +Name=KFTPGrabber XML Import plugin +Name[ar]=قابس الإستيراد لِــ KFTPGrabber XML +Name[bg]=Приставка за импортиране на XML в KFTPGrabber +Name[br]=Lugent enporzh XML evit KFTPGrabber +Name[cs]=KFTPGrabber XML importní modul +Name[da]=KFTPGrabber XML Import-plugin +Name[de]=KFTPGrabber XML-Importmodul +Name[el]=Πρόσθετο εισαγωγής XML του KFTPGrabber +Name[es]=Complemento de importación de XML de KFTPGrabber +Name[et]=KFTPGrabberi XML-i impordiplugin +Name[ga]=Breiseán Iompórtála XML KFTPGrabber +Name[gl]=Plugin de importazón de XML para KFTPGrabber +Name[it]=KFTPGrabber Plugin di importazione XML +Name[ja]=KFTPGrabber XML インポートプラグイン +Name[ka]=KFTPGrabber-ის XML-ის იმპორტის მოდული +Name[lt]=KFTPGrabber XML importavimo įskiepis +Name[nl]=KFTPGrabber XML Importplugin +Name[pt]='Plugin' de importação XML do KFTPGrabber +Name[pt_BR]=Plug-in de importação XML do KFTPGrabber +Name[sr]=Прикључак KFTPGrabber-а за XML увоз +Name[sr@Latn]=Priključak KFTPGrabber-a za XML uvoz +Name[sv]=Insticksprogram för XML-import till KFTPgrabber +Name[tr]=KFTPGrabber XML alma eklentisi +Name[uk]=Втулок імпортування XML для KFTPGrabber +Name[xx]=xxKFTPGrabber XML Import pluginxx +Name[zh_CN]=KFTPGrabber XML 导入插件 +Comment=KFTPGrabber XML bookmarks import plugin +Comment[ar]=قابس الإستيراد KFTPGrabber XML لعلامات المواقع +Comment[bg]=Приставка за импортиране на XML отметки в KFTPGrabber +Comment[br]=Lugent enporzh sinedoù XML KFTPGrabber evit KFTPGrabber +Comment[cs]=XML modul importu záložek pro KFTPGrabber +Comment[da]=KFTPGrabber XML bogmærkeimport-plugin +Comment[de]=KFTPGrabber XML-Lesezeichenimportmodul +Comment[el]=Πρόσθετο εισαγωγής σελιδοδεικτών XML του KFTPGrabber +Comment[es]=Complemento de importación de marcadores en XML de KFTPGrabber +Comment[et]=KFTPGrabberi XML-järjehoidjate impordiplugin +Comment[ga]=Breiseán iompórtála leabharmharcanna XML le haghaidh KFTPGrabber +Comment[gl]=Plugin de importazón de marcadores XML para KFTPGrabber +Comment[it]=Plugin di importazione dei segnalibri XML per KFTPGrabber +Comment[ja]=KFTPGrabber XML ブックマークをインポートするプラグイン +Comment[ka]=KFTPGrabber-ის XML-ის სანიშნეების იმპორტის მოდული +Comment[lt]=KFTPGrabber XML importavimo įskiepis +Comment[nl]=KFTPGrabber-plugin voor het importeren van XML-bladwijzers +Comment[pt]='Plugin' de importação de favoritos em XML para o KFTPGrabber +Comment[pt_BR]=Plug-in de importação de favoritos em XML para o KFTPGrabber +Comment[sr]=KFTPGrabber-ов прикључак за увоз XML маркера +Comment[sr@Latn]=KFTPGrabber-ov priključak za uvoz XML markera +Comment[sv]=Insticksprogram för XML-bokmärkesimport till KFTPgrabber +Comment[tr]=KFTPGrabber için XML yer imlerini alma eklentisi +Comment[uk]=Втулок імпортування XML-закладок для KFTPGrabber +Comment[xx]=xxKFTPGrabber XML bookmarks import pluginxx +Comment[zh_CN]=KFTPGrabber XML 书签导入插件 +ServiceTypes=KFTPGrabber/BookmarkImportPlugin +Type=Service +X-KDE-Library=kftpimportplugin_kftp + diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/Makefile.am b/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/Makefile.am new file mode 100644 index 0000000..feb557e --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/Makefile.am @@ -0,0 +1,14 @@ +INCLUDES = -I$(srcdir)/../../../interfaces \ + $(all_includes) +METASOURCES = AUTO + +kde_module_LTLIBRARIES = kftpimportplugin_ncftp.la +kftpimportplugin_ncftp_la_SOURCES = kftpimportncftpplugin.cpp +kftpimportplugin_ncftp_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KPARTS) ../../../interfaces/libkftpinterfaces.la +kftpimportplugin_ncftp_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) + +kde_services_DATA = kftpimportplugin_ncftp.desktop +noinst_HEADERS = kftpimportncftpplugin.h + +pluginsdir = $(kde_datadir)/kftpimportplugin_ncftp + diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/kftpimportncftpplugin.cpp b/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/kftpimportncftpplugin.cpp new file mode 100644 index 0000000..e146f88 --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/kftpimportncftpplugin.cpp @@ -0,0 +1,165 @@ +/* + * 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 "kftpimportncftpplugin.h" + +#include <qdir.h> +#include <qfile.h> + +#include <kgenericfactory.h> +#include <klocale.h> +#include <kconfig.h> +#include <kmdcodec.h> + +K_EXPORT_COMPONENT_FACTORY(kftpimportplugin_ncftp, + KGenericFactory<KFTPImportNcftpPlugin>("kftpimportplugin_ncftp")) + +KFTPImportNcftpPlugin::KFTPImportNcftpPlugin(QObject *parent, const char *name, const QStringList&) + : KFTPBookmarkImportPlugin(parent, name) +{ + KGlobal::locale()->insertCatalogue("kftpgrabber"); + m_domDocument.setContent(QString("<category name=\"%1\"/>").arg(i18n("NcFtp import"))); +} + +QDomDocument KFTPImportNcftpPlugin::getImportedXml() +{ + return m_domDocument; +} + +void KFTPImportNcftpPlugin::import(const QString &fileName) +{ + /* + ARNES FTP serve,ftp.arnes.si,username,*encoded*cGFzc3dvcmQA,,/remote,I,21,4294967295,1,1,-1,1,193.2.1.79,Komentar,,,,,S,-1,/local + Redhat,ftp.redhat.com,,,,,I,21,1102099812,-1,-1,-1,1,66.187.224.30,,,,,,S,-1, + */ + + QFile f(fileName); + if (!f.open(IO_ReadOnly)) { + emit progress(100); + return; + } + + QTextStream stream(&f); + QString line; + int lineNum = 0; + + while (!stream.atEnd()) { + line = stream.readLine(); + if (++lineNum <= 2) continue; + + // Add the imported bookmark + QDomElement parentElement = m_domDocument.documentElement(); + + // Set name + QDomElement siteElement = m_domDocument.createElement("server"); + siteElement.setAttribute("name", subSection(line, 0)); + parentElement.appendChild(siteElement); + + // Set host + QString tmp = subSection(line, 1); + QDomElement tmpElement = m_domDocument.createElement("host"); + QDomText txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + // Set port + tmp = subSection(line, 7, "21"); + tmpElement = m_domDocument.createElement("port"); + txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + // Set remote directory + tmp = subSection(line, 5, "/"); + tmpElement = m_domDocument.createElement("defremotepath"); + txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + // Set local directory + tmp = subSection(line, 21, QDir::homeDirPath()); + tmpElement = m_domDocument.createElement("deflocalpath"); + txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + // Set username + tmp = subSection(line, 2, "anonymous"); + tmpElement = m_domDocument.createElement("username"); + txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + if (tmp == "anonymous") { + tmpElement = m_domDocument.createElement("anonlogin"); + txtNode = m_domDocument.createTextNode("1"); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + } + + // Set password + tmp = subSection(line, 3, ""); + tmp.replace("*encoded*", ""); + + tmpElement = m_domDocument.createElement("password"); + txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + + // Set description + tmp = subSection(line, 14, ""); + if (!tmp.isEmpty()) { + tmpElement = m_domDocument.createElement("description"); + txtNode = m_domDocument.createTextNode(tmp); + tmpElement.appendChild(txtNode); + siteElement.appendChild(tmpElement); + } + } + + emit progress(100); +} + +QString KFTPImportNcftpPlugin::subSection(const QString &text, int section, const QString &def) +{ + QString tmp = text.section(',', section, section); + + return tmp.isEmpty() ? def : tmp; +} + +QString KFTPImportNcftpPlugin::getDefaultPath() +{ + return QString(".ncftp/bookmarks"); +} + +#include "kftpimportncftpplugin.moc" diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/kftpimportncftpplugin.h b/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/kftpimportncftpplugin.h new file mode 100644 index 0000000..7a58d0e --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/kftpimportncftpplugin.h @@ -0,0 +1,80 @@ +/* + * 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 KFTPIMPORTNCFTPPLUGIN_H +#define KFTPIMPORTNCFTPPLUGIN_H + +#include <qdom.h> +#include <kftpbookmarkimportplugin.h> + +/** +This plugin can import NcFTP bookmarks into KFTPGrabber. + +@author Jernej Kos +*/ +class KFTPImportNcftpPlugin : public KFTPBookmarkImportPlugin +{ +Q_OBJECT +public: + KFTPImportNcftpPlugin(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; + + QString subSection(const QString &text, int section, const QString &def = QString::null); +}; + +#endif diff --git a/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/kftpimportplugin_ncftp.desktop b/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/kftpimportplugin_ncftp.desktop new file mode 100644 index 0000000..226f2cc --- /dev/null +++ b/kftpgrabber/src/misc/plugins/bookmarkimport/ncftp/kftpimportplugin_ncftp.desktop @@ -0,0 +1,62 @@ +[Desktop Entry] +Name=NcFTP Import plugin +Name[ar]=قابس أستيراد NcFTP +Name[bg]=Приставка за импортиране на NcFTP +Name[br]=Lugent enporzh NcFTP +Name[cs]=NcFTP importní modul +Name[da]=NcFTP import-plugin +Name[de]=NcFTP Importmodul +Name[el]=Πρόσθετο εισαγωγής NcFTP +Name[es]=Complemento de importación de NcFTP +Name[et]=NcFTP impordiplugin +Name[fr]=Module d'importation de NcFTP +Name[ga]=Breiseán Iompórtála NcFTP +Name[gl]=Plugin de Importazón de NcFTP +Name[it]=Plugin di importazione NcFTP +Name[ja]=NcFTP インポートプラグイン +Name[ka]=NcFTP-ის იმპორტის მოდული +Name[lt]=NcFTP importavimo įskiepis +Name[nl]=NcFTP-importplugin +Name[pa]=NcFTP ਆਯਾਤ ਪਲੱਗਿੰਨ +Name[pt]='Plugin' de importação do NcFTP +Name[pt_BR]=Plug-in de importação NcFTP +Name[ru]=Модуль импорта из NcFTP +Name[sr]=Прикључак NcFTP увоза +Name[sr@Latn]=Priključak NcFTP uvoza +Name[sv]=NcFTP-importinsticksprogram +Name[tr]=NcFTP'den alma eklentisi +Name[uk]=Втулок імпорту NcFTP +Name[xx]=xxNcFTP Import pluginxx +Name[zh_CN]=NcFTP 导入插件 +Comment=NcFTP bookmarks import plugin for KFTPGrabber +Comment[ar]=قابس NcFTP لإستيراد علامات المواقع لِــ KFTPGrabber +Comment[bg]=Приставка за импортиране на NcFTP отметки в KFTPGrabber +Comment[br]=Lugent enporzh sinedoù NcFTP evit KFTPGrabber +Comment[cs]=NcFTP modul importu záložek pro KFTPGrabber +Comment[da]=NcFTP bogmærker import-plugin for KFTPGrabber +Comment[de]=NcFTP Lesezeichenimportmodul für KFTPGrabber +Comment[el]=Πρόσθετο εισαγωγής σελιδοδεικτών NcFTP για το KFTPGrabber +Comment[es]=Complemento de importación de marcadores de NcFTP de KFTPGrabber +Comment[et]=KFTPGrabberi NcFTP järjehoidjate impordiplugin +Comment[fr]=Module d'importation des signets NcFTP pour KFTPGrabber +Comment[ga]=Breiseán iompórtála leabharmharcanna NcFTP le haghaidh KFTPGrabber +Comment[gl]=Plugin de importazón de marcadores NcFTP para KFTPGrabber +Comment[it]=Plugin di importazione dei segnalibri di NcFTP per KFTPGrabber +Comment[ja]=KFTPGrabber NcFTP ブックマークをインポートするプラグイン +Comment[ka]=NcFTP-ის სანიშნეების იმპორტის მოდული KFTPGrabber-თვის +Comment[lt]=NcFTP žymelių importavimo į KFTPGrabber įskiepis +Comment[nl]=Een KFTPGrabber-plugin voor het importeren van NcFTP-bladwijzers +Comment[pt]='Plugin' de importação de favoritos do NcFTP para o KFTPGrabber +Comment[pt_BR]=Plug-in de importação de favoritos do NcFTP para o KFTPGrabber +Comment[ru]=Импорт закладок NcFTP в KFTPGrabber +Comment[sr]=KFTPGrabber-ов прикључак за увоз NcFTP маркера +Comment[sr@Latn]=KFTPGrabber-ov priključak za uvoz NcFTP markera +Comment[sv]=Insticksprogram för NcFTP-bokmärkesimport till KFTPgrabber +Comment[tr]=KFTPGrabber için NcFTP'den yer imleri alma eklentisi +Comment[uk]=Втулок імпортування закладок NcFTP для KFTPGrabber +Comment[xx]=xxNcFTP bookmarks import plugin for KFTPGrabberxx +Comment[zh_CN]=KFTPGrabber 的 NcFTP 书签导入插件 +ServiceTypes=KFTPGrabber/BookmarkImportPlugin +Type=Service +X-KDE-Library=kftpimportplugin_ncftp + |