-rw-r--r-- | noncore/apps/opie-console/sz_transfer.cpp | 35 | ||||
-rw-r--r-- | noncore/apps/opie-console/sz_transfer.h | 7 |
2 files changed, 29 insertions, 13 deletions
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp index 10f3f7a..a5af2be 100644 --- a/noncore/apps/opie-console/sz_transfer.cpp +++ b/noncore/apps/opie-console/sz_transfer.cpp @@ -1,54 +1,69 @@ #include "sz_transfer.h" #include <qfile.h> #include <opie/oprocess.h> +#include <stdio.h> SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) { } SzTransfer::~SzTransfer() { } void SzTransfer::sendFile(const QFile& file) { sendFile(file.name()); } void SzTransfer::sendFile(const QString& file) { proc = new OProcess; *proc << "sz"; - *proc << "-vv" << file; + *proc << "-v" << "-v" << "-v" << "-b" << file; connect(proc, SIGNAL(processExited(OProcess *)), this, SLOT(sent())); - connect(proc, SIGNAL(processRecievedStdout(OProcess *, char *, int)), - this, SLOT(SzRecievedStdout(OProcess *, char *, int))); - connect(proc, SIGNAL(processRecievedStderr(OProcess *, char *, int)), - this, SLOT(SzRecievedStderr(OProcess *, char *, int))); - connect(layer(), SIGNAL(received(QByteArray &)), - this, SLOT(recievedStdin(QByteArray &))); + connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), + this, SLOT(SzReceivedStdout(OProcess *, char *, int))); + connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), + this, SLOT(SzReceivedStderr(OProcess *, char *, int))); + connect(layer(), SIGNAL(received(const QByteArray &)), + this, SLOT(receivedStdin(const QByteArray &))); proc->start(OProcess::NotifyOnExit, OProcess::All); } -void SzTransfer::SzRecievedStdout(OProcess *, char *buffer, int buflen) { +void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { + + qWarning("recieved from sz %d bytes", buflen); QByteArray data(buflen); data.fill(*buffer, buflen); // send out through the io layer (layer())->send(data); } -void SzTransfer::SzRecievedStderr(OProcess *, char *, int) { +void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { // parse and show data in a progress dialog/widget + printf("\n"); + for (int i = 0; i < length; i++) + printf("%c", buffer[i]); } -void SzTransfer::recievedStdin(QByteArray &data) { +void SzTransfer::receivedStdin(const QByteArray &data) { + qWarning("recieved from io_serial %d bytes", data.size()); // recieved data from the io layer goes to sz proc->writeStdin(data.data(), data.size()); } + +void SzTransfer::sent() { + + qWarning("sent file"); + delete proc; + disconnect(layer(), SIGNAL(received(const QByteArray &)), + this, SLOT(receivedStdin(const QByteArray &))); +} diff --git a/noncore/apps/opie-console/sz_transfer.h b/noncore/apps/opie-console/sz_transfer.h index 825680d..d3e6621 100644 --- a/noncore/apps/opie-console/sz_transfer.h +++ b/noncore/apps/opie-console/sz_transfer.h @@ -1,39 +1,40 @@ #ifndef OPIE_FL_SZ_H #define OPIE_FL_SZ_H #include "file_layer.h" #include <opie/oprocess.h> class SzTransfer : public FileTransferLayer { Q_OBJECT public: enum Type { SZ=0, SX, SY }; SzTransfer( Type t, IOLayer * ); ~SzTransfer(); public slots: /** * send a file over the layer */ void sendFile( const QString& file ) ; void sendFile( const QFile& ); + void sent(); private slots: - void SzRecievedStdout(OProcess *, char *, int); - void SzRecievedStderr(OProcess *, char *, int); - void recievedStdin(QByteArray &); + void SzReceivedStdout(OProcess *, char *, int); + void SzReceivedStderr(OProcess *, char *, int); + void receivedStdin(const QByteArray &); private: OProcess *proc; Type m_t; }; #endif |