scriptmanager.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org) 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 #ifndef __scriptmanager_h__ 00020 #define __scriptmanager_h__ 00021 00022 #include <qvariant.h> 00023 #include <scriptclientinterface.h> 00024 #include <scriptinterface.h> 00025 #include <qdict.h> 00026 #include <qobject.h> 00027 00028 class ScriptInfo; 00029 //namespace KScriptInterface 00030 //{ 00031 00037 class KScriptManager : public QObject, public KScriptClientInterface 00038 { 00039 Q_OBJECT 00040 friend class KScriptInterface; 00041 public: 00045 KScriptManager(QObject *parent, const char *name); 00049 virtual ~KScriptManager(); 00055 bool addScript( const QString &scriptDesktopFile); 00060 bool removeScript( const QString &scriptName ); 00065 QStringList scripts(); 00069 void clear(); 00074 void error( const QString &msg ) {emit scriptError(msg);} 00079 void warning( const QString &msg ) {emit scriptWarning(msg);} 00084 void output( const QString &msg ) {emit scriptOutput(msg);} 00091 void progress( int percent ) {emit scriptProgress(percent);} 00097 void done( KScriptClientInterface::Result result, const QVariant &returned ) {emit scriptDone(result, returned);} 00098 00099 public slots: 00103 void runScript( const QString &scriptName, QObject *context = 0, const QVariant &arg = 0 ); 00104 signals: 00109 void scriptError( const QString &msg ); 00114 void scriptWarning( const QString &msg ); 00119 void scriptOutput( const QString &msg ); 00124 void scriptProgress( int percent); 00129 void scriptDone( KScriptClientInterface::Result result, const QVariant &returned); 00130 protected: 00131 QDict<ScriptInfo> m_scripts; 00132 QDict<KScriptInterface> m_scriptCache; 00133 //QStringList m_scriptNames; 00134 QString m_currentScript; 00135 }; 00136 //}; 00137 #endif