summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/sz_transfer.cpp35
-rw-r--r--noncore/apps/opie-console/sz_transfer.h7
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 @@
1 1
2#include "sz_transfer.h" 2#include "sz_transfer.h"
3#include <qfile.h> 3#include <qfile.h>
4#include <opie/oprocess.h> 4#include <opie/oprocess.h>
5#include <stdio.h>
5 6
6SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) 7SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t)
7{ 8{
8} 9}
9 10
10SzTransfer::~SzTransfer() { 11SzTransfer::~SzTransfer() {
11} 12}
12 13
13void SzTransfer::sendFile(const QFile& file) { 14void SzTransfer::sendFile(const QFile& file) {
14 15
15 sendFile(file.name()); 16 sendFile(file.name());
16} 17}
17 18
18void SzTransfer::sendFile(const QString& file) { 19void SzTransfer::sendFile(const QString& file) {
19 20
20 proc = new OProcess; 21 proc = new OProcess;
21 *proc << "sz"; 22 *proc << "sz";
22 *proc << "-vv" << file; 23 *proc << "-v" << "-v" << "-v" << "-b" << file;
23 connect(proc, SIGNAL(processExited(OProcess *)), 24 connect(proc, SIGNAL(processExited(OProcess *)),
24 this, SLOT(sent())); 25 this, SLOT(sent()));
25 connect(proc, SIGNAL(processRecievedStdout(OProcess *, char *, int)), 26 connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
26 this, SLOT(SzRecievedStdout(OProcess *, char *, int))); 27 this, SLOT(SzReceivedStdout(OProcess *, char *, int)));
27 connect(proc, SIGNAL(processRecievedStderr(OProcess *, char *, int)), 28 connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
28 this, SLOT(SzRecievedStderr(OProcess *, char *, int))); 29 this, SLOT(SzReceivedStderr(OProcess *, char *, int)));
29 connect(layer(), SIGNAL(received(QByteArray &)), 30 connect(layer(), SIGNAL(received(const QByteArray &)),
30 this, SLOT(recievedStdin(QByteArray &))); 31 this, SLOT(receivedStdin(const QByteArray &)));
31 proc->start(OProcess::NotifyOnExit, OProcess::All); 32 proc->start(OProcess::NotifyOnExit, OProcess::All);
32 33
33} 34}
34 35
35void SzTransfer::SzRecievedStdout(OProcess *, char *buffer, int buflen) { 36void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) {
37
38 qWarning("recieved from sz %d bytes", buflen);
36 39
37 QByteArray data(buflen); 40 QByteArray data(buflen);
38 data.fill(*buffer, buflen); 41 data.fill(*buffer, buflen);
39 42
40 // send out through the io layer 43 // send out through the io layer
41 (layer())->send(data); 44 (layer())->send(data);
42} 45}
43 46
44void SzTransfer::SzRecievedStderr(OProcess *, char *, int) { 47void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) {
45 48
46 // parse and show data in a progress dialog/widget 49 // parse and show data in a progress dialog/widget
50 printf("\n");
51 for (int i = 0; i < length; i++)
52 printf("%c", buffer[i]);
47} 53}
48 54
49void SzTransfer::recievedStdin(QByteArray &data) { 55void SzTransfer::receivedStdin(const QByteArray &data) {
50 56
57 qWarning("recieved from io_serial %d bytes", data.size());
51 // recieved data from the io layer goes to sz 58 // recieved data from the io layer goes to sz
52 proc->writeStdin(data.data(), data.size()); 59 proc->writeStdin(data.data(), data.size());
53 60
54} 61}
62
63void SzTransfer::sent() {
64
65 qWarning("sent file");
66 delete proc;
67 disconnect(layer(), SIGNAL(received(const QByteArray &)),
68 this, SLOT(receivedStdin(const QByteArray &)));
69}
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
@@ -15,25 +15,26 @@ public:
15 SY 15 SY
16 }; 16 };
17 17
18 SzTransfer( Type t, IOLayer * ); 18 SzTransfer( Type t, IOLayer * );
19 ~SzTransfer(); 19 ~SzTransfer();
20 20
21public slots: 21public slots:
22 /** 22 /**
23 * send a file over the layer 23 * send a file over the layer
24 */ 24 */
25 void sendFile( const QString& file ) ; 25 void sendFile( const QString& file ) ;
26 void sendFile( const QFile& ); 26 void sendFile( const QFile& );
27 void sent();
27 28
28private slots: 29private slots:
29 void SzRecievedStdout(OProcess *, char *, int); 30 void SzReceivedStdout(OProcess *, char *, int);
30 void SzRecievedStderr(OProcess *, char *, int); 31 void SzReceivedStderr(OProcess *, char *, int);
31 void recievedStdin(QByteArray &); 32 void receivedStdin(const QByteArray &);
32 33
33private: 34private:
34 OProcess *proc; 35 OProcess *proc;
35 Type m_t; 36 Type m_t;
36 37
37}; 38};
38 39
39#endif 40#endif