Diffstat (limited to 'noncore/apps/opie-console/sz_transfer.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/sz_transfer.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
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 @@ | |||
1 | |||
2 | #include "sz_transfer.h" | ||
3 | #include <qfile.h> | ||
4 | #include <opie/oprocess.h> | ||
5 | |||
6 | SzTransfer::SzTransfer(IOLayer *layer) : FileTransferLayer(layer) | ||
7 | { | ||
8 | } | ||
9 | |||
10 | SzTransfer::~SzTransfer() { | ||
11 | } | ||
12 | |||
13 | void SzTransfer::sendFile(const QFile& file) { | ||
14 | |||
15 | sendFile(file.name()); | ||
16 | } | ||
17 | |||
18 | void SzTransfer::sendFile(const QString& file) { | ||
19 | |||
20 | proc = new OProcess; | ||
21 | *proc << "sz"; | ||
22 | *proc << "-vv" << file; | ||
23 | connect(proc, SIGNAL(processExited(OProcess *)), | ||
24 | this, SLOT(sent())); | ||
25 | connect(proc, SIGNAL(processRecievedStdout(OProcess *, char *, int)), | ||
26 | this, SLOT(SzRecievedStdout(OProcess *, char *, int))); | ||
27 | connect(proc, SIGNAL(processRecievedStderr(OProcess *, char *, int)), | ||
28 | this, SLOT(SzRecievedStderr(OProcess *, char *, int))); | ||
29 | connect(layer(), SIGNAL(received(QByteArray &)), | ||
30 | this, SLOT(recievedStdin(QByteArray &))); | ||
31 | proc->start(OProcess::NotifyOnExit, OProcess::All); | ||
32 | |||
33 | } | ||
34 | |||
35 | void SzTransfer::SzRecievedStdout(OProcess *, char *buffer, int buflen) { | ||
36 | |||
37 | QByteArray data(buflen); | ||
38 | data.fill(*buffer, buflen); | ||
39 | |||
40 | // send out through the io layer | ||
41 | (layer())->send(data); | ||
42 | } | ||
43 | |||
44 | void SzTransfer::SzRecievedStderr(OProcess *, char *, int) { | ||
45 | |||
46 | // parse and show data in a progress dialog/widget | ||
47 | } | ||
48 | |||
49 | void SzTransfer::recievedStdin(QByteArray &data) { | ||
50 | |||
51 | // recieved data from the io layer goes to sz | ||
52 | proc->writeStdin(data.data(), data.size()); | ||
53 | |||
54 | } | ||