diff --git a/ecorexx/include/ecorexx/Ecorexx.h b/ecorexx/include/ecorexx/Ecorexx.h index 6c1487e..16f5ffd 100644 --- a/ecorexx/include/ecorexx/Ecorexx.h +++ b/ecorexx/include/ecorexx/Ecorexx.h @@ -17,6 +17,7 @@ #include "Timer.h" #include "XWindow.h" #include "Job.h" +#include "Exe.h" #endif // ECOREXX_H diff --git a/ecorexx/include/ecorexx/Exe.h b/ecorexx/include/ecorexx/Exe.h new file mode 100644 index 0000000..7bf3ee7 --- /dev/null +++ b/ecorexx/include/ecorexx/Exe.h @@ -0,0 +1,93 @@ +#ifndef ECOREXX_EXE_H +#define ECOREXX_EXE_H + +/* EFL */ +#include +#include + +namespace Ecorexx { + +/** + * @defgroup Ecorexx_Exe_Group Process Spawning Functions + * + * This module is responsible for managing portable processes using Ecore. + * With this module you're able to spawn processes and you also can pause, + * quit your spawned processes. + * An interaction between your process and those spawned is possible + * using pipes or signals. + * + * + * @ingroup Ecorexx_Main_Loop_Group + * + * @{ + */ +class Exe +{ +public: + virtual ~Exe(); + + static void setRunPriority(int pri); + + static int getRunPriority(); + + static Eflxx::CountedPtr run(const std::string &exe_cmd, const void *data); + + static Eflxx::CountedPtr runPipe(const std::string &exe_cmd, Ecore_Exe_Flags flags, const void *data); + + // TODO +//EAPI void ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func); + + bool send(const void *data, int size); + + void stdinClose(); + + void setAutoLimits(int start_bytes, int end_bytes, int start_lines, int end_lines); + + // TODO +//EAPI Ecore_Exe_Event_Data *ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags); + + void freeData(Ecore_Exe_Event_Data *data); + + pid_t getPid(); + + void setTag(const std::string &tag); + + std::string getTag(); + + std::string getCmd(); + + void *getData(); + + void *setData(void *data); + + Ecore_Exe_Flags getFlags(); + + void pause(); + + void cont(); + + void interrupt(); + + void quit(); + + void terminate(); + + void kill(); + + void signal(int num); + + void hup(); + +private: + /** + * no constructor -> call run() or runPipe() + */ + Exe(); + Exe(const Exe&); // forbid copy constructor + + Ecore_Exe *mExe; +}; + +} // end namespace Ecorexx + +#endif // ECOREXX_EXE_H \ No newline at end of file diff --git a/ecorexx/include/ecorexx/Makefile.am b/ecorexx/include/ecorexx/Makefile.am index 91afce8..3f3ec0d 100644 --- a/ecorexx/include/ecorexx/Makefile.am +++ b/ecorexx/include/ecorexx/Makefile.am @@ -10,7 +10,8 @@ libecorexx_HEADERS = \ EvasWindowFB.h \ EvasWindowGLX11.h \ EvasWindowSoftwareX11.h \ - EvasWindowXRenderX11.h + EvasWindowXRenderX11.h \ + Exe.h libecorexxdir = \ $(pkgincludedir) diff --git a/ecorexx/src/Exe.cpp b/ecorexx/src/Exe.cpp new file mode 100644 index 0000000..8c0e41b --- /dev/null +++ b/ecorexx/src/Exe.cpp @@ -0,0 +1,151 @@ +#ifdef HAVE_CONFIG_H +#include +#endif + +/* STL */ +#include +#include + +#include "ecorexx/Exe.h" + +namespace Ecorexx { + +Exe::Exe() : + mExe(NULL) +{ +} + +Exe::~Exe() +{ + if(mExe) + { + assert(ecore_exe_free(mExe)); + } +} + +void Exe::setRunPriority(int pri) +{ + ecore_exe_run_priority_set(pri); +} + +int Exe::getRunPriority() +{ + return ecore_exe_run_priority_get(); +} + +Eflxx::CountedPtr Exe::run(const std::string &exe_cmd, const void *data) +{ + Ecore_Exe *ecore_exe = ecore_exe_run(exe_cmd.c_str(), data); + + Exe *exe_obj = new Exe(); + exe_obj->mExe = ecore_exe; + + return Eflxx::CountedPtr (exe_obj); +} + +Eflxx::CountedPtr Exe::runPipe(const std::string &exe_cmd, Ecore_Exe_Flags flags, const void *data) +{ + Ecore_Exe *ecore_exe = ecore_exe_pipe_run(exe_cmd.c_str(), flags, data); + + Exe *exe_obj = new Exe(); + exe_obj->mExe = ecore_exe; + + return Eflxx::CountedPtr (exe_obj); +} + +bool Exe::send(const void *data, int size) +{ + return ecore_exe_send(mExe, data, size); +} + +void Exe::stdinClose() +{ + ecore_exe_close_stdin(mExe); +} + +void Exe::setAutoLimits(int start_bytes, int end_bytes, int start_lines, int end_lines) +{ + ecore_exe_auto_limits_set(mExe, start_bytes, end_bytes, start_lines, end_lines); +} + +void Exe::freeData(Ecore_Exe_Event_Data *data) +{ + ecore_exe_event_data_free(data); +} + +pid_t Exe::getPid() +{ + return ecore_exe_pid_get(mExe); +} + +void Exe::setTag(const std::string &tag) +{ + ecore_exe_tag_set(mExe, tag.c_str()); +} + +std::string Exe::getTag() +{ + return ecore_exe_tag_get(mExe); +} + +std::string Exe::getCmd() +{ + return ecore_exe_cmd_get(mExe); +} + +void *Exe::getData() +{ + return ecore_exe_data_get(mExe); +} + +void *Exe::setData(void *data) +{ + return ecore_exe_data_set(mExe, data); +} + +Ecore_Exe_Flags Exe::getFlags() +{ + return ecore_exe_flags_get(mExe); +} + +void Exe::pause() +{ + ecore_exe_pause(mExe); +} + +void Exe::cont() +{ + ecore_exe_continue(mExe); +} + +void Exe::interrupt() +{ + ecore_exe_interrupt(mExe); +} + +void Exe::quit() +{ + ecore_exe_quit(mExe); +} + +void Exe::terminate() +{ + ecore_exe_terminate(mExe); +} + +void Exe::kill() +{ + ecore_exe_kill(mExe); +} + +void Exe::signal(int num) +{ + ecore_exe_signal(mExe, num); +} + +void Exe::hup() +{ + ecore_exe_hup(mExe); +} + +} // end namespace Ecorexx diff --git a/ecorexx/src/Makefile.am b/ecorexx/src/Makefile.am index 5ef4884..f26809a 100644 --- a/ecorexx/src/Makefile.am +++ b/ecorexx/src/Makefile.am @@ -26,7 +26,8 @@ libecorexx_la_SOURCES = \ EvasWindowFB.cpp \ EvasWindowGLX11.cpp \ EvasWindowSoftwareX11.cpp \ - EvasWindowXRenderX11.cpp + EvasWindowXRenderX11.cpp \ + Exe.cpp libecorexx_la_LIBADD = \ $(EFL_LIBS)