email/imum/Mtms/Inc/ImapConnectionOp.h
branchRCL_3
changeset 60 7fdbb852d323
parent 0 72b543305e3a
equal deleted inserted replaced
57:ebe688cedc25 60:7fdbb852d323
       
     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 *       CImapConnectionOp declaration file
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef __IMAPCONNECTIONOP_H__
       
    20 #define __IMAPCONNECTIONOP_H__
       
    21 
       
    22 #include <msvapi.h>
       
    23 #include <imapset.h>
       
    24 #include "imapconnectionobserver.h"
       
    25 #include <mtmuibas.h>
       
    26 #include <MTMStore.h>
       
    27 #include <MsvPrgReporter.h>
       
    28 #include <imapconnectcompletionstates.h>
       
    29 #include <MuiuMsvSingleOpWatcher.h>
       
    30 #include <ImumInternalApi.h>
       
    31 
       
    32 //  Forward declarations
       
    33 //
       
    34 class CMsvEmailConnectionProgressProvider;
       
    35 class CCoeEnv;
       
    36 
       
    37 /**
       
    38 * class CImapConnectionOp
       
    39 *
       
    40 */
       
    41 class CImapConnectionOp :
       
    42     public CMsvOperation,
       
    43     public MMsvImapConnectionObserver,
       
    44     public MMsvProgressDecoder,
       
    45     public MMsvSingleOpWatcher
       
    46     {
       
    47     public:
       
    48 
       
    49         enum TImapConnectionType
       
    50             {
       
    51             ECompleteAfterConnect,
       
    52             EWithSyncCompleteAfterConnect,
       
    53             EWithSyncCompleteAfterFullSync,
       
    54             EWithSyncCompleteAfterDisconnection
       
    55             };
       
    56 
       
    57         /**
       
    58         * NewL()
       
    59         * Basic factory function - creates dialog with standard title resource
       
    60         * @param CMsvSession& CMsvSession reference
       
    61         * @param TInt priority
       
    62         * @param TRequestStatus& request status
       
    63         * @param TMsvId service (mailbox) id
       
    64         * @param MMsvProgressReporter& prog. reporter reference
       
    65         * @param TImapConnectionType connection type
       
    66         * @return CImapConnectionOp* self pointer
       
    67         */
       
    68         static CImapConnectionOp* NewL(
       
    69             CMsvSession& aMsvSession,
       
    70             TInt aPriority,
       
    71             TRequestStatus& aStatus,
       
    72             TMsvId aService,
       
    73             MMsvProgressReporter& aProgressReporter,
       
    74             TImapConnectionType aConnectionType);
       
    75 
       
    76         /**
       
    77         * ~CImapConnectionOp()
       
    78         * destructor
       
    79         */
       
    80         ~CImapConnectionOp();
       
    81 
       
    82         /**
       
    83         * ProgressL()
       
    84         * @return TDesC8&, progress
       
    85         */
       
    86         const TDesC8& ProgressL();
       
    87 
       
    88         /**
       
    89         * HandleImapConnectionEvent()
       
    90         * From MMsvImapConnectionObserver
       
    91         * @param TImapConnectionEvent, imap connection event
       
    92         */
       
    93         virtual void HandleImapConnectionEvent(
       
    94             TImapConnectionEvent aConnectionEvent);
       
    95 
       
    96         /**
       
    97         * DecodeProgress()
       
    98         * From MMsvProgressDecoder
       
    99         * @param TDesC8& progress
       
   100         * @param TBuf<CBaseMtmUi::EProgressStringMaxLen>&, return string
       
   101         * @param TInt&, total entry count
       
   102         * @param TInt& entries done
       
   103         * @param TInt& current entry size
       
   104         * @param TInt& current bytes transferred
       
   105         * @param TBool internal flag
       
   106         */
       
   107         virtual TInt DecodeProgress(
       
   108             const TDesC8& aProgress,
       
   109             TBuf<CBaseMtmUi::EProgressStringMaxLen>& aReturnString,
       
   110             TInt& aTotalEntryCount,
       
   111             TInt& aEntriesDone,
       
   112             TInt& aCurrentEntrySize,
       
   113             TInt& aCurrentBytesTrans,
       
   114             TBool aInternal);
       
   115 
       
   116         /**
       
   117         * OpCompleted()
       
   118         * From MMsvSingleOpWatcher
       
   119         * @param CMsvSingleOpWatcher& opwatcher which completed
       
   120         * @param TInt, completion code
       
   121         */
       
   122         virtual void OpCompleted(
       
   123             CMsvSingleOpWatcher& aOpWatcher,
       
   124             TInt aCompletionCode );
       
   125 
       
   126     private:
       
   127 
       
   128         enum TImapConnectionState
       
   129             {
       
   130             EConstructing,
       
   131             EEstablishingConnection,
       
   132             EUpdatingFolderList,
       
   133             EUpdatingInbox,
       
   134             EUpdatingFolders,
       
   135             EOnline,
       
   136             ECompleted
       
   137             };
       
   138 
       
   139         /**
       
   140         * CImapConnectionOp()
       
   141         * @param CMsvSession&, CMsvSession reference
       
   142         * @param TInt, priority
       
   143         * @param TRequestStatus&, request status
       
   144         * @param TMsvId, service ( mailbox ) id
       
   145         * @param MMsvProgressReporter&, prog. reporter
       
   146         * @param TImapConnectionType, connection type
       
   147         */
       
   148         CImapConnectionOp(
       
   149             CMsvSession& aMsvSession,
       
   150             TInt aPriority,
       
   151             TRequestStatus& aStatus,
       
   152             TMsvId aService,
       
   153             MMsvProgressReporter& aProgressReporter,
       
   154             TImapConnectionType aConnectionType );
       
   155 
       
   156         /**
       
   157         * ConstructL()
       
   158         */
       
   159         void ConstructL();
       
   160 
       
   161 
       
   162         /**
       
   163         * GetConnectionOperationL()
       
   164         * Generate the appropriate type of connection operation
       
   165         * @return CMsvOperation*, operation
       
   166         */
       
   167         CMsvOperation* GetConnectionOperationL();
       
   168 
       
   169         /**
       
   170         * DecodeConnectionProgress()
       
   171         * @param TDesC8& progress
       
   172         * @param TBuf<CBaseMtmUi::EProgressStringMaxLen>&, return string
       
   173         * @param TInt&, total entry count
       
   174         * @param TInt& entries done
       
   175         * @param TInt& current entry size
       
   176         * @param TInt& current bytes transferred
       
   177         */
       
   178         TInt DecodeConnectionProgress(
       
   179             const TDesC8& aProgress,
       
   180             TBuf<CBaseMtmUi::EProgressStringMaxLen>& aReturnString,
       
   181             TInt& aTotalEntryCount,
       
   182             TInt& aEntriesDone,
       
   183             TInt& aCurrentEntrySize,
       
   184             TInt& aCurrentBytesTrans);
       
   185 
       
   186         /**
       
   187         * RunL()
       
   188         */
       
   189         virtual void RunL();
       
   190 
       
   191         /**
       
   192         * DoRunL()
       
   193         */
       
   194         void DoRunL();
       
   195 
       
   196         /**
       
   197         * FinishConstructionL()
       
   198         */
       
   199         void FinishConstructionL();
       
   200 
       
   201         /**
       
   202         * ConnectionCompletionL()
       
   203         */
       
   204         void ConnectionCompletionL();
       
   205 
       
   206         /**
       
   207         * DoCancel()
       
   208         */
       
   209         virtual void DoCancel();
       
   210 
       
   211         /**
       
   212         * Complete()
       
   213         */
       
   214         void Complete();
       
   215         
       
   216         /**
       
   217         * RunError()
       
   218         */
       
   219 		virtual TInt RunError(TInt aError);                       
       
   220 
       
   221     private: //Data
       
   222         //Owned
       
   223         CImumInternalApi*                       iMailboxApi;
       
   224         CMsvOperation*                          iSubOperation;
       
   225         CMsvEmailConnectionProgressProvider*    iConnectionProgressProvider;
       
   226         TImapConnectionState                    iState;
       
   227         TImapConnectionType                     iConnectionType;
       
   228         TPckgBuf<TImap4SyncProgress>            iSyncProgress;
       
   229         MMsvProgressReporter&                   iProgressReporter;
       
   230         CBaseMtmUi*                             iMtmUi;
       
   231         HBufC*                                  iTitleText;
       
   232         HBufC*                                  iConnectionText;
       
   233         TMsvId                                  iRelatedServiceId;
       
   234         CCoeEnv*                                iCoeEnv;
       
   235         TInt                                    iLoginRetryCounter;
       
   236 
       
   237       //  CMsvSingleOpWatcherArray                iOperations;//for more operations
       
   238     };
       
   239 
       
   240 #endif