summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2006-10-24 20:39:01 (UTC)
committer korovkin <korovkin>2006-10-24 20:39:01 (UTC)
commitb742daec72bbef07039b785dcadca9dca9a0dc1c (patch) (unidiff)
tree9aa359723443aab322dedd95110858718287784b
parent687aa5f6bd15190461d4460779d1913e7bd0db55 (diff)
downloadopie-b742daec72bbef07039b785dcadca9dca9a0dc1c.zip
opie-b742daec72bbef07039b785dcadca9dca9a0dc1c.tar.gz
opie-b742daec72bbef07039b785dcadca9dca9a0dc1c.tar.bz2
IR OBEX is handled by OPIE OBEX functions, not by external utility.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/btobex.cpp2
-rw-r--r--core/obex/obex.cpp3
-rw-r--r--core/obex/obex.h3
-rw-r--r--core/obex/obexserver.cpp24
-rw-r--r--core/obex/obexserver.h4
5 files changed, 21 insertions, 15 deletions
diff --git a/core/obex/btobex.cpp b/core/obex/btobex.cpp
index 212a084..4e078b0 100644
--- a/core/obex/btobex.cpp
+++ b/core/obex/btobex.cpp
@@ -1,294 +1,294 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> 3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under 6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; version 2 of the License. 9 - .   .-<_>     .<> Foundation; version 2 of the License.
10     ._= =}       : 10     ._= =}       :
11    .%+i>       _;_. 11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details. 18++=   -.     .     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22   --        :-= this library; see the file COPYING.LIB. 22   --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28/* 28/*
29 * The Bluetooth OBEX manipulating class implementation 29 * The Bluetooth OBEX manipulating class implementation
30 */ 30 */
31 31
32#include "btobex.h" 32#include "btobex.h"
33#include <manager.h> 33#include <manager.h>
34#include <services.h> 34#include <services.h>
35 35
36/* OPIE */ 36/* OPIE */
37#include <opie2/oprocess.h> 37#include <opie2/oprocess.h>
38#include <opie2/odebug.h> 38#include <opie2/odebug.h>
39 39
40/* QT */ 40/* QT */
41#include <qfileinfo.h> 41#include <qfileinfo.h>
42#include <qstring.h> 42#include <qstring.h>
43#include <qmap.h> 43#include <qmap.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45 45
46using namespace OpieObex; 46using namespace OpieObex;
47 47
48using namespace Opie::Core; 48using namespace Opie::Core;
49/* TRANSLATOR OpieObex::Obex */ 49/* TRANSLATOR OpieObex::Obex */
50using namespace OpieTooth; 50using namespace OpieTooth;
51 51
52BtObex::BtObex( QObject *parent, const char* name ) 52BtObex::BtObex( QObject *parent, const char* name )
53 : ObexBase(parent, name ) 53 : ObexBase(parent, name )
54{ 54{
55 m_rec = 0; 55 m_rec = 0;
56 m_send=0; 56 m_send=0;
57 btManager = NULL; 57 btManager = NULL;
58}; 58};
59 59
60BtObex::~BtObex() { 60BtObex::~BtObex() {
61 delete btManager; 61 delete btManager;
62 delete m_rec; 62 delete m_rec;
63 delete m_send; 63 delete m_send;
64} 64}
65 65
66void BtObex::receive() { 66void BtObex::receive() {
67 ObexBase::receive(); 67 ObexBase::receive();
68 m_rec = new ObexServer(); 68 m_rec = new ObexServer(OBEX_TRANS_BLUETOOTH);
69 69
70 odebug << "BT OBEX do receive" << oendl; 70 odebug << "BT OBEX do receive" << oendl;
71 // 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.
72 // connect to the necessary slots 72 // connect to the necessary slots
73 connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ), 73 connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ),
74 this, SLOT(slotExited(Opie::Core::OProcess*) ) ); 74 this, SLOT(slotExited(Opie::Core::OProcess*) ) );
75 75
76 connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), 76 connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
77 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); 77 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) );
78 78
79 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 79 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
80 emit done( false ); 80 emit done( false );
81 delete m_rec; 81 delete m_rec;
82 m_rec = 0; 82 m_rec = 0;
83 } 83 }
84} 84}
85 85
86void BtObex::send( const QString& fileName, const QString& bdaddr) { 86void BtObex::send( const QString& fileName, const QString& bdaddr) {
87 ObexBase::send(fileName, bdaddr); 87 ObexBase::send(fileName, bdaddr);
88 // if currently receiving stop it send receive 88 // if currently receiving stop it send receive
89 if (m_send != 0) { 89 if (m_send != 0) {
90 if (m_send->isSending()) 90 if (m_send->isSending())
91 return; 91 return;
92 else { 92 else {
93 delete m_send; 93 delete m_send;
94 m_send = 0; 94 m_send = 0;
95 } 95 }
96 } 96 }
97 if (m_rec != 0 ) { 97 if (m_rec != 0 ) {
98 if (m_rec->isRunning() ) { 98 if (m_rec->isRunning() ) {
99 emit error(-1 ); 99 emit error(-1 );
100 delete m_rec; 100 delete m_rec;
101 m_rec = 0; 101 m_rec = 0;
102 102
103 }else{ 103 }else{
104 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending 104 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending
105 return; 105 return;
106 } 106 }
107 } 107 }
108 //Now we need to find out if the OBEX push is supported for this device 108 //Now we need to find out if the OBEX push is supported for this device
109 //And get the port number 109 //And get the port number
110 if (!btManager) { 110 if (!btManager) {
111 btManager = new Manager("hci0"); 111 btManager = new Manager("hci0");
112 connect(btManager, 112 connect(btManager,
113 SIGNAL(foundServices(const QString&, Services::ValueList)), 113 SIGNAL(foundServices(const QString&, Services::ValueList)),
114 this, SLOT(slotFoundServices(const QString&, Services::ValueList))); 114 this, SLOT(slotFoundServices(const QString&, Services::ValueList)));
115 } 115 }
116 btManager->searchServices(bdaddr); 116 btManager->searchServices(bdaddr);
117} 117}
118 118
119/** 119/**
120 * This function reacts on the service discovery finish 120 * This function reacts on the service discovery finish
121 */ 121 */
122void BtObex::slotFoundServices(const QString&, Services::ValueList svcList) 122void BtObex::slotFoundServices(const QString&, Services::ValueList svcList)
123{ 123{
124 QValueList<OpieTooth::Services>::Iterator it; 124 QValueList<OpieTooth::Services>::Iterator it;
125 QMap<int, QString> classList; //The classes list 125 QMap<int, QString> classList; //The classes list
126 QMap<int, QString>::Iterator classIt; //Iterator in the class list 126 QMap<int, QString>::Iterator classIt; //Iterator in the class list
127 int portNum = -1; //The desired port number 127 int portNum = -1; //The desired port number
128 odebug << "BtObex slotFoundServices" << oendl; 128 odebug << "BtObex slotFoundServices" << oendl;
129 if (svcList.isEmpty()) { 129 if (svcList.isEmpty()) {
130 QMessageBox::critical(NULL, tr("Object send"), tr("No services found")); 130 QMessageBox::critical(NULL, tr("Object send"), tr("No services found"));
131 emit error(-1); 131 emit error(-1);
132 return; 132 return;
133 } 133 }
134 for (it = svcList.begin(); it != svcList.end(); it++) { 134 for (it = svcList.begin(); it != svcList.end(); it++) {
135 classList = (*it).classIdList(); 135 classList = (*it).classIdList();
136 classIt = classList.begin(); 136 classIt = classList.begin();
137 if (classIt == classList.end()) 137 if (classIt == classList.end())
138 continue; 138 continue;
139////We really need symbolic names for service IDs 139////We really need symbolic names for service IDs
140 //Ok, we have found the object push service 140 //Ok, we have found the object push service
141 if (classIt.key() == 4357) { 141 if (classIt.key() == 4357) {
142 portNum = (*it).protocolDescriptorList().last().port(); 142 portNum = (*it).protocolDescriptorList().last().port();
143 break; 143 break;
144 } 144 }
145 } 145 }
146 if (portNum == -1) { 146 if (portNum == -1) {
147 QMessageBox::critical(NULL, tr("Object send"), 147 QMessageBox::critical(NULL, tr("Object send"),
148 tr("No OBEX Push service")); 148 tr("No OBEX Push service"));
149 emit error(-1); 149 emit error(-1);
150 return; 150 return;
151 } 151 }
152 m_port = portNum; 152 m_port = portNum;
153 sendNow(); 153 sendNow();
154} 154}
155 155
156void BtObex::sendNow(){ 156void BtObex::sendNow(){
157 QString m_dst = ""; 157 QString m_dst = "";
158 int result; //function call result 158 int result; //function call result
159 if ( m_count >= 25 ) { // could not send 159 if ( m_count >= 25 ) { // could not send
160 emit error(-1 ); 160 emit error(-1 );
161 emit sent(false); 161 emit sent(false);
162 return; 162 return;
163 } 163 }
164 // OProcess inititialisation 164 // OProcess inititialisation
165 m_send = new ObexPush(); 165 m_send = new ObexPush();
166 // connect to slots Exited and and StdOut 166 // connect to slots Exited and and StdOut
167 connect(m_send, SIGNAL(sendComplete(int)), 167 connect(m_send, SIGNAL(sendComplete(int)),
168 this, SLOT(slotPushComplete(int)) ); 168 this, SLOT(slotPushComplete(int)) );
169 connect(m_send, SIGNAL(sendError(int)), 169 connect(m_send, SIGNAL(sendError(int)),
170 this, SLOT(slotPushError(int)) ); 170 this, SLOT(slotPushError(int)) );
171 connect(m_send, SIGNAL(status(QCString&)), 171 connect(m_send, SIGNAL(status(QCString&)),
172 this, SLOT(slotPushStatus(QCString&) ) ); 172 this, SLOT(slotPushStatus(QCString&) ) );
173 173
174 /* 174 /*
175 * FIXME: this delay is made because some cell phones understands an error 175 * FIXME: this delay is made because some cell phones understands an error
176 * later. 176 * later.
177 */ 177 */
178 ::sleep(4); 178 ::sleep(4);
179 // now start it 179 // now start it
180 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);
181 if (result > 0) //Sending process is actually running 181 if (result > 0) //Sending process is actually running
182 return; 182 return;
183 else if (result < 0) { 183 else if (result < 0) {
184 m_count = 25; 184 m_count = 25;
185 emit error(-1 ); 185 emit error(-1 );
186 delete m_send; 186 delete m_send;
187 m_send=0; 187 m_send=0;
188 } 188 }
189 // end 189 // end
190 m_count++; 190 m_count++;
191 emit currentTry( m_count ); 191 emit currentTry( m_count );
192} 192}
193 193
194void BtObex::slotExited(OProcess* proc ){ 194void BtObex::slotExited(OProcess* proc ){
195 odebug << proc->name() << " exited with result " 195 odebug << proc->name() << " exited with result "
196 << proc->exitStatus() << oendl; 196 << proc->exitStatus() << oendl;
197 if (proc == m_rec ) // receive process 197 if (proc == m_rec ) // receive process
198 received(); 198 received();
199 199
200} 200}
201void BtObex::slotStdOut(OProcess* proc, char* buf, int len){ 201void BtObex::slotStdOut(OProcess* proc, char* buf, int len){
202 if ( proc == m_rec ) { // only receive 202 if ( proc == m_rec ) { // only receive
203 QByteArray ar( len ); 203 QByteArray ar( len );
204 memcpy( ar.data(), buf, len ); 204 memcpy( ar.data(), buf, len );
205 m_outp.append( ar ); 205 m_outp.append( ar );
206 QCString str(buf, len); 206 QCString str(buf, len);
207 odebug << str << oendl; 207 odebug << str << oendl;
208 } 208 }
209} 209}
210 210
211void BtObex::slotPushComplete(int result) { 211void BtObex::slotPushComplete(int result) {
212 if (result == 0) { 212 if (result == 0) {
213 delete m_send; 213 delete m_send;
214 m_send=0; 214 m_send=0;
215 emit sent(true); 215 emit sent(true);
216 } else { // it failed maybe the other side wasn't ready 216 } else { // it failed maybe the other side wasn't ready
217 // let's try it again 217 // let's try it again
218 delete m_send; 218 delete m_send;
219 m_send = 0; 219 m_send = 0;
220 sendNow(); 220 sendNow();
221 } 221 }
222} 222}
223 223
224void BtObex::slotPushError(int) { 224void BtObex::slotPushError(int) {
225 emit error( -1 ); 225 emit error( -1 );
226 delete m_send; 226 delete m_send;
227 m_send = 0; 227 m_send = 0;
228} 228}
229 229
230void BtObex::slotPushStatus(QCString& str) { 230void BtObex::slotPushStatus(QCString& str) {
231 odebug << str << oendl; 231 odebug << str << oendl;
232} 232}
233 233
234void BtObex::received() { 234void BtObex::received() {
235 if (m_rec->normalExit() ) { 235 if (m_rec->normalExit() ) {
236 if ( m_rec->exitStatus() == 0 ) { // we got one 236 if ( m_rec->exitStatus() == 0 ) { // we got one
237 QString filename = parseOut(); 237 QString filename = parseOut();
238 odebug << "OBEX " << filename << " received" << oendl; 238 odebug << "OBEX " << filename << " received" << oendl;
239 emit receivedFile( filename ); 239 emit receivedFile( filename );
240 } 240 }
241 }else{ 241 }else{
242 emit done(false); 242 emit done(false);
243 }; 243 };
244 delete m_rec; 244 delete m_rec;
245 m_rec = 0; 245 m_rec = 0;
246 receive(); 246 receive();
247} 247}
248 248
249// This probably doesn't do anything useful for bt. 249// This probably doesn't do anything useful for bt.
250QString BtObex::parseOut(){ 250QString BtObex::parseOut(){
251 QString path; 251 QString path;
252 QStringList list = QStringList::split("\n", m_outp); 252 QStringList list = QStringList::split("\n", m_outp);
253 QStringList::Iterator it; 253 QStringList::Iterator it;
254 for (it = list.begin(); it != list.end(); ++it ) { 254 for (it = list.begin(); it != list.end(); ++it ) {
255 odebug << (*it) << oendl; 255 odebug << (*it) << oendl;
256 if ( (*it).startsWith("Wrote" ) ) { 256 if ( (*it).startsWith("Wrote" ) ) {
257 int pos = (*it).findRev('(' ); 257 int pos = (*it).findRev('(' );
258 if ( pos > 0 ) { 258 if ( pos > 0 ) {
259 259
260 path = (*it).remove( pos, (*it).length() - pos ); 260 path = (*it).remove( pos, (*it).length() - pos );
261 path = path.mid(6 ); 261 path = path.mid(6 );
262 path = path.stripWhiteSpace(); 262 path = path.stripWhiteSpace();
263 } 263 }
264 } 264 }
265 } 265 }
266 return path; 266 return path;
267} 267}
268/** 268/**
269 * 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
270 */ 270 */
271void BtObex::slotError() { 271void BtObex::slotError() {
272 ObexBase::slotError(); 272 ObexBase::slotError();
273 if ( m_receive ) 273 if ( m_receive )
274 receive(); 274 receive();
275}; 275};
276void BtObex::setReceiveEnabled( bool receive ) { 276void BtObex::setReceiveEnabled( bool receive ) {
277 odebug << "BT OBEX setReceiveEnabled " << receive << oendl; 277 odebug << "BT OBEX setReceiveEnabled " << receive << oendl;
278 ObexBase::setReceiveEnabled(receive); 278 ObexBase::setReceiveEnabled(receive);
279 if ( !receive ) { // 279 if ( !receive ) { //
280 m_receive = false; 280 m_receive = false;
281 shutDownReceive(); 281 shutDownReceive();
282 } 282 }
283} 283}
284 284
285void BtObex::shutDownReceive() { 285void BtObex::shutDownReceive() {
286 if (m_rec != 0 ) { 286 if (m_rec != 0 ) {
287 if (m_rec->isRunning() ) { 287 if (m_rec->isRunning() ) {
288 emit error(-1 ); 288 emit error(-1 );
289 delete m_rec; 289 delete m_rec;
290 m_rec = 0; 290 m_rec = 0;
291 } 291 }
292 } 292 }
293 293
294} 294}
diff --git a/core/obex/obex.cpp b/core/obex/obex.cpp
index 95c561a..e4a3c31 100644
--- a/core/obex/obex.cpp
+++ b/core/obex/obex.cpp
@@ -1,212 +1,211 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> 3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under 6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; version 2 of the License. 9 - .   .-<_>     .<> Foundation; version 2 of the License.
10     ._= =}       : 10     ._= =}       :
11    .%+i>       _;_. 11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details. 18++=   -.     .     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22   --        :-= this library; see the file COPYING.LIB. 22   --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28/* 28/*
29 * The Infrared OBEX handling class implementation 29 * The Infrared OBEX handling class implementation
30 */ 30 */
31 31
32#include "obex.h" 32#include "obex.h"
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/oprocess.h> 35#include <opie2/oprocess.h>
36#include <opie2/odebug.h> 36#include <opie2/odebug.h>
37 37
38/* QT */ 38/* QT */
39#include <qfileinfo.h> 39#include <qfileinfo.h>
40 40
41 41
42 42
43using namespace OpieObex; 43using namespace OpieObex;
44 44
45using namespace Opie::Core; 45using namespace Opie::Core;
46/* TRANSLATOR OpieObex::Obex */ 46/* TRANSLATOR OpieObex::Obex */
47 47
48Obex::Obex( QObject *parent, const char* name ) 48Obex::Obex( QObject *parent, const char* name )
49 : ObexBase(parent, name ) 49 : ObexBase(parent, name )
50{ 50{
51 m_rec = 0; 51 m_rec = 0;
52 m_send=0; 52 m_send=0;
53}; 53};
54Obex::~Obex() { 54Obex::~Obex() {
55 delete m_rec; 55 delete m_rec;
56 delete m_send; 56 delete m_send;
57} 57}
58void Obex::receive() { 58void Obex::receive() {
59 ObexBase::receive(); 59 ObexBase::receive();
60 m_rec = new OProcess(); 60 m_rec = new ObexServer(OBEX_TRANS_IRDA);
61 *m_rec << "irobex_palm3";
62 // connect to the necessary slots 61 // connect to the necessary slots
63 connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ), 62 connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ),
64 this, SLOT(slotExited(Opie::Core::OProcess*) ) ); 63 this, SLOT(slotExited(Opie::Core::OProcess*) ) );
65 64
66 connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), 65 connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
67 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); 66 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) );
68 67
69 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 68 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
70 emit done( false ); 69 emit done( false );
71 delete m_rec; 70 delete m_rec;
72 m_rec = 0; 71 m_rec = 0;
73 } 72 }
74} 73}
75 74
76// if currently receiving stop it send receive 75// if currently receiving stop it send receive
77void Obex::send(const QString& fileName, const QString& addr) { 76void Obex::send(const QString& fileName, const QString& addr) {
78 ObexBase::send(fileName, addr); 77 ObexBase::send(fileName, addr);
79 if (m_rec != 0 ) { 78 if (m_rec != 0 ) {
80 if (m_rec->isRunning() ) { 79 if (m_rec->isRunning() ) {
81 emit error(-1 ); 80 emit error(-1 );
82 delete m_rec; 81 delete m_rec;
83 m_rec = 0; 82 m_rec = 0;
84 83
85 }else{ 84 }else{
86 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending 85 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending
87 return; 86 return;
88 } 87 }
89 } 88 }
90 sendNow(); 89 sendNow();
91} 90}
92void Obex::sendNow(){ 91void Obex::sendNow(){
93 if ( m_count >= 25 ) { // could not send 92 if ( m_count >= 25 ) { // could not send
94 emit error(-1 ); 93 emit error(-1 );
95 emit sent(false); 94 emit sent(false);
96 return; 95 return;
97 } 96 }
98 // OProcess inititialisation 97 // OProcess inititialisation
99 m_send = new OProcess(); 98 m_send = new OProcess();
100 m_send->setWorkingDirectory( QFileInfo(m_file).dirPath(true) ); 99 m_send->setWorkingDirectory( QFileInfo(m_file).dirPath(true) );
101 100
102 *m_send << "irobex_palm3"; 101 *m_send << "irobex_palm3";
103 *m_send << QFile::encodeName(QFileInfo(m_file).fileName()); 102 *m_send << QFile::encodeName(QFileInfo(m_file).fileName());
104 103
105 // connect to slots Exited and and StdOut 104 // connect to slots Exited and and StdOut
106 connect(m_send, SIGNAL(processExited(Opie::Core::OProcess*) ), 105 connect(m_send, SIGNAL(processExited(Opie::Core::OProcess*) ),
107 this, SLOT(slotExited(Opie::Core::OProcess*)) ); 106 this, SLOT(slotExited(Opie::Core::OProcess*)) );
108 connect(m_send, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int )), 107 connect(m_send, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int )),
109 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); 108 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) );
110 109
111 // now start it 110 // now start it
112 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { 111 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) {
113 m_count = 25; 112 m_count = 25;
114 emit error(-1 ); 113 emit error(-1 );
115 delete m_send; 114 delete m_send;
116 m_send=0; 115 m_send=0;
117 } 116 }
118 // end 117 // end
119 m_count++; 118 m_count++;
120 emit currentTry( m_count ); 119 emit currentTry( m_count );
121} 120}
122 121
123void Obex::slotExited(OProcess* proc ){ 122void Obex::slotExited(OProcess* proc ){
124 if (proc == m_rec ) // receive process 123 if (proc == m_rec ) // receive process
125 received(); 124 received();
126 else if ( proc == m_send ) 125 else if ( proc == m_send )
127 sendEnd(); 126 sendEnd();
128 127
129} 128}
130void Obex::slotStdOut(OProcess* proc, char* buf, int len){ 129void Obex::slotStdOut(OProcess* proc, char* buf, int len){
131 if ( proc == m_rec ) { // only receive 130 if ( proc == m_rec ) { // only receive
132 QByteArray ar( len ); 131 QByteArray ar( len );
133 memcpy( ar.data(), buf, len ); 132 memcpy( ar.data(), buf, len );
134 m_outp.append( ar ); 133 m_outp.append( ar );
135 } 134 }
136} 135}
137 136
138void Obex::received() { 137void Obex::received() {
139 if (m_rec->normalExit() ) { 138 if (m_rec->normalExit() ) {
140 if ( m_rec->exitStatus() == 0 ) { // we got one 139 if ( m_rec->exitStatus() == 0 ) { // we got one
141 QString filename = parseOut(); 140 QString filename = parseOut();
142 emit receivedFile( filename ); 141 emit receivedFile( filename );
143 } 142 }
144 }else{ 143 }else{
145 emit done(false); 144 emit done(false);
146 }; 145 };
147 delete m_rec; 146 delete m_rec;
148 m_rec = 0; 147 m_rec = 0;
149 receive(); 148 receive();
150} 149}
151 150
152void Obex::sendEnd() { 151void Obex::sendEnd() {
153 if (m_send->normalExit() ) { 152 if (m_send->normalExit() ) {
154 if ( m_send->exitStatus() == 0 ) { 153 if ( m_send->exitStatus() == 0 ) {
155 delete m_send; 154 delete m_send;
156 m_send=0; 155 m_send=0;
157 emit sent(true); 156 emit sent(true);
158 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready 157 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready
159 // let's try it again 158 // let's try it again
160 delete m_send; 159 delete m_send;
161 m_send = 0; 160 m_send = 0;
162 sendNow(); 161 sendNow();
163 } 162 }
164 }else { 163 }else {
165 emit error( -1 ); 164 emit error( -1 );
166 delete m_send; 165 delete m_send;
167 m_send = 0; 166 m_send = 0;
168 } 167 }
169} 168}
170QString Obex::parseOut( ){ 169QString Obex::parseOut( ){
171 QString path; 170 QString path;
172 QStringList list = QStringList::split("\n", m_outp); 171 QStringList list = QStringList::split("\n", m_outp);
173 QStringList::Iterator it; 172 QStringList::Iterator it;
174 for (it = list.begin(); it != list.end(); ++it ) { 173 for (it = list.begin(); it != list.end(); ++it ) {
175 if ( (*it).startsWith("Wrote" ) ) { 174 if ( (*it).startsWith("Wrote" ) ) {
176 int pos = (*it).findRev('(' ); 175 int pos = (*it).findRev('(' );
177 if ( pos > 0 ) { 176 if ( pos > 0 ) {
178 177
179 path = (*it).remove( pos, (*it).length() - pos ); 178 path = (*it).remove( pos, (*it).length() - pos );
180 path = path.mid(6 ); 179 path = path.mid(6 );
181 path = path.stripWhiteSpace(); 180 path = path.stripWhiteSpace();
182 } 181 }
183 } 182 }
184 } 183 }
185 return path; 184 return path;
186} 185}
187/** 186/**
188 * when sent is done slotError is called we will start receive again 187 * when sent is done slotError is called we will start receive again
189 */ 188 */
190void Obex::slotError() { 189void Obex::slotError() {
191 ObexBase::slotError(); 190 ObexBase::slotError();
192 if ( m_receive ) 191 if ( m_receive )
193 receive(); 192 receive();
194}; 193};
195void Obex::setReceiveEnabled( bool receive ) { 194void Obex::setReceiveEnabled( bool receive ) {
196 ObexBase::setReceiveEnabled(receive); 195 ObexBase::setReceiveEnabled(receive);
197 if ( !receive ) { // 196 if ( !receive ) { //
198 m_receive = false; 197 m_receive = false;
199 shutDownReceive(); 198 shutDownReceive();
200 } 199 }
201} 200}
202 201
203void Obex::shutDownReceive() { 202void Obex::shutDownReceive() {
204 if (m_rec != 0 ) { 203 if (m_rec != 0 ) {
205 if (m_rec->isRunning() ) { 204 if (m_rec->isRunning() ) {
206 emit error(-1 ); 205 emit error(-1 );
207 delete m_rec; 206 delete m_rec;
208 m_rec = 0; 207 m_rec = 0;
209 } 208 }
210 } 209 }
211 210
212} 211}
diff --git a/core/obex/obex.h b/core/obex/obex.h
index 36ff29a..b948ce4 100644
--- a/core/obex/obex.h
+++ b/core/obex/obex.h
@@ -1,114 +1,115 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> 3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under 6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; version 2 of the License. 9 - .   .-<_>     .<> Foundation; version 2 of the License.
10     ._= =}       : 10     ._= =}       :
11    .%+i>       _;_. 11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details. 18++=   -.     .     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22   --        :-= this library; see the file COPYING.LIB. 22   --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28/* 28/*
29 * The Infrared OBEX handling class declaration 29 * The Infrared OBEX handling class declaration
30 */ 30 */
31 31
32#ifndef OpieObex_H 32#ifndef OpieObex_H
33#define OpieObex_H 33#define OpieObex_H
34 34
35#include "obexbase.h" 35#include "obexbase.h"
36#include <qobject.h> 36#include <qobject.h>
37#include "obexserver.h"
37 38
38namespace Opie {namespace Core {class OProcess;}} 39namespace Opie {namespace Core {class OProcess;}}
39class QCopChannel; 40class QCopChannel;
40namespace OpieObex { 41namespace OpieObex {
41 class Obex : public ObexBase { 42 class Obex : public ObexBase {
42 Q_OBJECT 43 Q_OBJECT
43 public: 44 public:
44 /** 45 /**
45 * Obex c'tor look 46 * Obex c'tor look
46 */ 47 */
47 Obex( QObject *parent, const char* name); 48 Obex( QObject *parent, const char* name);
48 /** 49 /**
49 * d'tor 50 * d'tor
50 */ 51 */
51 ~Obex(); 52 ~Obex();
52 53
53 /** 54 /**
54 * Starting listening to irda after enabled by the applet 55 * Starting listening to irda after enabled by the applet
55 * a signal gets emitted when received a file 56 * a signal gets emitted when received a file
56 */ 57 */
57 virtual void receive(); 58 virtual void receive();
58 virtual void send(const QString& filename, const QString& addr); 59 virtual void send(const QString& filename, const QString& addr);
59 virtual void setReceiveEnabled( bool = false ); 60 virtual void setReceiveEnabled( bool = false );
60 signals: 61 signals:
61 62
62 /** 63 /**
63 * a signal 64 * a signal
64 * @param path The path to the received file 65 * @param path The path to the received file
65 */ 66 */
66 void receivedFile( const QString& path); 67 void receivedFile( const QString& path);
67 /** 68 /**
68 * error signal if the program couldn't be started or the 69 * error signal if the program couldn't be started or the
69 * the connection timed out 70 * the connection timed out
70 */ 71 */
71 void error( int ); 72 void error( int );
72 /** 73 /**
73 * The current try to receive data 74 * The current try to receive data
74 */ 75 */
75 void currentTry(unsigned int); 76 void currentTry(unsigned int);
76 /** 77 /**
77 * signal sent The file got beamed to the remote location 78 * signal sent The file got beamed to the remote location
78 */ 79 */
79 void sent(bool); 80 void sent(bool);
80 void done(bool); 81 void done(bool);
81 82
82 private: 83 private:
83 uint m_count; 84 uint m_count;
84 QString m_file; 85 QString m_file;
85 QString m_outp; 86 QString m_outp;
86 Opie::Core::OProcess *m_send; 87 Opie::Core::OProcess *m_send;
87 Opie::Core::OProcess *m_rec; 88 ObexServer* m_rec; //The OBEX server
88 bool m_receive : 1; 89 bool m_receive : 1;
89 void shutDownReceive(); 90 void shutDownReceive();
90 91
91private slots: 92private slots:
92 93
93 /** 94 /**
94 * send over palm obex 95 * send over palm obex
95 */ 96 */
96 97
97 //void send(const QString&); 98 //void send(const QString&);
98 99
99 // the process exited 100 // the process exited
100 void slotExited(Opie::Core::OProcess* proc) ; 101 void slotExited(Opie::Core::OProcess* proc) ;
101 void slotStdOut(Opie::Core::OProcess*, char*, int); 102 void slotStdOut(Opie::Core::OProcess*, char*, int);
102 virtual void slotError(); 103 virtual void slotError();
103 104
104 private: 105 private:
105 void sendNow(); 106 void sendNow();
106 QString parseOut(); 107 QString parseOut();
107 void received(); 108 void received();
108 void sendEnd(); 109 void sendEnd();
109 110
110 }; 111 };
111}; 112};
112 113
113 114
114#endif 115#endif
diff --git a/core/obex/obexserver.cpp b/core/obex/obexserver.cpp
index 95196de..25d8224 100644
--- a/core/obex/obexserver.cpp
+++ b/core/obex/obexserver.cpp
@@ -1,514 +1,518 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> 3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under 6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; version 2 of the License. 9 - .   .-<_>     .<> Foundation; version 2 of the License.
10     ._= =}       : 10     ._= =}       :
11    .%+i>       _;_. 11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details. 18++=   -.     .     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22   --        :-= this library; see the file COPYING.LIB. 22   --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28/* 28/*
29 * The OBEX server class implementation 29 * The OBEX server class implementation
30 * Based on OBEX server from GPE (thanks, guys) 30 * Based on OBEX server from GPE (thanks, guys)
31 */ 31 */
32 32
33#include "obexserver.h" 33#include "obexserver.h"
34#include <unistd.h> 34#include <unistd.h>
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36#include <sys/types.h> 36#include <sys/types.h>
37#include <sys/wait.h> 37#include <sys/wait.h>
38#include <errno.h> 38#include <errno.h>
39#include <stdlib.h> 39#include <stdlib.h>
40#include <stdio.h> 40#include <stdio.h>
41#include <fcntl.h> 41#include <fcntl.h>
42#include <qapplication.h> 42#include <qapplication.h>
43#include <opie2/oprocctrl.h> 43#include <opie2/oprocctrl.h>
44#include <qstring.h> 44#include <qstring.h>
45#include <qfile.h> 45#include <qfile.h>
46 46
47using namespace Opie::Core; 47using namespace Opie::Core;
48using namespace Opie::Core::Internal; 48using namespace Opie::Core::Internal;
49using namespace OpieObex; 49using namespace OpieObex;
50 50
51ObexServer::ObexServer() : 51ObexServer::ObexServer(int trans) :
52 OProcess(tr("ObexServer"), 0, "ObexServer") 52 OProcess(tr("ObexServer"), 0, "ObexServer")
53{ 53{
54 transport = trans;
54 m_obex = NULL; 55 m_obex = NULL;
55} 56}
56 57
57ObexServer::~ObexServer() 58ObexServer::~ObexServer()
58{ 59{
59 stop(); 60 stop();
60} 61}
61 62
62/** 63/**
63 * Function handles the file received 64 * Function handles the file received
64 * @param name the file name 65 * @param name the file name
65 * @param data the file data 66 * @param data the file data
66 * @param data_len the data length 67 * @param data_len the data length
67 * @return 0 on success -1 on error 68 * @return 0 on success -1 on error
68 */ 69 */
69static int file_received(uint8_t* name, const uint8_t* data, size_t data_len) 70static int file_received(uint8_t* name, const uint8_t* data, size_t data_len)
70{ 71{
71 QString path("/tmp/"); 72 QString path("/tmp/");
72 path += (char*)name; 73 path += (char*)name;
73 QFile out(path); 74 QFile out(path);
74 int err = 0; 75 int err = 0;
75 76
76 if (!out.open(IO_Raw | IO_ReadWrite | IO_Truncate)) { 77 if (!out.open(IO_Raw | IO_ReadWrite | IO_Truncate)) {
77 printf("File %s open error %d\n", (const char*)path, errno); 78 printf("File %s open error %d\n", (const char*)path, errno);
78 err = -1; 79 err = -1;
79 goto out; 80 goto out;
80 } 81 }
81 if (out.writeBlock((const char*)data, data_len) < 0) { 82 if (out.writeBlock((const char*)data, data_len) < 0) {
82 printf("File %s write error %d\n", (const char*)path, errno); 83 printf("File %s write error %d\n", (const char*)path, errno);
83 err = -1; 84 err = -1;
84 goto out; 85 goto out;
85 } 86 }
86out: 87out:
87 out.close(); 88 out.close();
88 if (err == 0) { 89 if (err == 0) {
89 printf("Wrote %s (%d bytes)\n", (const char*)path, data_len); 90 printf("Wrote %s (%d bytes)\n", (const char*)path, data_len);
90 fflush(stdout); 91 fflush(stdout);
91 } 92 }
92 return err; 93 return err;
93} 94}
94 95
95/** 96/**
96 * Function handles the situation when the PUT request has been done 97 * Function handles the situation when the PUT request has been done
97 * @param handle OBEX connection handle 98 * @param handle OBEX connection handle
98 * @param object OBEX object itself 99 * @param object OBEX object itself
99 */ 100 */
100static int put_done(obex_t* handle, obex_object_t* object) 101static int put_done(obex_t* handle, obex_object_t* object)
101{ 102{
102 obex_headerdata_t hv; //Received file header 103 obex_headerdata_t hv; //Received file header
103 uint8_t hi; //Type of the request 104 uint8_t hi; //Type of the request
104 uint32_t hlen; //File (file name) length 105 uint32_t hlen; //File (file name) length
105 int err = 0; 106 int err = 0;
106 107
107 const uint8_t *body = NULL; 108 const uint8_t *body = NULL;
108 int body_len = 0; 109 int body_len = 0;
109 uint8_t* name = NULL; 110 uint8_t* name = NULL;
110 111
111 while (OBEX_ObjectGetNextHeader (handle, object, &hi, &hv, &hlen)) { 112 while (OBEX_ObjectGetNextHeader (handle, object, &hi, &hv, &hlen)) {
112 switch(hi) { 113 switch(hi) {
113 case OBEX_HDR_BODY: 114 case OBEX_HDR_BODY:
114 body = hv.bs; 115 body = hv.bs;
115 body_len = hlen; 116 body_len = hlen;
116 break; 117 break;
117 118
118 case OBEX_HDR_NAME: 119 case OBEX_HDR_NAME:
119 name = new uint8_t[(hlen / 2) + 1]; 120 name = new uint8_t[(hlen / 2) + 1];
120 OBEX_UnicodeToChar(name, hv.bs, hlen); 121 OBEX_UnicodeToChar(name, hv.bs, hlen);
121 break; 122 break;
122 123
123 default: 124 default:
124 break; 125 break;
125 } 126 }
126 } 127 }
127 128
128 if (body) 129 if (body)
129 err = file_received(name, body, body_len); 130 err = file_received(name, body, body_len);
130 131
131 if (name) 132 if (name)
132 delete[] name; 133 delete[] name;
133 return err; 134 return err;
134} 135}
135 136
136/** 137/**
137 * Function handles OBEX request 138 * Function handles OBEX request
138 * @param handle OBEX connection handle 139 * @param handle OBEX connection handle
139 * @param object OBEX object itself 140 * @param object OBEX object itself
140 * @param mode 141 * @param mode
141 * @param event event code 142 * @param event event code
142 * @param cmd OBEX command itself 143 * @param cmd OBEX command itself
143 */ 144 */
144static void handle_request (obex_t* handle, obex_object_t* object, 145static void handle_request (obex_t* handle, obex_object_t* object,
145 int event, int cmd) 146 int event, int cmd)
146{ 147{
147 (void)event; 148 (void)event;
148 switch(cmd){ 149 switch(cmd){
149 case OBEX_CMD_SETPATH: 150 case OBEX_CMD_SETPATH:
150 OBEX_ObjectSetRsp (object, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS); 151 OBEX_ObjectSetRsp (object, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS);
151 break; 152 break;
152 case OBEX_CMD_PUT: 153 case OBEX_CMD_PUT:
153 if (put_done (handle, object) < 0) 154 if (put_done (handle, object) < 0)
154 OBEX_ObjectSetRsp (object, OBEX_RSP_INTERNAL_SERVER_ERROR, 155 OBEX_ObjectSetRsp (object, OBEX_RSP_INTERNAL_SERVER_ERROR,
155 OBEX_RSP_INTERNAL_SERVER_ERROR); 156 OBEX_RSP_INTERNAL_SERVER_ERROR);
156 else 157 else
157 OBEX_ObjectSetRsp (object, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS); 158 OBEX_ObjectSetRsp (object, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS);
158 break; 159 break;
159 case OBEX_CMD_CONNECT: 160 case OBEX_CMD_CONNECT:
160 OBEX_ObjectSetRsp (object, OBEX_RSP_SUCCESS, OBEX_RSP_SUCCESS); 161 OBEX_ObjectSetRsp (object, OBEX_RSP_SUCCESS, OBEX_RSP_SUCCESS);
161 break; 162 break;
162 case OBEX_CMD_DISCONNECT: 163 case OBEX_CMD_DISCONNECT:
163 OBEX_ObjectSetRsp (object, OBEX_RSP_SUCCESS, OBEX_RSP_SUCCESS); 164 OBEX_ObjectSetRsp (object, OBEX_RSP_SUCCESS, OBEX_RSP_SUCCESS);
164 break; 165 break;
165 default: 166 default:
166 printf("Denied %02x request\n", cmd); 167 printf("Denied %02x request\n", cmd);
167 fflush(stdout); 168 fflush(stdout);
168 OBEX_ObjectSetRsp (object, OBEX_RSP_NOT_IMPLEMENTED, 169 OBEX_ObjectSetRsp (object, OBEX_RSP_NOT_IMPLEMENTED,
169 OBEX_RSP_NOT_IMPLEMENTED); 170 OBEX_RSP_NOT_IMPLEMENTED);
170 break; 171 break;
171 } 172 }
172} 173}
173 174
174 175
175/** 176/**
176 * Function handles OBEX event when a client is connected to the server 177 * Function handles OBEX event when a client is connected to the server
177 * @param handle OBEX connection handle 178 * @param handle OBEX connection handle
178 * @param object OBEX object itself 179 * @param object OBEX object itself
179 * @param mode 180 * @param mode
180 * @param event event code 181 * @param event event code
181 * @param obex_cmd OBEX command itself 182 * @param obex_cmd OBEX command itself
182 * @param obex_rsp OBEX responce 183 * @param obex_rsp OBEX responce
183 */ 184 */
184static void obex_conn_event (obex_t *handle, obex_object_t *object, 185static void obex_conn_event (obex_t *handle, obex_object_t *object,
185 int mode, int event, int obex_cmd, int obex_rsp) 186 int mode, int event, int obex_cmd, int obex_rsp)
186{ 187{
187 (void)mode; 188 (void)mode;
188 (void)obex_rsp; 189 (void)obex_rsp;
189 190
190 switch(event) { 191 switch(event) {
191 case OBEX_EV_REQHINT: 192 case OBEX_EV_REQHINT:
192 switch(obex_cmd) { 193 switch(obex_cmd) {
193 case OBEX_CMD_PUT: 194 case OBEX_CMD_PUT:
194 case OBEX_CMD_CONNECT: 195 case OBEX_CMD_CONNECT:
195 case OBEX_CMD_DISCONNECT: 196 case OBEX_CMD_DISCONNECT:
196 OBEX_ObjectSetRsp (object, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS); 197 OBEX_ObjectSetRsp (object, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS);
197 break; 198 break;
198 default: 199 default:
199 OBEX_ObjectSetRsp (object, OBEX_RSP_NOT_IMPLEMENTED, 200 OBEX_ObjectSetRsp (object, OBEX_RSP_NOT_IMPLEMENTED,
200 OBEX_RSP_NOT_IMPLEMENTED); 201 OBEX_RSP_NOT_IMPLEMENTED);
201 break; 202 break;
202 } 203 }
203 break; 204 break;
204 205
205 case OBEX_EV_REQ: 206 case OBEX_EV_REQ:
206 /* Comes when a server-request has been received. */ 207 /* Comes when a server-request has been received. */
207 handle_request (handle, object, event, obex_cmd); 208 handle_request (handle, object, event, obex_cmd);
208 break; 209 break;
209 210
210 case OBEX_EV_LINKERR: 211 case OBEX_EV_LINKERR:
211 break; 212 break;
212 } 213 }
213} 214}
214 215
215/** 216/**
216 * Function handles OBEX event 217 * Function handles OBEX event
217 * @param handle OBEX connection handle 218 * @param handle OBEX connection handle
218 * @param object OBEX object itself 219 * @param object OBEX object itself
219 * @param mode 220 * @param mode
220 * @param event event code 221 * @param event event code
221 * @param obex_cmd OBEX command itself 222 * @param obex_cmd OBEX command itself
222 * @param obex_rsp OBEX responce 223 * @param obex_rsp OBEX responce
223 */ 224 */
224static void obex_event (obex_t* handle, obex_object_t* object, int mode, 225static void obex_event (obex_t* handle, obex_object_t* object, int mode,
225 int event, int obex_cmd, int obex_rsp) 226 int event, int obex_cmd, int obex_rsp)
226{ 227{
227 228
228 obex_t *obex; //OBEX connection handle 229 obex_t *obex; //OBEX connection handle
229 230
230 switch (event) { 231 switch (event) {
231 case OBEX_EV_ACCEPTHINT: 232 case OBEX_EV_ACCEPTHINT:
232 obex = OBEX_ServerAccept (handle, obex_conn_event, NULL); 233 obex = OBEX_ServerAccept (handle, obex_conn_event, NULL);
233 break; 234 break;
234 235
235 default: 236 default:
236 obex_conn_event(handle, object, mode, event, obex_cmd, obex_rsp); 237 obex_conn_event(handle, object, mode, event, obex_cmd, obex_rsp);
237 } 238 }
238} 239}
239 240
240/** 241/**
241 * Function registers OBEX push service on a specified channel 242 * Function registers OBEX push service on a specified channel
242 * Based on The same function from GPE. 243 * Based on The same function from GPE.
243 * @param session SDP session 244 * @param session SDP session
244 * @param chan channel to listen 245 * @param chan channel to listen
245 * @name name to show 246 * @name name to show
246 */ 247 */
247sdp_session_t* ObexServer::addOpushSvc(uint8_t chan, const char* name) 248sdp_session_t* ObexServer::addOpushSvc(uint8_t chan, const char* name)
248{ 249{
249 sdp_list_t *svclass_id, *pfseq, *apseq, *root; 250 sdp_list_t *svclass_id, *pfseq, *apseq, *root;
250 uuid_t root_uuid, opush_uuid, l2cap_uuid, rfcomm_uuid, obex_uuid; 251 uuid_t root_uuid, opush_uuid, l2cap_uuid, rfcomm_uuid, obex_uuid;
251 sdp_profile_desc_t profile[1]; 252 sdp_profile_desc_t profile[1];
252 sdp_list_t *aproto, *proto[3]; 253 sdp_list_t *aproto, *proto[3];
253 sdp_record_t record; 254 sdp_record_t record;
254 sdp_data_t *channel; 255 sdp_data_t *channel;
255 uint8_t formats[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; 256 uint8_t formats[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
256 //uint8_t formats[] = { 0xff }; 257 //uint8_t formats[] = { 0xff };
257 void *dtds[sizeof(formats)], *values[sizeof(formats)]; 258 void *dtds[sizeof(formats)], *values[sizeof(formats)];
258 unsigned int i; 259 unsigned int i;
259 uint8_t dtd = SDP_UINT8; 260 uint8_t dtd = SDP_UINT8;
260 sdp_data_t *sflist; 261 sdp_data_t *sflist;
261 int err = 0; 262 int err = 0;
262 sdp_session_t* lsession = 0; 263 sdp_session_t* lsession = 0;
263 264
264 memset((void *)&record, 0, sizeof(sdp_record_t)); 265 memset((void *)&record, 0, sizeof(sdp_record_t));
265 record.handle = 0xffffffff; 266 record.handle = 0xffffffff;
266 sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP); 267 sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
267 root = sdp_list_append(0, &root_uuid); 268 root = sdp_list_append(0, &root_uuid);
268 sdp_set_browse_groups(&record, root); 269 sdp_set_browse_groups(&record, root);
269 270
270 sdp_uuid16_create(&opush_uuid, OBEX_OBJPUSH_SVCLASS_ID); 271 sdp_uuid16_create(&opush_uuid, OBEX_OBJPUSH_SVCLASS_ID);
271 svclass_id = sdp_list_append(0, &opush_uuid); 272 svclass_id = sdp_list_append(0, &opush_uuid);
272 sdp_set_service_classes(&record, svclass_id); 273 sdp_set_service_classes(&record, svclass_id);
273 274
274 sdp_uuid16_create(&profile[0].uuid, OBEX_OBJPUSH_PROFILE_ID); 275 sdp_uuid16_create(&profile[0].uuid, OBEX_OBJPUSH_PROFILE_ID);
275 profile[0].version = 0x0100; 276 profile[0].version = 0x0100;
276 pfseq = sdp_list_append(0, profile); 277 pfseq = sdp_list_append(0, profile);
277 sdp_set_profile_descs(&record, pfseq); 278 sdp_set_profile_descs(&record, pfseq);
278 279
279 sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID); 280 sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
280 proto[0] = sdp_list_append(0, &l2cap_uuid); 281 proto[0] = sdp_list_append(0, &l2cap_uuid);
281 apseq = sdp_list_append(0, proto[0]); 282 apseq = sdp_list_append(0, proto[0]);
282 283
283 sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID); 284 sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
284 proto[1] = sdp_list_append(0, &rfcomm_uuid); 285 proto[1] = sdp_list_append(0, &rfcomm_uuid);
285 channel = sdp_data_alloc(SDP_UINT8, &chan); 286 channel = sdp_data_alloc(SDP_UINT8, &chan);
286 proto[1] = sdp_list_append(proto[1], channel); 287 proto[1] = sdp_list_append(proto[1], channel);
287 apseq = sdp_list_append(apseq, proto[1]); 288 apseq = sdp_list_append(apseq, proto[1]);
288 289
289 sdp_uuid16_create(&obex_uuid, OBEX_UUID); 290 sdp_uuid16_create(&obex_uuid, OBEX_UUID);
290 proto[2] = sdp_list_append(0, &obex_uuid); 291 proto[2] = sdp_list_append(0, &obex_uuid);
291 apseq = sdp_list_append(apseq, proto[2]); 292 apseq = sdp_list_append(apseq, proto[2]);
292 293
293 aproto = sdp_list_append(0, apseq); 294 aproto = sdp_list_append(0, apseq);
294 sdp_set_access_protos(&record, aproto); 295 sdp_set_access_protos(&record, aproto);
295 296
296 for (i = 0; i < sizeof(formats); i++) 297 for (i = 0; i < sizeof(formats); i++)
297 { 298 {
298 dtds[i] = &dtd; 299 dtds[i] = &dtd;
299 values[i] = &formats[i]; 300 values[i] = &formats[i];
300 } 301 }
301 sflist = sdp_seq_alloc(dtds, values, sizeof(formats)); 302 sflist = sdp_seq_alloc(dtds, values, sizeof(formats));
302 sdp_attr_add(&record, SDP_ATTR_SUPPORTED_FORMATS_LIST, sflist); 303 sdp_attr_add(&record, SDP_ATTR_SUPPORTED_FORMATS_LIST, sflist);
303 304
304 sdp_set_info_attr(&record, name, 0, 0); 305 sdp_set_info_attr(&record, name, 0, 0);
305 306
306 // connect to the local SDP server, register the service record, and 307 // connect to the local SDP server, register the service record, and
307 // disconnect 308 // disconnect
308 lsession = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY); 309 lsession = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY);
309 if (lsession == NULL) 310 if (lsession == NULL)
310 goto errout; 311 goto errout;
311 err = sdp_record_register(lsession, &record, 0); 312 err = sdp_record_register(lsession, &record, 0);
312 if (err) { 313 if (err) {
313 sdp_close(lsession); 314 sdp_close(lsession);
314 lsession = NULL; 315 lsession = NULL;
315 } 316 }
316errout: 317errout:
317 sdp_data_free(channel); 318 sdp_data_free(channel);
318 sdp_list_free(proto[0], 0); 319 sdp_list_free(proto[0], 0);
319 sdp_list_free(proto[1], 0); 320 sdp_list_free(proto[1], 0);
320 sdp_list_free(proto[2], 0); 321 sdp_list_free(proto[2], 0);
321 sdp_list_free(apseq, 0); 322 sdp_list_free(apseq, 0);
322 sdp_list_free(aproto, 0); 323 sdp_list_free(aproto, 0);
323 324
324 return lsession; 325 return lsession;
325} 326}
326 327
327int ObexServer::initObex(void) 328int ObexServer::initObex(void)
328{ 329{
329 int channel = 10; //Channel on which we do listen 330 int channel = 10; //Channel on which we do listen
330 if (m_obex) 331 if (m_obex)
331 return 0; 332 return 0;
332 m_obex = ::OBEX_Init(OBEX_TRANS_BLUETOOTH, obex_event, 0); 333 m_obex = ::OBEX_Init(transport, obex_event, 0);
333 if (!m_obex) { 334 if (!m_obex) {
334 printf("OBEX initialization error %d\n", errno); 335 printf("OBEX initialization error %d\n", errno);
335 return -1; 336 return -1;
336 } 337 }
337 ::BtOBEX_ServerRegister(m_obex, NULL, channel); 338 if (transport == OBEX_TRANS_BLUETOOTH) {
338 m_session = addOpushSvc(channel, "OBEX push service"); 339 ::BtOBEX_ServerRegister(m_obex, NULL, channel);
339 if (!m_session) { 340 m_session = addOpushSvc(channel, "OBEX push service");
340 printf("OBEX registration error %d\n", errno); 341 if (!m_session) {
341 ::OBEX_Cleanup(m_obex); 342 printf("OBEX registration error %d\n", errno);
342 m_obex = NULL; 343 ::OBEX_Cleanup(m_obex);
343 return -1; 344 m_obex = NULL;
344 } 345 return -1;
346 }
347 } else if (transport == OBEX_TRANS_IRDA)
348 ::IrOBEX_ServerRegister(m_obex, "OBEX");
345 return 0; 349 return 0;
346} 350}
347 351
348bool ObexServer::start(RunMode runmode, Communication comm) 352bool ObexServer::start(RunMode runmode, Communication comm)
349{ 353{
350 if ( runs ) 354 if ( runs )
351 { 355 {
352 return false; // cannot start a process that is already running 356 return false; // cannot start a process that is already running
353 // or if no executable has been assigned 357 // or if no executable has been assigned
354 } 358 }
355 run_mode = runmode; 359 run_mode = runmode;
356 status = 0; 360 status = 0;
357 361
358 if ( !setupCommunication( comm ) ) 362 if ( !setupCommunication( comm ) )
359 qWarning( "Could not setup Communication!" ); 363 qWarning( "Could not setup Communication!" );
360 364
361 // We do this in the parent because if we do it in the child process 365 // We do this in the parent because if we do it in the child process
362 // gdb gets confused when the application runs from gdb. 366 // gdb gets confused when the application runs from gdb.
363 uid_t uid = getuid(); 367 uid_t uid = getuid();
364 gid_t gid = getgid(); 368 gid_t gid = getgid();
365#ifdef HAVE_INITGROUPS 369#ifdef HAVE_INITGROUPS
366 370
367 struct passwd *pw = getpwuid( uid ); 371 struct passwd *pw = getpwuid( uid );
368#endif 372#endif
369 373
370 int fd[ 2 ]; 374 int fd[ 2 ];
371 if ( 0 > pipe( fd ) ) 375 if ( 0 > pipe( fd ) )
372 { 376 {
373 fd[ 0 ] = fd[ 1 ] = 0; // Pipe failed.. continue 377 fd[ 0 ] = fd[ 1 ] = 0; // Pipe failed.. continue
374 } 378 }
375 379
376 runs = true; 380 runs = true;
377 381
378 QApplication::flushX(); 382 QApplication::flushX();
379 383
380 // WABA: Note that we use fork() and not vfork() because 384 // WABA: Note that we use fork() and not vfork() because
381 // vfork() has unclear semantics and is not standardized. 385 // vfork() has unclear semantics and is not standardized.
382 pid_ = fork(); 386 pid_ = fork();
383 387
384 if ( 0 == pid_ ) 388 if ( 0 == pid_ )
385 { 389 {
386 if ( fd[ 0 ] ) 390 if ( fd[ 0 ] )
387 close( fd[ 0 ] ); 391 close( fd[ 0 ] );
388 if ( !runPrivileged() ) 392 if ( !runPrivileged() )
389 { 393 {
390 setgid( gid ); 394 setgid( gid );
391#if defined( HAVE_INITGROUPS) 395#if defined( HAVE_INITGROUPS)
392 396
393 if ( pw ) 397 if ( pw )
394 initgroups( pw->pw_name, pw->pw_gid ); 398 initgroups( pw->pw_name, pw->pw_gid );
395#endif 399#endif
396 400
397 setuid( uid ); 401 setuid( uid );
398 } 402 }
399 // The child process 403 // The child process
400 if ( !commSetupDoneC() ) 404 if ( !commSetupDoneC() )
401 qWarning( "Could not finish comm setup in child!" ); 405 qWarning( "Could not finish comm setup in child!" );
402 406
403 setupEnvironment(); 407 setupEnvironment();
404 408
405 // Matthias 409 // Matthias
406 if ( run_mode == DontCare ) 410 if ( run_mode == DontCare )
407 setpgid( 0, 0 ); 411 setpgid( 0, 0 );
408 // restore default SIGPIPE handler (Harri) 412 // restore default SIGPIPE handler (Harri)
409 struct sigaction act; 413 struct sigaction act;
410 sigemptyset( &( act.sa_mask ) ); 414 sigemptyset( &( act.sa_mask ) );
411 sigaddset( &( act.sa_mask ), SIGPIPE ); 415 sigaddset( &( act.sa_mask ), SIGPIPE );
412 act.sa_handler = SIG_DFL; 416 act.sa_handler = SIG_DFL;
413 act.sa_flags = 0; 417 act.sa_flags = 0;
414 sigaction( SIGPIPE, &act, 0L ); 418 sigaction( SIGPIPE, &act, 0L );
415 419
416 // We set the close on exec flag. 420 // We set the close on exec flag.
417 // Closing of fd[1] indicates that the execvp succeeded! 421 // Closing of fd[1] indicates that the execvp succeeded!
418 if ( fd[ 1 ] ) 422 if ( fd[ 1 ] )
419 fcntl( fd[ 1 ], F_SETFD, FD_CLOEXEC ); 423 fcntl( fd[ 1 ], F_SETFD, FD_CLOEXEC );
420 424
421 if (initObex() == 0) { 425 if (initObex() == 0) {
422 do { 426 do {
423 int result; //Connection result 427 int result; //Connection result
424 if ( fd[ 1 ] ) { 428 if ( fd[ 1 ] ) {
425 ::close(fd[1]); 429 ::close(fd[1]);
426 fd[1] = 0; 430 fd[1] = 0;
427 } 431 }
428 if ((result = OBEX_HandleInput(m_obex, 60)) < 0) { 432 if ((result = OBEX_HandleInput(m_obex, 60)) < 0) {
429 if (errno != ECONNRESET) { 433 if (errno != ECONNRESET) {
430 printf("OBEX_HandleInput error %d\n", errno); 434 printf("OBEX_HandleInput error %d\n", errno);
431 fflush(stdout); 435 fflush(stdout);
432 _exit(-1); 436 _exit(-1);
433 } 437 }
434 else 438 else
435 _exit(0); 439 _exit(0);
436 } 440 }
437 } while(1); 441 } while(1);
438 } 442 }
439 char resultByte = 1; 443 char resultByte = 1;
440 if ( fd[ 1 ] ) 444 if ( fd[ 1 ] )
441 write( fd[ 1 ], &resultByte, 1 ); 445 write( fd[ 1 ], &resultByte, 1 );
442 _exit( -1 ); 446 _exit( -1 );
443 } 447 }
444 else if ( -1 == pid_ ) 448 else if ( -1 == pid_ )
445 { 449 {
446 // forking failed 450 // forking failed
447 451
448 runs = false; 452 runs = false;
449 return false; 453 return false;
450 } 454 }
451 else 455 else
452 { 456 {
453 if ( fd[ 1 ] ) 457 if ( fd[ 1 ] )
454 close( fd[ 1 ] ); 458 close( fd[ 1 ] );
455 // the parent continues here 459 // the parent continues here
456 460
457 // Discard any data for stdin that might still be there 461 // Discard any data for stdin that might still be there
458 input_data = 0; 462 input_data = 0;
459 463
460 // Check whether client could be started. 464 // Check whether client could be started.
461 if ( fd[ 0 ] ) 465 if ( fd[ 0 ] )
462 for ( ;; ) 466 for ( ;; )
463 { 467 {
464 char resultByte; 468 char resultByte;
465 int n = ::read( fd[ 0 ], &resultByte, 1 ); 469 int n = ::read( fd[ 0 ], &resultByte, 1 );
466 if ( n == 1 ) 470 if ( n == 1 )
467 { 471 {
468 // Error 472 // Error
469 runs = false; 473 runs = false;
470 close( fd[ 0 ] ); 474 close( fd[ 0 ] );
471 pid_ = 0; 475 pid_ = 0;
472 return false; 476 return false;
473 } 477 }
474 if ( n == -1 ) 478 if ( n == -1 )
475 { 479 {
476 if ( ( errno == ECHILD ) || ( errno == EINTR ) ) 480 if ( ( errno == ECHILD ) || ( errno == EINTR ) )
477 continue; // Ignore 481 continue; // Ignore
478 } 482 }
479 break; // success 483 break; // success
480 } 484 }
481 if ( fd[ 0 ] ) 485 if ( fd[ 0 ] )
482 close( fd[ 0 ] ); 486 close( fd[ 0 ] );
483 487
484 if ( !commSetupDoneP() ) // finish communication socket setup for the parent 488 if ( !commSetupDoneP() ) // finish communication socket setup for the parent
485 qWarning( "Could not finish comm setup in parent!" ); 489 qWarning( "Could not finish comm setup in parent!" );
486 490
487 if ( run_mode == Block ) 491 if ( run_mode == Block )
488 { 492 {
489 commClose(); 493 commClose();
490 494
491 // The SIGCHLD handler of the process controller will catch 495 // The SIGCHLD handler of the process controller will catch
492 // the exit and set the status 496 // the exit and set the status
493 while ( runs ) 497 while ( runs )
494 { 498 {
495 OProcessController::theOProcessController-> 499 OProcessController::theOProcessController->
496 slotDoHousekeeping( 0 ); 500 slotDoHousekeeping( 0 );
497 } 501 }
498 runs = FALSE; 502 runs = FALSE;
499 emit processExited( this ); 503 emit processExited( this );
500 } 504 }
501 } 505 }
502 return true; 506 return true;
503} 507}
504 508
505/* 509/*
506 * Stop forwarding process 510 * Stop forwarding process
507 */ 511 */
508int ObexServer::stop() 512int ObexServer::stop()
509{ 513{
510 kill(SIGTERM); 514 kill(SIGTERM);
511 return 0; 515 return 0;
512} 516}
513 517
514//eof 518//eof
diff --git a/core/obex/obexserver.h b/core/obex/obexserver.h
index 8567105..28577e2 100644
--- a/core/obex/obexserver.h
+++ b/core/obex/obexserver.h
@@ -1,83 +1,85 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> 3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under 6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; version 2 of the License. 9 - .   .-<_>     .<> Foundation; version 2 of the License.
10     ._= =}       : 10     ._= =}       :
11    .%+i>       _;_. 11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details. 18++=   -.     .     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22   --        :-= this library; see the file COPYING.LIB. 22   --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28/* 28/*
29 * The OBEX server class declaration 29 * The OBEX server class declaration
30 * Based on OBEX server from GPE (thanks, guys) 30 * Based on OBEX server from GPE (thanks, guys)
31 */ 31 */
32#ifndef ObexServer_H 32#ifndef ObexServer_H
33#define ObexServer_H 33#define ObexServer_H
34 34
35#include <qobject.h> 35#include <qobject.h>
36#include <opie2/oprocess.h> 36#include <opie2/oprocess.h>
37 37
38#include <bluetooth/sdp.h> 38#include <bluetooth/sdp.h>
39#include <bluetooth/sdp_lib.h> 39#include <bluetooth/sdp_lib.h>
40 40
41#include <openobex/obex.h> 41#include <openobex/obex.h>
42 42
43namespace Opie { 43namespace Opie {
44 namespace Core { 44 namespace Core {
45 class OProcess; 45 class OProcess;
46 namespace Internal { 46 namespace Internal {
47 class OProcessController; 47 class OProcessController;
48 } 48 }
49 } 49 }
50}; 50};
51 51
52namespace Opie {namespace Core {class OProcess;}} 52namespace Opie {namespace Core {class OProcess;}}
53namespace OpieObex { 53namespace OpieObex {
54 class ObexServer : public Opie::Core::OProcess { 54 class ObexServer : public Opie::Core::OProcess {
55 Q_OBJECT 55 Q_OBJECT
56 private:
57 int transport; //The OBEX transport type
56 public: 58 public:
57 /** 59 /**
58 * ObexServer constructor 60 * ObexServer constructor
59 */ 61 */
60 ObexServer(); 62 ObexServer(int trans);
61 /** 63 /**
62 * 64 *
63 */ 65 */
64 ~ObexServer(); 66 ~ObexServer();
65 //Function starts the server process 67 //Function starts the server process
66 virtual bool start( RunMode runmode = NotifyOnExit, 68 virtual bool start( RunMode runmode = NotifyOnExit,
67 Communication comm = NoCommunication ); 69 Communication comm = NoCommunication );
68 //Stop the server process 70 //Stop the server process
69 int stop(); 71 int stop();
70 protected: //variables 72 protected: //variables
71 obex_t* m_obex; //Obex server handler 73 obex_t* m_obex; //Obex server handler
72 sdp_session_t* m_session; //SDP session handler; 74 sdp_session_t* m_session; //SDP session handler;
73 protected: //functions 75 protected: //functions
74 //Funtion initializes obex server return 0 on success and -1 on error 76 //Funtion initializes obex server return 0 on success and -1 on error
75 int initObex(void); 77 int initObex(void);
76 //Function registers an OBEX push service 78 //Function registers an OBEX push service
77 sdp_session_t* addOpushSvc(uint8_t chan, const char* name); 79 sdp_session_t* addOpushSvc(uint8_t chan, const char* name);
78 signals: 80 signals:
79 protected slots: 81 protected slots:
80 }; 82 };
81}; 83};
82 84
83#endif 85#endif