summaryrefslogtreecommitdiffstats
path: root/kommander/executor
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite9ae80694875f869892f13f4fcaf1170a00dea41 (patch)
treeaa2f8d8a217e2d376224c8d46b7397b68d35de2d /kommander/executor
downloadtdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz
tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kommander/executor')
-rw-r--r--kommander/executor/Makefile.am25
-rw-r--r--kommander/executor/dcopkommanderif.h82
-rw-r--r--kommander/executor/instance.cpp683
-rw-r--r--kommander/executor/instance.h137
-rw-r--r--kommander/executor/kmdr-executor.desktop82
-rw-r--r--kommander/executor/main.cpp102
-rw-r--r--kommander/executor/register.cpp104
-rw-r--r--kommander/executor/templates/cpp_template16
-rw-r--r--kommander/executor/templates/header_template16
9 files changed, 1247 insertions, 0 deletions
diff --git a/kommander/executor/Makefile.am b/kommander/executor/Makefile.am
new file mode 100644
index 00000000..7d9004fe
--- /dev/null
+++ b/kommander/executor/Makefile.am
@@ -0,0 +1,25 @@
+bin_PROGRAMS = kmdr-executor
+
+noinst_LTLIBRARIES = libinstance.la
+
+libinstance_la_SOURCES = instance.cpp dcopkommanderif.skel
+libinstance_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) -no-undefined
+
+
+kmdr_executor_SOURCES = main.cpp
+kmdr_executor_LDADD = libinstance.la $(top_builddir)/kommander/widget/libkommanderwidget.la $(top_builddir)/kommander/widgets/libkommanderwidgets.la $(top_builddir)/kommander/factory/libkommanderfactory.la $(LIB_KIO)
+
+#KDE_ICON = kmdr_executor
+
+appsdir = $(kde_appsdir)/.hidden
+apps_DATA = kmdr-executor.desktop
+
+AM_CPPFLAGS = -I$(top_srcdir)/kommander/plugin -I$(top_srcdir)/kommander/widgets -I$(top_srcdir)/kommander/widget -I$(top_srcdir)/kommander/factory $(all_includes)
+
+
+METASOURCES = AUTO
+
+# the library search path.
+kmdr_executor_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+
+noinst_HEADERS = dcopkommanderif.h
diff --git a/kommander/executor/dcopkommanderif.h b/kommander/executor/dcopkommanderif.h
new file mode 100644
index 00000000..3ee8a552
--- /dev/null
+++ b/kommander/executor/dcopkommanderif.h
@@ -0,0 +1,82 @@
+/***************************************************************************
+ dcopkommanderif.h - description
+ -------------------
+ begin : Tue Jan 27 2004
+ copyright : (C) 2004 by Andras Mantia <amantia@kde.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; version 2 of the License. *
+ * *
+ ***************************************************************************/
+
+#ifndef DCOPKOMMANDERIF_H
+#define DCOPKOMMANDERIF_H
+
+#include <dcopobject.h>
+#include <qstringlist.h>
+
+/* See widgets/specials.cpp for description. Deprecated methods are replaced by methods above. */
+
+class DCOPKommanderIf : virtual public DCOPObject
+{
+ K_DCOP
+
+ k_dcop:
+virtual void setEnabled(const QString& widgetName, bool enable) = 0;
+virtual void enableWidget(const QString& widgetName, bool enable) = 0; /* DEPRECATED */
+virtual void setVisible(const QString& widgetName, bool enable) = 0;
+virtual void setText(const QString& widgetName, const QString& text) = 0;
+virtual void changeWidgetText(const QString& widgetName, const QString& text) = 0; /* DEPRECATED */
+virtual QString text(const QString& widgetName) = 0;
+virtual void setSelection(const QString& widgetName, const QString& text) = 0;
+virtual void setCurrentListItem(const QString& widgetName, const QString& text) = 0; /* DEPRECATED */
+virtual QString selection(const QString& widgetName) = 0;
+virtual int currentItem(const QString &widgetName) = 0;
+virtual QString item(const QString &widgetName, int index) = 0;
+virtual int itemDepth(const QString &widgetName, int index) = 0;
+virtual QString itemPath(const QString &widgetName, int index) = 0;
+virtual void removeItem(const QString &widgetName, int index) = 0;
+virtual void removeListItem(const QString &widgetName, int index) = 0; /* DEPRECATED */
+virtual void insertItem(const QString &widgetName, const QString &item, int index) = 0;
+virtual void addListItem(const QString &widgetName, const QString &item, int index) = 0; /* DEPRECATED */
+virtual void setPixmap(const QString &widgetName, const QString &iconName, int index) = 0;
+virtual void insertItems(const QString &widgetName, const QStringList &items, int index) = 0;
+virtual void addListItems(const QString &widgetName, const QStringList &items, int index) = 0;/*DEPRECATED*/
+virtual void addUniqueItem(const QString &widgetName, const QString &item) = 0;
+virtual int findItem(const QString &widgetName, const QString &item) = 0;
+virtual void clear(const QString &widgetName) = 0;
+virtual void clearList(const QString &widgetName) = 0; /* DEPRECATED */
+virtual void setCurrentItem(const QString &widgetName, int index) = 0;
+virtual void setCurrentTab(const QString &widgetName, int index) = 0; /* DEPRECATED */
+virtual void insertTab(const QString &widgetName, const QString &label, int index) = 0;
+virtual bool checked(const QString &widgetName) = 0;
+virtual void setChecked(const QString &widgetName, bool checked) = 0;
+virtual void setAssociatedText(const QString &widgetName, const QString &text) = 0;
+virtual QStringList associatedText(const QString &widgetName) = 0;
+virtual QString type(const QString& widget) = 0;
+virtual QStringList children(const QString& parent, bool recursive) = 0;
+virtual QString global(const QString& variableName) = 0;
+virtual void setGlobal(const QString& variableName, const QString& value) = 0;
+virtual void setMaximum(const QString &widgetName, int value) = 0;
+virtual QString execute(const QString &widgetName) = 0;
+virtual void cancel(const QString &widgetName) = 0;
+virtual int count(const QString &widgetName) = 0;
+virtual int currentColumn(const QString &widgetName) = 0;
+virtual int currentRow(const QString &widgetName) = 0;
+virtual void insertRow(const QString &widgetName, int row, int count) = 0;
+virtual void insertColumn(const QString &widgetName, int column, int count) = 0;
+virtual void setCellText(const QString &widgetName, int row, int column, const QString& text) = 0;
+virtual QString cellText(const QString &widgetName, int row, int column) = 0;
+virtual void removeRow(const QString &widgetName, int row, int count) = 0;
+virtual void removeColumn(const QString &widgetName, int column, int count) = 0;
+virtual void setRowCaption(const QString &widgetName, int row, const QString& text) = 0;
+virtual void setColumnCaption(const QString &widgetName, int column, const QString& text) = 0;
+virtual int getWinID() = 0;
+virtual void setBusyCursor(bool busy) = 0;
+};
+
+#endif
diff --git a/kommander/executor/instance.cpp b/kommander/executor/instance.cpp
new file mode 100644
index 00000000..2ff4edfd
--- /dev/null
+++ b/kommander/executor/instance.cpp
@@ -0,0 +1,683 @@
+/***************************************************************************
+ instance.cpp - running instance of a dialog
+ -------------------
+ begin : Tue Aug 13 2002
+ copyright : (C) 2002 by Marc Britton <consume@optushome.com.au>
+ (C) 2004 by Andras Mantia <amantia@kde.org>
+ (C) 2004 by Michal Rudolf <mrudolf@kdewebdev.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+ /* KDE INCLUDES */
+#include <kapplication.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+
+/* QT INCLUDES */
+#include <qdialog.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qiodevice.h>
+#include <qlabel.h>
+#include <qmainwindow.h>
+#include <qobjectlist.h>
+#include <qstring.h>
+#include <qtabwidget.h>
+#include <qwidget.h>
+#include <qcursor.h>
+
+/* OTHER INCLUDES */
+#include "instance.h"
+#include "kommanderwidget.h"
+#include "kommanderwindow.h"
+#include "kommanderfactory.h"
+#include "kommanderversion.h"
+#include "specials.h"
+#include "specialinformation.h"
+#include "fileselector.h"
+
+Instance::Instance()
+ : DCOPObject("KommanderIf"), m_instance(0), m_textInstance(0), m_parent(0)
+{
+ SpecialInformation::registerSpecials();
+}
+
+Instance::Instance(QWidget *a_parent)
+ : DCOPObject("KommanderIf"), m_instance(0), m_textInstance(0),
+ m_parent(a_parent)
+{
+ SpecialInformation::registerSpecials();
+}
+
+void Instance::addCmdlineArguments(const QStringList& args)
+{
+ if (!m_textInstance)
+ return;
+ // Filter out variable arguments ('var=value')
+ QStringList stdArgs;
+ for (QStringList::ConstIterator it = args.begin(); it != args.end(); ++it)
+ {
+ int pos = (*it).find('=');
+ if (pos != -1)
+ m_textInstance->setGlobal((*it).left(pos), (*it).mid(pos+1));
+ else
+ stdArgs.append(*it);
+ }
+ int i = 0;
+ for (QStringList::ConstIterator it = stdArgs.begin(); it != stdArgs.end(); ++it)
+ m_textInstance->setGlobal(QString("_ARG%1").arg(++i), *it);
+ m_textInstance->setGlobal("_ARGS", stdArgs.join(" "));
+ m_textInstance->setGlobal("_ARGCOUNT", QString::number(stdArgs.count()));
+}
+
+
+
+Instance::~Instance()
+{
+ delete m_instance;
+}
+
+/** Builds the instance */
+bool Instance::build(const KURL& fname)
+{
+ delete m_instance;
+ m_instance = 0;
+ m_textInstance = 0;
+
+ if (!fname.isValid() || !isFileValid(fname))
+ return false; // Check if file is correct
+
+ // create the main instance, must inherit QDialog
+ KommanderFactory::loadPlugins();
+
+ if (fname.isValid())
+ m_instance = KommanderFactory::create(fname.path(), 0L, dynamic_cast<QWidget*>(parent()));
+ else
+ {
+ QFile inputFile;
+ inputFile.open(IO_ReadOnly, stdin);
+ m_instance = KommanderFactory::create(&inputFile);
+ }
+
+ // check if build was successful
+ if (!m_instance)
+ {
+ KMessageBox::sorry(0, i18n("<qt>Unable to create dialog.</qt>"));
+ return false;
+ }
+
+ KommanderWindow* window = dynamic_cast<KommanderWindow*>((QWidget*)m_instance);
+ if (window)
+ window->setFileName(fname.path().local8Bit());
+
+ // FIXME : Should verify that all of the widgets in the dialog derive from KommanderWidget
+ m_textInstance = kommanderWidget(m_instance);
+
+ if (!m_textInstance) // Main dialog/window is not a Kommander widget - look for one
+ {
+ if (m_instance)
+ {
+ QObjectList* widgets = m_instance->queryList();
+ for (QObject* w = widgets->first(); w; w = widgets->next())
+ if (kommanderWidget(w))
+ {
+ m_textInstance = kommanderWidget(w);
+ break;
+ }
+ }
+ if (!m_textInstance)
+ {
+ qDebug("Warning: no Kommander widget present!");
+ return true;
+ }
+ }
+
+ if (fname.isValid())
+ {
+ m_textInstance->setGlobal("KDDIR", fname.directory());
+ m_textInstance->setGlobal("NAME", fname.fileName());
+ m_textInstance->setGlobal("_PID", QString().setNum(getpid()));
+ m_textInstance->setGlobal("VERSION", KOMMANDER_VERSION);
+ }
+ return true;
+}
+
+bool Instance::run()
+{
+ if (!isBuilt())
+ return false;
+
+ // Handle both dialogs and main windows
+ if (m_instance->inherits("QDialog"))
+ dynamic_cast<QDialog*>((QWidget*)m_instance)->exec();
+ else if (m_instance->inherits("QMainWindow"))
+ {
+ kapp->setMainWidget(m_instance);
+ dynamic_cast<QMainWindow*>((QWidget*)m_instance)->show();
+ kapp->exec();
+ }
+ else return false;
+ return true;
+}
+
+bool Instance::isBuilt() const
+{
+ return m_instance;
+}
+
+void Instance::setParent(QWidget *a_parent)
+{
+ m_parent = a_parent;
+}
+
+bool Instance::isFileValid(const KURL& fname) const
+{
+ if (!QFileInfo(fname.path()).exists())
+ {
+ KMessageBox::sorry(0, i18n("<qt>Kommander file<br><b>%1</b><br>does not "
+ "exist.</qt>").arg(fname.path()));
+ return false;
+ }
+
+ // Check whether extension is *.kmdr
+ if (!fname.fileName().endsWith(".kmdr"))
+ {
+ KMessageBox::error(0, i18n("<qt>This file does not have a <b>.kmdr</b> extension. As a security precaution "
+ "Kommander will only run Kommander scripts with a clear identity.</qt>"),
+ i18n("Wrong Extension"));
+ return false;
+ }
+
+ // Check whether file is not in some temporary directory.
+ QStringList tmpDirs = KGlobal::dirs()->resourceDirs("tmp");
+ tmpDirs += KGlobal::dirs()->resourceDirs("cache");
+ tmpDirs.append("/tmp/");
+ tmpDirs.append("/var/tmp/");
+
+ bool inTemp = false;
+ for (QStringList::ConstIterator I = tmpDirs.begin(); I != tmpDirs.end(); ++I)
+ if (fname.directory(false).startsWith(*I))
+ inTemp = true;
+
+ if (inTemp)
+ {
+ if (KMessageBox::warningContinueCancel(0, i18n("<qt>This dialog is running from your <i>/tmp</i> directory. "
+ " This may mean that it was run from a KMail attachment or from a webpage. "
+ "<p>Any script contained in this dialog will have write access to all of your home directory; "
+ "<b>running such dialogs may be dangerous: </b>"
+ "<p>are you sure you want to continue?</qt>"), QString(), i18n("Run Nevertheless")) == KMessageBox::Cancel)
+ return false;
+ }
+ if (!QFileInfo(fname.path()).isExecutable())
+ {
+ if (KMessageBox::warningContinueCancel(0, i18n("<qt>The Kommander file <i>%1</i> does not have the <b>executable attribute</b> set and could possibly contain dangerous exploits.<p>If you trust the scripting (viewable in kmdr-editor) in this program, make it executable to get rid of this warning.<p>Are you sure you want to continue?</qt>").arg(fname.pathOrURL()), QString(), i18n("Run Nevertheless")) == KMessageBox::Cancel)
+ return false;
+ }
+ return true;
+}
+
+
+
+
+
+// Widget functions
+void Instance::setEnabled(const QString& widgetName, bool enable)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (child && child->inherits("QWidget"))
+ ((QWidget*)child)->setEnabled(enable);
+}
+
+void Instance::setVisible(const QString& widgetName, bool visible)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (child && child->inherits("QWidget"))
+ ((QWidget*)child)->setShown(visible);
+}
+
+void Instance::setText(const QString& widgetName, const QString& text)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->handleDCOP(DCOP::setText, text);
+ else if (child && child->inherits("QLabel"))
+ {
+ QLabel* label = (QLabel*)child;
+ if (label->pixmap())
+ {
+ QPixmap pixmap;
+ if (pixmap.load(text))
+ label->setPixmap(pixmap);
+ }
+ else
+ label->setText(text);
+ }
+}
+
+QString Instance::text(const QString& widgetName)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::text);
+ else if (child && child->inherits("QLabel"))
+ return ((QLabel*)child)->text();
+ return QString();
+}
+
+void Instance::setSelection(const QString& widgetName, const QString& text)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->handleDCOP(DCOP::setSelection, text);
+ else if (child && child->inherits("QLabel"))
+ ((QLabel*)child)->setText(text);
+}
+
+QString Instance::selection(const QString& widgetName)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::selection);
+ return QString();
+}
+
+int Instance::currentItem(const QString &widgetName)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::currentItem).toInt();
+ return -1;
+}
+
+QString Instance::item(const QString &widgetName, int i)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::item, QString::number(i));
+ return QString();
+}
+
+void Instance::removeItem(const QString &widgetName, int index)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->handleDCOP(DCOP::removeItem, QString::number(index));
+}
+
+void Instance::insertItem(const QString &widgetName, const QString &item, int index)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ {
+ QStringList args(item);
+ args += QString::number(index);
+ kommanderWidget(child)->handleDCOP(DCOP::insertItem, args);
+ }
+}
+
+void Instance::insertItems(const QString &widgetName, const QStringList &items, int index)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ {
+ QStringList args(items.join("\n"));
+ args += QString::number(index);
+ kommanderWidget(child)->handleDCOP(DCOP::insertItems, args);
+ }
+}
+
+int Instance::findItem(const QString &widgetName, const QString& item)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::findItem, item).toInt();
+ return -1;
+}
+
+void Instance::addUniqueItem(const QString &widgetName, const QString &item)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->handleDCOP(DCOP::addUniqueItem, item);
+}
+
+int Instance::itemDepth(const QString &widgetName, int index)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::itemDepth, QString::number(index)).toInt();
+ return -1;
+}
+
+QString Instance::itemPath(const QString &widgetName, int index)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::itemPath, QString::number(index));
+ return QString();
+}
+
+
+void Instance::setPixmap(const QString &widgetName, const QString& iconName, int index)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ {
+ QStringList args(iconName);
+ args += QString::number(index);
+ kommanderWidget(child)->handleDCOP(DCOP::setPixmap, args);
+ }
+}
+
+void Instance::clear(const QString &widgetName)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->handleDCOP(DCOP::clear);
+}
+
+void Instance::setCurrentItem(const QString &widgetName, int index)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->handleDCOP(DCOP::setCurrentItem, QString::number(index));
+}
+
+void Instance::setChecked(const QString &widgetName, bool checked)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->handleDCOP(DCOP::setChecked, checked ? "true" : "false");
+}
+
+bool Instance::checked(const QString &widgetName)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::checked, widgetName) == "1";
+ return false;
+}
+
+void Instance::setAssociatedText(const QString &widgetName, const QString& text)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->setAssociatedText(QStringList::split('\n', text, true));
+}
+
+QStringList Instance::associatedText(const QString &widgetName)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->associatedText();
+ return QString();
+}
+
+QString Instance::type(const QString& widget)
+{
+ QObject* child = stringToWidget(widget);
+ if (child && child->inherits("QWidget"))
+ return child->className();
+ return QString();
+}
+
+QStringList Instance::children(const QString& parent, bool recursive)
+{
+ QStringList matching;
+ QObject* child = stringToWidget(parent);
+ QObjectList* widgets;
+ if (!child)
+ child = m_instance;
+ if (child->inherits("QWidget"))
+ {
+ widgets = child->queryList("QWidget", 0, false, recursive);
+ for (QObject* w = widgets->first(); w; w = widgets->next())
+ if (w->name() && kommanderWidget(w))
+ matching.append(w->name());
+ }
+ return matching;
+}
+
+void Instance::setMaximum(const QString &widgetName, int value)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->handleDCOP(DCOP::setMaximum, QString::number(value));
+}
+
+QString Instance::execute(const QString &widgetName)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::execute);
+ return "";
+}
+
+void Instance::cancel(const QString &widgetName)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->handleDCOP(DCOP::cancel);
+}
+
+int Instance::count(const QString &widgetName)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::count).toInt();
+ return -1;
+}
+
+int Instance::currentColumn(const QString &widgetName)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::currentColumn).toInt();
+ return -1;
+}
+
+int Instance::currentRow(const QString &widgetName)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ return kommanderWidget(child)->handleDCOP(DCOP::currentRow).toInt();
+ return -1;
+}
+
+void Instance::insertRow(const QString &widgetName, int row, int count)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ {
+ QStringList args(QString::number(row));
+ args += QString::number(count);
+ kommanderWidget(child)->handleDCOP(DCOP::insertRow, args);
+ }
+}
+
+void Instance::insertColumn(const QString &widgetName, int column, int count)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ {
+ QStringList args(QString::number(column));
+ args += QString::number(count);
+ kommanderWidget(child)->handleDCOP(DCOP::insertColumn, args);
+ }
+}
+
+void Instance::setCellText(const QString &widgetName, int row, int column, const QString& text)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ {
+ QStringList args(QString::number(row));
+ args += QString::number(column);
+ args += text;
+ kommanderWidget(child)->handleDCOP(DCOP::setCellText, args);
+ }
+}
+
+QString Instance::cellText(const QString &widgetName, int row, int column)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ {
+ QStringList args(QString::number(row));
+ args += QString::number(column);
+ return kommanderWidget(child)->handleDCOP(DCOP::cellText, args);
+ }
+ else return QString();
+}
+
+void Instance::removeRow(const QString &widgetName, int row, int count)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ {
+ QStringList args(QString::number(row));
+ args += QString::number(count);
+ kommanderWidget(child)->handleDCOP(DCOP::removeRow, args);
+ }
+}
+
+void Instance::removeColumn(const QString &widgetName, int column, int count)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ {
+ QStringList args(QString::number(column));
+ args += QString::number(count);
+ kommanderWidget(child)->handleDCOP(DCOP::removeColumn, args);
+ }
+}
+
+void Instance::setRowCaption(const QString &widgetName, int row, const QString& text)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ {
+ QStringList args(QString::number(row));
+ args += text;
+ kommanderWidget(child)->handleDCOP(DCOP::setRowCaption, args);
+ }
+}
+
+void Instance::setColumnCaption(const QString &widgetName, int column, const QString& text)
+{
+ QObject* child = stringToWidget(widgetName);
+ if (kommanderWidget(child))
+ {
+ QStringList args(QString::number(column));
+ args += text;
+ kommanderWidget(child)->handleDCOP(DCOP::setColumnCaption, args);
+ }
+}
+
+
+
+
+
+
+
+
+
+
+QString Instance::global(const QString& variableName)
+{
+ return m_textInstance ? m_textInstance->global(variableName) : QString();
+}
+
+void Instance::setGlobal(const QString& variableName, const QString& value)
+{
+ if (m_textInstance)
+ m_textInstance->setGlobal(variableName, value);
+}
+
+QObject* Instance::stringToWidget(const QString& name)
+{
+ return m_instance->child(name);
+}
+
+KommanderWidget* Instance::kommanderWidget(QObject* object)
+{
+ return dynamic_cast<KommanderWidget*>(object);
+}
+
+
+/*** Deprecated methods: just call appropriate method ***/
+void Instance::changeWidgetText(const QString& widgetName, const QString& text)
+{
+ setText(widgetName, text);
+}
+
+void Instance::clearList(const QString &widgetName)
+{
+ clear(widgetName);
+}
+
+void Instance::setCurrentListItem(const QString& widgetName, const QString& item)
+{
+ setSelection(widgetName, item);
+}
+
+void Instance::setCurrentTab(const QString &widgetName, int index)
+{
+ setCurrentItem(widgetName, index);
+}
+
+void Instance::insertTab(const QString &widgetName, const QString &label, int index)
+{
+ QObject* child = stringToWidget(widgetName);
+ QStringList l;
+ l << label;
+ l << QString::number(index);
+ if (kommanderWidget(child))
+ kommanderWidget(child)->handleDCOP(DCOP::insertTab, l);
+}
+
+void Instance::addListItems(const QString &widgetName, const QStringList &items, int index)
+{
+ insertItems(widgetName, items, index);
+}
+
+void Instance::enableWidget(const QString& widgetName, bool enable)
+{
+ setEnabled(widgetName, enable);
+}
+
+void Instance::removeListItem(const QString &widgetName, int index)
+{
+ removeItem(widgetName, index);
+}
+
+void Instance::addListItem(const QString & widgetName, const QString & item, int index)
+{
+ insertItem(widgetName, item, index);
+}
+
+int Instance::getWinID()
+{
+ return m_instance->winId();
+}
+
+void Instance::setBusyCursor(bool busy)
+{
+ if (busy)
+ m_instance->setCursor(QCursor(Qt::WaitCursor));
+ else
+ m_instance->setCursor(QCursor(Qt::ArrowCursor));
+}
+
+
+#include "instance.moc"
diff --git a/kommander/executor/instance.h b/kommander/executor/instance.h
new file mode 100644
index 00000000..66b97455
--- /dev/null
+++ b/kommander/executor/instance.h
@@ -0,0 +1,137 @@
+/***************************************************************************
+ instance.h - description
+ -------------------
+ begin : Tue Aug 13 2002
+ copyright : (C) 2002 by Marc Britton <consume@optushome.com.au>
+ (C) 2004 by Andras Mantia <amantia@kde.org>
+ (C) 2004 by Michal Rudolf <mrudolf@kdewebdev.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef INSTANCE_H
+#define INSTANCE_H
+
+/* QT INCLUDES */
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qobject.h>
+#include <qmap.h>
+#include <qguardedptr.h>
+
+/* KDE INCLUDES */
+#include <kurl.h>
+
+/* OTHER INCLUDES */
+#include "dcopkommanderif.h"
+
+/* FORWARD DECLARATIONS */
+class QWidget;
+class QDialog;
+class QFile;
+class KommanderWidget;
+
+
+
+class Instance : public QObject, virtual public DCOPKommanderIf
+{
+ Q_OBJECT
+
+public:
+ Instance();
+ Instance(QWidget*);
+ ~Instance();
+ /* passing global variables: two forms are accepted.
+ kdmr-executor file.kmdr COUNT=45 PATH=/tmp - this adds global variables 45 and PATH
+ kmdr-executor file.kmdr 45 /tmp - this adds global variables ARG1 and ARG2
+ ARGS holds space-separated list of all second-type variables (like Bash $@)
+ ARGCOUNT holds number of second-type arguments
+ */
+ virtual void addCmdlineArguments(const QStringList& args);
+
+ //DCOP methods. The documentation is in the widgets/specials.cpp file.
+ virtual void setEnabled(const QString& widgetName, bool enable);
+ virtual void enableWidget(const QString& widgetName, bool enable); /* DEPRECATED */
+ virtual void setVisible(const QString& widgetName, bool enable);
+ virtual void setText(const QString& widgetName, const QString& text);
+ virtual void changeWidgetText(const QString& widgetName, const QString& text); /* DEPRECATED */
+ virtual QString text(const QString& widgetName);
+ virtual void setSelection(const QString& widgetName, const QString& text);
+ virtual void setCurrentListItem(const QString& widgetName, const QString& text); /* DEPRECATED */
+ virtual QString selection(const QString& widgetName);
+ virtual int currentItem(const QString &widgetName);
+ virtual QString item(const QString &widgetName, int index);
+ virtual int itemDepth(const QString &widgetName, int index);
+ virtual QString itemPath(const QString &widgetName, int index);
+ virtual void removeItem(const QString &widgetName, int index);
+ virtual void removeListItem(const QString &widgetName, int index); /* DEPRECATED */
+ virtual void insertItem(const QString &widgetName, const QString &item, int index);
+ virtual void addListItem(const QString &widgetName, const QString &item, int index); /* DEPRECATED */
+ virtual void setPixmap(const QString &widgetName, const QString &iconName, int index);
+ virtual void insertItems(const QString &widgetName, const QStringList &items, int index);
+ virtual void addListItems(const QString &widgetName, const QStringList &items, int index);/*DEPRECATED*/
+ virtual void addUniqueItem(const QString &widgetName, const QString &item);
+ virtual int findItem(const QString &widgetName, const QString &item);
+ virtual void clear(const QString &widgetName);
+ virtual void clearList(const QString &widgetName); /* DEPRECATED */
+ virtual void setCurrentItem(const QString &widgetName, int index);
+ virtual void setCurrentTab(const QString &widgetName, int index); /* DEPRECATED */
+ virtual void insertTab(const QString &widgetName, const QString &label, int index);
+ virtual void setChecked(const QString &widgetName, bool checked);
+ virtual bool checked(const QString &widgetName);
+ virtual void setAssociatedText(const QString &widgetName, const QString &text);
+ virtual QStringList associatedText(const QString &widgetName);
+ virtual QString type(const QString& widget);
+ virtual QStringList children(const QString& parent, bool recursive);
+ virtual QString global(const QString& variableName);
+ virtual void setGlobal(const QString& variableName, const QString& value);
+ virtual void setMaximum(const QString &widgetName, int value);
+ virtual QString execute(const QString &widgetName);
+ virtual void cancel(const QString &widgetName);
+ virtual int count(const QString &widgetName);
+ virtual int currentColumn(const QString &widgetName);
+ virtual int currentRow(const QString &widgetName);
+ virtual void insertRow(const QString &widgetName, int row, int count);
+ virtual void insertColumn(const QString &widgetName, int column, int count);
+ virtual void setCellText(const QString &widgetName, int row, int column, const QString& text);
+ virtual QString cellText(const QString &widgetName, int row, int column);
+ virtual void removeRow(const QString &widgetName, int row, int count);
+ virtual void removeColumn(const QString &widgetName, int column, int count);
+ virtual void setRowCaption(const QString &widgetName, int row, const QString& text);
+ virtual void setColumnCaption(const QString &widgetName, int column, const QString& text);
+ virtual int getWinID();
+ virtual void setBusyCursor(bool busy);
+ QWidget *widget() { return m_instance;}
+
+public slots:
+ /** Sets the instance's parent */
+ void setParent(QWidget*);
+ /** Returns whether the instance is built */
+ bool isBuilt() const;
+ /** Builds the instance. Uses stdin if no filename is given */
+ bool build(const KURL& fname);
+ /** Executes the instance which was built before */
+ bool run();
+private:
+ /** Check if the file exists, has correct extension and is not in a temporary (insecure) directory */
+ bool isFileValid(const KURL& fname) const;
+ /* Dialog Instance */
+ QGuardedPtr<QWidget> m_instance;
+ /* Associated Text Instance */
+ KommanderWidget *m_textInstance;
+ /** The parent widget */
+ QWidget *m_parent;
+ /* Get object by name */
+ QObject* stringToWidget(const QString& name);
+ /* Cast to Kommander widget if possible */
+ KommanderWidget* kommanderWidget(QObject* object);
+};
+
+#endif
diff --git a/kommander/executor/kmdr-executor.desktop b/kommander/executor/kmdr-executor.desktop
new file mode 100644
index 00000000..88489c68
--- /dev/null
+++ b/kommander/executor/kmdr-executor.desktop
@@ -0,0 +1,82 @@
+# KDE Config File
+[Desktop Entry]
+Type=Application
+Exec=kmdr-executor %F
+Icon=kommander
+Comment=Executor for Kommander dialogs
+Comment[bg]=Изпълнение на диалогови прозорци
+Comment[ca]=Executor per a diàlegs de Kommander
+Comment[cs]=Spouštěč dialogů Kommanderu
+Comment[da]=Udfører Kommanders dialoger
+Comment[de]=Stellt Kommander-Dialoge dar
+Comment[el]=Εκτελεστής για διαλόγους Kommander
+Comment[en_GB]=Executor for Kommander dialogues
+Comment[es]=Lanzador de cuadros de diálogo de Kommander
+Comment[et]=Kommanderi dialoogide rakendaja
+Comment[eu]=Kommander-en elkarrizketen exekutatzailea
+Comment[fa]=مجری محاوره‌های Kommander
+Comment[fi]=Komentodialogien rakentaja
+Comment[fr]=Exécuteur de boîtes de dialogue de Kommander
+Comment[gl]=Executor para os diálogos de Kommander
+Comment[hi]=कमांडर संवादों हेतु कार्यपालक
+Comment[hu]=Megjelenítőprogram Kommander-párbeszédablakokhoz
+Comment[is]=Executor fyrir Kommander glugga
+Comment[it]=Esecutore per maschere di Kommander
+Comment[ja]=Kommander ダイアログ用の Executor
+Comment[ka]=Kommander-ის დიალოგის შემსრულებელნი
+Comment[lt]=Kommander dialogų vykdyklė
+Comment[ms]=Pelaksana untuk dialog Kommander
+Comment[nds]=Föhrt Kommander-Dialogen ut
+Comment[ne]=आदेश संवादका लागि निर्वाहक
+Comment[nl]=Kommander-dialogen uitvoeren
+Comment[pl]=Uruchamianie z okien dialogowych Kommandera
+Comment[pt]=Executor dos diálogos do Kommander
+Comment[pt_BR]=Executor para diálogos do Kommander
+Comment[ru]=Выполнение диалогов Kommander
+Comment[sk]=Spúštač pre Kommander dialógy
+Comment[sl]=Izvajalnik za pogovorna okna Kommanderja
+Comment[sr]=Извршавач за Kommander-ове дијалоге
+Comment[sr@Latn]=Izvršavač za Kommander-ove dijaloge
+Comment[sv]=Körning av Kommander-dialogrutor
+Comment[ta]=Kகட்டளை உரையாடல் நிகழ்த்துபவர்
+Comment[tg]=Иҷрокунанда барои диалогҳои Kommander
+Comment[tr]=Kommander diyalogları için çalıştırıcı
+Comment[uk]=Запускач для вікон Kommander
+Comment[zh_CN]=Kommander 对话框执行器
+Comment[zh_HK]=Kommander 對話盒的運行程式
+Comment[zh_TW]=Kommander 對話盒的運行程式
+Terminal=false
+Name=Kommander Executor
+Name[br]=Aozer Kommander
+Name[ca]=Executor Kommander
+Name[cs]=Spouštěč Kommanderu
+Name[de]=Kommander-Exekutor
+Name[el]=Εκτελεστής Kommander
+Name[eu]=Kommander exekutatzailea
+Name[fa]=مجری Kommander
+Name[fi]=Komennon suorittaja
+Name[fr]=Exécuteur de Kommander
+Name[gl]=Executor de Kommander
+Name[hi]=कमांडर कार्यपालक
+Name[it]=Esecutore per Kommander
+Name[lt]=Kommander vykdyklė
+Name[ms]=Pelaksana Kommander
+Name[nds]=Kommander-Executor
+Name[ne]=आदेश निर्वाहक
+Name[nl]=Kommander Uitvoerder
+Name[pl]=Kommander: uruchamianie
+Name[pt]=Executor do Kommander
+Name[pt_BR]=Executor do Kommander
+Name[ru]=Kommander
+Name[sk]=Kommander spúštač
+Name[sl]=Izvajalnik Kommander
+Name[sr]=Kommander извршавач
+Name[sr@Latn]=Kommander izvršavač
+Name[ta]=Kகட்டளை நிகழ்த்துபவர்
+Name[tg]=Иҷрокунандаи Kommander
+Name[tr]=Kommander Çalıştırıcısı
+Name[uk]=Запускач Kommander
+Name[zh_CN]=Kommander 执行器
+Name[zh_HK]=Kommander 執行器
+Name[zh_TW]=Kommander 執行器
+MimeType=application/x-kommander
diff --git a/kommander/executor/main.cpp b/kommander/executor/main.cpp
new file mode 100644
index 00000000..589ec1cd
--- /dev/null
+++ b/kommander/executor/main.cpp
@@ -0,0 +1,102 @@
+/***************************************************************************
+ main.cpp - description
+ -------------------
+ begin : Tue Aug 13 09:31:50 EST 2002
+ copyright : (C) 2002 by Marc Britton
+ email : consume@optushome.com.au
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+/* KDE INCLUDES */
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kurl.h>
+#include <kmessagebox.h>
+
+/* QT INCLUDES */
+#include <qapplication.h>
+#include <qobject.h>
+#include <qstring.h>
+
+/* OTHER INCLUDES */
+#include <cstdio>
+#include <cstdlib>
+#include "instance.h"
+#include <iostream>
+#include <kommanderversion.h>
+
+using std::cout;
+using std::endl;
+using std::cerr;
+
+
+static const char *description =
+ I18N_NOOP("Executor is a component of the Kommander dialog system that executes .kmdr files given as arguments or via stdin");
+// INSERT A DESCRIPTION FOR YOUR APPLICATION HERE
+
+static KCmdLineOptions options[] =
+{
+ { "!stdin", I18N_NOOP("Read dialog from standard input"), 0},
+ { "c <catalog>", I18N_NOOP("Use given catalog for translation"), 0},
+ { "+[file]", I18N_NOOP("Dialog to open"), 0 },
+ KCmdLineLastOption
+};
+
+int main(int argc, char *argv[])
+{
+ KAboutData aboutData( "kmdr-executor", I18N_NOOP("Kommander Executor"),
+ KOMMANDER_VERSION, description, KAboutData::License_GPL,
+ "(c) 2002, Marc Britton, (C) 2008 Andras Mantia", 0, 0, "http://kommander.kdewebdev.org");
+ aboutData.addAuthor("Andras Mantia", I18N_NOOP("Current maintainer"), "amantia@kdewebdev.org");
+ aboutData.addAuthor("Michal Rudolf", I18N_NOOP("Previous maintainer"), "mrudolf@kdewebdev.org");
+ aboutData.addAuthor("Marc Britton", I18N_NOOP("Original author"), "consume@optusnet.com.au");
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ if (args->isSet("c"))
+ KLocale::setMainCatalogue(args->getOption("c"));
+ else if (args->count())
+ {
+ char buf[200];
+ QString baseFile = args->url(0).fileName();
+ int ext = baseFile.findRev('.');
+ if (ext != -1)
+ baseFile = baseFile.left(ext);
+ strcpy(buf, baseFile.latin1());
+ KLocale::setMainCatalogue(buf);
+ }
+ else
+ KLocale::setMainCatalogue("kommander");
+ KApplication app;
+
+ QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
+ if (!args->count())
+ {
+ KMessageBox::sorry(0, i18n("Error: no dialog given. Use --stdin option to read dialog from standard input.\n"));
+ return -1;
+ }
+ Instance instance;
+ if (!instance.build(args->isSet("stdin") ? QString() : args->url(0)))
+ return -1;
+
+ // Read command-line variables
+ QStringList cmdargs;
+ for (int i = !args->isSet("stdin"); i<args->count(); i++)
+ cmdargs.append(args->arg(i));
+ instance.addCmdlineArguments(cmdargs);
+
+ instance.run();
+ return 0;
+}
diff --git a/kommander/executor/register.cpp b/kommander/executor/register.cpp
new file mode 100644
index 00000000..e6c41b7f
--- /dev/null
+++ b/kommander/executor/register.cpp
@@ -0,0 +1,104 @@
+/***************************************************************************
+ register.cpp - registration of functions/specials for intance
+ -------------------
+ copyright : (C) 2004 by Michal Rudolf <mrudolf@kdewebdev.org>
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "instance.h"
+#include <dcopinformation.h>
+#include <specialinformation.h>
+
+#include <klocale.h>
+
+void Instance::registerDCOP()
+{
+ DCOPInformation::insert("enableWidget(QString,bool)");
+ DCOPInformation::insert("changeWidgetText(QString,QString)");
+ DCOPInformation::insert("currentItem(QString)");
+ DCOPInformation::insert("item(QString,int)");
+ DCOPInformation::insert("removeListItem(QString,int)");
+ DCOPInformation::insert("addListItem(QString,QString,int)");
+ DCOPInformation::insert("addListItems(QString,QStringList,int)");
+ DCOPInformation::insert("addUniqueItem(QString,QString)");
+ DCOPInformation::insert("findItem(QString,QString)");
+ DCOPInformation::insert("clearList(QString)");
+ DCOPInformation::insert("setCurrentListItem(QString,QString)");
+ DCOPInformation::insert("setCurrentTab(QString,int)");
+ DCOPInformation::insert("insertTab(QString,QString,int)");
+ DCOPInformation::insert("setChecked(QString, bool)");
+ DCOPInformation::insert("setAssociatedText(QString,QString)");
+ DCOPInformation::insert("associatedText(QString)");
+ DCOPInformation::insert("global(QString)");
+ DCOPInformation::insert("setGlobal(QString,QString)");
+}
+
+void Instance::registerSpecials()
+{
+ /* global specials */
+ SpecialInformation::insert("widgetText", 0, 0);
+ SpecialInformation::insert("selectedWidgetText", 0, 0);
+ SpecialInformation::insert("null", 0, 0);
+ SpecialInformation::insert("pid", 0, 0);
+ SpecialInformation::insert("dcopid", 0, 0);
+ SpecialInformation::insert("parentPid", 0, 0);
+ SpecialInformation::insert("execBegin", 0, 1);
+ SpecialInformation::insert("env", 1, 1);
+ SpecialInformation::insert("exec", 1, 1);
+ SpecialInformation::insert("execBackground", 1, 1);
+ SpecialInformation::insert("global", 1, 1);
+ SpecialInformation::insert("dialog", 1, 2);
+ SpecialInformation::insert("readSetting", 2, 2);
+ SpecialInformation::insert("setGlobal", 2, 2);
+ SpecialInformation::insert("writeSetting", 2, 2);
+ SpecialInformation::insert("dcop", 4, 10);
+
+ /* array specials */
+ SpecialInformation::setCurrentObject("Array");
+ SpecialInformation::insert("values", 1, 1, i18n( "Return EOL-separated list of all values in the array.") );
+ SpecialInformation::insert("keys", 1, 1, i18n( "Return EOL-separated list of all keys in the array.") );
+ SpecialInformation::insert("clear", 1, 1, i18n( "Remove all elements from the array.") );
+ SpecialInformation::insert("count", 1, 1, i18n( "Return number of elements in the array.") );
+ SpecialInformation::insert("value", 2, 2, i18n( "Return the value associated with given key.") );
+ SpecialInformation::insert("remove", 2, 2, i18n( "Remove element with given key from the array.") );
+ SpecialInformation::insert("setValue", 3, 3, i18n( "Add element with given key and value to the array") );
+ SpecialInformation::insert("fromString", 2, 2, i18n( "Add all elements in the string to the array. "
+ "String should have <i>key>\\tvalue\\n</i> format.") );
+ SpecialInformation::insert("toString", 1, 1, i18n( "Return all elements in the array in "
+ "<i>key>\\tvalue\\n</i> format.") );
+ SpecialInformation::insertInternal("indexedFromString", 3, 3, i18n( "Create an integer indexed array - starting from 0 - from a string. Use the separator character to split the string.") );
+ SpecialInformation::insertInternal("indexedToString", 2, 2, i18n( "Create a string from an integer indexed array. Concatenate the elements with the separator character.") );
+ SpecialInformation::insertInternal("indexedRemoveElement", 2, 2, i18n( "Remove the element specified by the key from an indexed array and reindex the array.") );
+
+ SpecialInformation::setCurrentObject("String");
+ SpecialInformation::insert("length", 1, 1, i18n( "Return number of chars in the string.") );
+ SpecialInformation::insert("contains", 2, 2, i18n( "Check if the string contains given substring.") );
+ SpecialInformation::insert("find", 2, 2, i18n( "Return position of a substring in the string, "
+ "or -1 if it isn't found.") );
+ SpecialInformation::insert("left", 2, 2, i18n( "Return first n chars of the string.") );
+ SpecialInformation::insert("right", 2, 2, i18n( "Return last n chars of the string.") );
+ SpecialInformation::insert("mid", 3, 3, i18n( "Return substring of the string, starting from "
+ "given position.") );
+ SpecialInformation::insert("remove", 2, 2, i18n( "Replace all occurencies of given substring.") );
+ SpecialInformation::insert("replace", 3, 3, i18n( "Replace all occurencies of given substring "
+ "with given replacement.") );
+ SpecialInformation::insert("upper", 1, 1, i18n( "Convert the string to uppercase.") );
+ SpecialInformation::insert("lower", 1, 1, i18n( "Convert the string to lowercase.") );
+ SpecialInformation::insert("compare", 2, 2, i18n( "Compare two strings. Return 0 if they are equal, "
+ "-1 if the first one is lower, 1 if the first one is higher") );
+ SpecialInformation::insert("isEmpty", 1, 1, i18n( "Check if string is empty.") );
+ SpecialInformation::insert("isNumber", 1, 1, i18n( "Check if string is a valid number.") );
+
+ SpecialInformation::setCurrentObject("File");
+ SpecialInformation::insert("read", 1, 1, i18n( "Return content of given file.") );
+ SpecialInformation::insert("write", 2, 2, i18n( "Write given string to a file.") );
+ SpecialInformation::insert("append", 2, 2, i18n( "Append given string to the end of a file.") );
+}
diff --git a/kommander/executor/templates/cpp_template b/kommander/executor/templates/cpp_template
new file mode 100644
index 00000000..6afef5d4
--- /dev/null
+++ b/kommander/executor/templates/cpp_template
@@ -0,0 +1,16 @@
+/***************************************************************************
+ |FILENAME| - description
+ -------------------
+ begin : |DATE|
+ copyright : (C) |YEAR| by |AUTHOR|
+ email : |EMAIL|
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
diff --git a/kommander/executor/templates/header_template b/kommander/executor/templates/header_template
new file mode 100644
index 00000000..6afef5d4
--- /dev/null
+++ b/kommander/executor/templates/header_template
@@ -0,0 +1,16 @@
+/***************************************************************************
+ |FILENAME| - description
+ -------------------
+ begin : |DATE|
+ copyright : (C) |YEAR| by |AUTHOR|
+ email : |EMAIL|
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/