I want to iterate trough the inbox using filter for only SMS type of messages and mark every message with the certain address pattern as invisible and read one. The problem is with the call to CMsvEntry::ChangeL function (it leaves with error -46 which I think is KPermissionDenide). The function works fine on emulator but leaves happen only on device.
Here is the part of the code, which makes the change:
// Create new selection list
iSelection = new (ELeave) CMsvEntrySelection();
// Create the message filter
CMsvEntryFilter* messageFilter = CMsvEntryFilter::NewLC();
messageFilter->SetType( KUidMsvMessageEntry ); // message entry
messageFilter->SetMtm( KUidMsgTypeSMS ); // we want only SMS messages
// set order with no grouping, sort by date and show invisible
messageFilter->SetOrder(TMsvSelectionOrdering(KMsvNoGrouping, EMsvSortByDate, ETrue));
// Get all filtered messages from the Global Inbox
iMsvSession->GetChildIdsL( KInbox, *messageFilter, *iSelection );
// we do not need the filter any more
TMsvId serviceID; // the ID of the service that owns the entry
TMsvEntry entry; // the index of an entry
for(TInt index = 0; index < iSelection->Count(); index++)
// Take the entry and the service that owns the entry from the given entry TMsvID
iMsvSession->GetEntry((*iSelection)[index], serviceID, entry);
// Check the entry address if its match the pattern
if (entry.iDetails.FindF(KAddressPattern) != KErrNotFound)
iMsvEntry = NULL;
// Get the entry
// Taking an ownership of this CMsvEntry so we are responsible of deleting it
iMsvEntry = iMsvSession->GetEntryL(entry.Id());
// set message as read one
// set message invisible flag to true
// Sets the context's index entry to the current entry
// Commit the changes
// It is not an SMS we are looking for
} // for
// CMsvEntry is relatively expensive in RAM usage.
// They should therefore be created sparingly.
// We do not need the entry any more so we can delete it.
iMsvEntry = NULL;
Does anyone know why ChangeL leaves with -46 and what I have to do to fix this?