Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3464282
  • 博文数量: 1450
  • 博客积分: 11163
  • 博客等级: 上将
  • 技术积分: 11101
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-25 14:40
文章分类

全部博文(1450)

文章存档

2017年(5)

2014年(2)

2013年(3)

2012年(35)

2011年(39)

2010年(88)

2009年(395)

2008年(382)

2007年(241)

2006年(246)

2005年(14)

分类: 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

  • 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.

阅读(444) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~