summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/filetransfer.cpp3
-rw-r--r--noncore/apps/opie-console/opie-console.pro4
-rw-r--r--noncore/apps/opie-console/procctl.cpp90
-rw-r--r--noncore/apps/opie-console/procctl.h33
4 files changed, 125 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp
index 7b75d35..7fd9f37 100644
--- a/noncore/apps/opie-console/filetransfer.cpp
+++ b/noncore/apps/opie-console/filetransfer.cpp
@@ -212,7 +212,6 @@ void FileTransfer::slotProgress( const QStringList& list ) {
212 212
213 total = progi[1].toULong(&complete ); 213 total = progi[1].toULong(&complete );
214 if (!complete || total == 0) { 214 if (!complete || total == 0) {
215 qWarning("returning!!");
216 return; 215 return;
217 } 216 }
218 217
@@ -231,11 +230,9 @@ void FileTransfer::slotProgress( const QStringList& list ) {
231 sec = progi[1].toInt(); 230 sec = progi[1].toInt();
232 231
233 232
234 qWarning("Prog!:%d", prog );
235 if ( prog > m_prog ) { 233 if ( prog > m_prog ) {
236 m_prog = prog; 234 m_prog = prog;
237 emit progress(m_file, m_prog, bps, -1, min , sec ); 235 emit progress(m_file, m_prog, bps, -1, min , sec );
238 qWarning("Progress: %s, %d\%, %d, %d:%d", m_file.latin1(), m_prog, bps, min, sec );
239 } 236 }
240 237
241} 238}
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 37cef92..9208042 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -27,7 +27,7 @@ HEADERS = io_layer.h io_serial.h io_irda.h \
27 terminalwidget.h \ 27 terminalwidget.h \
28 iolayerbase.h \ 28 iolayerbase.h \
29 serialconfigwidget.h irdaconfigwidget.h btconfigwidget.h \ 29 serialconfigwidget.h irdaconfigwidget.h btconfigwidget.h \
30 emulation_widget.h 30 emulation_widget.h procctl.h
31 31
32 32
33SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp \ 33SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp \
@@ -54,7 +54,7 @@ SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp \
54 terminalwidget.cpp \ 54 terminalwidget.cpp \
55 iolayerbase.cpp \ 55 iolayerbase.cpp \
56 serialconfigwidget.cpp irdaconfigwidget.cpp btconfigwidget.cpp \ 56 serialconfigwidget.cpp irdaconfigwidget.cpp btconfigwidget.cpp \
57 emulation_widget.cpp 57 emulation_widget.cpp procctl.cpp
58 58
59INTERFACES = configurebase.ui editbase.ui 59INTERFACES = configurebase.ui editbase.ui
60INCLUDEPATH += $(OPIEDIR)/include 60INCLUDEPATH += $(OPIEDIR)/include
diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp
new file mode 100644
index 0000000..6839a84
--- a/dev/null
+++ b/noncore/apps/opie-console/procctl.cpp
@@ -0,0 +1,90 @@
1#include <sys/wait.h>
2
3#include <fcntl.h>
4#include <unistd.h>
5
6#include "procctl.h"
7
8ProcContainer *ProcCtl::m_last = 0;
9
10ProcCtl::ProcCtl() {
11 signal( SIGCHLD, signal_handler );
12}
13ProcCtl::~ProcCtl() {
14}
15void ProcCtl::add(pid_t pi, int fd ) {
16 ProcContainer * con = new ProcContainer;
17 //memset(con, 0, sizeof(con) );
18 con->pid = pi;
19 con->fd = fd;
20 con->status = 0;
21 con->prev = m_last;
22
23 m_last = con;
24
25}
26void ProcCtl::remove( pid_t pi ) {
27 /*
28 * We first check if the last item
29 * is equal to pi the we
30 *
31 */
32 ProcContainer* con;
33 if (m_last->pid == pi ) {
34 con = m_last;
35 m_last = con->prev;
36 delete con;
37 return;
38 }
39
40 con = m_last;
41 ProcContainer* forw = 0l;
42 while (con ) {
43 /* remove it */
44 if ( pi == con->pid ) {
45 forw->prev = con->prev;
46 delete con;
47 return;
48 }
49
50 forw = con;
51 con = con->prev;
52 }
53
54}
55void ProcCtl::remove( ProcContainer con ) {
56 remove( con.pid );
57}
58int ProcCtl::status(pid_t pid )const{
59 ProcContainer *con = m_last;
60 while (con) {
61 if (con->pid == pid )
62 return con->status;
63 con = con->prev;
64 }
65 return -1;
66}
67void ProcCtl::signal_handler(int) {
68 int status;
69 signal( SIGCHLD, signal_handler );
70 pid_t pi = waitpid( -1, &status, WNOHANG );
71
72 /*
73 * find the container for pid
74 *
75 */
76 if ( pi < 0 ) {
77 return;
78 }
79
80 ProcContainer* con = m_last;
81 while (con) {
82 if ( con->pid == pi ) {
83 con->status = status;
84 char result = 1;
85 /* give a 'signal' */
86 ::write(con->fd, &result, 1 );
87 }
88 con = con->prev;
89 }
90}
diff --git a/noncore/apps/opie-console/procctl.h b/noncore/apps/opie-console/procctl.h
new file mode 100644
index 0000000..e2161f3
--- a/dev/null
+++ b/noncore/apps/opie-console/procctl.h
@@ -0,0 +1,33 @@
1#ifndef OPIE_PROC_CTL_H
2#define OPIE_PROC_CTL_H
3
4#include <sys/types.h>
5#include <unistd.h>
6#include <fcntl.h>
7#include <signal.h>
8
9#include <qmap.h>
10
11
12struct ProcContainer {
13 pid_t pid;
14 int fd;
15 int status;
16 ProcContainer* prev;
17};
18
19class ProcCtl {
20public:
21 ProcCtl();
22 ~ProcCtl();
23
24 int status(pid_t)const;
25 void add( pid_t, int fd );
26 void remove( pid_t );
27 void remove( ProcContainer );
28private:
29 static void signal_handler(int);
30 static ProcContainer* m_last;
31};
32
33#endif