PSignal was already able to handle this without modifications
[enigma2.git] / lib / base / console.h
1 #ifndef __LIB_BASE_CONSOLE_H__
2 #define __LIB_BASE_CONSOLE_H__
3
4 #include <string>
5 #include <lib/base/ebase.h>
6 #include <lib/python/connections.h>
7 #include <queue>
8
9 #ifndef SWIG
10 struct queue_data
11 {
12         queue_data( char *data, int len )
13                 :data(data), len(len)
14         {
15         }
16         char *data;
17         int len;
18 };
19 #endif
20
21 class eConsoleAppContainer: public Object
22 {
23 #ifndef SWIG
24         int fd[3];
25         int pid;
26         int killstate;
27         std::queue<struct queue_data> outbuf;
28         eSocketNotifier *in, *out, *err;
29         void readyRead(int what);
30         void readyErrRead(int what);
31         void readyWrite(int what);
32         void closePipes();
33 #endif
34 public:
35         eConsoleAppContainer();
36         int execute( const std::string &str );
37         ~eConsoleAppContainer();
38         int getPID() { return pid; }
39         void kill();
40         void sendCtrlC();
41         void write( const char *data, int len );
42         bool running() { return (fd[0]!=-1) && (fd[1]!=-1) && (fd[2]!=-1); }
43         PSignal1<void, const char*> dataAvail;
44         PSignal1<void,int> dataSent;
45         PSignal1<void,int> appClosed;
46 };
47
48 #endif // __LIB_BASE_CONSOLE_H__