|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __SSMCOMMANDLISTRESOURCEREADERIMPL_H__ |
|
17 #define __SSMCOMMANDLISTRESOURCEREADERIMPL_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <f32file.h> |
|
21 |
|
22 #include <ssm/ssmstate.h> |
|
23 #include <ssm/ssmswp.h> |
|
24 #include <ssm/ssmcmd.hrh> |
|
25 #include <barsread2.h> |
|
26 |
|
27 class CResourceFile; |
|
28 class MSsmConditionalCallback; |
|
29 class MSsmCommandList; |
|
30 |
|
31 /** Private implementation of CSsmCommandListResourceReader. |
|
32 |
|
33 @internalComponent |
|
34 */ |
|
35 NONSHARABLE_CLASS(CSsmCommandListResourceReaderImpl) : public CBase |
|
36 { |
|
37 public: |
|
38 static CSsmCommandListResourceReaderImpl* NewL(RFs& aFs, const TDesC& aCommandListPath, MSsmConditionalCallback& aConditionalCallback); |
|
39 ~CSsmCommandListResourceReaderImpl(); |
|
40 |
|
41 void Initialise(TRequestStatus& aStatus); |
|
42 void InitialiseCancel(); |
|
43 void PrepareCommandList(MSsmCommandList& aCommandList, TInt aCommandListId, const TSsmState& aState, TRequestStatus& aStatus); |
|
44 void PrepareCommandList(MSsmCommandList& aCommandList, TInt aCommandListId, const TSsmSwp& aSwp, TRequestStatus& aStatus); |
|
45 void PrepareCommandListCancel(); |
|
46 TBool IsCommandListReady() const; |
|
47 TBool Busy() const; |
|
48 void GetCommandListIdsL(RArray<TInt>& aArray) const; |
|
49 |
|
50 private: |
|
51 enum TInternalAction |
|
52 { |
|
53 EIdle, |
|
54 EInitialiseFirstStep, |
|
55 EInitialiseNextStep, |
|
56 EInitialiseSysDriveStep, |
|
57 EPrepareFirstStep, |
|
58 EPrepareNextStep |
|
59 }; |
|
60 |
|
61 NONSHARABLE_CLASS(TMapping) |
|
62 { |
|
63 public: |
|
64 TMapping(TInt aCommandListId, TInt aResourceId, CResourceFile* aResourceFile) : iCommandListId(aCommandListId), iResourceId(aResourceId), iResourceFile(aResourceFile) {} |
|
65 TInt iCommandListId; //this should always be the first member data |
|
66 TInt iResourceId; |
|
67 CResourceFile* iResourceFile; // CSsmCommandListResourceReaderImpl takes the ownership |
|
68 }; |
|
69 |
|
70 NONSHARABLE_CLASS(CResourcePool) : public CBase |
|
71 { |
|
72 public: |
|
73 CResourcePool(); |
|
74 ~CResourcePool(); |
|
75 TBool IsEmpty() const; |
|
76 void Reset(); |
|
77 void AppendL(const CResourceFile* aResourceFile); |
|
78 void AppendL(const TDesC& aFileName); |
|
79 void AppendL(const TMapping& aMapping); |
|
80 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
81 void UpdateMappingArrayL(TInt aCommandListId, RArray<TMapping>& aMappingArray) const; |
|
82 #else |
|
83 TMapping MappingL(TInt aCommandListId) const; |
|
84 #endif //SYMBIAN_SSM_FLEXIBLE_MERGE |
|
85 void GetCommandListIdsL(RArray<TInt>& aArray) const; |
|
86 const TDesC& FileNameForResourceFileL(const CResourceFile* aResourceFile) const; |
|
87 |
|
88 private: |
|
89 RPointerArray<CResourceFile> iResourceFiles; |
|
90 RArray<TMapping> iMappings; |
|
91 RPointerArray<HBufC> iResourceFileNames; |
|
92 }; |
|
93 |
|
94 NONSHARABLE_CLASS(CActiveBase) : public CActive |
|
95 { |
|
96 public: |
|
97 ~CActiveBase(); |
|
98 protected: |
|
99 CActiveBase(TInt aPriority); |
|
100 void Start(); |
|
101 void CompleteClientRequest(TInt aReason); |
|
102 protected: |
|
103 TRequestStatus* iRequestStatus; |
|
104 TInternalAction iAction; |
|
105 }; |
|
106 |
|
107 NONSHARABLE_CLASS(CInitialiser) : public CActiveBase |
|
108 { |
|
109 public: |
|
110 static CInitialiser* NewL(RFs& aFs, const TDesC& aCommandListPath, CResourcePool& aResourcePool); |
|
111 void Start(TRequestStatus& aStatus); |
|
112 ~CInitialiser(); |
|
113 private: |
|
114 CInitialiser(RFs& aFs, CResourcePool& aResourcePool); |
|
115 void ConstructL(const TDesC& aCommandListPath); |
|
116 void ResetToUninitialisedState(); |
|
117 void DoInitialiseFirstStepL(); |
|
118 void DoInitialiseNextStepL(); |
|
119 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
120 void DoInitialiseSysDriveStepL(); |
|
121 #endif |
|
122 CResourceFile* OpenResourceFileL(const TDesC& aFileName); |
|
123 void ParseFileL(CResourceFile* aResourceFile); |
|
124 // from CActive |
|
125 void RunL(); |
|
126 void DoCancel(); |
|
127 TInt RunError(TInt aError); |
|
128 private: |
|
129 RFs& iFs; |
|
130 RBuf iPath; |
|
131 CResourcePool& iResourcePool; |
|
132 CDir* iResourceFileEntries; |
|
133 TInt iEntryIndex; |
|
134 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
135 RBuf iSystemDrivePath; |
|
136 CDir* iRssFileEntriesInSysDrive; |
|
137 TInt iSysDriveEntryIndex; |
|
138 #endif //SYMBIAN_SSM_FLEXIBLE_MERGE |
|
139 }; |
|
140 |
|
141 NONSHARABLE_CLASS(CPreparer) : public CActiveBase |
|
142 { |
|
143 public: |
|
144 CPreparer(const CResourcePool& aResourcePool, MSsmConditionalCallback& aConditionalCallback); |
|
145 ~CPreparer(); |
|
146 void Start(MSsmCommandList& aCommandList, TInt aCommandListId, const TSsmState& aState, TRequestStatus& aStatus); |
|
147 void Start(MSsmCommandList& aCommandList, TInt aCommandListId, const TSsmSwp& aSwp, TRequestStatus& aStatus); |
|
148 TBool IsCommandListReady(); |
|
149 private: |
|
150 void ResetReadyForNextPrepare(); |
|
151 void DoPrepareFirstStepL(); |
|
152 void DoPrepareNextStepL(); |
|
153 void AddCommandToListL(TSsmCommandType aType, RResourceReader& aCommandReader, TInt aConditionalInfoResourceId); |
|
154 // from CActive |
|
155 void RunL(); |
|
156 void DoCancel(); |
|
157 TInt RunError(TInt aError); |
|
158 private: |
|
159 const CResourcePool& iResourcePool; |
|
160 MSsmConditionalCallback& iConditionalCallback; |
|
161 |
|
162 // input parameters for current prepare operation |
|
163 MSsmCommandList* iCommandList; // Not owning |
|
164 TInt iCommandListId; |
|
165 TSsmState iState; |
|
166 TSsmSwp iSwpChange; |
|
167 |
|
168 // working variables for current prepare operation |
|
169 TMapping iMapping; // mapping used for current prepare |
|
170 RResourceReader iListReader; |
|
171 TInt iCommandIndex; |
|
172 TInt iBatchIndex; // number of commands left to read in current RunL |
|
173 TBool iCommandListReady; |
|
174 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
175 RArray<TMapping> iMappingArray; |
|
176 RArray<TInt> iCommandIndexInRssFile; |
|
177 TInt iCurrentCommandListInMapping; |
|
178 #endif //SYMBIAN_SSM_FLEXIBLE_MERGE |
|
179 }; |
|
180 |
|
181 private: |
|
182 CSsmCommandListResourceReaderImpl(); |
|
183 void ConstructL(RFs& aFs, const TDesC& aCommandListPath, MSsmConditionalCallback& aConditionalCallback); |
|
184 |
|
185 private: |
|
186 CResourcePool* iResourcePool; |
|
187 CInitialiser* iInitialiser; |
|
188 CPreparer* iPreparer; |
|
189 }; |
|
190 |
|
191 #endif // __SSMCOMMANDLISTRESOURCEREADERIMPL_H__ |