author | hash <hash> | 2002-10-01 20:27:21 (UTC) |
---|---|---|
committer | hash <hash> | 2002-10-01 20:27:21 (UTC) |
commit | 88c3937936dbbb13575425ce9da72d5286bd1233 (patch) (side-by-side diff) | |
tree | 75dd4722c885ed76bf08d0b48c2b2f5732c4878d | |
parent | 514a68beeb6abd4402bc7187eedc01e5d4793f64 (diff) | |
download | opie-88c3937936dbbb13575425ce9da72d5286bd1233.zip opie-88c3937936dbbb13575425ce9da72d5286bd1233.tar.gz opie-88c3937936dbbb13575425ce9da72d5286bd1233.tar.bz2 |
i'm kinda embarrased to commit this cus i really dont know how it's supposed
to work yet. if anyone has any pointers, please dont hesitate to tell me.
-rw-r--r-- | noncore/apps/opie-console/file_layer.cpp | 53 | ||||
-rw-r--r-- | noncore/apps/opie-console/file_layer.h | 11 |
2 files changed, 60 insertions, 4 deletions
diff --git a/noncore/apps/opie-console/file_layer.cpp b/noncore/apps/opie-console/file_layer.cpp index 3ff85af..4830f3b 100644 --- a/noncore/apps/opie-console/file_layer.cpp +++ b/noncore/apps/opie-console/file_layer.cpp @@ -1,13 +1,66 @@ +/* + * <zecke> what you would simply do is connect stdout of the sz process + * <zecke> to the send slot of the IOLayer + * <zecke> and stdin to the receive signal of IOlayer + * <zecke> on stderr you can see the progress + */ + #include "file_layer.h" +#include <qfile.h> +#include <opie/oprocess.h> FileTransferLayer::FileTransferLayer(IOLayer *layer) : QObject(), m_layer( layer ) { } FileTransferLayer::~FileTransferLayer() { } + +void FileTransferLayer::sendFile(const QFile& file) { + + sendFile(file.name()); +} + +void FileTransferLayer::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(m_layer, SIGNAL(received(QByteArray &)), + this, SLOT(recievedStdin(QByteArray &))); + proc->start(OProcess::NotifyOnExit, OProcess::All); + +} + IOLayer* FileTransferLayer::layer() { return m_layer; } + +void FileTransferLayer::SzRecievedStdout(OProcess *, char *buffer, int buflen) { + + QByteArray data(buflen); + data.fill(*buffer, buflen); + + // send out through the io layer + m_layer->send(data); +} + +void FileTransferLayer::SzRecievedStderr(OProcess *, char *, int) { + + // parse and show data in a progress dialog/widget +} + +void FileTransferLayer::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/file_layer.h b/noncore/apps/opie-console/file_layer.h index 035e125..71a0c82 100644 --- a/noncore/apps/opie-console/file_layer.h +++ b/noncore/apps/opie-console/file_layer.h @@ -1,10 +1,11 @@ #ifndef OPIE_FILE_LAYER_H #define OPIE_FILE_LAYER_H #include "io_layer.h" +#include <opie/oprocess.h> class QFile; /** * this is the layer for sending files */ class FileTransferLayer : public QObject { @@ -18,18 +19,19 @@ public: public slots: /** * send a file over the layer */ virtual void sendFile( const QString& file ) = 0; - - /** - * convience method - */ virtual void sendFile( const QFile& ) = 0; +private slots: + void SzRecievedStdout(OProcess *, char *, int); + void SzRecievedStderr(OProcess *, char *, int); + void recievedStdin(QByteArray &); + signals: /** * sent the file */ void sent(); @@ -47,10 +49,11 @@ signals: protected: IOLayer* layer(); private: IOLayer* m_layer; + OProcess *proc; }; #endif |