Verified Commit 023def08 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Remove cross scripting

Cross is not well maintained, even before the Qt5 port.
For KF5 it is marked as porting aid. Considering that there
are no known users of this scripting and there is already a DBus
API it was agreed on removing it.

If there comes up the need for more scripting options one could extend the DBus
API or implement sth. in QJSEngine.

Task: https://phabricator.kde.org/T11608
parent 51c7fa07
......@@ -97,16 +97,6 @@ if(KF5ItemViews_FOUND)
set(HAVE_KF5ItemViews 1)
endif()
find_package(KF5Kross ${KF5_MIN_VERSION})
set_package_properties(KF5Kross
PROPERTIES
TYPE OPTIONAL
PURPOSE "Required for KTorrent's scripting plugin"
)
if(KF5Kross_FOUND)
set(HAVE_KF5Kross 1)
endif()
find_package(KF5Plotting ${KF5_MIN_VERSION})
set_package_properties(KF5Plotting
PROPERTIES
......
......@@ -56,11 +56,10 @@ either 'xx.yy.zz (&kde; x.y)' or '&kde; x.y'
<listitem><para>Support for distributed hash tables (DHT, the Mainline version)</para></listitem>
<listitem><para>Support for UPnP to automatically forward ports on a LAN with dynamic assigned hosts</para></listitem>
<listitem><para>Support for webseeds</para></listitem>
<listitem><para>Scripting support via Kross and interprocess control via DBus interface</para></listitem>
<listitem><para>System tray integration</para></listitem>
<listitem><para>Tracker authentication support</para></listitem>
<listitem><para>Connection though a proxy</para></listitem>
<listitem><para>Scripting support via Kross and interprocess control via DBus interface</para></listitem>
<listitem><para>Interprocess control via DBus interface</para></listitem>
</itemizedlist>
<itemizedlist>
......
......@@ -631,37 +631,6 @@
<li xml:lang="uk">Підтримка вебпоширення</li>
<li xml:lang="x-test">xxSupport for webseedsxx</li>
<li xml:lang="zh-CN">支持 Webseed</li>
<li>Scripting support via Kross, and interprocess control via D-Bus interface</li>
<li xml:lang="ca">Suport per a crear scripts mitjançant el Kross i control entre processos a través de la interfície de D-Bus</li>
<li xml:lang="ca-valencia">Suport per a crear scripts mitjançant el Kross i control entre processos a través de la interfície de D-Bus</li>
<li xml:lang="da">Scripting-understøttelse via Kross og interproceskontrol via D-Bus-grænseflade</li>
<li xml:lang="de">Skript-Unterstützung mit Kross und Interprozess-Steuerung über die D-Bus-Schnittstelle</li>
<li xml:lang="el">Υποστήριξη συγγραφής σεναρίων με Kross και έλεγχος επικοινωνίας διεργασιών με D-Bus διεπαφή</li>
<li xml:lang="en-GB">Scripting support via Kross, and interprocess control via D-Bus interface</li>
<li xml:lang="es">Admite el uso de guiones vía Kross y control de interprocesos vía la interfaz D-Bus</li>
<li xml:lang="et">Skriptimise toetus Krossi kaudu ja protsesside juhtimine D-Busi liidese abil</li>
<li xml:lang="fi">Skriptaustuki Krossin kautta sekä prosessienvälinen hallinta D-Bus-liitännän kautta</li>
<li xml:lang="fr">Scriptable par Kross et contrôle inter-processus par l'interface D-Bus</li>
<li xml:lang="gl">Funcionalidade de scripting mediante Kross, e control entre procesos mediante unha interface de D-Bus.</li>
<li xml:lang="id">Dukungan penskripan via Kross, dan kendali interproses via D-Bus interface</li>
<li xml:lang="it">Supporto per lo scripting tramite Kross, e per il controllo dei processi tramite interfaccia D-Bus</li>
<li xml:lang="ko">Kross를 통한 스크립팅 및 D-Bus 인터페이스를 통한 원격 제어 지원</li>
<li xml:lang="nl">Ondersteuning voor scripts via Kross en interprocescontrole via het D-Bus-interface</li>
<li xml:lang="pl">Obsługa skryptów przez Kross i sterowania międzyprocesowego poprzez interfejs D-Bus</li>
<li xml:lang="pt">Suporte de programação através do Kross e controlo entre processos por uma interface de D-Bus</li>
<li xml:lang="pt-BR">Suporte a scripts via Kross e controle de interprocessos via interface D-Bus</li>
<li xml:lang="ru">Поддержка сценариев при помощи Kross и внешнего управления через интерфейс D-Bus</li>
<li xml:lang="sk">Podpora skriptovania cez Kross a medziprocesové ovládanie cez rozhrani D-Bus</li>
<li xml:lang="sl">Podpora za skripte prek Kross-a in medprocesni nadzor prek vmesnika D-Bus</li>
<li xml:lang="sr">Подршка за скриптовање преко Кроса и међупроцесно управљање преко д‑бус сучеља.</li>
<li xml:lang="sr-Latn">Podrška za skriptovanje preko Krossa i međuprocesno upravljanje preko D‑Bus sučelja.</li>
<li xml:lang="sr-ijekavian">Подршка за скриптовање преко Кроса и међупроцесно управљање преко д‑бус сучеља.</li>
<li xml:lang="sr-ijekavianlatin">Podrška za skriptovanje preko Krossa i međuprocesno upravljanje preko D‑Bus sučelja.</li>
<li xml:lang="sv">Skriptstöd via Kross och styrning mellan processer via D-Bus gränssnitt</li>
<li xml:lang="tr">Kross üzerinden betik yazma desteği ve D-Bus arayüzü ile süreçler arası denetim</li>
<li xml:lang="uk">Підтримка керування за допомогою скриптів на Kross та обміну даними між процесами за допомогою D-Bus</li>
<li xml:lang="x-test">xxScripting support via Kross, and interprocess control via D-Bus interfacexx</li>
<li xml:lang="zh-CN">通过 Kross 支持脚本编程,通过 D-Bus 接口实现进程间控制</li>
<li>System tray integration</li>
<li xml:lang="ca">Integració amb la safata del sistema</li>
<li xml:lang="ca-valencia">Integració amb la safata del sistema</li>
......
......@@ -31,9 +31,6 @@ macro_kt_plugin(ENABLE_BWSCHEDULER_PLUGIN bwscheduler bwscheduler)
if (HAVE_Taglib AND PHONON_FOUND_EXPERIMENTAL) #AND Qt5Multimedia_FOUND)
macro_kt_plugin(ENABLE_MEDIAPLAYER_PLUGIN mediaplayer mediaplayer)
endif()
if (HAVE_KF5Archive AND HAVE_KF5ItemViews AND HAVE_KF5Kross)
macro_kt_plugin(ENABLE_SCRIPTING_PLUGIN scripting scripting)
endif()
if (HAVE_KF5Syndication AND HAVE_Qt5WebEngineWidgets)
macro_kt_plugin(ENABLE_SYNDICATION_PLUGIN syndication syndication)
endif()
......
add_subdirectory(scripts)
add_library(ktorrent_scripting MODULE)
target_sources(ktorrent_scripting PRIVATE
api/scriptingmodule.cpp
api/scriptablegroup.cpp
scriptingplugin.cpp
scriptmanager.cpp
scriptmodel.cpp
scriptdelegate.cpp
script.cpp)
ki18n_wrap_ui(ktorrent_scripting scriptproperties.ui)
kcoreaddons_desktop_to_json(ktorrent_scripting ktorrent_scripting.desktop)
target_link_libraries(
ktorrent_scripting
ktcore
Qt5::Core
KF5::Torrent
KF5::Archive
KF5::ConfigCore
KF5::CoreAddons
KF5::I18n
KF5::IconThemes
KF5::ItemViews
KF5::KIOWidgets
KF5::KrossCore
KF5::XmlGui
)
install(TARGETS ktorrent_scripting DESTINATION ${KTORRENT_PLUGIN_INSTALL_DIR} )
install(FILES ktorrent_scriptingui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/ktorrent )
/*
SPDX-FileCopyrightText: 2008 Joris Guisson <joris.guisson@gmail.com>
SPDX-FileCopyrightText: 2008 Ivan Vasic <ivasic@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "scriptablegroup.h"
#include <dbus/dbus.h>
#include <interfaces/torrentinterface.h>
#include <util/log.h>
#include <util/sha1hash.h>
using namespace bt;
namespace kt
{
ScriptableGroup::ScriptableGroup(const QString &name, const QString &icon, const QString &path, Kross::Object::Ptr script, DBus *api)
: kt::Group(name, MIXED_GROUP, path)
, script(script)
, api(api)
{
setIconByName(icon);
}
ScriptableGroup::~ScriptableGroup()
{
}
bool ScriptableGroup::isMember(bt::TorrentInterface *tor)
{
QVariantList args;
args << tor->getInfoHash().toString();
QVariant ret = script->callMethod(QStringLiteral("isMember"), args);
return ret.toBool();
}
}
/*
SPDX-FileCopyrightText: 2008 Joris Guisson <joris.guisson@gmail.com>
SPDX-FileCopyrightText: 2008 Ivan Vasic <ivasic@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KTAPISCRIPTABLEGROUP_H
#define KTAPISCRIPTABLEGROUP_H
#include <Kross/Core/Object>
#include <groups/group.h>
namespace kt
{
class DBus;
/**
Group which uses objects in a script to determine if a torrent is a member of the group.
*/
class ScriptableGroup : public kt::Group
{
Kross::Object::Ptr script;
DBus *api;
public:
ScriptableGroup(const QString &name, const QString &icon, const QString &path, Kross::Object::Ptr script, DBus *api);
~ScriptableGroup() override;
bool isMember(bt::TorrentInterface *tor) override;
};
}
#endif
/*
SPDX-FileCopyrightText: 2008 Joris Guisson <joris.guisson@gmail.com>
SPDX-FileCopyrightText: 2008 Ivan Vasic <ivasic@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <QStandardPaths>
#include <QTimer>
#include <KConfigGroup>
#include <KSharedConfig>
#include "scriptablegroup.h"
#include "scriptingmodule.h"
#include <groups/groupmanager.h>
#include <interfaces/coreinterface.h>
#include <util/functions.h>
namespace kt
{
ScriptingModule::ScriptingModule(GUIInterface *gui, CoreInterface *core, QObject *parent)
: QObject(parent)
, gui(gui)
, core(core)
{
}
ScriptingModule::~ScriptingModule()
{
}
QString ScriptingModule::scriptsDir() const
{
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("ktorrent/scripts"), QStandardPaths::LocateDirectory);
if (dirs.count() == 0)
return QString();
QString ret = dirs.front();
if (!ret.endsWith(bt::DirSeparator()))
ret += bt::DirSeparator();
return ret;
}
QString ScriptingModule::scriptDir(const QString &script) const
{
QStringList dirs =
QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("ktorrent/scripts/") + script, QStandardPaths::LocateDirectory);
if (dirs.count() == 0)
return QString();
QString ret = dirs.front();
if (!ret.endsWith(bt::DirSeparator()))
ret += bt::DirSeparator();
return ret;
}
QString ScriptingModule::readConfigEntry(const QString &group, const QString &name, const QString &default_value)
{
KConfigGroup g = KSharedConfig::openConfig()->group(group);
return g.readEntry(name, default_value);
}
bool ScriptingModule::readConfigEntryBool(const QString &group, const QString &name, bool default_value)
{
KConfigGroup g = KSharedConfig::openConfig()->group(group);
return g.readEntry(name, default_value);
}
int ScriptingModule::readConfigEntryInt(const QString &group, const QString &name, int default_value)
{
KConfigGroup g = KSharedConfig::openConfig()->group(group);
return g.readEntry(name, default_value);
}
float ScriptingModule::readConfigEntryFloat(const QString &group, const QString &name, float default_value)
{
KConfigGroup g = KSharedConfig::openConfig()->group(group);
return g.readEntry(name, default_value);
}
void ScriptingModule::writeConfigEntry(const QString &group, const QString &name, const QString &value)
{
KConfigGroup g = KSharedConfig::openConfig()->group(group);
g.writeEntry(name, value);
}
void ScriptingModule::writeConfigEntryBool(const QString &group, const QString &name, bool value)
{
KConfigGroup g = KSharedConfig::openConfig()->group(group);
g.writeEntry(name, value);
}
void ScriptingModule::writeConfigEntryInt(const QString &group, const QString &name, int value)
{
KConfigGroup g = KSharedConfig::openConfig()->group(group);
g.writeEntry(name, value);
}
void ScriptingModule::writeConfigEntryFloat(const QString &group, const QString &name, float value)
{
KConfigGroup g = KSharedConfig::openConfig()->group(group);
g.writeEntry(name, value);
}
void ScriptingModule::syncConfig(const QString &group)
{
KConfigGroup g = KSharedConfig::openConfig()->group(group);
g.sync();
}
QObject *ScriptingModule::createTimer(bool single_shot)
{
QTimer *t = new QTimer(this);
t->setSingleShot(single_shot);
return t;
}
bool ScriptingModule::addGroup(const QString &name, const QString &icon, const QString &path, Kross::Object::Ptr obj)
{
ScriptableGroup *g = new ScriptableGroup(name, icon, path, obj, core->getExternalInterface());
kt::GroupManager *gman = core->getGroupManager();
gman->addDefaultGroup(g);
sgroups.insert(name, g);
return true;
}
void ScriptingModule::removeGroup(const QString &name)
{
if (!sgroups.contains(name))
return;
kt::GroupManager *gman = core->getGroupManager();
ScriptableGroup *g = sgroups[name];
sgroups.remove(name);
gman->removeDefaultGroup(g);
}
}
/*
SPDX-FileCopyrightText: 2008 Joris Guisson <joris.guisson@gmail.com>
SPDX-FileCopyrightText: 2008 Ivan Vasic <ivasic@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef KTSCRIPTINGMODULE_H
#define KTSCRIPTINGMODULE_H
#include "scriptablegroup.h"
#include <QObject>
#include <kross/core/object.h>
namespace kt
{
class GUIInterface;
class CoreInterface;
/**
Additional functions to be used in scripts
*/
class ScriptingModule : public QObject
{
Q_OBJECT
public:
ScriptingModule(GUIInterface *gui, CoreInterface *core, QObject *parent);
~ScriptingModule() override;
public Q_SLOTS:
/// Get the scripts directory
QString scriptsDir() const;
/// Get the data directory of a script
QString scriptDir(const QString &script) const;
/// Read a config entry
QString readConfigEntry(const QString &group, const QString &name, const QString &default_value);
int readConfigEntryInt(const QString &group, const QString &name, int default_value);
float readConfigEntryFloat(const QString &group, const QString &name, float default_value);
bool readConfigEntryBool(const QString &group, const QString &name, bool default_value);
/// Write a config entry
void writeConfigEntry(const QString &group, const QString &name, const QString &value);
void writeConfigEntryInt(const QString &group, const QString &name, int value);
void writeConfigEntryFloat(const QString &group, const QString &name, float value);
void writeConfigEntryBool(const QString &group, const QString &name, bool value);
/// Sync a group
void syncConfig(const QString &group);
/// Create a timer
QObject *createTimer(bool single_shot);
/// Add a new scriptable group
bool addGroup(const QString &name, const QString &icon, const QString &path, Kross::Object::Ptr obj);
/// Remove a previously added group
void removeGroup(const QString &name);
private:
GUIInterface *gui;
CoreInterface *core;
QMap<QString, ScriptableGroup *> sgroups;
};
}
#endif
[Desktop Entry]
Name=Scripting
Name[bg]=Скриптиране
Name[bs]=Skriptovanje
Name[ca]=Crea scripts
Name[ca@valencia]=Crea scripts
Name[cs]=Skriptování
Name[da]=Scripting
Name[de]=Skripte
Name[el]=Σενάρια
Name[en_GB]=Scripting
Name[es]=Programación
Name[et]=Skriptid
Name[fi]=Skriptaus
Name[fr]=Langage de scripts
Name[ga]=Scriptiú
Name[gl]=Scripts
Name[hu]=Parancsfájlkezelés
Name[ia]=Scripting
Name[is]=Skriftun
Name[it]=Script
Name[ja]=スクリプティング
Name[kk]=Скриптті жазу
Name[km]=ការ​ស្គ្រីប
Name[ko]=스크립팅
Name[lt]=Scenarijai
Name[lv]=Skriptēšana
Name[nb]=Skripting
Name[nds]=Skripten
Name[nl]=Scripting
Name[nn]=Skripting
Name[pl]=Skrypty
Name[pt]=Programação
Name[pt_BR]=Scripts
Name[ro]=Scriptare
Name[ru]=Сценарии
Name[si]=විධානාවලි
Name[sk]=Skriptovanie
Name[sl]=Skriptno izvajanje
Name[sq]=Skriptimi
Name[sr]=Скрипте
Name[sr@ijekavian]=Скрипте
Name[sr@ijekavianlatin]=Skripte
Name[sr@latin]=Skripte
Name[sv]=Skripthantering
Name[tr]=Betikleme
Name[ug]=قوليازما
Name[uk]=Запис сценаріїв
Name[x-test]=xxScriptingxx
Name[zh_CN]=脚本
Name[zh_TW]=文稿
Comment=Enables Kross scripting support
Comment[bg]=Включване на поддръжка на скриптиране на Kross
Comment[bs]=Omogućava podršku za skriptovanje Krosom
Comment[ca]=Habilita l'ús per a crear scripts del Kross
Comment[ca@valencia]=Habilita l'ús per a crear scripts del Kross
Comment[cs]=Podpora skriptování Kross
Comment[da]=Aktiverer understøttelse af Kross-scripting
Comment[de]=Aktiviert die Unterstützung für Kross-Skripte
Comment[el]=Ενεργοποίηση υποστήριξης σεναρίων Kross
Comment[en_GB]=Enables Kross scripting support
Comment[es]=Activa el uso de scripts con Kross
Comment[et]=Krossi skriptimise toetus
Comment[fi]=Ottaa käyttöön Kross-skriptaustuen
Comment[fr]=Active la prise en charge du langage de scripts Kross
Comment[ga]=Breiseán a chumasaíonn scriptiú Kross
Comment[gl]=Permite o uso de scripts escritos en Kross.
Comment[hu]=A Kross parancsfájlok támogatásának engedélyezése
Comment[is]=Virkja stuðning við Kross skriftun
Comment[it]=Abilita il supporto script Kross
Comment[ja]=Kross スクリプティングサポートを有効にします
Comment[kk]=Kross скриптін рұқсат ету
Comment[km]=អនុញ្ញាត​ការ​គាំទ្រ​ការ​ស្គ្រីប Kross
Comment[ko]=Kross 스크립팅 지원 사용
Comment[lt]=Įgalina kryžminį scenarijų palaikymą
Comment[lv]=Kross skriptēšanas spraudnis
Comment[nb]=Skru på støtte for Kross skripting
Comment[nds]=Ünnerstütten för Kross-Skripten
Comment[nl]=Schakelt ondersteuning voor kross-scripting in
Comment[nn]=Slår på støtte for Kross-skripting
Comment[pl]=Włącza obsługę skryptową Kross
Comment[pt]=Activa o suporte de programação com o Kross
Comment[pt_BR]=Habilita suporte à scripts do Kross
Comment[ro]=Activează suportul pentru scripturi Kross
Comment[ru]=Модуль поддержки сценариев Kross в KTorrent
Comment[si]=Kross විධානාවලි සහාය සක්‍රීය කරයි
Comment[sk]=Povolí podporu Kross scripting
Comment[sl]=Omogoči podporo za pisanje skript Kross
Comment[sr]=Додаје подршку за скриптовање Кросом
Comment[sr@ijekavian]=Додаје подршку за скриптовање Кросом
Comment[sr@ijekavianlatin]=Dodaje podršku za skriptovanje Krossom
Comment[sr@latin]=Dodaje podršku za skriptovanje Krossom
Comment[sv]=Aktiverar stöd för skripthantering med Kross
Comment[tr]=Kross betikleme desteğini etkinleştirir
Comment[uk]=Уможливлює підтримку Kross
Comment[x-test]=xxEnables Kross scripting supportxx
Comment[zh_CN]=启用 Kross 脚本支持
Comment[zh_TW]=Kross 文稿支援
Type=Service
X-KDE-Library=ktscriptingplugin
X-KDE-PluginInfo-Author=Joris Guisson
X-KDE-PluginInfo-Email=joris.guisson@gmail.com
X-KDE-PluginInfo-Name=ScriptingPlugin
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=http://kde.org/applications/internet/ktorrent/
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=false
Icon=text-x-script
<?xml version="1.0"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui library="libktscriptingplugin" name="ktscriptingplugin" version="1">
<ToolBar name="ScriptingToolbar">
<text>Scripting</text>
<Action name="add_script" />
<Action name="remove_script" />
<Separator/>
<Action name="run_script" />
<Action name="stop_script" />
<Separator/>
<Action name="configure_script" />
</ToolBar>
<Menu name="ScriptingMenu">
<text>Scripting</text>
<Action name="add_script" />
<Action name="remove_script" />
<Separator/>
<Action name="run_script" />
<Action name="stop_script" />
<Action name="edit_script" />
<Separator/>
<Action name="script_properties" />
<Action name="configure_script" />
</Menu>
</gui>
/*
SPDX-FileCopyrightText: 2008 Joris Guisson <joris.guisson@gmail.com>
SPDX-FileCopyrightText: 2008 Ivan Vasic <ivasic@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <QMimeDatabase>
#include <QMimeType>
#include <KConfigGroup>
#include <KDesktopFile>
#include <Kross/Core/ActionCollection>
#include <Kross/Core/Manager>
#include "script.h"
#include <util/fileops.h>
#include <util/log.h>
using namespace bt;
namespace kt
{
Script::Script(QObject *parent)
: QObject(parent)
, action(nullptr)
, executing(false)
, can_be_removed(true)
{
}
Script::Script(const QString &file, QObject *parent)
: QObject(parent)
, file(file)
, action(nullptr)
, executing(false)
, can_be_removed(true)
{
}
Script::~Script()
{
stop();
}
bool Script::loadFromDesktopFile(const QString &dir, const QString &desktop_file)
{
KDesktopFile df(dir + desktop_file);
// check if everything is OK
if (df.readType().trimmed() != QStringLiteral("KTorrentScript"))
return false;
info.name = df.readName();
info.comment = df.readComment();
info.icon = df.readIcon();
KConfigGroup g = df.group("Desktop Entry");
info.author = g.readEntry("X-KTorrent-Script-Author", QString());
info.email = g.readEntry("X-KTorrent-Script-Email", QString());
info.website = g.readEntry("X-KTorrent-Script-Website", QString());
info.license = g.readEntry("X-KTorrent-Script-License", QString());
file = g.readEntry("X-KTorrent-Script-File", QString());
if (file.isEmpty() || !bt::Exists(dir + file)) // the script file must exist
return false;
file = dir + file;
return true;
}