author | korovkin <korovkin> | 2007-01-24 18:38:04 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2007-01-24 18:38:04 (UTC) |
commit | a4a7bd22feb060a80e20c81cded43cc24f5cd423 (patch) (unidiff) | |
tree | 5d92d27b96ad235f3815014f98d49c766461a678 | |
parent | 8644340455a433f4d6e3b31b329479f1e7983f78 (diff) | |
download | opie-a4a7bd22feb060a80e20c81cded43cc24f5cd423.zip opie-a4a7bd22feb060a80e20c81cded43cc24f5cd423.tar.gz opie-a4a7bd22feb060a80e20c81cded43cc24f5cd423.tar.bz2 |
OBEX push server has a more common description.
-rw-r--r-- | core/obex/obexserver.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/obex/obexserver.cpp b/core/obex/obexserver.cpp index 25d8224..f1fb205 100644 --- a/core/obex/obexserver.cpp +++ b/core/obex/obexserver.cpp | |||
@@ -276,129 +276,129 @@ sdp_session_t* ObexServer::addOpushSvc(uint8_t chan, const char* name) | |||
276 | profile[0].version = 0x0100; | 276 | profile[0].version = 0x0100; |
277 | pfseq = sdp_list_append(0, profile); | 277 | pfseq = sdp_list_append(0, profile); |
278 | sdp_set_profile_descs(&record, pfseq); | 278 | sdp_set_profile_descs(&record, pfseq); |
279 | 279 | ||
280 | sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID); | 280 | sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID); |
281 | proto[0] = sdp_list_append(0, &l2cap_uuid); | 281 | proto[0] = sdp_list_append(0, &l2cap_uuid); |
282 | apseq = sdp_list_append(0, proto[0]); | 282 | apseq = sdp_list_append(0, proto[0]); |
283 | 283 | ||
284 | sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID); | 284 | sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID); |
285 | proto[1] = sdp_list_append(0, &rfcomm_uuid); | 285 | proto[1] = sdp_list_append(0, &rfcomm_uuid); |
286 | channel = sdp_data_alloc(SDP_UINT8, &chan); | 286 | channel = sdp_data_alloc(SDP_UINT8, &chan); |
287 | proto[1] = sdp_list_append(proto[1], channel); | 287 | proto[1] = sdp_list_append(proto[1], channel); |
288 | apseq = sdp_list_append(apseq, proto[1]); | 288 | apseq = sdp_list_append(apseq, proto[1]); |
289 | 289 | ||
290 | sdp_uuid16_create(&obex_uuid, OBEX_UUID); | 290 | sdp_uuid16_create(&obex_uuid, OBEX_UUID); |
291 | proto[2] = sdp_list_append(0, &obex_uuid); | 291 | proto[2] = sdp_list_append(0, &obex_uuid); |
292 | apseq = sdp_list_append(apseq, proto[2]); | 292 | apseq = sdp_list_append(apseq, proto[2]); |
293 | 293 | ||
294 | aproto = sdp_list_append(0, apseq); | 294 | aproto = sdp_list_append(0, apseq); |
295 | sdp_set_access_protos(&record, aproto); | 295 | sdp_set_access_protos(&record, aproto); |
296 | 296 | ||
297 | for (i = 0; i < sizeof(formats); i++) | 297 | for (i = 0; i < sizeof(formats); i++) |
298 | { | 298 | { |
299 | dtds[i] = &dtd; | 299 | dtds[i] = &dtd; |
300 | values[i] = &formats[i]; | 300 | values[i] = &formats[i]; |
301 | } | 301 | } |
302 | sflist = sdp_seq_alloc(dtds, values, sizeof(formats)); | 302 | sflist = sdp_seq_alloc(dtds, values, sizeof(formats)); |
303 | sdp_attr_add(&record, SDP_ATTR_SUPPORTED_FORMATS_LIST, sflist); | 303 | sdp_attr_add(&record, SDP_ATTR_SUPPORTED_FORMATS_LIST, sflist); |
304 | 304 | ||
305 | sdp_set_info_attr(&record, name, 0, 0); | 305 | sdp_set_info_attr(&record, name, 0, 0); |
306 | 306 | ||
307 | // connect to the local SDP server, register the service record, and | 307 | // connect to the local SDP server, register the service record, and |
308 | // disconnect | 308 | // disconnect |
309 | lsession = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY); | 309 | lsession = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY); |
310 | if (lsession == NULL) | 310 | if (lsession == NULL) |
311 | goto errout; | 311 | goto errout; |
312 | err = sdp_record_register(lsession, &record, 0); | 312 | err = sdp_record_register(lsession, &record, 0); |
313 | if (err) { | 313 | if (err) { |
314 | sdp_close(lsession); | 314 | sdp_close(lsession); |
315 | lsession = NULL; | 315 | lsession = NULL; |
316 | } | 316 | } |
317 | errout: | 317 | errout: |
318 | sdp_data_free(channel); | 318 | sdp_data_free(channel); |
319 | sdp_list_free(proto[0], 0); | 319 | sdp_list_free(proto[0], 0); |
320 | sdp_list_free(proto[1], 0); | 320 | sdp_list_free(proto[1], 0); |
321 | sdp_list_free(proto[2], 0); | 321 | sdp_list_free(proto[2], 0); |
322 | sdp_list_free(apseq, 0); | 322 | sdp_list_free(apseq, 0); |
323 | sdp_list_free(aproto, 0); | 323 | sdp_list_free(aproto, 0); |
324 | 324 | ||
325 | return lsession; | 325 | return lsession; |
326 | } | 326 | } |
327 | 327 | ||
328 | int ObexServer::initObex(void) | 328 | int ObexServer::initObex(void) |
329 | { | 329 | { |
330 | int channel = 10; //Channel on which we do listen | 330 | int channel = 10; //Channel on which we do listen |
331 | if (m_obex) | 331 | if (m_obex) |
332 | return 0; | 332 | return 0; |
333 | m_obex = ::OBEX_Init(transport, obex_event, 0); | 333 | m_obex = ::OBEX_Init(transport, obex_event, 0); |
334 | if (!m_obex) { | 334 | if (!m_obex) { |
335 | printf("OBEX initialization error %d\n", errno); | 335 | printf("OBEX initialization error %d\n", errno); |
336 | return -1; | 336 | return -1; |
337 | } | 337 | } |
338 | if (transport == OBEX_TRANS_BLUETOOTH) { | 338 | if (transport == OBEX_TRANS_BLUETOOTH) { |
339 | ::BtOBEX_ServerRegister(m_obex, NULL, channel); | 339 | ::BtOBEX_ServerRegister(m_obex, NULL, channel); |
340 | m_session = addOpushSvc(channel, "OBEX push service"); | 340 | m_session = addOpushSvc(channel, "OBEX Object Push"); |
341 | if (!m_session) { | 341 | if (!m_session) { |
342 | printf("OBEX registration error %d\n", errno); | 342 | printf("OBEX registration error %d\n", errno); |
343 | ::OBEX_Cleanup(m_obex); | 343 | ::OBEX_Cleanup(m_obex); |
344 | m_obex = NULL; | 344 | m_obex = NULL; |
345 | return -1; | 345 | return -1; |
346 | } | 346 | } |
347 | } else if (transport == OBEX_TRANS_IRDA) | 347 | } else if (transport == OBEX_TRANS_IRDA) |
348 | ::IrOBEX_ServerRegister(m_obex, "OBEX"); | 348 | ::IrOBEX_ServerRegister(m_obex, "OBEX"); |
349 | return 0; | 349 | return 0; |
350 | } | 350 | } |
351 | 351 | ||
352 | bool ObexServer::start(RunMode runmode, Communication comm) | 352 | bool ObexServer::start(RunMode runmode, Communication comm) |
353 | { | 353 | { |
354 | if ( runs ) | 354 | if ( runs ) |
355 | { | 355 | { |
356 | return false; // cannot start a process that is already running | 356 | return false; // cannot start a process that is already running |
357 | // or if no executable has been assigned | 357 | // or if no executable has been assigned |
358 | } | 358 | } |
359 | run_mode = runmode; | 359 | run_mode = runmode; |
360 | status = 0; | 360 | status = 0; |
361 | 361 | ||
362 | if ( !setupCommunication( comm ) ) | 362 | if ( !setupCommunication( comm ) ) |
363 | qWarning( "Could not setup Communication!" ); | 363 | qWarning( "Could not setup Communication!" ); |
364 | 364 | ||
365 | // 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 |
366 | // gdb gets confused when the application runs from gdb. | 366 | // gdb gets confused when the application runs from gdb. |
367 | uid_t uid = getuid(); | 367 | uid_t uid = getuid(); |
368 | gid_t gid = getgid(); | 368 | gid_t gid = getgid(); |
369 | #ifdef HAVE_INITGROUPS | 369 | #ifdef HAVE_INITGROUPS |
370 | 370 | ||
371 | struct passwd *pw = getpwuid( uid ); | 371 | struct passwd *pw = getpwuid( uid ); |
372 | #endif | 372 | #endif |
373 | 373 | ||
374 | int fd[ 2 ]; | 374 | int fd[ 2 ]; |
375 | if ( 0 > pipe( fd ) ) | 375 | if ( 0 > pipe( fd ) ) |
376 | { | 376 | { |
377 | fd[ 0 ] = fd[ 1 ] = 0; // Pipe failed.. continue | 377 | fd[ 0 ] = fd[ 1 ] = 0; // Pipe failed.. continue |
378 | } | 378 | } |
379 | 379 | ||
380 | runs = true; | 380 | runs = true; |
381 | 381 | ||
382 | QApplication::flushX(); | 382 | QApplication::flushX(); |
383 | 383 | ||
384 | // WABA: Note that we use fork() and not vfork() because | 384 | // WABA: Note that we use fork() and not vfork() because |
385 | // vfork() has unclear semantics and is not standardized. | 385 | // vfork() has unclear semantics and is not standardized. |
386 | pid_ = fork(); | 386 | pid_ = fork(); |
387 | 387 | ||
388 | if ( 0 == pid_ ) | 388 | if ( 0 == pid_ ) |
389 | { | 389 | { |
390 | if ( fd[ 0 ] ) | 390 | if ( fd[ 0 ] ) |
391 | close( fd[ 0 ] ); | 391 | close( fd[ 0 ] ); |
392 | if ( !runPrivileged() ) | 392 | if ( !runPrivileged() ) |
393 | { | 393 | { |
394 | setgid( gid ); | 394 | setgid( gid ); |
395 | #if defined( HAVE_INITGROUPS) | 395 | #if defined( HAVE_INITGROUPS) |
396 | 396 | ||
397 | if ( pw ) | 397 | if ( pw ) |
398 | initgroups( pw->pw_name, pw->pw_gid ); | 398 | initgroups( pw->pw_name, pw->pw_gid ); |
399 | #endif | 399 | #endif |
400 | 400 | ||
401 | setuid( uid ); | 401 | setuid( uid ); |
402 | } | 402 | } |
403 | // The child process | 403 | // The child process |
404 | if ( !commSetupDoneC() ) | 404 | if ( !commSetupDoneC() ) |