author | zecke <zecke> | 2002-10-12 01:21:45 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-12 01:21:45 (UTC) |
commit | b256987cda5449e3abfd3bd4c2d0650530b5a562 (patch) (unidiff) | |
tree | b739480699193ae0a2bd7a5ea9bfb3ce00923d8b | |
parent | a92703ad1ed767713de21c2389b06434dc223eba (diff) | |
download | opie-b256987cda5449e3abfd3bd4c2d0650530b5a562.zip opie-b256987cda5449e3abfd3bd4c2d0650530b5a562.tar.gz opie-b256987cda5449e3abfd3bd4c2d0650530b5a562.tar.bz2 |
Implemented Y-Moden and X-Modem
The parsing needs to ne adjusted for
these gusys though..
-rw-r--r-- | noncore/apps/opie-console/filetransfer.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp index 97552fe..b39dc95 100644 --- a/noncore/apps/opie-console/filetransfer.cpp +++ b/noncore/apps/opie-console/filetransfer.cpp | |||
@@ -28,66 +28,79 @@ FileTransfer::~FileTransfer() { | |||
28 | * | 28 | * |
29 | * we request an fd. The IOLayer should be closed | 29 | * we request an fd. The IOLayer should be closed |
30 | * then we will setup a pipe for progress communication | 30 | * then we will setup a pipe for progress communication |
31 | * then we will dup2 the m_fd in the forked process | 31 | * then we will dup2 the m_fd in the forked process |
32 | * to do direct IO from and to the fd | 32 | * to do direct IO from and to the fd |
33 | */ | 33 | */ |
34 | void FileTransfer::sendFile( const QString& file ) { | 34 | void FileTransfer::sendFile( const QString& file ) { |
35 | m_prog =-1; | 35 | m_prog =-1; |
36 | m_fd = layer()->rawIO(); | 36 | m_fd = layer()->rawIO(); |
37 | // | 37 | // |
38 | // m_fd = ::open("/dev/ttyS0", O_RDWR); | 38 | // m_fd = ::open("/dev/ttyS0", O_RDWR); |
39 | 39 | ||
40 | m_file = file; | 40 | m_file = file; |
41 | if ( pipe( m_comm ) < 0 ) | 41 | if ( pipe( m_comm ) < 0 ) |
42 | m_comm[0] = m_comm[1] = 0; | 42 | m_comm[0] = m_comm[1] = 0; |
43 | if ( pipe( m_info ) < 0 ) | 43 | if ( pipe( m_info ) < 0 ) |
44 | m_info[0] = m_info[1] = 0; | 44 | m_info[0] = m_info[1] = 0; |
45 | 45 | ||
46 | 46 | ||
47 | m_pid = fork(); | 47 | m_pid = fork(); |
48 | switch( m_pid ) { | 48 | switch( m_pid ) { |
49 | case -1: | 49 | case -1: |
50 | emit error( StartError, tr("Was not able to fork") ); | 50 | emit error( StartError, tr("Was not able to fork") ); |
51 | break; | 51 | break; |
52 | case 0:{ | 52 | case 0:{ |
53 | setupChild(); | 53 | setupChild(); |
54 | qWarning("output:"+file ); | 54 | qWarning("output:"+file ); |
55 | /* exec */ | 55 | /* exec */ |
56 | char* verbose = "-vv"; | 56 | char* verbose = "-vv"; |
57 | char* binray = "-b"; | 57 | char* binray = "-b"; |
58 | 58 | ||
59 | 59 | ||
60 | char* typus; | ||
61 | switch(m_type ) { | ||
62 | case SZ: | ||
63 | typus = ""; | ||
64 | break; | ||
65 | case SX: | ||
66 | typus = "-X"; | ||
67 | break; | ||
68 | case SY: | ||
69 | typus = "--ymodem"; | ||
70 | break; | ||
71 | } | ||
72 | |||
60 | /* we should never return from here */ | 73 | /* we should never return from here */ |
61 | execlp("sz", "sz", verbose, binray, file.latin1(), NULL ); | 74 | execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); |
62 | 75 | ||
63 | /* communication for error!*/ | 76 | /* communication for error!*/ |
64 | char resultByte =1; | 77 | char resultByte =1; |
65 | if (m_info[1] ) | 78 | if (m_info[1] ) |
66 | write(m_info[1], &resultByte, 1 ); | 79 | write(m_info[1], &resultByte, 1 ); |
67 | _exit( -1 ); | 80 | _exit( -1 ); |
68 | break; | 81 | break; |
69 | } | 82 | } |
70 | default:{ | 83 | default:{ |
71 | if ( m_info[1] ) | 84 | if ( m_info[1] ) |
72 | close( m_info[1] ); | 85 | close( m_info[1] ); |
73 | if ( m_info[0] ) for (;;) { | 86 | if ( m_info[0] ) for (;;) { |
74 | char resultByte; int len; | 87 | char resultByte; int len; |
75 | len = read(m_info[0], &resultByte, 1 ); | 88 | len = read(m_info[0], &resultByte, 1 ); |
76 | /* len == 1 start up failed */ | 89 | /* len == 1 start up failed */ |
77 | if ( len == 1 ) { | 90 | if ( len == 1 ) { |
78 | emit error( StartError, tr("Could not start") ); | 91 | emit error( StartError, tr("Could not start") ); |
79 | return; | 92 | return; |
80 | } | 93 | } |
81 | if ( len == -1 ) | 94 | if ( len == -1 ) |
82 | if ( (errno == ECHILD ) || (errno == EINTR ) ) | 95 | if ( (errno == ECHILD ) || (errno == EINTR ) ) |
83 | continue; | 96 | continue; |
84 | 97 | ||
85 | // len == 0 or something like this | 98 | // len == 0 or something like this |
86 | break; | 99 | break; |
87 | } | 100 | } |
88 | if ( m_info[0] ) | 101 | if ( m_info[0] ) |
89 | close( m_info[0] ); | 102 | close( m_info[0] ); |
90 | 103 | ||
91 | 104 | ||
92 | 105 | ||
93 | /* replace by QSocketNotifier!!! */ | 106 | /* replace by QSocketNotifier!!! */ |