read attachment from bluetooth

Login to reply to this topic.
Mon, 2007-03-05 10:28
Joined: 2006-07-21
Forum posts: 151
Hi,
i need to read in my inbox the attachment of bluetooth message.
I work with series60.
How to its?
Thanks a lots
SIlvia

Tue, 2007-03-06 06:25
Joined: 2006-11-14
Forum posts: 89
Re: read attachment from bluetooth
Hi SIlvia,

For reading inbox use any mtm example

In that switch mtm on that bluetooth message ID.

   in iDetail field you get "bluetooth" and
  in iDescription field you get "fileName"

then

(now main task starts from here)

get that entry and get childrens ids by CMsvEntrySelection

then check that entry has a store or not then if it has store

then with the help of MMsvAttachmentManager  you can

get the attachment.

CMsvEntry& btEntry = iMtm->Entry();
               
   //   CleanupStack::PushL(btEntry);
      CMsvEntrySelection* btChildren = btEntry.ChildrenL();


Thanks And Regards,
Yogesh
Tue, 2007-03-06 09:36
Joined: 2006-07-21
Forum posts: 151
Re: read attachment from bluetooth
Hi,
this method work, but iDescription has a not valid value, why?
I write this code that work, but nont iDescription Sad

if(msvEntry.iMtm == KUidMsgTypeBt)
   {
      smsMtm->LoadMessageL();
      
      //CEikonEnv::Static()->AlertWin(_L("sono un sms bluetooth"));
      
      CMsvEntry* btEntry = iSession->GetEntryL(aEntryId);
      CleanupStack::PushL(btEntry);
      CMsvEntrySelection* btChildren = btEntry->ChildrenL();
      CleanupStack::PushL(btChildren);
      
      if (btChildren->Count() == 1)
      {
         TMsvId btAtt = (*btChildren)[0];
         btEntry->SetEntryL(btAtt); // switch context to CHILD entry
         
         
         if (btEntry->HasStoreL())
         {
            User::After(1000000);
            CMsvStore* store = btEntry->ReadStoreL();
            CleanupStack::PushL(store);

            TBuf<60>det;
            det.AppendFormat(msvEntry.iDetails);
            
            TBuf<60>des;
            des.AppendFormat(msvEntry.iDescription);
            CEikonEnv::Static()->AlertWin(det, des); //this is the prblem
 Sad            
            
            TBuf<98> sub;
            sub.Copy(smsMtm->SubjectL());
            CEikonEnv::Static()->AlertWin(_L("sub"), sub);
                  
            TFileName attPath, KPathAppVideo;
            TInt p;
            p = btEntry->GetFilePath(attPath);
            
            
            
            
            CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
            globalNote->ShowNoteL( EAknGlobalErrorNote,  attPath);
            CleanupStack::PopAndDestroy();
            
            
            
            RFs fsSession;
            User::LeaveIfError(fsSession.Connect());
            
            
            
            KPathAppVideo += _L("mypath");
            KPathAppVideo += msvEntry.iDescription;
            attPath += msvEntry.iDescription;
            
            
            
            User::LeaveIfError(fsSession.Rename(attPath, KPathAppVideo));
            fsSession.Close();
                  
            CEikonEnv::Static()->AlertWin(_L("fine"));
            CleanupStack::PopAndDestroy(store);
         }
      }
      CleanupStack::PopAndDestroy(2, btEntry);
      
      
      
   }


best regards
Silvia
Tue, 2007-03-06 10:33
Joined: 2006-11-14
Forum posts: 89
Re: read attachment from bluetooth
Hi,

Use following code


void CMtmsEngine::SetMtmEntryL(TMsvId aEntryId)
{
   //Get the server entry from our session

   CMsvEntry* entry = iSession->GetEntryL(aEntryId);

   CleanupStack::PushL(entry);

   //Check if our mtm is different from the mtm set to our entry
   if ((iMtm == NULL) || (entry->Entry().iMtm != (iMtm->Entry()).Entry().iMtm))
    {
       //If so, we delete the old...
       delete iMtm;
       iMtm = NULL;

       // ...and get a new one from the MtmRegistry
       iMtm = iMtmReg->NewMtmL(entry->Entry().iMtm);
    }
    iMtm->SetCurrentEntryL(entry);

   CleanupStack::Pop(entry);
}

TBool CMtmsEngine::GetBluetoohAttachment( TMsvId aMessageId)
{

   _LIT(KBluetoothMessage, "Bluetooth");

   SetMtmEntryL(aMessageId);

   iMtm->LoadMessageL();

   TMsvEntry MsvEntry = iMtm->Entry().Entry();

   TBufC<20> itext(MsvEntry.iDetails);

   if( itext == KBluetoothMessage)
   {

      CMsvEntry& btEntry = iMtm->Entry();

      CMsvEntrySelection* btChildren = btEntry.ChildrenL();

      if (btChildren->Count() >= 1)
      {
         TMsvId btAtt = (*btChildren)[0];
         btEntry.SetEntryL(btAtt); // switch context to CHILD entry

         if (btEntry.HasStoreL())
         {
            CMsvStore* store = btEntry.ReadStoreL();

            CleanupStack::PushL(store);

            CRichText* richText = CRichText::NewL(
                              CEikonEnv::Static()->SystemParaFormatLayerL(),
                              CEikonEnv::Static()->SystemCharFormatLayerL());
            richText->Reset();
            CleanupStack::PushL(richText);

            if (store->HasBodyTextL())
            {

               // Get the SMS body text.
               store->RestoreBodyTextL(*richText);


               TPtrC ptr;
               TCharFormat aFormat;
               richText->GetChars(ptr,aFormat,0);

               logBuf.Copy(p);
               logMe(logBuf);
            }
            else
            {

               MMsvAttachmentManager& iAttMangr=store->AttachmentManagerL();

               RFile attFile=iAttMangr.GetAttachmentFileL(0);

               TBuf8<256> attFileBuf;

               attFile.Read(attFileBuf);

               attFile.Close();

               logBuf.Copy(attFileBuf);
               logMe(logBuf);

            }

            CleanupStack::PopAndDestroy(richText);
            CleanupStack::PopAndDestroy(store);
         }
         else
         {
            return EFalse;
         }
      }
   }
   return ETrue;
}


Thanks And Regards,
Yogesh
Tue, 2007-03-06 11:33
Joined: 2006-07-21
Forum posts: 151
Re: read attachment from bluetooth
I resolved my proble, thanks you Smiley
Bye
Silvia
  • Login to reply to this topic.