diff options
Diffstat (limited to 'plugins/scanfolder')
-rw-r--r-- | plugins/scanfolder/Makefile.am | 31 | ||||
-rw-r--r-- | plugins/scanfolder/ktscanfolderplugin.desktop | 26 | ||||
-rw-r--r-- | plugins/scanfolder/ktscanfolderplugin.kcfg | 53 | ||||
-rw-r--r-- | plugins/scanfolder/scanfolder.cpp | 273 | ||||
-rw-r--r-- | plugins/scanfolder/scanfolder.h | 112 | ||||
-rw-r--r-- | plugins/scanfolder/scanfolderplugin.cpp | 187 | ||||
-rw-r--r-- | plugins/scanfolder/scanfolderplugin.h | 62 | ||||
-rw-r--r-- | plugins/scanfolder/scanfolderpluginsettings.kcfgc | 7 | ||||
-rw-r--r-- | plugins/scanfolder/scanfolderprefpage.cpp | 66 | ||||
-rw-r--r-- | plugins/scanfolder/scanfolderprefpage.h | 53 | ||||
-rw-r--r-- | plugins/scanfolder/scanfolderprefpagewidget.cpp | 107 | ||||
-rw-r--r-- | plugins/scanfolder/scanfolderprefpagewidget.h | 37 | ||||
-rw-r--r-- | plugins/scanfolder/sfprefwidgetbase.ui | 266 |
13 files changed, 0 insertions, 1280 deletions
diff --git a/plugins/scanfolder/Makefile.am b/plugins/scanfolder/Makefile.am deleted file mode 100644 index 05ae0c8..0000000 --- a/plugins/scanfolder/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -INCLUDES = -I$(srcdir)/../../libktorrent $(all_includes) -METASOURCES = AUTO -kde_module_LTLIBRARIES = ktscanfolderplugin.la - - -# LD flags for the plugin -# -module says: this is a module, i.e. something you're going to dlopen -# so e.g. it has no version number like a normal shared lib would have. -ktscanfolderplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) - -# rc file containing the GUI for the plugin -# pluginsdir = $(kde_datadir)/ktscanfolderplugin -# plugins_DATA = ktscanfolderpluginui.rc - -# Install the desktop file needed to detect the plugin - -rcdir = $(kde_datadir)/ktorrent - -kde_kcfg_DATA = ktscanfolderplugin.kcfg -kde_services_DATA = ktscanfolderplugin.desktop - -noinst_HEADERS = scanfolderplugin.h scanfolderprefpage.h \ - scanfolderprefpagewidget.h scanfolder.h -ktscanfolderplugin_la_SOURCES = scanfolderplugin.cpp \ - scanfolderpluginsettings.kcfgc scanfolderprefpage.cpp sfprefwidgetbase.ui scanfolderprefpagewidget.cpp \ - scanfolder.cpp -ktscanfolderplugin_la_LIBADD = $(LIB_TDEPARTS) ../../libktorrent/libktorrent.la \ - $(LIB_QT) $(LIB_TDECORE) $(LIB_TDEUI) $(LIB_TDEFILE) - - -KDE_CXXFLAGS = $(USE_EXCEPTIONS) $(USE_RTTI) diff --git a/plugins/scanfolder/ktscanfolderplugin.desktop b/plugins/scanfolder/ktscanfolderplugin.desktop deleted file mode 100644 index 53c7a6c..0000000 --- a/plugins/scanfolder/ktscanfolderplugin.desktop +++ /dev/null @@ -1,26 +0,0 @@ -[Desktop Entry] -Name=ScanFolderPlugin -Name[bg]=Приставка за сканиране -Name[cs]=Modul prohledávání složek -Name[da]=Plugin for mappesøgning -Name[de]=Ordner-Durchsuchen-Modul -Name[el]=Πρόσθετο σάρωσης φακέλων -Name[et]=Kataloogi uurimise plugin -Name[it]=Plugin scansione cartella -Name[nb]=Katalogundersøkingsmdoul -Name[nds]=Moduul för't Dörkieken vun Ornern -Name[nl]=Mapscanplugin -Name[pl]=Wtyczka przeszukiwania katalogów -Name[pt_BR]=Plugins de Busca -Name[sk]=ScanFolder Plugin -Name[sr]=Прикључак прегледа фасцикле -Name[sr@Latn]=Priključak pregleda fascikle -Name[sv]=Insticksprogram för katalogsökning -Name[tr]=Dizin Tarama Eklentisi -Name[uk]=Втулок сканування тек -Name[xx]=xxScanFolderPluginxx -Name[zh_CN]=扫描文件夹插件 -Name[zh_TW]=掃描資料夾外掛程式 -X-TDE-ServiceTypes=KTorrent/Plugin -Type=Service -X-TDE-Library=ktscanfolderplugin diff --git a/plugins/scanfolder/ktscanfolderplugin.kcfg b/plugins/scanfolder/ktscanfolderplugin.kcfg deleted file mode 100644 index f9b919f..0000000 --- a/plugins/scanfolder/ktscanfolderplugin.kcfg +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - - <group name="general"> - <entry name="useFolder1" type="Bool"> - <label>Enable scanning of folder1?</label> - <default>FALSE</default> - </entry> - - <entry name="useFolder2" type="Bool"> - <label>Enable scanning of folder2?</label> - <default>FALSE</default> - </entry> - - <entry name="useFolder3" type="Bool"> - <label>Enable scanning of folder3?</label> - <default>FALSE</default> - </entry> - - <entry name="folder1" type="String"> - <label>Folder1 path</label> - <default></default> - </entry> - - <entry name="folder2" type="String"> - <label>Folder2 path</label> - <default></default> - </entry> - - <entry name="folder3" type="String"> - <label>Folder3 path</label> - <default></default> - </entry> - - <entry name="openSilently" type="Bool"> - <label>Whether to open torrent silently or not.</label> - <default>FALSE</default> - </entry> - - <entry name="actionDelete" type="Bool"> - <label>Delete action checked.</label> - <default>FALSE</default> - </entry> - - <entry name="actionMove" type="Bool"> - <label>Move action checked.</label> - <default>FALSE</default> - </entry> - </group> -</kcfg> diff --git a/plugins/scanfolder/scanfolder.cpp b/plugins/scanfolder/scanfolder.cpp deleted file mode 100644 index dfceba0..0000000 --- a/plugins/scanfolder/scanfolder.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Ivan Vasić * - * ivasic@gmail.com * - * * - * 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 WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#include "scanfolder.h" - -#include <kdirlister.h> -#include <tdefileitem.h> -#include <tdelocale.h> -#include <tdeio/job.h> - -#include <tqstring.h> -#include <tqobject.h> -#include <tqfile.h> -#include <tqvaluelist.h> - -#include <torrent/globals.h> -#include <util/log.h> -#include <util/fileops.h> -#include <util/functions.h> -#include <util/constants.h> - -#include <torrent/bnode.h> -#include <torrent/bdecoder.h> - -#include <interfaces/coreinterface.h> - -using namespace bt; - -namespace kt -{ - - ScanFolder::ScanFolder(CoreInterface* core, TQString& dir, LoadedTorrentAction action, bool openSilently) - : m_core(core), m_dir(0), m_loadedAction(action), m_openSilently(openSilently) - { - m_dir = new KDirLister(); - - if(!m_dir->openURL(dir)) { - m_valid = false; - return; - } else - m_valid = true; - - m_dir->setShowingDotFiles(true); - - connect(m_dir, TQT_SIGNAL(newItems( const KFileItemList& )), this, TQT_SLOT(onNewItems( const KFileItemList& ))); - connect(m_core, TQT_SIGNAL(loadingFinished( const KURL&, bool, bool )), this, TQT_SLOT(onLoadingFinished( const KURL&, bool, bool ))); - connect(&m_incomplePollingTimer,TQT_SIGNAL(timeout()),this,TQT_SLOT(onIncompletePollingTimeout())); - } - - - ScanFolder::~ScanFolder() - { -// Out() << "UNLOADING SCANFOLDER: " << m_dir->url().path() << endl; - delete m_dir; - } - - void ScanFolder::onNewItems(const KFileItemList& items) - { - KFileItemList list = items; - KFileItem* file; - for(file=list.first(); file; file=list.next()) - { - TQString name = file->name(); - TQString dirname = m_dir->url().path(); - TQString filename = dirname + bt::DirSeparator() + name; - - if(!name.endsWith(".torrent")) - continue; - - if(name.startsWith(".")) - { - //Check if corresponding torrent exists - if(!TQFile::exists(m_dir->url().path() + bt::DirSeparator() + name.right(name.length() - 1)) && (m_loadedAction == defaultAction)) - TQFile::remove(filename); - - continue; - } - - KURL source; - source.setPath(filename); - - //If torrent has it's hidden complement - skip it. - if(TQFile::exists(dirname + "/." + name)) - continue; - - if (incomplete(source)) - { - // incomplete file, try this again in 10 seconds - bt::Out(SYS_SNF|LOG_NOTICE) << "ScanFolder : incomplete file " << source << endl; - m_incompleteURLs.append(source); - if (m_incompleteURLs.count() == 1) - { - // first URL so start the poll timer - // lets poll every 10 seconds - m_incomplePollingTimer.start(10000,false); - } - } - else - { - bt::Out(SYS_SNF|LOG_NOTICE) << "ScanFolder : found " << source << endl; - //Add pending entry... - m_pendingURLs.push_back(source); - - //Load torrent - if(m_openSilently) - m_core->loadSilently(source); - else - m_core->load(source); - } - } - } - - void ScanFolder::onLoadingFinished(const KURL & url, bool success, bool canceled) - { - if(m_pendingURLs.empty() || !success) - return; - - //search for entry - TQValueList<KURL>::iterator it = m_pendingURLs.find(url); - - //if no entry is found than this torrent was not started by this plugin so - quit - if(it == m_pendingURLs.end()) - return; - - //remove this entry - m_pendingURLs.erase(it); - - if(canceled) - return; - - TQString name = url.filename(false); - TQString dirname = m_dir->url().path(); - TQString filename = dirname + "/" + name; - KURL destination(dirname + "/" + i18n("loaded") + "/" + name); - - switch(m_loadedAction) { - case deleteAction: - //If torrent has it's hidden complement - remove it too. - if(TQFile::exists(dirname + "/." + name)) - TQFile::remove(dirname + "/." + name); - // Out() << "Deleting: " << name.ascii() << endl; - TQFile::remove(filename); - break; - case moveAction: - // Out() << "Moving: " << name.ascii() << endl; - //If torrent has it's hidden complement - remove it too. - if(TQFile::exists(dirname + "/." + name)) - TQFile::remove(dirname + "/." + name); - - // NetAccess considered harmfull !!! - TDEIO::file_move(url, destination); - break; - case defaultAction: - TQFile f(dirname + "/." + name); - f.open(IO_WriteOnly); - f.close(); - break; - } - } - - void ScanFolder::setOpenSilently(bool theValue) - { - m_openSilently = theValue; - } - - void ScanFolder::setLoadedAction(const LoadedTorrentAction& theValue) - { - m_loadedAction = theValue; - - TQDir tmp(m_dir->url().path()); - - if( (m_loadedAction == moveAction) && !tmp.exists(i18n("loaded"), false)) - tmp.mkdir(i18n("loaded"), false); - } - - void ScanFolder::setFolderUrl(TQString& url) - { - if(!m_dir->openURL(url)) { - m_valid = false; - return; - } else - m_valid = true; - } - - bool ScanFolder::incomplete(const KURL & src) - { - // try to decode file, if it is syntactically correct, we can try to load it - TQFile fptr(src.path()); - if (!fptr.open(IO_ReadOnly)) - return false; - - try - { - TQByteArray data(fptr.size()); - fptr.readBlock(data.data(),fptr.size()); - bt::BDecoder dec(data,false); - bt::BNode* n = dec.decode(); - if (n) - { - // valid node, so file is complete - delete n; - return false; - } - else - { - // decoding failed so incomplete - return true; - } - } - catch (...) - { - // any error means shit happened and the file is incomplete - return true; - } - return false; - } - - void ScanFolder::onIncompletePollingTimeout() - { - bt::Out(SYS_SNF|LOG_NOTICE) << "ScanFolder : checking incomplete files" << endl; - for (TQValueList<KURL>::iterator i = m_incompleteURLs.begin(); i != m_incompleteURLs.end();) - { - KURL source = *i; - if (!bt::Exists(source.path())) - { - // doesn't exist anymore, so throw out of list - i = m_incompleteURLs.erase(i); - } - else if (!incomplete(source)) - { - bt::Out(SYS_SNF|LOG_NOTICE) << "ScanFolder : incomplete file " << source << " appears to be completed " << endl; - //Add pending entry... - m_pendingURLs.push_back(source); - - //Load torrent - if(m_openSilently) - m_core->loadSilently(source); - else - m_core->load(source); - - // remove from incomplete list - i = m_incompleteURLs.erase(i); - } - else - { - bt::Out(SYS_SNF|LOG_NOTICE) << "ScanFolder : still incomplete : " << source << endl; - i++; - } - } - - // stop timer when no incomple URL's are left - if (m_incompleteURLs.count() == 0) - m_incomplePollingTimer.stop(); - } -} - -#include "scanfolder.moc" diff --git a/plugins/scanfolder/scanfolder.h b/plugins/scanfolder/scanfolder.h deleted file mode 100644 index 680f74c..0000000 --- a/plugins/scanfolder/scanfolder.h +++ /dev/null @@ -1,112 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Ivan Vasić * - * ivasic@gmail.com * - * * - * 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 WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#ifndef SCANFOLDER_H -#define SCANFOLDER_H - -#include <kdirlister.h> -#include <tdefileitem.h> -#include <tqstring.h> -#include <tqobject.h> -#include <tqdir.h> -#include <tqvaluelist.h> -#include <tqtimer.h> -#include <kurl.h> - -namespace kt -{ - ///Action to perform after loading torrent. - enum LoadedTorrentAction - { - deleteAction, - moveAction, - defaultAction - }; - - class CoreInterface; - - /** - * @brief Scanned folder class. - * @author Ivan Vasić <ivasic@gmail.com> - * - * It will monitor m_dir directory for changes and automatically pass new torrents to core for loading. - * After loading, it will perform specified action which can be: - * 1. Deleting torrent in question - * 2. Moving torrent to 'loaded' subdirectory - * 3. Default action (neither 1. nor 2.) - * @see LoadedTorrentAction - * - */ - class ScanFolder : public TQObject - { - Q_OBJECT - - public: - - /** - * Default constructor. - * @param core Pointer to core interface - * @param dir Full directory path - * @param action Action to perform on loaded torrents. - * @param openSilently Wheather to open torrent silently or not. - */ - ScanFolder(CoreInterface* core, TQString& dir, LoadedTorrentAction action = defaultAction, bool openSilently = true); - ~ScanFolder(); - - ///Accessor method for m_openSilently. - bool openSilently() const { return m_openSilently; } - ///Accessor method for m_openSilently - void setOpenSilently(bool theValue); - - ///Accessor method for m_loadedAction. - void setLoadedAction(const LoadedTorrentAction& theValue); - ///Accessor method for m_loadedAction. - LoadedTorrentAction loadedAction() const { return m_loadedAction; } - - ///Returns true if this object is valid, that is - weather directory is valid and this object does its work. - bool isValid() const { return m_valid; } - - ///Sets directory path - void setFolderUrl(TQString& url); - - public slots: - void onNewItems(const KFileItemList &items); - void onLoadingFinished(const KURL & url,bool success,bool canceled); - void onIncompletePollingTimeout(); - - private: - /// Check if the URL is a complete file - bool incomplete(const KURL & src); - - private: - CoreInterface* m_core; - - bool m_valid; - KDirLister* m_dir; - - LoadedTorrentAction m_loadedAction; - bool m_openSilently; - - TQValueList<KURL> m_pendingURLs; - TQValueList<KURL> m_incompleteURLs; - - TQTimer m_incomplePollingTimer; - }; -} -#endif diff --git a/plugins/scanfolder/scanfolderplugin.cpp b/plugins/scanfolder/scanfolderplugin.cpp deleted file mode 100644 index 710d1d0..0000000 --- a/plugins/scanfolder/scanfolderplugin.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Ivan Vasić * - * ivasic@gmail.com * - * * - * 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 WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#include <kgenericfactory.h> - -#include <interfaces/coreinterface.h> -#include <interfaces/guiinterface.h> -#include <interfaces/plugin.h> -#include <util/constants.h> -#include <util/log.h> - -#include <tqstring.h> -#include <tqfile.h> - -#include <tdemessagebox.h> -#include <tdelocale.h> -#include <tdeglobal.h> - -#include "scanfolder.h" -#include "scanfolderplugin.h" -#include "scanfolderprefpage.h" -#include "scanfolderpluginsettings.h" - -using namespace bt; - -K_EXPORT_COMPONENT_FACTORY(ktscanfolderplugin,KGenericFactory<kt::ScanFolderPlugin>("scanfolderplugin")) - -namespace kt -{ - const TQString NAME = "Scan Folder"; - const TQString AUTHOR = "Ivan Vasic"; - const TQString EMAIL = "ivasic@gmail.com"; - const TQString DESCRIPTION = i18n("Automatically scans directories for torrent files and loads them."); - - ScanFolderPlugin::ScanFolderPlugin(TQObject* parent, const char* name, const TQStringList& args) - : Plugin(parent, name, args,NAME,i18n("Scan Folder"),AUTHOR,EMAIL,DESCRIPTION,"view_sidetree") - { -// setXMLFile("ktscanfolderpluginui.rc"); - m_sf1 = 0; - m_sf2 = 0; - m_sf3 = 0; - } - - - ScanFolderPlugin::~ScanFolderPlugin() - { - } - - void ScanFolderPlugin::load() - { - pref = new ScanFolderPrefPage(this); - getGUI()->addPrefPage(pref); - updateScanFolders(); - } - - void ScanFolderPlugin::unload() - { - getGUI()->removePrefPage(pref); - delete pref; - pref = 0; - - if(m_sf1) - delete m_sf1; - m_sf1 = 0; - - if(m_sf2) - delete m_sf2; - m_sf2 = 0; - - if(m_sf3) - delete m_sf3; - m_sf3 = 0; - } - - void ScanFolderPlugin::updateScanFolders() - { - TQString sfPath1 = ScanFolderPluginSettings::folder1(); - TQString sfPath2 = ScanFolderPluginSettings::folder2(); - TQString sfPath3 = ScanFolderPluginSettings::folder3(); - - bool valid1 = TQFile::exists(sfPath1); - bool valid2 = TQFile::exists(sfPath2); - bool valid3 = TQFile::exists(sfPath3); - - bool usesf1 = ScanFolderPluginSettings::useFolder1() && valid1; - bool usesf2 = ScanFolderPluginSettings::useFolder2() && valid2; - bool usesf3 = ScanFolderPluginSettings::useFolder3() && valid3; - - bool silently = ScanFolderPluginSettings::openSilently(); - - LoadedTorrentAction action; - - if(ScanFolderPluginSettings::actionDelete()) - action = deleteAction; - else if(ScanFolderPluginSettings::actionMove()) - action = moveAction; - else - action = defaultAction; - - - if(usesf1) - { - if(!m_sf1) - m_sf1 = new ScanFolder(getCore(), sfPath1, action, silently); - else - { - m_sf1->setFolderUrl(sfPath1); - m_sf1->setLoadedAction(action); - m_sf1->setOpenSilently(silently); - } - } - else - { - if(m_sf1) - delete m_sf1; - m_sf1 = 0; - } - - if(usesf2) - { - if(!m_sf2) - m_sf2 = new ScanFolder(getCore(), sfPath1, action, silently); - else - { - m_sf2->setFolderUrl(sfPath1); - m_sf2->setLoadedAction(action); - m_sf2->setOpenSilently(silently); - } - } - else - { - if(m_sf2) - delete m_sf2; - m_sf2 = 0; - } - - if(usesf3) - { - if(!m_sf3) - m_sf3 = new ScanFolder(getCore(), sfPath1, action, silently); - else - { - m_sf3->setFolderUrl(sfPath1); - m_sf3->setLoadedAction(action); - m_sf3->setOpenSilently(silently); - } - } - else - { - if(m_sf3) - delete m_sf3; - m_sf3 = 0; - } - - //update config file - if(!valid1) - ScanFolderPluginSettings::setUseFolder1(false); - if(!valid2) - ScanFolderPluginSettings::setUseFolder2(false); - if(!valid3) - ScanFolderPluginSettings::setUseFolder3(false); - - ScanFolderPluginSettings::writeConfig(); - - } - - bool ScanFolderPlugin::versionCheck(const TQString & version) const - { - return version == KT_VERSION_MACRO; - } -} diff --git a/plugins/scanfolder/scanfolderplugin.h b/plugins/scanfolder/scanfolderplugin.h deleted file mode 100644 index 527b36d..0000000 --- a/plugins/scanfolder/scanfolderplugin.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Ivan Vasić * - * ivasic@gmail.com * - * * - * 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 WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#ifndef KTSCANFOLDERPLUGIN_H -#define KTSCANFOLDERPLUGIN_H - -#include <interfaces/plugin.h> - -class TQString; - - -namespace kt -{ - class ScanFolder; - class ScanFolderPrefPage; - - /** - * @author Ivan Vasic <ivasic@gmail.com> - * @brief KTorrent ScanFolder plugin - * Automatically scans selected folder for torrent files and loads them. - */ - class ScanFolderPlugin : public Plugin - { - Q_OBJECT - - public: - ScanFolderPlugin(TQObject* parent, const char* name, const TQStringList& args); - virtual ~ScanFolderPlugin(); - - virtual void load(); - virtual void unload(); - virtual bool versionCheck(const TQString& version) const; - - void updateScanFolders(); - - private: - ScanFolder* m_sf1; - ScanFolder* m_sf2; - ScanFolder* m_sf3; - - ScanFolderPrefPage* pref; - }; - -} - -#endif diff --git a/plugins/scanfolder/scanfolderpluginsettings.kcfgc b/plugins/scanfolder/scanfolderpluginsettings.kcfgc deleted file mode 100644 index 7550c9d..0000000 --- a/plugins/scanfolder/scanfolderpluginsettings.kcfgc +++ /dev/null @@ -1,7 +0,0 @@ -# Code generation options for tdeconfig_compiler -File=ktscanfolderplugin.kcfg -ClassName=ScanFolderPluginSettings -Namespace=kt -Singleton=true -Mutators=true -# will create the necessary code for setting those variables
\ No newline at end of file diff --git a/plugins/scanfolder/scanfolderprefpage.cpp b/plugins/scanfolder/scanfolderprefpage.cpp deleted file mode 100644 index 9fc466e..0000000 --- a/plugins/scanfolder/scanfolderprefpage.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Ivan Vasić * - * ivasic@gmail.com * - * * - * 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 WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#include "scanfolderplugin.h" -#include "scanfolderprefpage.h" - -#include <tdelocale.h> -#include <tdeglobal.h> -#include <kstandarddirs.h> -#include <kiconloader.h> - - - -namespace kt -{ - - ScanFolderPrefPage::ScanFolderPrefPage(ScanFolderPlugin* plugin) - : PrefPageInterface(i18n("ScanFolder"), i18n("ScanFolder Options"), - TDEGlobal::iconLoader()->loadIcon("view_sidetree",TDEIcon::NoGroup)), m_plugin(plugin) - {} - - - ScanFolderPrefPage::~ScanFolderPrefPage() - {} - - bool ScanFolderPrefPage::apply() - { - if(m_widget) - m_widget->apply(); - - m_plugin->updateScanFolders(); - - return true; - } - - void ScanFolderPrefPage::createWidget(TQWidget* parent) - { - m_widget = new ScanFolderPrefPageWidget(parent); - } - - void ScanFolderPrefPage::updateData() - { - } - - void ScanFolderPrefPage::deleteWidget() - { - delete m_widget; - } - -} diff --git a/plugins/scanfolder/scanfolderprefpage.h b/plugins/scanfolder/scanfolderprefpage.h deleted file mode 100644 index cb2f80c..0000000 --- a/plugins/scanfolder/scanfolderprefpage.h +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Ivan Vasić * - * ivasic@gmail.com * - * * - * 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 WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#ifndef KTSCANFOLDERPREFPAGE_H -#define KTSCANFOLDERPREFPAGE_H - -#include <interfaces/prefpageinterface.h> - -#include "scanfolderplugin.h" -#include "scanfolderprefpagewidget.h" - -namespace kt -{ - - /** - * ScanFolder plugin preferences page - * @author Ivan Vasić <ivasic@gmail.com> - */ - class ScanFolderPrefPage : public PrefPageInterface - { - public: - ScanFolderPrefPage(ScanFolderPlugin* plugin); - virtual ~ScanFolderPrefPage(); - - virtual bool apply(); - virtual void createWidget(TQWidget* parent); - virtual void updateData(); - virtual void deleteWidget(); - - private: - ScanFolderPlugin* m_plugin; - ScanFolderPrefPageWidget* m_widget; - }; - -} - -#endif diff --git a/plugins/scanfolder/scanfolderprefpagewidget.cpp b/plugins/scanfolder/scanfolderprefpagewidget.cpp deleted file mode 100644 index 14b89ff..0000000 --- a/plugins/scanfolder/scanfolderprefpagewidget.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Ivan Vasić * - * ivasic@gmail.com * - * * - * 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 WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#include "scanfolderprefpagewidget.h" -#include "scanfolderpluginsettings.h" - -#include <tqwidget.h> -#include <tqstring.h> -#include <tqcheckbox.h> -#include <tqfile.h> - -#include <tdeglobal.h> -#include <tdelocale.h> -#include <tdemessagebox.h> -#include <kurlrequester.h> - -namespace kt -{ - ScanFolderPrefPageWidget::ScanFolderPrefPageWidget(TQWidget *parent, const char *name) - :SfPrefPageWidgetBase(parent, name) - { - use1->setChecked(ScanFolderPluginSettings::useFolder1()); - use2->setChecked(ScanFolderPluginSettings::useFolder2()); - use3->setChecked(ScanFolderPluginSettings::useFolder3()); - - url1->setURL(ScanFolderPluginSettings::folder1()); - url2->setURL(ScanFolderPluginSettings::folder2()); - url3->setURL(ScanFolderPluginSettings::folder3()); - - openSilently->setChecked(ScanFolderPluginSettings::openSilently()); - deleteCheck->setChecked(ScanFolderPluginSettings::actionDelete()); - moveCheck->setChecked(ScanFolderPluginSettings::actionMove()); - - url1->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly); - url2->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly); - url3->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly); - } - - void ScanFolderPrefPageWidget::apply() - { - bool usesf1 = use1->isChecked(); - bool usesf2 = use2->isChecked(); - bool usesf3 = use3->isChecked(); - - TQString sfPath1 = url1->url(); - TQString sfPath2 = url2->url(); - TQString sfPath3 = url3->url(); - - bool silently = openSilently->isChecked(); - bool deleteChecked = deleteCheck->isChecked(); - bool moveChecked = moveCheck->isChecked(); - - ScanFolderPluginSettings::setOpenSilently(silently); - ScanFolderPluginSettings::setActionDelete(deleteChecked); - ScanFolderPluginSettings::setActionMove(moveChecked); - - TQString message = i18n( "ScanFolder - Folder %1: Invalid URL or folder does not exist. Please, choose a valid directory." ); - if(!TQFile::exists(sfPath1) && usesf1) - { - KMessageBox::sorry(0, message.arg( 1 ) ); - usesf1 = false; - } - else - ScanFolderPluginSettings::setFolder1(sfPath1); - - if(!TQFile::exists(sfPath2) && usesf2) - { - KMessageBox::sorry(0, message.arg( 2 ) ); - usesf2 = false; - } - else - ScanFolderPluginSettings::setFolder2(sfPath2); - - if(!TQFile::exists(sfPath3) && usesf3) - { - KMessageBox::sorry(0, message.arg( 3 ) ); - usesf3 = false; - } - else - ScanFolderPluginSettings::setFolder3(sfPath3); - - - ScanFolderPluginSettings::setUseFolder1(usesf1); - ScanFolderPluginSettings::setUseFolder2(usesf2); - ScanFolderPluginSettings::setUseFolder3(usesf3); - - ScanFolderPluginSettings::writeConfig(); - } - -} -#include "scanfolderprefpagewidget.moc" diff --git a/plugins/scanfolder/scanfolderprefpagewidget.h b/plugins/scanfolder/scanfolderprefpagewidget.h deleted file mode 100644 index 6468d9d..0000000 --- a/plugins/scanfolder/scanfolderprefpagewidget.h +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Ivan Vasić * - * ivasic@gmail.com * - * * - * 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 WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#ifndef SCANFOLDERPREFPAGEWIDGET_H -#define SCANFOLDERPREFPAGEWIDGET_H - -#include "sfprefwidgetbase.h" - -namespace kt -{ - class ScanFolderPrefPageWidget: public SfPrefPageWidgetBase - { - Q_OBJECT - - public: - ScanFolderPrefPageWidget(TQWidget *parent = 0, const char *name = 0); - - void apply(); - }; -} -#endif diff --git a/plugins/scanfolder/sfprefwidgetbase.ui b/plugins/scanfolder/sfprefwidgetbase.ui deleted file mode 100644 index dd106cb..0000000 --- a/plugins/scanfolder/sfprefwidgetbase.ui +++ /dev/null @@ -1,266 +0,0 @@ -<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> -<class>SfPrefPageWidgetBase</class> -<widget class="TQWidget"> - <property name="name"> - <cstring>SfPrefPageWidgetBase</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>546</width> - <height>480</height> - </rect> - </property> - <property name="caption"> - <string>ScanFolder Preferences</string> - </property> - <grid> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="TQLayoutWidget" row="0" column="0"> - <property name="name"> - <cstring>layout16</cstring> - </property> - <vbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="TQCheckBox"> - <property name="name"> - <cstring>use1</cstring> - </property> - <property name="text"> - <string>Scan folder &1</string> - </property> - <property name="accel"> - <string>Alt+1</string> - </property> - </widget> - <widget class="TQCheckBox"> - <property name="name"> - <cstring>use2</cstring> - </property> - <property name="text"> - <string>Scan folder &2</string> - </property> - <property name="accel"> - <string>Alt+2</string> - </property> - </widget> - <widget class="TQCheckBox"> - <property name="name"> - <cstring>use3</cstring> - </property> - <property name="text"> - <string>Scan folder &3</string> - </property> - <property name="accel"> - <string>Alt+3</string> - </property> - </widget> - </vbox> - </widget> - <widget class="TQButtonGroup" row="3" column="0"> - <property name="name"> - <cstring>buttonGroup1</cstring> - </property> - <property name="title"> - <string>Options</string> - </property> - <grid> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="TQCheckBox" row="2" column="0"> - <property name="name"> - <cstring>moveCheck</cstring> - </property> - <property name="text"> - <string>Move to "loaded" directory &after loading</string> - </property> - <property name="toolTip" stdset="0"> - <string>Move torrent to "loaded" directory after loading it</string> - </property> - </widget> - <widget class="TQCheckBox" row="0" column="0"> - <property name="name"> - <cstring>openSilently</cstring> - </property> - <property name="text"> - <string>Open torrents silentl&y</string> - </property> - <property name="toolTip" stdset="0"> - <string>Do not show 'Select files to download' dialog</string> - </property> - </widget> - <widget class="TQCheckBox" row="1" column="0"> - <property name="name"> - <cstring>deleteCheck</cstring> - </property> - <property name="text"> - <string>Delete after loadin&g</string> - </property> - <property name="toolTip" stdset="0"> - <string>Deletes torrent after loading</string> - </property> - </widget> - </grid> - </widget> - <widget class="TQGroupBox" row="2" column="0"> - <property name="name"> - <cstring>groupBox9</cstring> - </property> - <property name="title"> - <string>Folders to scan</string> - </property> - <grid> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="KURLRequester" row="0" column="1"> - <property name="name"> - <cstring>url1</cstring> - </property> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - <widget class="KURLRequester" row="1" column="1"> - <property name="name"> - <cstring>url2</cstring> - </property> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - <widget class="KURLRequester" row="2" column="1"> - <property name="name"> - <cstring>url3</cstring> - </property> - <property name="enabled"> - <bool>false</bool> - </property> - </widget> - <widget class="TQLabel" row="0" column="0"> - <property name="name"> - <cstring>textLabel1</cstring> - </property> - <property name="text"> - <string>Folder 1:</string> - </property> - <property name="buddy" stdset="0"> - <cstring>kURLRequester1</cstring> - </property> - </widget> - <widget class="TQLabel" row="1" column="0"> - <property name="name"> - <cstring>textLabel2</cstring> - </property> - <property name="text"> - <string>Folder 2:</string> - </property> - <property name="buddy" stdset="0"> - <cstring>kURLRequester4</cstring> - </property> - </widget> - <widget class="TQLabel" row="2" column="0"> - <property name="name"> - <cstring>textLabel3</cstring> - </property> - <property name="text"> - <string>Folder 3:</string> - </property> - <property name="buddy" stdset="0"> - <cstring>kURLRequester5</cstring> - </property> - </widget> - </grid> - </widget> - <spacer row="1" column="0"> - <property name="name"> - <cstring>spacer6</cstring> - </property> - <property name="orientation"> - <enum>Vertical</enum> - </property> - <property name="sizeType"> - <enum>Fixed</enum> - </property> - <property name="sizeHint"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <spacer row="4" column="0"> - <property name="name"> - <cstring>spacer4</cstring> - </property> - <property name="orientation"> - <enum>Vertical</enum> - </property> - <property name="sizeType"> - <enum>Expanding</enum> - </property> - <property name="sizeHint"> - <size> - <width>20</width> - <height>90</height> - </size> - </property> - </spacer> - </grid> -</widget> -<connections> - <connection> - <sender>use1</sender> - <signal>toggled(bool)</signal> - <receiver>url1</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>use2</sender> - <signal>toggled(bool)</signal> - <receiver>url2</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>use3</sender> - <signal>toggled(bool)</signal> - <receiver>url3</receiver> - <slot>setEnabled(bool)</slot> - </connection> - <connection> - <sender>deleteCheck</sender> - <signal>toggled(bool)</signal> - <receiver>moveCheck</receiver> - <slot>setDisabled(bool)</slot> - </connection> - <connection> - <sender>moveCheck</sender> - <signal>toggled(bool)</signal> - <receiver>deleteCheck</receiver> - <slot>setDisabled(bool)</slot> - </connection> -</connections> -<tabstops> - <tabstop>use1</tabstop> - <tabstop>use2</tabstop> - <tabstop>use3</tabstop> - <tabstop>url1</tabstop> - <tabstop>url2</tabstop> - <tabstop>url3</tabstop> - <tabstop>openSilently</tabstop> - <tabstop>deleteCheck</tabstop> - <tabstop>moveCheck</tabstop> -</tabstops> -<layoutdefaults spacing="6" margin="11"/> -<includes> - <include location="global" impldecl="in implementation">klineedit.h</include> - <include location="global" impldecl="in implementation">kpushbutton.h</include> - <include location="global" impldecl="in implementation">kurlrequester.h</include> -</includes> -</UI> |