-rw-r--r-- | core/obex/btobex.cpp | 60 |
1 files changed, 46 insertions, 14 deletions
diff --git a/core/obex/btobex.cpp b/core/obex/btobex.cpp index a5bfe5f..212a084 100644 --- a/core/obex/btobex.cpp +++ b/core/obex/btobex.cpp | |||
@@ -1,2 +1,32 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <, > . <= redistribute it and/or modify it under | ||
7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; version 2 of the License. | ||
10 | ._= =} : | ||
11 | .%+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. . .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-= this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | /* | ||
29 | * The Bluetooth OBEX manipulating class implementation | ||
30 | */ | ||
1 | 31 | ||
2 | #include "btobex.h" | 32 | #include "btobex.h" |
@@ -21,14 +51,8 @@ using namespace OpieTooth; | |||
21 | 51 | ||
22 | BtObex::BtObex( QObject *parent, const char* name ) | 52 | BtObex::BtObex( QObject *parent, const char* name ) |
23 | : QObject(parent, name ) | 53 | : ObexBase(parent, name ) |
24 | { | 54 | { |
25 | m_rec = 0; | 55 | m_rec = 0; |
26 | m_send=0; | 56 | m_send=0; |
27 | m_count = 0; | ||
28 | m_receive = false; | ||
29 | connect( this, SIGNAL(error(int) ), // for recovering to receive | ||
30 | SLOT(slotError() ) ); | ||
31 | connect( this, SIGNAL(sent(bool) ), | ||
32 | SLOT(slotError() ) ); | ||
33 | btManager = NULL; | 57 | btManager = NULL; |
34 | }; | 58 | }; |
@@ -41,10 +65,9 @@ BtObex::~BtObex() { | |||
41 | 65 | ||
42 | void BtObex::receive() { | 66 | void BtObex::receive() { |
43 | m_receive = true; | 67 | ObexBase::receive(); |
44 | m_outp = QString::null; | 68 | m_rec = new ObexServer(); |
45 | m_rec = new OProcess(); | ||
46 | 69 | ||
70 | odebug << "BT OBEX do receive" << oendl; | ||
47 | // TODO mbhaynie: No idea if this actually works -- maybe opd is better. | 71 | // TODO mbhaynie: No idea if this actually works -- maybe opd is better. |
48 | *m_rec << "obexftpd" << "-b"; | ||
49 | // connect to the necessary slots | 72 | // connect to the necessary slots |
50 | connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ), | 73 | connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ), |
@@ -62,8 +85,6 @@ void BtObex::receive() { | |||
62 | 85 | ||
63 | void BtObex::send( const QString& fileName, const QString& bdaddr) { | 86 | void BtObex::send( const QString& fileName, const QString& bdaddr) { |
87 | ObexBase::send(fileName, bdaddr); | ||
64 | // if currently receiving stop it send receive | 88 | // if currently receiving stop it send receive |
65 | m_count = 0; | ||
66 | m_file = fileName; | ||
67 | m_bdaddr = bdaddr; | ||
68 | if (m_send != 0) { | 89 | if (m_send != 0) { |
69 | if (m_send->isSending()) | 90 | if (m_send->isSending()) |
@@ -151,4 +172,8 @@ void BtObex::sendNow(){ | |||
151 | this, SLOT(slotPushStatus(QCString&) ) ); | 172 | this, SLOT(slotPushStatus(QCString&) ) ); |
152 | 173 | ||
174 | /* | ||
175 | * FIXME: this delay is made because some cell phones understands an error | ||
176 | * later. | ||
177 | */ | ||
153 | ::sleep(4); | 178 | ::sleep(4); |
154 | // now start it | 179 | // now start it |
@@ -172,4 +197,5 @@ void BtObex::slotExited(OProcess* proc ){ | |||
172 | if (proc == m_rec ) // receive process | 197 | if (proc == m_rec ) // receive process |
173 | received(); | 198 | received(); |
199 | |||
174 | } | 200 | } |
175 | void BtObex::slotStdOut(OProcess* proc, char* buf, int len){ | 201 | void BtObex::slotStdOut(OProcess* proc, char* buf, int len){ |
@@ -178,4 +204,6 @@ void BtObex::slotStdOut(OProcess* proc, char* buf, int len){ | |||
178 | memcpy( ar.data(), buf, len ); | 204 | memcpy( ar.data(), buf, len ); |
179 | m_outp.append( ar ); | 205 | m_outp.append( ar ); |
206 | QCString str(buf, len); | ||
207 | odebug << str << oendl; | ||
180 | } | 208 | } |
181 | } | 209 | } |
@@ -208,4 +236,5 @@ void BtObex::received() { | |||
208 | if ( m_rec->exitStatus() == 0 ) { // we got one | 236 | if ( m_rec->exitStatus() == 0 ) { // we got one |
209 | QString filename = parseOut(); | 237 | QString filename = parseOut(); |
238 | odebug << "OBEX " << filename << " received" << oendl; | ||
210 | emit receivedFile( filename ); | 239 | emit receivedFile( filename ); |
211 | } | 240 | } |
@@ -241,8 +270,11 @@ QString BtObex::parseOut(){ | |||
241 | */ | 270 | */ |
242 | void BtObex::slotError() { | 271 | void BtObex::slotError() { |
272 | ObexBase::slotError(); | ||
243 | if ( m_receive ) | 273 | if ( m_receive ) |
244 | receive(); | 274 | receive(); |
245 | }; | 275 | }; |
246 | void BtObex::setReceiveEnabled( bool receive ) { | 276 | void BtObex::setReceiveEnabled( bool receive ) { |
277 | odebug << "BT OBEX setReceiveEnabled " << receive << oendl; | ||
278 | ObexBase::setReceiveEnabled(receive); | ||
247 | if ( !receive ) { // | 279 | if ( !receive ) { // |
248 | m_receive = false; | 280 | m_receive = false; |