-rw-r--r-- | core/obex/btobex.cpp | 87 | ||||
-rw-r--r-- | core/obex/btobex.h | 14 |
2 files changed, 57 insertions, 44 deletions
diff --git a/core/obex/btobex.cpp b/core/obex/btobex.cpp index 886f3dc..a5bfe5f 100644 --- a/core/obex/btobex.cpp +++ b/core/obex/btobex.cpp | |||
@@ -2,4 +2,4 @@ | |||
2 | #include "btobex.h" | 2 | #include "btobex.h" |
3 | #include <opietooth/manager.h> | 3 | #include <manager.h> |
4 | #include <opietooth/services.h> | 4 | #include <services.h> |
5 | 5 | ||
@@ -67,2 +67,10 @@ void BtObex::send( const QString& fileName, const QString& bdaddr) { | |||
67 | m_bdaddr = bdaddr; | 67 | m_bdaddr = bdaddr; |
68 | if (m_send != 0) { | ||
69 | if (m_send->isSending()) | ||
70 | return; | ||
71 | else { | ||
72 | delete m_send; | ||
73 | m_send = 0; | ||
74 | } | ||
75 | } | ||
68 | if (m_rec != 0 ) { | 76 | if (m_rec != 0 ) { |
@@ -127,2 +135,4 @@ void BtObex::slotFoundServices(const QString&, Services::ValueList svcList) | |||
127 | void BtObex::sendNow(){ | 135 | void BtObex::sendNow(){ |
136 | QString m_dst = ""; | ||
137 | int result; //function call result | ||
128 | if ( m_count >= 25 ) { // could not send | 138 | if ( m_count >= 25 ) { // could not send |
@@ -133,19 +143,17 @@ void BtObex::sendNow(){ | |||
133 | // OProcess inititialisation | 143 | // OProcess inititialisation |
134 | m_send = new OProcess(0, "ussp-push"); | 144 | m_send = new ObexPush(); |
135 | m_send->setWorkingDirectory( QFileInfo(m_file).dirPath(true) ); | ||
136 | |||
137 | // ussp-push --timeo 30 <btaddr:port> file file | ||
138 | *m_send << "ussp-push" << "--timeo 30"; | ||
139 | *m_send << m_bdaddr + "@" + QString::number(m_port); | ||
140 | *m_send << QFile::encodeName(QFileInfo(m_file).fileName()); | ||
141 | *m_send << QFile::encodeName(QFileInfo(m_file).fileName()); | ||
142 | m_send->setUseShell(true); | ||
143 | |||
144 | // connect to slots Exited and and StdOut | 145 | // connect to slots Exited and and StdOut |
145 | connect(m_send, SIGNAL(processExited(Opie::Core::OProcess*) ), | 146 | connect(m_send, SIGNAL(sendComplete(int)), |
146 | this, SLOT(slotExited(Opie::Core::OProcess*)) ); | 147 | this, SLOT(slotPushComplete(int)) ); |
147 | connect(m_send, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), | 148 | connect(m_send, SIGNAL(sendError(int)), |
148 | this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); | 149 | this, SLOT(slotPushError(int)) ); |
150 | connect(m_send, SIGNAL(status(QCString&)), | ||
151 | this, SLOT(slotPushStatus(QCString&) ) ); | ||
152 | |||
153 | ::sleep(4); | ||
149 | // now start it | 154 | // now start it |
150 | if (!m_send->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 155 | result = m_send->send(m_bdaddr, m_port, m_file, m_dst); |
156 | if (result > 0) //Sending process is actually running | ||
157 | return; | ||
158 | else if (result < 0) { | ||
151 | m_count = 25; | 159 | m_count = 25; |
@@ -165,5 +173,2 @@ void BtObex::slotExited(OProcess* proc ){ | |||
165 | received(); | 173 | received(); |
166 | else if ( proc == m_send ) | ||
167 | sendEnd(); | ||
168 | |||
169 | } | 174 | } |
@@ -177,19 +182,4 @@ void BtObex::slotStdOut(OProcess* proc, char* buf, int len){ | |||
177 | 182 | ||
178 | void BtObex::received() { | 183 | void BtObex::slotPushComplete(int result) { |
179 | if (m_rec->normalExit() ) { | 184 | if (result == 0) { |
180 | if ( m_rec->exitStatus() == 0 ) { // we got one | ||
181 | QString filename = parseOut(); | ||
182 | emit receivedFile( filename ); | ||
183 | } | ||
184 | }else{ | ||
185 | emit done(false); | ||
186 | }; | ||
187 | delete m_rec; | ||
188 | m_rec = 0; | ||
189 | receive(); | ||
190 | } | ||
191 | |||
192 | void BtObex::sendEnd() { | ||
193 | if (m_send->normalExit() ) { | ||
194 | if ( m_send->exitStatus() == 0 ) { | ||
195 | delete m_send; | 185 | delete m_send; |
@@ -197,3 +187,3 @@ void BtObex::sendEnd() { | |||
197 | emit sent(true); | 187 | emit sent(true); |
198 | }else if (m_send->exitStatus() != 0 ) { // it failed maybe the other side wasn't ready | 188 | } else { // it failed maybe the other side wasn't ready |
199 | // let's try it again | 189 | // let's try it again |
@@ -203,3 +193,5 @@ void BtObex::sendEnd() { | |||
203 | } | 193 | } |
204 | }else { | 194 | } |
195 | |||
196 | void BtObex::slotPushError(int) { | ||
205 | emit error( -1 ); | 197 | emit error( -1 ); |
@@ -208,2 +200,19 @@ void BtObex::sendEnd() { | |||
208 | } | 200 | } |
201 | |||
202 | void BtObex::slotPushStatus(QCString& str) { | ||
203 | odebug << str << oendl; | ||
204 | } | ||
205 | |||
206 | void BtObex::received() { | ||
207 | if (m_rec->normalExit() ) { | ||
208 | if ( m_rec->exitStatus() == 0 ) { // we got one | ||
209 | QString filename = parseOut(); | ||
210 | emit receivedFile( filename ); | ||
211 | } | ||
212 | }else{ | ||
213 | emit done(false); | ||
214 | }; | ||
215 | delete m_rec; | ||
216 | m_rec = 0; | ||
217 | receive(); | ||
209 | } | 218 | } |
diff --git a/core/obex/btobex.h b/core/obex/btobex.h index ba50064..9c1ab70 100644 --- a/core/obex/btobex.h +++ b/core/obex/btobex.h | |||
@@ -6,4 +6,5 @@ | |||
6 | #include <qobject.h> | 6 | #include <qobject.h> |
7 | #include <opietooth/services.h> | 7 | #include <services.h> |
8 | #include <opietooth/manager.h> | 8 | #include <manager.h> |
9 | #include <obexpush.h> | ||
9 | 10 | ||
@@ -61,3 +62,3 @@ namespace OpieObex { | |||
61 | int m_port; | 62 | int m_port; |
62 | Opie::Core::OProcess *m_send; | 63 | ObexPush* m_send; |
63 | Opie::Core::OProcess *m_rec; | 64 | Opie::Core::OProcess *m_rec; |
@@ -69,2 +70,7 @@ private slots: | |||
69 | 70 | ||
71 | // Push process slots | ||
72 | void slotPushStatus(QCString&); | ||
73 | void slotPushComplete(int); | ||
74 | void slotPushError(int); | ||
75 | |||
70 | // the process exited | 76 | // the process exited |
@@ -79,4 +85,2 @@ private slots: | |||
79 | void received(); | 85 | void received(); |
80 | void sendEnd(); | ||
81 | |||
82 | }; | 86 | }; |