author | hgs |
Wed, 21 Jul 2010 14:31:36 +0100 | |
changeset 220 | 14267bc009a6 |
parent 90 | 947f0dc9f7a8 |
child 243 | c7a0ce20c48c |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2002-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 the License "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 |
// f32\sfile\sf_request.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include "sf_std.h" |
|
19 |
#include "sf_file_cache.h" |
|
20 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
21 |
#include "sf_notifier.h" |
|
22 |
#endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
23 |
||
24 |
||
25 |
TParse dummyP; |
|
26 |
RMessage2 dummyM; |
|
27 |
||
28 |
CFsClientMessageRequest* RequestAllocator::iFreeHead; |
|
29 |
CFsClientMessageRequest* RequestAllocator::iCloseHead; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
30 |
TInt RequestAllocator::iRequestCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
31 |
TInt RequestAllocator::iFreeCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
32 |
TInt RequestAllocator::iRequestCountPeak; |
0 | 33 |
RFastLock RequestAllocator::iCacheLock; |
34 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
35 |
TMsgOperation* OperationAllocator::iFreeHead; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
36 |
TInt OperationAllocator::iRequestCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
37 |
TInt OperationAllocator::iFreeCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
38 |
TInt OperationAllocator::iRequestCountPeak; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
39 |
RFastLock OperationAllocator::iCacheLock; |
0 | 40 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
41 |
TInt RequestAllocator::Initialise() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
42 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
43 |
iFreeHead = NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
44 |
iCloseHead = NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
45 |
iRequestCount = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
46 |
iFreeCount = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
47 |
iRequestCountPeak = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
48 |
return iCacheLock.CreateLocal(); |
0 | 49 |
} |
50 |
||
51 |
void RequestAllocator::FreeRequest(CFsClientMessageRequest* aRequest) |
|
52 |
// |
|
53 |
//free request |
|
54 |
// |
|
55 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
56 |
__CACHE_PRINT1(_L("RequestAllocator::FreeRequest for %x"), aRequest); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
57 |
ASSERT(aRequest != NULL); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
58 |
iCacheLock.Wait(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
59 |
if (iFreeCount >= KFreeCountMax) |
0 | 60 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
61 |
delete aRequest; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
62 |
ASSERT(iRequestCount > 0); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
63 |
iRequestCount--; |
0 | 64 |
} |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
65 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
66 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
67 |
aRequest->SetSubstedDrive(NULL); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
68 |
aRequest->iNext = iFreeHead; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
69 |
iFreeHead=aRequest; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
70 |
iFreeCount++; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
71 |
} |
0 | 72 |
iCacheLock.Signal(); |
73 |
} |
|
74 |
||
75 |
void RequestAllocator::OpenSubFailed(CSessionFs* aSession) |
|
76 |
// |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
77 |
// Move request from closed list to free list |
0 | 78 |
// |
79 |
{ |
|
80 |
__ASSERT_DEBUG(iCloseHead!=NULL,Fault(ERequestAllocatorOpenSubFailed)); // On arriving here Close Queue is supposed to be empty |
|
81 |
__ASSERT_ALWAYS(aSession!=NULL,Fault(ERequestAllocatorOpenSubFailed)); |
|
82 |
if (iCloseHead==NULL) |
|
83 |
{ |
|
84 |
return; |
|
85 |
} |
|
86 |
iCacheLock.Wait(); |
|
87 |
CFsClientMessageRequest* rp = iCloseHead; |
|
88 |
iCloseHead = rp->iNext; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
89 |
iCacheLock.Signal(); |
0 | 90 |
|
91 |
// dec the number of closed requests owned by this session |
|
92 |
aSession->CloseRequestCountDec(); |
|
93 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
94 |
__CACHE_PRINT1(_L("RequestAllocator::OpenSubFailed() IsAllocated %d"), rp->IsAllocated()); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
95 |
FreeRequest(rp); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
96 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
97 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
98 |
CFsClientMessageRequest* RequestAllocator::GetRequest() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
99 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
100 |
// Get request from the free queue |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
101 |
// |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
102 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
103 |
CFsClientMessageRequest* request; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
104 |
if (iFreeHead == NULL) |
0 | 105 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
106 |
request = new CFsClientMessageRequest; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
107 |
if (request) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
108 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
109 |
iRequestCount++; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
110 |
iRequestCountPeak = Max(iRequestCountPeak, iRequestCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
111 |
} |
0 | 112 |
} |
113 |
else |
|
114 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
115 |
request = iFreeHead; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
116 |
iFreeHead = iFreeHead->iNext; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
117 |
request->iNext = NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
118 |
iFreeCount--; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
119 |
ASSERT(iFreeCount >= 0); |
0 | 120 |
} |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
121 |
return request; |
0 | 122 |
} |
123 |
||
124 |
TInt RequestAllocator::GetMessageRequest(const TOperation& aOperation,const RMessage2& aMessage,CFsClientMessageRequest* &aRequest) |
|
125 |
// |
|
126 |
// tries to get a pre allocated message from the cache. Failing that allocates one indivisualy |
|
127 |
// |
|
128 |
{ |
|
129 |
if(aOperation.IsOpenSubSess()) |
|
130 |
{ |
|
131 |
__CACHE_PRINT(_L("++RequestAllocator::GetMessageRequest() Open sub-sess")); |
|
132 |
iCacheLock.Wait(); |
|
133 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
134 |
aRequest = GetRequest(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
135 |
CFsClientMessageRequest* closeRequest = GetRequest(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
136 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
137 |
if (aRequest == NULL || closeRequest == NULL) |
0 | 138 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
139 |
delete aRequest; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
140 |
delete closeRequest; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
141 |
iCacheLock.Signal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
142 |
return KErrNoMemory; |
0 | 143 |
} |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
144 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
145 |
closeRequest->iNext = iCloseHead; //set second one as a reserved (tail) close request |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
146 |
iCloseHead = closeRequest; |
0 | 147 |
|
148 |
((CSessionFs*) aMessage.Session())->CloseRequestCountInc(); |
|
149 |
} |
|
150 |
else if(aOperation.IsCloseSubSess()) |
|
151 |
{ |
|
152 |
__CACHE_PRINT(_L("++RequestAllocator::GetMessageRequest() Close sub-sess")); |
|
153 |
||
154 |
CFsObject* pO = SessionObjectFromHandle(aMessage.Int3(),0,reinterpret_cast<CSessionFs*>(aMessage.Session())); |
|
155 |
if(!pO) |
|
156 |
return KErrBadHandle; |
|
157 |
||
158 |
CObjPromotion* pm = (CObjPromotion*)pO; |
|
159 |
TInt function = aMessage.Function(); |
|
160 |
switch(function & KIpcFunctionMask) |
|
161 |
{ |
|
162 |
case EFsFormatSubClose: |
|
163 |
{ |
|
164 |
if(pm->UniqueID() != Formats->UniqueID()) |
|
165 |
{ |
|
166 |
return KErrBadHandle; |
|
167 |
} |
|
168 |
break; |
|
169 |
} |
|
170 |
case EFsDirSubClose: |
|
171 |
{ |
|
172 |
if(pm->UniqueID() != Dirs->UniqueID()) |
|
173 |
{ |
|
174 |
return KErrBadHandle; |
|
175 |
} |
|
176 |
break; |
|
177 |
} |
|
178 |
case EFsFileSubClose: |
|
179 |
{ |
|
180 |
if(pm->UniqueID() != FileShares->UniqueID()) |
|
181 |
{ |
|
182 |
return KErrBadHandle; |
|
183 |
} |
|
184 |
break; |
|
185 |
} |
|
186 |
case EFsRawSubClose: |
|
187 |
{ |
|
188 |
if(pm->UniqueID() != RawDisks->UniqueID()) |
|
189 |
{ |
|
190 |
return KErrBadHandle; |
|
191 |
} |
|
192 |
break; |
|
193 |
} |
|
194 |
case EFsPluginSubClose: |
|
195 |
{ |
|
196 |
if(pm->UniqueID() != FsPluginManager::iPluginConns->UniqueID()) |
|
197 |
{ |
|
198 |
return KErrBadHandle; |
|
199 |
} |
|
200 |
break; |
|
201 |
} |
|
202 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
203 |
case EFsNotificationSubClose: |
|
204 |
{ |
|
205 |
if(pm->UniqueID() != FsNotificationManager::iNotifyRequests->UniqueID()) |
|
206 |
{ |
|
207 |
return KErrBadHandle; |
|
208 |
} |
|
209 |
break; |
|
210 |
} |
|
211 |
#endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
212 |
default: |
|
213 |
Fault(ECloseSubBadMessage); |
|
214 |
} |
|
215 |
||
216 |
iCacheLock.Wait(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
217 |
ASSERT(iCloseHead); |
0 | 218 |
aRequest = iCloseHead; |
219 |
iCloseHead = aRequest->iNext; |
|
220 |
((CSessionFs*) aMessage.Session())->CloseRequestCountDec(); |
|
221 |
aRequest->iNext = NULL; |
|
222 |
||
223 |
if((function & KIpcFunctionMask)!= EFsPluginSubClose && |
|
224 |
(function & KIpcFunctionMask)!= EFsNotificationSubClose) |
|
225 |
{ |
|
226 |
aRequest->SetDrive(&TheDrives[((CFsDispatchObject*)pO)->DriveNumber()]); |
|
227 |
} |
|
228 |
||
229 |
aRequest->SetScratchValue((TUint)pO); |
|
230 |
} |
|
231 |
else |
|
232 |
{ |
|
233 |
__CACHE_PRINT(_L("++RequestAllocator::GetMessageRequest() ")); |
|
234 |
iCacheLock.Wait(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
235 |
aRequest = GetRequest(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
236 |
if (aRequest == NULL) |
0 | 237 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
238 |
iCacheLock.Signal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
239 |
return KErrNoMemory; |
0 | 240 |
} |
241 |
} |
|
242 |
||
243 |
aRequest->Init(); |
|
244 |
||
245 |
iCacheLock.Signal(); |
|
246 |
||
247 |
// pre-allocate any TParse objects needed by this request |
|
248 |
if (aRequest->AllocParseObjects(aOperation) != KErrNone) |
|
249 |
{ |
|
250 |
aRequest->Free(); |
|
251 |
return KErrNoMemory; |
|
252 |
} |
|
253 |
||
254 |
__CACHE_PRINT1(_L("--RequestAllocator::GetMessageRequest() allocated %08x"), aRequest); |
|
255 |
||
256 |
return KErrNone; |
|
257 |
} |
|
258 |
||
259 |
||
260 |
#if defined(_USE_CONTROLIO) || defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
261 |
TInt RequestAllocator::CloseCount() |
|
262 |
{TInt count=0; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
263 |
iCacheLock.Wait(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
264 |
|
0 | 265 |
CFsClientMessageRequest* list=iCloseHead; |
266 |
while(list!=NULL) |
|
267 |
{ |
|
268 |
count++; |
|
269 |
list=list->iNext; |
|
270 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
271 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
272 |
iCacheLock.Signal(); |
0 | 273 |
return(count); |
274 |
} |
|
275 |
TInt RequestAllocator::FreeCount() |
|
276 |
{ |
|
277 |
TInt count=0; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
278 |
iCacheLock.Wait(); |
0 | 279 |
CFsClientMessageRequest* list=iFreeHead; |
280 |
while(list!=NULL) |
|
281 |
{ |
|
282 |
count++; |
|
283 |
list=list->iNext; |
|
284 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
285 |
ASSERT(count == iFreeCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
286 |
iCacheLock.Signal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
287 |
return(count); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
288 |
} |
0 | 289 |
#endif |
290 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
291 |
TInt OperationAllocator::Initialise() |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
292 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
293 |
iFreeHead = NULL; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
294 |
iRequestCount = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
295 |
iFreeCount = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
296 |
return iCacheLock.CreateLocal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
297 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
298 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
299 |
void OperationAllocator::FreeOperation(TMsgOperation* aOperation) |
0 | 300 |
// |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
301 |
// free Operation |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
302 |
// |
0 | 303 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
304 |
__CACHE_PRINT1(_L("RequestAllocator::FreeOperation() returning %x to free list"), aOperation); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
305 |
ASSERT(aOperation != NULL); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
306 |
iCacheLock.Wait(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
307 |
if (iFreeCount >= KFreeCountMax) |
0 | 308 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
309 |
delete aOperation; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
310 |
ASSERT(iRequestCount > 0); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
311 |
iRequestCount--; |
0 | 312 |
} |
313 |
else |
|
314 |
{ |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
315 |
aOperation->iNext = iFreeHead; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
316 |
iFreeHead = aOperation; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
317 |
iFreeCount++; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
318 |
} |
0 | 319 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
320 |
iCacheLock.Signal(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
321 |
} |
0 | 322 |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
323 |
TInt OperationAllocator::GetOperation(TMsgOperation* &aOperation) |
0 | 324 |
// |
325 |
// tries to get a pre allocated subop from the cache. Failing that allocates one individualy |
|
326 |
// |
|
327 |
{ |
|
328 |
||
329 |
__CACHE_PRINT(_L("RequestAllocator::GetOperation() ")); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
330 |
|
0 | 331 |
iCacheLock.Wait(); |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
332 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
333 |
TInt r = KErrNone; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
334 |
if (iFreeHead == NULL) |
0 | 335 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
336 |
aOperation = new TMsgOperation; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
337 |
if (aOperation == NULL) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
338 |
r = KErrNoMemory; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
339 |
else |
0 | 340 |
{ |
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
341 |
iRequestCount++; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
342 |
iRequestCountPeak = Max(iRequestCountPeak, iRequestCount); |
0 | 343 |
} |
344 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
345 |
else |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
346 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
347 |
aOperation = iFreeHead; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
348 |
iFreeHead = iFreeHead->iNext; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
349 |
iFreeCount--; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
350 |
ASSERT(iFreeCount >= 0); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
351 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
352 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
353 |
if (aOperation) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
354 |
aOperation->iNext = aOperation->iPrev = NULL; |
0 | 355 |
|
356 |
iCacheLock.Signal(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
357 |
return r; |
0 | 358 |
} |
359 |
||
360 |
||
361 |
CFsRequest::CFsRequest() |
|
362 |
// |
|
363 |
// |
|
364 |
// |
|
365 |
: iOperation(NULL),iDriveNumber(KDriveInvalid) |
|
366 |
{} |
|
367 |
||
368 |
CFsRequest::~CFsRequest() |
|
369 |
// |
|
370 |
// |
|
371 |
// |
|
372 |
{} |
|
373 |
||
374 |
void CFsRequest::Set(const TOperation& aOperation,CSessionFs* aSession) |
|
375 |
// |
|
376 |
// |
|
377 |
// |
|
378 |
{ |
|
379 |
||
380 |
SetState(EReqStateInitialise); |
|
381 |
||
382 |
iOperation = const_cast<TOperation*>(&aOperation); |
|
383 |
iSession = aSession; |
|
384 |
iIsCompleted = aOperation.IsCompleted(); |
|
385 |
iError = KErrNone; |
|
386 |
iDriveNumber = KDriveInvalid; |
|
387 |
iCurrentPlugin = NULL; |
|
388 |
iOwnerPlugin = NULL; |
|
389 |
iDirectToDrive = EFalse; |
|
390 |
iClientThreadId= 0; |
|
391 |
iFlags &= ~(EFreeChanged | EPostInterceptEnabled | EPostOperation | EFsObjectOpen); |
|
392 |
iScratchValue = 0; |
|
393 |
} |
|
394 |
||
395 |
void CFsRequest::Set(CSessionFs* aSession) |
|
396 |
// |
|
397 |
// |
|
398 |
// |
|
399 |
{ |
|
400 |
__ASSERT_DEBUG(iOperation,Fault(EBaseRequestSet1)); |
|
401 |
||
402 |
SetState(EReqStateInitialise); |
|
403 |
||
404 |
iSession = aSession; |
|
405 |
iIsCompleted = iOperation->IsCompleted(); |
|
406 |
iError = KErrNone; |
|
407 |
iDriveNumber = KDriveInvalid; |
|
408 |
iCurrentPlugin = NULL; |
|
409 |
iOwnerPlugin = NULL; |
|
410 |
iDirectToDrive = EFalse; |
|
411 |
iClientThreadId= 0; |
|
412 |
iFlags &= ~(EFreeChanged | EPostInterceptEnabled | EPostOperation | EFsObjectOpen); |
|
413 |
iScratchValue = 0; |
|
414 |
} |
|
415 |
||
416 |
||
417 |
TParse& CFsRequest::Src() |
|
418 |
// |
|
419 |
// |
|
420 |
// |
|
421 |
{ |
|
422 |
Fault(EBaseRequestSrc); |
|
423 |
return(dummyP); |
|
424 |
} |
|
425 |
||
426 |
TParse& CFsRequest::Dest() |
|
427 |
// |
|
428 |
// |
|
429 |
// |
|
430 |
{ |
|
431 |
Fault(EBaseRequestDest); |
|
432 |
return(dummyP); |
|
433 |
} |
|
434 |
||
435 |
TDrive* CFsRequest::Drive() |
|
436 |
// |
|
437 |
// |
|
438 |
// |
|
439 |
{ |
|
440 |
Fault(EBaseRequestDrive); |
|
441 |
return(NULL); |
|
442 |
} |
|
443 |
||
444 |
TDrive* CFsRequest::SubstedDrive() |
|
445 |
// |
|
446 |
// |
|
447 |
// |
|
448 |
{ |
|
449 |
Fault(EBaseRequestSubstedDrive); |
|
450 |
return(NULL); |
|
451 |
} |
|
452 |
||
453 |
void CFsRequest::SetDrive(TDrive* /*aDrive*/) |
|
454 |
// |
|
455 |
// |
|
456 |
// |
|
457 |
{ |
|
458 |
Fault(EBaseRequestSetDrive); |
|
459 |
} |
|
460 |
||
461 |
void CFsRequest::SetSubstedDrive(TDrive* /*aDrive*/) |
|
462 |
// |
|
463 |
// |
|
464 |
// |
|
465 |
{ |
|
466 |
Fault(EBaseRequestSetSubstedDrive); |
|
467 |
} |
|
468 |
||
469 |
TInt CFsRequest::GetSlot(TFsPluginRequest::TF32ArgType aType) |
|
470 |
{ |
|
471 |
if(iOperation->Arg(0) == aType) return 0; |
|
472 |
if(iOperation->Arg(1) == aType) return 1; |
|
473 |
if(iOperation->Arg(2) == aType) return 2; |
|
474 |
if(iOperation->Arg(3) == aType) return 3; |
|
475 |
||
476 |
return(-1); |
|
477 |
} |
|
478 |
||
479 |
||
480 |
TBool CFsMessageRequest::IsNotifierSpecific() const |
|
481 |
{ |
|
482 |
#ifndef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
483 |
return EFalse; |
|
484 |
#else |
|
485 |
TInt function = iOperation->iFunction; |
|
486 |
return( function == EFsNotificationAdd || |
|
487 |
function == EFsNotificationBuffer || |
|
488 |
function == EFsNotificationCancel || |
|
489 |
function == EFsNotificationOpen || |
|
490 |
function == EFsNotificationRemove || |
|
491 |
function == EFsNotificationRequest || |
|
492 |
function == EFsNotificationSubClose); |
|
493 |
#endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
494 |
} |
|
495 |
||
496 |
||
497 |
TBool CFsMessageRequest::IsNotifierSupported() const |
|
498 |
{ |
|
499 |
#ifndef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
500 |
return EFalse; |
|
501 |
#else |
|
502 |
TInt function = iOperation->iFunction; |
|
503 |
return( function == EFsDelete || |
|
504 |
function == EFsRmDir || |
|
505 |
function == EFsMkDir || |
|
506 |
function == EFsFormatNext || |
|
507 |
function == EFsFileCreate || |
|
508 |
function == EFsFileReplace || |
|
509 |
function == EFsFileRename || |
|
510 |
function == EFsRename || |
|
511 |
function == EFsReplace || |
|
512 |
function == EFsSetDriveName || |
|
513 |
function == EFsSetVolume || |
|
514 |
function == EFsSetEntry || |
|
515 |
function == EFsFileSetAtt || |
|
516 |
function == EFsFileSet || |
|
517 |
function == EFsMountFileSystem || |
|
518 |
function == EFsDismountFileSystem || |
|
519 |
function == EFsFileSetSize || |
|
520 |
function == EFsFileWrite || |
|
521 |
function == EFsFileWriteDirty || |
|
522 |
function == EFsRawDiskWrite || |
|
523 |
function == EFsMountFileSystemScan); |
|
524 |
#endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
525 |
} |
|
526 |
||
527 |
||
528 |
TInt CFsRequest::Read(TFsPluginRequest::TF32ArgType aType, TInt& aVal) |
|
529 |
{ |
|
530 |
if(iOperation->Arg(0) == aType) { aVal = Message().Int0(); return KErrNone; } |
|
531 |
if(iOperation->Arg(1) == aType) { aVal = Message().Int1(); return KErrNone; } |
|
532 |
if(iOperation->Arg(2) == aType) { aVal = Message().Int2(); return KErrNone; } |
|
533 |
if(iOperation->Arg(3) == aType) { aVal = Message().Int3(); return KErrNone; } |
|
534 |
||
535 |
return KErrNotSupported; |
|
536 |
} |
|
537 |
||
538 |
||
539 |
TInt CFsRequest::Read(TFsPluginRequest::TF32ArgType aType, TUint& aVal) |
|
540 |
{ |
|
541 |
if(iOperation->Arg(0) == aType) { aVal = (TUint)Message().Int0(); return KErrNone; } |
|
542 |
if(iOperation->Arg(1) == aType) { aVal = (TUint)Message().Int1(); return KErrNone; } |
|
543 |
if(iOperation->Arg(2) == aType) { aVal = (TUint)Message().Int2(); return KErrNone; } |
|
544 |
if(iOperation->Arg(3) == aType) { aVal = (TUint)Message().Int3(); return KErrNone; } |
|
545 |
||
546 |
return KErrNotSupported; |
|
547 |
} |
|
548 |
||
549 |
TInt CFsRequest::Read(TFsPluginRequest::TF32ArgType aType, TInt64& aVal) |
|
550 |
{ |
|
551 |
TPckg<TInt64> pkVal(aVal); |
|
552 |
// EFsFileLock, EFsFileUnLock, EFsFileSeek and EFsFileSetSize need special treatment |
|
553 |
if(iOperation->Arg(0) == aType) |
|
554 |
{ |
|
555 |
if((iOperation->Function()==EFsFileLock) || |
|
556 |
(iOperation->Function()==EFsFileUnLock) ) |
|
557 |
{ |
|
558 |
if(IsDescData(KMsgPtr0)) |
|
559 |
Read(KMsgPtr0,pkVal); |
|
560 |
else |
|
561 |
aVal = MAKE_TINT64(0, Message().Int0()); // Position is unsigned value |
|
562 |
return KErrNone; |
|
563 |
} |
|
564 |
||
565 |
if((iOperation->Function()==EFsFileSeek) || // Seek offset (input paramater) |
|
566 |
(iOperation->Function()==EFsFileSize) || // Size (output paramater) |
|
567 |
(iOperation->Function()==EFsFileSetSize) ) // Size to be set (input paramater) |
|
568 |
{ |
|
569 |
if(IsDescData(KMsgPtr0)) |
|
570 |
Read(KMsgPtr0,pkVal); |
|
571 |
else |
|
572 |
aVal = Message().Int0(); // Seek offset / Size is signed value |
|
573 |
return KErrNone; |
|
574 |
} |
|
575 |
||
576 |
aVal = Message().Int0(); |
|
577 |
return KErrNone; |
|
578 |
} |
|
579 |
||
580 |
// EFsFileLock and EFsFileUnLock need special treatment |
|
581 |
if(iOperation->Arg(1) == aType) |
|
582 |
{ |
|
583 |
if((iOperation->Function()==EFsFileLock) || |
|
584 |
(iOperation->Function()==EFsFileUnLock) ) |
|
585 |
{ |
|
586 |
if(IsDescData(KMsgPtr1)) |
|
587 |
Read(KMsgPtr1,pkVal); |
|
588 |
else |
|
589 |
aVal = MAKE_TINT64(0, Message().Int1()); // Length is unsigned value |
|
590 |
return KErrNone; |
|
591 |
} |
|
592 |
||
593 |
aVal = Message().Int1(); |
|
594 |
return KErrNone; |
|
595 |
} |
|
596 |
||
597 |
// EFsFileRead, EFsFileWrite, EFsFileSeek and EFsReadFileSection need special treatment |
|
598 |
if(iOperation->Arg(2) == aType) |
|
599 |
{ |
|
600 |
if((iOperation->Function()==EFsFileRead) || |
|
601 |
(iOperation->Function()==EFsFileWrite) ) |
|
602 |
{ |
|
603 |
if(IsDescData(KMsgPtr2)) |
|
604 |
Read(KMsgPtr2,pkVal); |
|
605 |
else |
|
606 |
{ |
|
607 |
if(Message().Int2() == (TInt)I64LOW(KCurrentPosition64)) |
|
608 |
aVal = KCurrentPosition64; // Position is KCurrentPosition64 (-1) |
|
609 |
else |
|
610 |
aVal = MAKE_TINT64(0,Message().Int2()); // Position is unsigned value |
|
611 |
} |
|
612 |
return KErrNone; |
|
613 |
} |
|
614 |
||
615 |
if(iOperation->Function()==EFsFileSeek) |
|
616 |
{ |
|
617 |
if(IsDescData(KMsgPtr2)) |
|
618 |
Read(KMsgPtr2,pkVal); |
|
619 |
else |
|
620 |
aVal = Message().Int2(); // New position is signed value |
|
621 |
return KErrNone; |
|
622 |
} |
|
623 |
||
624 |
if(iOperation->Function()==EFsReadFileSection) |
|
625 |
{ |
|
626 |
if(IsDescData(KMsgPtr2)) |
|
627 |
Read(KMsgPtr2,pkVal); |
|
628 |
else |
|
629 |
aVal = MAKE_TINT64(0,Message().Int2()); // Position is unsigned value |
|
630 |
return KErrNone; |
|
631 |
} |
|
632 |
||
633 |
aVal = Message().Int2(); |
|
634 |
return KErrNone; |
|
635 |
} |
|
636 |
||
637 |
if(iOperation->Arg(3) == aType) |
|
638 |
{ |
|
639 |
aVal = Message().Int3(); |
|
640 |
return KErrNone; |
|
641 |
} |
|
642 |
||
643 |
return KErrNotSupported; |
|
644 |
} |
|
645 |
||
646 |
void CFsRequest::SetAndOpenScratchValue(const TInt64& aValue) |
|
647 |
{ |
|
648 |
if (IsFsObjectOpen()) |
|
649 |
{ |
|
650 |
((CFsDispatchObject*) I64LOW(iScratchValue))->Close(); |
|
651 |
SetFsObjectOpen(EFalse); |
|
652 |
} |
|
653 |
if (I64LOW(aValue) && iOperation && (iOperation->iFlags & EFileShare)) |
|
654 |
{ |
|
655 |
((CFsDispatchObject*) I64LOW(aValue))->Open(); |
|
656 |
SetFsObjectOpen(ETrue); |
|
657 |
} |
|
658 |
iScratchValue = aValue; |
|
659 |
} |
|
660 |
||
661 |
||
662 |
TInt CFsRequest::Read(TFsPluginRequest::TF32ArgType aType, TDes8& aDes, TInt aOffset) |
|
663 |
{ |
|
664 |
TInt slot = GetSlot(aType); |
|
665 |
if(slot >= 0) |
|
666 |
return Read(slot, aDes, aOffset); |
|
667 |
return KErrNotSupported; |
|
668 |
} |
|
669 |
||
670 |
||
671 |
TInt CFsRequest::Read(TFsPluginRequest::TF32ArgType aType, TDes16& aDes, TInt aOffset) |
|
672 |
{ |
|
673 |
TInt slot = GetSlot(aType); |
|
674 |
if(slot >= 0) |
|
675 |
return Read(slot, aDes, aOffset); |
|
676 |
return KErrNotSupported; |
|
677 |
} |
|
678 |
||
679 |
||
680 |
TInt CFsRequest::Write(TFsPluginRequest::TF32ArgType aType, const TDesC8& aDes, TInt aOffset) |
|
681 |
{ |
|
682 |
TInt slot = GetSlot(aType); |
|
683 |
if(slot >= 0) |
|
684 |
return Write(slot, aDes, aOffset); |
|
685 |
return KErrNotSupported; |
|
686 |
} |
|
687 |
||
688 |
||
689 |
TInt CFsRequest::Write(TFsPluginRequest::TF32ArgType aType, const TDesC16& aDes, TInt aOffset) |
|
690 |
{ |
|
691 |
TInt slot = GetSlot(aType); |
|
692 |
if(slot >= 0) |
|
693 |
return Write(slot, aDes, aOffset); |
|
694 |
return KErrNotSupported; |
|
695 |
} |
|
696 |
||
697 |
||
698 |
TInt CFsRequest::Read(const TInt aMsgPtr,TDes8 &aDes) |
|
699 |
{ |
|
700 |
if (Message().Handle() == KLocalMessageHandle) |
|
701 |
{ |
|
702 |
TDesC8* pDes = (TDesC8*) ((const RLocalMessage*) &Message())->Arg(aMsgPtr); |
|
703 |
if (aDes.MaxLength() < pDes->Length()) |
|
704 |
return KErrTooBig; |
|
705 |
aDes.Copy(*pDes); |
|
706 |
return KErrNone; |
|
707 |
} |
|
708 |
||
709 |
return Message().Read(aMsgPtr,aDes,0); |
|
710 |
} |
|
711 |
||
712 |
||
713 |
TInt CFsRequest::Read(const TInt aMsgPtr,TDes8 &aDes,TInt anOffset) |
|
714 |
{ |
|
715 |
if (Message().Handle() == KLocalMessageHandle) |
|
716 |
{ |
|
717 |
TDesC8* pDes = (TDesC8*) ((const RLocalMessage*) &Message())->Arg(aMsgPtr); |
|
718 |
if (aDes.MaxLength() < pDes->Length() + anOffset) |
|
719 |
return KErrTooBig; |
|
720 |
aDes.SetLength(pDes->Length() + anOffset); |
|
721 |
aDes.MidTPtr(anOffset).Copy(*pDes); |
|
722 |
return KErrNone; |
|
723 |
} |
|
724 |
||
725 |
return Message().Read(aMsgPtr,aDes,anOffset); |
|
726 |
} |
|
727 |
||
728 |
||
729 |
TInt CFsRequest::Read(const TInt aMsgPtr,TDes16 &aDes) |
|
730 |
{ |
|
731 |
if (Message().Handle() == KLocalMessageHandle) |
|
732 |
{ |
|
733 |
TDesC16* pDes = (TDesC16*) ((const RLocalMessage*) &Message())->Arg(aMsgPtr); |
|
734 |
if (aDes.MaxLength() < pDes->Length()) |
|
735 |
return KErrTooBig; |
|
736 |
aDes.Copy(*pDes); |
|
737 |
return KErrNone; |
|
738 |
} |
|
739 |
||
740 |
return Message().Read(aMsgPtr,aDes,0); |
|
741 |
} |
|
742 |
||
743 |
||
744 |
TInt CFsRequest::Read(const TInt aMsgPtr,TDes16 &aDes,TInt anOffset) |
|
745 |
{ |
|
746 |
if (Message().Handle() == KLocalMessageHandle) |
|
747 |
{ |
|
748 |
TDesC16* pDes = (TDesC16*) ((const RLocalMessage*) &Message())->Arg(aMsgPtr); |
|
749 |
if (aDes.MaxLength() < pDes->Length() + anOffset) |
|
750 |
return KErrTooBig; |
|
751 |
aDes.SetLength(pDes->Length() + anOffset); |
|
752 |
aDes.MidTPtr(anOffset).Copy(*pDes); |
|
753 |
return KErrNone; |
|
754 |
} |
|
755 |
||
756 |
return Message().Read(aMsgPtr,aDes,anOffset); |
|
757 |
} |
|
758 |
||
759 |
||
760 |
TInt CFsRequest::Write(const TInt aMsgNum,const TDesC8 &aDes) |
|
761 |
{ |
|
762 |
if (Message().Handle() == KLocalMessageHandle) |
|
763 |
{ |
|
764 |
TDes8* pDes = (TDes8*) ((const RLocalMessage*) &Message())->Arg(aMsgNum); |
|
765 |
if (pDes->MaxLength() < aDes.Length()) |
|
766 |
return KErrTooBig; |
|
767 |
pDes->Copy(aDes); |
|
768 |
return KErrNone; |
|
769 |
} |
|
770 |
||
771 |
return Message().Write(aMsgNum,aDes,0); |
|
772 |
} |
|
773 |
||
774 |
||
775 |
TInt CFsRequest::Write(const TInt aMsgNum,const TDesC8 &aDes,TInt anOffset) |
|
776 |
{ |
|
777 |
if (Message().Handle() == KLocalMessageHandle) |
|
778 |
{ |
|
779 |
TDes8* pDes = (TDes8*) ((const RLocalMessage*) &Message())->Arg(aMsgNum); |
|
780 |
if (pDes->MaxLength() < aDes.Length() + anOffset) |
|
781 |
return KErrTooBig; |
|
782 |
pDes->SetLength(aDes.Length() + anOffset); |
|
783 |
pDes->MidTPtr(anOffset).Copy(aDes); |
|
784 |
return KErrNone; |
|
785 |
} |
|
786 |
||
787 |
return Message().Write(aMsgNum,aDes,anOffset); |
|
788 |
} |
|
789 |
||
790 |
||
791 |
TInt CFsRequest::Write(const TInt aMsgNum,const TDesC16 &aDes) |
|
792 |
{ |
|
793 |
if (Message().Handle() == KLocalMessageHandle) |
|
794 |
{ |
|
795 |
TDes16* pDes = (TDes16*) ((const RLocalMessage*) &Message())->Arg(aMsgNum); |
|
796 |
if (pDes->MaxLength() < aDes.Length()) |
|
797 |
return KErrTooBig; |
|
798 |
pDes->Copy(aDes); |
|
799 |
return KErrNone; |
|
800 |
} |
|
801 |
||
802 |
return Message().Write(aMsgNum,aDes,0); |
|
803 |
} |
|
804 |
||
805 |
||
806 |
TInt CFsRequest::Write(const TInt aMsgNum,const TDesC16 &aDes,TInt anOffset) |
|
807 |
{ |
|
808 |
if (Message().Handle() == KLocalMessageHandle) |
|
809 |
{ |
|
810 |
TDes16* pDes = (TDes16*) ((const RLocalMessage*) &Message())->Arg(aMsgNum); |
|
811 |
if (pDes->MaxLength() < aDes.Length() + anOffset) |
|
812 |
return KErrTooBig; |
|
813 |
pDes->SetLength(aDes.Length() + anOffset); |
|
814 |
pDes->MidTPtr(anOffset).Copy(aDes); |
|
815 |
return KErrNone; |
|
816 |
} |
|
817 |
||
818 |
return Message().Write(aMsgNum,aDes,anOffset); |
|
819 |
} |
|
820 |
||
821 |
||
822 |
void CFsRequest::ReadL(const TInt aMsgPtr,TDes8 &aDes) |
|
823 |
{ User::LeaveIfError(Read(aMsgPtr,aDes)); } |
|
824 |
||
825 |
void CFsRequest::ReadL(const TInt aMsgPtr,TDes8 &aDes,TInt anOffset) |
|
826 |
{ User::LeaveIfError(Read(aMsgPtr,aDes,anOffset)); } |
|
827 |
||
828 |
void CFsRequest::ReadL(const TInt aMsgPtr,TDes16 &aDes) |
|
829 |
{ User::LeaveIfError(Read(aMsgPtr,aDes)); } |
|
830 |
||
831 |
void CFsRequest::ReadL(const TInt aMsgPtr,TDes16 &aDes,TInt anOffset) |
|
832 |
{ User::LeaveIfError(Read(aMsgPtr,aDes,anOffset)); } |
|
833 |
||
834 |
void CFsRequest::WriteL(const TInt aMsgNum,const TDesC8 &aDes) |
|
835 |
{ User::LeaveIfError(Write(aMsgNum,aDes)); } |
|
836 |
||
837 |
void CFsRequest::WriteL(const TInt aMsgNum,const TDesC8 &aDes,TInt anOffset) |
|
838 |
{ User::LeaveIfError(Write(aMsgNum,aDes,anOffset)); } |
|
839 |
||
840 |
void CFsRequest::WriteL(const TInt aMsgNum,const TDesC16 &aDes) |
|
841 |
{ User::LeaveIfError(Write(aMsgNum,aDes)); } |
|
842 |
||
843 |
void CFsRequest::WriteL(const TInt aMsgNum,const TDesC16 &aDes,TInt anOffset) |
|
844 |
{ User::LeaveIfError(Write(aMsgNum,aDes,anOffset)); } |
|
845 |
||
846 |
||
847 |
/** |
|
848 |
@param aMsgNum message argument index |
|
849 |
@return client side descriptor length |
|
850 |
*/ |
|
851 |
TInt CFsRequest::GetDesLength(const TInt aMsgNum) |
|
852 |
{ |
|
853 |
if (Message().Handle() == KLocalMessageHandle) |
|
854 |
{ |
|
855 |
TDes8* pDes = (TDes8*) ((const RLocalMessage*) &Message())->Arg(aMsgNum); |
|
856 |
return pDes->Length(); |
|
857 |
} |
|
858 |
else |
|
859 |
{ |
|
860 |
return Message().GetDesLength(aMsgNum); |
|
861 |
} |
|
862 |
} |
|
863 |
||
864 |
const RMessage2& CFsRequest::Message() |
|
865 |
// |
|
866 |
// |
|
867 |
// |
|
868 |
{ |
|
869 |
Fault(EBaseRequestMessage); |
|
870 |
return(dummyM); |
|
871 |
} |
|
872 |
||
873 |
||
874 |
||
875 |
void CFsMessageRequest::Set(const RMessage2& aMessage,CSessionFs* aSession) |
|
876 |
// |
|
877 |
// For reuseable request |
|
878 |
// |
|
879 |
{ |
|
880 |
iMessage=aMessage; |
|
881 |
iDrive=NULL; |
|
882 |
iSubstedDrive=NULL; |
|
883 |
CFsRequest::Set(aSession); |
|
884 |
SetFreeChanged(EFalse); |
|
885 |
EnablePostIntercept(ETrue); |
|
886 |
} |
|
887 |
||
888 |
||
889 |
void CFsMessageRequest::Set(const RMessage2& aMessage,const TOperation& aOperation,CSessionFs* aSession) |
|
890 |
// |
|
891 |
// |
|
892 |
// |
|
893 |
{ |
|
894 |
iCurrentPlugin=NULL; |
|
895 |
iMessage=aMessage; |
|
896 |
iDrive=NULL; |
|
897 |
iSubstedDrive=NULL; |
|
898 |
CFsRequest::Set(aOperation,aSession); |
|
899 |
SetFreeChanged(EFalse); |
|
900 |
EnablePostIntercept(ETrue); |
|
901 |
} |
|
902 |
||
903 |
void CFsMessageRequest::Set(const TOperation& aOperation) |
|
904 |
{ |
|
905 |
iOperation=const_cast<TOperation*>(&aOperation); |
|
906 |
} |
|
907 |
||
908 |
void CFsMessageRequest::Process() |
|
909 |
// |
|
910 |
// Process the request - (passing to a plugin or a drive thread) |
|
911 |
// |
|
912 |
{ |
|
913 |
__THRD_PRINT3(_L("CFsMessageRequest::Process() req %08x state %d plugin 0x%x"), this, iReqState, iCurrentPlugin); |
|
914 |
||
915 |
// initialise request - if not initialised already |
|
916 |
if (iReqState == EReqStateInitialise) |
|
917 |
{ |
|
918 |
TInt r = DoInitialise(); |
|
919 |
if (r == EReqActionComplete) |
|
920 |
{ |
|
921 |
return; |
|
922 |
} |
|
923 |
else if (r == EReqActionBusy) // request postponed ? |
|
924 |
{ |
|
925 |
SetState(EReqStateInitialise); |
|
926 |
Dispatch(EFalse); |
|
927 |
return; |
|
928 |
} |
|
929 |
else if (r == KErrNone && iCurrentPlugin) // dispatch to plugin thread ? |
|
930 |
{ |
|
931 |
Dispatch(EFalse); |
|
932 |
return; |
|
933 |
} |
|
934 |
} |
|
935 |
||
936 |
if(iCurrentPlugin) |
|
937 |
{ |
|
938 |
if (IsPostOperation()) |
|
939 |
{ |
|
940 |
ProcessPostOperation(); |
|
941 |
return; |
|
942 |
} |
|
943 |
||
944 |
if(!IsPluginSpecific()) |
|
945 |
{ |
|
946 |
ProcessPreOperation(); |
|
947 |
return; |
|
948 |
} |
|
949 |
} |
|
950 |
||
951 |
||
952 |
// Is there a PostInitialise function ? |
|
953 |
if (iReqState == EReqStatePostInitialise) |
|
954 |
{ |
|
955 |
TInt r = PostInitialise(); |
|
956 |
if (r == EReqActionComplete) |
|
957 |
{ |
|
958 |
return; |
|
959 |
} |
|
960 |
else if (r == EReqActionBusy) // request postponed ? |
|
961 |
{ |
|
962 |
SetState(EReqStatePostInitialise); |
|
963 |
Dispatch(EFalse); |
|
964 |
return; |
|
965 |
} |
|
966 |
} |
|
967 |
||
968 |
ProcessDriveOperation(); |
|
969 |
} |
|
970 |
||
971 |
void CFsMessageRequest::ProcessPostOperation() |
|
972 |
// |
|
973 |
// Process the message in post operation mode (handled by the current plugin) |
|
974 |
// |
|
975 |
{ |
|
976 |
TInt err = KErrNone; |
|
977 |
if(!iCurrentPlugin->IsPluginThread(*this)) |
|
978 |
{ |
|
979 |
// The request hasn't come from this plugin so it's safe to dispatch |
|
980 |
TFsPluginRequest request(this); |
|
981 |
TRAPD(leaveValue, err = iCurrentPlugin->DoRequestL(request)); |
|
982 |
if(leaveValue != KErrNone) |
|
983 |
{ |
|
984 |
Panic(KFsClient,leaveValue); |
|
985 |
if(iOperation->IsOpenSubSess()) |
|
986 |
RequestAllocator::OpenSubFailed(Session()); |
|
987 |
Free(); |
|
988 |
return; |
|
989 |
} |
|
990 |
||
991 |
if(!IsExpectedResult(err)) |
|
992 |
{ |
|
993 |
Complete(err); |
|
994 |
return; |
|
995 |
} |
|
996 |
} |
|
997 |
||
998 |
// Find the previous plugin in the chain and dispatch |
|
999 |
// - If no more plugins are interested in this message, then complete |
|
1000 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this, ETrue); |
|
1001 |
if(iCurrentPlugin == NULL) |
|
1002 |
{ |
|
1003 |
Complete(GetError()); |
|
1004 |
return; |
|
1005 |
} |
|
1006 |
||
1007 |
Dispatch(); |
|
1008 |
return; |
|
1009 |
} |
|
1010 |
||
1011 |
||
1012 |
void CFsMessageRequest::ProcessPreOperation() |
|
1013 |
// |
|
1014 |
// Process the message in pre operation mode (handled by the current plugin) |
|
1015 |
// |
|
1016 |
{ |
|
1017 |
TInt err = KErrNone; |
|
1018 |
if(!iCurrentPlugin->IsPluginThread(*this)) |
|
1019 |
{ |
|
1020 |
// The request hasn't come from this plugin so it's safe to dispatch |
|
1021 |
TFsPluginRequest request(this); |
|
1022 |
TRAPD(leaveValue, err = iCurrentPlugin->DoRequestL(request)); |
|
1023 |
__PLUGIN_PRINT1(_L("PLUGIN: CFsMessageRequest:: %x processed by plugin"), this); |
|
1024 |
||
1025 |
if((iOperation->Function() == EFsDismountPlugin) && (err != KErrPermissionDenied)) |
|
1026 |
{ |
|
1027 |
TRAP(leaveValue, err = iOperation->DoRequestL(this)); |
|
1028 |
} |
|
1029 |
||
1030 |
if(leaveValue != KErrNone) |
|
1031 |
{ |
|
1032 |
Panic(KFsClient,leaveValue); |
|
1033 |
if(iOperation->IsOpenSubSess()) //this should be close subsession |
|
1034 |
RequestAllocator::OpenSubFailed(Session()); //need a close subsession fail |
|
1035 |
Free(); |
|
1036 |
return; |
|
1037 |
} |
|
1038 |
} |
|
1039 |
||
1040 |
if(err == KErrNone) |
|
1041 |
{ |
|
1042 |
// Find the next plugin in the chain and dispatch |
|
1043 |
// - If no more plugins are interested in this message, |
|
1044 |
// then Dispatch() will process the request in drive/main thread context. |
|
1045 |
FsPluginManager::NextPlugin(iCurrentPlugin, this,(TBool)ETrue); |
|
1046 |
if(iCurrentPlugin && IsPostOperation()) |
|
1047 |
SetPostOperation(EFalse); |
|
1048 |
Dispatch(); |
|
1049 |
return; |
|
1050 |
} |
|
1051 |
// KErrCompletion may be returned by the plugin to |
|
1052 |
// indicate that it has process the message itself (do post-intercept) |
|
1053 |
else if (err == KErrCompletion) |
|
1054 |
{ |
|
1055 |
// Find the previous plugin in the chain and dispatch |
|
1056 |
// - If no more plugins are interested in this message, then complete |
|
1057 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this,(TBool)ETrue); |
|
1058 |
if(iCurrentPlugin != NULL) |
|
1059 |
{ |
|
1060 |
SetPostOperation(ETrue); |
|
1061 |
err = KErrNone; |
|
1062 |
Dispatch(); |
|
1063 |
return; |
|
1064 |
} |
|
1065 |
else |
|
1066 |
{ |
|
1067 |
err = KErrNone; |
|
1068 |
} |
|
1069 |
} |
|
1070 |
||
1071 |
Complete(err); |
|
1072 |
return; |
|
1073 |
} |
|
1074 |
||
1075 |
||
1076 |
void CFsMessageRequest::ProcessDriveOperation() |
|
1077 |
// |
|
1078 |
// Process the message in drive (or main thread) context |
|
1079 |
// |
|
1080 |
{ |
|
1081 |
||
1082 |
// A new request is to be processed - kick off the inactivity/finalisation timer... |
|
1083 |
FsThreadManager::StartFinalisationTimer(iDriveNumber); |
|
1084 |
||
1085 |
TInt err = KErrNone; |
|
1086 |
||
1087 |
TRAPD(leaveValue, err = iOperation->DoRequestL(this)); |
|
1088 |
||
1089 |
// Cancel hung state if a request from the drive thread has finished |
|
1090 |
FsThreadManager::SetDriveHung(DriveNumber(), EFalse); |
|
1091 |
||
1092 |
if(leaveValue != KErrNone) |
|
1093 |
{ |
|
1094 |
Panic(KFsClient,leaveValue); |
|
1095 |
if(iOperation->IsOpenSubSess()) |
|
1096 |
RequestAllocator::OpenSubFailed(Session()); |
|
1097 |
Free(); |
|
1098 |
return; |
|
1099 |
} |
|
1100 |
||
1101 |
// request postponed ? (e.g. if a page used by file cache is busy, |
|
1102 |
// or because of fair scheduling). |
|
1103 |
if (err == EReqActionBusy) |
|
1104 |
{ |
|
1105 |
Dispatch(); |
|
1106 |
return; |
|
1107 |
} |
|
1108 |
||
1109 |
iLastError = err; |
|
1110 |
||
1111 |
if(!IsExpectedResult(err) || IsPluginSpecific()) |
|
1112 |
{ |
|
1113 |
// no need to call DoNotify here since that requires err==KErrNone |
|
1114 |
Complete(err); |
|
1115 |
return; |
|
1116 |
} |
|
1117 |
||
1118 |
SetError(err); |
|
220 | 1119 |
|
1120 |
if (IsExpectedResult(err) && !IsPluginSpecific() && !IsNotifierSpecific()) |
|
1121 |
DoNotifyDiskSpace(KErrNone); |
|
0 | 1122 |
|
1123 |
// Start issuing the post-operation requests starting from the bottom of the chain |
|
1124 |
iCurrentPlugin = NULL; |
|
1125 |
if (PostInterceptEnabled()) |
|
1126 |
{ |
|
1127 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this,(TBool)ETrue); |
|
1128 |
if(iCurrentPlugin && !iCurrentPlugin->IsPluginThread(*this)) |
|
1129 |
{ |
|
1130 |
SetPostOperation(ETrue); |
|
1131 |
if (DispatchToPlugin()) |
|
1132 |
return; |
|
1133 |
} |
|
1134 |
} |
|
1135 |
||
1136 |
Complete(GetError()); |
|
1137 |
return; |
|
1138 |
} |
|
1139 |
||
1140 |
void CFsMessageRequest::Complete(TInt aError) |
|
1141 |
// |
|
1142 |
// |
|
1143 |
// |
|
1144 |
{ |
|
1145 |
__THRD_PRINT2(_L("----- CFsMessageRequest::Complete() req %08x with %d"), this, aError); |
|
1146 |
||
1147 |
if(aError!=KErrNone) |
|
1148 |
{ |
|
1149 |
if(iOperation->IsOpenSubSess()) |
|
1150 |
RequestAllocator::OpenSubFailed(Session()); |
|
1151 |
} |
|
1152 |
||
1153 |
iLastError = aError; |
|
1154 |
||
1155 |
// Call the current MessageOp's completion routine - if this returns EReqActionComplete, |
|
1156 |
// then pop the request and call the next MessageOps's completion routine. |
|
1157 |
// Do this until there are no more MessageOp's on the stack. |
|
1158 |
// |
|
1159 |
// Completion return codes: |
|
1160 |
// EReqActionOwnedByPlugin: DON'T dispatch message again, DON'T complete message |
|
1161 |
// EReqActionComplete: DON'T dispatch message again, DO complete message |
|
1162 |
// EReqActionContinue: DO dispatch message again, DON'T complete message |
|
1163 |
// EReqActionBusy DO dispatch message again, DON'T complete message, |
|
1164 |
TInt completeErr; |
|
1165 |
||
1166 |
for (completeErr = EReqActionComplete; CurrentOperationPtr() != NULL && completeErr == EReqActionComplete; ) |
|
1167 |
{ |
|
1168 |
// Get the completion routine from the current TMsgOperation and then pop it |
|
1169 |
TFsRequestFunc doComplete = CurrentOperation().iComplete; |
|
1170 |
PopOperation(); |
|
1171 |
||
1172 |
// Check that a completion routine is supplied if this isn't the last TMsgOperation |
|
1173 |
__ASSERT_ALWAYS(iCurrentOperation == NULL || doComplete != NULL, Fault(EBadOperationIndex)); |
|
1174 |
||
1175 |
// Call the completion routine |
|
1176 |
if (doComplete) |
|
1177 |
completeErr = doComplete(this); |
|
1178 |
||
1179 |
// Check return code is valid |
|
1180 |
__ASSERT_DEBUG(completeErr == EReqActionContinue || completeErr == EReqActionBusy || completeErr == EReqActionComplete || completeErr == EReqActionOwnedByPlugin, Fault(EBadOperationCompletionCode)); |
|
1181 |
} |
|
1182 |
||
1183 |
// a set of flags to determine what actions to take for each return code |
|
1184 |
enum |
|
1185 |
{ |
|
1186 |
EDispatch = 0x01, // dispatch request |
|
1187 |
EComplete = 0x02, // complete request |
|
1188 |
EFree =0x04, // free request |
|
1189 |
EResetPostInitialised = 0x08, // call iPostInitialise again |
|
1190 |
EDispatchToFront = 0x10 // dispatch to back of drive thread queue |
|
1191 |
}; |
|
1192 |
const TUint actions[8] = |
|
1193 |
{ |
|
1194 |
// 0 - EReqActionContinue |
|
1195 |
EDispatch, |
|
1196 |
// 1 - unused |
|
1197 |
0, |
|
1198 |
// 2 - unused |
|
1199 |
0, |
|
1200 |
// 3 - unused |
|
1201 |
0, |
|
1202 |
// 4 - EReqActionCompleteAndDispatch |
|
1203 |
EDispatch | EComplete | EResetPostInitialised | EDispatchToFront, |
|
1204 |
// 5 - EReqActionOwnedByPlugin |
|
1205 |
0, |
|
1206 |
// 6 - EReqActionBusy |
|
1207 |
EDispatch | EResetPostInitialised, |
|
1208 |
// 7 - EReqActionComplete |
|
1209 |
EComplete | EFree, |
|
1210 |
}; |
|
1211 |
||
1212 |
TUint actionFlags = actions[((TUint32) completeErr) & 0x00000007]; |
|
1213 |
||
1214 |
// To dispatch to drive thread and intercept before DoRequestL() |
|
1215 |
// we must re-call iPostInitialise(), so reset iPostInitialised flag |
|
1216 |
if (actionFlags & EResetPostInitialised) |
|
1217 |
{ |
|
1218 |
// can only postpone the request if there's a PostInitialise() function |
|
1219 |
__ASSERT_DEBUG(iOperation->iPostInitialise , Fault(EBadOperationCompletionCode)); |
|
1220 |
SetState(EReqStatePostInitialise); |
|
1221 |
} |
|
1222 |
||
1223 |
||
1224 |
||
1225 |
TInt dispatchError = KErrNone; |
|
1226 |
TBool completeMessage = (iLastError != KErrNone) || (iIsCompleted && (actionFlags & EComplete)); |
|
1227 |
||
1228 |
// Need to lock drive to prevent both file server and drive thread from completing the same message (!) |
|
1229 |
// or the dispatched thread from freeing the message before the first thread has completed it |
|
1230 |
TDrive* drive = iDrive; |
|
1231 |
if (drive) |
|
1232 |
drive->Lock(); |
|
1233 |
||
1234 |
// don't go back up plugin chain once message has been completed |
|
1235 |
if (completeMessage) |
|
1236 |
EnablePostIntercept(EFalse); |
|
1237 |
||
1238 |
if (actionFlags & EDispatch) |
|
1239 |
{ |
|
1240 |
__ASSERT_DEBUG(((actionFlags & EFree) == 0), Fault(EInvalidCompletionFlags)); |
|
1241 |
__ASSERT_DEBUG (iCurrentPlugin == NULL, Fault(EInvalidMsgState)); |
|
1242 |
dispatchError = DispatchToDrive(EFalse, actionFlags & EDispatchToFront); |
|
1243 |
} |
|
1244 |
||
1245 |
||
1246 |
if ((actionFlags & EComplete) && IsExpectedResult(iLastError) && !IsPluginSpecific() && !IsNotifierSpecific()) |
|
1247 |
DoNotify(KErrNone); |
|
1248 |
||
1249 |
||
1250 |
if (completeMessage) |
|
1251 |
{ |
|
1252 |
iIsCompleted = EFalse; |
|
1253 |
TInt msgHandle = Message().Handle(); |
|
1254 |
if ((msgHandle != KLocalMessageHandle) && (msgHandle != 0)) |
|
1255 |
Message().Complete(iLastError); |
|
1256 |
if (IsPluginRequest()) |
|
1257 |
CFsPlugin::Complete(this, iLastError); |
|
1258 |
} |
|
1259 |
||
1260 |
if(iOperation->Function() == EFsFileSubClose) |
|
1261 |
{ |
|
1262 |
HBufC* pFileName = (HBufC*) I64HIGH(ScratchValue64()); |
|
1263 |
if(pFileName) |
|
1264 |
{ |
|
1265 |
delete pFileName; |
|
1266 |
SetScratchValue(NULL); |
|
1267 |
} |
|
1268 |
} |
|
1269 |
||
1270 |
if (drive) |
|
1271 |
drive->UnLock(); |
|
1272 |
||
1273 |
if (actionFlags & EFree) |
|
1274 |
Free(); |
|
1275 |
||
1276 |
// if the dispatch failed, then continue with popping MessageOps from the stack. |
|
1277 |
if (dispatchError != KErrNone) |
|
1278 |
Complete(dispatchError); |
|
1279 |
} |
|
1280 |
||
1281 |
void CFsMessageRequest::DoNotify(TInt aError) |
|
1282 |
// |
|
1283 |
// |
|
1284 |
// |
|
1285 |
{ |
|
1286 |
__PRINT1(_L("----- CFsMessageRequest::DoNotify() with %d"),aError); |
|
1287 |
||
1288 |
TInt driveNumber = DriveNumber(); |
|
1289 |
||
1290 |
if(aError==KErrNone) |
|
1291 |
{ |
|
1292 |
if(!(FsNotify::IsChangeQueEmpty(driveNumber))) |
|
220 | 1293 |
FsNotify::HandleChange(this,driveNumber); |
0 | 1294 |
|
1295 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
1296 |
if (iOperation->iFunction == EFsFileWrite) |
|
1297 |
{ |
|
1298 |
CFileShare* share = (CFileShare*) this->ScratchValue(); |
|
1299 |
CFileCB* file = &share->File(); |
|
1300 |
CFileCache* fileCache = file->FileCache(); |
|
1301 |
||
1302 |
// Manage notifications for write with no cache or a write-through |
|
1303 |
if (!fileCache || !fileCache->IsDirty()) |
|
1304 |
{ |
|
1305 |
FsNotificationManager::HandleChange((CFsClientMessageRequest&)*this); |
|
1306 |
} |
|
1307 |
} |
|
1308 |
else if((iOperation->iFunction == EFsFileWriteDirty) && FsNotificationManager::IsInitialised()) |
|
1309 |
{ |
|
1310 |
CFileShare* share; |
|
1311 |
CFileCB* file; |
|
1312 |
GetFileFromScratch(this, share, file); |
|
1313 |
||
1314 |
TFileName path; |
|
1315 |
path.Append(file->DriveNumber() + 'A'); |
|
1316 |
path.Append(':'); |
|
1317 |
path.Append(file->FileName().Des()); |
|
1318 |
||
1319 |
// Manage notifications for write with caching enabled |
|
1320 |
FsNotificationManager::HandleChange((CFsClientMessageRequest*)this, path, TFsNotification::EFileChange); |
|
1321 |
} |
|
1322 |
else if(IsNotifierSupported()) |
|
1323 |
{ |
|
1324 |
FsNotificationManager::HandleChange((CFsClientMessageRequest&)*this); |
|
1325 |
} |
|
1326 |
#endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
1327 |
} |
|
1328 |
} |
|
1329 |
||
220 | 1330 |
void CFsMessageRequest::DoNotifyDiskSpace(TInt aError) |
1331 |
{ |
|
1332 |
__PRINT1(_L("----- CFsMessageRequest::DoNotifyDiskSpace() with %d"),aError); |
|
1333 |
if(aError != KErrNone) |
|
1334 |
return; |
|
1335 |
||
1336 |
TInt driveNumber = DriveNumber(); |
|
1337 |
if ((driveNumber != KDriveInvalid) && !(FsNotify::IsDiskSpaceQueEmpty(driveNumber))) |
|
1338 |
FsNotify::HandleDiskSpace(this, driveNumber); |
|
1339 |
} |
|
0 | 1340 |
|
1341 |
void CFsMessageRequest::Free() |
|
1342 |
// |
|
1343 |
// |
|
1344 |
// |
|
1345 |
{ |
|
1346 |
__THRD_PRINT1(_L("CFsMessageRequest::Free() isAllocated=%d"), IsAllocated()); |
|
1347 |
||
1348 |
SetScratchValue(0); // this should close the CFsObject |
|
1349 |
||
1350 |
if(!IsAllocated()) |
|
1351 |
delete(this); |
|
1352 |
else iOperation = NULL; |
|
1353 |
||
1354 |
} |
|
1355 |
||
1356 |
TInt CFsMessageRequest::DoInitialise() |
|
1357 |
// |
|
1358 |
// returns KErrNone if Initialise succeeded normally |
|
1359 |
// or EReqActionComplete if request completed already |
|
1360 |
// or EReqActionBusy if request needs dispatching & initialising again |
|
1361 |
// |
|
1362 |
{ |
|
1363 |
TInt r = KErrNone; |
|
1364 |
||
1365 |
SetState(iOperation->iPostInitialise ? EReqStatePostInitialise : EReqStateDoRequest); |
|
1366 |
r=Initialise(); |
|
1367 |
if(r==KErrBadHandle) |
|
1368 |
{ |
|
1369 |
// bad subsession handle so panic client |
|
1370 |
_LIT(KPanic,"Panic"); |
|
1371 |
Panic(KPanic,r); |
|
1372 |
if(iOperation->IsOpenSubSess()) //this should be close subsession |
|
1373 |
RequestAllocator::OpenSubFailed(Session()); //need a close subsession fail |
|
1374 |
Free(); |
|
1375 |
r = EReqActionComplete; |
|
1376 |
} |
|
1377 |
else if (r == EReqActionComplete) // completed synchronously in Initialise() function ? |
|
1378 |
{ |
|
1379 |
Complete(KErrNone); |
|
1380 |
} |
|
1381 |
else if (r == EReqActionBusy || r == EReqActionPending) // request postponed or owned by file share ? |
|
1382 |
{ |
|
1383 |
} |
|
1384 |
else if (r != KErrNone) // error |
|
1385 |
{ |
|
1386 |
Complete(r); |
|
1387 |
r = EReqActionComplete; |
|
1388 |
} |
|
1389 |
||
1390 |
return r; |
|
1391 |
} |
|
1392 |
||
1393 |
TInt CFsMessageRequest::PostInitialise() |
|
1394 |
// |
|
1395 |
// returns KErrNone if PostInitialise() succeeded normally |
|
1396 |
// or EReqActionComplete if request completed already |
|
1397 |
// or EReqActionBusy if request needs dispatching & initialising again |
|
1398 |
// |
|
1399 |
{ |
|
1400 |
TInt r = KErrNone; |
|
1401 |
||
1402 |
SetState(EReqStateDoRequest); |
|
1403 |
if (iOperation->iPostInitialise) |
|
1404 |
r = iOperation->iPostInitialise(this); |
|
1405 |
if (r == EReqActionComplete) // completed early ? |
|
1406 |
{ |
|
1407 |
||
1408 |
// Start issuing the post-operation requests starting from the bottom of the chain |
|
1409 |
iCurrentPlugin = NULL; |
|
1410 |
if (PostInterceptEnabled()) |
|
1411 |
{ |
|
1412 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this,(TBool)ETrue); |
|
1413 |
if(iCurrentPlugin && !iCurrentPlugin->IsPluginThread(*this)) |
|
1414 |
{ |
|
1415 |
SetPostOperation(ETrue); |
|
1416 |
Dispatch(); |
|
1417 |
return r; // EReqActionComplete |
|
1418 |
} |
|
1419 |
} |
|
1420 |
||
1421 |
Complete(KErrNone); |
|
1422 |
} |
|
1423 |
else if (r == EReqActionBusy) // request postponed ? |
|
1424 |
{ |
|
1425 |
} |
|
1426 |
else if (r != KErrNone) // error |
|
1427 |
{ |
|
1428 |
Complete(r); |
|
1429 |
r = EReqActionComplete; |
|
1430 |
} |
|
1431 |
||
1432 |
return r; |
|
1433 |
} |
|
1434 |
||
1435 |
||
1436 |
// CFsMessageRequest::Dispatch() |
|
1437 |
// |
|
1438 |
// If aInitialise is EFalse, just disptach request to appropriate thread - |
|
1439 |
// don't call DoInitialise() or PostInitialise() |
|
1440 |
// |
|
1441 |
void CFsMessageRequest::Dispatch(TBool aInitialise, TBool aLowPriority, TBool aDispatchToFront) |
|
1442 |
{ |
|
1443 |
__THRD_PRINT1(_L("CFsMessageRequest::Dispatch() req %08x"), this); |
|
1444 |
||
1445 |
TInt r = KErrNone; |
|
1446 |
||
1447 |
if (iReqState == EReqStateInitialise && aInitialise) |
|
1448 |
{ |
|
1449 |
r = DoInitialise(); |
|
1450 |
if (r == EReqActionComplete) |
|
1451 |
{ |
|
1452 |
return; |
|
1453 |
} |
|
1454 |
else if (r == EReqActionBusy) // request postponed ? |
|
1455 |
{ |
|
1456 |
SetState(EReqStateInitialise); // reinitialize when request is next processed |
|
1457 |
} |
|
1458 |
else if (r == EReqActionPending) // owned by file share ? |
|
1459 |
{ |
|
1460 |
SetState(EReqStateInitialise); // reinitialize when request is next processed |
|
1461 |
return; |
|
1462 |
} |
|
1463 |
if(!IsPluginSpecific() && (iOwnerPlugin == NULL)) |
|
1464 |
{ |
|
1465 |
iCurrentPlugin = NULL; |
|
1466 |
iClientThreadId = 0; |
|
1467 |
FsPluginManager::NextPlugin(iCurrentPlugin, this, (TBool)ETrue); |
|
1468 |
||
1469 |
// find out whether there is a plugin registered to post intercept this message |
|
1470 |
CFsPlugin* postInterceptPlugin = NULL; |
|
1471 |
if (iCurrentPlugin == NULL) |
|
1472 |
FsPluginManager::PrevPlugin(postInterceptPlugin, this, (TBool)ETrue); |
|
1473 |
||
1474 |
// Save the client's thread Id for subsequent testing by CFsPlugin::IsPluginThread() - doing so on the fly |
|
1475 |
// is risky because some messages are completed early in which case Message().Client() will result in a panic |
|
1476 |
if ((iCurrentPlugin || postInterceptPlugin) && Message().Handle() != NULL && Message().Handle() != KLocalMessageHandle) |
|
1477 |
{ |
|
1478 |
RThread thread; |
|
1479 |
Message().Client(thread, EOwnerThread); |
|
1480 |
iClientThreadId = thread.Id(); |
|
1481 |
thread.Close(); |
|
1482 |
} |
|
1483 |
} |
|
1484 |
} // initialise |
|
1485 |
||
1486 |
||
1487 |
// dispatch to plugin thread if initialised (otherwise dispatch to drive thread) |
|
1488 |
if (iReqState > EReqStateInitialise && DispatchToPlugin()) |
|
1489 |
{ |
|
1490 |
__PLUGIN_PRINT1(_L("PLUGIN: CFsMessageRequest %x dispatched to plugin (async)"), this); |
|
1491 |
// The request has been delivered to the plugin thread |
|
1492 |
// - leave the main thread now and await asynchronous completion |
|
1493 |
return; |
|
1494 |
} |
|
1495 |
||
1496 |
||
1497 |
// Is there a PostInitialise function ? |
|
1498 |
if (iReqState == EReqStatePostInitialise && aInitialise && r == KErrNone) |
|
1499 |
{ |
|
1500 |
TInt r = PostInitialise(); |
|
1501 |
if (r == EReqActionComplete) |
|
1502 |
return; |
|
1503 |
else if (r == EReqActionBusy) // request postponed ? |
|
1504 |
SetState(EReqStatePostInitialise); // reinitialize when request is next processed |
|
1505 |
} |
|
1506 |
||
1507 |
||
1508 |
if(!IsSeparateThread() || FsThreadManager::IsDriveSync(DriveNumber(),EFalse)) |
|
1509 |
{ |
|
1510 |
__PLUGIN_PRINT1(_L("PLUGIN: CFsMessageRequest %x dispatched to plugin (sync)"), this); |
|
1511 |
FsPluginManager::DispatchSync(this); |
|
1512 |
return; |
|
1513 |
} |
|
1514 |
||
1515 |
r = DispatchToDrive(aLowPriority, aDispatchToFront); |
|
1516 |
if (r != KErrNone) |
|
1517 |
Complete(r); |
|
1518 |
} |
|
1519 |
||
1520 |
inline TInt CFsMessageRequest::DispatchToDrive(TBool aLowPriority, TBool aDispatchToFront) |
|
1521 |
{ |
|
1522 |
TInt drivenumber = DriveNumber(); |
|
1523 |
||
1524 |
if (drivenumber < EDriveA || drivenumber > EDriveZ) |
|
1525 |
return KErrNotSupported; |
|
1526 |
||
1527 |
FsThreadManager::LockDrive(drivenumber); |
|
1528 |
||
1529 |
CDriveThread* dT=NULL; |
|
1530 |
TInt r = FsThreadManager::GetDriveThread(drivenumber,&dT); |
|
1531 |
||
1532 |
if(r == KErrNone) |
|
1533 |
{ |
|
1534 |
CRequestThread* pT = (CRequestThread*)dT; |
|
1535 |
||
1536 |
if (FsThreadManager::IsDriveHung(drivenumber)) |
|
1537 |
r = KErrNotReady; |
|
1538 |
else if (aDispatchToFront) |
|
1539 |
pT->DeliverFront(this); |
|
1540 |
else |
|
1541 |
pT->DeliverBack(this, aLowPriority); |
|
1542 |
} |
|
1543 |
else if (r == KErrAccessDenied) |
|
1544 |
{ |
|
1545 |
Process(); |
|
1546 |
} |
|
1547 |
||
1548 |
FsThreadManager::UnlockDrive(drivenumber); |
|
1549 |
||
1550 |
return r; |
|
1551 |
} |
|
1552 |
||
1553 |
void CFsMessageRequest::Dispatch() |
|
1554 |
{ |
|
1555 |
Dispatch(ETrue); |
|
1556 |
} |
|
1557 |
||
1558 |
TBool CFsMessageRequest::DispatchToPlugin() |
|
1559 |
// |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1560 |
// Common route: Receive -> Process -> Dispatch -> DispatchToPlugin |
0 | 1561 |
// |
1562 |
{ |
|
1563 |
TInt drivenumber = DriveNumber(); |
|
1564 |
if(iCurrentPlugin) |
|
1565 |
{ |
|
1566 |
FOREVER |
|
1567 |
{ |
|
1568 |
// if we've reached a plugin which is waiting for Complete(), stop going up the plugin chain |
|
1569 |
if(drivenumber >= 0 && IsPostOperation() && CurrentPluginWaiting()) |
|
1570 |
{ |
|
1571 |
// No more plug-ins need to process this request |
|
1572 |
iCurrentPlugin = NULL; |
|
1573 |
} |
|
1574 |
||
1575 |
while(iCurrentPlugin && iCurrentPlugin->IsPluginThread(*this)) |
|
1576 |
{ |
|
1577 |
// Skip the current plugin if the request originated from the plugin |
|
1578 |
if(IsPostOperation()) |
|
1579 |
{ |
|
1580 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this,(TBool)ETrue); |
|
1581 |
} |
|
1582 |
else |
|
1583 |
{ |
|
1584 |
FsPluginManager::NextPlugin(iCurrentPlugin, this,(TBool)ETrue); |
|
1585 |
} |
|
1586 |
} |
|
1587 |
||
1588 |
if(iCurrentPlugin) |
|
1589 |
{ |
|
1590 |
TFsPluginRequest request(this); |
|
1591 |
__THRD_PRINT1(_L("CFsMessageRequest::DispatchToPlugin() req %08x"), this); |
|
1592 |
||
1593 |
TInt err = iCurrentPlugin->Deliver(request); |
|
1594 |
if(err == KErrNone) |
|
1595 |
{ |
|
1596 |
||
1597 |
// The request has been delivered to the plugin thread |
|
1598 |
// - leave the main thread now |
|
1599 |
return(ETrue); |
|
1600 |
} |
|
1601 |
else if(err < KErrNone) |
|
1602 |
{ |
|
1603 |
// An error has occurred |
|
1604 |
// - complete the message |
|
1605 |
Complete(err); |
|
1606 |
return(ETrue); |
|
1607 |
} |
|
1608 |
else if(err == KPluginMessageForward) |
|
1609 |
{ |
|
1610 |
// The plugin has processed synchronously (case 1) |
|
1611 |
// - Pass the message on to the next plugin |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1612 |
if(FsFunction() != EFsPluginOpen) |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1613 |
{ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1614 |
FsPluginManager::NextPlugin(iCurrentPlugin, this,(TBool)ETrue); |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1615 |
continue; |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1616 |
} |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1617 |
else // FsFunction == EFsPluginOpen |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1618 |
{ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1619 |
/* |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1620 |
* PluginOpen requests should not be passed down the plugin stack. |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1621 |
* |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1622 |
|
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1623 |
*/ |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1624 |
iCurrentPlugin = NULL; |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1625 |
continue; |
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
1626 |
} |
0 | 1627 |
} |
1628 |
else if(err == KPluginMessageComplete) |
|
1629 |
{ |
|
1630 |
// The plugin has processed synchronously (case 2) |
|
1631 |
// - Pass the message back up the stack |
|
1632 |
SetPostOperation(ETrue); |
|
1633 |
FsPluginManager::PrevPlugin(iCurrentPlugin, this,(TBool)ETrue); |
|
1634 |
continue; |
|
1635 |
} |
|
1636 |
_LIT(KPanic,"Panic: F32-BAD-PLUGIN-ERROR"); |
|
1637 |
Panic(KPanic, err); |
|
1638 |
} |
|
1639 |
else if (IsPostOperation()) |
|
1640 |
{ |
|
1641 |
// No more plugins are interested in this request |
|
1642 |
// - If in post operation, complete the request |
|
1643 |
Complete(GetError()); |
|
1644 |
return(ETrue); |
|
1645 |
} |
|
1646 |
else |
|
1647 |
{ |
|
1648 |
// No plugin is registered for pre-operation interception this message |
|
1649 |
// - pass the request onto the drive thread. |
|
1650 |
return EFalse; |
|
1651 |
} |
|
1652 |
} |
|
1653 |
} |
|
1654 |
||
1655 |
if(iOperation->Function() == EFsDismountPlugin) |
|
1656 |
{ |
|
1657 |
// Don't pass plugin dismounts to the drive thread |
|
1658 |
Process(); |
|
1659 |
return(ETrue); |
|
1660 |
} |
|
1661 |
||
1662 |
return EFalse; |
|
1663 |
} |
|
1664 |
||
1665 |
TDrive* CFsMessageRequest::Drive() |
|
1666 |
// |
|
1667 |
// |
|
1668 |
// |
|
1669 |
{ |
|
1670 |
return(iDrive); |
|
1671 |
} |
|
1672 |
||
1673 |
TDrive* CFsMessageRequest::SubstedDrive() |
|
1674 |
// |
|
1675 |
// |
|
1676 |
// |
|
1677 |
{ |
|
1678 |
return(iSubstedDrive); |
|
1679 |
} |
|
1680 |
||
1681 |
void CFsMessageRequest::SetDrive(TDrive* aDrive) |
|
1682 |
// |
|
1683 |
// |
|
1684 |
// |
|
1685 |
{ |
|
1686 |
iDrive=aDrive; |
|
1687 |
if(aDrive) |
|
1688 |
{ |
|
1689 |
iDriveNumber=aDrive->DriveNumber(); |
|
1690 |
} |
|
1691 |
} |
|
1692 |
||
1693 |
void CFsMessageRequest::SetSubstedDrive(TDrive* aDrive) |
|
1694 |
// |
|
1695 |
// |
|
1696 |
// |
|
1697 |
{ |
|
1698 |
iSubstedDrive=aDrive; |
|
1699 |
} |
|
1700 |
||
1701 |
const RMessage2& CFsMessageRequest::Message() |
|
1702 |
// |
|
1703 |
// |
|
1704 |
// |
|
1705 |
{ |
|
1706 |
return(iMessage); |
|
1707 |
} |
|
1708 |
||
1709 |
||
1710 |
||
1711 |
void CFsMessageRequest::ReStart() |
|
1712 |
{ |
|
1713 |
__ASSERT_ALWAYS(CurrentOperationPtr() != NULL, Fault(EBadOperationIndex)); |
|
1714 |
||
1715 |
// restore original settings : |
|
1716 |
TMsgOperation& currentOperation = CurrentOperation(); |
|
1717 |
TInt offset = currentOperation.iReadWriteArgs.iOffset; |
|
1718 |
currentOperation.iReadWriteArgs.iPos-= offset; |
|
1719 |
currentOperation.iReadWriteArgs.iTotalLength+= offset; |
|
1720 |
currentOperation.iReadWriteArgs.iLength = currentOperation.iReadWriteArgs.iTotalLength; |
|
1721 |
currentOperation.iReadWriteArgs.iOffset = 0; |
|
1722 |
currentOperation.iState = 0; |
|
1723 |
TInt function = iOperation->Function(); |
|
1724 |
__ASSERT_ALWAYS(function == EFsFileRead || function == EFsFileWrite, Fault(EMsgRestartBadFunction)); |
|
1725 |
} |
|
1726 |
||
1727 |
||
1728 |
void CFsMessageRequest::SetOperationFunc(TInt aFunction) |
|
1729 |
{ |
|
1730 |
const TOperation& oP = OperationArray[aFunction]; |
|
1731 |
Set(oP); |
|
1732 |
// modified because some requests were set to PostInitialise. They are set to DoRequest in Dispatch anyway, so this is possibly ok? |
|
1733 |
//__ASSERT_ALWAYS(iReqState == EReqStateDoRequest, Fault(EInvalidMsgState)); |
|
1734 |
} |
|
1735 |
||
1736 |
TInt CFsMessageRequest::PushOperation(TFsRequestFunc aCallback, TInt aNextState, TInt aFunction) |
|
1737 |
{ |
|
1738 |
TMsgOperation* nextOperation; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
1739 |
TInt r = OperationAllocator::GetOperation(nextOperation); |
0 | 1740 |
if (r != KErrNone) |
1741 |
return r; |
|
1742 |
||
1743 |
||
1744 |
// Store the caller's state etc in the CURRENT TMsgOperation (if there is one) |
|
1745 |
if (iCurrentOperation != NULL) |
|
1746 |
{ |
|
1747 |
__ASSERT_ALWAYS(aCallback, Fault(EPushOpNoCallback)); |
|
1748 |
iCurrentOperation->iState = aNextState; |
|
1749 |
iCurrentOperation->iCurrentPlugin = iCurrentPlugin; |
|
1750 |
iCurrentOperation->iFunction = iOperation->Function(); |
|
1751 |
iCurrentOperation->iNext = nextOperation; |
|
1752 |
nextOperation->iPrev = iCurrentOperation; |
|
1753 |
} |
|
1754 |
||
1755 |
// store the call-back routine in the NEW TMsgOperation |
|
1756 |
nextOperation->iComplete = aCallback; |
|
1757 |
nextOperation->iState = 0; |
|
1758 |
if (aFunction != KOperationFunctionUnaltered && aFunction != iOperation->Function()) |
|
1759 |
SetOperationFunc(aFunction); |
|
1760 |
||
1761 |
||
1762 |
iCurrentOperation = nextOperation; |
|
1763 |
||
1764 |
// reset post operation state: as a plugin may push more than one TMsgOperation |
|
1765 |
SetPostOperation(EFalse); |
|
1766 |
||
1767 |
return KErrNone; |
|
1768 |
} |
|
1769 |
||
1770 |
/** |
|
1771 |
PushOperation() |
|
1772 |
||
1773 |
Pushes a new TMsgOperation onto this request's "stack". After this function completes the new |
|
1774 |
TMsgOperation object becomes the "current" one (pointed at by CFsMessageRequest::iCurrentOperation). |
|
1775 |
||
1776 |
After the request has been dispatched to the drive thread, TOperation::DoRequestL() will be called. |
|
1777 |
When this has completed, CFsMessage::Complete() is called which then pops the new TMsgOperation |
|
1778 |
off the stack; and calls the callback routine (aCallback). |
|
1779 |
||
1780 |
@param aPos The position to read / write. Stored in the NEW TMsgOperation. |
|
1781 |
||
1782 |
@param aLength The length to read / write. Stored in the NEW TMsgOperation. |
|
1783 |
||
1784 |
@param aData A buffer to read the data from / write the data to. Stored in the NEW TMsgOperation. |
|
1785 |
The buffer must belong to the file server or to a plugin |
|
1786 |
||
1787 |
@param aOffset The offset onto the buffer to read from / write to. Stored in the NEW TMsgOperation. |
|
1788 |
||
1789 |
@param aCallback An optional callback routine. Stored in the OLD TMsgOperation. |
|
1790 |
MUST be supplied if there are one or more TMsgOperation's already on the stack |
|
1791 |
||
1792 |
@param aNextState State information private to the caller. Defaults to zero. Stored in the OLD TMsgOperation. |
|
1793 |
||
1794 |
@param aFunction An optional TFsMessage. Supplied if the caller wishes to change the TOperation |
|
1795 |
associated with this request. When the new TMsgOperation is popped off the stack, the |
|
1796 |
previous TOperation is restored. Used primarally for read-modify-write. |
|
1797 |
||
1798 |
*/ |
|
1799 |
TInt CFsMessageRequest::PushOperation(TInt64 aPos, TInt aLength, TUint8* aData, TInt aOffset, TFsRequestFunc aCallback, TInt aNextState, TInt aFunction) |
|
1800 |
{ |
|
1801 |
TInt r = PushOperation(aCallback, aNextState, aFunction); |
|
1802 |
if (r == KErrNone) |
|
1803 |
CurrentOperation().Set(aPos, aLength, aData, aOffset, 0); |
|
1804 |
return r; |
|
1805 |
} |
|
1806 |
||
1807 |
||
1808 |
/** |
|
1809 |
PushOperation() |
|
1810 |
||
1811 |
Pushes a new TMsgOperation onto this request's "stack". After this function completes the new |
|
1812 |
TMsgOperation object becomes the "current" one (pointed at by CFsMessageRequest::iCurrentOperation). |
|
1813 |
||
1814 |
After the request has been dispatched to the drive thread, TOperation::DoRequestL() will be called. |
|
1815 |
When this has completed, CFsMessage::Complete() is called which then pops the new TMsgOperation |
|
1816 |
off the stack; and calls the callback routine (aCallback). |
|
1817 |
||
1818 |
@param aPos The position to read / write. Stored in the NEW TMsgOperation. |
|
1819 |
||
1820 |
@param aLength The length to read / write. Stored in the NEW TMsgOperation. |
|
1821 |
||
1822 |
@param aData A buffer to read the data from / write the data to. Stored in the NEW TMsgOperation. |
|
1823 |
The buffer belongs to a client of the file server on the other side of an IPC boundary. |
|
1824 |
||
1825 |
@param aOffset The offset onto the buffer to read from / write to. Stored in the NEW TMsgOperation. |
|
1826 |
||
1827 |
@param aCallback An optional callback routine. Stored in the OLD TMsgOperation. |
|
1828 |
MUST be supplied if there are one or more TMsgOperation's already on the stack |
|
1829 |
||
1830 |
@param aNextState State information private to the caller. Defaults to zero. Stored in the OLD TMsgOperation. |
|
1831 |
||
1832 |
@param aFunction An optional TFsMessage. Supplied if the caller wishes to change the TOperation |
|
1833 |
associated with this request. When the new TMsgOperation is popped off the stack, the |
|
1834 |
previous TOperation is restored. Used primarally for read-modify-write. |
|
1835 |
||
1836 |
*/ |
|
1837 |
TInt CFsMessageRequest::PushOperation(TInt64 aPos, TInt aLength, TDesC8* aData, TInt aOffset, TFsRequestFunc aCallback, TInt aNextState, TInt aFunction) |
|
1838 |
{ |
|
1839 |
TInt r = PushOperation(aCallback, aNextState, aFunction); |
|
1840 |
if (r == KErrNone) |
|
1841 |
CurrentOperation().Set(aPos, aLength, aData, aOffset, 0); |
|
1842 |
return r; |
|
1843 |
} |
|
1844 |
||
1845 |
void CFsMessageRequest::PopOperation() |
|
1846 |
{ |
|
1847 |
__ASSERT_ALWAYS(iCurrentOperation != NULL, Fault(EInvalidOperationIndex)); |
|
1848 |
||
1849 |
TMsgOperation* currentOperation = iCurrentOperation; |
|
1850 |
||
1851 |
if (iCurrentOperation->iPrev == NULL) |
|
1852 |
{ |
|
1853 |
iCurrentOperation = NULL; |
|
1854 |
} |
|
1855 |
else |
|
1856 |
{ |
|
1857 |
TMsgOperation* prevOperation = iCurrentOperation->iPrev; |
|
1858 |
prevOperation->iNext = NULL; |
|
1859 |
iCurrentOperation = prevOperation; |
|
1860 |
||
1861 |
iCurrentPlugin = iCurrentOperation->iCurrentPlugin; |
|
1862 |
||
1863 |
if (iCurrentOperation->iFunction != iOperation->Function()) |
|
1864 |
SetOperationFunc(iCurrentOperation->iFunction); |
|
1865 |
} |
|
1866 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
15
diff
changeset
|
1867 |
OperationAllocator::FreeOperation(currentOperation); |
0 | 1868 |
} |
1869 |
||
1870 |
TMsgOperation& CFsMessageRequest::CurrentOperation() |
|
1871 |
{ |
|
1872 |
__ASSERT_ALWAYS(iCurrentOperation != NULL, Fault(EInvalidOperationIndex)); |
|
1873 |
return *iCurrentOperation; |
|
1874 |
} |
|
1875 |
||
1876 |
||
1877 |
CFsClientMessageRequest::CFsClientMessageRequest() |
|
1878 |
: iPoolSrc (0), |
|
1879 |
iPoolDest(0) |
|
1880 |
{ |
|
1881 |
} |
|
1882 |
||
1883 |
// Return ETrue if there are ANY TMsgOperation's in the stack which were pushed by iCurrentPlugin |
|
1884 |
// If there are any, then it's NOT OK to dispatch this message to the plugin thread as it will be |
|
1885 |
// waiting on a semaphore which is only cleared by Complete() |
|
1886 |
TBool CFsMessageRequest::CurrentPluginWaiting() |
|
1887 |
{ |
|
1888 |
if (iOwnerPlugin == iCurrentPlugin) |
|
1889 |
return ETrue; |
|
1890 |
||
1891 |
// find out which plugin (if any) was the last to push a TMsgOperation |
|
1892 |
TMsgOperation* currentOperation; |
|
1893 |
||
1894 |
for (currentOperation = iCurrentOperation ? iCurrentOperation->iPrev : NULL; |
|
1895 |
currentOperation != NULL; |
|
1896 |
currentOperation = currentOperation->iPrev) |
|
1897 |
{ |
|
1898 |
if (currentOperation->iCurrentPlugin == iCurrentPlugin) |
|
1899 |
return ETrue; |
|
1900 |
} |
|
1901 |
||
1902 |
return EFalse; |
|
1903 |
} |
|
1904 |
||
1905 |
||
1906 |
TBool CFsMessageRequest::IsPluginRequest() |
|
1907 |
{ |
|
1908 |
if(iOwnerPlugin) // Check the previous operation had a plugin) |
|
1909 |
{ |
|
1910 |
return ETrue; |
|
1911 |
} |
|
1912 |
return EFalse; |
|
1913 |
} |
|
1914 |
||
1915 |
||
1916 |
void CFsClientMessageRequest::Free() |
|
1917 |
// |
|
1918 |
// |
|
1919 |
// |
|
1920 |
{ |
|
1921 |
__THRD_PRINT(_L("CFsClientMessageRequest::Free()")); |
|
1922 |
__ASSERT_ALWAYS(CurrentOperationPtr() == NULL, Fault(EFreeingMsgWithMsgOp)); |
|
1923 |
if (iPoolSrc) |
|
1924 |
{ |
|
1925 |
TParsePool::Release(iPoolSrc); |
|
1926 |
iPoolSrc = 0; |
|
1927 |
} |
|
1928 |
||
1929 |
if (iPoolDest) |
|
1930 |
{ |
|
1931 |
TParsePool::Release(iPoolDest); |
|
1932 |
iPoolDest = 0; |
|
1933 |
} |
|
1934 |
||
1935 |
SetScratchValue(0); // this should close the CFsObject |
|
1936 |
iOperation = NULL; |
|
1937 |
RequestAllocator::FreeRequest(this); |
|
1938 |
} |
|
1939 |
||
1940 |
||
1941 |
TInt CFsClientMessageRequest::AllocParseObjects(const TOperation& aOperation) |
|
1942 |
{ |
|
1943 |
__ASSERT_ALWAYS(iPoolSrc == NULL && iPoolDest == NULL, Fault(ETParsePoolGet)); |
|
1944 |
||
1945 |
if (aOperation.iFlags & EParseSrc) |
|
1946 |
{ |
|
1947 |
iPoolSrc = TParsePool::Get(); |
|
1948 |
if (iPoolSrc == NULL) |
|
1949 |
return KErrNoMemory; |
|
1950 |
} |
|
1951 |
if (aOperation.iFlags & EParseDst) |
|
1952 |
{ |
|
1953 |
iPoolDest = TParsePool::Get(); |
|
1954 |
if (iPoolDest == NULL) |
|
1955 |
return KErrNoMemory; |
|
1956 |
} |
|
1957 |
return KErrNone; |
|
1958 |
} |
|
1959 |
||
1960 |
TParse& CFsClientMessageRequest::Src() |
|
1961 |
// |
|
1962 |
// |
|
1963 |
{ |
|
1964 |
__ASSERT_ALWAYS(iPoolSrc, Fault(ETParsePoolGet)); |
|
1965 |
return (iPoolSrc->GetObject()); |
|
1966 |
} |
|
1967 |
||
1968 |
TParse& CFsClientMessageRequest::Dest() |
|
1969 |
// |
|
1970 |
// |
|
1971 |
// |
|
1972 |
{ |
|
1973 |
__ASSERT_ALWAYS(iPoolDest, Fault(ETParsePoolGet)); |
|
1974 |
return (iPoolDest->GetObject()); |
|
1975 |
} |
|
1976 |
||
1977 |
||
1978 |
||
1979 |
TParsePool* TParsePool::iFreeHead = 0; |
|
1980 |
TParsePool* TParsePool::iClosedHead = 0; |
|
1981 |
TInt TParsePool::iCountFree = 0; |
|
1982 |
RFastLock TParsePool::iLock; |
|
1983 |
||
1984 |
||
1985 |
TParsePool::TParsePool() |
|
1986 |
: iNext (iFreeHead), |
|
1987 |
iPrev (0), |
|
1988 |
iFree (ETrue) |
|
1989 |
{ |
|
1990 |
} |
|
1991 |
||
1992 |
TInt TParsePool::Init() |
|
1993 |
{ |
|
1994 |
return iLock.CreateLocal(); |
|
1995 |
} |
|
1996 |
||
1997 |
TParsePool* TParsePool::Get() |
|
1998 |
// Gets a TParsePool object from the free list. If the free list does |
|
1999 |
// not contain any TParsePool objects, additional objects are manufactured. |
|
2000 |
// Returns NULL if unable to allocate a new object |
|
2001 |
{ |
|
2002 |
iLock.Wait(); |
|
2003 |
||
2004 |
TParsePool* pObject = 0; |
|
2005 |
||
2006 |
// If we don't have anything in the free list, allocate some more... |
|
2007 |
if (iCountFree < 1) |
|
2008 |
{ |
|
2009 |
__ASSERT_DEBUG(iFreeHead == NULL, Fault(ETParsePoolGet)); |
|
2010 |
for (TInt i = 0; i < KEBlockSize; i++) |
|
2011 |
{ |
|
2012 |
// if allocation fails break out of the loop. |
|
2013 |
pObject = new TParsePool; |
|
2014 |
if (pObject == NULL) |
|
2015 |
break; |
|
2016 |
||
2017 |
iCountFree++; |
|
2018 |
||
2019 |
if (iFreeHead) |
|
2020 |
iFreeHead->iPrev = pObject; |
|
2021 |
||
2022 |
iFreeHead = pObject; |
|
2023 |
} |
|
2024 |
} |
|
2025 |
||
2026 |
// if we failed to allocate even a single object, return NULL |
|
2027 |
if (iCountFree < 1) |
|
2028 |
{ |
|
2029 |
iLock.Signal(); |
|
2030 |
return NULL; |
|
2031 |
} |
|
2032 |
||
2033 |
||
2034 |
__ASSERT_ALWAYS(iFreeHead != NULL, Fault(ETParsePoolGet)); |
|
2035 |
||
2036 |
pObject = iFreeHead; |
|
2037 |
pObject->iFree = EFalse; |
|
2038 |
||
2039 |
||
2040 |
// Remove the head of the free list... |
|
2041 |
iFreeHead = pObject->iNext; |
|
2042 |
if (iFreeHead) |
|
2043 |
iFreeHead->iPrev = 0; |
|
2044 |
iCountFree--; |
|
2045 |
||
2046 |
// ... and add it to the closed list |
|
2047 |
pObject->iNext = iClosedHead; |
|
2048 |
pObject->iPrev = 0; |
|
2049 |
if (iClosedHead) |
|
2050 |
iClosedHead->iPrev = pObject; |
|
2051 |
iClosedHead = pObject; |
|
2052 |
||
2053 |
iLock.Signal(); |
|
2054 |
||
2055 |
return pObject; |
|
2056 |
} |
|
2057 |
||
2058 |
||
2059 |
void TParsePool::Release(TParsePool* aObject) |
|
2060 |
// |
|
2061 |
// Release a sub-sequence of TParsePool objects back to the free list. |
|
2062 |
// |
|
2063 |
{ |
|
2064 |
__ASSERT_ALWAYS(aObject != NULL && !aObject->iFree, Fault(ETParsePoolGet)); |
|
2065 |
||
2066 |
iLock.Wait(); |
|
2067 |
||
2068 |
aObject->iFree = ETrue; |
|
2069 |
||
2070 |
// Get the objects either side of the one we're interested in |
|
2071 |
TParsePool* pPrevious = aObject->iPrev; |
|
2072 |
TParsePool* pNext = aObject->iNext; |
|
2073 |
||
2074 |
// Remove it from the closed list |
|
2075 |
if (pPrevious) |
|
2076 |
pPrevious->iNext = pNext; |
|
2077 |
else |
|
2078 |
iClosedHead = pNext; |
|
2079 |
||
2080 |
if (pNext) |
|
2081 |
pNext->iPrev = pPrevious; |
|
2082 |
||
2083 |
||
2084 |
// Now add it to the free list |
|
2085 |
aObject->iNext = iFreeHead; |
|
2086 |
aObject->iPrev = 0; |
|
2087 |
if (iFreeHead) |
|
2088 |
iFreeHead->iPrev = aObject; |
|
2089 |
||
2090 |
iFreeHead = aObject; |
|
2091 |
iCountFree++; |
|
2092 |
||
2093 |
iLock.Signal(); |
|
2094 |
} |
|
2095 |
||
2096 |
||
2097 |
CFsInternalRequest::CFsInternalRequest() |
|
2098 |
// |
|
2099 |
// |
|
2100 |
// |
|
2101 |
{ |
|
2102 |
// iStatus=NULL; |
|
2103 |
// iIsAllocated=EFalse; |
|
2104 |
} |
|
2105 |
||
2106 |
void CFsInternalRequest::Set(const TOperation& aOperation,CSessionFs* aSession) |
|
2107 |
// |
|
2108 |
// |
|
2109 |
// |
|
2110 |
{ |
|
2111 |
CFsRequest::Set(aOperation,aSession); |
|
2112 |
} |
|
2113 |
||
2114 |
void CFsInternalRequest::Process() |
|
2115 |
// |
|
2116 |
// |
|
2117 |
// |
|
2118 |
{ |
|
2119 |
__THRD_PRINT(_L("CFsInternalRequest::Process()")); |
|
2120 |
TInt r=KErrNone; |
|
2121 |
TRAPD(leaveValue,r=iOperation->DoRequestL(this)); |
|
2122 |
// internal requests should never fail |
|
2123 |
__ASSERT_ALWAYS(leaveValue==KErrNone && (r==KErrNone||r==EReqActionBusy),Fault(EInternalRequestProcess)); |
|
2124 |
||
2125 |
// request postponed ? (e.g. if a page used by file cache is busy). |
|
2126 |
if (r == EReqActionBusy) |
|
2127 |
{ |
|
2128 |
Dispatch(); |
|
2129 |
return; |
|
2130 |
} |
|
2131 |
||
2132 |
Complete(r); |
|
2133 |
} |
|
2134 |
||
2135 |
||
2136 |
void CFsInternalRequest::Complete(TInt aError) |
|
2137 |
// |
|
2138 |
// |
|
2139 |
// |
|
2140 |
{ |
|
2141 |
__PRINT1(_L("CFsInternalRequest::Complete() with %d"),aError); |
|
2142 |
TInt func = Operation()->Function(); |
|
2143 |
if(func==KCancelSession || func==KCancelPlugin || func==KFlushDirtyData) |
|
2144 |
{ |
|
2145 |
__ASSERT_DEBUG(ThreadHandle()!=0 && !FsThreadManager::IsDisconnectThread(),Fault(EInternalRequestComplete1)); |
|
2146 |
RThread t; |
|
2147 |
t.SetHandle(ThreadHandle()); |
|
2148 |
TRequestStatus* s=&Status(); |
|
2149 |
t.RequestComplete(s,aError); |
|
2150 |
Free(); |
|
2151 |
} |
|
2152 |
else if(func == KDispatchObjectClose) |
|
2153 |
{ |
|
2154 |
TFsCloseObject::Complete(this); |
|
2155 |
Free(); |
|
2156 |
} |
|
2157 |
else if(func==KFileShareClose) |
|
2158 |
{ |
|
2159 |
if (aError == EReqActionBusy) |
|
2160 |
{ |
|
2161 |
Dispatch(); |
|
2162 |
} |
|
2163 |
else |
|
2164 |
{ |
|
2165 |
TFsCloseFileShare::Complete(this); |
|
2166 |
Free(); |
|
2167 |
} |
|
2168 |
} |
|
2169 |
else |
|
2170 |
Fault(EInternalRequestComplete3); |
|
2171 |
} |
|
2172 |
||
2173 |
void CFsInternalRequest::Dispatch() |
|
2174 |
// |
|
2175 |
// |
|
2176 |
// |
|
2177 |
{ |
|
2178 |
__THRD_PRINT(_L("CFsInternalRequest::Dispatch()")); |
|
2179 |
__ASSERT_ALWAYS(Initialise()==KErrNone,Fault(EInternalRequestDispatch1)); |
|
2180 |
||
2181 |
if(iCurrentPlugin && Operation()->Function() == KCancelPlugin) |
|
2182 |
{ |
|
2183 |
TFsPluginRequest request(this); |
|
2184 |
TInt r = iCurrentPlugin->Deliver(request); |
|
2185 |
__ASSERT_ALWAYS(r == KErrNone, Fault(EInternalRequestDispatchCancelPlugin)); |
|
2186 |
} |
|
2187 |
else |
|
2188 |
{ |
|
2189 |
TInt drivenumber = DriveNumber(); |
|
2190 |
FsThreadManager::LockDrive(drivenumber); |
|
2191 |
// shouldn't dispath if no drive available |
|
2192 |
__ASSERT_ALWAYS(FsThreadManager::IsDriveAvailable(drivenumber,EFalse) && !FsThreadManager::IsDriveSync(drivenumber,EFalse),Fault(EInternalRequestDispatch2)); |
|
2193 |
CDriveThread* dT=NULL; |
|
2194 |
TInt r=FsThreadManager::GetDriveThread(drivenumber,&dT); |
|
2195 |
__THRD_PRINT2(_L("deliver to thread 0x%x, drive number %d"),dT,drivenumber); |
|
2196 |
__ASSERT_ALWAYS(r==KErrNone && dT,Fault(EInternalRequestDispatch3)); |
|
2197 |
CRequestThread* pT = (CRequestThread*)dT; |
|
2198 |
TInt func = Operation()->Function(); |
|
2199 |
if(func == KDispatchObjectClose || func == KFileShareClose || func == KFlushDirtyData) |
|
2200 |
pT->DeliverBack(this); |
|
2201 |
else |
|
2202 |
pT->DeliverFront(this); |
|
2203 |
FsThreadManager::UnlockDrive(drivenumber); |
|
2204 |
} |
|
2205 |
} |
|
2206 |
||
2207 |
void CFsInternalRequest::Free() |
|
2208 |
// |
|
2209 |
// |
|
2210 |
// |
|
2211 |
{ |
|
2212 |
__THRD_PRINT1(_L("CFsInternalRequest::Free() isAllocated=%d"),IsAllocated()); |
|
2213 |
||
2214 |
SetScratchValue(0); // this should close the CFsObject |
|
2215 |
||
2216 |
if(!IsAllocated()) |
|
2217 |
delete(this); |
|
2218 |
} |
|
2219 |
||
2220 |
void CFsDisconnectRequest::Dispatch() |
|
2221 |
// |
|
2222 |
// |
|
2223 |
// |
|
2224 |
{ |
|
2225 |
__THRD_PRINT(_L("CFsDisconnectRequest::Dispatch()")); |
|
2226 |
// no need to lock |
|
2227 |
TInt r=Initialise(); |
|
2228 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EDisconnectRequestDispatch1)); |
|
2229 |
CRequestThread* pT=FsThreadManager::GetDisconnectThread(); |
|
2230 |
__ASSERT_ALWAYS(pT,Fault(EDisconnectRequestDispatch2)); |
|
2231 |
pT->DeliverBack(this); |
|
2232 |
} |
|
2233 |
||
2234 |
void CFsDisconnectRequest::Process() |
|
2235 |
// |
|
2236 |
// |
|
2237 |
// |
|
2238 |
{ |
|
2239 |
__THRD_PRINT(_L("CFsDisconnectRequest::Process()")); |
|
2240 |
TInt r=KErrNone; |
|
2241 |
TRAPD(leaveValue,r=iOperation->DoRequestL(this)); |
|
2242 |
leaveValue=leaveValue; // just to make compiler happy |
|
2243 |
__ASSERT_DEBUG(leaveValue==KErrNone && r==KErrNone,Fault(EDisonncectRequestProcess)); |
|
2244 |
Complete(r); |
|
2245 |
} |
|
2246 |
||
2247 |
void CFsDisconnectRequest::Complete(TInt aError) |
|
2248 |
// |
|
2249 |
// |
|
2250 |
// |
|
2251 |
{ |
|
2252 |
__PRINT1(_L("CFsDisconnectRequest::Complete() with %d"),aError); |
|
2253 |
__ASSERT_ALWAYS(aError==KErrNone,Fault(EDisconnectRequestComplete)); |
|
2254 |
// set session disconnect reqeust to NULL |
|
2255 |
// will be freed in CFsMessageRequest::Free() |
|
2256 |
Session()->iDisconnectRequest=NULL; |
|
2257 |
// now delete session |
|
2258 |
TheFileServer->SessionQueueLockWait(); |
|
2259 |
delete(Session()); |
|
2260 |
TheFileServer->SessionQueueLockSignal(); |
|
2261 |
// NB Must complete the message AFTER the session has been deleted... |
|
2262 |
Message().Complete(aError); |
|
2263 |
delete(this); |
|
2264 |
} |
|
2265 |
||
2266 |
||
2267 |
/** |
|
2268 |
Create a new synchronous message scheduler |
|
2269 |
*/ |
|
2270 |
CFsSyncMessageScheduler* CFsSyncMessageScheduler::NewL() |
|
2271 |
{ |
|
2272 |
__PRINT(_L("CFsSyncMessageScheduler::NewL()")); |
|
2273 |
||
2274 |
CFsSyncMessageScheduler* pSelf = new(ELeave)CFsSyncMessageScheduler(); |
|
2275 |
||
2276 |
CleanupStack::PushL(pSelf); |
|
2277 |
pSelf->ConstructL(); |
|
2278 |
CleanupStack::Pop(); |
|
2279 |
||
2280 |
return(pSelf); |
|
2281 |
} |
|
2282 |
||
2283 |
||
2284 |
/** |
|
2285 |
Construct a synchronous message scheduler |
|
2286 |
*/ |
|
2287 |
CFsSyncMessageScheduler::CFsSyncMessageScheduler() |
|
2288 |
: CActive(EPriorityHigh), |
|
2289 |
iList(_FOFF(CFsRequest,iLink)) |
|
2290 |
{ |
|
2291 |
__PRINT(_L("CFsSyncMessageScheduler::CFsSyncMessageScheduler()")); |
|
2292 |
} |
|
2293 |
||
2294 |
||
2295 |
/** |
|
2296 |
Second-phase constructor |
|
2297 |
*/ |
|
2298 |
||
2299 |
void CFsSyncMessageScheduler::ConstructL() |
|
2300 |
{ |
|
2301 |
__PRINT(_L("CFsSyncMessageScheduler::ConstructL()")); |
|
2302 |
||
2303 |
User::LeaveIfError(iLock.CreateLocal()); |
|
2304 |
User::LeaveIfError(iThread.Open(RThread().Id())); |
|
2305 |
||
2306 |
CActiveScheduler::Add(this); |
|
2307 |
} |
|
2308 |
||
2309 |
||
2310 |
/** |
|
2311 |
Synchronous message scheduler |
|
2312 |
- dispatch any synchronous requests that were queued via ::Dispatch |
|
2313 |
*/ |
|
2314 |
void CFsSyncMessageScheduler::RunL() |
|
2315 |
{ |
|
2316 |
__PRINT(_L(">> CFsSyncMessageScheduler::RunL()")); |
|
2317 |
||
2318 |
FOREVER |
|
2319 |
{ |
|
2320 |
iLock.Wait(); |
|
2321 |
if(iList.IsEmpty()) |
|
2322 |
{ |
|
2323 |
break; |
|
2324 |
} |
|
2325 |
else |
|
2326 |
{ |
|
2327 |
CFsRequest* request = iList.First(); |
|
2328 |
request->iLink.Deque(); |
|
2329 |
iLock.Signal(); |
|
2330 |
__PRINT1(_L(" CFsSyncMessageScheduler - Dispatching message %08x"), request); |
|
2331 |
request->Process(); |
|
2332 |
} |
|
2333 |
} |
|
2334 |
||
2335 |
iSignalled = EFalse; |
|
2336 |
iStatus = KRequestPending; |
|
2337 |
SetActive(); |
|
2338 |
iLock.Signal(); |
|
2339 |
||
2340 |
__PRINT(_L("<< CFsSyncMessageScheduler::RunL()")); |
|
2341 |
} |
|
2342 |
||
2343 |
||
2344 |
/** |
|
2345 |
DoCancel - Not Implemented |
|
2346 |
*/ |
|
2347 |
void CFsSyncMessageScheduler::DoCancel() |
|
2348 |
{ |
|
2349 |
__PRINT(_L("CFsSyncMessageScheduler::DoCancel")); |
|
2350 |
} |
|
2351 |
||
2352 |
||
2353 |
/** |
|
2354 |
Queue synchronous requests to be processed in main thread context |
|
2355 |
- called when synchronous messages are passed from plugin threads |
|
2356 |
*/ |
|
2357 |
void CFsSyncMessageScheduler::Dispatch(CFsRequest* aRequest) |
|
2358 |
{ |
|
2359 |
__PRINT1(_L("CFsSyncMessageScheduler::Dispatch(%08x)"), aRequest); |
|
2360 |
||
2361 |
// Accquire lock and add request to queue. |
|
2362 |
iLock.Wait(); |
|
2363 |
iList.AddFirst(*aRequest); |
|
2364 |
||
2365 |
if(!iSignalled) |
|
2366 |
{ |
|
2367 |
// set iSignalled in case another thread (plug-in) is calling dispatch, then release lock. |
|
2368 |
iSignalled = ETrue; |
|
2369 |
iLock.Signal(); |
|
2370 |
||
2371 |
// signal main thread. |
|
2372 |
TRequestStatus* s = &iStatus; |
|
2373 |
iThread.RequestComplete(s, KErrNone); |
|
2374 |
} |
|
2375 |
else |
|
2376 |
{ |
|
2377 |
// main thread already signalled, just release lock. |
|
2378 |
iLock.Signal(); |
|
2379 |
} |
|
2380 |
} |
|
2381 |
||
2382 |
||
2383 |
/** |
|
2384 |
Complete outstanding requests for the specified session |
|
2385 |
*/ |
|
2386 |
void CFsSyncMessageScheduler::CompleteSessionRequests(CSessionFs* aSession, TInt aValue) |
|
2387 |
{ |
|
2388 |
__PRINT2(_L("FsPluginManager::CompleteSessionRequests(%08x, %d)"), aSession, aValue); |
|
2389 |
||
2390 |
iLock.Wait(); |
|
2391 |
TDblQueIter<CFsRequest> q(iList); |
|
2392 |
CFsRequest* pR; |
|
2393 |
while((pR=q++)!=NULL) |
|
2394 |
{ |
|
2395 |
if(pR->Session()==aSession) |
|
2396 |
{ |
|
2397 |
pR->iLink.Deque(); |
|
2398 |
pR->Complete(aValue); |
|
2399 |
} |
|
2400 |
} |
|
2401 |
iLock.Signal(); |
|
2402 |
} |
|
2403 |