summaryrefslogtreecommitdiff
path: root/core/obex/obex.cc
Unidiff
Diffstat (limited to 'core/obex/obex.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/obex.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/obex/obex.cc b/core/obex/obex.cc
index 92cd317..b8ed6e0 100644
--- a/core/obex/obex.cc
+++ b/core/obex/obex.cc
@@ -1,44 +1,44 @@
1 1
2#include <qapplication.h> 2#include <qapplication.h>
3#include <qfile.h> 3#include <qfile.h>
4#include <qmessagebox.h> 4#include <qmessagebox.h>
5#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6#include <opie/oprocess.h> 6#include <opie/oprocess.h>
7#include "obex.h" 7#include "obex.h"
8 8
9using namespace OpieObex; 9using namespace OpieObex;
10 10
11Obex::Obex( QObject *parent, const char* name ) 11Obex::Obex( QObject *parent, const char* name )
12 : QObject(parent, name ) 12 : QObject(parent, name )
13{ 13{
14 m_rec = 0; 14 m_rec = 0;
15 m_send=0; 15 m_send=0;
16 m_count = 0; 16 m_count = 0;
17 m_receive = false; 17 m_receive = false;
18 connect( this, SIGNAL(error(int) ), // for recovering to receive 18 connect( this, SIGNAL(error(int) ), // for recovering to receive
19 SLOT(slotError() ) ); 19 SLOT(slotError() ) );
20 connect( this, SIGNAL(sent() ), 20 connect( this, SIGNAL(sent(bool) ),
21 SLOT(slotError() ) ); 21 SLOT(slotError() ) );
22}; 22};
23Obex::~Obex() { 23Obex::~Obex() {
24 delete m_rec; 24 delete m_rec;
25 delete m_send; 25 delete m_send;
26} 26}
27void Obex::receive() { 27void Obex::receive() {
28 m_receive = true; 28 m_receive = true;
29 m_outp = QString::null; 29 m_outp = QString::null;
30 qWarning("Receive" ); 30 qWarning("Receive" );
31 m_rec = new OProcess(); 31 m_rec = new OProcess();
32 *m_rec << "irobex_palm3"; 32 *m_rec << "irobex_palm3";
33 // connect to the necessary slots 33 // connect to the necessary slots
34 connect(m_rec, SIGNAL(processExited(OProcess*) ), 34 connect(m_rec, SIGNAL(processExited(OProcess*) ),
35 this, SLOT(slotExited(OProcess*) ) ); 35 this, SLOT(slotExited(OProcess*) ) );
36 36
37 connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 37 connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
38 this, SLOT(slotStdOut(OProcess*, char*, int) ) ); 38 this, SLOT(slotStdOut(OProcess*, char*, int) ) );
39 39
40 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 40 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
41 qWarning("could not start :("); 41 qWarning("could not start :(");
42 emit done( false ); 42 emit done( false );
43 delete m_rec; 43 delete m_rec;
44 m_rec = 0; 44 m_rec = 0;
@@ -85,58 +85,58 @@ void Obex::sendNow(){
85 this, SLOT(slotStdOut(OProcess*, char*, int) ) ); 85 this, SLOT(slotStdOut(OProcess*, char*, int) ) );
86 86
87 // now start it 87 // now start it
88 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { 88 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) {
89 qWarning("could not send" ); 89 qWarning("could not send" );
90 m_count = 25; 90 m_count = 25;
91 emit error(-1 ); 91 emit error(-1 );
92 delete m_send; 92 delete m_send;
93 m_send=0; 93 m_send=0;
94 } 94 }
95 // end 95 // end
96 m_count++; 96 m_count++;
97 emit currentTry( m_count ); 97 emit currentTry( m_count );
98} 98}
99 99
100void Obex::slotExited(OProcess* proc ){ 100void Obex::slotExited(OProcess* proc ){
101 if (proc == m_rec ) { // receive process 101 if (proc == m_rec ) { // receive process
102 received(); 102 received();
103 }else if ( proc == m_send ) { 103 }else if ( proc == m_send ) {
104 sendEnd(); 104 sendEnd();
105 } 105 }
106} 106}
107void Obex::slotStdOut(OProcess* proc, char* buf, int len){ 107void Obex::slotStdOut(OProcess* proc, char* buf, int len){
108 if ( proc == m_rec ) { // only receive 108 if ( proc == m_rec ) { // only receive
109 QCString cstring( buf, len ); 109 QString str = QString::fromUtf8( buf, len );
110 m_outp.append( cstring.data() ); 110 m_outp.append( str );
111 } 111 }
112} 112}
113 113
114void Obex::received() { 114void Obex::received() {
115 if (m_rec->normalExit() ) { 115 if (m_rec->normalExit() ) {
116 if ( m_rec->exitStatus() == 0 ) { // we got one 116 if ( m_rec->exitStatus() == 0 ) { // we got one
117 QString filename = parseOut(); 117 QString filename = parseOut();
118 qWarning("ACHTUNG"); 118 qWarning("ACHTUNG %s", filename.latin1() );
119 emit receivedFile( filename ); 119 emit receivedFile( filename );
120 } 120 }
121 }else{ 121 }else{
122 emit done(false); 122 emit done(false);
123 }; 123 };
124 delete m_rec; 124 delete m_rec;
125 m_rec = 0; 125 m_rec = 0;
126 receive(); 126 receive();
127} 127}
128 128
129void Obex::sendEnd() { 129void Obex::sendEnd() {
130 if (m_send->normalExit() ) { 130 if (m_send->normalExit() ) {
131 if ( m_send->exitStatus() == 0 ) { 131 if ( m_send->exitStatus() == 0 ) {
132 delete m_send; 132 delete m_send;
133 m_send=0; 133 m_send=0;
134 qWarning("done" ); 134 qWarning("done" );
135 emit sent(true); 135 emit sent(true);
136 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready 136 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready
137 // let's try it again 137 // let's try it again
138 delete m_send; 138 delete m_send;
139 m_send = 0; 139 m_send = 0;
140 qWarning("try sending again" ); 140 qWarning("try sending again" );
141 sendNow(); 141 sendNow();
142 } 142 }