You Are Here:

Community: Blogs

Paul Todd's Forum Nokia Blog

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);
}

 

RSSComments

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
 

Rate This

 
 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fblogsE2eforumE2enokiaE2ecomE2fblogE2fideasE2dyouE2dcanE2duseE2f2009E2f09E2f16E2fgravityE2dforE2dtwitterX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZBlogContentQ qdcZtypeQUqfntypeZBlogE45ntryQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZcppQ qfnZtopicQUqfnTopicZmessagingQ qfnZtopicQUqfnTopicZseriesE5f60Q qfnZtypeQUqfntypeZBlogContentQ qfnZtypeQUqfntypeZBlogE45ntryQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxmessagingX qfnZuserE5ftagQSxs60X qfnZuserE5ftagQSxsymbianE2dcE2bE2bX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZBlogContentQ qrdfZtypeQUqfntypeZBlogE45ntryQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ