summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-12 01:05:54 (UTC)
committer zecke <zecke>2002-10-12 01:05:54 (UTC)
commita92703ad1ed767713de21c2389b06434dc223eba (patch) (unidiff)
treeef5368486c2c4472e41c78ec5c7e3c1821e4c88d
parent78eddaa8057462b0b8e94f10f8673bb9f555061b (diff)
downloadopie-a92703ad1ed767713de21c2389b06434dc223eba.zip
opie-a92703ad1ed767713de21c2389b06434dc223eba.tar.gz
opie-a92703ad1ed767713de21c2389b06434dc223eba.tar.bz2
missing commits
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/filetransfer.h7
-rw-r--r--noncore/apps/opie-console/procctl.cpp1
-rw-r--r--noncore/apps/opie-console/procctl.h3
3 files changed, 7 insertions, 4 deletions
diff --git a/noncore/apps/opie-console/filetransfer.h b/noncore/apps/opie-console/filetransfer.h
index 0829f16..9cc1e8d 100644
--- a/noncore/apps/opie-console/filetransfer.h
+++ b/noncore/apps/opie-console/filetransfer.h
@@ -2,52 +2,53 @@
2#define OPIE_FILE_TRANSFER_H 2#define OPIE_FILE_TRANSFER_H
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5 5
6#include <qfile.h> 6#include <qfile.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8 8
9#include "file_layer.h" 9#include "file_layer.h"
10 10
11class QSocketNotifier; 11class QSocketNotifier;
12class OProcess; 12class OProcess;
13class FileTransferControl; 13class FileTransferControl;
14class FileTransfer : public FileTransferLayer{ 14class FileTransfer : public FileTransferLayer{
15 Q_OBJECT 15 Q_OBJECT
16 friend class FileTransferControl; 16 friend class FileTransferControl;
17public: 17public:
18 enum Type { 18 enum Type {
19 SZ = 0, 19 SZ = 0,
20 SX, 20 SX,
21 SY 21 SY
22 }; 22 };
23 FileTransfer( Type t, IOLayer* ); 23 FileTransfer( Type t, IOLayer* );
24 ~FileTransfer(); 24 ~FileTransfer();
25 25
26 void sendFile( const QString& file ); 26 void sendFile( const QString& file );
27 void sendFile( const QFile& ); 27 void sendFile( const QFile& );
28 void cancel(); 28 void cancel();
29 29
30private slots: 30private slots:
31 void setupChild(); 31 void setupChild();
32 void slotRead(); 32 void slotRead();
33 void slotProgress( const QStringList& ); 33 void slotProgress( const QStringList& );
34 void slotExec();
34private: 35private:
35 /* 36 /*
36 * FIXME? What does happen if we've 37 * FIXME? What does happen if we've
37 * two FileTransfers at a time? 38 * two FileTransfers at a time?
38 * Have a procctl which does listen 39 * Have a procctl which does listen
39 * for termination and then send a signal 40 * for termination and then send a signal
40 */ 41 */
41 static pid_t m_pid; 42 pid_t m_pid;
42 int m_fd; 43 int m_fd;
43 int m_prog; 44 int m_prog;
44 int m_info[2]; 45 int m_info[2];
45 int m_comm[2]; 46 int m_comm[2];
47 int m_term[2];
46 QString m_file; 48 QString m_file;
47 Type m_type; 49 Type m_type;
48 QSocketNotifier *m_not; 50 QSocketNotifier *m_not;
49 static void signal_handler(int); 51 QSocketNotifier* m_proc;
50 static bool terminate;
51}; 52};
52 53
53#endif 54#endif
diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp
index ff6bea8..b0b6846 100644
--- a/noncore/apps/opie-console/procctl.cpp
+++ b/noncore/apps/opie-console/procctl.cpp
@@ -42,55 +42,56 @@ void ProcCtl::remove( pid_t pi ) {
42 delete con; 42 delete con;
43 return; 43 return;
44 } 44 }
45 45
46 con = m_last; 46 con = m_last;
47 ProcContainer* forw = 0l; 47 ProcContainer* forw = 0l;
48 while (con ) { 48 while (con ) {
49 /* remove it */ 49 /* remove it */
50 if ( pi == con->pid ) { 50 if ( pi == con->pid ) {
51 forw->prev = con->prev; 51 forw->prev = con->prev;
52 delete con; 52 delete con;
53 return; 53 return;
54 } 54 }
55 55
56 forw = con; 56 forw = con;
57 con = con->prev; 57 con = con->prev;
58 } 58 }
59 59
60} 60}
61void ProcCtl::remove( ProcContainer con ) { 61void ProcCtl::remove( ProcContainer con ) {
62 remove( con.pid ); 62 remove( con.pid );
63} 63}
64int ProcCtl::status(pid_t pid )const{ 64int ProcCtl::status(pid_t pid )const{
65 ProcContainer *con = m_last; 65 ProcContainer *con = m_last;
66 while (con) { 66 while (con) {
67 if (con->pid == pid ) 67 if (con->pid == pid )
68 return con->status; 68 return con->status;
69 con = con->prev; 69 con = con->prev;
70 } 70 }
71 return -1; 71 return -1;
72} 72}
73void ProcCtl::signal_handler(int) { 73void ProcCtl::signal_handler(int) {
74 qWarning("signal handler");
74 int status; 75 int status;
75 signal( SIGCHLD, signal_handler ); 76 signal( SIGCHLD, signal_handler );
76 pid_t pi = waitpid( -1, &status, WNOHANG ); 77 pid_t pi = waitpid( -1, &status, WNOHANG );
77 78
78 /* 79 /*
79 * find the container for pid 80 * find the container for pid
80 * 81 *
81 */ 82 */
82 if ( pi < 0 ) { 83 if ( pi < 0 ) {
83 return; 84 return;
84 } 85 }
85 86
86 ProcContainer* con = m_last; 87 ProcContainer* con = m_last;
87 while (con) { 88 while (con) {
88 if ( con->pid == pi ) { 89 if ( con->pid == pi ) {
89 con->status = status; 90 con->status = status;
90 char result = 1; 91 char result = 1;
91 /* give a 'signal' */ 92 /* give a 'signal' */
92 ::write(con->fd, &result, 1 ); 93 ::write(con->fd, &result, 1 );
93 } 94 }
94 con = con->prev; 95 con = con->prev;
95 } 96 }
96} 97}
diff --git a/noncore/apps/opie-console/procctl.h b/noncore/apps/opie-console/procctl.h
index 5e96423..1da7c6d 100644
--- a/noncore/apps/opie-console/procctl.h
+++ b/noncore/apps/opie-console/procctl.h
@@ -1,36 +1,37 @@
1#ifndef OPIE_PROC_CTL_H 1#ifndef OPIE_PROC_CTL_H
2#define OPIE_PROC_CTL_H 2#define OPIE_PROC_CTL_H
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#include <unistd.h> 5#include <unistd.h>
6#include <fcntl.h> 6#include <fcntl.h>
7#include <signal.h> 7#include <signal.h>
8 8
9#include <qmap.h> 9#include <qmap.h>
10 10
11 11
12struct ProcContainer { 12struct ProcContainer {
13 pid_t pid; 13 pid_t pid;
14 int fd; 14 int fd;
15 int status; 15 int status;
16 ProcContainer* prev; 16 ProcContainer* prev;
17}; 17};
18 18
19class ProcCtl { 19class ProcCtl {
20private: 20private:
21 ProcCtl(); 21 ProcCtl();
22public: 22public:
23 ~ProcCtl(); 23 ~ProcCtl();
24 24
25 ProcCtl* self(); 25 static ProcCtl* self();
26 int status(pid_t)const; 26 int status(pid_t)const;
27 void add( pid_t, int fd ); 27 void add( pid_t, int fd );
28 void remove( pid_t ); 28 void remove( pid_t );
29 void remove( ProcContainer ); 29 void remove( ProcContainer );
30private: 30private:
31 static void signal_handler(int); 31 static void signal_handler(int);
32 static ProcContainer* m_last; 32 static ProcContainer* m_last;
33 static ProcCtl* m_self; 33 static ProcCtl* m_self;
34
34}; 35};
35 36
36#endif 37#endif