summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-console/filetransfer.cpp55
-rw-r--r--noncore/apps/opie-console/test/console.pro4
2 files changed, 27 insertions, 32 deletions
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp
index 7fd9f37..97552fe 100644
--- a/noncore/apps/opie-console/filetransfer.cpp
+++ b/noncore/apps/opie-console/filetransfer.cpp
@@ -9,28 +9,16 @@
#include <opie/oprocess.h>
+#include "procctl.h"
#include "filetransfer.h"
-/**
- *
- *
-class FileTransferControl {
-public:
- FileTransferControl();
- ~FileTransferControl();
-
-
-};
-*/
-
-bool FileTransfer::terminate = false;
-pid_t FileTransfer::m_pid;
FileTransfer::FileTransfer( Type t, IOLayer* lay )
: FileTransferLayer( lay ), m_type( t ) {
signal(SIGPIPE, SIG_IGN );
- signal( SIGCHLD, signal_handler );
+
m_not = 0l;
+ m_proc = 0l;
}
FileTransfer::~FileTransfer() {
}
@@ -100,15 +88,20 @@ void FileTransfer::sendFile( const QString& file ) {
if ( m_info[0] )
close( m_info[0] );
- terminate = false;
- fd_set fds;
- struct timeval timeout;
- int sel;
+
/* 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;
}
@@ -119,17 +112,6 @@ void FileTransfer::sendFile( const QString& file ) {
void FileTransfer::sendFile( const QFile& file ) {
sendFile( file.name() );
}
-/*
- * our signal handler to be replaced by
- * a procctl thingie
- */
-void FileTransfer::signal_handler(int ) {
- qWarning("Terminated");
- int status;
- signal( SIGCHLD, signal_handler );
- waitpid( m_pid, &status, WNOHANG );
- terminate = true;
-}
/*
* setting up communication
@@ -175,6 +157,7 @@ void FileTransfer::slotRead() {
}
ar.resize( len );
QString str( ar );
+ qWarning(str.simplifyWhiteSpace() );
QStringList lis = QStringList::split(' ', str );
/*
* Transfer finished.. either complete or incomplete
@@ -240,3 +223,15 @@ void FileTransfer::cancel() {
::kill(m_pid,9 );
delete m_not;
}
+void FileTransfer::slotExec() {
+ qWarning("exited!");
+ char buf[2];
+ ::read(m_term[0], buf, 1 );
+ delete m_proc;
+ delete m_not;
+ close( m_term[0] );
+ close( m_term[1] );
+ close( m_comm[0] );
+ close( m_comm[1] );
+ emit sent();
+}
diff --git a/noncore/apps/opie-console/test/console.pro b/noncore/apps/opie-console/test/console.pro
index 9fe8e13..af0e9f7 100644
--- a/noncore/apps/opie-console/test/console.pro
+++ b/noncore/apps/opie-console/test/console.pro
@@ -3,10 +3,10 @@ TEMPLATE = app
CONFIG = qt debug
#DESTDIR = $(OPIEDIR)/bin
HEADERS = ../io_layer.h ../io_serial.h ../sz_transfer.h ../file_layer.h\
- senderui.h ../profile.h ../filetransfer.h
+ senderui.h ../profile.h ../filetransfer.h ../procctl.h
SOURCES = ../io_layer.cpp ../io_serial.cpp \
../profile.cpp ../sz_transfer.cpp ../file_layer.cpp\
- main.cpp senderui.cpp ../filetransfer.cpp
+ main.cpp senderui.cpp ../filetransfer.cpp ../procctl.cpp
INTERFACES = sender.ui
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include