author | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
commit | 2b64a84d39eeed5681d0ee5068c7d11a01527750 (patch) (unidiff) | |
tree | c8693340dbc5ef5e2f9afa90b690829ddff2c4bd /noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.h | |
parent | 61fa699140c5efbb6ba0bf2a62f7e8fbf62976be (diff) | |
download | opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.zip opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.gz opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.bz2 |
other keymapping tool - not working this moment, I have to check it out
- the reason is that the config file is somewhat easier to understand than
from zkbapplet and has a nice config tool.
Please don't put it into any repositories this moment.
Diffstat (limited to 'noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.h | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.h b/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.h new file mode 100644 index 0000000..1f53cd6 --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.h | |||
@@ -0,0 +1,114 @@ | |||
1 | #ifndef _PROCESS_INVOKER_H_ | ||
2 | #define _PROCESS_INVOKER_H_ | ||
3 | |||
4 | #include <qobject.h> | ||
5 | #include <sys/wait.h> | ||
6 | #include <sys/types.h> | ||
7 | #include <sys/time.h> | ||
8 | #include <signal.h> | ||
9 | #include <stdio.h> | ||
10 | #include <unistd.h> | ||
11 | #include <errno.h> | ||
12 | |||
13 | #include <qtimer.h> | ||
14 | #include <qdatastream.h> | ||
15 | #include <qcstring.h> | ||
16 | #include <qpe/qcopenvelope_qws.h> | ||
17 | #include <qpe/global.h> | ||
18 | //#include "KHUtil.h" | ||
19 | #include "StringParser.h" | ||
20 | |||
21 | typedef void Sigfunc(int); | ||
22 | |||
23 | #define SC_CHANNEL"QPE/ShellCommander" | ||
24 | |||
25 | /* Sigleton Object */ | ||
26 | class ProcessInvoker : public QObject | ||
27 | { | ||
28 | Q_OBJECT | ||
29 | public: | ||
30 | static ProcessInvoker& getInstance() | ||
31 | { | ||
32 | static ProcessInvoker instance; | ||
33 | return(instance); | ||
34 | } | ||
35 | |||
36 | bool run(); | ||
37 | bool run(const QString& args); | ||
38 | void terminate(); | ||
39 | void terminate(pid_t pid); | ||
40 | void kill(); | ||
41 | void kill(pid_t pid); | ||
42 | void setCommand(const QString& command){ | ||
43 | m_arguments.clear(); | ||
44 | addArgument(command); | ||
45 | } | ||
46 | void setArguments(const QStringList& arglist){ | ||
47 | m_arguments = arglist; | ||
48 | } | ||
49 | void setArguments(const QString& arguments){ | ||
50 | //setArguments(KHUtil::parseArgs(arguments)); | ||
51 | setArguments(StringParser::split(' ', arguments)); | ||
52 | } | ||
53 | void addArgument(const QString& argument){ | ||
54 | m_arguments.append(argument); | ||
55 | } | ||
56 | void addArguments(const QString& arguments){ | ||
57 | QStringList arglist; | ||
58 | //arglist = KHUtil::parseArgs(arguments); | ||
59 | arglist = StringParser::split(' ', arguments); | ||
60 | addArguments(arglist); | ||
61 | } | ||
62 | void addArguments(const QStringList& arglist){ | ||
63 | for(QStringList::ConstIterator it=arglist.begin(); | ||
64 | it!=arglist.end(); ++it){ | ||
65 | addArgument(*it); | ||
66 | } | ||
67 | } | ||
68 | //const QStringList parseArgs(const QString& arguments); | ||
69 | void setRunning(int pid); | ||
70 | void setNotify(bool enable=true){ | ||
71 | m_isNotify = enable; | ||
72 | } | ||
73 | |||
74 | bool isRunning(){ | ||
75 | return(m_isRunning); | ||
76 | } | ||
77 | void notifyFinish(int status, bool success=true); | ||
78 | |||
79 | pid_t m_child; | ||
80 | |||
81 | friend class Dummy; /* for compile warning */ | ||
82 | signals: | ||
83 | void start(int, QStringList); | ||
84 | void finish(QString,int); | ||
85 | private: | ||
86 | ProcessInvoker(); | ||
87 | ProcessInvoker(const ProcessInvoker&); | ||
88 | ProcessInvoker& operator=(const ProcessInvoker&); | ||
89 | ~ProcessInvoker(); | ||
90 | |||
91 | class Dummy{}; /* for compile warning */ | ||
92 | |||
93 | QTimer* m_pTimer; | ||
94 | QStringList m_arguments; | ||
95 | |||
96 | bool m_isRunning; | ||
97 | bool m_isNotify; | ||
98 | |||
99 | Sigfunc* m_defChildHandler; | ||
100 | |||
101 | int m_stdfd[2]; | ||
102 | int m_errfd[2]; | ||
103 | int m_maxfdp1; | ||
104 | |||
105 | bool openPipe(); | ||
106 | void closePipe(int fd[] = NULL, int n = 2); | ||
107 | void notifyStatus(const QString& result, int code); | ||
108 | |||
109 | void workerProc(); | ||
110 | private slots: | ||
111 | void readOutputs(); | ||
112 | }; | ||
113 | |||
114 | #endif /* _PROCESS_INVOKER_H_ */ | ||