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);
Forum posts: 89
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
Forum posts: 151
this method work, but iDescription has a not valid value, why?
I write this code that work, but nont iDescription
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
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
Forum posts: 89
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
Forum posts: 151
Bye
Silvia