diff options
Diffstat (limited to 'interfaces/kscript/sample')
-rw-r--r-- | interfaces/kscript/sample/Makefile.am | 13 | ||||
-rw-r--r-- | interfaces/kscript/sample/shellscript.cpp | 85 | ||||
-rw-r--r-- | interfaces/kscript/sample/shellscript.desktop | 153 | ||||
-rw-r--r-- | interfaces/kscript/sample/shellscript.h | 48 |
4 files changed, 299 insertions, 0 deletions
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 |