emailservices/emailcommon/src/CFSMailFolder.cpp
changeset 43 99bcbff212ad
parent 20 ecc8def7944a
child 51 d845db10c0d4
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
    13 *
    13 *
    14 * Description:  common email folder object
    14 * Description:  common email folder object
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 #include "emailtrace.h"
       
    19 
    18 // <qmail>
    20 // <qmail>
    19 #include <nmcommonheaders.h>
    21 #include <nmcommonheaders.h>
    20 // </qmail>
    22 // </qmail>
    21 
    23 
    22 //<cmail>
    24 //<cmail>
    23 #include "emailtrace.h"
       
    24 #include "CFSMailFolder.h"
    25 #include "CFSMailFolder.h"
    25 #include "CFSMailPlugin.h"
    26 #include "CFSMailPlugin.h"
    26 //</cmail>
    27 //</cmail>
    27 
    28 
    28 #include "CFSMailIterator.h"
    29 #include "CFSMailIterator.h"
    32 // -----------------------------------------------------------------------------
    33 // -----------------------------------------------------------------------------
    33 // CFSMailFolder::NewLC
    34 // CFSMailFolder::NewLC
    34 // -----------------------------------------------------------------------------
    35 // -----------------------------------------------------------------------------
    35 EXPORT_C CFSMailFolder* CFSMailFolder::NewLC( TFSMailMsgId aFolderId )
    36 EXPORT_C CFSMailFolder* CFSMailFolder::NewLC( TFSMailMsgId aFolderId )
    36 {
    37 {
    37     FUNC_LOG;
    38     NM_FUNCTION;
    38   CFSMailFolder* api = new (ELeave) CFSMailFolder();
    39     
    39   CleanupStack:: PushL(api);
    40     CFSMailFolder* api = new (ELeave) CFSMailFolder();
    40   api->ConstructL( aFolderId );
    41     CleanupStack:: PushL(api);
    41   return api;
    42     api->ConstructL( aFolderId );
       
    43     return api;
    42 } 
    44 } 
    43 
    45 
    44 // -----------------------------------------------------------------------------
    46 // -----------------------------------------------------------------------------
    45 // CFSMailFolder::NewL
    47 // CFSMailFolder::NewL
    46 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    47 EXPORT_C CFSMailFolder* CFSMailFolder::NewL( TFSMailMsgId aFolderId )
    49 EXPORT_C CFSMailFolder* CFSMailFolder::NewL( TFSMailMsgId aFolderId )
    48 {
    50 {
    49     FUNC_LOG;
    51     NM_FUNCTION;
    50   CFSMailFolder* api =  CFSMailFolder::NewLC( aFolderId );
    52     
    51   CleanupStack:: Pop(api);
    53     CFSMailFolder* api =  CFSMailFolder::NewLC( aFolderId );
    52   return api;
    54     CleanupStack:: Pop(api);
       
    55     return api;
    53 }
    56 }
    54 
    57 
    55 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
    56 // CFSMailFolder::CFSMailFolder
    59 // CFSMailFolder::CFSMailFolder
    57 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    58 CFSMailFolder::CFSMailFolder()
    61 CFSMailFolder::CFSMailFolder()
    59 {
    62 {
    60     FUNC_LOG;
    63     NM_FUNCTION;
    61 
       
    62 }
    64 }
    63 
    65 
    64 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
    65 // CFSMailFolder::ConstructL
    67 // CFSMailFolder::ConstructL
    66 // -----------------------------------------------------------------------------
    68 // -----------------------------------------------------------------------------
    67 void CFSMailFolder::ConstructL( TFSMailMsgId aFolderId )
    69 void CFSMailFolder::ConstructL( TFSMailMsgId aFolderId )
    68 {
    70 {
    69     FUNC_LOG;
    71     NM_FUNCTION;
       
    72     
    70 // <qmail>
    73 // <qmail>
    71     CFSMailFolderBase::ConstructL( aFolderId );
    74     CFSMailFolderBase::ConstructL( aFolderId );
    72 // </qmail>
    75 // </qmail>
    73     
    76     
    74 	// get requesthandler pointer
    77 	// get requesthandler pointer
    78 // -----------------------------------------------------------------------------
    81 // -----------------------------------------------------------------------------
    79 // CFSMailFolder::~CFSMailFolder
    82 // CFSMailFolder::~CFSMailFolder
    80 // -----------------------------------------------------------------------------
    83 // -----------------------------------------------------------------------------
    81 EXPORT_C CFSMailFolder::~CFSMailFolder()
    84 EXPORT_C CFSMailFolder::~CFSMailFolder()
    82 {
    85 {
    83     FUNC_LOG;
    86     NM_FUNCTION;
    84 
       
    85 }
    87 }
    86 
    88 
    87 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
    88 // CFSMailFolder::ListMessagesL
    90 // CFSMailFolder::ListMessagesL
    89 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
    90 EXPORT_C MFSMailIterator* CFSMailFolder::ListMessagesL( const TFSMailDetails aDetails,
    92 EXPORT_C MFSMailIterator* CFSMailFolder::ListMessagesL( const TFSMailDetails aDetails,
    91         						const RArray<TFSMailSortCriteria>& aSorting)
    93         						const RArray<TFSMailSortCriteria>& aSorting)
    92 {
    94 {
    93     FUNC_LOG;
    95     NM_FUNCTION;
    94 
    96     
    95 	CFSMailIterator* iterator = NULL;
    97 	CFSMailIterator* iterator = NULL;
    96 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
    98 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
    97 		{
    99 		{
    98 		MFSMailIterator* pluginIterator =
   100 		MFSMailIterator* pluginIterator =
    99 		plugin->ListMessagesL(GetMailBoxId(),GetFolderId(),aDetails,aSorting);
   101 		plugin->ListMessagesL(GetMailBoxId(),GetFolderId(),aDetails,aSorting);
   110 // -----------------------------------------------------------------------------
   112 // -----------------------------------------------------------------------------
   111 EXPORT_C TInt CFSMailFolder::FetchMessagesL( 	const RArray<TFSMailMsgId>& aMessageIds,
   113 EXPORT_C TInt CFSMailFolder::FetchMessagesL( 	const RArray<TFSMailMsgId>& aMessageIds,
   112      							 				TFSMailDetails aDetails,
   114      							 				TFSMailDetails aDetails,
   113      							 				MFSMailRequestObserver& aObserver )
   115      							 				MFSMailRequestObserver& aObserver )
   114 	{
   116 	{
   115     FUNC_LOG;
   117     NM_FUNCTION;
       
   118     
   116 	// init asynchronous request
   119 	// init asynchronous request
   117 	CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId());
   120 	CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId());
   118     TFSPendingRequest request = 
   121     TFSPendingRequest request = 
   119     	iRequestHandler->InitAsyncRequestL(	GetFolderId().PluginId(), aObserver );
   122     	iRequestHandler->InitAsyncRequestL(	GetFolderId().PluginId(), aObserver );
   120 
   123 
   148 // -----------------------------------------------------------------------------
   151 // -----------------------------------------------------------------------------
   149 // CFSMailFolder::GetSubFoldersL
   152 // CFSMailFolder::GetSubFoldersL
   150 // -----------------------------------------------------------------------------
   153 // -----------------------------------------------------------------------------
   151 EXPORT_C void CFSMailFolder::GetSubFoldersL(RPointerArray<CFSMailFolder>& aSubFolders)
   154 EXPORT_C void CFSMailFolder::GetSubFoldersL(RPointerArray<CFSMailFolder>& aSubFolders)
   152 {
   155 {
   153     FUNC_LOG;
   156     NM_FUNCTION;
       
   157     
   154 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
   158 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
   155 		{
   159 		{
   156 		TRAPD(err,plugin->ListFoldersL( GetMailBoxId(), GetFolderId(), aSubFolders));
   160 		TRAPD(err,plugin->ListFoldersL( GetMailBoxId(), GetFolderId(), aSubFolders));
   157 		if(err != KErrNone)
   161 		if(err != KErrNone)
   158 			{
   162 			{
   164 // -----------------------------------------------------------------------------
   168 // -----------------------------------------------------------------------------
   165 // CFSMailFolder::RemoveMessageL
   169 // CFSMailFolder::RemoveMessageL
   166 // -----------------------------------------------------------------------------
   170 // -----------------------------------------------------------------------------
   167 EXPORT_C void CFSMailFolder::RemoveMessageL(TFSMailMsgId aMessage)
   171 EXPORT_C void CFSMailFolder::RemoveMessageL(TFSMailMsgId aMessage)
   168 {
   172 {
   169     FUNC_LOG;
   173     NM_FUNCTION;
       
   174     
   170 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
   175 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
   171 		{
   176 		{
   172 		RArray<TFSMailMsgId> messages;
   177 		RArray<TFSMailMsgId> messages;
   173 		messages.Reset();
   178 		messages.Reset();
   174 		messages.Append(aMessage);
   179 		messages.Append(aMessage);
   175 		plugin->DeleteMessagesByUidL(GetMailBoxId(),GetFolderId(),messages);
   180 		plugin->DeleteMessagesByUidL(GetMailBoxId(),GetFolderId(),messages);
   176 		messages.Close();
   181 		messages.Close();
   177 		}
   182 		}
   178 }
   183 }
   179 
   184 
       
   185 // <qmail>
       
   186 // -----------------------------------------------------------------------------
       
   187 // CFSMailFolder::RemoveMessageL
       
   188 // -----------------------------------------------------------------------------
       
   189 EXPORT_C TInt CFSMailFolder::RemoveMessageL(TFSMailMsgId aMessage,
       
   190                                             MFSMailRequestObserver& aObserver)
       
   191 {
       
   192     NM_FUNCTION;
       
   193 
       
   194     // init asynchronous request
       
   195     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId());
       
   196     TFSPendingRequest request = 
       
   197         iRequestHandler->InitAsyncRequestL( GetFolderId().PluginId(), aObserver );
       
   198 
       
   199     TInt err = KErrNone;
       
   200     
       
   201     if (plugin)
       
   202         {
       
   203         MFSMailRequestObserver* observer = request.iObserver;
       
   204         
       
   205         RArray<TFSMailMsgId> messages;
       
   206         messages.Reset();
       
   207         messages.Append(aMessage);
       
   208         
       
   209         TRAP(err,plugin->DeleteMessagesByUidL(
       
   210             GetMailBoxId(),
       
   211             GetFolderId(),
       
   212             messages,
       
   213             *observer,
       
   214             request.iRequestId));
       
   215         
       
   216         messages.Close();
       
   217         }
       
   218     else 
       
   219         {
       
   220         err = KErrNotFound;        
       
   221         }
       
   222     
       
   223     if(err != KErrNone)
       
   224         {
       
   225         iRequestHandler->CompleteRequest(request.iRequestId);
       
   226         User::Leave(err);
       
   227         }
       
   228     return request.iRequestId;
       
   229 }
       
   230 // </qmail>
       
   231 
   180 // -----------------------------------------------------------------------------
   232 // -----------------------------------------------------------------------------
   181 // CFSMailFolder::SupportsCopyFromL
   233 // CFSMailFolder::SupportsCopyFromL
   182 // -----------------------------------------------------------------------------
   234 // -----------------------------------------------------------------------------
   183 EXPORT_C TBool CFSMailFolder::SupportsCopyFromL( TFSFolderType aFolderType )
   235 EXPORT_C TBool CFSMailFolder::SupportsCopyFromL( TFSFolderType aFolderType )
   184 	{
   236 	{
   185     FUNC_LOG;
   237     NM_FUNCTION;
   186 	
   238     
   187 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
   239 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
   188 		{
   240 		{
   189 		TFSMailBoxStatus onlineStatus = plugin->GetMailBoxStatus(GetMailBoxId());
   241 		TFSMailBoxStatus onlineStatus = plugin->GetMailBoxStatus(GetMailBoxId());
   190 		if(onlineStatus == EFSMailBoxOnline)
   242 		if(onlineStatus == EFSMailBoxOnline)
   191 			{
   243 			{
   214 // -----------------------------------------------------------------------------
   266 // -----------------------------------------------------------------------------
   215 // CFSMailFolder::SupportsMoveFromL
   267 // CFSMailFolder::SupportsMoveFromL
   216 // -----------------------------------------------------------------------------
   268 // -----------------------------------------------------------------------------
   217 EXPORT_C TBool CFSMailFolder::SupportsMoveFromL( TFSFolderType aFolderType )
   269 EXPORT_C TBool CFSMailFolder::SupportsMoveFromL( TFSFolderType aFolderType )
   218 	{
   270 	{
   219     FUNC_LOG;
   271     NM_FUNCTION;
   220 
   272     
   221 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
   273 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId()))
   222 		{
   274 		{
   223 		TFSMailBoxStatus onlineStatus = plugin->GetMailBoxStatus(GetMailBoxId());
   275 		TFSMailBoxStatus onlineStatus = plugin->GetMailBoxStatus(GetMailBoxId());
   224 		if(onlineStatus == EFSMailBoxOnline)
   276 		if(onlineStatus == EFSMailBoxOnline)
   225 			{
   277 			{
   248 // -----------------------------------------------------------------------------
   300 // -----------------------------------------------------------------------------
   249 // CFSMailFolder::RemoveDownLoadedAttachmentsL
   301 // CFSMailFolder::RemoveDownLoadedAttachmentsL
   250 // -----------------------------------------------------------------------------
   302 // -----------------------------------------------------------------------------
   251 EXPORT_C void CFSMailFolder::RemoveDownLoadedAttachmentsL()
   303 EXPORT_C void CFSMailFolder::RemoveDownLoadedAttachmentsL()
   252     {
   304     {
   253     FUNC_LOG;
   305     NM_FUNCTION;
   254     
   306     
   255     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId());
   307     CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetFolderId());
   256     if(plugin != NULL)
   308     if(plugin != NULL)
   257         {
   309         {
   258         MFSMailIterator* iterator = NULL;
   310         MFSMailIterator* iterator = NULL;
   289 // -----------------------------------------------------------------------------
   341 // -----------------------------------------------------------------------------
   290 // CFSMailFolder::ReleaseExtension
   342 // CFSMailFolder::ReleaseExtension
   291 // -----------------------------------------------------------------------------
   343 // -----------------------------------------------------------------------------
   292 EXPORT_C void CFSMailFolder::ReleaseExtension( CEmailExtension* aExtension )
   344 EXPORT_C void CFSMailFolder::ReleaseExtension( CEmailExtension* aExtension )
   293     {
   345     {
   294     FUNC_LOG;
   346     NM_FUNCTION;
       
   347     
   295     // no specialized behaviour, call base class
   348     // no specialized behaviour, call base class
   296     CExtendableEmail::ReleaseExtension( aExtension );
   349     CExtendableEmail::ReleaseExtension( aExtension );
   297     }
   350     }
   298     
   351     
   299 // -----------------------------------------------------------------------------
   352 // -----------------------------------------------------------------------------
   300 // CFSMailFolder::ExtensionL
   353 // CFSMailFolder::ExtensionL
   301 // -----------------------------------------------------------------------------
   354 // -----------------------------------------------------------------------------
   302 EXPORT_C CEmailExtension* CFSMailFolder::ExtensionL( const TUid& aInterfaceUid )
   355 EXPORT_C CEmailExtension* CFSMailFolder::ExtensionL( const TUid& aInterfaceUid )
   303     {
   356     {
   304     FUNC_LOG;
   357     NM_FUNCTION;
       
   358     
   305     return CExtendableEmail::ExtensionL( aInterfaceUid );
   359     return CExtendableEmail::ExtensionL( aInterfaceUid );
   306     }
   360     }
   307 
   361