summaryrefslogtreecommitdiff
authorMarek Vasut <marek.vasut@gmail.com>2007-07-14 22:09:38 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-15 18:33:28 (UTC)
commit9dacb2c97939fad573446c0858f6b536b3d7bf15 (patch) (unidiff)
tree6cb098508e6513f67d608278bf6f61a08fb6d158
parent15fbd2a9189281ca84d89ad6a77261d0046add36 (diff)
downloadopie-9dacb2c97939fad573446c0858f6b536b3d7bf15.zip
opie-9dacb2c97939fad573446c0858f6b536b3d7bf15.tar.gz
opie-9dacb2c97939fad573446c0858f6b536b3d7bf15.tar.bz2
obex receive fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/obexserver.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/core/obex/obexserver.cpp b/core/obex/obexserver.cpp
index f1fb205..786e9f7 100644
--- a/core/obex/obexserver.cpp
+++ b/core/obex/obexserver.cpp
@@ -186,49 +186,60 @@ static void obex_conn_event (obex_t *handle, obex_object_t *object,
186 int mode, int event, int obex_cmd, int obex_rsp) 186 int mode, int event, int obex_cmd, int obex_rsp)
187{ 187{
188 (void)mode; 188 (void)mode;
189 (void)obex_rsp; 189 (void)obex_rsp;
190 190
191 switch(event) { 191 switch(event) {
192 case OBEX_EV_REQHINT: 192 case OBEX_EV_REQHINT:
193 switch(obex_cmd) { 193 switch(obex_cmd) {
194 case OBEX_CMD_PUT: 194 case OBEX_CMD_PUT:
195 case OBEX_CMD_CONNECT: 195 case OBEX_CMD_CONNECT:
196 case OBEX_CMD_DISCONNECT: 196 case OBEX_CMD_DISCONNECT:
197 OBEX_ObjectSetRsp (object, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS); 197 OBEX_ObjectSetRsp (object, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS);
198 break; 198 break;
199 default: 199 default:
200 OBEX_ObjectSetRsp (object, OBEX_RSP_NOT_IMPLEMENTED, 200 OBEX_ObjectSetRsp (object, OBEX_RSP_NOT_IMPLEMENTED,
201 OBEX_RSP_NOT_IMPLEMENTED); 201 OBEX_RSP_NOT_IMPLEMENTED);
202 break; 202 break;
203 } 203 }
204 break; 204 break;
205 205
206 case OBEX_EV_REQ: 206 case OBEX_EV_REQ:
207 /* Comes when a server-request has been received. */ 207 /* Comes when a server-request has been received. */
208 handle_request (handle, object, event, obex_cmd); 208 handle_request (handle, object, event, obex_cmd);
209 break; 209 break;
210 210 case OBEX_EV_REQDONE:
211 switch(obex_cmd) {
212 case OBEX_CMD_PUT:
213 case OBEX_CMD_CONNECT:
214 break;
215 case OBEX_CMD_DISCONNECT:
216 OBEX_TransportDisconnect(handle);
217 break;
218 default:
219 break;
220 }
221 break;
211 case OBEX_EV_LINKERR: 222 case OBEX_EV_LINKERR:
212 break; 223 break;
213 } 224 }
214} 225}
215 226
216/** 227/**
217 * Function handles OBEX event 228 * Function handles OBEX event
218 * @param handle OBEX connection handle 229 * @param handle OBEX connection handle
219 * @param object OBEX object itself 230 * @param object OBEX object itself
220 * @param mode 231 * @param mode
221 * @param event event code 232 * @param event event code
222 * @param obex_cmd OBEX command itself 233 * @param obex_cmd OBEX command itself
223 * @param obex_rsp OBEX responce 234 * @param obex_rsp OBEX responce
224 */ 235 */
225static void obex_event (obex_t* handle, obex_object_t* object, int mode, 236static void obex_event (obex_t* handle, obex_object_t* object, int mode,
226 int event, int obex_cmd, int obex_rsp) 237 int event, int obex_cmd, int obex_rsp)
227{ 238{
228 239
229 obex_t *obex; //OBEX connection handle 240 obex_t *obex; //OBEX connection handle
230 241
231 switch (event) { 242 switch (event) {
232 case OBEX_EV_ACCEPTHINT: 243 case OBEX_EV_ACCEPTHINT:
233 obex = OBEX_ServerAccept (handle, obex_conn_event, NULL); 244 obex = OBEX_ServerAccept (handle, obex_conn_event, NULL);
234 break; 245 break;
@@ -403,62 +414,54 @@ bool ObexServer::start(RunMode runmode, Communication comm)
403 // The child process 414 // The child process
404 if ( !commSetupDoneC() ) 415 if ( !commSetupDoneC() )
405 qWarning( "Could not finish comm setup in child!" ); 416 qWarning( "Could not finish comm setup in child!" );
406 417
407 setupEnvironment(); 418 setupEnvironment();
408 419
409 // Matthias 420 // Matthias
410 if ( run_mode == DontCare ) 421 if ( run_mode == DontCare )
411 setpgid( 0, 0 ); 422 setpgid( 0, 0 );
412 // restore default SIGPIPE handler (Harri) 423 // restore default SIGPIPE handler (Harri)
413 struct sigaction act; 424 struct sigaction act;
414 sigemptyset( &( act.sa_mask ) ); 425 sigemptyset( &( act.sa_mask ) );
415 sigaddset( &( act.sa_mask ), SIGPIPE ); 426 sigaddset( &( act.sa_mask ), SIGPIPE );
416 act.sa_handler = SIG_DFL; 427 act.sa_handler = SIG_DFL;
417 act.sa_flags = 0; 428 act.sa_flags = 0;
418 sigaction( SIGPIPE, &act, 0L ); 429 sigaction( SIGPIPE, &act, 0L );
419 430
420 // We set the close on exec flag. 431 // We set the close on exec flag.
421 // Closing of fd[1] indicates that the execvp succeeded! 432 // Closing of fd[1] indicates that the execvp succeeded!
422 if ( fd[ 1 ] ) 433 if ( fd[ 1 ] )
423 fcntl( fd[ 1 ], F_SETFD, FD_CLOEXEC ); 434 fcntl( fd[ 1 ], F_SETFD, FD_CLOEXEC );
424 435
425 if (initObex() == 0) { 436 if (initObex() == 0) {
426 do { 437 do {
427 int result; //Connection result
428 if ( fd[ 1 ] ) { 438 if ( fd[ 1 ] ) {
429 ::close(fd[1]); 439 ::close(fd[1]);
430 fd[1] = 0; 440 fd[1] = 0;
431 } 441 }
432 if ((result = OBEX_HandleInput(m_obex, 60)) < 0) { 442 if (OBEX_HandleInput(m_obex, 10) < 0)
433 if (errno != ECONNRESET) { 443 _exit(0);
434 printf("OBEX_HandleInput error %d\n", errno);
435 fflush(stdout);
436 _exit(-1);
437 }
438 else
439 _exit(0);
440 }
441 } while(1); 444 } while(1);
442 } 445 }
443 char resultByte = 1; 446 char resultByte = 1;
444 if ( fd[ 1 ] ) 447 if ( fd[ 1 ] )
445 write( fd[ 1 ], &resultByte, 1 ); 448 write( fd[ 1 ], &resultByte, 1 );
446 _exit( -1 ); 449 _exit( -1 );
447 } 450 }
448 else if ( -1 == pid_ ) 451 else if ( -1 == pid_ )
449 { 452 {
450 // forking failed 453 // forking failed
451 454
452 runs = false; 455 runs = false;
453 return false; 456 return false;
454 } 457 }
455 else 458 else
456 { 459 {
457 if ( fd[ 1 ] ) 460 if ( fd[ 1 ] )
458 close( fd[ 1 ] ); 461 close( fd[ 1 ] );
459 // the parent continues here 462 // the parent continues here
460 463
461 // Discard any data for stdin that might still be there 464 // Discard any data for stdin that might still be there
462 input_data = 0; 465 input_data = 0;
463 466
464 // Check whether client could be started. 467 // Check whether client could be started.