ipsservices/ipssosplugin/src/ipsplgpop3plugin.cpp
changeset 0 8466d47a6819
child 18 578830873419
child 63 d189ee25cf9d
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: This file implements class CIpsPlgPop3Plugin.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include "ipsplgheaders.h"
       
    21 
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // CIpsPlgPop3Plugin::CIpsPlgPop3Plugin
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CIpsPlgPop3Plugin::CIpsPlgPop3Plugin( ) :
       
    28     CIpsPlgSosBasePlugin( KIpsPlgPop3PluginUidValue )
       
    29     {
       
    30     FUNC_LOG;
       
    31     // none
       
    32     }
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // CIpsPlgPop3Plugin::ConstructL
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 void CIpsPlgPop3Plugin::ConstructL()
       
    39     {
       
    40     FUNC_LOG;
       
    41     BaseConstructL();
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CIpsPlgPop3Plugin::NewL
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C CIpsPlgPop3Plugin* CIpsPlgPop3Plugin::NewL()
       
    49     {
       
    50     FUNC_LOG;
       
    51     CIpsPlgPop3Plugin* self = CIpsPlgPop3Plugin::NewLC();
       
    52     CleanupStack::Pop( self );
       
    53     return self;
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // CIpsPlgPop3Plugin::NewLC
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 EXPORT_C CIpsPlgPop3Plugin* CIpsPlgPop3Plugin::NewLC()
       
    61     {
       
    62     FUNC_LOG;
       
    63     CIpsPlgPop3Plugin* self = new( ELeave ) CIpsPlgPop3Plugin;
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL();
       
    66     return self;
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CIpsPlgPop3Plugin::~CIpsPlgPop3Plugin
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CIpsPlgPop3Plugin::~CIpsPlgPop3Plugin()
       
    74     {
       
    75     FUNC_LOG;
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CIpsPlgPop3Plugin::MailboxHasCapabilityL
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 TBool CIpsPlgPop3Plugin::MailboxHasCapabilityL(
       
    83     TFSMailBoxCapabilities aCapability,
       
    84     TFSMailMsgId /* aMailBoxId */)
       
    85     {
       
    86     FUNC_LOG;
       
    87     TBool result( EFalse );
       
    88 
       
    89     switch ( aCapability )
       
    90         {
       
    91         // These should be clear    
       
    92         case EFSMBoxCapaCanBeDeleted:
       
    93         case EFSMBoxCapaSupportsSaveToDrafts:
       
    94         case EFSMBoxCapaMeetingRequestRespond:
       
    95         case EFSMboxCapaSupportsAttahmentsInMR:
       
    96         case EFSMBoxCapaMeetingRequestCreate:
       
    97         case EFSMBoxCapaCanUpdateMeetingRequest:
       
    98         case EFSMBoxCapaRemoveFromCalendar:    
       
    99             {
       
   100             result = ETrue;
       
   101             break;
       
   102             }
       
   103         // These are positively not supported 
       
   104         case EFSMBoxCapaCreateSubfolder:
       
   105         case EFSMBoxCapaManipulateUserFolders:
       
   106         case EFSMBoxCapaMoveMessageToUserFolder:
       
   107         case EFSMBoxCapaSmartReply:
       
   108         case EFSMBoxCapaSmartForward:
       
   109         case EFSMBoxCapaSupportsMRU:
       
   110         case EFSMBoxCapaSymbianMsgIntegration:
       
   111         case EFSMBoxCapaNewEmailNotifications:
       
   112         case EFSMBoxCapaMoveToFolder:
       
   113         case EFSMBoxCapaCopyToFolder:
       
   114         case EFSMBoxCapaSupportsSync:
       
   115             {
       
   116             result = EFalse;
       
   117             break;
       
   118             }
       
   119         }
       
   120 
       
   121     return result;
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CIpsPlgPop3Plugin::RefreshNowL
       
   126 // ---------------------------------------------------------------------------
       
   127 //  
       
   128 TInt CIpsPlgPop3Plugin::RefreshNowL( )
       
   129     {
       
   130     FUNC_LOG;
       
   131     //we don't need this
       
   132     return KErrNone;
       
   133     }
       
   134 
       
   135 // ----------------------------------------------------------------------------
       
   136 // CIpsPlgPop3Plugin::RefreshNowL
       
   137 // ---------------------------------------------------------------------------- 
       
   138 void CIpsPlgPop3Plugin::RefreshNowL(
       
   139     const TFSMailMsgId& aMailBoxId,
       
   140     MFSMailRequestObserver& aOperationObserver,
       
   141     TInt aRequestId )
       
   142     {
       
   143     FUNC_LOG;
       
   144     TMsvId service = aMailBoxId.Id();
       
   145     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this);
       
   146     CleanupStack::PushL( watcher ); // << watcher
       
   147     
       
   148     TBuf8<1> dummyParams;
       
   149     dummyParams.Zero();
       
   150     CMsvEntrySelection* sel=new(ELeave) CMsvEntrySelection;
       
   151     CleanupStack::PushL( sel ); // << sel
       
   152     
       
   153     sel->AppendL( service );
       
   154 
       
   155     // Get population limit in order to find out if only headers are to be loaded
       
   156     // (i.e. whether to use force-populate or not in connect op)
       
   157     CImPop3Settings* settings = new(ELeave) CImPop3Settings();
       
   158     CleanupStack::PushL( settings );    // << settings
       
   159     TPopAccount popAccountId;
       
   160     CEmailAccounts* accounts = CEmailAccounts::NewLC(); // << accounts
       
   161     accounts->GetPopAccountL( service , popAccountId );
       
   162     accounts->LoadPopSettingsL( popAccountId, *settings );
       
   163     TInt populationLimit( settings->PopulationLimit() );
       
   164     CleanupStack::PopAndDestroy( 2, settings );   // >>> settings, accounts
       
   165     TBool forcePopulate( EFalse );
       
   166     if( populationLimit != KIpsSetDataHeadersOnly )
       
   167         {
       
   168         forcePopulate = ETrue;
       
   169         }
       
   170     
       
   171     CIpsPlgBaseOperation* op = CIpsPlgPop3ConnectOp::NewL( 
       
   172         *iSession, 
       
   173         watcher->iStatus, 
       
   174         service, 
       
   175         forcePopulate,
       
   176         ActivityTimerL( aMailBoxId ),
       
   177         aMailBoxId, 
       
   178         aOperationObserver,
       
   179         aRequestId,
       
   180         iEventHandler );
       
   181     
       
   182     watcher->SetOperation( op );
       
   183     CleanupStack::PopAndDestroy( sel ); // >>> sel
       
   184     
       
   185     iOperations.AppendL( watcher );
       
   186     CleanupStack::Pop( watcher );   // >> watcher
       
   187     
       
   188     // send part
       
   189     EmptyOutboxL( aMailBoxId );
       
   190     }
       
   191 
       
   192 // ---------------------------------------------------------------------------
       
   193 // CIpsPlgPop3Plugin::ListFoldersL
       
   194 // ---------------------------------------------------------------------------
       
   195 //  
       
   196 void CIpsPlgPop3Plugin::ListFoldersL(
       
   197     const TFSMailMsgId& aMailBoxId,
       
   198     const TFSMailMsgId& aFolderId,
       
   199     RPointerArray<CFSMailFolder>& aFolderList)
       
   200     {
       
   201     FUNC_LOG;
       
   202     // Pop3 can return only folders on the root level, so folders are not
       
   203     // listed when the given folder ID is not null ID.
       
   204     if ( aFolderId.IsNullId() )
       
   205         {
       
   206         ListFoldersL( aMailBoxId, aFolderList );
       
   207         }
       
   208     }
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // CIpsPlgPop3Plugin::ListFoldersL
       
   212 // ---------------------------------------------------------------------------
       
   213 //  
       
   214 void CIpsPlgPop3Plugin::ListFoldersL(
       
   215     const TFSMailMsgId& aMailBoxId,
       
   216     RPointerArray<CFSMailFolder>& aFolderList)
       
   217  	{
       
   218     FUNC_LOG;
       
   219  	//list service folder, drafts, inbox, outbox
       
   220  	
       
   221  	//inbox
       
   222  	CFSMailFolder* folder = 
       
   223  	   GetFolderByUidL( aMailBoxId, GetStandardFolderIdL( aMailBoxId, EFSInbox ) );
       
   224  	if( folder )
       
   225  	    {
       
   226  	    // in Pop inbox is same as symbian mailbox, correct type refer to FS Inbox
       
   227  	    folder->SetFolderType( EFSInbox );
       
   228  	    CleanupStack::PushL( folder );
       
   229         aFolderList.AppendL( folder );
       
   230         CleanupStack::Pop( folder );
       
   231  	    }
       
   232 
       
   233     //outbox 	    
       
   234     folder = GetFolderByUidL( aMailBoxId, GetStandardFolderIdL( aMailBoxId, EFSOutbox ) );
       
   235     if( folder )
       
   236  	    {
       
   237  	    CleanupStack::PushL( folder );
       
   238         aFolderList.AppendL( folder );
       
   239         CleanupStack::Pop( folder );
       
   240  	    }
       
   241     
       
   242     //drafts
       
   243     folder = GetFolderByUidL( aMailBoxId, GetStandardFolderIdL( aMailBoxId, EFSDraftsFolder ) );
       
   244     if( folder )
       
   245  	    {
       
   246  	    CleanupStack::PushL( folder );
       
   247         aFolderList.AppendL( folder );
       
   248         CleanupStack::Pop( folder );
       
   249  	    } 	    
       
   250  	    
       
   251     //sent
       
   252     folder = GetFolderByUidL( aMailBoxId, GetStandardFolderIdL( aMailBoxId, EFSSentFolder ) );
       
   253     if( folder )
       
   254  	    {
       
   255  	    CleanupStack::PushL( folder );
       
   256         aFolderList.AppendL( folder );
       
   257         CleanupStack::Pop( folder );
       
   258  	    } 	    
       
   259  	}
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // CIpsPlgPop3Plugin::GetStandardFolderIdL
       
   263 // ---------------------------------------------------------------------------
       
   264 //       
       
   265 TFSMailMsgId CIpsPlgPop3Plugin::GetStandardFolderIdL( 
       
   266     const TFSMailMsgId& aMailBoxId,
       
   267     const TFSFolderType aFolderType )
       
   268  	{
       
   269     FUNC_LOG;
       
   270  	TFSMailMsgId result;
       
   271  	
       
   272  	if( aFolderType==EFSInbox )
       
   273         {
       
   274         //in case of pop3, mailbox id == service id == inbox id
       
   275         CMsvEntry* cEntry = iSession->GetEntryL( aMailBoxId.Id() );
       
   276         CleanupStack::PushL( cEntry );
       
   277         if ( cEntry->Count() != 0 )
       
   278             {
       
   279             result.SetId( aMailBoxId.Id() );
       
   280             }
       
   281         CleanupStack::PopAndDestroy( cEntry );
       
   282         }
       
   283     else if( aFolderType==EFSOutbox )
       
   284         {
       
   285         result.SetId( KMsvGlobalOutBoxIndexEntryId );
       
   286         }
       
   287     else if( aFolderType==EFSDraftsFolder )
       
   288         {
       
   289         result.SetId( KMsvDraftEntryId );
       
   290         }
       
   291     else if( aFolderType==EFSSentFolder )
       
   292         {
       
   293         result.SetId( KMsvSentEntryId );
       
   294         }
       
   295     else if( aFolderType==EFSDeleted )
       
   296         {
       
   297         }
       
   298     else if( aFolderType==EFSOther )
       
   299         {
       
   300         }
       
   301     if ( !result.IsNullId() )
       
   302         {
       
   303         result.SetPluginId( KIpsPlgPop3PluginUid );
       
   304         }
       
   305     
       
   306     return result;        
       
   307  	}
       
   308 
       
   309 // ---------------------------------------------------------------------------
       
   310 // CIpsPlgPop3Plugin::FetchMessagesL
       
   311 // ---------------------------------------------------------------------------
       
   312 //   
       
   313 void CIpsPlgPop3Plugin::FetchMessagesL(
       
   314     const TFSMailMsgId& aMailBoxId,
       
   315     const TFSMailMsgId& /* aFolderId */,
       
   316     const RArray<TFSMailMsgId>& aMessageIds, 
       
   317     TFSMailDetails /* aDetails */,
       
   318     MFSMailRequestObserver& aObserver,
       
   319     TInt aRequestId )
       
   320  	{
       
   321     FUNC_LOG;
       
   322     CIpsPlgSingleOpWatcher* watcher = CIpsPlgSingleOpWatcher::NewL(*this);
       
   323     CleanupStack::PushL( watcher );
       
   324     
       
   325     TBuf8<1> dummyParams;
       
   326     dummyParams.Zero();
       
   327     CMsvEntrySelection* sel=new(ELeave) CMsvEntrySelection;
       
   328     CleanupStack::PushL(sel);
       
   329     
       
   330     TInt count = aMessageIds.Count();
       
   331     for ( TInt i=0; i<count; i++ )
       
   332         {
       
   333         sel->AppendL( aMessageIds[i].Id() );
       
   334         }
       
   335     
       
   336     TImPop3GetMailInfo info;
       
   337     info.iMaxEmailSize = KMaxTInt32;
       
   338     info.iDestinationFolder = aMailBoxId.Id();
       
   339     
       
   340     CIpsPlgBaseOperation* op = CIpsPlgPop3FetchOperation::NewL( 
       
   341         *iSession, 
       
   342         watcher->iStatus,
       
   343         KPOP3MTMCopyMailSelectionWhenAlreadyConnected,
       
   344         aMailBoxId.Id(), 
       
   345         ActivityTimerL( aMailBoxId ), 
       
   346         info, 
       
   347         *sel, 
       
   348         aMailBoxId, 
       
   349         aObserver, 
       
   350         aRequestId,
       
   351         iEventHandler );
       
   352     
       
   353     watcher->SetOperation( op );
       
   354     CleanupStack::PopAndDestroy( sel );
       
   355     CleanupStack::Pop( watcher );
       
   356     
       
   357     iOperations.AppendL( watcher );	
       
   358  	}
       
   359 
       
   360 // ---------------------------------------------------------------------------
       
   361 // CIpsPlgPop3Plugin::FetchMessagesPartsL
       
   362 // ---------------------------------------------------------------------------
       
   363 //  
       
   364 void CIpsPlgPop3Plugin::FetchMessagesPartsL( 
       
   365     const RArray<TFSMailMsgId>& /* aMessagePartIds */,
       
   366     MFSMailRequestObserver& aOperationObserver,
       
   367 	TInt aRequestId)
       
   368  	{
       
   369     FUNC_LOG;
       
   370  	// this not supported atm, framework never calls this function
       
   371  	TFSProgress prog = { TFSProgress::EFSStatus_RequestCancelled, 0, 0, KErrNone };
       
   372  	aOperationObserver.RequestResponseL( prog, aRequestId );
       
   373  	
       
   374  	}
       
   375 
       
   376 // ---------------------------------------------------------------------------
       
   377 // CIpsPlgPop3Plugin::FetchMessagePartsL
       
   378 // ---------------------------------------------------------------------------
       
   379 //
       
   380 void CIpsPlgPop3Plugin::FetchMessagePartsL(
       
   381     const TFSMailMsgId& aMailBoxId,
       
   382     const TFSMailMsgId& aFolderId,
       
   383     const TFSMailMsgId& aMessageId,
       
   384     const RArray<TFSMailMsgId>& /* aMessagePartIds */,
       
   385     MFSMailRequestObserver& aOperationObserver,
       
   386     const TInt aRequestId,
       
   387     const TUint /* aPreferredByteCount */)
       
   388     {
       
   389     FUNC_LOG;
       
   390     // with pop no sense to fetch parts separately, instead fetch 
       
   391     // whole message id is just set some value FetchMessageL not use it
       
   392     RArray<TFSMailMsgId> msgId(1);
       
   393     msgId.AppendL( aMessageId );
       
   394     FetchMessagesL(
       
   395         aMailBoxId,
       
   396         aFolderId,
       
   397         msgId, 
       
   398         EFSMsgDataIdOnly,
       
   399         aOperationObserver,
       
   400         aRequestId );
       
   401     msgId.Close();
       
   402     }
       
   403 
       
   404 // ---------------------------------------------------------------------------
       
   405 // CIpsPlgPop3Plugin::HandleOpCompletedL
       
   406 // ---------------------------------------------------------------------------
       
   407 //
       
   408 void CIpsPlgPop3Plugin::HandleOpCompletedL(
       
   409     CIpsPlgSingleOpWatcher& /*aOpWatcher*/,
       
   410     TInt /*aCompletionCode*/ )
       
   411     {
       
   412 
       
   413     }
       
   414 
       
   415 // ---------------------------------------------------------------------------
       
   416 // CIpsPlgPop3Plugin::PopulateNewMailL
       
   417 // ---------------------------------------------------------------------------
       
   418 //
       
   419 void CIpsPlgPop3Plugin::PopulateNewMailL( 
       
   420     const TFSMailMsgId& /* aMailboxId */, 
       
   421     TMsvId /* aNewId */, 
       
   422     TMsvId /* aParentId */ )
       
   423     {
       
   424     // do nothing
       
   425     }
       
   426 
       
   427 // End of File
       
   428