summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/file_layer.cpp
authorhash <hash>2002-10-01 20:27:21 (UTC)
committer hash <hash>2002-10-01 20:27:21 (UTC)
commit88c3937936dbbb13575425ce9da72d5286bd1233 (patch) (unidiff)
tree75dd4722c885ed76bf08d0b48c2b2f5732c4878d /noncore/apps/opie-console/file_layer.cpp
parent514a68beeb6abd4402bc7187eedc01e5d4793f64 (diff)
downloadopie-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.
Diffstat (limited to 'noncore/apps/opie-console/file_layer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/file_layer.cpp53
1 files changed, 53 insertions, 0 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,4 +1,13 @@
1/*
2 * <zecke> what you would simply do is connect stdout of the sz process
3 * <zecke> to the send slot of the IOLayer
4 * <zecke> and stdin to the receive signal of IOlayer
5 * <zecke> on stderr you can see the progress
6 */
7
1#include "file_layer.h" 8#include "file_layer.h"
9#include <qfile.h>
10#include <opie/oprocess.h>
2 11
3FileTransferLayer::FileTransferLayer(IOLayer *layer) 12FileTransferLayer::FileTransferLayer(IOLayer *layer)
4 : QObject(), m_layer( layer ) 13 : QObject(), m_layer( layer )
@@ -7,7 +16,51 @@ FileTransferLayer::FileTransferLayer(IOLayer *layer)
7 16
8FileTransferLayer::~FileTransferLayer() { 17FileTransferLayer::~FileTransferLayer() {
9} 18}
19
20void FileTransferLayer::sendFile(const QFile& file) {
21
22 sendFile(file.name());
23}
24
25void FileTransferLayer::sendFile(const QString& file) {
26
27 proc = new OProcess;
28 *proc << "sz";
29 *proc << "-vv" << file;
30 connect(proc, SIGNAL(processExited(OProcess *)),
31 this, SLOT(sent()));
32 connect(proc, SIGNAL(processRecievedStdout(OProcess *, char *, int)),
33 this, SLOT(SzRecievedStdout(OProcess *, char *, int)));
34 connect(proc, SIGNAL(processRecievedStderr(OProcess *, char *, int)),
35 this, SLOT(SzRecievedStderr(OProcess *, char *, int)));
36 connect(m_layer, SIGNAL(received(QByteArray &)),
37 this, SLOT(recievedStdin(QByteArray &)));
38 proc->start(OProcess::NotifyOnExit, OProcess::All);
39
40}
41
10IOLayer* FileTransferLayer::layer() { 42IOLayer* FileTransferLayer::layer() {
11 return m_layer; 43 return m_layer;
12} 44}
13 45
46
47void FileTransferLayer::SzRecievedStdout(OProcess *, char *buffer, int buflen) {
48
49 QByteArray data(buflen);
50 data.fill(*buffer, buflen);
51
52 // send out through the io layer
53 m_layer->send(data);
54}
55
56void FileTransferLayer::SzRecievedStderr(OProcess *, char *, int) {
57
58 // parse and show data in a progress dialog/widget
59}
60
61void FileTransferLayer::recievedStdin(QByteArray &data) {
62
63 // recieved data from the io layer goes to sz
64 proc->writeStdin(data.data(), data.size());
65
66}