Article # 692, added by Geoworks, historical record
| first | previous | index | next | last |

How to receive OBEX transport address structure.



Q. I am trying to send some data through the mailbox library, via
   the OBEX transport data structure. The receiving side should get
   the sent file name from the message and I cannot find it. I can
   extract the temporary file name from the data but the name of the
   file I cannot get. Here is how I try to do it:
  
   When I send the file I fill in the info as follows:
  
       MailboxRegisterMessageArgs mrma;
       MailboxMessage             mmsg;
       MailboxTransAddr           mta;
       ObexTDMailboxTransAddr     obexMta;
  
       /* Some irrelevant data filling here */
  
       /* This should be found at the receiving side */
       strncpy( obexMta.OMTA_fileName,
                ptcFileName,
                sizeof( obexMta.OMTA_fileName ) );
       strncpy( obexMta.OMTA_dataType,
                (TCHAR*)LMemDeref( @ringingtones ),
                sizeof( obexMta.OMTA_dataType ) );
       obexMta.OMTA_userHeadersLength = 0;
  
       mta.MTA_transAddr = &obexMta;
       mta.MTA_transAddrLen = sizeof( ObexTDMailboxTransAddr );
       mta.MTA_userTransAddr = 0;
       mrma.MRA_transAddrs = &mta;
       mrma.MRA_numTransAddrs = 1;
       mrma.MRA_flags = 0;
  
       /* Send */
       MailboxRegisterMessage( &mrma, &mmsg );
  
   And in the receiving side I try to read the data:
  
       MailboxDataFormat      dataFormat;
       FileDDMaxAppRef        fddmarFileInfo;
       ObexTDMailboxTransAddr obexMta;
  
       /* This shows that we receive by OBEX */
       MailboxGetBodyFormat( msg, &dataFormat );
  
       /* Here we can read the temp file name */
       wSize = sizeof( fddmarFileInfo );
       error = MailboxGetBodyRef( msg, &fddmarFileInfo, &wSize );
  
       /* But this fails - structure shows only mess */
       wSize = sizeof( ObexTDMailboxTransAddr );
       MailboxGetTransAddr( msg, 0, &obexMta, &wSize );

A. You should check your error return codes. This is probably returning
   an error and garbage in obexMta, because the transport address
   attached to the message is actually larger than the basic
   ObexTDMailboxTransAddr, so MailboxGetTransAddr is failing.

   The right way to fetch a transport address, particularly from an OBEX
   message, which you should expect to contain arbitrary extra OBEX
   headers, is to do the following:

       wSize = 0;
       MailboxGetTransAddr( msg, 0, NULL, &wSize );
          /* Will fail, but wSize now contains real size of the address */

       obexMta = 
       MailboxGetTransAddr( msg, 0, obexMta, &wSize ); /* Should succeed */