summaryrefslogtreecommitdiffstats
path: root/interfaces/tdescript
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
commitdfe289850f068f19ba4a83ab4e7e22a7e09c13c9 (patch)
treec297348a55df66c571de4525646e0b9762427353 /interfaces/tdescript
parentb7658a0d5eca24a9d37c6e04f88298ef02389db0 (diff)
downloadtdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.tar.gz
tdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'interfaces/tdescript')
-rw-r--r--interfaces/tdescript/CMakeLists.txt56
-rw-r--r--interfaces/tdescript/Makefile.am21
-rw-r--r--interfaces/tdescript/README14
-rw-r--r--interfaces/tdescript/sample/CMakeLists.txt43
-rw-r--r--interfaces/tdescript/sample/Makefile.am13
-rw-r--r--interfaces/tdescript/sample/shellscript.cpp85
-rw-r--r--interfaces/tdescript/sample/shellscript.desktop153
-rw-r--r--interfaces/tdescript/sample/shellscript.h48
-rw-r--r--interfaces/tdescript/scriptclientinterface.h124
-rw-r--r--interfaces/tdescript/scriptinterface.desktop89
-rw-r--r--interfaces/tdescript/scriptinterface.h88
-rw-r--r--interfaces/tdescript/scriptloader.cpp104
-rw-r--r--interfaces/tdescript/scriptloader.h59
-rw-r--r--interfaces/tdescript/scriptmanager.cpp132
-rw-r--r--interfaces/tdescript/scriptmanager.h139
15 files changed, 1168 insertions, 0 deletions
diff --git a/interfaces/tdescript/CMakeLists.txt b/interfaces/tdescript/CMakeLists.txt
new file mode 100644
index 000000000..bcddb1068
--- /dev/null
+++ b/interfaces/tdescript/CMakeLists.txt
@@ -0,0 +1,56 @@
+#################################################
+#
+# (C) 2010 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_subdirectory( sample )
+
+include_directories(
+ ${TQT_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_BINARY_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}/tdeui
+ ${CMAKE_SOURCE_DIR}/kio
+ ${CMAKE_SOURCE_DIR}/kio/kio
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### headers ###################################
+
+install( FILES
+ scriptinterface.h scriptclientinterface.h scriptmanager.h
+ DESTINATION ${INCLUDE_INSTALL_DIR} )
+
+
+##### other data ################################
+
+install( FILES scriptinterface.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
+
+
+##### tdescript ###################################
+
+set( target tdescript )
+
+set( ${target}_SRCS
+ scriptmanager.cpp
+)
+
+tde_add_library( ${target} SHARED AUTOMOC
+ SOURCES ${${target}_SRCS}
+ VERSION 0.0.0
+ LINK kio-shared
+ DESTINATION ${LIB_INSTALL_DIR}
+)
diff --git a/interfaces/tdescript/Makefile.am b/interfaces/tdescript/Makefile.am
new file mode 100644
index 000000000..55d4cac35
--- /dev/null
+++ b/interfaces/tdescript/Makefile.am
@@ -0,0 +1,21 @@
+SUBDIRS = . sample
+
+INCLUDES = -I$(top_srcdir)/kio -I$(top_srcdir) -I$(srcdir) -I$(srcdir)/.. $(all_includes)
+
+#lib_LTLIBRARIES = libtdescriptloader.la libtdescript.la
+lib_LTLIBRARIES = libtdescript.la
+#libtdescriptloader_la_SOURCES = scriptloader.cpp
+#libtdescriptloader_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+#libtdescriptloader_la_LIBADD = $(LIB_KPARTS)
+
+libtdescript_la_SOURCES = scriptmanager.cpp
+libtdescript_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
+libtdescript_la_LIBADD = $(LIB_KIO) $(LIB_QT) $(LIB_TDECORE) $(LIB_TDEUI)
+
+tdescriptinclude_HEADERS = scriptinterface.h scriptclientinterface.h scriptmanager.h
+tdescriptincludedir = $(includedir)
+
+METASOURCES = AUTO
+
+servicetypedir = $(kde_servicetypesdir)
+servicetype_DATA = scriptinterface.desktop
diff --git a/interfaces/tdescript/README b/interfaces/tdescript/README
new file mode 100644
index 000000000..213a0c277
--- /dev/null
+++ b/interfaces/tdescript/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/tdescript/sample/CMakeLists.txt b/interfaces/tdescript/sample/CMakeLists.txt
new file mode 100644
index 000000000..46d031bff
--- /dev/null
+++ b/interfaces/tdescript/sample/CMakeLists.txt
@@ -0,0 +1,43 @@
+#################################################
+#
+# (C) 2010 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${TQT_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}/tdecore
+ ${CMAKE_SOURCE_DIR}/interfaces/tdescript
+ ${CMAKE_SOURCE_DIR}/dcop
+ ${CMAKE_SOURCE_DIR}/tdecore
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### other data ################################
+
+install( FILES shellscript.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+##### libshellscript ############################
+
+set( target libshellscript )
+
+set( ${target}_SRCS
+ shellscript.cpp
+)
+
+tde_add_kpart( ${target} AUTOMOC
+ SOURCES ${${target}_SRCS}
+ LINK tdescript-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/interfaces/tdescript/sample/Makefile.am b/interfaces/tdescript/sample/Makefile.am
new file mode 100644
index 000000000..77d39b28c
--- /dev/null
+++ b/interfaces/tdescript/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/tdescript $(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 = ../libtdescript.la $(LIB_QT) $(LIB_TDECORE) $(top_builddir)/dcop/libDCOP.la
+
+
+METASOURCES = AUTO
+
+servicetypedir = $(kde_servicesdir)
+servicetype_DATA = shellscript.desktop
diff --git a/interfaces/tdescript/sample/shellscript.cpp b/interfaces/tdescript/sample/shellscript.cpp
new file mode 100644
index 000000000..9ec34f7a2
--- /dev/null
+++ b/interfaces/tdescript/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 TQStringList & ) : ScriptClientInterface(parent)
+{
+ m_script = new TDEProcess();
+ connect ( m_script, TQT_SIGNAL(processExited(TDEProcess *)), TQT_SLOT(Exit(TDEProcess *)));
+ connect ( m_script, TQT_SIGNAL(receivedStdout(TDEProcess *, char *, int)), TQT_SLOT(stdOut(TDEProcess *, char *, int )));
+ connect ( m_script, TQT_SIGNAL(receivedStderr(TDEProcess *, char *, int)), TQT_SLOT(stdErr(TDEProcess *, char *, int )));
+ // Connect feedback signals and slots
+ //kdDebug() << "Building new script engine" << endl;
+}
+
+ShellScript::~ShellScript()
+{
+}
+
+TQString ShellScript::script() const
+{
+ return m_scriptName;
+}
+
+void ShellScript::setScript( const TQString &scriptFile )
+{
+ m_scriptName = scriptFile;
+ *m_script << "sh" << m_scriptName << kapp->dcopClient()->appId();
+}
+
+void ShellScript::setScript( const TQString &, const TQString & )
+{
+ // ### what is this?
+}
+
+void ShellScript::run(TQObject *, const TQVariant &)
+{
+ m_script->start(TDEProcess::NotifyOnExit,TDEProcess::All);
+}
+void ShellScript::kill()
+{
+ if (!m_script->kill()) // Kill the process
+ m_script->kill(9); // Kill it harder
+}
+
+void ShellScript::Exit(TDEProcess *proc)
+{
+ ScriptClientInterface->done((KScriptClientInterface::Result)proc->exitStatus(), "");
+}
+
+void ShellScript::stdErr(TDEProcess *, char *buffer, int)
+{
+ ScriptClientInterface->error(buffer);
+}
+void ShellScript::stdOut(TDEProcess *, char *buffer, int)
+{
+ ScriptClientInterface->output(buffer);
+}
+
+#include "shellscript.moc"
diff --git a/interfaces/tdescript/sample/shellscript.desktop b/interfaces/tdescript/sample/shellscript.desktop
new file mode 100644
index 000000000..e65713a3b
--- /dev/null
+++ b/interfaces/tdescript/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-TDE-Library=libshellscript
+X-TDE-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/tdescript/sample/shellscript.h b/interfaces/tdescript/sample/shellscript.h
new file mode 100644
index 000000000..2cdaf7e5a
--- /dev/null
+++ b/interfaces/tdescript/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 <tqvariant.h>
+#include <tqobject.h>
+#include <kprocess.h>
+//using namespace KScriptInterface;
+class ShellScript : public KScriptInterface
+{
+ Q_OBJECT
+public:
+ ShellScript(KScriptClientInterface *parent, const char *name, const TQStringList &args);
+ virtual ~ShellScript();
+ TQString script() const;
+ void setScript( const TQString &scriptFile );
+ void setScript( const TQString &scriptLibFile, const TQString &method );
+ void run(TQObject *context = 0, const TQVariant &arg = 0);
+ void kill();
+private slots:
+ void Exit(TDEProcess *proc);
+ void stdErr(TDEProcess *proc, char *buffer, int buflen);
+ void stdOut(TDEProcess *proc, char *buffer, int buflen);
+private:
+ TDEProcess *m_script;
+ KScriptClientInterface *ScriptClientInterface;
+ TQString m_scriptName;
+};
+
+#endif
diff --git a/interfaces/tdescript/scriptclientinterface.h b/interfaces/tdescript/scriptclientinterface.h
new file mode 100644
index 000000000..0f07d34b2
--- /dev/null
+++ b/interfaces/tdescript/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 <tqvariant.h>
+
+class TQString;
+
+//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 TQObject, public KScriptClientInterface {
+ * Q_OBJECT
+ * public:
+ *
+ * MyScript(TQObject *parent)
+ * {
+ * // Create your @ref KScriptInterface here.
+ * m_interface = KParts::ComponentFactory::createInstanceFromQuery<KScriptInterface>(
+ * "KScriptRunner/KScriptRunner", "([X-TDE-Script-Runner] == 'bash/shell')", this );
+ * }
+ *
+ * virtual ~KScriptAction()
+ * {
+ * delete m_interface;
+ * }
+ *
+ * signals:
+ * void error ( const TQString &msg );
+ * void warning ( const TQString &msg );
+ * void output ( const TQString &msg );
+ * void progress ( int percent );
+ * void done ( KScriptClientInterface::Result result, const TQVariant &returned );
+ *
+ * public slots:
+ * void activate(const TQVariant &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 TQString &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 TQString &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 TQString &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 TQVariant &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/tdescript/scriptinterface.desktop b/interfaces/tdescript/scriptinterface.desktop
new file mode 100644
index 000000000..397e650d8
--- /dev/null
+++ b/interfaces/tdescript/scriptinterface.desktop
@@ -0,0 +1,89 @@
+[Desktop Entry]
+Type=ServiceType
+X-TDE-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-TDE-Script-Runner]
+Type=TQString
+
diff --git a/interfaces/tdescript/scriptinterface.h b/interfaces/tdescript/scriptinterface.h
new file mode 100644
index 000000000..1c37b7f71
--- /dev/null
+++ b/interfaces/tdescript/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 <tqvariant.h>
+#include <tqobject.h>
+#include <kdemacros.h>
+
+//#include <scripclientinterface.h>
+class TQString;
+class TQObject;
+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 TQObject
+ {
+ Q_OBJECT
+ public:
+ /**
+ * Return the current script code data
+ * @returns TQString containing the currenly runable code
+ **/
+ virtual TQString script() const = 0;
+ /**
+ * Sets the path to the script library that we are going to embed.
+ **/
+ virtual void setScript( const TQString &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 TQString &scriptLibFile, const TQString &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(TQObject *context = 0, const TQVariant &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/tdescript/scriptloader.cpp b/interfaces/tdescript/scriptloader.cpp
new file mode 100644
index 000000000..79fa2055a
--- /dev/null
+++ b/interfaces/tdescript/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 <tdeparts/part.h>
+#include <tdeparts/componentfactory.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kconfig.h>
+#include <kdesktopfile.h>
+#include <kstandarsdirs.h>
+#include <kstdaccel.h>
+#include <kdebug.h>
+
+#include <tqdir.h>
+#include <tqfileinfo.h>
+
+
+ScriptLoader::ScriptLoader(KMainWindow *parent) : TQObject (parent)
+{
+ m_parent = parent;
+ m_scripts.clear();
+ m_theAction = new KSelectAction ( i18n("KDE Scripts"),
+ 0,
+ this,
+ TQT_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.
+ TQStringList pluginList = "";
+ // Find plugins
+ TQString searchPath = kapp->name();
+ searchPath += "/scripts/";
+ TQDir d(locate( "data", searchPath));
+ kdDebug() << "loading plugin from " << locate( "data", searchPath) << endl;
+ const QFileInfoList *fileList = d.entryInfoList("*.desktop");
+ QFileInfoListIterator it ( *fileList );
+ TQFileInfo *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()
+{
+ TQString scriptName = m_theAction->currentText();
+
+}
+
+void ScriptLoader::stopAction()
+{
+
+}
+
+#include "scriptloader.moc"
diff --git a/interfaces/tdescript/scriptloader.h b/interfaces/tdescript/scriptloader.h
new file mode 100644
index 000000000..a249283d6
--- /dev/null
+++ b/interfaces/tdescript/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 <tqptrlist.h>
+#include <kmainwindow.h>
+#include <kaction.h>
+#include <tdescript/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(TQString messages);
+ virtual void output(TQString messages);
+ virtual void done(int errorCode);
+ private:
+ TQPtrList<KScriptInterface> m_scripts;
+ KSelectAction *m_theAction;
+ int m_currentSelection;
+ KMainWindow *m_parent;
+};
+#endif
diff --git a/interfaces/tdescript/scriptmanager.cpp b/interfaces/tdescript/scriptmanager.cpp
new file mode 100644
index 000000000..cd20655d0
--- /dev/null
+++ b/interfaces/tdescript/scriptmanager.cpp
@@ -0,0 +1,132 @@
+#include "scriptmanager.h"
+#include <tdeparts/part.h>
+#include <tdeparts/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:
+ TQString scriptType;
+ TQString scriptFile;
+ TQString scriptMethod;
+ ScriptInfo();
+ ~ScriptInfo(){}
+};
+ScriptInfo::ScriptInfo()
+{
+ scriptType = "";
+ scriptFile = "";
+ scriptMethod = "";
+}
+KScriptManager::KScriptManager(TQObject *parent, const char *name) :
+ TQObject(parent,name), KScriptClientInterface()
+{
+
+}
+KScriptManager::~KScriptManager()
+{
+ m_scripts.setAutoDelete(true);
+ m_scriptCache.setAutoDelete(true);
+
+}
+bool KScriptManager::addScript( const TQString &scriptDesktopFile)
+{
+ //m_scriptNames.append(scriptName);
+ // lets get some information about the script we are going to run...
+ bool success = false;
+ TQString tmpScriptType = "";
+ TQString tmpScriptFile = "";
+ TQString 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();
+ TQString localpath = TQString(kapp->name()) + "/scripts/" + desktop.readEntry("X-TDE-ScriptName", "");
+ m_scripts[desktop.readName()]->scriptFile = locate("data", localpath);
+// m_scripts[desktop.readName()]->scriptMethod = tmpScriptMethod;
+ success = true;
+ }
+ return success;
+}
+bool KScriptManager::removeScript( const TQString &scriptName )
+{
+ bool result = m_scriptCache.remove(scriptName);
+ result = m_scripts.remove(scriptName);
+ return result;
+}
+TQStringList KScriptManager::scripts()
+{
+ TQDictIterator<ScriptInfo> it( m_scripts );
+// return m_scriptNames;
+ TQStringList scriptList;
+ while ( it.current() )
+ {
+ scriptList.append(it.currentKey());
+ ++it;
+ }
+ return scriptList;
+}
+void KScriptManager::clear()
+{
+ m_scriptCache.clear();
+ m_scripts.clear();
+}
+void KScriptManager::runScript( const TQString &scriptName, TQObject *context, const TQVariant &arg)
+{
+ ScriptInfo *newScript = m_scripts[scriptName];
+ if (newScript)
+ {
+ TQString scriptType = "([X-TDE-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 TQTimer 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/tdescript/scriptmanager.h b/interfaces/tdescript/scriptmanager.h
new file mode 100644
index 000000000..d21219901
--- /dev/null
+++ b/interfaces/tdescript/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 <tqvariant.h>
+#include <scriptclientinterface.h>
+#include <scriptinterface.h>
+#include <tqdict.h>
+#include <tqobject.h>
+
+#include <tdelibs_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 TQObject, public KScriptClientInterface
+ {
+ Q_OBJECT
+ friend class KScriptInterface;
+ public:
+ /**
+ * Create a new instance of the script engine.
+ */
+ KScriptManager(TQObject *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 TQString &scriptDesktopFile);
+ /**
+ * Remove a script instance from the script engine.
+ * @returns the success of the operation.
+ */
+ bool removeScript( const TQString &scriptName );
+ /**
+ * Access the names of script instances from the script engine.
+ * @returns a TQStringList of the current scripts.
+ */
+ TQStringList 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 TQString &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 TQString &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 TQString &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 TQVariant &returned ) {emit scriptDone(result, returned);}
+
+ public slots:
+ /**
+ * Run the selected script
+ */
+ void runScript( const TQString &scriptName, TQObject *context = 0, const TQVariant &arg = 0 );
+ signals:
+ /**
+ * Send out a signal of the error message from the current running
+ * script.
+ */
+ void scriptError( const TQString &msg );
+ /**
+ * Send out a signal of the warning message from the current running
+ * script.
+ */
+ void scriptWarning( const TQString &msg );
+ /**
+ * Send out a signal of the output message from the current running
+ * script.
+ */
+ void scriptOutput( const TQString &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 TQVariant &returned);
+ protected:
+ TQDict<ScriptInfo> m_scripts;
+ TQDict<KScriptInterface> m_scriptCache;
+ //TQStringList m_scriptNames;
+ TQString m_currentScript;
+ };
+//};
+#endif