Join Now

Hi, I'm Paul, but you can also call me Todd and I won't get upset.

Send a file bluetooth

Paul.Todd | 16 February, 2007 10:37

A number of people seem to have a problem using RSendAs to send a file via Bluetooth but its more or less the same as sending any other message.

To start,  you need to get hold of the bluetooth MTM UID, its in "SendUiConsts.h"

Then its simply a case of:

  1. Opening the SendAs session
  2. Creating a message using the session
  3. Adding the file as an attachment
  4. Sending the message

void SendFileL(const TDesC& aFilename)
    {
   // 1. Open session
   RSendAs session;
   User::LeaveIfError(session.Connect());
   CleanupClosePushL(session);

   // 2. Create message
   RSendAsMessage message;
   message.CreateL(session, KSenduiMtmBtUid);
   CleanupClosePushL(message);

    // 3. Add attachment
    TRequestStatus status;
    message.AddAttachment(aFilename.FullName(), status);
    User::WaitForRequest(status);

    // 4. Send message
    if (status.Int() == KErrNone)
        {  
        CleanupStack::Pop(&message);
        message.LaunchEditorAndCloseL();
        }
   else
       CleanupStack::PopAndDestroy(&message); 

   CleanupStack::PopAndDestroy(&session);
}

 

Comments

Re: Send a file bluetooth

KevinD | 16/02/2007, 13:07

Nice and simple!

One thing I would say (and a general tip) - User::WaitForRequest() is nearly always a bad idea... Why?

* In an app, it will block re-drawing (adding the attachment usually completes quickly, but can take more time than you think if the file system is tied up). Not only does this look bad, you put yourself at risk of ViewSrv 11 panics.

* WaitForRequest() *doesn't work* with chains of active objects (and you have no way of telling if there is a chain of active objects underneath AddAttachment()). Prime examples where this can get you into hot water are the CTelephony methods (see http://forum.nokia.com/document/Forum_Nokia_Technical_Library/contents/FNTL/User_WaitForRequest()_with_ETel_3rd_Party_API_CTelephony.htm).

Avoid User::WaitForRequest() if at all possible..... If you are calling an asynchronous method, it was probably meant to be asynchronous.

Re: Send a file bluetooth

krk_mohan | 16/02/2007, 13:39

Hello,

Thanks a lot for this code...I wanted to know how a BT recipient can be added to the method RSendAsMessage::AddRecipientL();...As in, do we give the BT address of the remote device directly in the ESendAsRecipientTo field of the message?

Thanks & Regards,
Mohan
You must login to post comments. Login
 
 
Powered by LifeType
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZcppQ
     qfnZtopicQUqfnTopicZmessagingQ
     qfnZtopicQUqfnTopicZseriesE5f60Q
     qfnZtypeQUqfnTypeZBlogContentQ
     qfnZtypeQUqfnTypeZBlogE45ntryQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX