|
1 // Copyright (c) 1999-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 #if !defined(__INDEXCONTEXT_H__) |
|
17 #define __INDEXCONTEXT_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <f32file.h> |
|
21 #include <msvipc.h> |
|
22 #include <barsread.h> |
|
23 #include "msventryfreepool.h" |
|
24 #include "msvindexadapter.h" |
|
25 |
|
26 class CMsvServer; |
|
27 class CMsvIndexAdapter; |
|
28 |
|
29 //********************************** |
|
30 // TMsvConfig |
|
31 //********************************** |
|
32 |
|
33 class TMsvConfig |
|
34 /** |
|
35 @internalComponent |
|
36 @released |
|
37 */ |
|
38 { |
|
39 public: |
|
40 TDriveUnit iDrive; |
|
41 TUint iUniqueID; |
|
42 TBool iDebug; |
|
43 |
|
44 // these are used to compare against the above so we know if we have to write the data. |
|
45 TDriveUnit iDriveAsLoaded; |
|
46 TUint iUniqueIDAsLoaded; |
|
47 TBool iDebugAsLoaded; |
|
48 }; |
|
49 |
|
50 //********************************** |
|
51 // MMsvContextObserver |
|
52 //********************************** |
|
53 |
|
54 class MMsvContextObserver |
|
55 /** |
|
56 @internalComponent |
|
57 @released |
|
58 */ |
|
59 { |
|
60 public: |
|
61 virtual void ContextComplete(TInt aError, TBool aRunMailInit)=0; |
|
62 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT) |
|
63 virtual void ChangeDriveComplete(TInt aError, TBool aRunMailInit, TDriveNumber aNewDrive)=0; |
|
64 #endif |
|
65 }; |
|
66 |
|
67 //********************************** |
|
68 // CMsvIndexContext |
|
69 //********************************** |
|
70 |
|
71 class CMsvIndexContext : public CActive |
|
72 /** |
|
73 @internalComponent |
|
74 @released |
|
75 */ |
|
76 { |
|
77 public: |
|
78 static CMsvIndexContext* NewLC(CMsvServer& aServer, MMsvContextObserver& aObserver); |
|
79 static CMsvIndexContext* NewL(CMsvServer& aServer, MMsvContextObserver& aObserver); |
|
80 ~CMsvIndexContext(); |
|
81 |
|
82 inline const CMsvEntrySelection& Update() const; |
|
83 inline CMsvEntrySelection& Update(); |
|
84 // |
|
85 inline const CMsvEntrySelection& Remove() const; |
|
86 inline CMsvEntrySelection& Remove(); |
|
87 // |
|
88 inline TBool Initialized() const; |
|
89 inline void Initialized(TBool aInitialized); |
|
90 |
|
91 // |
|
92 inline const TDesC& MessageFolder() const; |
|
93 inline TMsvIndexLoadProgress::TIndexState State() const; |
|
94 inline const TMsvConfig& Config() const; |
|
95 |
|
96 const TMsvIndexLoadProgress& Progress(); |
|
97 // |
|
98 const TDesC &IndexFileName() const; |
|
99 CPermanentFileStore &IndexStore(); |
|
100 // |
|
101 void LocalizeStandardFoldersL(); |
|
102 TBool GetAndClearIndexCorruptFlagL(); |
|
103 |
|
104 // Code changes for PREQ 557. |
|
105 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT) |
|
106 void CreateIndexL(); |
|
107 void UpdateDriveStatusL(TUint aDriveIndex, TDriveState& aStoreStatus); |
|
108 TInt ChangeDrive(TUint aNewDriveIndex, TRequestStatus& aStatus); |
|
109 TInt ChangeDrive(TUint aNewDriveIndex, TBool aIsRemovePartial = ETrue, TBool aAsync = EFalse); |
|
110 void GetInPreparationIds(TUint aDriveId); |
|
111 inline void MessageFolder(TUint aDriveId, TDes& aName) const; |
|
112 #else |
|
113 TInt LoadStoreConfig(TBool aLoad); |
|
114 void CreateIndexL(TInt aDrive, TRequestStatus& aStatus); |
|
115 void CreateIndexL(TInt aDrive, TBool aSync); |
|
116 #endif // #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT) |
|
117 |
|
118 inline CMsvIndexAdapter*& IndexAdapter(); |
|
119 inline CMsvIndexAdapter* IndexAdapter() const; |
|
120 private: |
|
121 |
|
122 void ConstructL(); |
|
123 CMsvIndexContext(CMsvServer& aServer, MMsvContextObserver& aObserver); |
|
124 |
|
125 // Changes for PREQ 557. |
|
126 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT) |
|
127 void DoCreateIndexL(); |
|
128 void IndexLoadingCompleted(); |
|
129 void ChangeDriveCompleted(TInt aError); |
|
130 void DoCreateServiceDirsL(TUint aDriveId); |
|
131 void CreateStoreDeleteFile(TDriveNumber aDriveNum); |
|
132 void CreateStandardEntriesFromResourceFileL(TUint aDriveId); |
|
133 void DoChangeDriveL(TUint aNewDriveIndex, TBool aIsRemovePartial, TDriveNumber& aNewDriveNumber); |
|
134 #else |
|
135 void DoStoreConfigL(); |
|
136 void DoCreateServiceDirsL(); |
|
137 void CreateStoreDeleteFile(); |
|
138 void IndexFailedToLoad(TInt aError); |
|
139 void IndexLoadingCompleted(TInt aError); |
|
140 #endif |
|
141 |
|
142 void ResetAndCreateNewMailStoreL(TBool aDelete = ETrue); |
|
143 // |
|
144 void IndexLoaded(TMsvServerChangeNotificationType aNotification); |
|
145 // |
|
146 void DoCancel(); |
|
147 void RunL(); |
|
148 |
|
149 private: |
|
150 CMsvEntrySelection* iUpdateEntryStreams; |
|
151 CMsvEntrySelection* iRemoveEntries; |
|
152 // |
|
153 CMsvServer& iServer; |
|
154 MMsvContextObserver& iObserver; |
|
155 // |
|
156 TFileName iMessageFolder; |
|
157 TMsvIndexLoadProgress iProgress; |
|
158 TMsvConfig iConfig; |
|
159 TRequestStatus* iObserverStatus; |
|
160 TBool iSyncLoad; |
|
161 TBool iRunMailInit; |
|
162 TBool iInitialized; |
|
163 HBufC8* iBuf; |
|
164 CMsvIndexAdapter* iIndexAdapter; |
|
165 |
|
166 #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE) |
|
167 friend class CTestIndexContext; |
|
168 friend class CTestSearchSortDBadapter; |
|
169 #endif |
|
170 }; |
|
171 |
|
172 inline const TDesC& CMsvIndexContext::MessageFolder() const |
|
173 { |
|
174 return iMessageFolder; |
|
175 } |
|
176 |
|
177 inline const CMsvEntrySelection& CMsvIndexContext::Update() const |
|
178 { |
|
179 return *iUpdateEntryStreams; |
|
180 } |
|
181 |
|
182 inline CMsvEntrySelection& CMsvIndexContext::Update() |
|
183 { |
|
184 return *iUpdateEntryStreams; |
|
185 } |
|
186 |
|
187 inline const CMsvEntrySelection& CMsvIndexContext::Remove() const |
|
188 { |
|
189 return *iRemoveEntries; |
|
190 } |
|
191 |
|
192 inline CMsvEntrySelection& CMsvIndexContext::Remove() |
|
193 { |
|
194 return *iRemoveEntries; |
|
195 } |
|
196 |
|
197 inline TMsvIndexLoadProgress::TIndexState CMsvIndexContext::State() const |
|
198 { |
|
199 return iProgress.iState; |
|
200 } |
|
201 |
|
202 inline const TMsvConfig& CMsvIndexContext::Config() const |
|
203 { |
|
204 return iConfig; |
|
205 } |
|
206 |
|
207 inline TBool CMsvIndexContext::Initialized() const |
|
208 { |
|
209 return iInitialized; |
|
210 } |
|
211 |
|
212 inline void CMsvIndexContext::Initialized(TBool aInitialized) |
|
213 { |
|
214 iInitialized=aInitialized; |
|
215 } |
|
216 |
|
217 inline CMsvIndexAdapter*& CMsvIndexContext::IndexAdapter() |
|
218 { |
|
219 CMsvEntryFreePool::Instance()->FlushExcessMemory(); |
|
220 return iIndexAdapter; |
|
221 } |
|
222 |
|
223 inline CMsvIndexAdapter* CMsvIndexContext::IndexAdapter() const |
|
224 { |
|
225 CMsvEntryFreePool::Instance()->FlushExcessMemory(); |
|
226 return iIndexAdapter; |
|
227 } |
|
228 |
|
229 |
|
230 |
|
231 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT) |
|
232 inline void CMsvIndexContext::MessageFolder(TUint aDriveId, TDes& aName) const |
|
233 { |
|
234 TParse parse; |
|
235 TDriveNumber driveNum; |
|
236 CMsvPreferredDriveList::GetDriveList()->GetDriveNumber(aDriveId, driveNum); |
|
237 TPtrC drive(TDriveUnit(driveNum).Name()); |
|
238 parse.Set(KMsvDefaultIndexFile2(), &drive, NULL); |
|
239 aName = parse.DriveAndPath(); |
|
240 } |
|
241 #endif // #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT) |
|
242 |
|
243 #endif |