summaryrefslogtreecommitdiffstats
path: root/interfaces/kscript
diff options
context:
space:
mode:
Diffstat (limited to 'interfaces/kscript')
-rw-r--r--interfaces/kscript/Makefile.am21
-rw-r--r--interfaces/kscript/README14
-rw-r--r--interfaces/kscript/sample/Makefile.am13
-rw-r--r--interfaces/kscript/sample/shellscript.cpp85
-rw-r--r--interfaces/kscript/sample/shellscript.desktop153
-rw-r--r--interfaces/kscript/sample/shellscript.h48
-rw-r--r--interfaces/kscript/scriptclientinterface.h124
-rw-r--r--interfaces/kscript/scriptinterface.desktop89
-rw-r--r--interfaces/kscript/scriptinterface.h88
-rw-r--r--interfaces/kscript/scriptloader.cpp104
-rw-r--r--interfaces/kscript/scriptloader.h59
-rw-r--r--interfaces/kscript/scriptmanager.cpp132
-rw-r--r--interfaces/kscript/scriptmanager.h139
13 files changed, 1069 insertions, 0 deletions
diff --git a/interfaces/kscript/Makefile.am b/interfaces/kscript/Makefile.am
new file mode 100644
index 000000000..a84d73863
--- /dev/null
+++ b/interfaces/kscript/Makefile.am
@@ -0,0 +1,21 @@
+SUBDIRS = . sample
+
+INCLUDES = -I$(top_srcdir)/kio -I$(top_srcdir) -I$(srcdir) -I$(srcdir)/.. $(all_includes)
+
+#lib_LTLIBRARIES = libkscriptloader.la libkscript.la
+lib_LTLIBRARIES = libkscript.la
+#libkscriptloader_la_SOURCES = scriptloader.cpp
+#libkscriptloader_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+#libkscriptloader_la_LIBADD = $(LIB_KPARTS)
+
+libkscript_la_SOURCES = scriptmanager.cpp
+libkscript_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
+libkscript_la_LIBADD = $(LIB_KIO)
+
+kscriptinclude_HEADERS = scriptinterface.h scriptclientinterface.h scriptmanager.h
+kscriptincludedir = $(includedir)
+
+METASOURCES = AUTO
+
+servicetypedir = $(kde_servicetypesdir)
+servicetype_DATA = scriptinterface.desktop
diff --git a/interfaces/kscript/README b/interfaces/kscript/README
new file mode 100644
index 000000000..213a0c277
--- /dev/null
+++ b/interfaces/kscript/README
@@ -0,0 +1,14 @@
+Script interface
+----------------
+Overview:
+scriptloader - used to load script engines and scripts from the GUI
+scriptinterface - the base of all script engines
+
+Script Engines:
+
+TODO
+
+Script Loader:
+
+TODO
+
diff --git a/interfaces/kscript/sample/Makefile.am b/interfaces/kscript/sample/Makefile.am
new file mode 100644
index 000000000..96e8f0873
--- /dev/null
+++ b/interfaces/kscript/sample/Makefile.am
@@ -0,0 +1,13 @@
+INCLUDES = -I$(top_srcdir)/kio -I$(top_srcdir)/interfaces -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/interfaces/kscript $(all_includes)
+
+kde_module_LTLIBRARIES = libshellscript.la
+
+libshellscript_la_SOURCES = shellscript.cpp
+libshellscript_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) -no-undefined -avoid-version
+libshellscript_la_LIBADD = ../libkscript.la
+
+
+METASOURCES = AUTO
+
+servicetypedir = $(kde_servicesdir)
+servicetype_DATA = shellscript.desktop
diff --git a/interfaces/kscript/sample/shellscript.cpp b/interfaces/kscript/sample/shellscript.cpp
new file mode 100644
index 000000000..4e3062eb2
--- /dev/null
+++ b/interfaces/kscript/sample/shellscript.cpp
@@ -0,0 +1,85 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "shellscript.h"
+#include <kdebug.h>
+#include <kapplication.h>
+#include <dcopclient.h>
+
+#include <kgenericfactory.h>
+#include <scriptclientinterface.h>
+//using namespace KScriptInterface;
+typedef KGenericFactory<ShellScript, KScriptClientInterface> ShellScriptFactory;
+K_EXPORT_COMPONENT_FACTORY( libshellscript, ShellScriptFactory( "ShellScript" ) )
+
+ShellScript::ShellScript(KScriptClientInterface *parent, const char *, const QStringList & ) : ScriptClientInterface(parent)
+{
+ m_script = new KProcess();
+ connect ( m_script, SIGNAL(processExited(KProcess *)), SLOT(Exit(KProcess *)));
+ connect ( m_script, SIGNAL(receivedStdout(KProcess *, char *, int)), SLOT(stdOut(KProcess *, char *, int )));
+ connect ( m_script, SIGNAL(receivedStderr(KProcess *, char *, int)), SLOT(stdErr(KProcess *, char *, int )));
+ // Connect feedback signals and slots
+ //kdDebug() << "Building new script engine" << endl;
+}
+
+ShellScript::~ShellScript()
+{
+}
+
+QString ShellScript::script() const
+{
+ return m_scriptName;
+}
+
+void ShellScript::setScript( const QString &scriptFile )
+{
+ m_scriptName = scriptFile;
+ *m_script << "sh" << m_scriptName << kapp->dcopClient()->appId();
+}
+
+void ShellScript::setScript( const QString &, const QString & )
+{
+ // ### what is this?
+}
+
+void ShellScript::run(QObject *, const QVariant &)
+{
+ m_script->start(KProcess::NotifyOnExit,KProcess::All);
+}
+void ShellScript::kill()
+{
+ if (!m_script->kill()) // Kill the process
+ m_script->kill(9); // Kill it harder
+}
+
+void ShellScript::Exit(KProcess *proc)
+{
+ ScriptClientInterface->done((KScriptClientInterface::Result)proc->exitStatus(), "");
+}
+
+void ShellScript::stdErr(KProcess *, char *buffer, int)
+{
+ ScriptClientInterface->error(buffer);
+}
+void ShellScript::stdOut(KProcess *, char *buffer, int)
+{
+ ScriptClientInterface->output(buffer);
+}
+
+#include "shellscript.moc"
diff --git a/interfaces/kscript/sample/shellscript.desktop b/interfaces/kscript/sample/shellscript.desktop
new file mode 100644
index 000000000..990a69386
--- /dev/null
+++ b/interfaces/kscript/sample/shellscript.desktop
@@ -0,0 +1,153 @@
+[Desktop Entry]
+Name=Bash Shell Script Runner
+Name[af]=Bash Tolk Skrip Hardloper
+Name[az]=Bash Qabıq Skripti İcraçısı
+Name[be]=Выкананне сцэнараў абалонкі bash
+Name[bn]=ব্যাশ শেল স্ক্রিপ্ট চালক
+Name[bs]=Izvršavanje Bash shell skripti
+Name[ca]=Processa script bash a l'intèrpret de comandaments
+Name[cs]=Spouštěč skriptů pro BASH
+Name[csb]=Programa zrëszôjącô skriptë Bash
+Name[cy]=Rhedydd Sgript Plisgyn Bash
+Name[da]=Bash Skal-script-udførsel
+Name[de]=Ausführung von Bash-Skripten
+Name[el]=Εκτελεστής σεναρίων κελύφους Bash
+Name[eo]=Baŝoskriptlanĉilo
+Name[es]=Ejecutor de script para intérprete de órdenes de bash
+Name[et]=Bash shelli skripti käivitaja
+Name[eu]=Bash shell script-aren abiarazlea
+Name[fa]=اجراکنندۀ دست‌نوشتۀ پوستۀ bash
+Name[fi]=Komentotulkkiohjelmien käynnistäjä
+Name[fr]=Lanceur de scripts shell Bash
+Name[fy]=Bash Flues Skript Rinner
+Name[ga]=Reathaí Script Bhlaoisce bash
+Name[gl]=Guión Executábel da Shell Bash
+Name[he]=הרצת תסריט מעטפת של Bash
+Name[hi]=बैश शेल स्क्रिप्ट चालक
+Name[hr]=Pokretač Bash skripti ljuske
+Name[hu]=Bash parancsfájl futtatása
+Name[is]=Keyrsluforrit bash skeljaforrita
+Name[it]=Esecutore script bash
+Name[ja]=Bash シェルスクリプト 実行
+Name[ka]=bash სკრიპტების შესრულება
+Name[kk]=Bash қоршау-ортаның скриптерін орындау
+Name[km]=កម្មវិធី​រត់​ស្គ្រីប​សែល Bash
+Name[ko]=배쉬 쉘 스크립트 실행기
+Name[lb]=Ausféierer fir Bash-Kommandozeil-Skripter
+Name[lt]=Bash apvalkalo scenarijų paleidėjas
+Name[lv]=Bash čaulas skriptu darbinātājs
+Name[mk]=Стартувач на скрипти за школката Bash
+Name[mn]=Bash-Shell-Скрипт ажиллуулагч
+Name[ms]=Pelaksana Skrip Cengkerang Bash
+Name[nb]=Bash skallskriptkjører
+Name[nds]=Bashskript-Starter
+Name[ne]=बाश शेल स्क्रिप्ट सञ्चालक
+Name[nn]=Bash-skalskriptkøyrar
+Name[pa]=ਬੈਸ਼ ਸ਼ੈਲ ਸਕ੍ਰਿਪਟ ਰਨਰ(Bash Shell)
+Name[pl]=Program uruchamiający skrypty Bash
+Name[pt]=Execução de Programa da 'Shell' BASH
+Name[pt_BR]=Executor de Script Shell do Bash
+Name[ro]=Executor scripturi de interpretor
+Name[ru]=Запуск скриптов bash
+Name[rw]=Mutangiza Gaporogaramu Bash Shell
+Name[se]=Skálžu-skriptavuodji
+Name[sk]=Spustenie Bash shell skriptu
+Name[sl]=Zaganjalnik lupinski skriptov
+Name[sq]=Egzekutuesi i skriptave të Guacës Bash
+Name[sr]=Извршавач скрипти Bash шкољке
+Name[sr@Latn]=Izvršavač skripti Bash školjke
+Name[sv]=Kör Bash-skalskript
+Name[ta]=பேஷ் ஓட்டு எழுத்தாக்க இயக்கி
+Name[te]=బేష్ షెల్ స్క్రిప్ట్లను నిర్వర్తించెది
+Name[tg]=Иҷрокунандаи Bash Shell
+Name[th]=ตัวสั่งสคริปต์ของ bash เชลล์ให้ทำงาน
+Name[tr]=Kabuk Betiği Çalıştırıcısı
+Name[tt]=Qabıqnıñ Bash Ämerlek Cibärgeçe
+Name[uk]=Виконувач скриптів командної оболонки (bash)
+Name[uz]=Bash shell skriptini ishga tushuruvchi
+Name[uz@cyrillic]=Bash шелл скриптини ишга тушурувчи
+Name[vi]=Bộ chạy tập lệnh hệ vỏ Bash
+Name[wa]=Enondeu di scripes shell bash
+Name[zh_CN]=Bash Shell 脚本运行程序
+Name[zh_TW]=Bash Shell Script 執行器
+Type=Service
+X-KDE-Library=libshellscript
+X-KDE-Script-Runner=ShellScript/bash
+ServiceTypes=KScriptRunner/KScriptRunner
+Comment=Runs bash shell scripts from inside the application.
+Comment[af]=Laai bash tolk skripte vanuit die program.
+Comment[ar]=يشغَل bash shell scripts من داخل التطبيق
+Comment[az]=Proqramın içindən bash qabıq skriptlərini icra edin
+Comment[be]=Выконвае сцэнары абалонкі bash у межах праграмы.
+Comment[bg]=Изпълнение на скриптове на bash от друга програма.
+Comment[bn]=অ্যাপ্লিকেশনের ভেতরে ব্যাশ শেল স্ক্রিপ্ট (bash shell script) চালায়।
+Comment[bs]=Izvršava bash shell skripte iz same aplikacije.
+Comment[ca]=Processa scripts bash des de les aplicacions.
+Comment[cs]=Spouští BASH skript z aplikace.
+Comment[csb]=Zrëszô skriptë Bash bënë aplikacëji.
+Comment[cy]=Yn rhedeg sgriptiau plisgyn bash o tu fewn y cymhwysiad.
+Comment[da]=Kører bash skal-scripter inde fra programmet.
+Comment[de]=Führt Bash-Shell-Skripte innerhalb von Programmen aus
+Comment[el]=Εκτελεί σενάρια κελύφους bash μέσα από την εφαρμογή.
+Comment[eo]=Enaplikaĵe lanĉas ŝelskriptojn.
+Comment[es]=Ejecuta procedimientos del intérprete de órdenes bash desde dentro de la aplicación.
+Comment[et]=Käivitab bash shelli skripte rakendustes.
+Comment[eu]=Aplikazioaren baitatik bash-eko shell script-ak abiarazteko.
+Comment[fa]=دست‌نوشته‌های پوستۀ bash را از درون کاربرد اجرا می‌کند.
+Comment[fi]=Suorittaa Bash-komentotulkkiohjelmia ohjelman sisästä
+Comment[fr]=Exécute des scripts shell Bash depuis l'intérieur de l'application.
+Comment[fy]=Bash flues skript rint yn de applikaasje.
+Comment[ga]=Ritheann seo scripteanna blaoisce bash ó thaobh istigh an fheidhmchláir.
+Comment[gl]=Executa guións da shell bash desde dentro da aplicación.
+Comment[he]=מריץ תסריטי Bash מתוך היישום
+Comment[hi]=अनुप्रयोगों के भीतर से ही बैश शेल स्क्रिप्ट चलाता है.
+Comment[hr]=Pokretanje bash skripti ljuske iz aplikacije.
+Comment[hsb]=Wuwjedźe skripty za bash znutřka aplikacije.
+Comment[hu]=Bash parancsfájlok futtatása alkalmazásokból.
+Comment[id]=Menjalankan skrip bash dari aplikasi
+Comment[is]=Keyrir bash skeljaforrit innan forritsins
+Comment[it]=Esegue gli script bash all'interno dell'applicazione.
+Comment[ja]=アプリケーション内部からの Bash シェルスクリプトを実行します。
+Comment[ka]=bash სკრიპტების პროგრამებში შესრულება.
+Comment[kk]=Қолданбаның ішінен bash скрипттерін орындайды.
+Comment[km]=រត់​ស្គ្រីប​សែល bash ពី​ក្នុង​កម្មវិធី ។
+Comment[ko]=응용 프로그램에서 배쉬 쉘 스크립트를 실행합니다.
+Comment[lb]=Féiert Skripter fir d'Bash-Kommandozeil aus dem Programm selwer aus.
+Comment[lt]=Paleidžia bash apvalkalo scenarijus iš taikomosios programos.
+Comment[lv]=Darbina Bash čaulas skriptus iekš programmas.
+Comment[mk]=Ги стартува bash shell скриптите од апликацијата.
+Comment[mn]=Програм дотроос Bash-Shell-Скрипт ажиллуулах.
+Comment[ms]=Laksanakan skrip cengkerang bash di dalam aplikasi.
+Comment[nb]=Kjører bash skallskript fra innsiden av programmet.
+Comment[nds]=Dor köönt Programmen Bash-Konsoolskripten mit utföhren.
+Comment[ne]=अनुप्रयोगको भित्रबाट बाश शेल स्क्रिप्ट सञ्चालन गर्दछ ।
+Comment[nl]=Voert Bash-shellscripts uit binnen de toepassing.
+Comment[nn]=Køyrer Bash-skalskript innanfrå programmet.
+Comment[pa]=ਇੱਕ ਕਾਰਜ ਵਿੱਚ ਬੈਸ਼ ਸ਼ੈਲ ਸਕ੍ਰਿਪਟਾਂ ਚਲਾਉਣ ਲਈ ਸਹਾਇਕ ਹੈ
+Comment[pl]=Uruchamia skrypty Bash wewnątrz programu.
+Comment[pt]=Corre os programas da 'shell' 'bash' dentro das aplicações.
+Comment[pt_BR]=Executa shell scripts do bash de dentro do aplicativo
+Comment[ro]=Execută scripturi de interpretor "bash" din interiorul unei aplicaţii.
+Comment[ru]=Запуск bash-скриптов из приложений.
+Comment[rw]=Itangiza inyandikoporogaramu ya sheli bash guhera imberemo ya porogaramu.
+Comment[se]=Vuodjá bash-skálzoskriptaid prográmma siskobeales.
+Comment[sk]=Spustí bash shell skript z aplikácie.
+Comment[sl]=Požene lupinske skripte znotraj programa.
+Comment[sq]=I ekzekuton skriptat Guacës Bash përbrenda aplikacionit.
+Comment[sr]=Покреће скриптре bash шкољке унутар програма.
+Comment[sr@Latn]=Pokreće skriptre bash školjke unutar programa.
+Comment[sv]=Kör Bash-skalskript inifrån programmet.
+Comment[ta]=பயன்பாட்டில் இருந்து பேஷ் ஓட்டு எழுத்தாக்க இயக்குகிறது
+Comment[te]=బేష్ షెల్ స్క్రిప్ట్లను కార్యక్షేత్రం లొపల నుంచి నిర్వర్తించెది
+Comment[tg]=Скриптҳои bash shell даруни барномаҳо иҷро мекунад.
+Comment[th]=สั่งให้สคริปต์ของ bash เชลล์ทำงานภายในแอพพลิเคชัน
+Comment[tr]=Uygulama içinden bash betiği çalıştırır.
+Comment[tt]=Yazılım eçennän bash ämerleklär cibärä.
+Comment[uk]=Запускає скрипти командної оболонки (bash) з програми.
+Comment[uz]=Dasturlarning ichdan bash shell skriptini ishga tushiradi
+Comment[uz@cyrillic]=Дастурларнинг ичдан bash шелл скриптини ишга туширади
+Comment[vi]=Chạy tập lệnh hệ vỏ bash bên trong ứng dụng.
+Comment[wa]=Enonder des scripes shell bash a pårti do programe
+Comment[zh_CN]=在应用程序内运行 bash shell 脚本。
+Comment[zh_HK]=於程式內執行 bash shell script 檔案
+Comment[zh_TW]=於程式內執行 bash shell script 檔案
diff --git a/interfaces/kscript/sample/shellscript.h b/interfaces/kscript/sample/shellscript.h
new file mode 100644
index 000000000..c6bdc3c38
--- /dev/null
+++ b/interfaces/kscript/sample/shellscript.h
@@ -0,0 +1,48 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef __shellscript_h__
+#define __shellscript_h__
+
+#include <scriptinterface.h>
+#include <qvariant.h>
+#include <qobject.h>
+#include <kprocess.h>
+//using namespace KScriptInterface;
+class ShellScript : public KScriptInterface
+{
+ Q_OBJECT
+public:
+ ShellScript(KScriptClientInterface *parent, const char *name, const QStringList &args);
+ virtual ~ShellScript();
+ QString script() const;
+ void setScript( const QString &scriptFile );
+ void setScript( const QString &scriptLibFile, const QString &method );
+ void run(QObject *context = 0, const QVariant &arg = 0);
+ void kill();
+private slots:
+ void Exit(KProcess *proc);
+ void stdErr(KProcess *proc, char *buffer, int buflen);
+ void stdOut(KProcess *proc, char *buffer, int buflen);
+private:
+ KProcess *m_script;
+ KScriptClientInterface *ScriptClientInterface;
+ QString m_scriptName;
+};
+
+#endif
diff --git a/interfaces/kscript/scriptclientinterface.h b/interfaces/kscript/scriptclientinterface.h
new file mode 100644
index 000000000..adeaa6424
--- /dev/null
+++ b/interfaces/kscript/scriptclientinterface.h
@@ -0,0 +1,124 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef __scriptclientinterface_h__
+#define __scriptclientinterface_h__
+#include <qvariant.h>
+
+class QString;
+
+//namespace KScriptInterface
+//{
+ /**
+ * This class is used for allowing feedback to the main system.
+ * @author Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * To implement KScript in your application you would use this class to interface with the scripting engine.
+ * There are currently a few implementations of script managers around but developers can implement their own custom
+ * interfaces with this class.
+ * @code
+ * class MyScript : public QObject, public KScriptClientInterface {
+ * Q_OBJECT
+ * public:
+ *
+ * MyScript(QObject *parent)
+ * {
+ * // Create your @ref KScriptInterface here.
+ * m_interface = KParts::ComponentFactory::createInstanceFromQuery<KScriptInterface>(
+ * "KScriptRunner/KScriptRunner", "([X-KDE-Script-Runner] == 'bash/shell')", this );
+ * }
+ *
+ * virtual ~KScriptAction()
+ * {
+ * delete m_interface;
+ * }
+ *
+ * signals:
+ * void error ( const QString &msg );
+ * void warning ( const QString &msg );
+ * void output ( const QString &msg );
+ * void progress ( int percent );
+ * void done ( KScriptClientInterface::Result result, const QVariant &returned );
+ *
+ * public slots:
+ * void activate(const QVariant &args)
+ * {
+ * m_interface->run(parent(), args);
+ * }
+ *
+ * private:
+ *
+ * KScriptInterface *m_interface;
+ * };
+ * @endcode
+ * Things to note about this example are that it only handles a single script type and instance. You may wish to
+ * extend this.
+ **/
+
+ class KScriptClientInterface
+ {
+ public:
+ enum Result { ResultSuccess, ResultFailure, ResultContinue, ResultBreak };
+ /**
+ * This function will allow the main application of any errors
+ * that have occurred during processing of the script.
+ * For script clients its best to implement this as a signal so feedback
+ * can be sent to the main application.
+ */
+ virtual void error( const QString &msg ) =0;
+ /**
+ * This function will allow the main application of any warnings
+ * that have occurred during the processing of the script.
+ * For script clients its best to implement this as a signal so feedback
+ * can be sent to the main application.
+ */
+ virtual void warning( const QString &msg ) =0;
+ /**
+ * This function will allow the main application of any normal
+ * output that has occurred during the processing of the script.
+ * For script clients its best to implement this as a signal so feedback
+ * can be sent to the main application.
+ */
+ virtual void output( const QString &msg ) =0;
+ /**
+ * This function will allow feedback to any progress bars in the main
+ * application as to how far along the script is. This is very useful when
+ * a script is processing files or doing some long operation that is of a
+ * known duration.]
+ * For script clients its best to implement this as a signal so feedback
+ * can be sent to the main application.
+ */
+ virtual void progress( int percent ) =0;
+ /**
+ * This function will allow feedback on completion of the script.
+ * It turns the result as a KScriptInteface::Result, and a return
+ * value as a QVariant
+ * For script clients its best to implement this as a signal so feedback
+ * can be sent to the main application.
+ */
+ virtual void done( KScriptClientInterface::Result result, const QVariant &returned ) =0;
+ /**
+ * Returned when the script has finished running.
+ * For script clients its best to implement this as a signal so feedback
+ * can be sent to the main application.
+ **/
+ //virtual bool isRunning() =0;
+ };
+//};
+
+#endif
diff --git a/interfaces/kscript/scriptinterface.desktop b/interfaces/kscript/scriptinterface.desktop
new file mode 100644
index 000000000..8e157e20a
--- /dev/null
+++ b/interfaces/kscript/scriptinterface.desktop
@@ -0,0 +1,89 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KScriptRunner/KScriptRunner
+Comment=This is a generic test script engine for testing the script interface.
+Comment[af]=Hierdie is 'n generies toets skrip masjien vir toetsing die skrip koppelvlak.
+Comment[ar]=هذه آلة نصوص برمجية اختبارية لاختبار واجهة النص البرمجي.
+Comment[az]=Skript ara üzünü sınamaq üçün ümumi sınaq skriptidir.
+Comment[be]=Простая сістэма праверкі выканання сцэнараў.
+Comment[bg]=Модул за тестване на скриптове.
+Comment[bs]=Ovo je opšti engine za testiranje interfejsa skripti.
+Comment[ca]=Aquest és un enginy per a provar la interfície de l'script.
+Comment[cs]=Toto je obecný testovací skript pro testování skriptovacího rozhranní.
+Comment[csb]=Mòduł testowaniô skriptowegò interfejsu.
+Comment[cy]=Mae hyn yn beiriant sgript prawf generig i brofi y sgript rhyngwyneb.
+Comment[da]=Dette er en generisk testscript-maskine til at teste scriptgrænsefladen.
+Comment[de]=Dies ist eine allgemeine Sammlung von Testroutinen für die Skript-Schnittstelle.
+Comment[el]=Αυτό είναι μια γενική μηχανή ελέγχου σεναρίων για τον έλεγχο της διασύνδεσης σεναρίων.
+Comment[eo]=Tio estas testprogram-maŝino por testi la programinterfaco.
+Comment[es]=Este es un motor de script genérico para probar el interfaz de script.
+Comment[et]=Üldise skriptimootori testskript liidese testimiseks.
+Comment[eu]=Hau script motoreen proba generikoa da script-aren interfazea probatzeko.
+Comment[fa]=این یک موتور دست‌نوشتۀ آزمون عمومی برای آزمایش واسط دست‌نوشته می‌باشد.
+Comment[fi]=Tämä on yleinen skriptitestimoottori skriptin käyttöliittymän testaamiseen
+Comment[fo]=Hetta er ein almen royndarforritsskipan til at nároyna fjølvisforritsmarkamótið.
+Comment[fr]=Ceci est un moteur de script de test générique pour expérimenter l'interface de script.
+Comment[fy]=Dit is in algemiene samling testroutines foar it testen fan de skript-interface.
+Comment[ga]=Is inneall tástála cineálach scripteanna é seo a úsáidtear chun an comhéadan scripte a thástáil.
+Comment[gl]=Ésta é unha ferramenta para probar a interface dos guións.
+Comment[he]=זהו מנוע תסריטים כללי לבדיקת ממשק התסריטים
+Comment[hi]= स्क्रिप्ट इंटरफेस जांचने के लिए यह एक जेनरिक टेस्ट स्क्रिप्ट इंजन है.
+Comment[hr]=Ovo je generička ispitna skripta programa za ispitivanje sučelja skripte.
+Comment[hsb]=To je program za testowanje skript-interfejsa.
+Comment[hu]=Ez egy tesztszkript a szkript-felület kipróbálásához.
+Comment[id]=Mesin skrip tes generik untuk menguji antarmuka skrip
+Comment[is]=Þetta er almennur þýðandi til að prófa skriftuviðmótið.
+Comment[it]=Questo è un motore di script generico per provare l'interfaccia di script.
+Comment[ja]=これはスクリプトインターフェースをテストする一般的なテストスクリプトです。
+Comment[ka]=ეს ძრავი სკრიპტების ინტერფეისის შესამოწმებლად გამოიყენება
+Comment[kk]=Бұл скрипт интерфейсін сынауға арналған тетік.
+Comment[km]=នេះ​ជា0​ម៉ាស៊ីន​ស្គ្រីប​សាកល្បង​ទូទៅ​មួយ ដើម្បី​សាកល្បង​ចំណុច​ប្រទាក់​ស្គ្រីប ។
+Comment[ko]=스크립트 인터페이스를 시험하는데 쓰이는 일반 시험 스크립트 엔진입니다.
+Comment[lb]=Dësst ass eng allgemeng Test-Skript-Engine fir de Skript-Interface ze testen.
+Comment[lt]=Tai yra bendras testavimo scenarijų variklis skirtas scenarijų sąsajos testavimui.
+Comment[lv]=Šis ir vispārējs skriptu testa dzinējs skriptu saskarsmes virsmas testēšanai.
+Comment[mk]=Ова е општа тест-скрипта за тестирање на скриптниот интерфејс
+Comment[mn]=Энэ бол скриптын харьцах хэсгийн (interface) тестчилэлийн хувьд дахь ерөнхий тестийн горимын цуглуулга.
+Comment[ms]=Ini ialah enjin skrip uji generik untuk mencuba antaramuka skrip.
+Comment[mt]=Magna ġenerika biex tittestja l-interfaċċja tal-iskritti
+Comment[nb]=Dette er et generisk testskript for å teste skriptgrensesnitt.
+Comment[nds]=Dit is en allgemeen Koppel vun Testskripten för dat Pröven vun de Skript-Koppelsteed.
+Comment[ne]=स्क्रिप्ट इन्टरफेस परीक्षणका लागि यो एउटा जेनेरिक परीक्षण स्क्रिप्ट हो ।
+Comment[nl]= Dit is een algemene verzameling van testroutines voor het testen dan de script-interface.
+Comment[nn]=Dette er ein generell testskriptmotor for å prøva ut skriptgrensesnittet.
+Comment[nso]=Ye ke engine ya thswaelo ya teko ya kakaretso yeo e somiswago go leka sefahlego sa tshwaelo.
+Comment[pa]=ਇਹ ਇੱਕ ਸਕ੍ਰਿਪਟ ਇੰਟਰਫੇਸ ਨੂੰ ਜਾਂਚਣ ਲਈ ਇੱਕ ਸਧਾਰਨ ਜਾਂਚ ਇੰਜਣ ਹੈ।
+Comment[pl]=Moduł do testowania interfejsu skryptowego.
+Comment[pt]=Este é um motor de 'scripts' de teste para testar a interface de 'scripting'.
+Comment[pt_BR]=Este é um mecanismo de teste genérico para testar a interface de script.
+Comment[ro]=Acesta este un script de test generic pentru testarea interfeţei de scriptare.
+Comment[ru]=Этот движок предназначен для тестирования интерфейса скриптов.
+Comment[rw]=Iyi ni imashini rusange y'inyandikoporogaramu y'igerageza ikoreshwa mu kugerageza imigaragarire y'inyandikoporogaramu.
+Comment[se]=Dát lea oppalaš geahččalanskriptamohtor testendihte skriptalavtta
+Comment[sk]=Toto je generický testovací skript pre testovanie skriptovacieho rozhrania.
+Comment[sl]=To je generični poskusni skriptni pogon za preizkušanje skriptnega vmesnika.
+Comment[sr]=Ово је генерички програм за тестирање интерфејса скрипти.
+Comment[sr@Latn]=Ovo je generički program za testiranje interfejsa skripti.
+Comment[ss]=Lena yinjini yelibhuku leluhlolo lolubanti lekuhlola sichumanisi selibhuku.
+Comment[sv]=Det här är ett generellt skripttestprogram för att testa skriptgränssnittet
+Comment[ta]=எழுத்தாக்க இடைமுகத்தைச் சோதிக்க உதவும் ஒரு பொதுவான சோதனை இயந்திரம்.
+Comment[te]=ఇది స్క్రిప్ట్ ఇంటర్ఫెస్లను పరీక్షించెందుకు వాడె సాధరణ పరీక్షా స్క్రిప్ట్ ఇంజను
+Comment[tg]=Ин ҷрокунандаи скрипт интерфейси скрипт тафтиш мекунад.
+Comment[th]=นี่เป็นกลไกทดสอบสคริปต์ทั่วไป สำหรับทดสอบส่วนติดต่อสคริปต์
+Comment[tr]=Bu betik arayüzünü test etmek için bir genel test betik motorudur.
+Comment[tt]=Ämeklek yözarasın tikşerü öçen sınaw qoralı bu.
+Comment[uk]=Це - загальний рушій тестових скриптів для перевірки інтерфейсу скрипту.
+Comment[uz]=Skriptning interfeysini tekshirish uchun umumiy sinov skript boshqaruvchisi
+Comment[uz@cyrillic]=Скриптнинг интерфейсини текшириш учун умумий синов скрипт бошқарувчиси
+Comment[ven]=Heyi ndi inzhini ya bammbiri la mulingo lau linga vhuvha ha bammbiri.
+Comment[vi]=Đây là cơ chế tập lệnh thử ra giống loài để thử ra giao diện tập lệnh.
+Comment[wa]=Çouchal est on programe di saye po vey kimint rote l' eterface di scripes.
+Comment[xh]=Olu luvavanyo luka wonke-wonke lwenjini yokushicilelweyo yokuvavanya ujongano loshicilelo.
+Comment[zh_CN]=这是一个用于测试脚本接口的通用脚本测试引擎。
+Comment[zh_HK]=這是用來測試手稿介面用的一般性測試手稿引擎
+Comment[zh_TW]=這是用來測試手稿介面用的一般性測試手稿引擎
+Comment[zu]=Lena yinjini yesikripti sokuvivinya sawonke wonke yokuvivinya isikripti somxhumanisi.
+
+[PropertyDef::X-KDE-Script-Runner]
+Type=QString
+
diff --git a/interfaces/kscript/scriptinterface.h b/interfaces/kscript/scriptinterface.h
new file mode 100644
index 000000000..de387ecc6
--- /dev/null
+++ b/interfaces/kscript/scriptinterface.h
@@ -0,0 +1,88 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+/**
+* \section Generic interface for building scripting engines
+*
+* This interface will create a generic API for implementing script engines.
+* These engines can then be accessed from any application that supports this interface.
+*
+*
+**/
+#ifndef __scriptinterface_h__
+#define __scriptinterface_h__
+#include <qvariant.h>
+#include <qobject.h>
+#include <kdemacros.h>
+
+//#include <scripclientinterface.h>
+class QString;
+class QObject;
+class KScriptClientInterface;
+
+
+//namespace KScriptInterface
+//{
+ /**
+ * This class is the base for all script engines.
+ * @author Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ **/
+ class KDE_EXPORT KScriptInterface : public QObject
+ {
+ Q_OBJECT
+ public:
+ /**
+ * Return the current script code data
+ * @returns QString containing the currenly runable code
+ **/
+ virtual QString script() const = 0;
+ /**
+ * Sets the path to the script library that we are going to embed.
+ **/
+ virtual void setScript( const QString &scriptFile ) = 0;
+ /**
+ * Sets the path to the script library that we are going to embed.
+ * The second argument is the function from the script library that
+ * we wish to call.
+ **/
+ virtual void setScript( const QString &scriptLibFile, const QString &method ) = 0;
+ /**
+ * Run the actual script code
+ * This can both take a context object that will be shared between the
+ * main application and a variant that will contain the arguments.
+ **/
+ virtual void run(QObject *context = 0, const QVariant &arg = 0) = 0;
+ /**
+ * Abort the scripts run
+ **/
+ virtual void kill() =0;
+ public:
+ /**
+ * This is the method for sending feedback to applications.
+ * example of how this works:
+ * \code
+ * ScriptClientInterface->error( message_to_send_back_to_the_main_application );
+ * \endcode
+ * Will send the error message back to the main application.
+ **/
+ KScriptClientInterface *ScriptClientInterface;
+ };
+//};
+#endif
diff --git a/interfaces/kscript/scriptloader.cpp b/interfaces/kscript/scriptloader.cpp
new file mode 100644
index 000000000..6ab7e091c
--- /dev/null
+++ b/interfaces/kscript/scriptloader.cpp
@@ -0,0 +1,104 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#include "scriptloader.h"
+
+#include <kapplication.h>
+#include <kparts/part.h>
+#include <kparts/componentfactory.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <kdesktopfile.h>
+#include <kstandarsdirs.h>
+#include <kstdaccel.h>
+#include <kdebug.h>
+
+#include <qdir.h>
+#include <qfileinfo.h>
+
+
+ScriptLoader::ScriptLoader(KMainWindow *parent) : QObject (parent)
+{
+ m_parent = parent;
+ m_scripts.clear();
+ m_theAction = new KSelectAction ( i18n("KDE Scripts"),
+ 0,
+ this,
+ SLOT(runAction()),
+ m_parent->actionCollection(),
+ "scripts");
+}
+
+ScriptLoader::~ScriptLoader()
+{
+ // Clean out the list
+ m_scripts.clear();
+}
+
+KSelectAction * ScriptLoader::getScripts()
+{
+ // Get the available scripts for this application.
+ QStringList pluginList = "";
+ // Find plugins
+ QString searchPath = kapp->name();
+ searchPath += "/scripts/";
+ QDir d(locate( "data", searchPath));
+ kdDebug() << "loading plugin from " << locate( "data", searchPath) << endl;
+ const QFileInfoList *fileList = d.entryInfoList("*.desktop");
+ QFileInfoListIterator it ( *fileList );
+ QFileInfo *fi;
+ // Find all available script desktop files
+ while( (fi=it.current()))
+ {
+ // Query each desktop file
+ if(KDesktopFile::isDesktopFile(fi->absFilePath()))
+ {
+ KDesktopFile desktop((fi->absFilePath()), true);
+ kdDebug () << "Trying to load script type: " << desktop.readType() << endl;
+ KScriptInterface *tmpIface = KParts::ComponentFactory::createInstanceFromQuery<KScriptInterface>(desktop.readType() );
+ if( tmpIface != 0 )
+ {
+ m_scripts.append(tmpIface);
+ m_scripts.current()->setScript(desktop.readURL());
+ //if(m_parent != 0)
+ //m_scripts.current()->setParent(m_parent);
+ pluginList.append(desktop.readName());
+ }
+ else
+ kdDebug() << desktop.readName() << " could not be loaded!" << endl;
+ }
+ ++it;
+ }
+ m_theAction->clear();
+ m_theAction->setItems(pluginList);
+ return m_theAction;
+}
+
+void ScriptLoader::runAction()
+{
+ QString scriptName = m_theAction->currentText();
+
+}
+
+void ScriptLoader::stopAction()
+{
+
+}
+
+#include "scriptloader.moc"
diff --git a/interfaces/kscript/scriptloader.h b/interfaces/kscript/scriptloader.h
new file mode 100644
index 000000000..c6b2848de
--- /dev/null
+++ b/interfaces/kscript/scriptloader.h
@@ -0,0 +1,59 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef _script_loader_h
+#define _script_loader_h
+#include <qptrlist.h>
+#include <kmainwindow.h>
+#include <kaction.h>
+#include <kscript/scriptinterface.h>
+
+/**
+ * Script loader
+ */
+class ScriptLoader : virtual public QObject
+{
+ Q_OBJECT
+ public:
+ /**
+ * Default Constructor
+ */
+ ScriptLoader(KMainWindow *parent=0);
+ ~ScriptLoader();
+ /** Return the a KSelectAction with all of the scripts
+ * @returns KSelectAction containing access to all of the scripts
+ */
+ KSelectAction *getScripts();
+ public slots:
+ /** Run the current action.
+ */
+ void runAction();
+ /** Stop the currently running scripts operations
+ */
+ void stopAction();
+ signals:
+ virtual void errors(QString messages);
+ virtual void output(QString messages);
+ virtual void done(int errorCode);
+ private:
+ QPtrList<KScriptInterface> m_scripts;
+ KSelectAction *m_theAction;
+ int m_currentSelection;
+ KMainWindow *m_parent;
+};
+#endif
diff --git a/interfaces/kscript/scriptmanager.cpp b/interfaces/kscript/scriptmanager.cpp
new file mode 100644
index 000000000..48592e2cf
--- /dev/null
+++ b/interfaces/kscript/scriptmanager.cpp
@@ -0,0 +1,132 @@
+#include "scriptmanager.h"
+#include <kparts/part.h>
+#include <kparts/componentfactory.h>
+#include <kapplication.h>
+#include <kdesktopfile.h>
+#include <kstandarddirs.h>
+
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+
+//using namespace KScriptInterface;
+class ScriptInfo
+{
+ public:
+ QString scriptType;
+ QString scriptFile;
+ QString scriptMethod;
+ ScriptInfo();
+ ~ScriptInfo(){}
+};
+ScriptInfo::ScriptInfo()
+{
+ scriptType = "";
+ scriptFile = "";
+ scriptMethod = "";
+}
+KScriptManager::KScriptManager(QObject *parent, const char *name) :
+ QObject(parent,name), KScriptClientInterface()
+{
+
+}
+KScriptManager::~KScriptManager()
+{
+ m_scripts.setAutoDelete(true);
+ m_scriptCache.setAutoDelete(true);
+
+}
+bool KScriptManager::addScript( const QString &scriptDesktopFile)
+{
+ //m_scriptNames.append(scriptName);
+ // lets get some information about the script we are going to run...
+ bool success = false;
+ QString tmpScriptType = "";
+ QString tmpScriptFile = "";
+ QString tmpScriptMethod = "";
+ // Read the desktop file
+
+ if(KDesktopFile::isDesktopFile(scriptDesktopFile))
+ {
+ KDesktopFile desktop(scriptDesktopFile, true);
+ m_scripts.insert(desktop.readName(), new ScriptInfo());
+ m_scripts[desktop.readName()]->scriptType = desktop.readType();
+ QString localpath = QString(kapp->name()) + "/scripts/" + desktop.readEntry("X-KDE-ScriptName", "");
+ m_scripts[desktop.readName()]->scriptFile = locate("data", localpath);
+// m_scripts[desktop.readName()]->scriptMethod = tmpScriptMethod;
+ success = true;
+ }
+ return success;
+}
+bool KScriptManager::removeScript( const QString &scriptName )
+{
+ bool result = m_scriptCache.remove(scriptName);
+ result = m_scripts.remove(scriptName);
+ return result;
+}
+QStringList KScriptManager::scripts()
+{
+ QDictIterator<ScriptInfo> it( m_scripts );
+// return m_scriptNames;
+ QStringList scriptList;
+ while ( it.current() )
+ {
+ scriptList.append(it.currentKey());
+ ++it;
+ }
+ return scriptList;
+}
+void KScriptManager::clear()
+{
+ m_scriptCache.clear();
+ m_scripts.clear();
+}
+void KScriptManager::runScript( const QString &scriptName, QObject *context, const QVariant &arg)
+{
+ ScriptInfo *newScript = m_scripts[scriptName];
+ if (newScript)
+ {
+ QString scriptType = "([X-KDE-Script-Runner] == '" + newScript->scriptType + "')";
+ kdDebug()<<"running script, type = '"<<scriptType<<"'"<<endl;
+ // See if the script is already cached...
+ if ( !m_scriptCache[scriptName] )
+ {
+ // via some magic we will let the old script engine go away after
+ // some minutes...
+ // currently i am thinking a QTimer that will throw a signal in 10 minutes
+ // to remove m_scriptCache[m_currentScript]
+ KScriptInterface *ksif = KParts::ComponentFactory::createInstanceFromQuery<KScriptInterface>( "KScriptRunner/KScriptRunner", scriptType, this );
+ if ( ksif )
+ {
+ m_scriptCache.insert( scriptName, ksif );
+
+ }
+ else
+ {
+ KMessageBox::sorry(0, i18n("Unable to get KScript Runner for type \"%1\".").arg(newScript->scriptType), i18n("KScript Error"));
+ return;
+ }
+ }
+ m_currentScript = scriptName;
+
+ if ( m_scriptCache[m_currentScript] )
+ {
+ m_scriptCache[m_currentScript]->ScriptClientInterface = this;
+ if (!newScript->scriptMethod.isEmpty())
+ m_scriptCache[m_currentScript]->setScript( newScript->scriptFile, newScript->scriptMethod );
+ else
+ m_scriptCache[m_currentScript]->setScript( newScript->scriptFile );
+ m_scriptCache[m_currentScript]->run(context, arg);
+ }
+ else
+ {
+ // Dialog and say we cant go on...
+ // This is also a broken script so we need to remove it
+ m_scriptCache.remove(m_currentScript);
+ }
+ }
+ else
+ KMessageBox::sorry(0, i18n("Unable find script \"%1\".").arg(scriptName), i18n("KScript Error"));
+}
+#include "scriptmanager.moc"
+#include "scriptinterface.moc"
diff --git a/interfaces/kscript/scriptmanager.h b/interfaces/kscript/scriptmanager.h
new file mode 100644
index 000000000..8ace6dcff
--- /dev/null
+++ b/interfaces/kscript/scriptmanager.h
@@ -0,0 +1,139 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef __scriptmanager_h__
+#define __scriptmanager_h__
+
+#include <qvariant.h>
+#include <scriptclientinterface.h>
+#include <scriptinterface.h>
+#include <qdict.h>
+#include <qobject.h>
+
+#include <kdelibs_export.h>
+
+class ScriptInfo;
+//namespace KScriptInterface
+//{
+
+ /**
+ * This class is the base for all script engines.
+ * @author Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ **/
+ class KDE_EXPORT KScriptManager : public QObject, public KScriptClientInterface
+ {
+ Q_OBJECT
+ friend class KScriptInterface;
+ public:
+ /**
+ * Create a new instance of the script engine.
+ */
+ KScriptManager(QObject *parent, const char *name);
+ /**
+ * Destroy the current script engine.
+ */
+ virtual ~KScriptManager();
+ /**
+ * Add a new script instance to the script engine.
+ * This should be the full name and path to the desktop
+ * file.
+ */
+ bool addScript( const QString &scriptDesktopFile);
+ /**
+ * Remove a script instance from the script engine.
+ * @returns the success of the operation.
+ */
+ bool removeScript( const QString &scriptName );
+ /**
+ * Access the names of script instances from the script engine.
+ * @returns a QStringList of the current scripts.
+ */
+ QStringList scripts();
+ /**
+ * Clear all script intstances in memory
+ */
+ void clear();
+ /**
+ * This function will allow the main application of any errors
+ * that have occurred during processing of the script.
+ */
+ void error( const QString &msg ) {emit scriptError(msg);}
+ /**
+ * This function will allow the main application of any warnings
+ * that have occurred during the processing of the script.
+ */
+ void warning( const QString &msg ) {emit scriptWarning(msg);}
+ /**
+ * This function will allow the main application of any normal
+ * output that has occurred during the processing of the script.
+ */
+ void output( const QString &msg ) {emit scriptOutput(msg);}
+ /**
+ * This function will allow feedback to any progress bars in the main
+ * application as to how far along the script is. This is very useful when
+ * a script is processing files or doing some long operation that is of a
+ * known duration.
+ */
+ void progress( int percent ) {emit scriptProgress(percent);}
+ /**
+ * This function will allow feedback on completion of the script.
+ * It turns the result as a KScriptInteface::Result, and a return
+ * value as a QVariant
+ */
+ void done( KScriptClientInterface::Result result, const QVariant &returned ) {emit scriptDone(result, returned);}
+
+ public slots:
+ /**
+ * Run the selected script
+ */
+ void runScript( const QString &scriptName, QObject *context = 0, const QVariant &arg = 0 );
+ signals:
+ /**
+ * Send out a signal of the error message from the current running
+ * script.
+ */
+ void scriptError( const QString &msg );
+ /**
+ * Send out a signal of the warning message from the current running
+ * script.
+ */
+ void scriptWarning( const QString &msg );
+ /**
+ * Send out a signal of the output message from the current running
+ * script.
+ */
+ void scriptOutput( const QString &msg );
+ /**
+ * Send out a signal of the progress of the current running
+ * script.
+ */
+ void scriptProgress( int percent);
+ /**
+ * Send out a signal of the exit status of the script
+ *
+ */
+ void scriptDone( KScriptClientInterface::Result result, const QVariant &returned);
+ protected:
+ QDict<ScriptInfo> m_scripts;
+ QDict<KScriptInterface> m_scriptCache;
+ //QStringList m_scriptNames;
+ QString m_currentScript;
+ };
+//};
+#endif