]> git.lyx.org Git - features.git/blobdiff - src/support/Systemcall.cpp
add progress view of system calls
[features.git] / src / support / Systemcall.cpp
index e8fbd6404e4206d91cb1e8600622184d27099e43..bf7192dd428f2e6742e7e03eb18b02ec7f71b10b 100644 (file)
@@ -4,6 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Asger Alstrup
+ * \author Peter Kümmel
  *
  * Interface cleaned up by
  * \author Angus Leeming
 #include <config.h>
 
 #include "support/Systemcall.h"
-#include "support/os.h"
+#include "support/SystemcallPrivate.h"
+#include "support/ProgressInterface.h"
 
-#include <cstdlib>
+namespace lyx {
+namespace support {
 
-using std::string;
+static ProgressInterface* progress_impl = 0;
 
-#ifndef CXX_GLOBAL_CSTD
-using std::system;
-#endif
 
-namespace lyx {
-namespace support {
+void Systemcall::registerProgressInterface(ProgressInterface* p)
+{
+       progress_impl = p;
+}
 
-// Reuse of instance
-int Systemcall::startscript(Starttype how, string const & what)
+
+ProgressInterface* Systemcall::progress()
+{
+       return progress_impl;
+}
+
+
+int Systemcall::startscript(Starttype how, std::string const & what)
 {
-       string command = what;
-
-       if (how == DontWait) {
-               switch (os::shell()) {
-               case os::UNIX:
-                       command += " &";
-                       break;
-               case os::CMD_EXE:
-                       command = "start /min " + command;
-                       break;
-               }
-       }
-
-       return ::system(command.c_str());
+       // TODO Reuse of instance?
+       SystemcallPrivate* process = new SystemcallPrivate;
+       if (how == Wait)
+               return process->start(what, true);
+       return process->start(what, false);
 }
 
+
 } // namespace support
 } // namespace lyx