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