remotestoragefw/remotefileengine/src/rsfwwaitnotestatemachine.cpp
branchRCL_3
changeset 19 88ee4cf65e19
parent 16 87c71b25c937
child 20 1aa8c82cb4cb
equal deleted inserted replaced
16:87c71b25c937 19:88ee4cf65e19
     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:  States that use a global wait dialog
       
    15 *
       
    16 */
       
    17 
       
    18   
       
    19 #include "rsfwwaitnotestatemachine.h"
       
    20 #include "rsfwvolumetable.h"
       
    21 #include "rsfwwaitnotemanager.h"
       
    22 #include "rsfwfileengine.h"
       
    23 #include "rsfwvolume.h"
       
    24 #include "mdebug.h"
       
    25 
       
    26 
       
    27 // ----------------------------------------------------------------------------
       
    28 // CRsfwWaitNoteStateMachine::CancelTransaction
       
    29 // ----------------------------------------------------------------------------
       
    30 //
       
    31 void CRsfwWaitNoteStateMachine::CancelTransaction() 
       
    32 	{	
       
    33 	//if ((iTransactionId > 0) && FileEngine()) 
       
    34 	if (FileEngine()) 
       
    35 		{
       
    36 		if ((iTransactionId > 0))
       
    37 		    {
       
    38 	        // with cancelled global wait notes the operation is
       
    39             // completed via access protocol Cancel
       
    40             // that is transaction is cancelled and the operation state machine
       
    41             // receives KErrCancel callback
       
    42 		    FileEngine()->CancelTransaction(iTransactionId);
       
    43 		    }
       
    44 		else
       
    45 		    {
       
    46 		    HandleRemoteAccessResponse(0, KErrCancel);
       
    47 		    }
       
    48     	}
       
    49     }
       
    50 
       
    51 // ----------------------------------------------------------------------------
       
    52 // CRsfwWaitNoteStateMachine::ShowWaitNoteL
       
    53 // ----------------------------------------------------------------------------
       
    54 //
       
    55 void CRsfwWaitNoteStateMachine::ShowWaitNoteL(TRemoteOperationType aOperationType)
       
    56     {
       
    57     if (FileEngine() && FileEngine()->Volume())
       
    58         {
       
    59         switch (aOperationType) 
       
    60             {
       
    61              case ERemoteOpConnecting:
       
    62                 iGlobalWaitNoteRequest.iMethod = TRsfwNotPluginRequest::EConnectingDlg;
       
    63                 break;    
       
    64              case ERemoteOpDirDownloading:  
       
    65                 iGlobalWaitNoteRequest.iMethod = TRsfwNotPluginRequest::EFetchingDlg;
       
    66                 break; 
       
    67              case ERemoteUnavailableRetry:
       
    68                 iGlobalWaitNoteRequest.iMethod = TRsfwNotPluginRequest::EUnavailableRetryDlg;
       
    69                 break;
       
    70              }
       
    71             Volumes()->WaitNoteManager()->SetGlobalNoteRequestL(iGlobalWaitNoteRequest);
       
    72             iNoteId = Volumes()->WaitNoteManager()
       
    73                         ->StartWaitNoteL(aOperationType, this);       
       
    74         }
       
    75    else
       
    76         {// show note if Uri info not available
       
    77         iNoteId = Volumes()->WaitNoteManager()->StartWaitNoteL(aOperationType, this);
       
    78         }
       
    79     }
       
    80 
       
    81 // ----------------------------------------------------------------------------
       
    82 // CRsfwWaitNoteStateMachine::DeleteWaitNoteL
       
    83 // ----------------------------------------------------------------------------
       
    84 //
       
    85 void CRsfwWaitNoteStateMachine::DeleteWaitNoteL(TBool aCancelOpWait)
       
    86     {
       
    87     DEBUGSTRING16(("CRsfwWaitNoteStateMachine::DeleteWaitNoteL"));	
       
    88     if (aCancelOpWait) 
       
    89         {
       
    90          // let the wait note manager know that we are not expecting any event anymore
       
    91         Volumes()->WaitNoteManager()->ResetOperation(); 
       
    92         }
       
    93     if (iNoteId > 0) 
       
    94     	{
       
    95     	Volumes()->WaitNoteManager()->CancelWaitNoteL(iNoteId);
       
    96     	iNoteId = 0;	
       
    97     	}
       
    98     }
       
    99 
       
   100 // ----------------------------------------------------------------------------
       
   101 // CRsfwWaitNoteStateMachine::ErrorOnStateEntry
       
   102 // ----------------------------------------------------------------------------
       
   103 //
       
   104 CRsfwRfeStateMachine::TState* CRsfwWaitNoteStateMachine::ErrorOnStateEntry(TInt aError)
       
   105     {
       
   106     TRAP_IGNORE(DeleteWaitNoteL(ETrue));
       
   107     return CRsfwRfeStateMachine::ErrorOnStateEntry(aError);
       
   108     }
       
   109 
       
   110 // ----------------------------------------------------------------------------
       
   111 // CRsfwWaitNoteStateMachine::ErrorOnStateExit
       
   112 // ----------------------------------------------------------------------------
       
   113 //
       
   114 CRsfwRfeStateMachine::TState* CRsfwWaitNoteStateMachine::ErrorOnStateExit(TInt aError)
       
   115     {
       
   116     TRAP_IGNORE(DeleteWaitNoteL(ETrue));
       
   117     return CRsfwRfeStateMachine::ErrorOnStateExit(aError);
       
   118     }    
       
   119     
       
   120 // ----------------------------------------------------------------------------
       
   121 // CRsfwWaitNoteStateMachine::CompleteRequestL
       
   122 // ----------------------------------------------------------------------------
       
   123 //     
       
   124 CRsfwRfeStateMachine::TState* CRsfwWaitNoteStateMachine::CompleteRequestL(
       
   125     TInt aError) 
       
   126     {   
       
   127     CompleteAndDestroyState()->SetErrorCode(aError);
       
   128     DeleteWaitNoteL(ETrue);
       
   129     return CompleteAndDestroyState(); 
       
   130     }
       
   131  
       
   132 
       
   133