TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
4.3KB

  1. /* This file is part of the KDE project
  2. Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org)
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this library; see the file COPYING.LIB. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. Boston, MA 02110-1301, USA.
  15. */
  16. #ifndef __scriptmanager_h__
  17. #define __scriptmanager_h__
  18. #include <tqvariant.h>
  19. #include <scriptclientinterface.h>
  20. #include <scriptinterface.h>
  21. #include <tqdict.h>
  22. #include <tqobject.h>
  23. #include <tdelibs_export.h>
  24. class ScriptInfo;
  25. //namespace KScriptInterface
  26. //{
  27. /**
  28. * This class is the base for all script engines.
  29. * @author Ian Reinhart Geiser <geiseri@kde.org>
  30. *
  31. **/
  32. class KDE_EXPORT KScriptManager : public TQObject, public KScriptClientInterface
  33. {
  34. Q_OBJECT
  35. friend class KScriptInterface;
  36. public:
  37. /**
  38. * Create a new instance of the script engine.
  39. */
  40. KScriptManager(TQObject *parent, const char *name);
  41. /**
  42. * Destroy the current script engine.
  43. */
  44. virtual ~KScriptManager();
  45. /**
  46. * Add a new script instance to the script engine.
  47. * This should be the full name and path to the desktop
  48. * file.
  49. */
  50. bool addScript( const TQString &scriptDesktopFile);
  51. /**
  52. * Remove a script instance from the script engine.
  53. * @returns the success of the operation.
  54. */
  55. bool removeScript( const TQString &scriptName );
  56. /**
  57. * Access the names of script instances from the script engine.
  58. * @returns a TQStringList of the current scripts.
  59. */
  60. TQStringList scripts();
  61. /**
  62. * Clear all script intstances in memory
  63. */
  64. void clear();
  65. /**
  66. * This function will allow the main application of any errors
  67. * that have occurred during processing of the script.
  68. */
  69. void error( const TQString &msg ) {emit scriptError(msg);}
  70. /**
  71. * This function will allow the main application of any warnings
  72. * that have occurred during the processing of the script.
  73. */
  74. void warning( const TQString &msg ) {emit scriptWarning(msg);}
  75. /**
  76. * This function will allow the main application of any normal
  77. * output that has occurred during the processing of the script.
  78. */
  79. void output( const TQString &msg ) {emit scriptOutput(msg);}
  80. /**
  81. * This function will allow feedback to any progress bars in the main
  82. * application as to how far along the script is. This is very useful when
  83. * a script is processing files or doing some long operation that is of a
  84. * known duration.
  85. */
  86. void progress( int percent ) {emit scriptProgress(percent);}
  87. /**
  88. * This function will allow feedback on completion of the script.
  89. * It turns the result as a KScriptInteface::Result, and a return
  90. * value as a QVariant
  91. */
  92. void done( KScriptClientInterface::Result result, const TQVariant &returned ) {emit scriptDone(result, returned);}
  93. public slots:
  94. /**
  95. * Run the selected script
  96. */
  97. void runScript( const TQString &scriptName, TQObject *context = 0, const TQVariant &arg = 0 );
  98. signals:
  99. /**
  100. * Send out a signal of the error message from the current running
  101. * script.
  102. */
  103. void scriptError( const TQString &msg );
  104. /**
  105. * Send out a signal of the warning message from the current running
  106. * script.
  107. */
  108. void scriptWarning( const TQString &msg );
  109. /**
  110. * Send out a signal of the output message from the current running
  111. * script.
  112. */
  113. void scriptOutput( const TQString &msg );
  114. /**
  115. * Send out a signal of the progress of the current running
  116. * script.
  117. */
  118. void scriptProgress( int percent);
  119. /**
  120. * Send out a signal of the exit status of the script
  121. *
  122. */
  123. void scriptDone( KScriptClientInterface::Result result, const TQVariant &returned);
  124. protected:
  125. TQDict<ScriptInfo> m_scripts;
  126. TQDict<KScriptInterface> m_scriptCache;
  127. //TQStringList m_scriptNames;
  128. TQString m_currentScript;
  129. };
  130. //};
  131. #endif