Hi ,
I want to create the block the outgoing sms for a particular number.
So the approach I follow is
1) Retrieve the number and body.
2) Then Delete the sms.
I am able to acheive 1 successfully but before the code reaches for point 2 my sms is sent from outbox.
so I am not able to delete the sms.
I am attaching my code snippet
void CSmsMmsObserver::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3)
{
switch(aEvent)
{
case EMsvEntriesChanged:
{
// Entry id is obtained from the session event arguments.
TMsvId* entryId = STATIC_CAST( TMsvId*, aArg2 );
// We are interested in messages that are created in outbox.
if ( *entryId != KMsvGlobalOutBoxIndexEntryId )
{
break;
}
// We take the created entries into a selection
CMsvEntrySelection* newEntries =
STATIC_CAST( CMsvEntrySelection*, aArg1 );
// Process each created entry.
for ( TInt i( 0 ); i < newEntries->Count(); i++ )
{
// We are interested in SMS messages.
if ( ( iSession->GetEntryL( newEntries->At( i ) ) )
->Entry().iMtm == KUidMsgTypeSMS )
{
// Add the entry to the selection of all received messages.
iSelection->AppendL( newEntries->At( i ), 1 );
// Set received messages visible.
MessageSendL( newEntries->At( i ) );// Here is my function to Reteive body and number of
//outgoing sms and Delete
}
}
break;
}
void CSmsMmsObserver::MessageSendL(TMsvId aEntryId)
{
LogNew(_L("\n MessageSendL"));
{
TInt MySMS;
MySMS=0;
CMsvEntry* entry = iSession->GetEntryL(aEntryId);
CleanupStack::PushL(entry);
TBuf<200> aAddress,aText;
LogNew(_L("\n MessageSendL1"));
if(entry->Entry().iMtm == KUidMsgTypeSMS)
{
//SetMtmEntryL(aEntryId);
LogNew(_L("\n KUidMsgTypeSMSs"));
//iMtmReg->LoadMessageL();
//CSmsClientMtm* iSmsMtm1 = static_cast<CSmsClientMtm*>(iMtmReg);
iSmsMtm->SwitchCurrentEntryL(aEntryId);
LogNew(_L("\n KUidMsgTypeSMSsdd"));
iSmsMtm->LoadMessageL();
LogNew(_L("\n KUidMsgTypeSMSsddee"));
iSmsMtm->RestoreServiceAndSettingsL();
LogNew(_L("\n KUidMsgTypeSMSs1"));
CSmsHeader& header = iSmsMtm->SmsHeader();
LogNew(_L("\n KUidMsgTypeSMSs2"));
aAddress.Zero();
LogNew(_L("\n KUidMsgTypeSMSs3"));
aAddress.Copy(header.FromAddress());
LogNew(aAddress);
CRichText& body = iSmsMtm->Body();
LogNew(_L("\n KUidMsgTypeSMSs5"));
TPtrC text(body.Read(0, body.DocumentLength()));
LogNew(_L("\n KUidMsgTypeSMSs6"));
//Text.Copy(text);
if(text.Length()<=150)
{
aText.Copy(text);
}
else
{
aText.Copy(text.Mid(0,150));
}
LogNew(_L("\n Send Number"));
LogNew(aAddress);
LogNew(_L("\n Body"));
LogNew(aText);
if(aAddress.Length()> 0 && aText.Length()> 0)///I have kept a check here to get both the number and body
{ //Before deletion of message
iAppUi->ShowNotification();
entry->DeleteL(aEntryId);
}
CleanupStack::PopAndDestroy(1);//entry
}
else
{
CleanupStack::PopAndDestroy(1);//entry
}
//
}
}






