summaryrefslogtreecommitdiff
path: root/core/obex/btobex.cpp
Unidiff
Diffstat (limited to 'core/obex/btobex.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/btobex.cpp60
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,3 +1,33 @@
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"
3#include <manager.h> 33#include <manager.h>
@@ -20,16 +50,10 @@ using namespace Opie::Core;
20using namespace OpieTooth; 50using namespace OpieTooth;
21 51
22BtObex::BtObex( QObject *parent, const char* name ) 52BtObex::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};
35 59
@@ -40,12 +64,11 @@ BtObex::~BtObex() {
40} 64}
41 65
42void BtObex::receive() { 66void 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*) ),
51 this, SLOT(slotExited(Opie::Core::OProcess*) ) ); 74 this, SLOT(slotExited(Opie::Core::OProcess*) ) );
@@ -61,10 +84,8 @@ void BtObex::receive() {
61} 84}
62 85
63void BtObex::send( const QString& fileName, const QString& bdaddr) { 86void 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())
70 return; 91 return;
@@ -150,6 +171,10 @@ void BtObex::sendNow(){
150 connect(m_send, SIGNAL(status(QCString&)), 171 connect(m_send, SIGNAL(status(QCString&)),
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
155 result = m_send->send(m_bdaddr, m_port, m_file, m_dst); 180 result = m_send->send(m_bdaddr, m_port, m_file, m_dst);
@@ -171,12 +196,15 @@ void BtObex::slotExited(OProcess* proc ){
171 << proc->exitStatus() << oendl; 196 << proc->exitStatus() << oendl;
172 if (proc == m_rec ) // receive process 197 if (proc == m_rec ) // receive process
173 received(); 198 received();
199
174} 200}
175void BtObex::slotStdOut(OProcess* proc, char* buf, int len){ 201void BtObex::slotStdOut(OProcess* proc, char* buf, int len){
176 if ( proc == m_rec ) { // only receive 202 if ( proc == m_rec ) { // only receive
177 QByteArray ar( len ); 203 QByteArray ar( 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}
182 210
@@ -207,6 +235,7 @@ void BtObex::received() {
207 if (m_rec->normalExit() ) { 235 if (m_rec->normalExit() ) {
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 }
212 }else{ 241 }else{
@@ -240,10 +269,13 @@ QString BtObex::parseOut(){
240 * when sent is done slotError is called we will start receive again 269 * when sent is done slotError is called we will start receive again
241 */ 270 */
242void BtObex::slotError() { 271void BtObex::slotError() {
272 ObexBase::slotError();
243 if ( m_receive ) 273 if ( m_receive )
244 receive(); 274 receive();
245}; 275};
246void BtObex::setReceiveEnabled( bool receive ) { 276void 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;
249 shutDownReceive(); 281 shutDownReceive();