From ed032e9e5b7a260e9ec05a0cc13a138dad5085d5 Mon Sep 17 00:00:00 2001 From: hash Date: Mon, 07 Oct 2002 08:18:40 +0000 Subject: separated from the interface --- (limited to 'noncore') diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp new file mode 100644 index 0000000..de321ae --- a/dev/null +++ b/noncore/apps/opie-console/sz_transfer.cpp @@ -0,0 +1,54 @@ + +#include "sz_transfer.h" +#include +#include + +SzTransfer::SzTransfer(IOLayer *layer) : FileTransferLayer(layer) +{ +} + +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; + 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 &))); + proc->start(OProcess::NotifyOnExit, OProcess::All); + +} + +void SzTransfer::SzRecievedStdout(OProcess *, char *buffer, int buflen) { + + QByteArray data(buflen); + data.fill(*buffer, buflen); + + // send out through the io layer + (layer())->send(data); +} + +void SzTransfer::SzRecievedStderr(OProcess *, char *, int) { + + // parse and show data in a progress dialog/widget +} + +void SzTransfer::recievedStdin(QByteArray &data) { + + // recieved data from the io layer goes to sz + proc->writeStdin(data.data(), data.size()); + +} diff --git a/noncore/apps/opie-console/sz_transfer.h b/noncore/apps/opie-console/sz_transfer.h new file mode 100644 index 0000000..778d1d3 --- a/dev/null +++ b/noncore/apps/opie-console/sz_transfer.h @@ -0,0 +1,33 @@ +#ifndef OPIE_FL_SZ_H +#define OPIE_FL_SZ_H + +#include "file_layer.h" +#include + +class SzTransfer : public FileTransferLayer { + + Q_OBJECT + +public: + + SzTransfer( IOLayer * ); + ~SzTransfer(); + +public slots: + /** + * send a file over the layer + */ + void sendFile( const QString& file ) = 0; + void sendFile( const QFile& ) = 0; + +private slots: + void SzRecievedStdout(OProcess *, char *, int); + void SzRecievedStderr(OProcess *, char *, int); + void recievedStdin(QByteArray &); + +private: + OProcess *proc; + +}; + +#endif diff --git a/noncore/apps/opie-console/sz_transfer.o b/noncore/apps/opie-console/sz_transfer.o new file mode 100644 index 0000000..8eb4fbf --- a/dev/null +++ b/noncore/apps/opie-console/sz_transfer.o Binary files differ -- cgit v0.9.0.2