ipsservices/ipssosplugin/src/ipsplgconnectandrefreshfolderlist.cpp
changeset 0 8466d47a6819
child 3 a4d6f1ea0416
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     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 *       folder refresh operation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "emailtrace.h"
       
    21 #include "ipsplgheaders.h"
       
    22 
       
    23 #include <ipssossettings.rsg>
       
    24 
       
    25 // ----------------------------------------------------------------------------
       
    26 // ----------------------------------------------------------------------------
       
    27 EXPORT_C CIpsPlgConnectAndRefreshFolderList* 
       
    28             CIpsPlgConnectAndRefreshFolderList::NewL(
       
    29                     CMsvSession& aSession, 
       
    30                     TInt aPriority, 
       
    31                     TRequestStatus& aObserverRequestStatus,
       
    32                     TMsvId aService, 
       
    33                     TFSMailMsgId& aMailboxId, 
       
    34                     CMsvEntrySelection& aMsvEntry, 
       
    35                     MFSMailRequestObserver& aFSObserver, 
       
    36                     CIpsPlgTimerOperation& aTimer )
       
    37     {
       
    38     FUNC_LOG;
       
    39     CIpsPlgConnectAndRefreshFolderList* self=
       
    40         new (ELeave) CIpsPlgConnectAndRefreshFolderList( 
       
    41                 aSession, 
       
    42                 aPriority, 
       
    43                 aObserverRequestStatus, 
       
    44                 aService, 
       
    45                 aMailboxId, 
       
    46                 aFSObserver, 
       
    47                 aTimer );
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL( aMsvEntry );
       
    50     CleanupStack::Pop( self );
       
    51     return self;
       
    52     }
       
    53 
       
    54 // ----------------------------------------------------------------------------
       
    55 // ----------------------------------------------------------------------------
       
    56 CIpsPlgConnectAndRefreshFolderList::CIpsPlgConnectAndRefreshFolderList(
       
    57     CMsvSession& aSession, 
       
    58     TInt aPriority, 
       
    59     TRequestStatus& aObserverRequestStatus,
       
    60     TMsvId aService, 
       
    61     TFSMailMsgId& aMailboxId, 
       
    62     MFSMailRequestObserver& aFSObserver,
       
    63     CIpsPlgTimerOperation& aTimer )
       
    64 	:
       
    65 	CIpsPlgOnlineOperation(
       
    66 	        aSession,
       
    67 	        aPriority,
       
    68 	        aObserverRequestStatus,
       
    69 	        aTimer,
       
    70 	        aMailboxId,
       
    71 	        aFSObserver,
       
    72 	        0, // FSRequestId
       
    73 	        EFalse), // SignallingAllowed
       
    74 	iState( EIdle ),
       
    75 	iMailboxId( aMailboxId ),
       
    76     iSession( aSession ),
       
    77     iService( aService ),
       
    78     iOperation( NULL ),
       
    79     iTimer( NULL ),
       
    80     iMsvEntry( NULL ),
       
    81     iObserverRequestStatus( aObserverRequestStatus )
       
    82     {
       
    83     FUNC_LOG;
       
    84     }
       
    85 
       
    86 // ----------------------------------------------------------------------------
       
    87 // ----------------------------------------------------------------------------
       
    88 void CIpsPlgConnectAndRefreshFolderList::ConstructL( 
       
    89         CMsvEntrySelection& aMsvEntry )
       
    90     {
       
    91     FUNC_LOG;
       
    92     BaseConstructL( KSenduiMtmImap4Uid );
       
    93     iMsvEntry = aMsvEntry.CopyL();    
       
    94     iState = EStartConnect;
       
    95     DoRunL();
       
    96     
       
    97     }
       
    98 
       
    99 // ----------------------------------------------------------------------------
       
   100 // ----------------------------------------------------------------------------
       
   101 CIpsPlgConnectAndRefreshFolderList::~CIpsPlgConnectAndRefreshFolderList()
       
   102     {
       
   103     FUNC_LOG;
       
   104     Cancel();
       
   105     delete iMsvEntry;
       
   106     delete iOperation;
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 void CIpsPlgConnectAndRefreshFolderList::StepL()
       
   113     {
       
   114     FUNC_LOG;
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 TBool CIpsPlgConnectAndRefreshFolderList::IsProcessDone() const
       
   121     {
       
   122     FUNC_LOG;
       
   123     TBool ret = EFalse;
       
   124     if ( iState == ECompleted )
       
   125         {
       
   126         ret = ETrue;
       
   127         }
       
   128     return ret;
       
   129     }
       
   130 
       
   131 // ---------------------------------------------------------------------------
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 void CIpsPlgConnectAndRefreshFolderList::DialogDismissedL(TInt /*aButtonId*/) 
       
   135     {
       
   136     FUNC_LOG;
       
   137     }
       
   138 
       
   139 // ----------------------------------------------------------------------------
       
   140 // ----------------------------------------------------------------------------
       
   141 const TDesC8& CIpsPlgConnectAndRefreshFolderList::ProgressL()
       
   142     {
       
   143     FUNC_LOG;
       
   144     return iProgressBuf;
       
   145     }
       
   146 
       
   147 // ----------------------------------------------------------------------------
       
   148 // ----------------------------------------------------------------------------
       
   149 const TDesC8& CIpsPlgConnectAndRefreshFolderList::GetErrorProgressL( 
       
   150         TInt aError )
       
   151     {
       
   152     FUNC_LOG;
       
   153     TImap4CompoundProgress& prog = iProgressBuf();
       
   154     prog.iGenericProgress.iErrorCode = aError;
       
   155     return iProgressBuf;
       
   156     }
       
   157 
       
   158 // ----------------------------------------------------------------------------
       
   159 // ----------------------------------------------------------------------------
       
   160 TFSProgress CIpsPlgConnectAndRefreshFolderList::GetFSProgressL() const
       
   161     {
       
   162     FUNC_LOG;
       
   163     // Hardly ever called
       
   164     return TFSProgress();
       
   165     }
       
   166     
       
   167 // ----------------------------------------------------------------------------
       
   168 // ----------------------------------------------------------------------------
       
   169 void CIpsPlgConnectAndRefreshFolderList::DoRunL()
       
   170     {
       
   171     FUNC_LOG;
       
   172     MFSMailRequestObserver* observer = NULL;
       
   173     
       
   174     if( iStatus.Int() != KErrNone )
       
   175         {
       
   176         iState = ECompleted;
       
   177         CompleteObserver();
       
   178         return;
       
   179         }
       
   180     
       
   181     switch(iState)
       
   182         {
       
   183         case EStartConnect:
       
   184             delete iOperation;
       
   185             iOperation = NULL;
       
   186             iOperation = CIpsPlgImap4ConnectOp::NewL(
       
   187                             iSession,
       
   188                             CActive::EPriorityStandard,
       
   189                             iStatus,
       
   190                             iService,
       
   191                             *iTimer,
       
   192                             iMailboxId,
       
   193                             *observer,
       
   194                             NULL, //FSRequestId
       
   195                             NULL, // Event handler
       
   196                             ETrue, // Plain connect
       
   197                             EFalse ); // No signalling needed )
       
   198             iState = EConnecting;
       
   199             SetActive();
       
   200             break;
       
   201 	    case EConnecting:
       
   202 	        {
       
   203 	        //  We have successfully completed connecting
       
   204 	        TBuf8<1> dummyParam;
       
   205 	        delete iOperation;
       
   206 	        iOperation = NULL;
       
   207 	        InvokeClientMtmAsyncFunctionL( 
       
   208 	                    KIMAP4MTMSyncTree, 
       
   209 	                    *iMsvEntry,
       
   210 	                    iService,
       
   211 	                    dummyParam ); 
       
   212 	        iState = ERefreshing;
       
   213 	        SetActive();
       
   214 	        }
       
   215 	        break;
       
   216 	    case ERefreshing:
       
   217 	        //  We have successfully completed refreshing the folder list
       
   218 	        delete iOperation;
       
   219 	        iOperation = NULL;
       
   220 	        iOperation = CIpsPlgDisconnectOp::NewL( 
       
   221 	                        iSession, 
       
   222 	                        iStatus, 
       
   223 	                        iService, 
       
   224 	                        *iTimer,
       
   225 	                        iMailboxId, 
       
   226 	                        *observer, 
       
   227 	                        NULL );
       
   228 	        iState = EDisconnecting;
       
   229 	        SetActive();
       
   230 	        break;
       
   231 	    case EDisconnecting:
       
   232 	        iState = ECompleted;
       
   233 	        CompleteObserver();
       
   234 	        break;
       
   235 	    default:
       
   236 	        User::Panic( KIpsPlgPanicCategory, EIpsPlgNoParameters );
       
   237 	    	break;
       
   238         }
       
   239     }
       
   240 
       
   241 // ----------------------------------------------------------------------------
       
   242 // CIpsPlgOnlineOperation::DoCancel()
       
   243 // ----------------------------------------------------------------------------
       
   244 //
       
   245 void CIpsPlgConnectAndRefreshFolderList::DoCancel()
       
   246     {
       
   247     FUNC_LOG;
       
   248     if( iOperation )
       
   249         {
       
   250         iOperation->Cancel();
       
   251         }
       
   252     CompleteObserver( KErrCancel );
       
   253     iState = ECompleted;
       
   254     }
       
   255 
       
   256 // End of File
       
   257