email/imum/Mtms/Src/Pop3MtmUi.cpp
changeset 79 2981cb3aa489
parent 0 72b543305e3a
equal deleted inserted replaced
25:84d9eb65b26f 79:2981cb3aa489
       
     1 /*
       
     2 * Copyright (c) 2006 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: 
       
    15 *       POP3 MTM UI
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // Standard includes
       
    21 #include <txtrich.h>                        // CRichText
       
    22 #include <apacmdln.h>                       // CApaCommandLine
       
    23 #include <apgcli.h>
       
    24 #include <apaid.h>
       
    25 #include <eikdialg.h>                       // CEikDialog
       
    26 #include <eikon.hrh>
       
    27 #include <eikenv.h>                         // CEikonEnv
       
    28 #include <eikrutil.h>                       // EikResourceUtils
       
    29 #include <aknlistquerydialog.h>
       
    30 #include <aknPopupHeadingPane.h>            // CAknPopupHeadingPane
       
    31 #include <ErrorUI.h>                        // CErrorUI
       
    32 #include <StringLoader.h>
       
    33 #include <etel.h>                           // KErrEtelBusyDetected
       
    34 #include <bldvariant.hrh>
       
    35 #include <etelpckt.h>
       
    36 
       
    37 // Messaging includes
       
    38 #include <mtclreg.h>
       
    39 #include <mtuireg.h>
       
    40 #include <mtmuidef.hrh>
       
    41 #include <pops.h>
       
    42 #include <pop3set.h>
       
    43 #include <smtpset.h>
       
    44 #include <miutset.h>
       
    45 #include <MuiuMsvProgressReporterOperation.h>
       
    46 #include <avkon.mbg>                        // bitmaps for progress
       
    47 #include <MuiuOperationWait.h>
       
    48 
       
    49 // Specific includes
       
    50 #include "ImumPanic.h"
       
    51 #include <imum.rsg>
       
    52 #include "Pop3MtmUi.h"
       
    53 #include <mtmdef.h>
       
    54 #include <msvids.h>
       
    55 #include "PROGTYPE.H"
       
    56 #include "MsvEmailConnectionProgressProvider.h"
       
    57 #include "EmailUtils.H"
       
    58 #include "EmailFeatureUtils.h"
       
    59 #include <muiuflagger.h>                    // CMuiuFlags
       
    60 #include "ImumDisconnectOperation.h"
       
    61 #include "ImumEditOperation.h"
       
    62 #include "ImumFetchAndEditOperation.h"
       
    63 #include <MTMStore.h>
       
    64 #include "ImumOnlineOperation.h"
       
    65 #include "ImumDeleteMessagesLocally.h"
       
    66 #include "ImumDeleteMessagesFromServer.h"
       
    67 #include "MsvPop3ConnectOp.h"
       
    68 #include "MsvPop3FetchOperation.h"
       
    69 #include "MsvPop3CopyMoveOperation.h"
       
    70 #include <MtmExtendedCapabilities.hrh>
       
    71 #include <Muiumsginfo.h>
       
    72 #include <Muiumsginfo.hrh>
       
    73 #include "EmailEditorViewerUids.h"
       
    74 #include <aknnotewrappers.h>                // CAknNoteDialog
       
    75 #include "IMSSettingsNoteUi.h"
       
    76 #include <ImumInternalApi.h>        // CImumInternalApi
       
    77 #include <ImumInHealthServices.h>
       
    78 #include "ImumMtmLogging.h"
       
    79 #include "ImumListQueryDialog.h"
       
    80 
       
    81 // prevents warning with TRefByValue in WINS REL
       
    82 #pragma warning (disable : 4710)	// CSI: 47 # Needed for disable warning.
       
    83 
       
    84 // Constants
       
    85 const TInt KPop3MtmUiDeleteMessagesLocally = 0;
       
    86 const TInt KImumEntriesDoneReplaceIndex = 0;
       
    87 const TInt KImumTotalEntriesReplaceIndex = 1;
       
    88 // Convenience function IDs for FetchL().
       
    89 const TInt KFunctionIdFetchSelected = KPOP3MTMCopyMailSelectionWhenAlreadyConnected;
       
    90 const TInt KFunctionIdFetchAll = KPOP3MTMCopyAllMailWhenAlreadyConnected;
       
    91 const TInt KFunctionIdFetchNew = KPOP3MTMCopyNewMailWhenAlreadyConnected;
       
    92 const TInt KImumMessageInfoDateBufferLength = 30;
       
    93 const TInt KImumMessageInfoSizeBufferLength = 20;
       
    94 const TInt KImumMessagePriorityBufferLength = 32;
       
    95 const TInt KImumMaxCharsInLine = 75;
       
    96 const TInt KImumKB = 1024;
       
    97 const TInt KErrDndNameNotFound = -5120;
       
    98 
       
    99 // Defines
       
   100 _LIT( KPop3uMtmUiResourceFile, "imum.rsc" );
       
   101 
       
   102 //////////////////////
       
   103 // Factory function //
       
   104 //////////////////////
       
   105 
       
   106 // ----------------------------------------------------------------------------
       
   107 // NewPP3UMtmUiL()
       
   108 // ----------------------------------------------------------------------------
       
   109 //
       
   110 EXPORT_C CBaseMtmUi* NewPP3UMtmUiL(CBaseMtm& aMtm, CRegisteredMtmDll& aRegisteredDll)
       
   111     {
       
   112     return CPop3MtmUi::NewL(aMtm, aRegisteredDll);
       
   113     }
       
   114 
       
   115 // ----------------------------------------------------------------------------
       
   116 // CPop3MtmUi::NewL()
       
   117 // ----------------------------------------------------------------------------
       
   118 //
       
   119 CPop3MtmUi* CPop3MtmUi::NewL(CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll)
       
   120     {
       
   121     IMUM_STATIC_CONTEXT( CPop3MtmUi::NewL, 0, mtm, KImumMtmLog );
       
   122     IMUM_IN();
       
   123     
       
   124     CPop3MtmUi* self=new(ELeave) CPop3MtmUi(aBaseMtm, aRegisteredMtmDll);
       
   125     CleanupStack::PushL(self);
       
   126     self->ConstructL();
       
   127     CleanupStack::Pop();
       
   128     
       
   129     IMUM_OUT();
       
   130     
       
   131     return self;
       
   132     }
       
   133 
       
   134 // ----------------------------------------------------------------------------
       
   135 // CPop3MtmUi::CPop3MtmUi(()
       
   136 // ----------------------------------------------------------------------------
       
   137 //
       
   138 CPop3MtmUi::CPop3MtmUi(CBaseMtm& aBaseMtm, CRegisteredMtmDll& aRegisteredMtmDll)
       
   139     :
       
   140     CImumMtmBaseMtmUi(aBaseMtm, aRegisteredMtmDll)
       
   141     {
       
   142     IMUM_CONTEXT( CPop3MtmUi::CPop3MtmUi, 0, KImumMtmLog );
       
   143     IMUM_IN();
       
   144     
       
   145     IMUM_OUT();
       
   146     }
       
   147 
       
   148 // ----------------------------------------------------------------------------
       
   149 // CPop3MtmUi::ConstructL()
       
   150 // ----------------------------------------------------------------------------
       
   151 //
       
   152 void CPop3MtmUi::ConstructL()
       
   153     {
       
   154     IMUM_CONTEXT( CPop3MtmUi::ConstructL, 0, KImumMtmLog );
       
   155     IMUM_IN();
       
   156     
       
   157     // --- Make sure base class correctly constructed ---
       
   158     CImumMtmBaseMtmUi::ConstructL();
       
   159     iServerNameCache.iService = KMsvNullIndexEntryId;
       
   160     IMUM_OUT();
       
   161     }
       
   162 
       
   163 // ----------------------------------------------------------------------------
       
   164 // CPop3MtmUi::GetEditorFileNameL()
       
   165 // ----------------------------------------------------------------------------
       
   166 //
       
   167 HBufC* CPop3MtmUi::GetEditorFileNameL()
       
   168     {
       
   169     IMUM_CONTEXT( CPop3MtmUi::GetEditorFileNameL, 0, KImumMtmLog );
       
   170     IMUM_IN();
       
   171     
       
   172     if(!iEditorFilename)
       
   173         {
       
   174         iEditorFilename = MsvUiEditorUtilities::ResolveAppFileNameL(
       
   175             KUidMsgInternetMailEditor);
       
   176         }
       
   177     IMUM_OUT();
       
   178     return iEditorFilename;
       
   179     }
       
   180 
       
   181 // ----------------------------------------------------------------------------
       
   182 // CPop3MtmUi::GetViewerFileNameL()
       
   183 // ----------------------------------------------------------------------------
       
   184 //
       
   185 HBufC* CPop3MtmUi::GetViewerFileNameL()
       
   186     {
       
   187     IMUM_CONTEXT( CPop3MtmUi::GetViewerFileNameL, 0, KImumMtmLog );
       
   188     IMUM_IN();
       
   189     
       
   190     if(!iViewerFilename)
       
   191         {
       
   192         iViewerFilename = MsvUiEditorUtilities::ResolveAppFileNameL(
       
   193             KUidMsgInternetMailViewer);
       
   194         }
       
   195     IMUM_OUT();
       
   196     return iViewerFilename;
       
   197     }
       
   198 
       
   199 // ----------------------------------------------------------------------------
       
   200 // ::~CPop3MtmUi()()
       
   201 // ----------------------------------------------------------------------------
       
   202 //
       
   203 CPop3MtmUi::~CPop3MtmUi()
       
   204     {
       
   205     IMUM_CONTEXT( CPop3MtmUi::~CPop3MtmUi, 0, KImumMtmLog );
       
   206     IMUM_IN();
       
   207     
       
   208     delete iEditorFilename;
       
   209     delete iViewerFilename;
       
   210     IMUM_OUT();
       
   211     }
       
   212 
       
   213 // ----------------------------------------------------------------------------
       
   214 // CPop3MtmUi::CreateL()
       
   215 // ----------------------------------------------------------------------------
       
   216 //
       
   217 CMsvOperation* CPop3MtmUi::CreateL(
       
   218     const TMsvEntry& aEntry,
       
   219     CMsvEntry& aParent,
       
   220     TRequestStatus& aStatus)
       
   221     {
       
   222     IMUM_CONTEXT( CPop3MtmUi::CreateL, 0, KImumMtmLog );
       
   223     IMUM_IN();
       
   224     
       
   225     // Context is irrelevant.
       
   226     aStatus=KRequestPending;
       
   227     // Make sure the entry is a service, since POP3 doesn't support folders
       
   228     // and POP3 messages / attachments are only created by the engine components
       
   229     if (aEntry.iType.iUid!=KUidMsvServiceEntryValue)
       
   230         User::Leave(KErrNotSupported);
       
   231     //
       
   232     // Since services can only be created from the root, make sure the requested parent is root
       
   233     __ASSERT_ALWAYS(aParent.Entry().Id()==KMsvRootIndexEntryId, User::Panic(KImumMtmUiPanic, EPop3MtmUiParentNotRoot));
       
   234     //
       
   235     // Create an SMTP service entry
       
   236     TMsvEntry smtpService(aEntry);
       
   237     smtpService.iMtm=KUidMsgTypeSMTP;
       
   238     smtpService.SetVisible(EFalse);
       
   239     aParent.CreateL(smtpService);
       
   240     IMUM_OUT();
       
   241     //
       
   242     // POP3 MTMUI defers set-up to the SMTP MTMUI, so create an SMTP mtmui and edit a service with it
       
   243     return EditSmtpServiceL(aStatus, smtpService.Id());
       
   244     }
       
   245 
       
   246 // ----------------------------------------------------------------------------
       
   247 // CPop3MtmUi::OpenL()
       
   248 // ----------------------------------------------------------------------------
       
   249 //
       
   250 CMsvOperation* CPop3MtmUi::OpenL(TRequestStatus& aStatus)
       
   251     {
       
   252     IMUM_CONTEXT( CPop3MtmUi::OpenL, 0, KImumMtmLog );
       
   253     IMUM_IN();
       
   254     
       
   255     // Context is the entry to open.
       
   256     const TMsvEntry& contextEntry=BaseMtm().Entry().Entry();
       
   257     CheckEntryL(contextEntry);
       
   258 
       
   259     if(contextEntry.iType.iUid == KUidMsvMessageEntryValue)
       
   260         {
       
   261         IMUM_OUT();
       
   262         return EditL(aStatus);
       
   263         }
       
   264 
       
   265     // Entry is a service.
       
   266     /*Check if partial fetch should be used*/
       
   267     /*
       
   268     const TMsvId serviceId = contextEntry.Id();
       
   269     const CImPop3Settings& settings = GetAccountSettingsL(serviceId);
       
   270     TInt limit = settings.PopulationLimit();
       
   271 
       
   272     TInt functionID = KPOP3MTMConnect;
       
   273     // n lines of message to be fetched. or full message.
       
   274     if( limit == EFullBody || ( limit >= EUserDefinedKB && limit < KMaxTInt32 ) )
       
   275         {
       
   276         functionID = KPOP3MTMPopulateAll;
       
   277         }
       
   278         */
       
   279 
       
   280     TBuf8<1> dummyParams;
       
   281     dummyParams.Zero();
       
   282     CMsvEntrySelection* sel=new(ELeave) CMsvEntrySelection;
       
   283     CleanupStack::PushL(sel);
       
   284     sel->AppendL(contextEntry.Id());
       
   285 
       
   286     CMsvOperation* op = InvokeAsyncFunctionL(
       
   287         KPOP3MTMConnect, *sel, aStatus, dummyParams);
       
   288     CleanupStack::PopAndDestroy();//sel
       
   289     IMUM_OUT();
       
   290     return op;
       
   291     }
       
   292 
       
   293 // ----------------------------------------------------------------------------
       
   294 // CPop3MtmUi::OpenL()
       
   295 // ----------------------------------------------------------------------------
       
   296 //
       
   297 CMsvOperation* CPop3MtmUi::OpenL(
       
   298     TRequestStatus& aStatus,
       
   299     const CMsvEntrySelection& aSelection)
       
   300     {
       
   301     IMUM_CONTEXT( CPop3MtmUi::OpenL, 0, KImumMtmLog );
       
   302     IMUM_IN();
       
   303     
       
   304     // Context is irrelevant.
       
   305     TMsvId selectionParent=KMsvNullIndexEntryId;
       
   306     CheckSelectionL(aSelection, selectionParent);
       
   307     // Edit the message selection
       
   308     IMUM_OUT();
       
   309     return EditL(aStatus, aSelection);
       
   310     }
       
   311 
       
   312 // ----------------------------------------------------------------------------
       
   313 // CPop3MtmUi::CloseL()
       
   314 // ----------------------------------------------------------------------------
       
   315 //
       
   316 CMsvOperation* CPop3MtmUi::CloseL(TRequestStatus& aStatus)
       
   317     {
       
   318     IMUM_CONTEXT( CPop3MtmUi::CloseL, 0, KImumMtmLog );
       
   319     IMUM_IN();
       
   320     
       
   321     // Context is the entry to close.
       
   322     const TMsvEntry& contextEntry=BaseMtm().Entry().Entry();
       
   323     CheckEntryL(contextEntry);
       
   324     // Check that current context is a service, all other entry types
       
   325     // cannot be closed
       
   326     if(contextEntry.iType != KUidMsvServiceEntry)
       
   327         {
       
   328         User::Leave(KErrNotSupported);
       
   329         }
       
   330     // Disconnect the service
       
   331     aStatus=KRequestPending;
       
   332     if(Session().ServiceActive(contextEntry.Id()))
       
   333         {
       
   334         IMUM_OUT();
       
   335         // Service is busy
       
   336         return CMsvCompletedOperation::NewL(
       
   337             Session(),
       
   338             Type(),
       
   339             KNullDesC8,
       
   340             KMsvLocalServiceIndexEntryId,
       
   341             aStatus,
       
   342             KErrNone);// KErrNone because we've reported the fact to the user
       
   343         }
       
   344     CMsvEntrySelection* sel=SingleEntrySelectionLC(contextEntry.Id());
       
   345     TBuf8<1> buf;
       
   346     buf.Zero();
       
   347     CMsvOperation* op=InvokeAsyncFunctionL(KPOP3MTMDisconnect, *sel, aStatus, buf);
       
   348     CleanupStack::PopAndDestroy();//selection
       
   349     IMUM_OUT();
       
   350     return op;
       
   351     }
       
   352 
       
   353 // ----------------------------------------------------------------------------
       
   354 // CPop3MtmUi::CloseL()
       
   355 // ----------------------------------------------------------------------------
       
   356 //
       
   357 CMsvOperation* CPop3MtmUi::CloseL(
       
   358     TRequestStatus& /*aStatus*/,
       
   359     const CMsvEntrySelection& /*aSelection*/)
       
   360     {
       
   361     IMUM_CONTEXT( CPop3MtmUi::CloseL, 0, KImumMtmLog );
       
   362     IMUM_IN();
       
   363     
       
   364     // Multiple close is not supported
       
   365     User::Leave(KErrNotSupported);
       
   366     IMUM_OUT();
       
   367     return NULL;
       
   368     }
       
   369 
       
   370 // ----------------------------------------------------------------------------
       
   371 // CPop3MtmUi::EditL()
       
   372 // ----------------------------------------------------------------------------
       
   373 //
       
   374 CMsvOperation* CPop3MtmUi::EditL(TRequestStatus& aStatus)
       
   375     {
       
   376     IMUM_CONTEXT( CPop3MtmUi::EditL, 0, KImumMtmLog );
       
   377     IMUM_IN();
       
   378     
       
   379     // Context is the entry to edit.
       
   380     const TMsvEntry& contextEntry=BaseMtm().Entry().Entry();
       
   381     CheckEntryL(contextEntry);
       
   382 
       
   383     // Edit service (mailbox)
       
   384     if(contextEntry.iType.iUid==KUidMsvServiceEntryValue)
       
   385         {
       
   386         TMsvEntry mailbox = BaseMtm().Entry().Entry();
       
   387         if ( !iMailboxApi->HealthServicesL().IsMailboxHealthy( mailbox.Id() ) )
       
   388             {
       
   389             User::Leave( KErrNotFound );
       
   390             }    
       
   391         
       
   392         return EditSmtpServiceL(aStatus, mailbox.iRelatedId);
       
   393         }
       
   394     IMUM_OUT();
       
   395     // Edit message
       
   396     return ViewMessageL(aStatus);
       
   397     // POP3 messages are always read only, so actually we are viewing the message.
       
   398     }
       
   399 
       
   400 // ----------------------------------------------------------------------------
       
   401 // CPop3MtmUi::EditL()
       
   402 // ----------------------------------------------------------------------------
       
   403 //
       
   404 CMsvOperation* CPop3MtmUi::EditL(
       
   405     TRequestStatus& aStatus,
       
   406     const CMsvEntrySelection& aSelection)
       
   407     {
       
   408     IMUM_CONTEXT( CPop3MtmUi::EditL, 0, KImumMtmLog );
       
   409     IMUM_IN();
       
   410     
       
   411     // Context is irrelevant.
       
   412     // Only the first message in the selection is editted.
       
   413     __ASSERT_ALWAYS(aSelection.Count(), User::Panic(KImumMtmUiPanic, EPop3MtmUiSelectionIsEmpty));
       
   414     BaseMtm().Entry().SetEntryL(aSelection[0]);
       
   415     IMUM_OUT();
       
   416     return EditL(aStatus);
       
   417     }
       
   418 
       
   419 // ----------------------------------------------------------------------------
       
   420 // CPop3MtmUi::ViewL()
       
   421 // ----------------------------------------------------------------------------
       
   422 //
       
   423 CMsvOperation* CPop3MtmUi::ViewL(TRequestStatus& aStatus)
       
   424     {
       
   425     IMUM_CONTEXT( CPop3MtmUi::ViewL, 0, KImumMtmLog );
       
   426     IMUM_IN();
       
   427     
       
   428     // Context is the message to view.
       
   429     const TMsvEntry& context=BaseMtm().Entry().Entry();
       
   430     CheckEntryL(context);
       
   431 
       
   432     // Can only view message entries
       
   433     if(context.iType.iUid != KUidMsvMessageEntryValue)
       
   434         {
       
   435         User::Leave(KErrNotSupported);
       
   436         }
       
   437     IMUM_OUT();
       
   438 
       
   439     return ViewMessageL(aStatus);
       
   440     }
       
   441 
       
   442 // ----------------------------------------------------------------------------
       
   443 // CPop3MtmUi::ViewL()
       
   444 // ----------------------------------------------------------------------------
       
   445 //
       
   446 CMsvOperation* CPop3MtmUi::ViewL(
       
   447     TRequestStatus& aStatus,
       
   448     const CMsvEntrySelection& aSelection)
       
   449     {
       
   450     IMUM_CONTEXT( CPop3MtmUi::ViewL, 0, KImumMtmLog );
       
   451     IMUM_IN();
       
   452     
       
   453     // Context is irrelevant.
       
   454     // Only the first message in the selection is viewed.
       
   455     __ASSERT_ALWAYS(aSelection.Count(), User::Panic(KImumMtmUiPanic, EPop3MtmUiSelectionIsEmpty));
       
   456     BaseMtm().Entry().SetEntryL(aSelection[0]);
       
   457     IMUM_OUT();
       
   458     return ViewL(aStatus);
       
   459     }
       
   460 
       
   461 // ----------------------------------------------------------------------------
       
   462 // CPop3MtmUi::CancelL()
       
   463 // ----------------------------------------------------------------------------
       
   464 //
       
   465 CMsvOperation* CPop3MtmUi::CancelL(
       
   466     TRequestStatus& /*aStatus*/,
       
   467     const CMsvEntrySelection& /*aSelection*/)
       
   468     {
       
   469     IMUM_CONTEXT( CPop3MtmUi::CancelL, 0, KImumMtmLog );
       
   470     IMUM_IN();
       
   471     
       
   472     // Currently this function only used to suspend messages queued for sending.
       
   473     // Can't send POP3 messages, so can't cancel them either.
       
   474     User::Leave(KErrNotSupported);
       
   475     IMUM_OUT();
       
   476     return NULL;
       
   477     }
       
   478 
       
   479 // ----------------------------------------------------------------------------
       
   480 // CPop3MtmUi::CopyToL()
       
   481 // ----------------------------------------------------------------------------
       
   482 //
       
   483 CMsvOperation* CPop3MtmUi::CopyToL(
       
   484     const CMsvEntrySelection& /*aSelection*/,
       
   485     TRequestStatus& /*aStatus*/)
       
   486     {
       
   487     IMUM_CONTEXT( CPop3MtmUi::CopyToL, 0, KImumMtmLog );
       
   488     IMUM_IN();
       
   489     
       
   490     __ASSERT_DEBUG( EFalse, User::Panic(KImumMtmUiPanic, EPop3MtmUiCannotCopyOrMoveToRemote));
       
   491     User::Leave(KErrNotSupported);
       
   492     IMUM_OUT();
       
   493     return NULL;
       
   494     }
       
   495 
       
   496 // ----------------------------------------------------------------------------
       
   497 // CPop3MtmUi::MoveToL()
       
   498 // ----------------------------------------------------------------------------
       
   499 //
       
   500 CMsvOperation* CPop3MtmUi::MoveToL(
       
   501     const CMsvEntrySelection& /*aSelection*/,
       
   502     TRequestStatus& /*aStatus*/)
       
   503     {
       
   504     IMUM_CONTEXT( CPop3MtmUi::MoveToL, 0, KImumMtmLog );
       
   505     IMUM_IN();
       
   506     
       
   507     __ASSERT_DEBUG( EFalse, User::Panic(KImumMtmUiPanic, EPop3MtmUiCannotCopyOrMoveToRemote));
       
   508     User::Leave(KErrNotSupported);
       
   509     IMUM_OUT();
       
   510     return NULL;
       
   511     }
       
   512 
       
   513 // ----------------------------------------------------------------------------
       
   514 // CPop3MtmUi::CopyFromL()
       
   515 // ----------------------------------------------------------------------------
       
   516 //
       
   517 CMsvOperation* CPop3MtmUi::CopyFromL(
       
   518     const CMsvEntrySelection& /*aSelection*/,
       
   519     TMsvId /*aTargetId*/,
       
   520     TRequestStatus& /*aStatus*/ )
       
   521     {
       
   522     IMUM_CONTEXT( CPop3MtmUi::CopyFromL, 0, KImumMtmLog );
       
   523     IMUM_IN();
       
   524     
       
   525     User::Leave( KErrNotSupported );
       
   526     IMUM_OUT();
       
   527     return NULL;
       
   528     }
       
   529 
       
   530 // ----------------------------------------------------------------------------
       
   531 // CPop3MtmUi::MoveFromL()
       
   532 // ----------------------------------------------------------------------------
       
   533 //
       
   534 CMsvOperation* CPop3MtmUi::MoveFromL(
       
   535     const CMsvEntrySelection& /*aSelection*/,
       
   536     TMsvId /*aTargetId*/,
       
   537     TRequestStatus& /*aStatus*/)
       
   538     {
       
   539     IMUM_CONTEXT( CPop3MtmUi::MoveFromL, 0, KImumMtmLog );
       
   540     IMUM_IN();
       
   541     
       
   542     User::Leave(KErrNotSupported);
       
   543     IMUM_OUT();
       
   544     return NULL;
       
   545     }
       
   546 
       
   547 // ----------------------------------------------------------------------------
       
   548 // ::QueryCapability(()
       
   549 // ----------------------------------------------------------------------------
       
   550 //
       
   551 TInt CPop3MtmUi::QueryCapability(TUid aCapability, TInt& aResponse)
       
   552     {
       
   553     IMUM_CONTEXT( CPop3MtmUi::QueryCapability, 0, KImumMtmLog );
       
   554     IMUM_IN();
       
   555     
       
   556     switch (aCapability.iUid)
       
   557         {
       
   558     case KUidMsvMtmUiQueryConnectionOrientedServices:
       
   559         IMUM_OUT();
       
   560         return KErrNone;
       
   561 
       
   562     default:
       
   563         break;
       
   564         };
       
   565 
       
   566     IMUM_OUT();
       
   567     return CBaseMtmUi::QueryCapability(aCapability, aResponse);
       
   568     }
       
   569 
       
   570 // ----------------------------------------------------------------------------
       
   571 // CPop3MtmUi::InvokeAsyncFunctionL()
       
   572 // ----------------------------------------------------------------------------
       
   573 //
       
   574 CMsvOperation* CPop3MtmUi::InvokeAsyncFunctionL(
       
   575     TInt aFunctionId,
       
   576     const CMsvEntrySelection& aSelection,
       
   577     TRequestStatus& aStatus,
       
   578     TDes8& aParameter )
       
   579     {
       
   580     IMUM_CONTEXT( CPop3MtmUi::InvokeAsyncFunctionL, 0, KImumMtmLog );
       
   581     IMUM_IN();
       
   582     
       
   583     // Context is dependant upon function ID.
       
   584     CMsvOperation* op = NULL;
       
   585 
       
   586     TMsvEntry tEntry;
       
   587     TMsvId service;
       
   588     Session().GetEntry( BaseMtm().Entry().EntryId(), service, tEntry );
       
   589     //Offline checks VARIATION START
       
   590     if( iFeatureFlags->GF( EMailFeatureOfflineMode ) &&
       
   591          aFunctionId != KMtmUiFunctionMessageInfo)
       
   592         {
       
   593         TBool offline = EFalse;
       
   594 
       
   595         TMsvEntry tEntry;
       
   596         TMsvId service;
       
   597         Session().GetEntry( BaseMtm().Entry().EntryId(), service, tEntry );
       
   598         if( !tEntry.Connected() &&
       
   599             !iMailboxApi->MailboxUtilitiesL().HasWlanConnectionL( service ) )            
       
   600             {
       
   601             offline = MsvEmailMtmUiUtils::DoOfflineChecksL( service );
       
   602             }
       
   603 
       
   604         if( offline )
       
   605             {
       
   606             op = CMsvCompletedOperation::NewL(
       
   607                 Session(), Type(), KNullDesC8,
       
   608                 KMsvLocalServiceIndexEntryId, aStatus, KErrCancel );
       
   609             return op;
       
   610             }
       
   611         }//if
       
   612     //VARIATION END
       
   613 
       
   614     switch( aFunctionId )
       
   615         {
       
   616         case KMtmUiFunctionFetchAll:
       
   617             IMUM_OUT();
       
   618             // Client MTM context is service.
       
   619             return FetchL( aStatus, aSelection, KFunctionIdFetchAll );
       
   620 
       
   621         case KMtmUiFunctionFetchNew:
       
   622             IMUM_OUT();
       
   623             // Client MTM context is service.
       
   624             return FetchL( aStatus, aSelection, KFunctionIdFetchNew );
       
   625 
       
   626         case KMtmUiFunctionFetchSelected:
       
   627             {
       
   628             // Client MTM context is service
       
   629             // Check there is something to fetch.
       
   630             CMsvEntrySelection* entries =
       
   631                 MsvEmailMtmUiUtils::StripCompleteEntriesLC(
       
   632                 BaseMtm().Entry(), aSelection );
       
   633             const TInt count = entries->Count();
       
   634             CleanupStack::PopAndDestroy();  // entries
       
   635             if( !count )
       
   636                 {
       
   637                 IMUM_OUT();
       
   638                 // All messages are complete so nothing to do.
       
   639                 return CMsvCompletedOperation::NewL(
       
   640                     Session(),
       
   641                     Type(),
       
   642                     KNullDesC8,
       
   643                     KMsvLocalServiceIndexEntryId,
       
   644                     aStatus,
       
   645                     KErrNone);
       
   646                 }
       
   647             }
       
   648             return FetchL( aStatus, aSelection, KFunctionIdFetchSelected );
       
   649 
       
   650         case KMtmUiFunctionGetNew:
       
   651             IMUM_OUT();
       
   652             // Client MTM context is service.
       
   653             return GetMailL( aStatus );
       
   654 
       
   655         case KPOP3MTMConnect:
       
   656         case KPOP3MTMDisconnect:
       
   657             {
       
   658 
       
   659             const CImPop3Settings& settings = GetAccountSettingsL( service );
       
   660 
       
   661             //get population limit for connect operations
       
   662             TInt limit = settings.PopulationLimit();
       
   663             // -1 means body and attachment, pass it to Symbian mail engine
       
   664             if ( limit != -1 )
       
   665                 {
       
   666                 limit = ( limit * KImumKB ) / KImumMaxCharsInLine;
       
   667                 }
       
   668 
       
   669             // Context is irrelevant.
       
   670             // aSelection[0] is service ID.
       
   671             CMsvProgressReporterOperation* reporter =
       
   672                 CMsvProgressReporterOperation::NewL(
       
   673                     ETrue, ETrue, Session(),
       
   674                     aStatus, EMbmAvkonQgn_note_progress );
       
   675             CleanupStack::PushL( reporter );
       
   676             if( aFunctionId == KPOP3MTMConnect )
       
   677                 {
       
   678                 op = CMsvPop3ConnectOp::NewL(
       
   679                     reporter->RequestStatus(),
       
   680                     *reporter,
       
   681                     aSelection[ 0 ],
       
   682                     limit );
       
   683                 TBuf<EProgressStringMaxLen> buffer;
       
   684                 FormatConnectingServerProgressTextL( service, buffer );
       
   685                 reporter->SetTitleL( buffer );
       
   686                 reporter->SetSeeding( ETrue );
       
   687                 }
       
   688             else
       
   689                 {
       
   690                 op = CImumDisconnectOperation::NewL(
       
   691                     *iMailboxApi,
       
   692                     reporter->RequestStatus(),
       
   693                     *reporter,
       
   694                     aSelection[ 0 ],
       
   695                     KPOP3MTMDisconnect,
       
   696                     KUidMsgTypePOP3 );
       
   697                 }
       
   698             reporter->SetOperationL( op ); // Takes immediate ownership
       
   699             CleanupStack::Pop(); // reporter
       
   700             IMUM_OUT();
       
   701             return reporter;
       
   702 
       
   703             }
       
   704         case KMtmUiFunctionMessageInfo:
       
   705             IMUM_OUT();
       
   706             return ShowMessageInfoL( aStatus, aParameter );
       
   707             /*
       
   708         case KPOP3MTMPopulateAll:
       
   709             {
       
   710             //doing full partial fetch instead of bare connect
       
   711             return FetchL(aStatus, aSelection, KPOP3MTMPopulateAll);
       
   712             }
       
   713             break;
       
   714             */
       
   715         default:
       
   716             break;
       
   717         };
       
   718     IMUM_OUT();
       
   719 
       
   720     return CBaseMtmUi::InvokeAsyncFunctionL(
       
   721         aFunctionId, aSelection, aStatus, aParameter );
       
   722     }
       
   723 
       
   724 // ----------------------------------------------------------------------------
       
   725 // CPop3MtmUi::ShowMessageInfoL()
       
   726 // ----------------------------------------------------------------------------
       
   727 //
       
   728 CMsvOperation* CPop3MtmUi::ShowMessageInfoL(
       
   729     TRequestStatus& aCompletionStatus,
       
   730     TDes8& /*aParameter*/)
       
   731     {
       
   732     IMUM_CONTEXT( CPop3MtmUi::ShowMessageInfoL, 0, KImumMtmLog );
       
   733     IMUM_IN();
       
   734     
       
   735     TMsgInfoMessageInfoData infoData;
       
   736     TBuf<KImumMessageInfoDateBufferLength> dateBuf;
       
   737     TBuf<KImumMessageInfoDateBufferLength> timeBuf;
       
   738     TBuf<KImumMessageInfoSizeBufferLength> sizeBuf;
       
   739     TBuf<KImumMessagePriorityBufferLength> priorityBuf;
       
   740     TBool readStoreFound = MsvEmailMtmUiUtils::SetMessageInfoDataLCC(
       
   741         infoData,BaseMtm(),*iEikonEnv,dateBuf,timeBuf,sizeBuf,priorityBuf);
       
   742 
       
   743     TBuf<KImumMessageInfoDateBufferLength> type;
       
   744     iEikonEnv->ReadResourceL(type,R_POP3_MESSAGE_INFO_MAIL_TYPE);
       
   745     infoData.iType.Set(type);
       
   746 
       
   747     CMsgInfoMessageInfoDialog* infoDialog = CMsgInfoMessageInfoDialog::NewL();
       
   748     infoDialog->ExecuteLD(infoData,CMsgInfoMessageInfoDialog::EEmailViewer);
       
   749     CleanupStack::PopAndDestroy(2); // CSI: 47 # 2 because SetMessageInfoDataLCC
       
   750     if ( readStoreFound )
       
   751         {
       
   752         CleanupStack::PopAndDestroy(2); // CSI: 47 # 2 because store found
       
   753         }
       
   754     IMUM_OUT();
       
   755 
       
   756     return CMsvCompletedOperation::NewL(
       
   757         Session(),
       
   758         KUidMsvLocalServiceMtm,
       
   759         KNullDesC8,
       
   760         KMsvLocalServiceIndexEntryId,
       
   761         aCompletionStatus,
       
   762         KErrNone);
       
   763     }
       
   764 
       
   765 // ----------------------------------------------------------------------------
       
   766 // CPop3MtmUi::FetchSyncL()
       
   767 // Offer to fetch messages synchronously if not downloaded.
       
   768 // ----------------------------------------------------------------------------
       
   769 //
       
   770 TInt CPop3MtmUi::FetchSyncL(const CMsvEntrySelection& aSelection)
       
   771     {
       
   772     IMUM_CONTEXT( CPop3MtmUi::FetchSyncL, 0, KImumMtmLog );
       
   773     IMUM_IN();
       
   774     
       
   775     // Client context is irrelevant.
       
   776     TMsvId parent = KMsvNullIndexEntryId;
       
   777     CheckSelectionL(aSelection, parent);
       
   778     BaseMtm().SwitchCurrentEntryL(parent);
       
   779     CMsvEntry* clientContext = &(BaseMtm().Entry());
       
   780     CMsvEntrySelection* entries = MsvEmailMtmUiUtils::StripCompleteEntriesLC(*clientContext, aSelection);
       
   781     const TInt count = entries->Count();
       
   782     CleanupStack::PopAndDestroy();  // entries
       
   783     if(!count)
       
   784         {
       
   785         // Mesages are complete.
       
   786         return KErrNone;
       
   787         }
       
   788     if(clientContext->EntryId() != clientContext->OwningService())
       
   789         {
       
   790         // Client context must be service for FetchL().
       
   791         BaseMtm().SwitchCurrentEntryL(clientContext->OwningService());
       
   792         clientContext = &(BaseMtm().Entry());
       
   793         }
       
   794     // Go get the messages.
       
   795     CMsvOperationWait* waiter = CMsvOperationWait::NewLC();
       
   796     waiter->iStatus = KRequestPending;
       
   797     CMsvOperation* op = FetchL(waiter->iStatus, aSelection, KFunctionIdFetchSelected);
       
   798     CleanupStack::PushL(op);
       
   799     waiter->Start();
       
   800     CActiveScheduler::Start();
       
   801     const TInt err = DisplayProgressSummary(op->ProgressL());
       
   802     CleanupStack::PopAndDestroy(2); // CSI: 47 # op, waiter
       
   803     IMUM_OUT();
       
   804     return err;
       
   805     }
       
   806 
       
   807 // ----------------------------------------------------------------------------
       
   808 // CPop3MtmUi::GetResourceFileName()
       
   809 // ----------------------------------------------------------------------------
       
   810 //
       
   811 void CPop3MtmUi::GetResourceFileName(TFileName& aFileName) const
       
   812     {
       
   813     IMUM_CONTEXT( CPop3MtmUi::GetResourceFileName, 0, KImumMtmLog );
       
   814     IMUM_IN();
       
   815     
       
   816     aFileName=KPop3uMtmUiResourceFile;
       
   817     IMUM_OUT();
       
   818     }
       
   819 
       
   820 // ----------------------------------------------------------------------------
       
   821 // CPop3MtmUi::GetProgress()
       
   822 // ----------------------------------------------------------------------------
       
   823 //
       
   824 TInt CPop3MtmUi::GetProgress(
       
   825     const TDesC8& aProgress,
       
   826     TBuf<EProgressStringMaxLen>& aReturnString,
       
   827     TInt& aTotalEntryCount,
       
   828     TInt& aEntriesDone,
       
   829     TInt& aCurrentEntrySize,
       
   830     TInt& aCurrentBytesTrans) const
       
   831     {
       
   832     IMUM_CONTEXT( CPop3MtmUi::GetProgress, 0, KImumMtmLog );
       
   833     IMUM_IN();
       
   834     
       
   835     aReturnString.Zero();
       
   836     aTotalEntryCount=0;
       
   837     aEntriesDone=0;
       
   838     aCurrentEntrySize=0;
       
   839     aCurrentBytesTrans=0;
       
   840     if( (!aProgress.Length()) ||
       
   841         (aProgress.Size() == sizeof(TMsvLocalOperationProgress)) )
       
   842         {
       
   843         IMUM_OUT();
       
   844         return KErrNone;
       
   845         }
       
   846     const TInt progressType = ProgressType(aProgress);
       
   847     if(progressType <= TPop3Progress::EPopMaxProgressValue)
       
   848         {
       
   849         IMUM_OUT();
       
   850         return GetEngineProgress(
       
   851             aProgress,
       
   852             aReturnString,
       
   853             aTotalEntryCount,
       
   854             aEntriesDone,
       
   855             aCurrentEntrySize,
       
   856             aCurrentBytesTrans);
       
   857         }
       
   858     else
       
   859         {
       
   860         IMUM_OUT();
       
   861         return GetUiProgress(
       
   862             aProgress,
       
   863             aReturnString,
       
   864             aTotalEntryCount,
       
   865             aEntriesDone,
       
   866             aCurrentEntrySize,
       
   867             aCurrentBytesTrans);
       
   868         }
       
   869     }
       
   870 
       
   871 // ----------------------------------------------------------------------------
       
   872 // CPop3MtmUi::ProgressType()
       
   873 // Find the type of the progress. Progress type is identified by the first
       
   874 // TInt in the buffer.
       
   875 // ----------------------------------------------------------------------------
       
   876 //
       
   877 TInt CPop3MtmUi::ProgressType(const TDesC8& aProgress) const
       
   878     {
       
   879     IMUM_CONTEXT( CPop3MtmUi::ProgressType, 0, KImumMtmLog );
       
   880     IMUM_IN();
       
   881     
       
   882     TPckgC<TInt> type(0);
       
   883     type.Set(aProgress.Left(sizeof(TInt)));
       
   884     const TInt progressType = type();
       
   885     __ASSERT_DEBUG(
       
   886         progressType==TPop3Progress::EPopRefreshing
       
   887         || progressType==TPop3Progress::EPopCopying
       
   888         || progressType==TPop3Progress::EPopDeleting
       
   889         || progressType==TPop3Progress::EPopConnecting
       
   890         || progressType==TPop3Progress::EPopTidying
       
   891         || progressType==TPop3Progress::EPopConnectedAndIdle
       
   892         || progressType==TPop3Progress::EPopDisconnecting
       
   893         || progressType==TPop3Progress::EPopDisconnected
       
   894         || progressType==TPop3Progress::EPopMoving
       
   895         || progressType==TPop3Progress::EPopCopyNewMail
       
   896         || progressType==TPop3Progress::EPopMoveNewMail
       
   897         || progressType==TPop3Progress::EPopCopyMailSelection
       
   898         || progressType==TPop3Progress::EPopMoveMailSelection
       
   899         || progressType==TPop3Progress::EPopCopyAllMail
       
   900         || progressType==TPop3Progress::EPopMoveAllMail
       
   901         || progressType==TPop3Progress::EPopPopulating
       
   902         || progressType==TPop3Progress::EPopCancellingOfflineOps
       
   903         || progressType==EUiProgTypeEditing
       
   904         || progressType==EUiProgTypeConnecting
       
   905         || progressType==TPop3Progress::EPopTopPopulating,
       
   906         User::Panic(KImumMtmUiPanic, EPop3MtmUiUnknownOperation));
       
   907     IMUM_OUT();
       
   908     return progressType;
       
   909     }
       
   910 
       
   911 // ----------------------------------------------------------------------------
       
   912 // CPop3MtmUi::GetEngineProgress()
       
   913 // ----------------------------------------------------------------------------
       
   914 //
       
   915 TInt CPop3MtmUi::GetEngineProgress(
       
   916     const TDesC8& aProgress,
       
   917     TBuf<EProgressStringMaxLen>& aReturnString,
       
   918     TInt& aTotalEntryCount,
       
   919     TInt& aEntriesDone,
       
   920     TInt& aCurrentEntrySize,
       
   921     TInt& aCurrentBytesTrans) const
       
   922     {
       
   923     IMUM_CONTEXT( CPop3MtmUi::GetEngineProgress, 0, KImumMtmLog );
       
   924     IMUM_IN();
       
   925     
       
   926     // Unpack the progress buffer in the appropriate POP3 progress object
       
   927     __ASSERT_ALWAYS(aProgress.Size() == sizeof(TPop3Progress), User::Panic(KImumMtmUiPanic, EPop3MtmUiNoProgress));
       
   928     TPckgBuf<TPop3Progress> paramPack;
       
   929     paramPack.Copy(aProgress);
       
   930     const TPop3Progress& progress = paramPack();
       
   931     // Extract the information on the entries which have been done
       
   932     aTotalEntryCount = progress.iTotalMsgs;
       
   933     aEntriesDone = Min(aTotalEntryCount, aTotalEntryCount - progress.iMsgsToProcess);
       
   934     aCurrentEntrySize = progress.iTotalBytes;
       
   935     aCurrentBytesTrans = progress.iBytesDone;
       
   936 
       
   937     // Get the progress description
       
   938     TInt resourceId = 0;
       
   939     switch(progress.iPop3Progress)
       
   940         {
       
   941     case TPop3Progress::EPopConnectedAndIdle:
       
   942     case TPop3Progress::EPopConnecting:
       
   943     case TPop3Progress::EPopDisconnecting:
       
   944     case TPop3Progress::EPopDisconnected:
       
   945         aCurrentEntrySize = 0;
       
   946         aCurrentBytesTrans = 0;
       
   947         IMUM_OUT();
       
   948         return progress.iErrorCode;     // No progress text for these states.
       
   949 
       
   950     case TPop3Progress::EPopTidying:
       
   951     case TPop3Progress::EPopRefreshing:
       
   952         if(progress.iTotalMsgs == 0)
       
   953             {
       
   954             // Display 'Connecting to <SERVER NAME>', rather than 'Getting header 0 of 0'
       
   955             TRAPD(err, FormatConnectingServerProgressTextL(
       
   956                 progress.iServiceId, aReturnString));
       
   957             if(err == KErrNone)
       
   958                 {
       
   959                 err = progress.iErrorCode;
       
   960                 }
       
   961             aCurrentEntrySize = 0;
       
   962             aCurrentBytesTrans = 0;
       
   963             IMUM_OUT();
       
   964             return err;
       
   965             }
       
   966         resourceId = R_POP3_UPDATING_INBOX;
       
   967         break;
       
   968 
       
   969     case TPop3Progress::EPopMoveNewMail:
       
   970     case TPop3Progress::EPopMoveAllMail:
       
   971     case TPop3Progress::EPopMoveMailSelection:
       
   972     case TPop3Progress::EPopMoving:
       
   973         __ASSERT_DEBUG( EFalse, User::Panic(KImumMtmUiPanic,   EPop3MtmUiMoveNotAllowed ));
       
   974         break;
       
   975     case TPop3Progress::EPopCopyNewMail:
       
   976     case TPop3Progress::EPopCopyAllMail:
       
   977     case TPop3Progress::EPopCopyMailSelection:
       
   978     case TPop3Progress::EPopCopying:
       
   979         resourceId = (progress.iTotalMsgs == 1) ?
       
   980             (R_POP3_COPYING_IMAIL_PROGRESS) : (R_POP3_COPYING_MULTI_IMAIL_PROGRESS);
       
   981         break;
       
   982     case TPop3Progress::EPopDeleting:
       
   983         resourceId = (progress.iTotalMsgs == 1) ?
       
   984             (R_POP3_DELETING_IMAIL_PROGRESS) : (R_POP3_DELETING_IMAIL_PROGRESS_MANY);
       
   985         break;
       
   986     case TPop3Progress::EPopPopulating:
       
   987     case TPop3Progress::EPopTopPopulating:
       
   988         resourceId = (progress.iTotalMsgs == 1) ?
       
   989             (R_POP3_POPULATING_SINGLE) : (R_POP3_POPULATING_MULTIPLE);
       
   990 		//We don't want progressbar, but wait animation instead. This is achieved 
       
   991 		//by denying progress information.
       
   992         aTotalEntryCount = 0;
       
   993 	    aEntriesDone = 0;
       
   994 	    aCurrentEntrySize = 0;
       
   995 	    aCurrentBytesTrans = 0;
       
   996         break;
       
   997     case TPop3Progress::EPopCancellingOfflineOps:
       
   998         resourceId = (progress.iTotalMsgs == 1) ?
       
   999             (R_POP3_UNDELETING_IMAIL_PROGRESS) : (R_POP3_UNDELETING_MULTI_IMAIL_PROGRESS);
       
  1000         break;
       
  1001     default:
       
  1002         User::Panic(KImumMtmUiPanic, EPop3MtmUiUnknownOperation);
       
  1003         break;
       
  1004         };
       
  1005     //
       
  1006     // Format the return progress string as appropriate
       
  1007     if (resourceId!=0)
       
  1008         {
       
  1009         StringLoader::Load( aReturnString, resourceId, iCoeEnv);
       
  1010         if ( resourceId != R_POP3_UPDATING_INBOX &&
       
  1011              progress.iTotalMsgs>1 )
       
  1012             {
       
  1013             TBuf<EProgressStringMaxLen> tempBuffer;
       
  1014             StringLoader::Format(
       
  1015                 tempBuffer,
       
  1016                 aReturnString,
       
  1017                 KImumEntriesDoneReplaceIndex,
       
  1018                 Min(progress.iTotalMsgs, progress.iTotalMsgs - progress.iMsgsToProcess+1) );
       
  1019             StringLoader::Format(
       
  1020                 aReturnString,
       
  1021                 tempBuffer,
       
  1022                 KImumTotalEntriesReplaceIndex,
       
  1023                 progress.iTotalMsgs );
       
  1024             }
       
  1025         }
       
  1026     else
       
  1027         {
       
  1028         aReturnString.Zero();
       
  1029         }
       
  1030     IMUM_OUT();
       
  1031 
       
  1032     return progress.iErrorCode;
       
  1033     }
       
  1034 
       
  1035 // ----------------------------------------------------------------------------
       
  1036 // CPop3MtmUi::GetUiProgress()
       
  1037 // ----------------------------------------------------------------------------
       
  1038 //
       
  1039 TInt CPop3MtmUi::GetUiProgress(
       
  1040     const TDesC8& aProgress,
       
  1041     TBuf<EProgressStringMaxLen>& aReturnString,
       
  1042     TInt& aTotalEntryCount,
       
  1043     TInt& aEntriesDone,
       
  1044     TInt& aCurrentEntrySize,
       
  1045     TInt& aCurrentBytesTrans) const
       
  1046     {
       
  1047     IMUM_CONTEXT( CPop3MtmUi::GetUiProgress, 0, KImumMtmLog );
       
  1048     IMUM_IN();
       
  1049     
       
  1050     switch(ProgressType(aProgress))
       
  1051         {
       
  1052         case EUiProgTypeEditing:
       
  1053             break;
       
  1054         case EUiProgTypeConnecting:
       
  1055             IMUM_OUT();
       
  1056             return GetConnectionProgress(
       
  1057                 aProgress,
       
  1058                 aReturnString,
       
  1059                 aTotalEntryCount,
       
  1060                 aEntriesDone,
       
  1061                 aCurrentEntrySize,
       
  1062                 aCurrentBytesTrans);
       
  1063 
       
  1064         default:
       
  1065             User::Panic(KImumMtmUiPanic, EPop3MtmUiUnknownOperation);
       
  1066             break;
       
  1067         }
       
  1068     IMUM_OUT();
       
  1069     return KErrNone;
       
  1070     }
       
  1071 
       
  1072 // ----------------------------------------------------------------------------
       
  1073 // CPop3MtmUi::GetConnectionProgress()
       
  1074 // ----------------------------------------------------------------------------
       
  1075 //
       
  1076 TInt CPop3MtmUi::GetConnectionProgress(
       
  1077     const TDesC8& aProgress,
       
  1078     TBuf<EProgressStringMaxLen>& aReturnString,
       
  1079     TInt& /*aTotalEntryCount*/,
       
  1080     TInt& /*aEntriesDone*/,
       
  1081     TInt& /*aCurrentEntrySize*/,
       
  1082     TInt& /*aCurrentBytesTrans*/) const
       
  1083     {
       
  1084     IMUM_CONTEXT( CPop3MtmUi::GetConnectionProgress, 0, KImumMtmLog );
       
  1085     IMUM_IN();
       
  1086     
       
  1087     // Unpack the progress buffer in the appropriate progress object
       
  1088     __ASSERT_ALWAYS(aProgress.Size() == sizeof(TMsvEmailConnectionProgress), User::Panic(KImumMtmUiPanic, EPop3MtmUiNoProgress));
       
  1089     TPckgBuf<TMsvEmailConnectionProgress> paramPack;
       
  1090     paramPack.Copy(aProgress);
       
  1091     const TMsvEmailConnectionProgress& progress = paramPack();
       
  1092 
       
  1093     // Get the progress text.
       
  1094     switch(progress.iState)
       
  1095         {
       
  1096         case TMsvEmailConnectionProgress::EInitialising:
       
  1097         case TMsvEmailConnectionProgress::EConnectNetwork:
       
  1098         case TMsvEmailConnectionProgress::EConnectMailbox:
       
  1099             MsvEmailMtmUiUtils::CreateConnectingToText( aReturnString,
       
  1100                 Session(), BaseMtm().Entry().EntryId() );
       
  1101             break;
       
  1102         default:
       
  1103             User::Panic(KImumMtmUiPanic, EPop3MtmUiUnknownProgressState);
       
  1104             break;
       
  1105         }
       
  1106     IMUM_OUT();
       
  1107     return KErrNone;
       
  1108     }
       
  1109 
       
  1110 // ----------------------------------------------------------------------------
       
  1111 // CPop3MtmUi::GetDeleteProgress()
       
  1112 // ----------------------------------------------------------------------------
       
  1113 //
       
  1114 TInt CPop3MtmUi::GetDeleteProgress(TInt aTotalMsgs, TInt aError, TBuf<EProgressStringMaxLen>& aReturnString, TInt& aTotalEntryCount, TInt& aEntriesDone,
       
  1115     TInt& aCurrentEntrySize, TInt& aCurrentBytesTrans) const
       
  1116     {
       
  1117     IMUM_CONTEXT( CPop3MtmUi::GetDeleteProgress, 0, KImumMtmLog );
       
  1118     IMUM_IN();
       
  1119     
       
  1120     // Delete progress is something of a special case since it reports only the total
       
  1121     // number of messages to be deleted, and has no progress bar.
       
  1122     aEntriesDone = 0;
       
  1123     aTotalEntryCount = 0;
       
  1124     aCurrentEntrySize = 0;
       
  1125     aCurrentBytesTrans = 0;
       
  1126     if(aTotalMsgs >= 2)
       
  1127         {
       
  1128         TBuf<EProgressStringMaxLen> resource;
       
  1129         TRAP_IGNORE( iCoeEnv->ReadResourceL( resource, 
       
  1130             R_POP3_DELETING_IMAIL_PROGRESS_MANY ) );
       
  1131         aReturnString.Format(resource, aTotalMsgs);
       
  1132         }
       
  1133     else
       
  1134         {
       
  1135         TRAP_IGNORE( iCoeEnv->ReadResourceL( aReturnString, 
       
  1136             R_POP3_DELETING_IMAIL_PROGRESS ) );
       
  1137         }
       
  1138     IMUM_OUT();
       
  1139     return aError;
       
  1140     }
       
  1141 
       
  1142 // ----------------------------------------------------------------------------
       
  1143 // CPop3MtmUi::DisplayProgressSummary()
       
  1144 // ----------------------------------------------------------------------------
       
  1145 //
       
  1146 TInt CPop3MtmUi::DisplayProgressSummary(const TDesC8& aProgress) const
       
  1147     {
       
  1148     IMUM_CONTEXT( CPop3MtmUi::DisplayProgressSummary, 0, KImumMtmLog );
       
  1149     IMUM_IN();
       
  1150     
       
  1151     if( (!aProgress.Length()) || (aProgress.Size() == sizeof(TMsvLocalOperationProgress)) )
       
  1152         {
       
  1153         // Probably a CMsvCompletedOperation
       
  1154         return KErrCancel;
       
  1155         }
       
  1156     const TInt progressType = ProgressType(aProgress);
       
  1157     TInt err = KErrNone;
       
  1158 
       
  1159     if( (progressType > EUiProgTypeBase) && (progressType < EUiProgTypeLast) )
       
  1160         {
       
  1161         // Handle UI types.
       
  1162         switch(progressType)
       
  1163             {
       
  1164             case EUiProgTypeEditing:
       
  1165                 IMUM_OUT();
       
  1166                 return KErrNone;
       
  1167 
       
  1168             case EUiProgTypeConnecting:
       
  1169                 {
       
  1170                 __ASSERT_ALWAYS(aProgress.Size() == sizeof(TMsvEmailConnectionProgress), User::Panic(KImumMtmUiPanic, EPop3MtmUiNoProgress));
       
  1171                 TPckgBuf<TMsvEmailConnectionProgress> uiParamPack;
       
  1172                 uiParamPack.Copy(aProgress);
       
  1173                 const TMsvEmailConnectionProgress& uiProgress = uiParamPack();
       
  1174                 err = uiProgress.iErrorCode;
       
  1175                 if( (err == KErrNone) || (err == KErrCancel) )
       
  1176                     {
       
  1177                     IMUM_OUT();
       
  1178                     // Success.
       
  1179                     return err;
       
  1180                     }
       
  1181                 }
       
  1182                 break;
       
  1183             default:
       
  1184                 User::Panic(KImumMtmUiPanic, EPop3MtmUiUnknownProgressType);
       
  1185                 break;
       
  1186             }
       
  1187         }
       
  1188     else
       
  1189         {
       
  1190         // Handle POPS or POPC types.
       
  1191         __ASSERT_ALWAYS(aProgress.Size() == sizeof(TPop3Progress), User::Panic(KImumMtmUiPanic, EPop3MtmUiNoProgress));
       
  1192         TPckgBuf<TPop3Progress> paramPack;
       
  1193         paramPack.Copy(aProgress);
       
  1194         const TPop3Progress& progress = paramPack();
       
  1195         err = progress.iErrorCode;
       
  1196         if( (err == KErrNone) || (err == KErrCancel) )
       
  1197             {
       
  1198             IMUM_OUT();
       
  1199             // Success.
       
  1200             return err;
       
  1201             }
       
  1202 
       
  1203         switch((TInt)progress.iPop3Progress)
       
  1204             {
       
  1205         case TPop3Progress::EPopConnectedAndIdle:
       
  1206         case TPop3Progress::EPopConnecting:
       
  1207         case TPop3Progress::EPopTidying:
       
  1208         case TPop3Progress::EPopRefreshing:
       
  1209         case TPop3Progress::EPopCopying:
       
  1210         case TPop3Progress::EPopCopyNewMail:
       
  1211         case TPop3Progress::EPopCopyMailSelection:
       
  1212         case TPop3Progress::EPopCopyAllMail:
       
  1213         case TPop3Progress::EPopDeleting:
       
  1214         case TPop3Progress::EPopDisconnecting:
       
  1215         case TPop3Progress::EPopDisconnected:
       
  1216         case TPop3Progress::EPopMoving:
       
  1217         case TPop3Progress::EPopMoveNewMail:
       
  1218         case TPop3Progress::EPopMoveMailSelection:
       
  1219         case TPop3Progress::EPopMoveAllMail:
       
  1220         case TPop3Progress::EPopPopulating:
       
  1221         case TPop3Progress::EPopTopPopulating:
       
  1222             break;
       
  1223         default:
       
  1224             User::Panic(KImumMtmUiPanic, EPop3MtmUiUnknownProgressType);
       
  1225             break;
       
  1226             }
       
  1227         }
       
  1228     IMUM_OUT();
       
  1229     return DisplayProgressErrorAlert( err );
       
  1230     }
       
  1231 
       
  1232 // ----------------------------------------------------------------------------
       
  1233 // CPop3MtmUi::DisplayProgressErrorAlert()
       
  1234 // ----------------------------------------------------------------------------
       
  1235 //
       
  1236 TInt CPop3MtmUi::DisplayProgressErrorAlert( TInt aErrCode ) const
       
  1237     {
       
  1238     IMUM_CONTEXT( CPop3MtmUi::DisplayProgressErrorAlert, 0, KImumMtmLog );
       
  1239     IMUM_IN();
       
  1240     
       
  1241     if ( aErrCode == KErrDndNameNotFound )
       
  1242         {
       
  1243         TRAP_IGNORE( CIMSSettingsNoteUi::ShowQueryL(
       
  1244             R_MAIL_ERR_NO_IN_SRVR, R_EMAIL_INFORMATION_QUERY ) );
       
  1245         }
       
  1246     else if ( aErrCode != KErrGeneral &&
       
  1247          aErrCode != KErrEtelBusyDetected &&
       
  1248          aErrCode != KErrAbort )
       
  1249         // general errors displayed by other components. for ex. phone app...
       
  1250         {
       
  1251         //remap error code so we get some sensible error note instead of system
       
  1252         // error which isn't even displayed.
       
  1253         if ( aErrCode == KErrDisconnected )
       
  1254             {
       
  1255             aErrCode = KPop3ProblemWithRemotePopServer;
       
  1256             }
       
  1257         if ( aErrCode == KErrGprsServicesNotAllowed )
       
  1258             {
       
  1259             aErrCode = KImskErrorActiveSettingIsDifferent;
       
  1260             }
       
  1261         if ( aErrCode == KErrCouldNotConnect )
       
  1262             {
       
  1263             aErrCode = KPop3CannotConnect;
       
  1264             }
       
  1265         if ( aErrCode == KImskSSLTLSNegotiateFailed )            
       
  1266 			{
       
  1267 			//we use IMAP error code because it has already been mapped in CTextResolver
       
  1268 			//and works for Pop3 too.
       
  1269 			aErrCode = KErrImapServerNoSecurity;
       
  1270 			}
       
  1271 
       
  1272         TRAP_IGNORE( iErrorResolver->ShowGlobalErrorNoteL( aErrCode ) );
       
  1273         }
       
  1274     IMUM_OUT();
       
  1275     return aErrCode;
       
  1276     }
       
  1277 
       
  1278 // ----------------------------------------------------------------------------
       
  1279 // CPop3MtmUi::FormatConnectingServerProgressTextL()
       
  1280 // ----------------------------------------------------------------------------
       
  1281 //
       
  1282 void CPop3MtmUi::FormatConnectingServerProgressTextL(
       
  1283     TMsvId aServiceId,
       
  1284     TDes& aReturnString) const
       
  1285     {
       
  1286     IMUM_CONTEXT( CPop3MtmUi::FormatConnectingServerProgressTextL, 0, KImumMtmLog );
       
  1287     IMUM_IN();
       
  1288     
       
  1289     if(iServerNameCache.iService != aServiceId)
       
  1290         {
       
  1291         TMsvEntry serviceEntry;
       
  1292         TMsvId serviceId;
       
  1293         User::LeaveIfError( Session().GetEntry( aServiceId, serviceId, serviceEntry ) );
       
  1294         HBufC* text = StringLoader::LoadLC(
       
  1295             R_EMAIL_CONNECTING_SERVER, serviceEntry.iDetails, iCoeEnv );
       
  1296         aReturnString.Copy( (*text).Left( EProgressStringMaxLen ) );
       
  1297         CleanupStack::PopAndDestroy(); // text
       
  1298         iServerNameCache.iService = aServiceId;
       
  1299         iServerNameCache.iConnectingServerTxt = aReturnString;
       
  1300         }
       
  1301     else
       
  1302         {
       
  1303         aReturnString = iServerNameCache.iConnectingServerTxt;
       
  1304         }
       
  1305     IMUM_OUT();
       
  1306     }
       
  1307 
       
  1308 // ----------------------------------------------------------------------------
       
  1309 // CPop3MtmUi::LaunchEditorApplicationL()
       
  1310 // ----------------------------------------------------------------------------
       
  1311 //
       
  1312 CMsvOperation* CPop3MtmUi::LaunchEditorApplicationL(
       
  1313     TRequestStatus& aStatus,
       
  1314     const TEditorParameters& aParams)
       
  1315     {
       
  1316     IMUM_CONTEXT( CPop3MtmUi::LaunchEditorApplicationL, 0, KImumMtmLog );
       
  1317     IMUM_IN();
       
  1318     
       
  1319     // Get the app name
       
  1320     HBufC* appName = (aParams.iFlags & EMsgReadOnly) ?
       
  1321         (GetViewerFileNameL()) : (GetEditorFileNameL());
       
  1322     const TUint preferences = Preferences();
       
  1323 
       
  1324     TEmailEditParams editParams;
       
  1325     editParams.iPreferences = preferences;
       
  1326     editParams.iEditorFileName = *appName;
       
  1327     editParams.iEditorParams = aParams;
       
  1328 
       
  1329     editParams.iEditorParams.iFlags &= ~(EMsgLaunchEditorEmbedded | EMsgLaunchEditorThenWait);
       
  1330     if(preferences & EMtmUiFlagEditorPreferEmbedded)
       
  1331         {
       
  1332         editParams.iEditorParams.iFlags |= EMsgLaunchEditorEmbedded;
       
  1333         }
       
  1334     if(!(preferences & EMtmUiFlagEditorNoWaitForExit))
       
  1335         {
       
  1336         editParams.iEditorParams.iFlags |= EMsgLaunchEditorThenWait;
       
  1337         }
       
  1338     const TBool ackReceipts = AcknowledgeReceiptsL(aParams.iId);
       
  1339     IMUM_OUT();
       
  1340     return CImumEditOperation::NewL(
       
  1341         *iMailboxApi, aStatus, Type(), editParams, ackReceipts);
       
  1342     }
       
  1343 
       
  1344 // ----------------------------------------------------------------------------
       
  1345 // CPop3MtmUi::ViewMessageL()
       
  1346 // ----------------------------------------------------------------------------
       
  1347 //
       
  1348 CMsvOperation* CPop3MtmUi::ViewMessageL(TRequestStatus& aStatus)
       
  1349     {
       
  1350     IMUM_CONTEXT( CPop3MtmUi::ViewMessageL, 0, KImumMtmLog );
       
  1351     IMUM_IN();
       
  1352     
       
  1353     // Context is message to view.
       
  1354     const TMsvEntry& context=BaseMtm().Entry().Entry();
       
  1355     TEditorParameters editorParams;
       
  1356     editorParams.iId=context.Id();
       
  1357     editorParams.iFlags|=EMsgReadOnly;
       
  1358 
       
  1359     TMsvEmailEntry emailEntry=BaseMtm().Entry().Entry();
       
  1360     if ( emailEntry.DisconnectedOperation() == EDisconnectedDeleteOperation )
       
  1361         {
       
  1362         // remove deleted flag
       
  1363         TInt error = MsvEmailMtmUiUtils::RemoveOfflineDeleteL(
       
  1364             BaseMtm(),
       
  1365             KPOP3MTMCancelOfflineOperations,
       
  1366             emailEntry.Id() );
       
  1367         User::LeaveIfError( error );
       
  1368         }
       
  1369 
       
  1370     if(context.Complete())
       
  1371         {
       
  1372         IMUM_OUT();
       
  1373         return LaunchEditorApplicationL(aStatus, editorParams);
       
  1374         }
       
  1375     IMUM_OUT();
       
  1376 
       
  1377     return RetrieveAndEditMessageL(aStatus, editorParams);
       
  1378     }
       
  1379 
       
  1380 // ----------------------------------------------------------------------------
       
  1381 // CPop3MtmUi::EditSmtpServiceL()
       
  1382 // ----------------------------------------------------------------------------
       
  1383 //
       
  1384 CMsvOperation* CPop3MtmUi::EditSmtpServiceL(
       
  1385     TRequestStatus& aStatus,
       
  1386     TMsvId aServiceEntry) const
       
  1387     {
       
  1388     IMUM_CONTEXT( CPop3MtmUi::EditSmtpServiceL, 0, KImumMtmLog );
       
  1389     IMUM_IN();
       
  1390     
       
  1391     // Context is irrelevant.
       
  1392     CMsvEntry* centry = Session().GetEntryL(aServiceEntry);
       
  1393     CleanupStack::PushL(centry);
       
  1394     CMtmStore* mtmStore = CMtmStore::NewL(Session());
       
  1395     CleanupStack::PushL(mtmStore);
       
  1396     CBaseMtmUi& smtpUi = mtmStore->GetMtmUiAndSetContextLC(centry->Entry());
       
  1397     CMsvOperation* op = smtpUi.EditL(aStatus);
       
  1398     CleanupStack::PopAndDestroy(3); // smtpUi, mtmStore, centry
       
  1399     IMUM_OUT();
       
  1400     return op;
       
  1401     }
       
  1402 
       
  1403 // ----------------------------------------------------------------------------
       
  1404 // CPop3MtmUi::CheckEntryL()
       
  1405 // ----------------------------------------------------------------------------
       
  1406 //
       
  1407 void CPop3MtmUi::CheckEntryL(const TMsvEntry& aEntry) const
       
  1408 // Checks that that the entry is a POP3 entry, and that it is
       
  1409 // of a type that the POP3 MTM supports; i.e. message or service entries.
       
  1410     {
       
  1411     IMUM_CONTEXT( CPop3MtmUi::CheckEntryL, 0, KImumMtmLog );
       
  1412     IMUM_IN();
       
  1413     
       
  1414     if( ((aEntry.iType.iUid!=KUidMsvMessageEntryValue) &&
       
  1415          (aEntry.iType.iUid!=KUidMsvServiceEntryValue)) ||
       
  1416         (aEntry.iMtm!=Type()) )
       
  1417         {
       
  1418         User::Leave(KErrNotSupported);
       
  1419         }
       
  1420     IMUM_OUT();
       
  1421     }
       
  1422 
       
  1423 // ----------------------------------------------------------------------------
       
  1424 // CPop3MtmUi::CheckSelectionL()
       
  1425 // Checks that the entries in the passed selection are of the correct mtm and are all
       
  1426 // children of the same entry.
       
  1427 // Returns the parent of the entries
       
  1428 // ----------------------------------------------------------------------------
       
  1429 void CPop3MtmUi::CheckSelectionL(
       
  1430     const CMsvEntrySelection& aSelection,
       
  1431     TMsvId& aParent) const
       
  1432     {
       
  1433     IMUM_CONTEXT( CPop3MtmUi::CheckSelectionL, 0, KImumMtmLog );
       
  1434     IMUM_IN();
       
  1435     
       
  1436     __ASSERT_ALWAYS(aSelection.Count(), User::Panic(KImumMtmUiPanic, EPop3MtmUiSelectionIsEmpty));
       
  1437     // Get the first entry, and then it's parent
       
  1438     CMsvEntry* entry=Session().GetEntryL(aSelection[0]);
       
  1439     CleanupStack::PushL(entry);
       
  1440     CheckEntryL(entry->Entry());
       
  1441     const TUid mtm=entry->Entry().iMtm;
       
  1442     __ASSERT_ALWAYS(mtm==Type(), User::Panic(KImumMtmUiPanic, EPop3MtmUiWrongMtm));
       
  1443     aParent=entry->Entry().Parent();
       
  1444     entry->SetEntryL(aParent);
       
  1445     //
       
  1446     // All entries in the selection should be from the same parent, so make sure this is the case
       
  1447     for (TInt cc=1; cc < aSelection.Count(); ++cc)
       
  1448         {
       
  1449         TMsvEntry tentry;
       
  1450         TRAPD(err, tentry=entry->ChildDataL(aSelection[cc]));
       
  1451         if(err == KErrNotFound)
       
  1452             {
       
  1453             // All the messages from the selection not found 'under' one parent
       
  1454             User::Panic(KImumMtmUiPanic, EPop3MtmUiSelectionOfMoreThanOneParent);
       
  1455             }
       
  1456         if(tentry.iType.iUid == KUidMsvMessageEntryValue)
       
  1457             {
       
  1458             // POP3 MTM UI only supports selections of messages, not services
       
  1459             User::Leave(KErrNotSupported);
       
  1460             }
       
  1461         if(tentry.iMtm != mtm)
       
  1462             {
       
  1463             // Given entry of the wrong mtm
       
  1464             User::Panic(KImumMtmUiPanic, EPop3MtmUiSelectionWithMessageOfWrongMtm);
       
  1465             }
       
  1466         }
       
  1467     CleanupStack::PopAndDestroy();// entry
       
  1468     IMUM_OUT();
       
  1469     }
       
  1470 
       
  1471 // ----------------------------------------------------------------------------
       
  1472 // CPop3MtmUi::SingleEntrySelectionLC()
       
  1473 // ----------------------------------------------------------------------------
       
  1474 //
       
  1475 CMsvEntrySelection* CPop3MtmUi::SingleEntrySelectionLC(TMsvId aId) const
       
  1476     {
       
  1477     IMUM_CONTEXT( CPop3MtmUi::SingleEntrySelectionLC, 0, KImumMtmLog );
       
  1478     IMUM_IN();
       
  1479     
       
  1480     CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
       
  1481     CleanupStack::PushL(selection);
       
  1482     selection->AppendL(aId);
       
  1483     IMUM_OUT();
       
  1484     return selection;
       
  1485     }
       
  1486 
       
  1487 // ----------------------------------------------------------------------------
       
  1488 // CPop3MtmUi::StripInvalidEntriesLC()
       
  1489 // ----------------------------------------------------------------------------
       
  1490 //
       
  1491 CMsvEntrySelection* CPop3MtmUi::StripInvalidEntriesLC(
       
  1492     const CMsvEntrySelection& aSelection) const
       
  1493     {
       
  1494     IMUM_CONTEXT( CPop3MtmUi::StripInvalidEntriesLC, 0, KImumMtmLog );
       
  1495     IMUM_IN();
       
  1496     
       
  1497     CMsvEntrySelection* entries=aSelection.CopyLC();
       
  1498     CMsvEntrySelection* contextChildren=BaseMtm().Entry().ChildrenL();
       
  1499     CleanupStack::PushL(contextChildren);
       
  1500     TInt cc=entries->Count();
       
  1501     while (cc--)
       
  1502         {
       
  1503         if (contextChildren->Find((*entries)[cc]) == KErrNotFound)
       
  1504             entries->Delete(cc);
       
  1505         }
       
  1506     CleanupStack::PopAndDestroy();
       
  1507     IMUM_OUT();
       
  1508     return entries;
       
  1509     }
       
  1510 
       
  1511 // ----------------------------------------------------------------------------
       
  1512 // CPop3MtmUi::DeleteFromL()
       
  1513 // ----------------------------------------------------------------------------
       
  1514 //
       
  1515 CMsvOperation* CPop3MtmUi::DeleteFromL(
       
  1516     const CMsvEntrySelection& aSelection,
       
  1517     TRequestStatus& aStatus)
       
  1518     {
       
  1519     IMUM_CONTEXT( CPop3MtmUi::DeleteFromL, 0, KImumMtmLog );
       
  1520     IMUM_IN();
       
  1521     
       
  1522     // Context is parent of entries to be deleted.
       
  1523     CMsvEntrySelection* validEntries=StripInvalidEntriesLC(aSelection);
       
  1524     CMsvEntrySelection* entries=
       
  1525         MsvEmailMtmUiUtils::StripDeletedEntriesLC(
       
  1526         BaseMtm().Entry(), *validEntries);
       
  1527         // Current context is parent.
       
  1528 
       
  1529     CMsvOperation* op=NULL;
       
  1530     const TInt numberOfItems = entries->Count();
       
  1531     IMUM1(0, "TInt numberOfItems( %d )", numberOfItems);
       
  1532     
       
  1533     if( numberOfItems )
       
  1534         {
       
  1535 
       
  1536         TInt chosedDelMode = KErrNotFound;
       
  1537         const TInt delMode = GetMailDeletionModeL();
       
  1538         TBool dlgResult = ETrue;
       
  1539 
       
  1540         IMUM0(0, "Many items");
       
  1541         if ( delMode == EIMASMailDeletionAlwaysAsk )
       
  1542             {
       
  1543             
       
  1544             CImumListQueryDialog* dlg = new (ELeave) CImumListQueryDialog(&chosedDelMode);
       
  1545             dlg->PrepareLC( R_IMUM_DELETE_LIST_QUERY );
       
  1546             
       
  1547             if ( numberOfItems > 1 )
       
  1548                 {
       
  1549                 // change list query title
       
  1550                 HBufC* manyMailsText = StringLoader::LoadLC(
       
  1551                   R_IMUM_DELETE_LIST_QUERY_TITLE_MANY_MAILS, numberOfItems, iEikonEnv );
       
  1552 
       
  1553                 CAknPopupHeadingPane* heading = dlg->QueryHeading();
       
  1554                 heading->SetTextL( *manyMailsText );
       
  1555                 CleanupStack::PopAndDestroy( manyMailsText );
       
  1556                 }
       
  1557             dlgResult = dlg->RunLD( );
       
  1558             }
       
  1559         else if ( numberOfItems > 1 )
       
  1560             { 
       
  1561             HBufC* queryText = NULL;
       
  1562             
       
  1563             if ( delMode == EIMASMailDeletionPhone )
       
  1564                 {
       
  1565                 queryText = StringLoader::LoadLC(
       
  1566                         R_IMUM_DELETE_MANY_MAILS_PHONE_QUERY, numberOfItems, iEikonEnv );
       
  1567                 }
       
  1568             else 
       
  1569                 {
       
  1570                 queryText = StringLoader::LoadLC(
       
  1571                         R_IMUM_DELETE_MANY_MAILS_SERVER_QUERY, numberOfItems, iEikonEnv );
       
  1572                 }
       
  1573             
       
  1574             dlgResult = CIMSSettingsNoteUi::ShowQueryL(
       
  1575                    *queryText, R_EMAIL_CONFIRMATION_QUERY );
       
  1576             
       
  1577             CleanupStack::PopAndDestroy( queryText );
       
  1578             }
       
  1579      
       
  1580         if ( delMode == EIMASMailDeletionPhone )
       
  1581             {
       
  1582             chosedDelMode = KPop3MtmUiDeleteMessagesLocally;  
       
  1583             }
       
  1584             
       
  1585 
       
  1586 
       
  1587         if( dlgResult )
       
  1588             {
       
  1589             IMUM0(0, "Starting delete operation");
       
  1590             CMsvProgressReporterOperation* reporter = NULL;
       
  1591             
       
  1592             if ( chosedDelMode == KPop3MtmUiDeleteMessagesLocally )
       
  1593                 {
       
  1594                 // Show a note to make sure that user understands that header will still be seen
       
  1595                 // even if mail is deleted from the phone, only showed if setting is always ask
       
  1596                 if ( delMode == EIMASMailDeletionAlwaysAsk ) 
       
  1597                     {
       
  1598                     CIMSSettingsNoteUi::ShowNoteL( R_IMUM_HEADER_WILL_REMAIN_PHONE,
       
  1599                         EIMSInformationNote, ETrue, CAknNoteDialog::EShortTimeout );
       
  1600                     }
       
  1601 
       
  1602                 reporter = CMsvProgressReporterOperation::NewL(Session(), aStatus, EMbmAvkonQgn_note_erased);
       
  1603                 CleanupStack::PushL(reporter);
       
  1604                 
       
  1605                 CImumDeleteMessagesLocally* deleteop =
       
  1606                     CImumDeleteMessagesLocally::NewL(
       
  1607                     *entries,
       
  1608                     *iMailboxApi,
       
  1609                     reporter->iStatus );
       
  1610                 reporter->SetProgressDecoder( *deleteop );
       
  1611                 reporter->SetOperationL( deleteop ); // Takes immediate ownership
       
  1612                 }
       
  1613             else
       
  1614                 {
       
  1615                 reporter = CMsvProgressReporterOperation::NewL(Session(), aStatus, EMbmAvkonQgn_note_erased);
       
  1616                 CleanupStack::PushL(reporter);
       
  1617                 
       
  1618                 CImumDeleteMessagesFromServer* deleteop =
       
  1619                     CImumDeleteMessagesFromServer::NewL( 
       
  1620                     *iMailboxApi, 
       
  1621                     reporter->iStatus, 
       
  1622                     *entries );
       
  1623                 reporter->SetProgressDecoder( *deleteop );
       
  1624                 reporter->SetOperationL( deleteop ); // Takes immediate ownership
       
  1625                 }
       
  1626                 
       
  1627             CleanupStack::Pop(); //reporter
       
  1628             op = reporter;
       
  1629             }
       
  1630         else
       
  1631             {
       
  1632             op=CMsvCompletedOperation::NewL(
       
  1633                 Session(),
       
  1634                 Type(),
       
  1635                 KNullDesC8,
       
  1636                 KMsvLocalServiceIndexEntryId,
       
  1637                 aStatus,
       
  1638                 KErrCancel );
       
  1639             }
       
  1640         }
       
  1641 
       
  1642     if(!op)
       
  1643         {
       
  1644         op=CMsvCompletedOperation::NewL(
       
  1645             Session(),
       
  1646             Type(),
       
  1647             KNullDesC8,
       
  1648             KMsvLocalServiceIndexEntryId,
       
  1649             aStatus,
       
  1650             KErrNone );
       
  1651         }
       
  1652     CleanupStack::PopAndDestroy(2);//entries, validEntries
       
  1653     
       
  1654     IMUM_OUT();
       
  1655     return op;
       
  1656     }
       
  1657 
       
  1658 // ----------------------------------------------------------------------------
       
  1659 // CPop3MtmUi::UnDeleteFromL()
       
  1660 // ----------------------------------------------------------------------------
       
  1661 //
       
  1662 CMsvOperation* CPop3MtmUi::UnDeleteFromL(
       
  1663     const CMsvEntrySelection& aSelection,
       
  1664     TRequestStatus& aStatus)
       
  1665     {
       
  1666     IMUM_CONTEXT( CPop3MtmUi::UnDeleteFromL, 0, KImumMtmLog );
       
  1667     IMUM_IN();
       
  1668     
       
  1669     // Context is parent of entries to be undeleted.
       
  1670     TBool undelete = EFalse;
       
  1671     if ( aSelection.Count() > 1 )
       
  1672         {
       
  1673         HBufC* promptText = StringLoader::LoadLC(
       
  1674             R_EMAIL_UNDELETE_MANY_MESSAGES_QUERY, aSelection.Count(), iCoeEnv );
       
  1675         undelete = CIMSSettingsNoteUi::ShowQueryL(
       
  1676             *promptText, R_EMAIL_CONFIRMATION_QUERY );
       
  1677         CleanupStack::PopAndDestroy( promptText );
       
  1678         }
       
  1679     else
       
  1680         {
       
  1681         undelete = CIMSSettingsNoteUi::ShowQueryL(
       
  1682             R_EMAIL_UNDELETE_MESSAGE_QUERY, R_EMAIL_CONFIRMATION_QUERY );
       
  1683         }
       
  1684     if ( undelete )
       
  1685         {
       
  1686         TBuf8<1> params;
       
  1687         params.Zero();
       
  1688         CMsvProgressReporterOperation* reporter =
       
  1689             CMsvProgressReporterOperation::NewL(
       
  1690             Session(), aStatus, EMbmAvkonQgn_note_progress );
       
  1691         CleanupStack::PushL(reporter);
       
  1692         reporter->SetTitleL( R_POP3_UNDELETING_IMAIL_PROGRESS );
       
  1693         reporter->SetSeeding(EFalse);
       
  1694         reporter->SetProgressVisibilityDelay( EFalse );
       
  1695         CMsvOperation* op = BaseMtm().InvokeAsyncFunctionL(
       
  1696             KPOP3MTMCancelOfflineOperations,
       
  1697             aSelection,
       
  1698             params,
       
  1699             reporter->RequestStatus());
       
  1700         reporter->SetOperationL(op); // Takes immediate ownership
       
  1701         CleanupStack::Pop(); // reporter
       
  1702         IMUM_OUT();
       
  1703         return reporter;
       
  1704         }
       
  1705     else
       
  1706         {
       
  1707         IMUM_OUT();
       
  1708         return CMsvCompletedOperation::NewL(
       
  1709             Session(),
       
  1710             Type(),
       
  1711             KNullDesC8,
       
  1712             KMsvLocalServiceIndexEntryId,
       
  1713             aStatus,
       
  1714             KErrCancel);
       
  1715         }
       
  1716     }
       
  1717 
       
  1718 // ----------------------------------------------------------------------------
       
  1719 // CPop3MtmUi::ForwardL()
       
  1720 // ----------------------------------------------------------------------------
       
  1721 //
       
  1722 CMsvOperation* CPop3MtmUi::ForwardL(
       
  1723     TMsvId aDestination,
       
  1724     TMsvPartList aPartList,
       
  1725     TRequestStatus& aCompletionStatus)
       
  1726     {
       
  1727     IMUM_CONTEXT( CPop3MtmUi::ForwardL, 0, KImumMtmLog );
       
  1728     IMUM_IN();
       
  1729     
       
  1730     // Context is the message to forward.
       
  1731     const TMsvEntry& entry = BaseMtm().Entry().Entry();
       
  1732     CheckEntryL(entry);
       
  1733     if(entry.iType.iUid != KUidMsvMessageEntryValue)
       
  1734         {
       
  1735         User::Leave(KErrNotSupported);
       
  1736         }
       
  1737     TEditorParameters editorParams;
       
  1738     editorParams.iFlags|=EMsgForwardMessage;
       
  1739     editorParams.iId = entry.Id();
       
  1740     editorParams.iPartList = aPartList;
       
  1741     editorParams.iDestinationFolderId = aDestination;
       
  1742     if(entry.Complete())
       
  1743         {
       
  1744         IMUM_OUT();
       
  1745         return LaunchEditorApplicationL(aCompletionStatus, editorParams);
       
  1746         }
       
  1747     IMUM_OUT();
       
  1748     return RetrieveAndEditMessageL(aCompletionStatus, editorParams);
       
  1749     }
       
  1750 
       
  1751 // ----------------------------------------------------------------------------
       
  1752 // CPop3MtmUi::ReplyL()
       
  1753 // ----------------------------------------------------------------------------
       
  1754 //
       
  1755 CMsvOperation* CPop3MtmUi::ReplyL(
       
  1756     TMsvId aDestination,
       
  1757     TMsvPartList aPartlist,
       
  1758     TRequestStatus& aCompletionStatus)
       
  1759     {
       
  1760     IMUM_CONTEXT( CPop3MtmUi::ReplyL, 0, KImumMtmLog );
       
  1761     IMUM_IN();
       
  1762     
       
  1763     // Context is the message to reply to.
       
  1764     TMsvEntry entry = BaseMtm().Entry().Entry();
       
  1765     CheckEntryL(entry);
       
  1766     if(entry.iType.iUid != KUidMsvMessageEntryValue)
       
  1767         {
       
  1768         User::Leave(KErrNotSupported);
       
  1769         }
       
  1770     TEditorParameters editorParams;
       
  1771     editorParams.iFlags|=(aPartlist&KMsvMessagePartRecipient)?
       
  1772         EMsgReplyToMessageAll:EMsgReplyToMessageSender;
       
  1773     editorParams.iId=entry.Id();
       
  1774     editorParams.iPartList = aPartlist;
       
  1775     editorParams.iDestinationFolderId = aDestination;
       
  1776 
       
  1777     if ( entry.Unread() )
       
  1778         {
       
  1779         entry.SetUnread( EFalse );
       
  1780 
       
  1781         CMuiuOperationWait* wait =
       
  1782             CMuiuOperationWait::NewLC( EActivePriorityDefault );
       
  1783         CMsvOperation* op = BaseMtm().Entry().ChangeL( entry, wait->iStatus );
       
  1784         wait->Start();
       
  1785         CleanupStack::PopAndDestroy( wait );
       
  1786         wait = NULL;
       
  1787 
       
  1788         delete op;
       
  1789         op = NULL;
       
  1790         }
       
  1791 
       
  1792     if(entry.Complete())
       
  1793         {
       
  1794         IMUM_OUT();
       
  1795         return LaunchEditorApplicationL(aCompletionStatus, editorParams);
       
  1796         }
       
  1797     IMUM_OUT();
       
  1798     return RetrieveAndEditMessageL(aCompletionStatus, editorParams);
       
  1799 }
       
  1800 
       
  1801 // ----------------------------------------------------------------------------
       
  1802 // CPop3MtmUi::RetrieveAndEditMessageL()
       
  1803 // ----------------------------------------------------------------------------
       
  1804 //
       
  1805 CMsvOperation* CPop3MtmUi::RetrieveAndEditMessageL(
       
  1806     TRequestStatus& aStatus,
       
  1807     const TEditorParameters& aEditorParams)
       
  1808     {
       
  1809     IMUM_CONTEXT( CPop3MtmUi::RetrieveAndEditMessageL, 0, KImumMtmLog );
       
  1810     IMUM_IN();
       
  1811     
       
  1812     // Context is irrelevant.
       
  1813     CMsvEntry* msgEntry = Session().GetEntryL(aEditorParams.iId);
       
  1814     CleanupStack::PushL(msgEntry);
       
  1815     const TMsvEntry& tentry = msgEntry->Entry();
       
  1816     const TMsvId destination = tentry.Parent();
       
  1817     
       
  1818     CMsvSession& session = Session();
       
  1819 
       
  1820     // Check available memory.
       
  1821     if( !MsvEmailMtmUiUtils::CheckAvailableDiskSpaceForDownloadL(
       
  1822             tentry.iSize, *iEikonEnv, session ) )
       
  1823         {
       
  1824         CleanupStack::PopAndDestroy();  // msgEntry
       
  1825         return CMsvCompletedOperation::NewL(
       
  1826             Session(),
       
  1827             Type(),
       
  1828             KNullDesC8,
       
  1829             KMsvLocalServiceIndexEntryId,
       
  1830             aStatus,
       
  1831             KErrCancel);
       
  1832         }
       
  1833 
       
  1834     // If not online, ask user.
       
  1835     msgEntry->SetEntryL(msgEntry->OwningService());
       
  1836     const TBool connected = msgEntry->Entry().Connected();
       
  1837     if(!connected)
       
  1838         {
       
  1839         // Prompt user.
       
  1840         if ( !CIMSSettingsNoteUi::ShowQueryL(
       
  1841             R_EMAIL_RETRIEVE_1_TEXT, R_EMAIL_CONFIRMATION_QUERY ) )
       
  1842             {
       
  1843             CleanupStack::PopAndDestroy();  // msgEntry
       
  1844             return CMsvCompletedOperation::NewL(
       
  1845                 Session(),
       
  1846                 Type(),
       
  1847                 KNullDesC8,
       
  1848                 KMsvLocalServiceIndexEntryId,
       
  1849                 aStatus,
       
  1850                 KErrNone);
       
  1851             }
       
  1852         }
       
  1853 
       
  1854     TMsvId id = msgEntry->Entry().Id();
       
  1855     CleanupStack::PopAndDestroy();  // msgEntry
       
  1856 
       
  1857     //Offline checks VARIATION START
       
  1858     if ( iFeatureFlags->GF( EMailFeatureOfflineMode ) )
       
  1859         {
       
  1860         TBool offline = EFalse;
       
  1861 
       
  1862         if( !connected &&
       
  1863             !iMailboxApi->MailboxUtilitiesL().HasWlanConnectionL( id ) )
       
  1864             {
       
  1865             offline = MsvEmailMtmUiUtils::DoOfflineChecksL( id );
       
  1866             }
       
  1867 
       
  1868         if( offline )
       
  1869             {
       
  1870             return CMsvCompletedOperation::NewL(Session(), Type(), KNullDesC8, KMsvLocalServiceIndexEntryId, aStatus, KErrCancel);
       
  1871             }
       
  1872         }//if
       
  1873     //VARIATION END
       
  1874 
       
  1875     const TBool ackReceipts = AcknowledgeReceiptsL(aEditorParams.iId);
       
  1876 
       
  1877     CMsvProgressReporterOperation* reporter =
       
  1878         CMsvProgressReporterOperation::NewL(
       
  1879             ETrue,
       
  1880             ETrue,
       
  1881             Session(),
       
  1882             aStatus,
       
  1883             EMbmAvkonQgn_note_progress );
       
  1884     CleanupStack::PushL(reporter);
       
  1885     
       
  1886     // If already connected, display the "Retrieving..." note right away.
       
  1887      
       
  1888     if ( connected )
       
  1889     	reporter->SetTitleL( R_POP3_POPULATING_SINGLE );
       
  1890     
       
  1891     else
       
  1892      	{
       
  1893      	TBuf<EProgressStringMaxLen> title;
       
  1894      	MsvEmailMtmUiUtils::CreateConnectingToText( title,
       
  1895              *iMsvSession, destination );
       
  1896      	reporter->SetTitleL( title );
       
  1897       	}
       
  1898     
       
  1899      HBufC* appName = (aEditorParams.iFlags & EMsgReadOnly) ? (GetViewerFileNameL()) : (GetEditorFileNameL());
       
  1900     TEmailEditParams fetchAndEditParams;
       
  1901     fetchAndEditParams.iPreferences = Preferences();
       
  1902     fetchAndEditParams.iEditorFileName = *appName;
       
  1903     fetchAndEditParams.iEditorParams = aEditorParams;
       
  1904 
       
  1905     if(fetchAndEditParams.iPreferences & EMtmUiFlagEditorPreferEmbedded)
       
  1906         {
       
  1907         fetchAndEditParams.iEditorParams.iFlags |= EMsgLaunchEditorEmbedded;
       
  1908         }
       
  1909     if(!(fetchAndEditParams.iPreferences & EMtmUiFlagEditorNoWaitForExit))
       
  1910         {
       
  1911         fetchAndEditParams.iEditorParams.iFlags |= EMsgLaunchEditorThenWait;
       
  1912         }
       
  1913 
       
  1914     CImumFetchAndEditOperation* fetchAndEdit =
       
  1915         CImumFetchAndEditOperation::NewL(
       
  1916         *iMailboxApi,
       
  1917         reporter->RequestStatus(),
       
  1918         *reporter,
       
  1919         fetchAndEditParams,
       
  1920         ackReceipts);
       
  1921     CleanupStack::PushL(fetchAndEdit);
       
  1922 
       
  1923     CMsvEntrySelection* sel = SingleEntrySelectionLC(aEditorParams.iId);
       
  1924     TImPop3GetMailInfo info;
       
  1925     info.iMaxEmailSize = KMaxTInt32;
       
  1926     info.iDestinationFolder = destination;
       
  1927     CMsvPop3FetchOperation* fetch =
       
  1928         CMsvPop3FetchOperation::NewL(
       
  1929         *iMailboxApi,
       
  1930         fetchAndEdit->RequestStatus(),
       
  1931         *reporter,
       
  1932         KFunctionIdFetchSelected,
       
  1933         destination,
       
  1934         info,
       
  1935         *sel);
       
  1936     CleanupStack::PopAndDestroy();      // sel
       
  1937 
       
  1938     fetchAndEdit->SetFetchOpL(fetch);
       
  1939     CleanupStack::Pop();    // fetchAndEdit
       
  1940     reporter->SetOperationL(fetchAndEdit); // Takes immediate ownership
       
  1941     CleanupStack::Pop(); // reporter
       
  1942     IMUM_OUT();
       
  1943     return reporter;
       
  1944     }
       
  1945 
       
  1946 // ----------------------------------------------------------------------------
       
  1947 // CPop3MtmUi::GetMailL()
       
  1948 // ----------------------------------------------------------------------------
       
  1949 //
       
  1950 CMsvOperation* CPop3MtmUi::GetMailL(TRequestStatus& aStatus)
       
  1951     {
       
  1952     IMUM_CONTEXT( CPop3MtmUi::GetMailL, 0, KImumMtmLog );
       
  1953     IMUM_IN();
       
  1954     
       
  1955     // Client MTM context is service.
       
  1956     const TMsvEntry& entry = BaseMtm().Entry().Entry();
       
  1957     CheckEntryL(entry);
       
  1958     if(entry.iType.iUid != KUidMsvServiceEntryValue)
       
  1959         {
       
  1960         User::Leave(KErrNotSupported);
       
  1961         }
       
  1962     const TMsvId serviceId = entry.Id();
       
  1963     const CImPop3Settings& settings = GetAccountSettingsL(serviceId);
       
  1964     const TPop3GetMailOptions opts = settings.GetMailOptions();
       
  1965 
       
  1966     //limit for for connect operation to be used with populate
       
  1967     TInt limit = settings.PopulationLimit();
       
  1968     // -1 means body and attachment, pass it to Symbian mail engine
       
  1969     if ( limit != -1 )
       
  1970         {
       
  1971         limit = ( limit * KImumKB ) / KImumMaxCharsInLine;
       
  1972         }
       
  1973 
       
  1974     CMsvProgressReporterOperation* reporter =
       
  1975         CMsvProgressReporterOperation::NewL(
       
  1976         Session(), aStatus, EMbmAvkonQgn_note_progress);
       
  1977     CleanupStack::PushL(reporter);
       
  1978 
       
  1979     CMsvOperation* op = NULL;
       
  1980     switch(opts)
       
  1981         {
       
  1982         case EGetPop3EmailHeaders:
       
  1983             {
       
  1984             op = CMsvPop3ConnectOp::NewL(
       
  1985                 reporter->RequestStatus(),
       
  1986                 *reporter,
       
  1987                 serviceId,
       
  1988                 limit);
       
  1989             TBuf<EProgressStringMaxLen> buffer;
       
  1990             FormatConnectingServerProgressTextL( serviceId, buffer );
       
  1991             reporter->SetTitleL( buffer );
       
  1992             reporter->SetSeeding( ETrue );
       
  1993             }
       
  1994             break;
       
  1995 
       
  1996         case EGetPop3EmailMessages:
       
  1997             {
       
  1998             TImPop3GetMailInfo info;
       
  1999             info.iMaxEmailSize = settings.MaxEmailSize();
       
  2000             info.iDestinationFolder = serviceId;
       
  2001 
       
  2002             CMsvEntrySelection* sel = new(ELeave) CMsvEntrySelection;
       
  2003             CleanupStack::PushL(sel);
       
  2004 
       
  2005             op = CMsvPop3FetchOperation::NewL(
       
  2006                 *iMailboxApi,
       
  2007                 reporter->RequestStatus(),
       
  2008                 *reporter,
       
  2009                 KFunctionIdFetchNew,
       
  2010                 serviceId,
       
  2011                 info,
       
  2012                 *sel);
       
  2013             CleanupStack::PopAndDestroy();      // sel
       
  2014             }
       
  2015             break;
       
  2016 
       
  2017         default:
       
  2018             break;
       
  2019         }
       
  2020     reporter->SetOperationL(op); // Takes immediate ownership
       
  2021     CleanupStack::Pop(); // reporter
       
  2022     IMUM_OUT();
       
  2023     return reporter;
       
  2024     }
       
  2025 
       
  2026 // ----------------------------------------------------------------------------
       
  2027 // CPop3MtmUi::FetchL()
       
  2028 // ----------------------------------------------------------------------------
       
  2029 //
       
  2030 CMsvOperation* CPop3MtmUi::FetchL(
       
  2031     TRequestStatus& aStatus,
       
  2032     const CMsvEntrySelection& aSel,
       
  2033     TInt aFunctionId )
       
  2034     {
       
  2035     IMUM_CONTEXT( CPop3MtmUi::FetchL, 0, KImumMtmLog );
       
  2036     IMUM_IN();
       
  2037     
       
  2038     // Client MTM context is service.
       
  2039     const TMsvEntry& serviceEntry = BaseMtm().Entry().Entry();
       
  2040     CheckEntryL( serviceEntry );
       
  2041     if ( serviceEntry.iType.iUid != KUidMsvServiceEntryValue )
       
  2042         {
       
  2043         User::Leave(KErrNotSupported);
       
  2044         }
       
  2045 
       
  2046     // Create reporter instance to keep track of the process
       
  2047     CMsvProgressReporterOperation* reporter =
       
  2048         CMsvProgressReporterOperation::NewL( ETrue, ETrue, Session(), aStatus,
       
  2049             EMbmAvkonQgn_note_progress );
       
  2050     CleanupStack::PushL( reporter );
       
  2051 
       
  2052     // Prepare the parameters to fetch operation
       
  2053     TImPop3GetMailInfo info;
       
  2054     info.iMaxEmailSize = KMaxTInt32;
       
  2055     info.iDestinationFolder = serviceEntry.Id();
       
  2056 
       
  2057     // Create the actual fetching operation
       
  2058     CMsvOperation* op = CMsvPop3FetchOperation::NewL( *iMailboxApi,
       
  2059         reporter->RequestStatus(), *reporter, aFunctionId,
       
  2060         info.iDestinationFolder, info, aSel );
       
  2061 
       
  2062     reporter->SetOperationL( op ); // Takes immediate ownership
       
  2063     CleanupStack::Pop(); // reporter
       
  2064     IMUM_OUT();
       
  2065     return reporter;
       
  2066     }
       
  2067 
       
  2068 // ----------------------------------------------------------------------------
       
  2069 // CPop3MtmUi::GetAccountSettingsL()
       
  2070 // ----------------------------------------------------------------------------
       
  2071 //
       
  2072 const CImPop3Settings& CPop3MtmUi::GetAccountSettingsL(TMsvId aId) const
       
  2073     {
       
  2074     IMUM_CONTEXT( CPop3MtmUi::GetAccountSettingsL, 0, KImumMtmLog );
       
  2075     IMUM_IN();
       
  2076     
       
  2077     CPop3ClientMtm& clientMtm = Pop3ClientMtm();
       
  2078     if(clientMtm.HasContext())
       
  2079         {
       
  2080         if(clientMtm.Entry().EntryId() != aId)
       
  2081             {
       
  2082             clientMtm.SwitchCurrentEntryL(aId);
       
  2083             }
       
  2084         }
       
  2085     else
       
  2086         {
       
  2087         clientMtm.SetCurrentEntryL(Session().GetEntryL(aId));
       
  2088         }
       
  2089     clientMtm.RestoreSettingsL();
       
  2090     IMUM_OUT();
       
  2091     return clientMtm.Settings();
       
  2092     }
       
  2093