ipsservices/ipssosplugin/src/ipsplgconnectandrefreshfolderlist.cpp
branchRCL_3
changeset 24 d189ee25cf9d
parent 11 0396474f30f5
child 25 3533d4323edc
equal deleted inserted replaced
23:dcf0eedfc1a3 24:d189ee25cf9d
    15 *       folder refresh operation
    15 *       folder refresh operation
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 #include <aknmessagequerydialog.h>
    20 // <qmail> aknmessagequerydialog include removed
    21 
    21 
    22 #include "emailtrace.h"
    22 #include "emailtrace.h"
    23 #include "ipsplgheaders.h"
    23 #include "ipsplgheaders.h"
    24 
    24 
    25 #include <ipssossettings.rsg>
    25 // <qmail> ipssossettings rsg removed
    26 #include <fsmailserver.rsg>     // For R_FS_MSERVER_*
    26 // <qmail> fsmailserver rsg removed
    27 
    27 
    28 // ----------------------------------------------------------------------------
    28 // ----------------------------------------------------------------------------
    29 // ----------------------------------------------------------------------------
    29 // ----------------------------------------------------------------------------
    30 EXPORT_C CIpsPlgConnectAndRefreshFolderList* 
    30 // <qmail> priority parameter removed, aSelection moved from ConstructL -> constructor
    31             CIpsPlgConnectAndRefreshFolderList::NewL(
    31 // <qmail> MFSMailRequestObserver& changed to pointer
    32                     CMsvSession& aSession, 
    32 // <qmail> renamed selection parameter
    33                     TInt aPriority, 
    33 CIpsPlgConnectAndRefreshFolderList* CIpsPlgConnectAndRefreshFolderList::NewL(
    34                     TRequestStatus& aObserverRequestStatus,
       
    35                     TMsvId aService, 
       
    36                     TFSMailMsgId& aMailboxId, 
       
    37                     CMsvEntrySelection& aMsvEntry, 
       
    38                     MFSMailRequestObserver& aFSObserver, 
       
    39                     CIpsPlgTimerOperation& aTimer )
       
    40     {
       
    41     FUNC_LOG;
       
    42     CIpsPlgConnectAndRefreshFolderList* self=
       
    43         new (ELeave) CIpsPlgConnectAndRefreshFolderList( 
       
    44                 aSession, 
       
    45                 aPriority, 
       
    46                 aObserverRequestStatus, 
       
    47                 aService, 
       
    48                 aMailboxId, 
       
    49                 aFSObserver, 
       
    50                 aTimer );
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL( aMsvEntry );
       
    53     CleanupStack::Pop( self );
       
    54     return self;
       
    55     }
       
    56 
       
    57 // ----------------------------------------------------------------------------
       
    58 // ----------------------------------------------------------------------------
       
    59 CIpsPlgConnectAndRefreshFolderList::CIpsPlgConnectAndRefreshFolderList(
       
    60     CMsvSession& aSession, 
    34     CMsvSession& aSession, 
    61     TInt aPriority, 
       
    62     TRequestStatus& aObserverRequestStatus,
    35     TRequestStatus& aObserverRequestStatus,
    63     TMsvId aService, 
    36     TMsvId aService, 
    64     TFSMailMsgId& aMailboxId, 
    37     TFSMailMsgId& aMailboxId, 
    65     MFSMailRequestObserver& aFSObserver,
    38     CMsvEntrySelection* aSelection, 
       
    39     MFSMailRequestObserver* aFSObserver, 
    66     CIpsPlgTimerOperation& aTimer )
    40     CIpsPlgTimerOperation& aTimer )
    67     :
    41     {
    68     CIpsPlgOnlineOperation(
    42     FUNC_LOG;
    69             aSession,
    43     CIpsPlgConnectAndRefreshFolderList* self = new (ELeave) CIpsPlgConnectAndRefreshFolderList( 
    70             aPriority,
    44         aSession, 
    71             aObserverRequestStatus,
    45         aObserverRequestStatus, 
    72             aTimer,
    46         aService, 
    73             aMailboxId,
    47         aMailboxId, 
    74             aFSObserver,
    48         aSelection,
    75             0, // FSRequestId
    49         aFSObserver, 
    76             EFalse), // SignallingAllowed
    50         aTimer );
    77     iState( EIdle ),
    51     CleanupStack::PushL( self );
    78     iTimer( NULL ),
    52     self->ConstructL();
    79     iMsvEntry( NULL )
    53     CleanupStack::Pop( self );
       
    54     return self;
       
    55     }
       
    56 
       
    57 // ----------------------------------------------------------------------------
       
    58 // ----------------------------------------------------------------------------
       
    59 // <qmail> priority parameter removed, aSelection moved from ConstructL -> constructor
       
    60 // <qmail> MFSMailRequestObserver& changed to pointer
       
    61 // <qmail> renamed selection parameter
       
    62 CIpsPlgConnectAndRefreshFolderList::CIpsPlgConnectAndRefreshFolderList(
       
    63     CMsvSession& aSession, 
       
    64     TRequestStatus& aObserverRequestStatus,
       
    65     TMsvId aService, 
       
    66     TFSMailMsgId& aMailboxId, 
       
    67     CMsvEntrySelection* aSelection,
       
    68     MFSMailRequestObserver* aFSObserver,
       
    69     CIpsPlgTimerOperation& aTimer )
       
    70 	:
       
    71 	CIpsPlgOnlineOperation(
       
    72         aSession,
       
    73         aObserverRequestStatus,
       
    74         aTimer,
       
    75         aMailboxId,
       
    76         aFSObserver,
       
    77         0 ), // requestId
       
    78 	iState( EIdle ),
       
    79     iSelection( aSelection )
    80     {
    80     {
    81     FUNC_LOG;
    81     FUNC_LOG;
    82     iService = aService;
    82     iService = aService;
    83     }
    83     }
    84 
    84 
    85 // ----------------------------------------------------------------------------
    85 // ----------------------------------------------------------------------------
    86 // ----------------------------------------------------------------------------
    86 // ----------------------------------------------------------------------------
    87 void CIpsPlgConnectAndRefreshFolderList::ConstructL( 
    87 // <qmail> aMsvEntry removed
    88         CMsvEntrySelection& aMsvEntry )
    88 void CIpsPlgConnectAndRefreshFolderList::ConstructL()
    89     {
    89     {
    90     FUNC_LOG;
    90     FUNC_LOG;
    91     BaseConstructL( KSenduiMtmImap4Uid );
    91     BaseConstructL( KSenduiMtmImap4Uid );
    92     iMsvEntry = aMsvEntry.CopyL();    
       
    93     iState = EStartConnect;
    92     iState = EStartConnect;
    94     DoRunL();
    93     DoRunL();
    95     }
    94     }
    96 
    95 
    97 // ----------------------------------------------------------------------------
    96 // ----------------------------------------------------------------------------
    98 // ----------------------------------------------------------------------------
    97 // ----------------------------------------------------------------------------
    99 CIpsPlgConnectAndRefreshFolderList::~CIpsPlgConnectAndRefreshFolderList()
    98 CIpsPlgConnectAndRefreshFolderList::~CIpsPlgConnectAndRefreshFolderList()
   100     {
    99     {
   101     FUNC_LOG;
   100     FUNC_LOG;
   102     Cancel();
   101     Cancel();
   103     delete iMsvEntry;
   102     delete iSelection;
   104     }
   103     }
   105 
   104 
   106 // ---------------------------------------------------------------------------
   105 // <qmail> removed 3 functions from MAknBackgroundProcess
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 void CIpsPlgConnectAndRefreshFolderList::StepL()
       
   110     {
       
   111     FUNC_LOG;
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 TBool CIpsPlgConnectAndRefreshFolderList::IsProcessDone() const
       
   118     {
       
   119     FUNC_LOG;
       
   120     TBool ret = EFalse;
       
   121     if ( iState == ECompleted )
       
   122         {
       
   123         ret = ETrue;
       
   124         }
       
   125     return ret;
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 void CIpsPlgConnectAndRefreshFolderList::DialogDismissedL(TInt /*aButtonId*/) 
       
   132     {
       
   133     FUNC_LOG;
       
   134     }
       
   135 
   106 
   136 // ----------------------------------------------------------------------------
   107 // ----------------------------------------------------------------------------
   137 // ----------------------------------------------------------------------------
   108 // ----------------------------------------------------------------------------
   138 const TDesC8& CIpsPlgConnectAndRefreshFolderList::ProgressL()
   109 const TDesC8& CIpsPlgConnectAndRefreshFolderList::ProgressL()
   139     {
   110     {
   141     return iProgressBuf;
   112     return iProgressBuf;
   142     }
   113     }
   143 
   114 
   144 // ----------------------------------------------------------------------------
   115 // ----------------------------------------------------------------------------
   145 // ----------------------------------------------------------------------------
   116 // ----------------------------------------------------------------------------
   146 const TDesC8& CIpsPlgConnectAndRefreshFolderList::GetErrorProgressL( 
   117 const TDesC8& CIpsPlgConnectAndRefreshFolderList::GetErrorProgressL( TInt aError )
   147         TInt aError )
       
   148     {
   118     {
   149     FUNC_LOG;
   119     FUNC_LOG;
   150     TImap4CompoundProgress& prog = iProgressBuf();
   120     TImap4CompoundProgress& prog = iProgressBuf();
   151     prog.iGenericProgress.iErrorCode = aError;
   121     prog.iGenericProgress.iErrorCode = aError;
   152     return iProgressBuf;
   122     return iProgressBuf;
   164 // ----------------------------------------------------------------------------
   134 // ----------------------------------------------------------------------------
   165 // ----------------------------------------------------------------------------
   135 // ----------------------------------------------------------------------------
   166 void CIpsPlgConnectAndRefreshFolderList::DoRunL()
   136 void CIpsPlgConnectAndRefreshFolderList::DoRunL()
   167     {
   137     {
   168     FUNC_LOG;
   138     FUNC_LOG;
   169     MFSMailRequestObserver* observer = NULL;
       
   170     int err = iStatus.Int();
       
   171     
   139     
   172     if ( err != KErrNone )
   140     if( iStatus.Int() != KErrNone )
       
   141 // </qmail>
   173         {
   142         {
   174         iState = ECompleted;
   143         iState = ECompleted;
   175         if( err == KErrImapBadLogon )
   144 // <qmail> DisplayLoginFailedDialogL removed
   176             {
   145         CompleteObserver();
   177             DisplayLoginFailedDialogL();
       
   178             RunError(err);
       
   179             }
       
   180         else
       
   181             {
       
   182             CompleteObserver();
       
   183             }
       
   184         return;
   146         return;
   185         }   
   147         }
   186     
   148     
   187     TBuf8<1> dummyParam;
   149     switch(iState)
   188     switch( iState )
       
   189         {
   150         {
   190         case EStartConnect:
   151         case EStartConnect:
   191             delete iOperation;
   152             delete iSubOperation;
   192             iOperation = NULL;
   153             iSubOperation = NULL;
   193             InvokeClientMtmAsyncFunctionL( 
   154             // <qmail> priority parameter has been removed
   194                             KIMAP4MTMConnect, 
   155             iSubOperation = CIpsPlgImap4ConnectOp::NewL(
   195                             *iMsvEntry,
   156                 iMsvSession,
   196                             iService,
   157                 iStatus,
   197                             dummyParam );
   158                 iService,
       
   159                 *iActivityTimer,
       
   160                 iFSMailboxId,
       
   161                 NULL, // no observer for suboperations
       
   162                 0, // no requestId needed
       
   163                 NULL, // Event handler
       
   164                 ETrue ); // Plain connect
   198             iState = EConnecting;
   165             iState = EConnecting;
   199             SetActive();
   166             SetActive();
   200             break;
   167             break;
   201         case EConnecting:
   168 	    case EConnecting:
   202             {
   169 	        {
   203             //  We have successfully completed connecting
   170 	        //  We have successfully completed connecting
   204             
   171 	        TBuf8<1> dummyParam;
   205             delete iOperation;
   172 	        delete iSubOperation;
   206             iOperation = NULL;
   173 	        iSubOperation = NULL;
   207             InvokeClientMtmAsyncFunctionL( 
   174 	        InvokeClientMtmAsyncFunctionL( KIMAP4MTMSyncTree, *iSelection, dummyParam ); // <qmail> 1 param removed 
   208                         KIMAP4MTMSyncTree, 
   175 	        iState = ERefreshing;
   209                         *iMsvEntry,
   176 	        SetActive();
   210                         iService,
   177 	        }
   211                         dummyParam ); 
   178 	        break;
   212             iState = ERefreshing;
   179 	    case ERefreshing:
   213             SetActive();
   180 	        //  We have successfully completed refreshing the folder list
   214             }
   181 	        delete iSubOperation;
   215             break;
   182 	        iSubOperation = NULL;
   216         case ERefreshing:
   183 	        iSubOperation = CIpsPlgDisconnectOp::NewL( 
   217             //  We have successfully completed refreshing the folder list
   184                 iMsvSession, 
   218             delete iOperation;
   185                 iStatus, 
   219             iOperation = NULL;
   186                 iService, 
   220             iOperation = CIpsPlgDisconnectOp::NewL( 
   187                 *iActivityTimer,
   221             		        iMsvSession, 
   188                 iFSMailboxId, 
   222                             iStatus, 
   189                 NULL, // no observer for suboperations
   223                             iService, 
   190                 0 ); // no requestId needed
   224                             *iTimer,
   191 	        iState = EDisconnecting;
   225                             iFSMailboxId, 
   192 	        SetActive();
   226                             *observer, 
   193 	        break;
   227                             NULL );
   194 	    case EDisconnecting:
   228             iState = EDisconnecting;
   195 	        iState = ECompleted;
   229             SetActive();
   196 	        CompleteObserver();
   230             break;
   197 	        break;
   231         case EDisconnecting:
   198 	    default:
   232             iState = ECompleted;
   199 	        User::Panic( KIpsPlgPanicCategory, EIpsPlgNoParameters );
   233             CompleteObserver();
   200 	    	break;
   234             break;
       
   235         default:
       
   236             User::Panic( KIpsPlgPanicCategory, EIpsPlgNoParameters );
       
   237             break;
       
   238         }
   201         }
   239     }
   202     }
   240 
   203 
   241 // ----------------------------------------------------------------------------
   204 // ----------------------------------------------------------------------------
   242 // CIpsPlgOnlineOperation::DoCancel()
       
   243 // ----------------------------------------------------------------------------
   205 // ----------------------------------------------------------------------------
   244 //
   206 //
   245 void CIpsPlgConnectAndRefreshFolderList::DoCancel()
   207 void CIpsPlgConnectAndRefreshFolderList::DoCancel()
   246     {
   208     {
   247     FUNC_LOG;
   209     FUNC_LOG;
   248     if( iOperation )
   210     if( iSubOperation )
   249         {
   211         {
   250         iOperation->Cancel();
   212         iSubOperation->Cancel();
   251         }
   213         }
   252     CompleteObserver( KErrCancel );
   214     CompleteObserver( KErrCancel );
   253     iState = ECompleted;
   215     iState = ECompleted;
   254     }
   216     }
   255 
   217 
   256 // ----------------------------------------------------------------------------
   218 
   257 // CIpsPlgConnectAndRefreshFolderList::DisplayLoginFailedDialogL()
   219 // <qmail> removed in Qmail
   258 // ----------------------------------------------------------------------------
   220 //void CIpsPlgConnectAndRefreshFolderList::DisplayLoginFailedDialogL()
   259 //
   221 // </qmail>
   260 void CIpsPlgConnectAndRefreshFolderList::DisplayLoginFailedDialogL()
   222 
   261     {
   223 // <qmail> new func to this op
   262     // Get the TMsvEntry for the mailbox, which we use to get its name.
   224 // ----------------------------------------------------------------------------
   263     TMsvId serviceId;
   225 // ----------------------------------------------------------------------------    
   264     TMsvEntry mailboxServiceEntry;
   226 TIpsOpType CIpsPlgConnectAndRefreshFolderList::IpsOpType() const
   265     User::LeaveIfError( iMsvSession.GetEntry( iFSMailboxId.Id(), serviceId, mailboxServiceEntry ) );
   227     {
   266 
   228     FUNC_LOG;
   267     // Load/construct the strings for the dialog.
   229     return EIpsOpTypeConnectAndRefreshFolderListOp;
   268     HBufC* headerText( NULL );
   230     }
   269     headerText = StringLoader::LoadLC( R_FS_MSERVER_MAILBOX_NAME, mailboxServiceEntry.iDetails );
       
   270     HBufC* text( NULL );
       
   271     text = StringLoader::LoadLC( R_FS_MSERVER_TEXT_LOGIN_FAILED );
       
   272 
       
   273     // Create and display the dialog.
       
   274     CAknMessageQueryDialog *dlg = new (ELeave) CAknMessageQueryDialog;
       
   275     dlg->PrepareLC( R_FS_MSERVER_DIALOG_MESSAGE_QUERY );
       
   276     dlg->SetHeaderTextL( headerText->Des() );
       
   277     dlg->SetMessageTextL( text->Des() );
       
   278     dlg->RunLD();
       
   279 
       
   280     CleanupStack::PopAndDestroy( text );
       
   281     CleanupStack::PopAndDestroy( headerText );
       
   282     }
       
   283 
       
   284 // End of File
       
   285