author | zecke <zecke> | 2002-10-12 00:30:06 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-12 00:30:06 (UTC) |
commit | 0a3ffe7e5657bed4cb77d9bc23457755e2d02591 (patch) (unidiff) | |
tree | a1b83e61035433668ca5c9e3af31586880535c98 | |
parent | ffa7f45a2100b7c438a437fce2d3a47608bd36e3 (diff) | |
download | opie-0a3ffe7e5657bed4cb77d9bc23457755e2d02591.zip opie-0a3ffe7e5657bed4cb77d9bc23457755e2d02591.tar.gz opie-0a3ffe7e5657bed4cb77d9bc23457755e2d02591.tar.bz2 |
This is targetted to the people telling
in computer science classes that I'm
toolkit dependant
This is a Process Controller which will be used
to work around the limit of only beeing able to do
one FileTransfer at a Time
-rw-r--r-- | noncore/apps/opie-console/filetransfer.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/procctl.cpp | 90 | ||||
-rw-r--r-- | noncore/apps/opie-console/procctl.h | 33 |
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 | ||
33 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp \ | 33 | SOURCES = 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 | ||
59 | INTERFACES = configurebase.ui editbase.ui | 59 | INTERFACES = configurebase.ui editbase.ui |
60 | INCLUDEPATH += $(OPIEDIR)/include | 60 | INCLUDEPATH += $(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 | |||
8 | ProcContainer *ProcCtl::m_last = 0; | ||
9 | |||
10 | ProcCtl::ProcCtl() { | ||
11 | signal( SIGCHLD, signal_handler ); | ||
12 | } | ||
13 | ProcCtl::~ProcCtl() { | ||
14 | } | ||
15 | void 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 | } | ||
26 | void 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 | } | ||
55 | void ProcCtl::remove( ProcContainer con ) { | ||
56 | remove( con.pid ); | ||
57 | } | ||
58 | int 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 | } | ||
67 | void 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 | |||
12 | struct ProcContainer { | ||
13 | pid_t pid; | ||
14 | int fd; | ||
15 | int status; | ||
16 | ProcContainer* prev; | ||
17 | }; | ||
18 | |||
19 | class ProcCtl { | ||
20 | public: | ||
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 ); | ||
28 | private: | ||
29 | static void signal_handler(int); | ||
30 | static ProcContainer* m_last; | ||
31 | }; | ||
32 | |||
33 | #endif | ||