author | zecke <zecke> | 2002-10-12 01:21:45 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-12 01:21:45 (UTC) |
commit | b256987cda5449e3abfd3bd4c2d0650530b5a562 (patch) (side-by-side diff) | |
tree | b739480699193ae0a2bd7a5ea9bfb3ce00923d8b /noncore | |
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 @@ -12,98 +12,111 @@ #include "procctl.h" #include "filetransfer.h" FileTransfer::FileTransfer( Type t, IOLayer* lay ) : FileTransferLayer( lay ), m_type( t ) { signal(SIGPIPE, SIG_IGN ); m_not = 0l; m_proc = 0l; } FileTransfer::~FileTransfer() { } /** * now we will send the file. * * we request an fd. The IOLayer should be closed * then we will setup a pipe for progress communication * then we will dup2 the m_fd in the forked process * to do direct IO from and to the fd */ void FileTransfer::sendFile( const QString& file ) { m_prog =-1; m_fd = layer()->rawIO(); // // m_fd = ::open("/dev/ttyS0", O_RDWR); m_file = file; if ( pipe( m_comm ) < 0 ) m_comm[0] = m_comm[1] = 0; if ( pipe( m_info ) < 0 ) m_info[0] = m_info[1] = 0; m_pid = fork(); switch( m_pid ) { case -1: emit error( StartError, tr("Was not able to fork") ); break; case 0:{ setupChild(); qWarning("output:"+file ); /* exec */ char* verbose = "-vv"; char* binray = "-b"; + char* typus; + switch(m_type ) { + case SZ: + typus = ""; + break; + case SX: + typus = "-X"; + break; + case SY: + typus = "--ymodem"; + break; + } + /* we should never return from here */ - execlp("sz", "sz", verbose, binray, file.latin1(), NULL ); + execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); /* communication for error!*/ char resultByte =1; if (m_info[1] ) write(m_info[1], &resultByte, 1 ); _exit( -1 ); break; } default:{ if ( m_info[1] ) close( m_info[1] ); if ( m_info[0] ) for (;;) { char resultByte; int len; len = read(m_info[0], &resultByte, 1 ); /* len == 1 start up failed */ if ( len == 1 ) { emit error( StartError, tr("Could not start") ); return; } if ( len == -1 ) if ( (errno == ECHILD ) || (errno == EINTR ) ) continue; // len == 0 or something like this break; } if ( m_info[0] ) close( m_info[0] ); /* replace by QSocketNotifier!!! */ m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); connect(m_not, SIGNAL(activated(int) ), this, SLOT(slotRead() ) ); if ( pipe(m_term) < 0 ) m_term[0] = m_term[1] = 0; ProcCtl::self()->add(m_pid, m_term[1] ); m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); connect(m_proc, SIGNAL(activated(int) ), this, SLOT(slotExec() ) ); } break; } } /* |