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 all operation state machines |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_RSFW_RFESTATEMACHINE_H |
|
19 #define C_RSFW_RFESTATEMACHINE_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include "rsfwremoteaccess.h" |
|
23 |
|
24 class CRsfwRfeRequest; |
|
25 class CRsfwVolumeTable; |
|
26 class CRsfwFileEngine; |
|
27 class TRfeInArgs; |
|
28 class TRfeOutArgs; |
|
29 class CRsfwFileEntry; |
|
30 class TFid; |
|
31 |
|
32 const TInt KUpdateNotRequired = 5; |
|
33 |
|
34 /** |
|
35 * Base class for all operation state machines |
|
36 * |
|
37 */ |
|
38 class CRsfwRfeStateMachine : public CBase, public MRsfwRemoteAccessResponseHandler |
|
39 { |
|
40 public: |
|
41 |
|
42 class TState |
|
43 { |
|
44 public: |
|
45 virtual void EnterL()=0;// pure virtual |
|
46 virtual TState* CompleteL(); |
|
47 virtual TState* ErrorL(TInt aCode); |
|
48 virtual void Cancel(); |
|
49 }; |
|
50 |
|
51 class TCompleteAndDestroyState : public CRsfwRfeStateMachine::TState |
|
52 { |
|
53 public: |
|
54 TCompleteAndDestroyState(CRsfwRfeStateMachine* aOperation, |
|
55 TInt aErrCode = 0); |
|
56 void EnterL(); |
|
57 void SetErrorCode(TInt aErrorCode); |
|
58 private: |
|
59 CRsfwRfeStateMachine* iOperation; |
|
60 TInt iErrCode; |
|
61 }; |
|
62 |
|
63 public: |
|
64 void BaseConstructL(); |
|
65 ~CRsfwRfeStateMachine(); |
|
66 |
|
67 virtual TState* ErrorOnStateEntry(TInt aError); |
|
68 |
|
69 void ChangeState(TState* aNextState); |
|
70 void EnterState(TState* aNextState); |
|
71 void SetNextState(TState* aNextState); |
|
72 void ReEnterCurrentState(); |
|
73 void SetRequest(CRsfwRfeRequest* aRequest); |
|
74 CRsfwRfeRequest* Request(); |
|
75 inline TState* CurrentState(){return iState;}; |
|
76 inline TCompleteAndDestroyState* CompleteAndDestroyState() |
|
77 {return iCompleteAndDestroyState;}; |
|
78 |
|
79 // completes client's request |
|
80 virtual TState* CompleteRequestL(TInt aError)=0; |
|
81 |
|
82 void SetVolumes(CRsfwVolumeTable* aImplementor); |
|
83 void SetFileEngine(CRsfwFileEngine* aFileEngine); |
|
84 void SetArguments(TRfeInArgs* aInArgs, TRfeOutArgs* aOutArgs); |
|
85 CRsfwVolumeTable* Volumes(); |
|
86 CRsfwFileEngine* FileEngine(); |
|
87 CRsfwFileEntry* Node(); |
|
88 virtual TState* ErrorOnStateExit(TInt aError); |
|
89 |
|
90 // from MRsfwRemoteAccessResponseHandler |
|
91 void HandleRemoteAccessResponse(TUint aId, TInt aStatus); |
|
92 void DoCancel(); |
|
93 |
|
94 public: |
|
95 TRfeInArgs* iInArgs; |
|
96 TRfeOutArgs* iOutArgs; |
|
97 |
|
98 private: |
|
99 CRsfwFileEntry* iFep; // target file/directory parameter used by almost all state machines: |
|
100 TCompleteAndDestroyState* iCompleteAndDestroyState; // pre-created so that the request can always be completed (OOM situations etc.) |
|
101 TState* iState; // our current state |
|
102 CRsfwRfeRequest *iRFeRequest; // back pointer to the request we are running |
|
103 CRsfwVolumeTable* iImplementor; // class that implements the operations |
|
104 CRsfwFileEngine* iFileEngine; // the file engine |
|
105 }; |
|
106 |
|
107 |
|
108 |
|
109 #endif // C_RSFW_RFESTATEMACHINE_H |
|