remotestoragefw/remotefileengine/src/rsfwrferequest.cpp
branchRCL_3
changeset 19 88ee4cf65e19
parent 16 87c71b25c937
child 20 1aa8c82cb4cb
equal deleted inserted replaced
16:87c71b25c937 19:88ee4cf65e19
     1 /*
       
     2 * Copyright (c) 2005-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:  Base class for request encapsulation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <f32file.h>
       
    20 #include "rsfwrferequest.h"
       
    21 #include "rsfwinterface.h"
       
    22 #include "rsfwrfeoperation.h"
       
    23 #include "rsfwrfesyncoperation.h"
       
    24 #include "rsfwrfeasyncoperation.h"
       
    25 #include "rsfwrfestatemachine.h"
       
    26 #include "rsfwrequestallocator.h"
       
    27 #include "rsfwvolumetable.h"
       
    28 #include "rsfwvolume.h"
       
    29 #include "rsfwfileengine.h"
       
    30 
       
    31 TParse dummyP;
       
    32 RMessage2 dummyM;
       
    33 
       
    34 
       
    35 // ----------------------------------------------------------------------------
       
    36 // CRsfwRfeRequest::~CRsfwRfeRequest
       
    37 // ----------------------------------------------------------------------------
       
    38 // 
       
    39 CRsfwRfeRequest::~CRsfwRfeRequest()
       
    40     {
       
    41     delete iInArgs;
       
    42     delete iOutArgs;
       
    43     if (iOperation) 
       
    44         {
       
    45         if (Operation()->IsSync()) 
       
    46             {
       
    47             delete (CRsfwRfeSyncOperation *)iOperation;
       
    48             iOperation = NULL;
       
    49             }
       
    50         else 
       
    51             {
       
    52             delete (CRsfwRfeAsyncOperation *)iOperation;
       
    53             iOperation = NULL;
       
    54             }
       
    55         }
       
    56     }
       
    57 
       
    58 // ----------------------------------------------------------------------------
       
    59 // CRsfwRfeRequest::Destroy
       
    60 // ----------------------------------------------------------------------------
       
    61 // 
       
    62 void CRsfwRfeRequest::Destroy()
       
    63     {
       
    64     CRsfwVolume* volume = iVolume;
       
    65     CRsfwVolumeTable* volumeTable = iVolumeTable;
       
    66 
       
    67     RsfwRequestAllocator::FreeRequest(this);
       
    68 
       
    69     if (volume && volume->iFileEngine)
       
    70         {
       
    71         // Signal the engine of operation completion
       
    72         volume->iFileEngine->OperationCompleted();
       
    73         }
       
    74     else
       
    75         {
       
    76         volumeTable->OperationCompleted(NULL);
       
    77         }
       
    78     }
       
    79     
       
    80 // ----------------------------------------------------------------------------
       
    81 // CRsfwRfeRequest::Dispatch
       
    82 // ----------------------------------------------------------------------------
       
    83 //     
       
    84 void CRsfwRfeRequest::Dispatch()
       
    85     {
       
    86     if (Operation()->IsSync()) 
       
    87         {
       
    88         TRAPD(leaveValue,
       
    89               ((CRsfwRfeSyncOperation * )Operation())->DoRequestL(this));
       
    90         CompleteAndDestroy(leaveValue);  
       
    91         }
       
    92     else 
       
    93         {
       
    94         // run the operation state machine
       
    95         // start from the initial state
       
    96         ((CRsfwRfeAsyncOperation *)Operation())->Implementation()->
       
    97             ReEnterCurrentState();
       
    98         }
       
    99     }
       
   100 
       
   101 // ----------------------------------------------------------------------------
       
   102 // CRsfwRfeRequest::Src
       
   103 // ----------------------------------------------------------------------------
       
   104 //     
       
   105 TParse& CRsfwRfeRequest::Src()
       
   106     {
       
   107     return(dummyP);
       
   108     }
       
   109 
       
   110 // ----------------------------------------------------------------------------
       
   111 // CRsfwRfeRequest::Dest
       
   112 // ----------------------------------------------------------------------------
       
   113 // 
       
   114 TParse& CRsfwRfeRequest::Dest()
       
   115     {
       
   116     return(dummyP);
       
   117     }
       
   118 
       
   119 // ----------------------------------------------------------------------------
       
   120 // CRsfwRfeRequest::Operation
       
   121 // ----------------------------------------------------------------------------
       
   122 //     
       
   123 CRsfwRfeOperation* CRsfwRfeRequest::Operation() 
       
   124     {return(iOperation);}
       
   125 
       
   126 // ----------------------------------------------------------------------------
       
   127 // CRsfwRfeRequest::SetOperation
       
   128 // ----------------------------------------------------------------------------
       
   129 // 
       
   130 void CRsfwRfeRequest::SetOperation(CRsfwRfeOperation* aCaller) 
       
   131     {
       
   132     iOperation = aCaller;
       
   133     }
       
   134 
       
   135 // ----------------------------------------------------------------------------
       
   136 // CRsfwRfeRequest::RequestType
       
   137 // ----------------------------------------------------------------------------
       
   138 // 
       
   139 TRequestType CRsfwRfeRequest::RequestType() 
       
   140     {
       
   141     return iRequestType;
       
   142     }
       
   143 
       
   144 // ----------------------------------------------------------------------------
       
   145 // CRsfwRfeRequest::SetRequestType
       
   146 // ----------------------------------------------------------------------------
       
   147 // 
       
   148 void CRsfwRfeRequest::SetRequestType(TRequestType aRequestType) 
       
   149     {
       
   150     iRequestType = aRequestType;
       
   151     }
       
   152 
       
   153