author | zecke <zecke> | 2002-06-13 19:04:05 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-13 19:04:05 (UTC) |
commit | ed10b73df98c1b4c41a0b940e4f8729fe28c2b8a (patch) (unidiff) | |
tree | 9fe7679c82a41b21de3378090ce211c00a8bc178 /core/applets/obex/obex.cc | |
parent | 9939c618389465ef5837bf510186d583891e65e3 (diff) | |
download | opie-ed10b73df98c1b4c41a0b940e4f8729fe28c2b8a.zip opie-ed10b73df98c1b4c41a0b940e4f8729fe28c2b8a.tar.gz opie-ed10b73df98c1b4c41a0b940e4f8729fe28c2b8a.tar.bz2 |
Stop receiving when wanting to send
-rw-r--r-- | core/applets/obex/obex.cc | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/core/applets/obex/obex.cc b/core/applets/obex/obex.cc index 683964b..2218dbc 100644 --- a/core/applets/obex/obex.cc +++ b/core/applets/obex/obex.cc | |||
@@ -13,12 +13,18 @@ Obex::Obex( QObject *parent, const char* name ) | |||
13 | m_rec = 0; | 13 | m_rec = 0; |
14 | m_send=0; | 14 | m_send=0; |
15 | m_count = 0; | 15 | m_count = 0; |
16 | m_receive = false; | ||
17 | connect( this, SIGNAL(error(int) ), // for recovering to receive | ||
18 | SLOT(slotError() ) ); | ||
19 | connect( this, SIGNAL(sent() ), | ||
20 | SLOT(slotError() ) ); | ||
16 | }; | 21 | }; |
17 | Obex::~Obex() { | 22 | Obex::~Obex() { |
18 | delete m_rec; | 23 | delete m_rec; |
19 | delete m_send; | 24 | delete m_send; |
20 | } | 25 | } |
21 | void Obex::receive() { | 26 | void Obex::receive() { |
27 | m_receive = true; | ||
22 | qWarning("Receive" ); | 28 | qWarning("Receive" ); |
23 | m_rec = new OProcess(); | 29 | m_rec = new OProcess(); |
24 | *m_rec << "irobex_palm3"; | 30 | *m_rec << "irobex_palm3"; |
@@ -32,16 +38,34 @@ void Obex::receive() { | |||
32 | if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 38 | if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
33 | qWarning("could not start :("); | 39 | qWarning("could not start :("); |
34 | emit done( false ); | 40 | emit done( false ); |
41 | delete m_rec; | ||
42 | m_rec = 0; | ||
35 | } | 43 | } |
36 | emit currentTry(m_count ); | 44 | // emit currentTry(m_count ); |
37 | 45 | ||
38 | } | 46 | } |
39 | void Obex::send( const QString& fileName) { | 47 | void Obex::send( const QString& fileName) { // if currently receiving stop it send receive |
40 | m_count = 0; | 48 | m_count = 0; |
41 | m_file = fileName; | 49 | m_file = fileName; |
50 | qWarning("send"); | ||
51 | if (m_rec != 0 ) { | ||
52 | qWarning("running"); | ||
53 | if (m_rec->isRunning() ) { | ||
54 | emit error(-1 ); | ||
55 | qWarning("is running"); | ||
56 | delete m_rec; | ||
57 | m_rec = 0; | ||
58 | |||
59 | }else{ | ||
60 | qWarning("is not running"); | ||
61 | emit error( -1 ); // we did not delete yet but it's not running slotExited is pending | ||
62 | return; | ||
63 | } | ||
64 | } | ||
42 | sendNow(); | 65 | sendNow(); |
43 | } | 66 | } |
44 | void Obex::sendNow(){ | 67 | void Obex::sendNow(){ |
68 | qWarning("sendNow"); | ||
45 | if ( m_count >= 25 ) { // could not send | 69 | if ( m_count >= 25 ) { // could not send |
46 | emit error(-1 ); | 70 | emit error(-1 ); |
47 | return; | 71 | return; |
@@ -56,11 +80,14 @@ void Obex::sendNow(){ | |||
56 | this, SLOT(slotExited(OProcess*)) ); | 80 | this, SLOT(slotExited(OProcess*)) ); |
57 | connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), | 81 | connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), |
58 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); | 82 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); |
83 | |||
59 | // now start it | 84 | // now start it |
60 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { | 85 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { |
61 | qWarning("could not send" ); | 86 | qWarning("could not send" ); |
62 | m_count = 25; | 87 | m_count = 25; |
63 | emit error(-1 ); | 88 | emit error(-1 ); |
89 | delete m_send; | ||
90 | m_send=0; | ||
64 | } | 91 | } |
65 | // end | 92 | // end |
66 | m_count++; | 93 | m_count++; |
@@ -88,9 +115,11 @@ void Obex::recieved() { | |||
88 | emit receivedFile( filename ); | 115 | emit receivedFile( filename ); |
89 | } | 116 | } |
90 | }else{ | 117 | }else{ |
91 | emit error(-1); | 118 | emit done(false); |
92 | }; | 119 | }; |
93 | delete m_rec; | 120 | delete m_rec; |
121 | m_rec = 0; | ||
122 | receive(); | ||
94 | } | 123 | } |
95 | 124 | ||
96 | void Obex::sendEnd() { | 125 | void Obex::sendEnd() { |
@@ -126,3 +155,30 @@ QString Obex::parseOut( ){ | |||
126 | } | 155 | } |
127 | return path; | 156 | return path; |
128 | } | 157 | } |
158 | /** | ||
159 | * when sent is done slotError is called we will start receive again | ||
160 | */ | ||
161 | void Obex::slotError() { | ||
162 | qWarning("slotError"); | ||
163 | if ( m_receive ) | ||
164 | receive(); | ||
165 | }; | ||
166 | void Obex::setReceiveEnabled( bool receive ) { | ||
167 | if ( !receive ) { // | ||
168 | m_receive = false; | ||
169 | shutDownReceive(); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | void Obex::shutDownReceive() { | ||
174 | if (m_rec != 0 ) { | ||
175 | qWarning("running"); | ||
176 | if (m_rec->isRunning() ) { | ||
177 | emit error(-1 ); | ||
178 | qWarning("is running"); | ||
179 | delete m_rec; | ||
180 | m_rec = 0; | ||
181 | } | ||
182 | } | ||
183 | |||
184 | } | ||