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.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/core/obex/obex.cc b/core/obex/obex.cc
index 50e5201..3c99af6 100644
--- a/core/obex/obex.cc
+++ b/core/obex/obex.cc
@@ -1,110 +1,111 @@
1 1
2#include <qfileinfo.h> 2#include <qfileinfo.h>
3 3
4 4
5#include <opie/oprocess.h> 5#include <opie2/oprocess.h>
6#include "obex.h" 6#include "obex.h"
7 7
8using namespace OpieObex; 8using namespace OpieObex;
9 9
10using namespace Opie::Core;
10/* TRANSLATOR OpieObex::Obex */ 11/* TRANSLATOR OpieObex::Obex */
11 12
12Obex::Obex( QObject *parent, const char* name ) 13Obex::Obex( QObject *parent, const char* name )
13 : QObject(parent, name ) 14 : QObject(parent, name )
14{ 15{
15 m_rec = 0; 16 m_rec = 0;
16 m_send=0; 17 m_send=0;
17 m_count = 0; 18 m_count = 0;
18 m_receive = false; 19 m_receive = false;
19 connect( this, SIGNAL(error(int) ), // for recovering to receive 20 connect( this, SIGNAL(error(int) ), // for recovering to receive
20 SLOT(slotError() ) ); 21 SLOT(slotError() ) );
21 connect( this, SIGNAL(sent(bool) ), 22 connect( this, SIGNAL(sent(bool) ),
22 SLOT(slotError() ) ); 23 SLOT(slotError() ) );
23}; 24};
24Obex::~Obex() { 25Obex::~Obex() {
25 delete m_rec; 26 delete m_rec;
26 delete m_send; 27 delete m_send;
27} 28}
28void Obex::receive() { 29void Obex::receive() {
29 m_receive = true; 30 m_receive = true;
30 m_outp = QString::null; 31 m_outp = QString::null;
31 qWarning("Receive" ); 32 qWarning("Receive" );
32 m_rec = new OProcess(); 33 m_rec = new OProcess();
33 *m_rec << "irobex_palm3"; 34 *m_rec << "irobex_palm3";
34 // connect to the necessary slots 35 // connect to the necessary slots
35 connect(m_rec, SIGNAL(processExited(OProcess*) ), 36 connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ),
36 this, SLOT(slotExited(OProcess*) ) ); 37 this, SLOT(slotExited(Opie::Core::OProcess*) ) );
37 38
38 connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 39 connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
39 this, SLOT(slotStdOut(OProcess*, char*, int) ) ); 40 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) );
40 41
41 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 42 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
42 qWarning("could not start :("); 43 qWarning("could not start :(");
43 emit done( false ); 44 emit done( false );
44 delete m_rec; 45 delete m_rec;
45 m_rec = 0; 46 m_rec = 0;
46 } 47 }
47// emit currentTry(m_count ); 48// emit currentTry(m_count );
48 49
49} 50}
50void Obex::send( const QString& fileName) { // if currently receiving stop it send receive 51void Obex::send( const QString& fileName) { // if currently receiving stop it send receive
51 m_count = 0; 52 m_count = 0;
52 m_file = fileName; 53 m_file = fileName;
53 qWarning("send %s", fileName.latin1() ); 54 qWarning("send %s", fileName.latin1() );
54 if (m_rec != 0 ) { 55 if (m_rec != 0 ) {
55 qWarning("running"); 56 qWarning("running");
56 if (m_rec->isRunning() ) { 57 if (m_rec->isRunning() ) {
57 emit error(-1 ); 58 emit error(-1 );
58 qWarning("is running"); 59 qWarning("is running");
59 delete m_rec; 60 delete m_rec;
60 m_rec = 0; 61 m_rec = 0;
61 62
62 }else{ 63 }else{
63 qWarning("is not running"); 64 qWarning("is not running");
64 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending 65 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending
65 return; 66 return;
66 } 67 }
67 } 68 }
68 sendNow(); 69 sendNow();
69} 70}
70void Obex::sendNow(){ 71void Obex::sendNow(){
71 qWarning("sendNow"); 72 qWarning("sendNow");
72 if ( m_count >= 25 ) { // could not send 73 if ( m_count >= 25 ) { // could not send
73 emit error(-1 ); 74 emit error(-1 );
74 emit sent(false); 75 emit sent(false);
75 return; 76 return;
76 } 77 }
77 // OProcess inititialisation 78 // OProcess inititialisation
78 m_send = new OProcess(); 79 m_send = new OProcess();
79 *m_send << "irobex_palm3"; 80 *m_send << "irobex_palm3";
80 *m_send << QFile::encodeName(m_file); 81 *m_send << QFile::encodeName(m_file);
81 82
82 // connect to slots Exited and and StdOut 83 // connect to slots Exited and and StdOut
83 connect(m_send, SIGNAL(processExited(OProcess*) ), 84 connect(m_send, SIGNAL(processExited(Opie::Core::OProcess*) ),
84 this, SLOT(slotExited(OProcess*)) ); 85 this, SLOT(slotExited(Opie::Core::OProcess*)) );
85 connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), 86 connect(m_send, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int )),
86 this, SLOT(slotStdOut(OProcess*, char*, int) ) ); 87 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) );
87 88
88 // now start it 89 // now start it
89 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { 90 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) {
90 qWarning("could not send" ); 91 qWarning("could not send" );
91 m_count = 25; 92 m_count = 25;
92 emit error(-1 ); 93 emit error(-1 );
93 delete m_send; 94 delete m_send;
94 m_send=0; 95 m_send=0;
95 } 96 }
96 // end 97 // end
97 m_count++; 98 m_count++;
98 emit currentTry( m_count ); 99 emit currentTry( m_count );
99} 100}
100 101
101void Obex::slotExited(OProcess* proc ){ 102void Obex::slotExited(OProcess* proc ){
102 if (proc == m_rec ) { // receive process 103 if (proc == m_rec ) { // receive process
103 received(); 104 received();
104 }else if ( proc == m_send ) { 105 }else if ( proc == m_send ) {
105 sendEnd(); 106 sendEnd();
106 } 107 }
107} 108}
108void Obex::slotStdOut(OProcess* proc, char* buf, int len){ 109void Obex::slotStdOut(OProcess* proc, char* buf, int len){
109 if ( proc == m_rec ) { // only receive 110 if ( proc == m_rec ) { // only receive
110 QByteArray ar( len ); 111 QByteArray ar( len );