summaryrefslogtreecommitdiff
path: root/core/obex/obex.cpp
Unidiff
Diffstat (limited to 'core/obex/obex.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/obex.cpp49
1 files changed, 37 insertions, 12 deletions
diff --git a/core/obex/obex.cpp b/core/obex/obex.cpp
index 36634ec..95c561a 100644
--- a/core/obex/obex.cpp
+++ b/core/obex/obex.cpp
@@ -1,67 +1,90 @@
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 Infrared OBEX handling class implementation
30 */
1 31
2#include "obex.h" 32#include "obex.h"
3 33
4/* OPIE */ 34/* OPIE */
5#include <opie2/oprocess.h> 35#include <opie2/oprocess.h>
6#include <opie2/odebug.h> 36#include <opie2/odebug.h>
7 37
8/* QT */ 38/* QT */
9#include <qfileinfo.h> 39#include <qfileinfo.h>
10 40
11 41
12 42
13using namespace OpieObex; 43using namespace OpieObex;
14 44
15using namespace Opie::Core; 45using namespace Opie::Core;
16/* TRANSLATOR OpieObex::Obex */ 46/* TRANSLATOR OpieObex::Obex */
17 47
18Obex::Obex( QObject *parent, const char* name ) 48Obex::Obex( QObject *parent, const char* name )
19 : QObject(parent, name ) 49 : ObexBase(parent, name )
20{ 50{
21 m_rec = 0; 51 m_rec = 0;
22 m_send=0; 52 m_send=0;
23 m_count = 0;
24 m_receive = false;
25 connect( this, SIGNAL(error(int) ), // for recovering to receive
26 SLOT(slotError() ) );
27 connect( this, SIGNAL(sent(bool) ),
28 SLOT(slotError() ) );
29}; 53};
30Obex::~Obex() { 54Obex::~Obex() {
31 delete m_rec; 55 delete m_rec;
32 delete m_send; 56 delete m_send;
33} 57}
34void Obex::receive() { 58void Obex::receive() {
35 m_receive = true; 59 ObexBase::receive();
36 m_outp = QString::null;
37 m_rec = new OProcess(); 60 m_rec = new OProcess();
38 *m_rec << "irobex_palm3"; 61 *m_rec << "irobex_palm3";
39 // connect to the necessary slots 62 // connect to the necessary slots
40 connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ), 63 connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ),
41 this, SLOT(slotExited(Opie::Core::OProcess*) ) ); 64 this, SLOT(slotExited(Opie::Core::OProcess*) ) );
42 65
43 connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), 66 connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
44 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); 67 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) );
45 68
46 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 69 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
47 emit done( false ); 70 emit done( false );
48 delete m_rec; 71 delete m_rec;
49 m_rec = 0; 72 m_rec = 0;
50 } 73 }
51} 74}
52 75
53void Obex::send( const QString& fileName) { // if currently receiving stop it send receive 76// if currently receiving stop it send receive
54 m_count = 0; 77void Obex::send(const QString& fileName, const QString& addr) {
55 m_file = fileName; 78 ObexBase::send(fileName, addr);
56 if (m_rec != 0 ) { 79 if (m_rec != 0 ) {
57 if (m_rec->isRunning() ) { 80 if (m_rec->isRunning() ) {
58 emit error(-1 ); 81 emit error(-1 );
59 delete m_rec; 82 delete m_rec;
60 m_rec = 0; 83 m_rec = 0;
61 84
62 }else{ 85 }else{
63 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending 86 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending
64 return; 87 return;
65 } 88 }
66 } 89 }
67 sendNow(); 90 sendNow();
@@ -156,28 +179,30 @@ QString Obex::parseOut( ){
156 path = (*it).remove( pos, (*it).length() - pos ); 179 path = (*it).remove( pos, (*it).length() - pos );
157 path = path.mid(6 ); 180 path = path.mid(6 );
158 path = path.stripWhiteSpace(); 181 path = path.stripWhiteSpace();
159 } 182 }
160 } 183 }
161 } 184 }
162 return path; 185 return path;
163} 186}
164/** 187/**
165 * when sent is done slotError is called we will start receive again 188 * when sent is done slotError is called we will start receive again
166 */ 189 */
167void Obex::slotError() { 190void Obex::slotError() {
191 ObexBase::slotError();
168 if ( m_receive ) 192 if ( m_receive )
169 receive(); 193 receive();
170}; 194};
171void Obex::setReceiveEnabled( bool receive ) { 195void Obex::setReceiveEnabled( bool receive ) {
196 ObexBase::setReceiveEnabled(receive);
172 if ( !receive ) { // 197 if ( !receive ) { //
173 m_receive = false; 198 m_receive = false;
174 shutDownReceive(); 199 shutDownReceive();
175 } 200 }
176} 201}
177 202
178void Obex::shutDownReceive() { 203void Obex::shutDownReceive() {
179 if (m_rec != 0 ) { 204 if (m_rec != 0 ) {
180 if (m_rec->isRunning() ) { 205 if (m_rec->isRunning() ) {
181 emit error(-1 ); 206 emit error(-1 );
182 delete m_rec; 207 delete m_rec;
183 m_rec = 0; 208 m_rec = 0;