×
Namespaces

Variants
Actions

How to create Local Message Folder

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: eswar_illuri (07 May 2007)
Last edited: hamishwillee (26 Jul 2012)
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 <msvapi.h> 
#include <msvstd.h >

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

  • msvids.h has to be updated with:
const TMsvId KMsvMyFoldersEntryId=KMsvMyFoldersEntryIdValue;
  • msvstd.hrh has to be updated with:
#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.


Related Links:

This page was last modified on 26 July 2012, at 05:42.
53 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×