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 | |
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 | ||||
-rw-r--r-- | core/applets/obex/obex.h | 4 | ||||
-rw-r--r-- | core/applets/obex/obeximpl.cc | 10 |
3 files changed, 71 insertions, 5 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 | |||
@@ -15,2 +15,7 @@ Obex::Obex( QObject *parent, const char* name ) | |||
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 | }; |
@@ -21,2 +26,3 @@ Obex::~Obex() { | |||
21 | void Obex::receive() { | 26 | void Obex::receive() { |
27 | m_receive = true; | ||
22 | qWarning("Receive" ); | 28 | qWarning("Receive" ); |
@@ -34,9 +40,26 @@ void Obex::receive() { | |||
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(); |
@@ -44,2 +67,3 @@ void Obex::send( const QString& fileName) { | |||
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 |
@@ -58,2 +82,3 @@ void Obex::sendNow(){ | |||
58 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); | 82 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); |
83 | |||
59 | // now start it | 84 | // now start it |
@@ -63,2 +88,4 @@ void Obex::sendNow(){ | |||
63 | emit error(-1 ); | 88 | emit error(-1 ); |
89 | delete m_send; | ||
90 | m_send=0; | ||
64 | } | 91 | } |
@@ -90,5 +117,7 @@ void Obex::recieved() { | |||
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 | } |
@@ -128 +157,28 @@ QString Obex::parseOut( ){ | |||
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 | } | ||
diff --git a/core/applets/obex/obex.h b/core/applets/obex/obex.h index 4e78015..2ce44f2 100644 --- a/core/applets/obex/obex.h +++ b/core/applets/obex/obex.h | |||
@@ -28,2 +28,3 @@ namespace OpieObex { | |||
28 | void send( const QString& ); | 28 | void send( const QString& ); |
29 | void setReceiveEnabled( bool = false ); | ||
29 | signals: | 30 | signals: |
@@ -57,2 +58,4 @@ namespace OpieObex { | |||
57 | OProcess *m_rec; | 58 | OProcess *m_rec; |
59 | bool m_receive : 1; | ||
60 | void shutDownReceive(); | ||
58 | 61 | ||
@@ -69,2 +72,3 @@ namespace OpieObex { | |||
69 | void slotStdOut(OProcess*, char*, int); | 72 | void slotStdOut(OProcess*, char*, int); |
73 | void slotError(); | ||
70 | 74 | ||
diff --git a/core/applets/obex/obeximpl.cc b/core/applets/obex/obeximpl.cc index 856f100..0c137af 100644 --- a/core/applets/obex/obeximpl.cc +++ b/core/applets/obex/obeximpl.cc | |||
@@ -51,2 +51,3 @@ void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { | |||
51 | stream >> filename; | 51 | stream >> filename; |
52 | m_sendgui->raise(); // should be on top | ||
52 | m_sendgui->showMaximized(); | 53 | m_sendgui->showMaximized(); |
@@ -58,5 +59,10 @@ void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { | |||
58 | SLOT( slotSent() ) ); | 59 | SLOT( slotSent() ) ); |
59 | }else if(msg == "receive(bool)" ) { // open a GUI | 60 | }else if(msg == "receive(int)" ) { // open a GUI |
60 | m_recvgui->showMaximized(); | 61 | m_recvgui->showMaximized(); |
62 | int receiveD = 0; | ||
63 | stream >> receiveD; | ||
64 | if ( receiveD == 1) | ||
61 | m_obex->receive(); | 65 | m_obex->receive(); |
66 | else | ||
67 | m_obex->setReceiveEnabled( false ); | ||
62 | 68 | ||
@@ -89,3 +95,3 @@ void ObexImpl::slotError( int errorCode) { | |||
89 | QString errorString = ""; | 95 | QString errorString = ""; |
90 | if (errorCode = -1) { | 96 | if (errorCode == -1) { |
91 | errorString = "test"; | 97 | errorString = "test"; |