emailservices/emailframework/commonlib/src/CFSMailBox.cpp
branchRCL_3
changeset 8 e1b6206813b4
parent 0 8466d47a6819
child 12 f5907b1a1053
equal deleted inserted replaced
4:e7aa27f58ae1 8:e1b6206813b4
    17 
    17 
    18 #include "emailtrace.h"
    18 #include "emailtrace.h"
    19 #include <bamdesca.h>
    19 #include <bamdesca.h>
    20 
    20 
    21 
    21 
    22 #include "CFSMailPlugin.h"
    22 #include "cfsmailplugin.h"
    23 #include "cmrcalendarinfoimpl.h"
    23 #include "cmrcalendarinfoimpl.h"
    24 
    24 
    25 #include "CFSMailBox.h"
    25 #include "cfsmailbox.h"
    26 #include "CFSMailRequestObserver.h"
    26 #include "cfsmailrequestobserver.h"
    27 
    27 
    28 const TInt KMaxMruEntries( 150 );
    28 const TInt KMaxMruEntries( 150 );
    29 
    29 
    30 // ================= MEMBER FUNCTIONS ==========================================
    30 // ================= MEMBER FUNCTIONS ==========================================
    31 // -----------------------------------------------------------------------------
    31 // -----------------------------------------------------------------------------
    55 // CFSMailBox::CFSMailBox
    55 // CFSMailBox::CFSMailBox
    56 // -----------------------------------------------------------------------------
    56 // -----------------------------------------------------------------------------
    57 CFSMailBox::CFSMailBox()
    57 CFSMailBox::CFSMailBox()
    58 {
    58 {
    59     FUNC_LOG;
    59     FUNC_LOG;
    60 	// get requesthandler pointer
    60     // get requesthandler pointer
    61 	iRequestHandler = static_cast<CFSMailRequestHandler*>(Dll::Tls());
    61     iRequestHandler = static_cast<CFSMailRequestHandler*>(Dll::Tls());
    62 }
    62 }
    63 
    63 
    64 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    65 // CFSMailBox::~CFSMailBox
    65 // CFSMailBox::~CFSMailBox
    66 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
    67 EXPORT_C CFSMailBox::~CFSMailBox()
    67 EXPORT_C CFSMailBox::~CFSMailBox()
    68 {
    68 {
    69     FUNC_LOG;
    69     FUNC_LOG;
    70 	iFolders.ResetAndDestroy();
    70     iFolders.ResetAndDestroy();
    71 }
    71 }
    72 
    72 
    73 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    74 // CFSMailBox::ConstructL
    74 // CFSMailBox::ConstructL
    75 // -----------------------------------------------------------------------------
    75 // -----------------------------------------------------------------------------
    87 // CFSMailBox::GoOnlineL
    87 // CFSMailBox::GoOnlineL
    88 // -----------------------------------------------------------------------------
    88 // -----------------------------------------------------------------------------
    89 EXPORT_C void CFSMailBox::GoOnlineL()
    89 EXPORT_C void CFSMailBox::GoOnlineL()
    90     {
    90     {
    91     FUNC_LOG;
    91     FUNC_LOG;
    92 	
    92     
    93 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
    93     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
    94 		{
    94         {
    95 	    plugin->GoOnlineL( GetId() );
    95         plugin->GoOnlineL( GetId() );
    96 		}
    96         }
    97     }
    97     }
    98 
    98 
    99 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
   100 // CFSMailBox::GoOfflineL
   100 // CFSMailBox::GoOfflineL
   101 // -----------------------------------------------------------------------------
   101 // -----------------------------------------------------------------------------
   102 EXPORT_C void CFSMailBox::GoOfflineL()
   102 EXPORT_C void CFSMailBox::GoOfflineL()
   103     {
   103     {
   104     FUNC_LOG;
   104     FUNC_LOG;
   105     
   105     
   106 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   106     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   107 		{
   107         {
   108 	    plugin->GoOfflineL( GetId() );
   108         plugin->GoOfflineL( GetId() );
   109 		}
   109         }
   110 		
   110         
   111     }
   111     }
   112 
   112 
   113 // -----------------------------------------------------------------------------
   113 // -----------------------------------------------------------------------------
   114 // CFSMailBox::CancelSyncL
   114 // CFSMailBox::CancelSyncL
   115 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   116 EXPORT_C void CFSMailBox::CancelSyncL()
   116 EXPORT_C void CFSMailBox::CancelSyncL()
   117     {
   117     {
   118     FUNC_LOG;
   118     FUNC_LOG;
   119 	
   119     
   120 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   120     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   121 		{
   121         {
   122 	    plugin->CancelSyncL( GetId() );
   122         plugin->CancelSyncL( GetId() );
   123 		}
   123         }
   124     }
   124     }
   125 
   125 
   126 // -----------------------------------------------------------------------------
   126 // -----------------------------------------------------------------------------
   127 // CFSMailBox::GetLastSyncStatusL
   127 // CFSMailBox::GetLastSyncStatusL
   128 // -----------------------------------------------------------------------------
   128 // -----------------------------------------------------------------------------
   129 EXPORT_C TFSProgress CFSMailBox::GetLastSyncStatusL()
   129 EXPORT_C TFSProgress CFSMailBox::GetLastSyncStatusL()
   130     {
   130     {
   131     FUNC_LOG;
   131     FUNC_LOG;
   132     TFSProgress progress;
   132     TFSProgress progress;
   133 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   133     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   134 		{
   134         {
   135 	    progress = plugin->GetLastSyncStatusL( GetId() );		
   135         progress = plugin->GetLastSyncStatusL( GetId() );       
   136 		}
   136         }
   137 	return progress;
   137     return progress;
   138     }
   138     }
   139 
   139 
   140 // -----------------------------------------------------------------------------
   140 // -----------------------------------------------------------------------------
   141 // CFSMailBox::RefreshNowL
   141 // CFSMailBox::RefreshNowL
   142 // -----------------------------------------------------------------------------
   142 // -----------------------------------------------------------------------------
   143 EXPORT_C TInt CFSMailBox::RefreshNowL(
   143 EXPORT_C TInt CFSMailBox::RefreshNowL(
   144     MFSMailRequestObserver& aOperationObserver )
   144     MFSMailRequestObserver& aOperationObserver )
   145     {
   145     {
   146     FUNC_LOG;
   146     FUNC_LOG;
   147 
   147 
   148 	TFSPendingRequest request;
   148     TFSPendingRequest request;
   149 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   149     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   150 		{
   150         {
   151 		// init asynchronous request
   151         // init asynchronous request
   152     	request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
   152         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
   153     													aOperationObserver );
   153                                                         aOperationObserver );
   154     	MFSMailRequestObserver* observer = request.iObserver;
   154         MFSMailRequestObserver* observer = request.iObserver;
   155     	TRAPD(err,plugin->RefreshNowL( GetId(), *observer, request.iRequestId));
   155         TRAPD(err,plugin->RefreshNowL( GetId(), *observer, request.iRequestId));
   156     	if(err != KErrNone)
   156         if(err != KErrNone)
   157 			{
   157             {
   158 			iRequestHandler->CompleteRequest(request.iRequestId);
   158             iRequestHandler->CompleteRequest(request.iRequestId);
   159 			User::Leave(err);
   159             User::Leave(err);
   160 			}
   160             }
   161 		}
   161         }
   162  	return request.iRequestId;
   162     return request.iRequestId;
   163 
   163 
   164    }
   164    }
   165 
   165 
   166 // -----------------------------------------------------------------------------
   166 // -----------------------------------------------------------------------------
   167 // CFSMailBox::RefreshNowL
   167 // CFSMailBox::RefreshNowL
   168 // -----------------------------------------------------------------------------
   168 // -----------------------------------------------------------------------------
   169 EXPORT_C TInt CFSMailBox::RefreshNowL( )
   169 EXPORT_C TInt CFSMailBox::RefreshNowL( )
   170     {
   170     {
   171     FUNC_LOG;
   171     FUNC_LOG;
   172 
   172 
   173 	TFSPendingRequest request;
   173     TFSPendingRequest request;
   174     MFSMailRequestObserver* observer = NULL;
   174     MFSMailRequestObserver* observer = NULL;
   175    	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   175     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   176 		{
   176         {
   177 		// init asynchronous request
   177         // init asynchronous request
   178         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(), *observer );
   178         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(), *observer );
   179     	
   179         
   180     	observer = request.iObserver;
   180         observer = request.iObserver;
   181     	TRAPD(err,plugin->RefreshNowL( GetId(), *observer, request.iRequestId));
   181         TRAPD(err,plugin->RefreshNowL( GetId(), *observer, request.iRequestId));
   182     	if(err != KErrNone)
   182         if(err != KErrNone)
   183 			{
   183             {
   184 			iRequestHandler->CompleteRequest(request.iRequestId);
   184             iRequestHandler->CompleteRequest(request.iRequestId);
   185 			User::Leave(err);
   185             User::Leave(err);
   186 			}
   186             }
   187 		}
   187         }
   188  	return request.iRequestId;
   188     return request.iRequestId;
   189 
   189 
   190    }
   190    }
   191 
   191 
   192 // -----------------------------------------------------------------------------
   192 // -----------------------------------------------------------------------------
   193 // CFSMailBox::CreateMessageToSend
   193 // CFSMailBox::CreateMessageToSend
   194 // -----------------------------------------------------------------------------
   194 // -----------------------------------------------------------------------------
   195 EXPORT_C CFSMailMessage* CFSMailBox::CreateMessageToSend( )
   195 EXPORT_C CFSMailMessage* CFSMailBox::CreateMessageToSend( )
   196 {
   196 {
   197     FUNC_LOG;
   197     FUNC_LOG;
   198 
   198 
   199 	CFSMailMessage* message = NULL;
   199     CFSMailMessage* message = NULL;
   200 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   200     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   201 		{
   201         {
   202 		TRAPD(err,message = plugin->CreateMessageToSendL( GetId() ));
   202         TRAPD(err,message = plugin->CreateMessageToSendL( GetId() ));
   203 		if(err != KErrNone)
   203         if(err != KErrNone)
   204 			{
   204             {
   205 			message = NULL;
   205             message = NULL;
   206 			}
   206             }
   207 		}
   207         }
   208 	return message;
   208     return message;
   209 }
   209 }
   210 
   210 
   211 // -----------------------------------------------------------------------------
   211 // -----------------------------------------------------------------------------
   212 // CFSMailBox::CreateForwardMessage
   212 // CFSMailBox::CreateForwardMessage
   213 // -----------------------------------------------------------------------------
   213 // -----------------------------------------------------------------------------
   214 EXPORT_C CFSMailMessage* CFSMailBox::CreateForwardMessage( 	TFSMailMsgId aOriginalMessageId,
   214 EXPORT_C CFSMailMessage* CFSMailBox::CreateForwardMessage(  TFSMailMsgId aOriginalMessageId,
   215 															const TDesC& aHeaderDescriptor )
   215                                                             const TDesC& aHeaderDescriptor )
   216 {
   216 {
   217     FUNC_LOG;
   217     FUNC_LOG;
   218 	CFSMailMessage* message = NULL;
   218     CFSMailMessage* message = NULL;
   219 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   219     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   220 		{
   220         {
   221 		TRAPD(err,message = plugin->CreateForwardMessageL( GetId(), 
   221         TRAPD(err,message = plugin->CreateForwardMessageL( GetId(), 
   222 																aOriginalMessageId,
   222                                                                 aOriginalMessageId,
   223 																aHeaderDescriptor ));
   223                                                                 aHeaderDescriptor ));
   224 		if(err != KErrNone)
   224         if(err != KErrNone)
   225 			{
   225             {
   226 			message = NULL;
   226             message = NULL;
   227 			}
   227             }
   228 		}
   228         }
   229 	return message;
   229     return message;
   230 }
   230 }
   231 
   231 
   232 // -----------------------------------------------------------------------------
   232 // -----------------------------------------------------------------------------
   233 // CFSMailBox::CreateReplyMessage
   233 // CFSMailBox::CreateReplyMessage
   234 // -----------------------------------------------------------------------------
   234 // -----------------------------------------------------------------------------
   235 EXPORT_C CFSMailMessage* CFSMailBox::CreateReplyMessage( TFSMailMsgId aOriginalMessageId,
   235 EXPORT_C CFSMailMessage* CFSMailBox::CreateReplyMessage( TFSMailMsgId aOriginalMessageId,
   236 														 TBool aReplyToAll,
   236                                                          TBool aReplyToAll,
   237 														 const TDesC& aHeaderDescriptor )
   237                                                          const TDesC& aHeaderDescriptor )
   238 {
   238 {
   239     FUNC_LOG;
   239     FUNC_LOG;
   240 	CFSMailMessage* message = NULL;
   240     CFSMailMessage* message = NULL;
   241 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   241     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   242 		{
   242         {
   243 		TRAPD(err,message = plugin->CreateReplyMessageL( GetId(),
   243         TRAPD(err,message = plugin->CreateReplyMessageL( GetId(),
   244 															aOriginalMessageId,
   244                                                             aOriginalMessageId,
   245 															aReplyToAll,
   245                                                             aReplyToAll,
   246 															aHeaderDescriptor ));
   246                                                             aHeaderDescriptor ));
   247 		if(err != KErrNone)
   247         if(err != KErrNone)
   248 			{
   248             {
   249 			message = NULL;
   249             message = NULL;
   250 			}
   250             }
   251 		}
   251         }
   252 	return message;
   252     return message;
   253 }
   253 }
   254 
   254 
   255 // -----------------------------------------------------------------------------
   255 // -----------------------------------------------------------------------------
   256 // CFSMailBox::GetStandardFolderId
   256 // CFSMailBox::GetStandardFolderId
   257 // -----------------------------------------------------------------------------
   257 // -----------------------------------------------------------------------------
   258 EXPORT_C TFSMailMsgId CFSMailBox::GetStandardFolderId(TFSFolderType aFolderType)
   258 EXPORT_C TFSMailMsgId CFSMailBox::GetStandardFolderId(TFSFolderType aFolderType)
   259 {
   259 {
   260     FUNC_LOG;
   260     FUNC_LOG;
   261 
   261 
   262 	TFSMailMsgId folderId;
   262     TFSMailMsgId folderId;
   263 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   263     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   264 		{
   264         {
   265 		TRAPD(err, folderId = plugin->GetStandardFolderIdL(GetId(), aFolderType ));
   265         TRAPD(err, folderId = plugin->GetStandardFolderIdL(GetId(), aFolderType ));
   266 		if(err != KErrNone)
   266         if(err != KErrNone)
   267 			{
   267             {
   268 			folderId.SetNullId();
   268             folderId.SetNullId();
   269 			}
   269             }
   270 		}
   270         }
   271 	return folderId;
   271     return folderId;
   272 }
   272 }
   273 
   273 
   274 // -----------------------------------------------------------------------------
   274 // -----------------------------------------------------------------------------
   275 // CFSMailBox::SendMessageL
   275 // CFSMailBox::SendMessageL
   276 // -----------------------------------------------------------------------------
   276 // -----------------------------------------------------------------------------
   277 EXPORT_C void CFSMailBox::SendMessageL( CFSMailMessage& aMessage )
   277 EXPORT_C void CFSMailBox::SendMessageL( CFSMailMessage& aMessage )
   278     {
   278     {
   279     FUNC_LOG;
   279     FUNC_LOG;
   280 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   280     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   281 		{
   281         {
   282 		UpdateMrusL( aMessage.GetToRecipients(),
   282         UpdateMrusL( aMessage.GetToRecipients(),
   283 		           	 aMessage.GetCCRecipients(),
   283                      aMessage.GetCCRecipients(),
   284 		        	 aMessage.GetBCCRecipients() );
   284                      aMessage.GetBCCRecipients() );
   285 		plugin->SendMessageL( aMessage );
   285         plugin->SendMessageL( aMessage );
   286 		
   286         
   287 		}
   287         }
   288     }
   288     }
   289 
   289 
   290 // -----------------------------------------------------------------------------
   290 // -----------------------------------------------------------------------------
   291 // CFSMailBox::ListFolders
   291 // CFSMailBox::ListFolders
   292 // -----------------------------------------------------------------------------
   292 // -----------------------------------------------------------------------------
   293 EXPORT_C void CFSMailBox::ListFolders( 	TFSMailMsgId aFolder,
   293 EXPORT_C void CFSMailBox::ListFolders(  TFSMailMsgId aFolder,
   294 										RPointerArray<CFSMailFolder>& aFolderList)
   294                                         RPointerArray<CFSMailFolder>& aFolderList)
   295 {
   295 {
   296     FUNC_LOG;
   296     FUNC_LOG;
   297 
   297 
   298 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   298     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   299 	{
   299     {
   300 		TRAPD(err, plugin->ListFoldersL(GetId(),aFolder,aFolderList));
   300         TRAPD(err, plugin->ListFoldersL(GetId(),aFolder,aFolderList));
   301 		if(err != KErrNone)
   301         if(err != KErrNone)
   302 			{
   302             {
   303 			aFolderList.ResetAndDestroy();
   303             aFolderList.ResetAndDestroy();
   304 			}
   304             }
   305 	}
   305     }
   306 }
   306 }
   307 
   307 
   308 // -----------------------------------------------------------------------------
   308 // -----------------------------------------------------------------------------
   309 // CFSMailBox::ListFolders
   309 // CFSMailBox::ListFolders
   310 // -----------------------------------------------------------------------------
   310 // -----------------------------------------------------------------------------
   311 EXPORT_C RPointerArray<CFSMailFolder>& CFSMailBox::ListFolders( )
   311 EXPORT_C RPointerArray<CFSMailFolder>& CFSMailBox::ListFolders( )
   312 {	
   312 {   
   313 	iFolders.ResetAndDestroy();
   313     iFolders.ResetAndDestroy();
   314 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   314     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   315 	{
   315     {
   316 		TRAPD(err,plugin->ListFoldersL(GetId(),iFolders));
   316         TRAPD(err,plugin->ListFoldersL(GetId(),iFolders));
   317 		if(err != KErrNone)
   317         if(err != KErrNone)
   318 			{
   318             {
   319 			iFolders.ResetAndDestroy();
   319             iFolders.ResetAndDestroy();
   320 			}
   320             }
   321 	}
   321     }
   322 
   322 
   323 	return iFolders;
   323     return iFolders;
   324 }
   324 }
   325 
   325 
   326 // -----------------------------------------------------------------------------
   326 // -----------------------------------------------------------------------------
   327 // CFSMailBox::GetBrandingIdL
   327 // CFSMailBox::GetBrandingIdL
   328 // -----------------------------------------------------------------------------
   328 // -----------------------------------------------------------------------------
   329 EXPORT_C TDesC& CFSMailBox::GetBrandingIdL( )
   329 EXPORT_C TDesC& CFSMailBox::GetBrandingIdL( )
   330 {
   330 {
   331     FUNC_LOG;
   331     FUNC_LOG;
   332 	return BrandingId();
   332     return BrandingId();
   333 }
   333 }
   334 
   334 
   335 // -----------------------------------------------------------------------------
   335 // -----------------------------------------------------------------------------
   336 // CFSMailBox::MoveMessagesL
   336 // CFSMailBox::MoveMessagesL
   337 // -----------------------------------------------------------------------------
   337 // -----------------------------------------------------------------------------
   338 EXPORT_C void CFSMailBox::MoveMessagesL( const RArray<TFSMailMsgId>& aMessageIds, 
   338 EXPORT_C void CFSMailBox::MoveMessagesL( const RArray<TFSMailMsgId>& aMessageIds, 
   339                             			 const TFSMailMsgId aSourceFolderId, 
   339                                          const TFSMailMsgId aSourceFolderId, 
   340                             			 const TFSMailMsgId aDestinationFolderId )
   340                                          const TFSMailMsgId aDestinationFolderId )
   341 {
   341 {
   342     FUNC_LOG;
   342     FUNC_LOG;
   343 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   343     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   344 		{
   344         {
   345 		plugin->MoveMessagesL(GetId(), aMessageIds, aSourceFolderId, aDestinationFolderId);
   345         plugin->MoveMessagesL(GetId(), aMessageIds, aSourceFolderId, aDestinationFolderId);
   346 		}
   346         }
   347 }
   347 }
   348 
   348 
   349 // -----------------------------------------------------------------------------
   349 // -----------------------------------------------------------------------------
   350 // CFSMailBox::MoveMessagesL
   350 // CFSMailBox::MoveMessagesL
   351 // -----------------------------------------------------------------------------
   351 // -----------------------------------------------------------------------------
   352 EXPORT_C TInt CFSMailBox::MoveMessagesL( MFSMailRequestObserver& aOperationObserver,
   352 EXPORT_C TInt CFSMailBox::MoveMessagesL( MFSMailRequestObserver& aOperationObserver,
   353                                          const RArray<TFSMailMsgId>& aMessageIds, 
   353                                          const RArray<TFSMailMsgId>& aMessageIds, 
   354                             			 const TFSMailMsgId aSourceFolderId, 
   354                                          const TFSMailMsgId aSourceFolderId, 
   355                             			 const TFSMailMsgId aDestinationFolderId )
   355                                          const TFSMailMsgId aDestinationFolderId )
   356 {
   356 {
   357     FUNC_LOG;
   357     FUNC_LOG;
   358     TFSPendingRequest request;
   358     TFSPendingRequest request;
   359 	if( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   359     if( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   360 		{
   360         {
   361 		// init asynchronous request
   361         // init asynchronous request
   362     	request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
   362         request = iRequestHandler->InitAsyncRequestL( GetId().PluginId(),
   363     													aOperationObserver );        
   363                                                         aOperationObserver );        
   364         
   364         
   365 		plugin->MoveMessagesL(
   365         plugin->MoveMessagesL(
   366 		    GetId(), 
   366             GetId(), 
   367 		    aMessageIds, 
   367             aMessageIds, 
   368 		    aSourceFolderId, 
   368             aSourceFolderId, 
   369 		    aDestinationFolderId, 
   369             aDestinationFolderId, 
   370 		    aOperationObserver, 
   370             aOperationObserver, 
   371 		    request.iRequestId );
   371             request.iRequestId );
   372 		}
   372         }
   373     return request.iRequestId;
   373     return request.iRequestId;
   374 }
   374 }
   375 
   375 
   376 // -----------------------------------------------------------------------------
   376 // -----------------------------------------------------------------------------
   377 // CFSMailBox::CopyMessagesL
   377 // CFSMailBox::CopyMessagesL
   378 // -----------------------------------------------------------------------------
   378 // -----------------------------------------------------------------------------
   379 EXPORT_C void CFSMailBox::CopyMessagesL( const RArray<TFSMailMsgId>& aMessageIds, 
   379 EXPORT_C void CFSMailBox::CopyMessagesL( const RArray<TFSMailMsgId>& aMessageIds, 
   380  										 RArray<TFSMailMsgId>& aNewMessages, 
   380                                          RArray<TFSMailMsgId>& aNewMessages, 
   381                                      	 const TFSMailMsgId aSourceFolderId, 
   381                                          const TFSMailMsgId aSourceFolderId, 
   382                                     	 const TFSMailMsgId aDestinationFolderId )
   382                                          const TFSMailMsgId aDestinationFolderId )
   383 {
   383 {
   384     FUNC_LOG;
   384     FUNC_LOG;
   385 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   385     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   386 		{
   386         {
   387 		plugin->CopyMessagesL(GetId(), aMessageIds, aNewMessages,
   387         plugin->CopyMessagesL(GetId(), aMessageIds, aNewMessages,
   388 								aSourceFolderId, aDestinationFolderId );	
   388                                 aSourceFolderId, aDestinationFolderId );    
   389 		}
   389         }
   390 }
   390 }
   391 
   391 
   392 // -----------------------------------------------------------------------------
   392 // -----------------------------------------------------------------------------
   393 // CFSMailBox::SearchL
   393 // CFSMailBox::SearchL
   394 // -----------------------------------------------------------------------------
   394 // -----------------------------------------------------------------------------
   395 EXPORT_C void CFSMailBox::SearchL( const RPointerArray<TDesC>& /*aSearchStrings*/,
   395 EXPORT_C void CFSMailBox::SearchL( const RPointerArray<TDesC>& /*aSearchStrings*/,
   396 								   const TFSMailSortCriteria&  /*aSortCriteria*/,
   396                                    const TFSMailSortCriteria&  /*aSortCriteria*/,
   397 					 			   MFSMailBoxSearchObserver&   /*aSearchObserver*/,
   397                                    MFSMailBoxSearchObserver&   /*aSearchObserver*/,
   398                                    const RArray<TFSMailMsgId>  /*aFolderIds */ )
   398                                    const RArray<TFSMailMsgId>  /*aFolderIds */ )
   399 	{
   399     {
   400     FUNC_LOG;
   400     FUNC_LOG;
   401 
   401 
   402 	}
   402     }
   403 	
   403     
   404 // -----------------------------------------------------------------------------
   404 // -----------------------------------------------------------------------------
   405 // CFSMailBox::SearchL
   405 // CFSMailBox::SearchL
   406 // -----------------------------------------------------------------------------
   406 // -----------------------------------------------------------------------------
   407 EXPORT_C void CFSMailBox::SearchL( const RPointerArray<TDesC>& aSearchStrings,
   407 EXPORT_C void CFSMailBox::SearchL( const RPointerArray<TDesC>& aSearchStrings,
   408 								   const TFSMailSortCriteria& aSortCriteria,
   408                                    const TFSMailSortCriteria& aSortCriteria,
   409 					 			   MFSMailBoxSearchObserver& aSearchObserver )
   409                                    MFSMailBoxSearchObserver& aSearchObserver )
   410 	{
   410     {
   411     FUNC_LOG;
   411     FUNC_LOG;
   412 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   412     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   413 		{
   413         {
   414 
   414 
   415 		// get mailbox folder list
   415         // get mailbox folder list
   416 		iFolders.ResetAndDestroy();
   416         iFolders.ResetAndDestroy();
   417 		plugin->ListFoldersL(GetId(),iFolders);
   417         plugin->ListFoldersL(GetId(),iFolders);
   418 
   418 
   419 		TFSMailMsgId draftsFolderId = GetStandardFolderId( EFSDraftsFolder );
   419         TFSMailMsgId draftsFolderId = GetStandardFolderId( EFSDraftsFolder );
   420 		TFSMailMsgId outboxId = GetStandardFolderId( EFSOutbox );
   420         TFSMailMsgId outboxId = GetStandardFolderId( EFSOutbox );
   421 		
   421         
   422 		// remove outbox, drafts folder from folder list
   422         // remove outbox, drafts folder from folder list
   423 		RArray<TFSMailMsgId> folderIds;
   423         RArray<TFSMailMsgId> folderIds;
   424 		folderIds.Reset();
   424         folderIds.Reset();
   425 		for(TInt i=0;i<iFolders.Count();i++)
   425         for(TInt i=0;i<iFolders.Count();i++)
   426 		{
   426         {
   427 			TFSMailMsgId id = iFolders[i]->GetFolderId();
   427             TFSMailMsgId id = iFolders[i]->GetFolderId();
   428 			if(	id != draftsFolderId && id != outboxId )
   428             if( id != draftsFolderId && id != outboxId )
   429 			{
   429             {
   430 				folderIds.Append(id);
   430                 folderIds.Append(id);
   431 			}
   431             }
   432 		}
   432         }
   433 		
   433         
   434 		// start search
   434         // start search
   435 		plugin->SearchL( GetId(), folderIds, aSearchStrings, aSortCriteria, aSearchObserver );
   435         plugin->SearchL( GetId(), folderIds, aSearchStrings, aSortCriteria, aSearchObserver );
   436 		folderIds.Reset();
   436         folderIds.Reset();
   437 		}
   437         }
   438 	}
   438     }
   439 
   439 
   440 // -----------------------------------------------------------------------------
   440 // -----------------------------------------------------------------------------
   441 // CFSMailBox::CancelSearch
   441 // CFSMailBox::CancelSearch
   442 // -----------------------------------------------------------------------------
   442 // -----------------------------------------------------------------------------
   443 EXPORT_C void CFSMailBox::CancelSearch()
   443 EXPORT_C void CFSMailBox::CancelSearch()
   444 	{
   444     {
   445     FUNC_LOG;
   445     FUNC_LOG;
   446 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   446     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   447 		{
   447         {
   448 		plugin->CancelSearch( GetId() );
   448         plugin->CancelSearch( GetId() );
   449 		}
   449         }
   450 	}
   450     }
   451 
   451 
   452 // -----------------------------------------------------------------------------
   452 // -----------------------------------------------------------------------------
   453 // CFSMailBox::ClearSearchResultCache
   453 // CFSMailBox::ClearSearchResultCache
   454 // -----------------------------------------------------------------------------
   454 // -----------------------------------------------------------------------------
   455 EXPORT_C void CFSMailBox::ClearSearchResultCache()
   455 EXPORT_C void CFSMailBox::ClearSearchResultCache()
   456 	{
   456     {
   457     FUNC_LOG;
   457     FUNC_LOG;
   458 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   458     if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId()))
   459 		{
   459         {
   460 		plugin->ClearSearchResultCache( GetId() );
   460         plugin->ClearSearchResultCache( GetId() );
   461 		}
   461         }
   462 	}
   462     }
   463 
   463 
   464 // -----------------------------------------------------------------------------
   464 // -----------------------------------------------------------------------------
   465 // CFSMailBox::ListMrusL
   465 // CFSMailBox::ListMrusL
   466 // -----------------------------------------------------------------------------
   466 // -----------------------------------------------------------------------------
   467 EXPORT_C MDesCArray* CFSMailBox::ListMrusL() const
   467 EXPORT_C MDesCArray* CFSMailBox::ListMrusL() const
   468 	{
   468     {
   469     FUNC_LOG;
   469     FUNC_LOG;
   470 	MDesCArray* mruList(0);
   470     MDesCArray* mruList(0);
   471 	if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   471     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   472 		{
   472         {
   473    		mruList = plugin->GetMrusL( GetId() );
   473         mruList = plugin->GetMrusL( GetId() );
   474 		}
   474         }
   475 	return mruList;
   475     return mruList;
   476 	}
   476     }
   477 
   477 
   478 
   478 
   479 // -----------------------------------------------------------------------------
   479 // -----------------------------------------------------------------------------
   480 // CFSMailBox::CurrentSyncState
   480 // CFSMailBox::CurrentSyncState
   481 // -----------------------------------------------------------------------------
   481 // -----------------------------------------------------------------------------
   482 EXPORT_C TSSMailSyncState CFSMailBox::CurrentSyncState() const
   482 EXPORT_C TSSMailSyncState CFSMailBox::CurrentSyncState() const
   483 	{
   483     {
   484     FUNC_LOG;
   484     FUNC_LOG;
   485 	TSSMailSyncState syncState(Idle);
   485     TSSMailSyncState syncState(Idle);
   486 	if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   486     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   487 		{
   487         {
   488 		syncState = plugin->CurrentSyncState( GetId() );
   488         syncState = plugin->CurrentSyncState( GetId() );
   489 		}
   489         }
   490 	return syncState;
   490     return syncState;
   491 	}
   491     }
   492 
   492 
   493 // -----------------------------------------------------------------------------
   493 // -----------------------------------------------------------------------------
   494 // CFSMailBox::HasCapability
   494 // CFSMailBox::HasCapability
   495 // -----------------------------------------------------------------------------
   495 // -----------------------------------------------------------------------------
   496 EXPORT_C TBool CFSMailBox::HasCapability( const TFSMailBoxCapabilities aCapability ) const
   496 EXPORT_C TBool CFSMailBox::HasCapability( const TFSMailBoxCapabilities aCapability ) const
   497 {
   497 {
   498     FUNC_LOG;
   498     FUNC_LOG;
   499 	TBool capability = EFalse;
   499     TBool capability = EFalse;
   500 	if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   500     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetId() ) )
   501 		{
   501         {
   502 		TRAPD( err,capability = plugin->MailboxHasCapabilityL( aCapability,GetId() )) ;
   502         TRAPD( err,capability = plugin->MailboxHasCapabilityL( aCapability,GetId() )) ;
   503 		if ( err != KErrNone )
   503         if ( err != KErrNone )
   504 			{
   504             {
   505 			capability = EFalse;
   505             capability = EFalse;
   506 			}
   506             }
   507 		}
   507         }
   508 	return capability;
   508     return capability;
   509 }
   509 }
   510 
   510 
   511 // -----------------------------------------------------------------------------
   511 // -----------------------------------------------------------------------------
   512 // CFSMailBox::GetMailBoxStatus
   512 // CFSMailBox::GetMailBoxStatus
   513 // -----------------------------------------------------------------------------
   513 // -----------------------------------------------------------------------------
   514 EXPORT_C TFSMailBoxStatus CFSMailBox::GetMailBoxStatus()
   514 EXPORT_C TFSMailBoxStatus CFSMailBox::GetMailBoxStatus()
   515 {
   515 {
   516     FUNC_LOG;
   516     FUNC_LOG;
   517 	TFSMailBoxStatus status(EFSMailBoxOffline);
   517     TFSMailBoxStatus status(EFSMailBoxOffline);
   518 	if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   518     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   519 	{
   519     {
   520 		status = plugin->GetMailBoxStatus( GetId() );
   520         status = plugin->GetMailBoxStatus( GetId() );
   521 	}
   521     }
   522 	return status;
   522     return status;
   523 }
   523 }
   524 
   524 
   525 // -----------------------------------------------------------------------------
   525 // -----------------------------------------------------------------------------
   526 // CFSMailBox::SetCredentialsL
   526 // CFSMailBox::SetCredentialsL
   527 // -----------------------------------------------------------------------------
   527 // -----------------------------------------------------------------------------
   528 EXPORT_C void CFSMailBox::SetCredentialsL( const TDesC& aUsername, const TDesC& aPassword )
   528 EXPORT_C void CFSMailBox::SetCredentialsL( const TDesC& aUsername, const TDesC& aPassword )
   529     {
   529     {
   530     FUNC_LOG;
   530     FUNC_LOG;
   531 	if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   531     if ( CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId() ) )
   532 		{
   532         {
   533 	    plugin->SetCredentialsL( GetId(), aUsername, aPassword );
   533         plugin->SetCredentialsL( GetId(), aUsername, aPassword );
   534 		}
   534         }
   535     }
   535     }
   536 
   536 
   537 // -----------------------------------------------------------------------------
   537 // -----------------------------------------------------------------------------
   538 // CFSMailBox::RemoveDownLoadedAttachmentsL
   538 // CFSMailBox::RemoveDownLoadedAttachmentsL
   539 // -----------------------------------------------------------------------------
   539 // -----------------------------------------------------------------------------
   609     
   609     
   610     // First lets make a copy of the current mru list
   610     // First lets make a copy of the current mru list
   611     // whose content we can later alter as we wish
   611     // whose content we can later alter as we wish
   612     MDesCArray* currentMruList( NULL );
   612     MDesCArray* currentMruList( NULL );
   613 
   613 
   614 	CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId());
   614     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetId());
   615     if ( !plugin )
   615     if ( !plugin )
   616         {
   616         {
   617         User::Leave( KErrGeneral );
   617         User::Leave( KErrGeneral );
   618         }
   618         }
   619     currentMruList = plugin->GetMrusL( GetId() );
   619     currentMruList = plugin->GetMrusL( GetId() );