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.cc15
1 files changed, 3 insertions, 12 deletions
diff --git a/core/obex/obex.cc b/core/obex/obex.cc
index 595fed9..2a306de 100644
--- a/core/obex/obex.cc
+++ b/core/obex/obex.cc
@@ -1,37 +1,39 @@
1 1
2#include <qapplication.h> 2#include <qapplication.h>
3#include <qfile.h> 3#include <qfile.h>
4#include <qfileinfo.h> 4#include <qfileinfo.h>
5#include <qtextcodec.h> 5#include <qtextcodec.h>
6 6
7#include <qpe/qcopenvelope_qws.h> 7#include <qpe/qcopenvelope_qws.h>
8 8
9#include <opie/oprocess.h> 9#include <opie/oprocess.h>
10#include "obex.h" 10#include "obex.h"
11 11
12using namespace OpieObex; 12using namespace OpieObex;
13 13
14/* TRANSLATOR OpieObex::Obex */
15
14Obex::Obex( QObject *parent, const char* name ) 16Obex::Obex( QObject *parent, const char* name )
15 : QObject(parent, name ) 17 : QObject(parent, name )
16{ 18{
17 m_rec = 0; 19 m_rec = 0;
18 m_send=0; 20 m_send=0;
19 m_count = 0; 21 m_count = 0;
20 m_receive = false; 22 m_receive = false;
21 connect( this, SIGNAL(error(int) ), // for recovering to receive 23 connect( this, SIGNAL(error(int) ), // for recovering to receive
22 SLOT(slotError() ) ); 24 SLOT(slotError() ) );
23 connect( this, SIGNAL(sent(bool) ), 25 connect( this, SIGNAL(sent(bool) ),
24 SLOT(slotError() ) ); 26 SLOT(slotError() ) );
25}; 27};
26Obex::~Obex() { 28Obex::~Obex() {
27 delete m_rec; 29 delete m_rec;
28 delete m_send; 30 delete m_send;
29} 31}
30void Obex::receive() { 32void Obex::receive() {
31 m_receive = true; 33 m_receive = true;
32 m_outp = QString::null; 34 m_outp = QString::null;
33 qWarning("Receive" ); 35 qWarning("Receive" );
34 m_rec = new OProcess(); 36 m_rec = new OProcess();
35 *m_rec << "irobex_palm3"; 37 *m_rec << "irobex_palm3";
36 // connect to the necessary slots 38 // connect to the necessary slots
37 connect(m_rec, SIGNAL(processExited(OProcess*) ), 39 connect(m_rec, SIGNAL(processExited(OProcess*) ),
@@ -88,71 +90,60 @@ void Obex::sendNow(){
88 this, SLOT(slotStdOut(OProcess*, char*, int) ) ); 90 this, SLOT(slotStdOut(OProcess*, char*, int) ) );
89 91
90 // now start it 92 // now start it
91 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { 93 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) {
92 qWarning("could not send" ); 94 qWarning("could not send" );
93 m_count = 25; 95 m_count = 25;
94 emit error(-1 ); 96 emit error(-1 );
95 delete m_send; 97 delete m_send;
96 m_send=0; 98 m_send=0;
97 } 99 }
98 // end 100 // end
99 m_count++; 101 m_count++;
100 emit currentTry( m_count ); 102 emit currentTry( m_count );
101} 103}
102 104
103void Obex::slotExited(OProcess* proc ){ 105void Obex::slotExited(OProcess* proc ){
104 if (proc == m_rec ) { // receive process 106 if (proc == m_rec ) { // receive process
105 received(); 107 received();
106 }else if ( proc == m_send ) { 108 }else if ( proc == m_send ) {
107 sendEnd(); 109 sendEnd();
108 } 110 }
109} 111}
110void Obex::slotStdOut(OProcess* proc, char* buf, int len){ 112void Obex::slotStdOut(OProcess* proc, char* buf, int len){
111 if ( proc == m_rec ) { // only receive 113 if ( proc == m_rec ) { // only receive
112 for (int i = 0; i < len; i++ ) { 114 QByteArray ar( len );
113 printf("%c", buf[i] );
114 }
115 printf("\n");
116 QByteArray ar( len );
117 memcpy( ar.data(), buf, len ); 115 memcpy( ar.data(), buf, len );
118 qWarning("parsed: %s", ar.data() ); 116 qWarning("parsed: %s", ar.data() );
119 m_outp.append( ar ); 117 m_outp.append( ar );
120 } 118 }
121} 119}
122 120
123void Obex::received() { 121void Obex::received() {
124 if (m_rec->normalExit() ) { 122 if (m_rec->normalExit() ) {
125 if ( m_rec->exitStatus() == 0 ) { // we got one 123 if ( m_rec->exitStatus() == 0 ) { // we got one
126 QString filename = parseOut(); 124 QString filename = parseOut();
127 qWarning("ACHTUNG %s", filename.latin1() ); 125 qWarning("ACHTUNG %s", filename.latin1() );
128 if (filename.contains( 'ö' ) || filename.contains( 'ä' ) || filename.contains('ü' ) ) {
129 qWarning("renaming!!!!");
130 QFileInfo inf( filename );
131 QString newName = "/tmp/opie-obex." + inf.extension();
132 ::rename( QFile::encodeName( filename ).data(), newName );
133 qWarning("name is %s", QFile::encodeName( filename ).data() );
134 }
135 emit receivedFile( filename ); 126 emit receivedFile( filename );
136 } 127 }
137 }else{ 128 }else{
138 emit done(false); 129 emit done(false);
139 }; 130 };
140 delete m_rec; 131 delete m_rec;
141 m_rec = 0; 132 m_rec = 0;
142 receive(); 133 receive();
143} 134}
144 135
145void Obex::sendEnd() { 136void Obex::sendEnd() {
146 if (m_send->normalExit() ) { 137 if (m_send->normalExit() ) {
147 if ( m_send->exitStatus() == 0 ) { 138 if ( m_send->exitStatus() == 0 ) {
148 delete m_send; 139 delete m_send;
149 m_send=0; 140 m_send=0;
150 qWarning("done" ); 141 qWarning("done" );
151 emit sent(true); 142 emit sent(true);
152 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready 143 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready
153 // let's try it again 144 // let's try it again
154 delete m_send; 145 delete m_send;
155 m_send = 0; 146 m_send = 0;
156 qWarning("try sending again" ); 147 qWarning("try sending again" );
157 sendNow(); 148 sendNow();
158 } 149 }