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