-rw-r--r-- | noncore/apps/opie-console/sz_transfer.cpp | 35 | ||||
-rw-r--r-- | noncore/apps/opie-console/sz_transfer.h | 7 |
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 | ||
6 | SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) | 7 | SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) |
7 | { | 8 | { |
8 | } | 9 | } |
9 | 10 | ||
10 | SzTransfer::~SzTransfer() { | 11 | SzTransfer::~SzTransfer() { |
11 | } | 12 | } |
12 | 13 | ||
13 | void SzTransfer::sendFile(const QFile& file) { | 14 | void SzTransfer::sendFile(const QFile& file) { |
14 | 15 | ||
15 | sendFile(file.name()); | 16 | sendFile(file.name()); |
16 | } | 17 | } |
17 | 18 | ||
18 | void SzTransfer::sendFile(const QString& file) { | 19 | void 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 | ||
35 | void SzTransfer::SzRecievedStdout(OProcess *, char *buffer, int buflen) { | 36 | void 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 | ||
44 | void SzTransfer::SzRecievedStderr(OProcess *, char *, int) { | 47 | void 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 | ||
49 | void SzTransfer::recievedStdin(QByteArray &data) { | 55 | void 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 | |||
63 | void 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 | ||
21 | public slots: | 21 | public 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 | ||
28 | private slots: | 29 | private 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 | ||
33 | private: | 34 | private: |
34 | OProcess *proc; | 35 | OProcess *proc; |
35 | Type m_t; | 36 | Type m_t; |
36 | 37 | ||
37 | }; | 38 | }; |
38 | 39 | ||
39 | #endif | 40 | #endif |