00001 /* 00002 * $Id$ 00003 * Kockpit - an Qt application for user/group management on unix based systems. 00004 * 00005 * Copyright (C) 2010 Julian Thome 00006 * 00007 * This program is free software; you can redistribute it and/or modify it under the terms of 00008 * the GNU General Public License as published by the Free Software Foundation; 00009 * either version 3 of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00012 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00013 * See the GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along with this program; 00016 * if not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #ifndef KOCKPITSCRIPTACTION_H 00020 #define KOCKPITSCRIPTACTION_H 00021 00022 #include <QVariant> 00023 #include <QtScript> 00024 #include "ldapmodule.h" 00025 #include "kockpitunit.h" 00026 #include "kockpituser.h" 00027 #include "kockpitgroup.h" 00028 #include "kockpitvalidator.h" 00029 #include "kockpithelpers.h" 00030 00032 00035 class KockpitScriptAction: public QObject { 00036 00037 Q_OBJECT 00038 00039 public: 00040 00042 00046 KockpitScriptAction(LDAPModule *lmod); 00047 00049 virtual ~KockpitScriptAction(){ } 00050 00052 00056 void initEngine(const QString &dir); 00057 00059 00067 void evaluateEach(const QString &dir,const scriptmode &mode, KockpitValidator* validator, KockpitUnit* kunit); 00068 00070 00076 QString* readJsFile(const QString &filepath); 00077 00079 00084 QStringList* getJsFilesInDir(const QString& dirname, const QStringList &files); 00085 00086 private: 00087 00089 00095 void evaluate(const QString &script, const QString &function, KockpitUser* kuser); 00096 00098 00104 void evaluate(const QString &script, const QString &function, KockpitGroup *kgrp); 00105 00107 QScriptEngine engine; 00108 00109 }; 00110 00111 Q_DECLARE_METATYPE(QScriptValue); 00112 #endif // KOCKPITSCRIPTACTION_H