分类: C/C++
2009-04-15 14:05:24
Local folders can be created under the global "Inbox" and under the "My Folders" folders. Access to other locations in the messaging tree is restricted to the system and particular MTMs that own those locations.
Hearders Required:
#include#include
Library required:
LIBRARY msgs.lib
To check if a custom folder already exists under the parent folder My Folders:
TBool CSmsHandler::Check() { CMsvEntry * entry = iSession->GetEntryL( KMsvMyFoldersEntryIdValue ); CleanupStack::PushL( entry ); CMsvEntrySelection * entries = entry->ChildrenWithTypeL(KUidMsvFolderEntry); CleanupStack::PopAndDestroy( entry ); TInt nCount = entries->Count(); TInt found =0; for ( TInt i=1; i < nCount; i++ ) { TMsvId entryID = entries->At( i ); entry = iSession->GetEntryL( entryID ); CleanupStack::PushL( entry ); TMsvEntry msvEntry = entry->Entry(); TPtrC descr = msvEntry.iDetails; if (descr.Compare(_L("MyToday"))==0) { found =1; iNewFolderId=entryID ; } CleanupStack::PopAndDestroy( entry ); } delete entries; return found; }
Two files need to be updated
const TMsvId KMsvMyFoldersEntryId=KMsvMyFoldersEntryIdValue;
#define KMsvMyFoldersEntryIdValue 0x1008
To create a custom folder, you can use the following type and MTM settings for the index entry:
TMsvEntry mEntry; mEntry.iMtm = KUidMsvLocalServiceMtm; mEntry.iServiceId = KMsvLocalServiceIndexEntryId; mEntry.iType = KUidMsvFolderEntry;
The following code shows how to create a folder named Wiki under My Folders
TMsvId msvServId; CMsvEntry *entry1 = NULL; CMsvEntry * rootEntry = NULL; CMsvEntry *entryRootService = NULL; TInt newFldrID = 0; //Get the entry (whatever is passed in) entry1 = iSmsMtm->Session().GetEntryL(KMsvMyFoldersEntryIdValue); CleanupStack::PushL(entry1); if (entry1) { msvServId = entry1->OwningService(); entryRootService = iSmsMtm->Session().GetEntryL(msvServId); CleanupStack::PushL(entryRootService); rootEntry = iSmsMtm->Session().GetEntryL(msvServId); CleanupStack::PushL(rootEntry); rootEntry->SetEntryL(KMsvMyFoldersEntryIdValue); // set to parent TMsvEntry newServiceEntry; TTime ttime; ttime.HomeTime(); newServiceEntry.iDate = ttime; newServiceEntry.iSize = 0; newServiceEntry.iType = KUidMsvFolderEntry; newServiceEntry.iMtm = KUidMsvLocalServiceMtm; newServiceEntry.iServiceId = iSmsMtm->ServiceId(); newServiceEntry.iDetails.Set (_L("Wiki")); newServiceEntry.iDescription.Set(KNullDesC); newServiceEntry.SetVisible(ETrue); rootEntry->CreateL(newServiceEntry); newFldrID = newServiceEntry.Id(); iNewFolderId=newFldrID; CleanupStack::PopAndDestroy(); CleanupStack::PopAndDestroy(); }
Hence a folder Wiki is created in My Folders folder.