diff options
Diffstat (limited to 'kftpgrabber/src/misc/plugins/bookmarkimport/ncftp')
4 files changed, 321 insertions, 0 deletions
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 + |