author | hgs |
Tue, 02 Nov 2010 15:29:23 +0000 | |
changeset 300 | 1d28c8722707 |
parent 286 | 48e57fb1237e |
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_notif.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include "sf_std.h" |
|
300 | 19 |
#include "sf_notifier.h" |
20 |
#include "sf_pool.h" |
|
0 | 21 |
|
300 | 22 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
23 |
#include <f32notification.h> |
|
24 |
#endif |
|
0 | 25 |
|
26 |
TChangeQue FsNotify::iChangeQues[KMaxNotifyQues]; |
|
27 |
TDiskSpaceQue FsNotify::iDiskSpaceQues[KMaxDiskQues]; |
|
28 |
TDebugQue FsNotify::iDebugQue; |
|
29 |
TDismountNotifyQue FsNotify::iDismountNotifyQue; |
|
30 |
||
300 | 31 |
_LIT(KEmptyString,""); |
32 |
||
33 |
CFsNotificationInfoBody::CFsNotificationInfoBody() |
|
34 |
: iSrc(KEmptyString), |
|
35 |
iSrcBuf(KEmptyString), |
|
36 |
iDest(KEmptyString), |
|
37 |
iDestDriveStored(EFalse), |
|
38 |
iFunction(KErrNotFound), |
|
39 |
iData(KErrNotFound), |
|
40 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
41 |
iNotificationType(TFsNotification::EOverflow), |
|
42 |
#else |
|
43 |
iNotificationType(KErrNotFound), |
|
44 |
#endif |
|
45 |
iUid(TUid::Null()) |
|
46 |
{ |
|
47 |
} |
|
48 |
||
49 |
CFsNotificationInfo::CFsNotificationInfo() |
|
50 |
{ |
|
51 |
} |
|
52 |
||
53 |
/* |
|
54 |
* These do not get deleted, they get Freed via CFsNotificationInfo::Free. |
|
55 |
*/ |
|
56 |
CFsNotificationInfo::~CFsNotificationInfo() |
|
57 |
{ |
|
58 |
Fault(ENotificationInfoDeletion); |
|
59 |
} |
|
60 |
||
61 |
TInt CFsNotificationInfo::Init(TInt aFunction, TInt aDriveNum) |
|
62 |
{ |
|
63 |
//Clean notification before use |
|
64 |
CleanNotification(); |
|
65 |
||
66 |
iBody->iFunction = aFunction; |
|
67 |
TInt err = SetDriveNumber(aDriveNum); |
|
68 |
if(err != KErrNone) |
|
69 |
{ |
|
70 |
return err; |
|
71 |
} |
|
72 |
||
73 |
//Set notification type |
|
74 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
75 |
CFsNotificationInfo::NotificationType(iBody->iFunction, iBody->iNotificationType); |
|
76 |
#else |
|
77 |
iBody->iNotificationType = KErrNotSupported; |
|
78 |
#endif |
|
79 |
return KErrNone; |
|
80 |
} |
|
81 |
||
82 |
void CFsNotificationInfo::CleanNotification() |
|
83 |
{ |
|
84 |
//Clear all variables |
|
85 |
TParsePtrC empty(KEmptyString); |
|
86 |
memcpy(&iBody->iSrc,&empty,sizeof(TParsePtrC)); |
|
87 |
memcpy(&iBody->iDest,&empty,sizeof(TParsePtrC)); |
|
88 |
iBody->iData = KErrNotFound; |
|
89 |
iBody->iRequest = NULL; |
|
90 |
iBody->iDriveNumber = KErrNotFound; |
|
91 |
iBody->iUid = TUid::Null(); |
|
92 |
iBody->iDestDriveStored = EFalse; |
|
93 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
94 |
iBody->iNotificationType=TFsNotification::EOverflow; |
|
95 |
#else |
|
96 |
iBody->iNotificationType=KErrNotFound; |
|
97 |
#endif |
|
98 |
} |
|
99 |
||
100 |
EXPORT_C CFsNotificationInfo* CFsNotificationInfo::Allocate(const CMountCB& aMount, TInt aFunction) |
|
101 |
{ |
|
102 |
CFsNotificationInfo* info = NotificationInfoPool->Allocate(); |
|
103 |
__ASSERT_DEBUG(info,User::Panic(_L("CFsNotificationInfo::Allocate, Could not allocate"),KErrNotFound)); |
|
104 |
||
105 |
TInt driveNum = aMount.Drive().DriveNumber(); |
|
106 |
__ASSERT_ALWAYS((driveNum >= EDriveA && driveNum <= EDriveZ), User::Panic(_L("CFsNotificationInfo::Allocate - Invalid Drive Num"),KErrArgument)); |
|
107 |
TInt err = info->Init(aFunction,driveNum); |
|
108 |
if(err != KErrNone) |
|
109 |
{ |
|
110 |
Free(info); |
|
111 |
return NULL; |
|
112 |
} |
|
113 |
return info; |
|
114 |
} |
|
115 |
||
116 |
||
117 |
CFsNotificationInfo* CFsNotificationInfo::Allocate(CFsMessageRequest& aRequest) |
|
118 |
{ |
|
119 |
//Get a notification Info block from the pool. |
|
120 |
CFsNotificationInfo* notificationInfo = NotificationInfoPool->Allocate(); |
|
121 |
||
122 |
//Set the function and call Init. |
|
123 |
TInt function = aRequest.Operation()->Function(); |
|
124 |
notificationInfo->iBody->iFunction = function; |
|
125 |
TInt err = notificationInfo->Init(function,aRequest.DriveNumber()); |
|
126 |
if(err != KErrNone) |
|
127 |
{ |
|
128 |
CFsNotificationInfo::Free(notificationInfo); |
|
129 |
return NULL; |
|
130 |
} |
|
131 |
||
132 |
//Set request |
|
133 |
notificationInfo->SetRequest(&aRequest); |
|
134 |
||
135 |
//Set UID |
|
136 |
notificationInfo->SetUid(aRequest.Uid()); |
|
137 |
||
138 |
//Set notification type |
|
139 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
140 |
CFsNotificationInfo::SetData(&aRequest,notificationInfo); |
|
141 |
#endif |
|
142 |
||
143 |
CFsClientMessageRequest& msgRequest = (CFsClientMessageRequest&)aRequest; |
|
144 |
||
145 |
//Get and store Src |
|
146 |
CFsNotificationInfo::PathName(msgRequest,notificationInfo->Source()); |
|
147 |
||
148 |
//Get and store NewName/Dest |
|
149 |
switch(function) |
|
150 |
{ |
|
151 |
case EFsFileRename: |
|
152 |
case EFsRename: |
|
153 |
case EFsReplace: |
|
154 |
case EFsSetDriveName: |
|
155 |
case EFsSetVolume: |
|
156 |
{ |
|
157 |
CFsNotificationInfo::NewPathName((CFsClientMessageRequest&)aRequest,notificationInfo->NewName()); |
|
158 |
notificationInfo->iBody->iDestDriveStored = ETrue; |
|
159 |
} |
|
160 |
default: |
|
161 |
break; |
|
162 |
} |
|
163 |
return notificationInfo; |
|
164 |
} |
|
165 |
||
166 |
CFsNotificationInfo* CFsNotificationInfo::Allocate(TInt aFunction, TInt aDrive) |
|
167 |
{ |
|
168 |
//Get a notification Info block from the pool. |
|
169 |
CFsNotificationInfo* notificationInfo = NotificationInfoPool->Allocate(); |
|
170 |
||
171 |
//Set the function and call Init. |
|
172 |
notificationInfo->iBody->iFunction = aFunction; |
|
173 |
TInt err = notificationInfo->Init(aFunction,aDrive); |
|
174 |
if(err != KErrNone) |
|
175 |
{ |
|
176 |
CFsNotificationInfo::Free(notificationInfo); |
|
177 |
return NULL; |
|
178 |
} |
|
179 |
||
180 |
//Set request (NULL) |
|
181 |
notificationInfo->SetRequest(NULL); |
|
182 |
||
183 |
//Set UID (KNullUid) |
|
184 |
notificationInfo->SetUid(TUid::Null()); |
|
185 |
return notificationInfo; |
|
186 |
} |
|
187 |
||
188 |
EXPORT_C void CFsNotificationInfo::Free(CFsNotificationInfo*& aNotificationInfo) |
|
189 |
{ |
|
190 |
__ASSERT_DEBUG(aNotificationInfo,User::Panic(_L("CFsNotificationInfo::Free - KErrArgument"), KErrArgument)); |
|
191 |
NotificationInfoPool->Free(aNotificationInfo); |
|
192 |
aNotificationInfo = NULL; |
|
193 |
} |
|
194 |
||
195 |
||
196 |
TInt CFsNotificationInfo::Initialise() |
|
197 |
{ |
|
198 |
//Have to trap as sf_main.cpp commonInitialize doesn't. |
|
199 |
TRAPD(r, NotificationInfoPool = CFsPool<CFsNotificationInfo>::New(KMaxDrives,CFsNotificationInfo::New)); |
|
200 |
if(r != KErrNone) |
|
201 |
return r; |
|
202 |
if(!NotificationInfoPool) |
|
203 |
return KErrNoMemory; |
|
204 |
return KErrNone; |
|
205 |
} |
|
206 |
||
207 |
CFsNotificationInfo* CFsNotificationInfo::New() |
|
208 |
{ |
|
209 |
CFsNotificationInfo* info = new CFsNotificationInfo; |
|
210 |
__ASSERT_ALWAYS(info,Fault(ENotifyPoolCreation)); |
|
211 |
info->iBody = new CFsNotificationInfoBody(); |
|
212 |
__ASSERT_ALWAYS(info->iBody,Fault(ENotifyPoolCreation)); |
|
213 |
return info; |
|
214 |
} |
|
215 |
||
216 |
EXPORT_C TInt CFsNotificationInfo::SetSourceName(const TDesC& aSrc) |
|
217 |
{ |
|
218 |
//Add the aSrc to a TParsePtrC (no copying the filename) |
|
219 |
TParsePtrC sourceParsePtr(aSrc); |
|
220 |
||
221 |
if(sourceParsePtr.DrivePresent() || !sourceParsePtr.FullName().Length()) |
|
222 |
return KErrArgument; |
|
223 |
||
224 |
switch(iBody->iFunction) |
|
225 |
{ |
|
226 |
||
227 |
case EFsFileWrite: //EParseSrc | EFileShare |
|
228 |
case EFsFileSetSize: //EParseSrc | EFileShare |
|
229 |
case EFsFileSetAtt: //EParseDst | EParseSrc, - should not use these; has share. |
|
230 |
case EFsFileSet: //EParseSrc | EFileShare |
|
231 |
case EFsFileSetModified: //EParseSrc | EFileShare - new |
|
232 |
case EFsFileWriteDirty: //EFileShare |
|
233 |
case EFsFileCreate: //EParseSrc |
|
234 |
case EFsFileTemp: //EParseSrc - new |
|
235 |
case EFsFileRename: //EParseDst | EParseSrc, |
|
236 |
case EFsFileReplace: //EParseSrc |
|
237 |
{ |
|
238 |
//Should look like this: \[path\]filename |
|
239 |
if(!sourceParsePtr.Name().Length()) |
|
240 |
{ |
|
241 |
return KErrArgument; |
|
242 |
} |
|
243 |
break; |
|
244 |
} |
|
245 |
case EFsDelete: //EParseSrc |
|
246 |
case EFsSetEntry: //EParseSrc, |
|
247 |
case EFsRename: //EParseDst | EParseSrc, |
|
248 |
case EFsReplace: //EParseDst | EParseSrc, |
|
249 |
{ |
|
250 |
if(!sourceParsePtr.PathPresent() && !sourceParsePtr.NamePresent()) |
|
251 |
{ |
|
252 |
return KErrArgument; |
|
253 |
} |
|
254 |
break; |
|
255 |
} |
|
256 |
case EFsRmDir: //EParseSrc |
|
257 |
case EFsMkDir: //EParseSrc |
|
258 |
{ |
|
259 |
if(!sourceParsePtr.PathPresent()) |
|
260 |
{ |
|
261 |
return KErrArgument; |
|
262 |
} |
|
263 |
break; |
|
264 |
} |
|
265 |
/*case EFsFormatNext: //EParseSrc |
|
266 |
case EFsDismountFileSystem: //0 |
|
267 |
case EFsMountFileSystem: //0 |
|
268 |
case EFsSetVolume: //0 |
|
269 |
case EFsSetDriveName: //ESync |
|
270 |
case EFsRawDiskWrite: //EParseSrc |
|
271 |
case EFsMountFileSystemScan: */ |
|
272 |
default: |
|
273 |
{ |
|
274 |
__ASSERT_DEBUG(EFalse,User::Panic(_L("CFsNotificationInfo::SetSourceName Invalid Operation"),KErrArgument)); |
|
275 |
return KErrNotSupported; |
|
276 |
} |
|
277 |
} |
|
278 |
memcpy(&iBody->iSrc,&sourceParsePtr,sizeof(TParsePtrC)); |
|
279 |
return KErrNone; |
|
280 |
} |
|
281 |
||
282 |
EXPORT_C TInt CFsNotificationInfo::SetNewName(const TDesC& aDest) |
|
283 |
{ |
|
284 |
//Add the aSrc to a TParsePtr for some validation without copying the filename |
|
285 |
TParsePtrC destParsePtr(aDest); |
|
286 |
||
287 |
if(destParsePtr.DrivePresent() || !destParsePtr.FullName().Length()) |
|
288 |
return KErrArgument; |
|
289 |
||
290 |
switch(iBody->iFunction) |
|
291 |
{ |
|
292 |
case EFsFileRename: //EParseDst | EParseSrc, |
|
293 |
case EFsRename: //EParseDst | EParseSrc, |
|
294 |
case EFsReplace: //EParseDst | EParseSrc, |
|
295 |
{ |
|
296 |
if(!destParsePtr.PathPresent() && !destParsePtr.NamePresent()) |
|
297 |
{ |
|
298 |
return KErrArgument; |
|
299 |
} |
|
300 |
break; |
|
301 |
} |
|
302 |
case EFsSetDriveName: |
|
303 |
case EFsSetVolume: |
|
304 |
{ |
|
305 |
if(!destParsePtr.NamePresent()) |
|
306 |
{ |
|
307 |
return KErrArgument; |
|
308 |
} |
|
309 |
break; |
|
310 |
} |
|
311 |
default: |
|
312 |
{ |
|
313 |
__ASSERT_DEBUG(ETrue,User::Panic(_L("CFsNotificationInfo::SetNewName Invalid Operation"),KErrArgument)); |
|
314 |
} |
|
315 |
} |
|
316 |
||
317 |
memcpy(&iBody->iDest,&destParsePtr,sizeof(TParsePtrC)); |
|
318 |
return KErrNone; |
|
319 |
} |
|
320 |
||
321 |
EXPORT_C TInt CFsNotificationInfo::SetFilesize(TInt64 aFilesize) |
|
322 |
{ |
|
323 |
if(aFilesize<0) |
|
324 |
return KErrArgument; |
|
325 |
||
326 |
iBody->iData = aFilesize; |
|
327 |
return KErrNone; |
|
328 |
} |
|
329 |
EXPORT_C TInt CFsNotificationInfo::SetAttributes(TUint aSet,TUint aCleared) |
|
330 |
{ |
|
331 |
iBody->iData = MAKE_TUINT64(aSet,aCleared); |
|
332 |
return KErrNone; |
|
333 |
} |
|
334 |
||
335 |
EXPORT_C TInt CFsNotificationInfo::SetUid(const TUid& aUid) |
|
336 |
{ |
|
337 |
iBody->iUid = aUid; |
|
338 |
return KErrNone; |
|
339 |
} |
|
340 |
||
341 |
||
342 |
TInt CFsNotificationInfo::SetDriveNumber(TInt aDriveNumber) |
|
343 |
{ |
|
344 |
if(aDriveNumber >= EDriveA && aDriveNumber <= EDriveZ) |
|
345 |
{ |
|
346 |
iBody->iDriveNumber = aDriveNumber; |
|
347 |
return KErrNone; |
|
348 |
} |
|
349 |
return KErrArgument; |
|
350 |
} |
|
351 |
void CFsNotificationInfo::SetRequest(CFsRequest* aRequest) |
|
352 |
{ |
|
353 |
iBody->iRequest = aRequest; |
|
354 |
} |
|
355 |
TInt CFsNotificationInfo::Function() |
|
356 |
{ return iBody->iFunction; } |
|
357 |
TInt CFsNotificationInfo::DriveNumber() |
|
358 |
{ return iBody->iDriveNumber; } |
|
359 |
TParsePtrC& CFsNotificationInfo::Source() |
|
360 |
{ |
|
361 |
switch(iBody->iFunction) |
|
362 |
{ |
|
363 |
case EFsFormatNext: //EParseSrc |
|
364 |
case EFsDismountFileSystem: //0 |
|
365 |
case EFsMountFileSystem: //0 |
|
366 |
case EFsSetVolume: //0 |
|
367 |
case EFsSetDriveName: //ESync |
|
368 |
case EFsRawDiskWrite: //EParseSrc |
|
369 |
case EFsMountFileSystemScan: |
|
370 |
{ |
|
371 |
_LIT(KFormatDrive,"?:"); |
|
372 |
iBody->iSrcBuf = KFormatDrive; |
|
373 |
iBody->iSrcBuf[0] = TText(DriveNumber() + 'A'); |
|
374 |
TParsePtrC parse(iBody->iSrcBuf); |
|
375 |
memcpy(&iBody->iSrc,&parse,sizeof(TParsePtrC)); |
|
376 |
} |
|
377 |
} |
|
378 |
return iBody->iSrc; |
|
379 |
} |
|
380 |
TParsePtrC& CFsNotificationInfo::NewName() |
|
381 |
{ return iBody->iDest; } |
|
382 |
CFsRequest* CFsNotificationInfo::Request() |
|
383 |
{ return iBody->iRequest; } |
|
384 |
TInt64* CFsNotificationInfo::Data() |
|
385 |
{ return &iBody->iData; } |
|
386 |
TUid& CFsNotificationInfo::Uid() |
|
387 |
{ return iBody->iUid; } |
|
388 |
TNotificationType& CFsNotificationInfo::NotificationType() |
|
389 |
{ return iBody->iNotificationType; } |
|
390 |
TBool CFsNotificationInfo::DestDriveIsSet() |
|
391 |
{ return iBody->iDestDriveStored; } |
|
392 |
TInt CFsNotificationInfo::SourceSize() |
|
393 |
{ |
|
394 |
TInt size = Source().FullName().Size(); |
|
395 |
if(NotificationType()!=TFsNotification::EMediaChange && |
|
396 |
NotificationType()!=TFsNotification::EDriveName && |
|
397 |
NotificationType()!=TFsNotification::EVolumeName) |
|
398 |
{ |
|
399 |
size += sizeof(TText)*2; |
|
400 |
} |
|
401 |
return size; |
|
402 |
} |
|
403 |
TInt CFsNotificationInfo::NewNameSize() |
|
404 |
{ |
|
405 |
TInt size = NewName().FullName().Size(); |
|
406 |
if(!DestDriveIsSet()) |
|
407 |
size += sizeof(TText)*2; |
|
408 |
return size; |
|
409 |
} |
|
410 |
||
411 |
//Get the path of the file, folder or drive name based on the TFsMessage function |
|
412 |
void CFsNotificationInfo::PathName(CFsClientMessageRequest& aRequest, TParsePtrC& aPath) |
|
413 |
{ |
|
414 |
__PRINT(_L("CFsNotificationInfo::PathName")); |
|
415 |
//Get the notification type |
|
416 |
TInt function = aRequest.Operation()->Function(); |
|
417 |
||
418 |
//Get the filename(s) |
|
419 |
switch(function) |
|
420 |
{ |
|
421 |
case EFsFileWrite: //EParseSrc | EFileShare |
|
422 |
case EFsFileSetSize: //EParseSrc | EFileShare |
|
423 |
case EFsFileSetAtt: //EParseDst | EParseSrc, - should not use these; has share. |
|
424 |
case EFsFileSet: //EParseSrc | EFileShare |
|
425 |
case EFsFileSetModified: //EParseSrc | EFileShare - new |
|
426 |
case EFsFileWriteDirty: //EFileShare |
|
427 |
{ |
|
428 |
CFileShare* share = NULL; |
|
429 |
CFileCB* file = NULL; |
|
430 |
GetFileFromScratch(&aRequest,share,file); |
|
431 |
TParsePtrC ptrC(file->iFileName->Des()); |
|
432 |
memcpy(&aPath,&ptrC,sizeof(TParsePtrC)); |
|
433 |
break; |
|
434 |
} |
|
435 |
case EFsFileCreate: //EParseSrc |
|
436 |
case EFsFileTemp: //EParseSrc - new |
|
437 |
case EFsDelete: //EParseSrc |
|
438 |
case EFsSetEntry: //EParseSrc, |
|
439 |
case EFsFileRename: //EParseDst | EParseSrc, |
|
440 |
case EFsRename: //EParseDst | EParseSrc, |
|
441 |
case EFsReplace: //EParseDst | EParseSrc, |
|
442 |
case EFsFileReplace: //EParseSrc |
|
443 |
{ |
|
444 |
TParsePtrC parsePtrC(aRequest.Src().FullName().Mid(2)); //Don't want drive letter |
|
445 |
memcpy(&aPath,&parsePtrC,sizeof(TParsePtrC)); |
|
446 |
break; |
|
447 |
} |
|
448 |
case EFsRmDir: //EParseSrc |
|
449 |
case EFsMkDir: //EParseSrc |
|
450 |
{ |
|
451 |
TParsePtrC parsePtrC(aRequest.Src().Path()); |
|
452 |
memcpy(&aPath,&parsePtrC,sizeof(TParsePtrC)); |
|
453 |
break; |
|
454 |
||
455 |
//aPath.Set(aRequest.Src().DriveAndPath(),NULL,NULL); |
|
456 |
//break; |
|
457 |
} |
|
458 |
case EFsFormatNext: //EParseSrc |
|
459 |
case EFsDismountFileSystem: //0 |
|
460 |
case EFsMountFileSystem: //0 |
|
461 |
case EFsSetVolume: //0 |
|
462 |
case EFsSetDriveName: //ESync |
|
463 |
case EFsRawDiskWrite: //EParseSrc |
|
464 |
case EFsLockDrive: |
|
465 |
case EFsUnlockDrive: |
|
466 |
case EFsReserveDriveSpace: |
|
467 |
case EFsMountFileSystemScan: |
|
468 |
{ |
|
469 |
break; |
|
470 |
} |
|
471 |
default: |
|
472 |
ASSERT(0); |
|
473 |
break; |
|
474 |
} |
|
475 |
} |
|
476 |
||
477 |
//Get the new path of the file, folder or drive name based on the TFsMessage function |
|
478 |
void CFsNotificationInfo::NewPathName(CFsClientMessageRequest& aRequest, TParsePtrC& aNewPath) |
|
479 |
{ |
|
480 |
__PRINT(_L("CFsNotificationInfo::NewPathName")); |
|
481 |
//Get the notification type |
|
482 |
TInt function = aRequest.Operation()->Function(); |
|
483 |
||
484 |
//Get the filename(s) |
|
485 |
switch(function) |
|
486 |
{ |
|
487 |
case EFsFileRename: //EParseDst | EParseSrc, |
|
488 |
case EFsRename: //EParseDst | EParseSrc, |
|
489 |
case EFsReplace: //EParseDst | EParseSrc, |
|
490 |
{ |
|
491 |
//We must provide the drive letter too as in the case |
|
492 |
//of the file being monitored being renamed to a |
|
493 |
//different drive. |
|
494 |
//In that case we need to provide the new drive letter to the client. |
|
495 |
TParsePtrC ptrC(aRequest.Dest().FullName()); |
|
496 |
memcpy(&aNewPath,&ptrC,sizeof(TParsePtrC)); |
|
497 |
break; |
|
498 |
} |
|
499 |
case EFsSetVolume: //EParseDst |
|
500 |
case EFsSetDriveName: //ESync | EParseDst |
|
501 |
{ |
|
502 |
TParsePtrC ptrC(aRequest.Dest().FullName()); |
|
503 |
memcpy(&aNewPath,&ptrC,sizeof(TParsePtrC)); |
|
504 |
break; |
|
505 |
} |
|
506 |
default: |
|
507 |
{ |
|
508 |
ASSERT(0); |
|
509 |
} |
|
510 |
} |
|
511 |
} |
|
512 |
||
513 |
//Get the size of the notification based on its type |
|
514 |
TInt CFsNotificationInfo::NotificationSize(CFsNotificationInfo& aRequest) |
|
515 |
{ |
|
516 |
__PRINT(_L("CFsNotificationInfo::NotificationSize")); |
|
517 |
||
518 |
/* |
|
519 |
* If there are no new names, the order of the data in the buffer is: |
|
520 |
* Word1 : NotificationSize (2 bytes) , PathSize (2 bytes) |
|
521 |
* Word2 : NotificationType (Lower 2 bytes) |
|
522 |
* Word3 : UID |
|
523 |
* Word(s) : Path (TText8) , [Any sub-class members] |
|
524 |
* |
|
525 |
* Else for notification types ERename, EVolumeName and EDriveName the order is: |
|
526 |
* Word1 : NotificationSize (2 bytes) , PathSize (2 bytes) |
|
527 |
* Word2 : NewNameSize (2 bytes) , NotificationType (2 bytes) |
|
528 |
* Word3 : UID |
|
529 |
* Word(s) : Path (TText8) , NewName (TText8) |
|
530 |
* |
|
531 |
* EOverflow size: KNotificationHeaderSize |
|
532 |
*/ |
|
533 |
||
534 |
//Size of the filename +(with '<drive>:') |
|
535 |
TInt size = KNotificationHeaderSize + Align4(aRequest.SourceSize()); |
|
536 |
||
537 |
switch(aRequest.NotificationType()) |
|
538 |
{ |
|
539 |
//NewName |
|
540 |
case TFsNotification::ERename: |
|
541 |
case TFsNotification::EVolumeName: |
|
542 |
case TFsNotification::EDriveName: |
|
543 |
{ |
|
544 |
if(!aRequest.NewName().FullName().Length()) |
|
545 |
__ASSERT_ALWAYS(false,User::Panic(_L("CFsNotificationInfo::NotificationSize"),KErrArgument)); |
|
546 |
||
547 |
size += Align4(aRequest.NewNameSize()); |
|
548 |
break; |
|
549 |
} |
|
550 |
case TFsNotification::EFileChange: |
|
551 |
{ |
|
552 |
size += sizeof(TInt64); |
|
553 |
break; |
|
554 |
} |
|
555 |
case TFsNotification::EAttribute: |
|
556 |
{ |
|
557 |
size += sizeof(TUint64); |
|
558 |
break; |
|
559 |
} |
|
560 |
case TFsNotification::ECreate: |
|
561 |
case TFsNotification::EDelete: |
|
562 |
case TFsNotification::EMediaChange: |
|
563 |
{ |
|
564 |
break; |
|
565 |
} |
|
566 |
default: |
|
567 |
{ |
|
568 |
ASSERT(0); |
|
569 |
break; |
|
570 |
} |
|
571 |
} |
|
572 |
return (TUint16) size; |
|
573 |
} |
|
574 |
||
575 |
||
576 |
TNotificationType CFsNotificationInfo::NotificationType(TInt& aIndex) |
|
577 |
{ |
|
578 |
__PRINT(_L("CFsNotificationInfo::NotificationType(TInt)")); |
|
579 |
__ASSERT_DEBUG(aIndex < KNumRegisterableFilters, Fault(ENotificationFault)); |
|
580 |
||
581 |
switch(aIndex) //No break statements here on purpose |
|
582 |
{ |
|
583 |
case 7 : return TFsNotification::EMediaChange; |
|
584 |
case 6 : return TFsNotification::EDriveName; |
|
585 |
case 5 : return TFsNotification::EVolumeName; |
|
586 |
case 4 : return TFsNotification::EDelete; |
|
587 |
case 3 : return TFsNotification::EAttribute; |
|
588 |
case 2 : return TFsNotification::ECreate; |
|
589 |
case 1 : return TFsNotification::ERename; |
|
590 |
case 0 : return TFsNotification::EFileChange; |
|
591 |
default: ASSERT(0); return (TFsNotification::TFsNotificationType) 0; |
|
592 |
} |
|
593 |
} |
|
594 |
||
595 |
//Get the array index of the notification based on its type |
|
596 |
TInt CFsNotificationInfo::TypeToIndex(TNotificationType aType) |
|
597 |
{ |
|
598 |
__PRINT(_L("CFsNotificationInfo::ArrayIndex")); |
|
599 |
||
600 |
TInt index = 0; |
|
601 |
switch(aType) //No break statements here on purpose |
|
602 |
{ |
|
603 |
case TFsNotification::EMediaChange: index++; |
|
604 |
case TFsNotification::EDriveName: index++; |
|
605 |
case TFsNotification::EVolumeName: index++; |
|
606 |
case TFsNotification::EDelete: index++; |
|
607 |
case TFsNotification::EAttribute: index++; |
|
608 |
case TFsNotification::ECreate: index++; |
|
609 |
case TFsNotification::ERename: index++; |
|
610 |
case TFsNotification::EFileChange: // skip; |
|
611 |
default: break; |
|
612 |
} |
|
613 |
__ASSERT_DEBUG(index < KNumRegisterableFilters, Fault(ENotificationFault)); |
|
614 |
return index; |
|
615 |
} |
|
616 |
||
617 |
TInt CFsNotificationInfo::DriveNumber(const TPtrC& aPath) |
|
618 |
{ |
|
619 |
if(aPath.Length() >= 1) |
|
620 |
{ |
|
621 |
TInt drive; |
|
622 |
TInt r = RFs::CharToDrive(aPath[0],drive); |
|
623 |
if(r!=KErrNone) |
|
624 |
return KErrNotFound; |
|
625 |
return drive; |
|
626 |
} |
|
627 |
return KErrNotFound; |
|
628 |
} |
|
629 |
||
630 |
//Get the attributes set and cleared |
|
631 |
void CFsNotificationInfo::Attributes(CFsMessageRequest& aRequest, TUint& aSet, TUint& aClear) |
|
632 |
{ |
|
633 |
__PRINT(_L("CFsNotificationInfo::Attributes")); |
|
634 |
||
635 |
TInt function = aRequest.Operation()->Function(); |
|
636 |
const RMessage2& msg = aRequest.Message(); |
|
637 |
||
638 |
//Client notification |
|
639 |
switch(function) |
|
640 |
{ |
|
641 |
case EFsFileSet: |
|
642 |
{ |
|
643 |
aSet = msg.Int1(); |
|
644 |
aClear = msg.Int2(); |
|
645 |
break; |
|
646 |
} |
|
647 |
case EFsFileSetAtt: |
|
648 |
{ |
|
649 |
aSet = msg.Int0(); |
|
650 |
aClear = msg.Int1(); |
|
651 |
break; |
|
652 |
} |
|
653 |
case EFsSetEntry: |
|
654 |
{ |
|
655 |
aSet = msg.Int2(); |
|
656 |
aClear = msg.Int3(); |
|
657 |
break; |
|
658 |
} |
|
659 |
default: |
|
660 |
{ |
|
661 |
ASSERT(0); |
|
662 |
break; |
|
663 |
} |
|
664 |
} |
|
665 |
} |
|
666 |
||
667 |
TInt64 CFsNotificationInfo::FileSize(CFsMessageRequest& aRequest) |
|
668 |
{ |
|
669 |
CFileShare* share = NULL; |
|
670 |
CFileCB* file = NULL; |
|
671 |
GetFileFromScratch(&aRequest, share, file); |
|
672 |
TInt64 size = file->CachedSize64(); |
|
673 |
return size; |
|
674 |
} |
|
675 |
||
676 |
||
677 |
void CFsNotificationInfo::SetData(CFsMessageRequest* aRequest, CFsNotificationInfo* aNotificationInfo) |
|
678 |
{ |
|
679 |
TInt function = aRequest->Operation()->Function(); |
|
680 |
||
681 |
switch(function) |
|
682 |
{ |
|
683 |
case EFsFileWrite: |
|
684 |
case EFsFileWriteDirty: |
|
685 |
case EFsFileSetSize: |
|
686 |
{ |
|
687 |
aNotificationInfo->SetFilesize(FileSize(*aRequest)); |
|
688 |
break; |
|
689 |
} |
|
690 |
case EFsSetEntry: |
|
691 |
case EFsFileSetAtt: |
|
692 |
case EFsFileSet: |
|
693 |
{ |
|
694 |
TUint set = 0; |
|
695 |
TUint clear = 0; |
|
696 |
Attributes(*aRequest,set,clear); |
|
697 |
*(aNotificationInfo->Data())= MAKE_TUINT64(set,clear); |
|
698 |
break; |
|
699 |
} |
|
700 |
default: |
|
701 |
{ |
|
702 |
return; |
|
703 |
} |
|
704 |
} |
|
705 |
} |
|
706 |
||
707 |
TInt CFsNotificationInfo::ValidateNotification(CFsNotificationInfo& aNotificationInfo) |
|
708 |
{ |
|
709 |
//Validate UID |
|
710 |
if(aNotificationInfo.Uid() == TUid::Null()) |
|
711 |
{ |
|
712 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - Uid not set"),KErrArgument)); |
|
713 |
return KErrArgument; |
|
714 |
} |
|
715 |
||
716 |
switch(aNotificationInfo.Function()) |
|
717 |
{ |
|
718 |
case EFsFileWrite: |
|
719 |
case EFsFileWriteDirty: |
|
720 |
case EFsFileSetSize: |
|
721 |
{ |
|
722 |
if(*aNotificationInfo.Data() == -1) |
|
723 |
{ |
|
724 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - File size not set"),KErrArgument)); |
|
725 |
return KErrArgument; |
|
726 |
} |
|
727 |
if(!aNotificationInfo.Source().FullName().Length()) |
|
728 |
{ |
|
729 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - Source Name not set"),KErrArgument)); |
|
730 |
return KErrArgument; |
|
731 |
} |
|
732 |
if(aNotificationInfo.NewName().FullName().Length()) |
|
733 |
{ |
|
734 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - New Name set in err"),KErrArgument)); |
|
735 |
return KErrArgument; |
|
736 |
} |
|
737 |
break; |
|
738 |
} |
|
739 |
case EFsRename: |
|
740 |
case EFsFileRename: |
|
741 |
case EFsReplace: |
|
742 |
case EFsSetVolume: |
|
743 |
case EFsSetDriveName: |
|
744 |
{ |
|
745 |
if(!aNotificationInfo.Source().FullName().Length()) |
|
746 |
{ |
|
747 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - Source Name not set"),KErrArgument)); |
|
748 |
return KErrArgument; |
|
749 |
} |
|
750 |
if(!aNotificationInfo.NewName().FullName().Length()) |
|
751 |
{ |
|
752 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - New Name not set"),KErrArgument)); |
|
753 |
return KErrArgument; |
|
754 |
} |
|
755 |
if(*aNotificationInfo.Data() != -1) |
|
756 |
{ |
|
757 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - Data set in err"),KErrArgument)); |
|
758 |
return KErrArgument; |
|
759 |
} |
|
760 |
break; |
|
761 |
} |
|
762 |
case EFsMkDir: |
|
763 |
case EFsFileCreate: |
|
764 |
case EFsFileReplace: |
|
765 |
case EFsDelete: |
|
766 |
case EFsRmDir: |
|
767 |
{ |
|
768 |
if(!aNotificationInfo.Source().FullName().Length()) |
|
769 |
{ |
|
770 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - Source Name not set"),KErrArgument)); |
|
771 |
return KErrArgument; |
|
772 |
} |
|
773 |
if(aNotificationInfo.NewName().FullName().Length()) |
|
774 |
{ |
|
775 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - New Name set in err"),KErrArgument)); |
|
776 |
return KErrArgument; |
|
777 |
} |
|
778 |
if(*aNotificationInfo.Data() != -1) |
|
779 |
{ |
|
780 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - Data set in err"),KErrArgument)); |
|
781 |
return KErrArgument; |
|
782 |
} |
|
783 |
break; |
|
784 |
} |
|
785 |
case EFsFileSetAtt: |
|
786 |
case EFsFileSet: |
|
787 |
case EFsSetEntry: |
|
788 |
{ |
|
789 |
if(!aNotificationInfo.Source().FullName().Length()) |
|
790 |
{ |
|
791 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - Source Name not set"),KErrArgument)); |
|
792 |
return KErrArgument; |
|
793 |
} |
|
794 |
if(*aNotificationInfo.Data() == -1) |
|
795 |
{ |
|
796 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - Attributes not set"),KErrArgument)); |
|
797 |
return KErrArgument; |
|
798 |
} |
|
799 |
if(aNotificationInfo.NewName().FullName().Length()) |
|
800 |
{ |
|
801 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - New Name set in err"),KErrArgument)); |
|
802 |
return KErrArgument; |
|
803 |
} |
|
804 |
break; |
|
805 |
} |
|
806 |
case EFsDismountFileSystem: |
|
807 |
case EFsMountFileSystem: |
|
808 |
case EFsFormatNext: |
|
809 |
case EFsRawDiskWrite: |
|
810 |
case EFsMountFileSystemScan: |
|
811 |
{ |
|
812 |
if(aNotificationInfo.NewName().FullName().Length()) |
|
813 |
{ |
|
814 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - New Name set in err"),KErrArgument)); |
|
815 |
return KErrArgument; |
|
816 |
} |
|
817 |
if(aNotificationInfo.Source().FullName().Length()) |
|
818 |
{ |
|
819 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - Source Name set in err"),KErrArgument)); |
|
820 |
return KErrArgument; |
|
821 |
} |
|
822 |
if(*aNotificationInfo.Data() != -1) |
|
823 |
{ |
|
824 |
__ASSERT_DEBUG(false,User::Panic(_L("::ValidateNotification - Data set in err"),KErrArgument)); |
|
825 |
return KErrArgument; |
|
826 |
} |
|
827 |
break; |
|
828 |
} |
|
829 |
default: |
|
830 |
{ |
|
831 |
break; |
|
832 |
} |
|
833 |
} |
|
834 |
return KErrNone; |
|
835 |
} |
|
836 |
||
837 |
TUint CFsNotificationInfo::NotifyType(TInt aFunction) |
|
838 |
// |
|
839 |
// Convert aFunction that caused the notification to a |
|
840 |
// value corresponding to the correct TNotifyType enum |
|
841 |
// |
|
842 |
{ |
|
843 |
switch (aFunction) |
|
844 |
{ |
|
845 |
case EFsFileCreate: |
|
846 |
case EFsFileReplace: |
|
847 |
case EFsDelete: |
|
848 |
case EFsReplace: |
|
849 |
case EFsFileRename: |
|
850 |
return(ENotifyFile|ENotifyEntry); |
|
851 |
case EFsMkDir: |
|
852 |
case EFsRmDir: |
|
853 |
return(ENotifyDir|ENotifyEntry); |
|
854 |
case EFsRename: |
|
855 |
return(ENotifyDir|ENotifyFile|ENotifyEntry); |
|
856 |
case EFsSetVolume: |
|
857 |
return(ENotifyDisk|ENotifyEntry); |
|
858 |
case EFsFileSet: |
|
859 |
case EFsFileSetAtt: |
|
860 |
case EFsFileSetModified: |
|
861 |
case EFsFileSetSize: |
|
862 |
case EFsSetEntry: |
|
863 |
return(ENotifyAttributes); |
|
864 |
case EFsFileWrite: |
|
865 |
case EFsFileWriteDirty: |
|
866 |
return(ENotifyWrite); |
|
867 |
case EFsRawDiskWrite: |
|
868 |
case EFsLockDrive: |
|
869 |
case EFsUnlockDrive: |
|
870 |
return(ENotifyDisk); |
|
871 |
case EFsFileTemp: |
|
872 |
case EFsSetDriveName: |
|
873 |
return(ENotifyAll); |
|
874 |
default: |
|
875 |
return(0); |
|
876 |
} |
|
877 |
} |
|
878 |
||
0 | 879 |
void CNotifyInfo::Initialise(TInfoType aType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession) |
880 |
// |
|
881 |
// |
|
882 |
// |
|
883 |
{ |
|
884 |
iType=aType; |
|
885 |
iStatus=aStatus; |
|
886 |
iMessage=aMessage; |
|
887 |
iSession=aSession; |
|
888 |
}; |
|
889 |
||
890 |
CNotifyInfo::~CNotifyInfo() |
|
891 |
// |
|
892 |
// |
|
893 |
// |
|
894 |
{ |
|
286 | 895 |
// message should have been completed already |
896 |
__ASSERT_DEBUG(iMessage.IsNull(), Fault(ENotifyInfoDestructor)); |
|
897 |
||
898 |
__ASSERT_DEBUG(iLink.iNext,Fault(ENotifyInfoDestructor)); |
|
899 |
iLink.Deque(); |
|
0 | 900 |
} |
901 |
||
902 |
void CNotifyInfo::Complete(TInt aError) |
|
903 |
// |
|
904 |
// |
|
905 |
// |
|
906 |
{ |
|
907 |
__PRINT2(_L("CNotifyInfo::Complete 0x%x error=%d"),this,aError); |
|
286 | 908 |
if (!iMessage.IsNull()) |
0 | 909 |
iMessage.Complete(aError); |
910 |
} |
|
911 |
||
912 |
||
913 |
void CStdChangeInfo::Initialise(TNotifyType aChangeType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession) |
|
914 |
// |
|
915 |
// |
|
916 |
// |
|
917 |
{ |
|
918 |
iChangeType=aChangeType; |
|
919 |
CNotifyInfo::Initialise(EStdChange,aStatus,aMessage,aSession); |
|
920 |
} |
|
921 |
||
300 | 922 |
TUint CStdChangeInfo::RequestNotifyType(CFsNotificationInfo* aRequest) |
0 | 923 |
// |
924 |
// return notification type for the request |
|
925 |
// |
|
926 |
{ |
|
300 | 927 |
TUint notifyType=CFsNotificationInfo::NotifyType(aRequest->Function()); |
928 |
if(aRequest->Function()==EFsRename) |
|
0 | 929 |
{ |
930 |
__ASSERT_DEBUG(notifyType==(ENotifyDir|ENotifyFile|ENotifyEntry),Fault(EStdChangeRequestType)); |
|
300 | 931 |
if(aRequest->Source().NamePresent()) |
0 | 932 |
notifyType=ENotifyFile|ENotifyEntry; |
933 |
else |
|
934 |
notifyType=ENotifyDir|ENotifyEntry; |
|
935 |
} |
|
936 |
return(notifyType); |
|
937 |
} |
|
938 |
||
300 | 939 |
|
940 |
TBool CStdChangeInfo::IsMatching(CFsNotificationInfo* aNotificationInfo) |
|
0 | 941 |
// |
942 |
// return ETrue if operation type of request matches that of change notification |
|
943 |
// |
|
300 | 944 |
{ |
945 |
if((iChangeType&ENotifyAll) || (iChangeType&CFsNotificationInfo::NotifyType(aNotificationInfo->Function()))) |
|
0 | 946 |
return(ETrue); |
947 |
else |
|
948 |
return(EFalse); |
|
949 |
} |
|
950 |
||
951 |
void CExtChangeInfo::Initialise(TNotifyType aChangeType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession,const TDesC& aName) |
|
952 |
// |
|
953 |
// |
|
954 |
// |
|
955 |
{ |
|
956 |
__ASSERT_DEBUG(aName.Length()<=KMaxFileName-2,Fault(EExtChangeNameLength)); |
|
957 |
iName=aName; |
|
958 |
iChangeType=aChangeType; |
|
959 |
CNotifyInfo::Initialise(EExtChange,aStatus,aMessage,aSession); |
|
960 |
} |
|
961 |
||
962 |
||
300 | 963 |
TBool CExtChangeInfo::IsMatching(CFsNotificationInfo* aRequest) |
0 | 964 |
// |
965 |
// return ETrue if operation notify type of request matches that of change notification |
|
966 |
// and paths match |
|
967 |
// |
|
300 | 968 |
{ |
969 |
TInt function=aRequest->Function(); |
|
0 | 970 |
// if a rename occurred inform any requests if their path has been changed regardless of the notification type |
971 |
if(function==EFsRename) |
|
972 |
{ |
|
300 | 973 |
TBuf<KMaxFileName> renamePath=aRequest->Source().FullName(); |
0 | 974 |
renamePath+=_L("*"); |
975 |
if (iName.MatchF(renamePath)!=KErrNotFound) |
|
976 |
return(ETrue); |
|
977 |
} |
|
978 |
||
979 |
||
980 |
//Special case where the dir the notifier is setup on has just been created |
|
981 |
if(function==EFsMkDir) |
|
982 |
{ |
|
300 | 983 |
if(aRequest->Source().Path().MatchF(iName) == 0) |
0 | 984 |
return ETrue; |
985 |
} |
|
986 |
||
300 | 987 |
//Special case where the File the notifier is setup on has just been created by temp as the name is not known until it has been created |
0 | 988 |
if(function==EFsRename||function==EFsFileOpen||function==EFsFileCreate||function==EFsFileReplace) |
989 |
{ |
|
300 | 990 |
if(aRequest->Source().FullName().MatchF(iName) == 0) |
0 | 991 |
return ETrue; |
992 |
} |
|
993 |
||
994 |
//For the case of a file created using EFsFileTemp we can probably ignore it for special cases as it |
|
995 |
//is created with a random name. Not specifically going to be being looked for |
|
996 |
||
997 |
if((iChangeType&ENotifyAll) || (iChangeType&RequestNotifyType(aRequest))) |
|
998 |
{ |
|
999 |
switch (function) |
|
1000 |
{ |
|
1001 |
// Notify interested requests if a SetDriveName(), SetVolume() or RawDiskWrite() operation |
|
1002 |
// occcurred. By their nature, these operations have no distinct path. All outstanding |
|
1003 |
// requests monitoring the relevant TNotifyType are potentially interested in such operations |
|
1004 |
case EFsFileWrite: |
|
1005 |
case EFsFileWriteDirty: |
|
1006 |
case EFsFileSet: |
|
1007 |
case EFsFileSetAtt: |
|
1008 |
case EFsFileSetModified: |
|
1009 |
case EFsFileSetSize: |
|
1010 |
{ |
|
1011 |
TBuf<KMaxFileName> root=iName; |
|
1012 |
root+=_L("*"); |
|
1013 |
||
300 | 1014 |
if (aRequest->Source().FullName().MatchF(root) != KErrNotFound) |
1015 |
{ |
|
1016 |
return(ETrue); |
|
1017 |
} |
|
0 | 1018 |
} |
1019 |
break; |
|
1020 |
case EFsSetDriveName: |
|
1021 |
case EFsSetVolume: |
|
1022 |
case EFsRawDiskWrite: |
|
1023 |
case EFsLockDrive: |
|
1024 |
case EFsUnlockDrive: |
|
1025 |
case EFsReserveDriveSpace: |
|
1026 |
{ |
|
1027 |
return(ETrue); |
|
1028 |
} |
|
1029 |
||
1030 |
default: |
|
1031 |
{ |
|
1032 |
TBuf<KMaxFileName> root = iName; |
|
1033 |
root+=_L("*"); |
|
1034 |
||
300 | 1035 |
if(aRequest->Source().FullName().MatchF(root)!=KErrNotFound) |
0 | 1036 |
return(ETrue); |
1037 |
else if(function==EFsRename||function==EFsReplace||function==EFsFileRename) |
|
1038 |
{ |
|
1039 |
// - rename/replace causes the file/path to disappear |
|
300 | 1040 |
TPtrC newName; |
1041 |
if(aRequest->DestDriveIsSet()) |
|
1042 |
newName.Set(aRequest->NewName().FullName().Mid(2)); |
|
1043 |
else |
|
1044 |
newName.Set(aRequest->NewName().FullName()); |
|
1045 |
if(newName.MatchF(root)!=KErrNotFound) |
|
0 | 1046 |
{ |
1047 |
return(ETrue); |
|
1048 |
} |
|
1049 |
||
1050 |
// - rename/replace causes the file/path to arrive |
|
300 | 1051 |
if(aRequest->DestDriveIsSet()) |
1052 |
root=aRequest->NewName().FullName().Mid(2); |
|
1053 |
else |
|
1054 |
root=aRequest->NewName().FullName(); |
|
0 | 1055 |
root+=_L("*"); |
1056 |
||
1057 |
if (iName.MatchF(root)!=KErrNotFound) |
|
1058 |
{ |
|
1059 |
return(ETrue); |
|
1060 |
} |
|
1061 |
} |
|
1062 |
} |
|
1063 |
} |
|
1064 |
} |
|
1065 |
return(EFalse); |
|
1066 |
} |
|
1067 |
||
1068 |
||
1069 |
void CDiskSpaceInfo::Initialise(TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession,TInt64 aThreshold) |
|
1070 |
// |
|
1071 |
// |
|
1072 |
// |
|
1073 |
{ |
|
1074 |
__ASSERT_DEBUG(aThreshold>0,Fault(EDiskSpaceThreshold)); |
|
1075 |
iThreshold=aThreshold; |
|
1076 |
CNotifyInfo::Initialise(EDiskSpace,aStatus,aMessage,aSession); |
|
1077 |
} |
|
1078 |
||
1079 |
TBool CDiskSpaceInfo::IsMatching(TInt64& aBefore,TInt64& aAfter) |
|
1080 |
// |
|
1081 |
// return ETrue if the threshold has been crossed |
|
1082 |
// |
|
1083 |
{ |
|
1084 |
if((aBefore>=iThreshold&&aAfter<iThreshold)||(aBefore<=iThreshold&&aAfter>iThreshold)) |
|
1085 |
return(ETrue); |
|
1086 |
return(EFalse); |
|
1087 |
} |
|
1088 |
||
1089 |
void CDebugChangeInfo::Initialise(TUint aDebugType,TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession) |
|
1090 |
// |
|
1091 |
// |
|
1092 |
// |
|
1093 |
{ |
|
1094 |
__ASSERT_DEBUG((aDebugType&KDebugNotifyMask)&&!(aDebugType&~KDebugNotifyMask),Fault(EDebugChangeType)); |
|
1095 |
iDebugType=aDebugType; |
|
1096 |
CNotifyInfo::Initialise(EDebugChange,aStatus,aMessage,aSession); |
|
1097 |
} |
|
1098 |
||
1099 |
TBool CDebugChangeInfo::IsMatching(TUint aFunction) |
|
1100 |
// |
|
1101 |
// return ETrue if debug notification type matches aFunction |
|
1102 |
// |
|
1103 |
{ |
|
1104 |
if(iDebugType&aFunction) |
|
1105 |
return(ETrue); |
|
1106 |
return(EFalse); |
|
1107 |
} |
|
1108 |
||
1109 |
||
1110 |
CDismountNotifyInfo::~CDismountNotifyInfo() |
|
1111 |
{ |
|
1112 |
switch(iMode) |
|
1113 |
{ |
|
1114 |
case EFsDismountNotifyClients: |
|
1115 |
break; |
|
1116 |
case EFsDismountRegisterClient: |
|
1117 |
__ASSERT_ALWAYS(TheDrives[iDriveNumber].DismountUnlock() >= 0, Fault(ENotifyDismountCancel)); |
|
286 | 1118 |
__ASSERT_ALWAYS(iMessage.IsNull(), Fault(ENotifyDismountCancel)); |
1119 |
TheDrives[iDriveNumber].DismountClientRemoved(); |
|
0 | 1120 |
break; |
1121 |
default: |
|
1122 |
break; |
|
1123 |
} |
|
1124 |
} |
|
1125 |
||
286 | 1126 |
void CDismountNotifyInfo::Complete(TInt aError) |
1127 |
{ |
|
1128 |
__PRINT2(_L("CDismountNotifyInfo::Complete 0x%x error=%d"),this,aError); |
|
1129 |
if (!iMessage.IsNull()) |
|
1130 |
{ |
|
1131 |
iMessage.Complete(aError); |
|
1132 |
// inc count of messages completed by EFsDismountNotifyClients & waiting for an EFsAllowDismount request from client |
|
1133 |
if (iMode == EFsDismountRegisterClient) |
|
1134 |
TheDrives[iDriveNumber].DismountClientAdded(); |
|
1135 |
} |
|
1136 |
} |
|
1137 |
||
1138 |
||
0 | 1139 |
void CDismountNotifyInfo::Initialise(TNotifyDismountMode aMode, TInt aDriveNumber, TRequestStatus* aStatus,const RMessagePtr2& aMessage,CSessionFs* aSession) |
1140 |
{ |
|
1141 |
iMode = aMode; |
|
1142 |
iDriveNumber=aDriveNumber; |
|
1143 |
CNotifyInfo::Initialise(EDismount,aStatus,aMessage,aSession); |
|
1144 |
||
1145 |
if (iMode == EFsDismountRegisterClient) |
|
1146 |
TheDrives[iDriveNumber].DismountLock(); |
|
1147 |
} |
|
1148 |
||
1149 |
TBool CDismountNotifyInfo::IsMatching(TNotifyDismountMode aMode, TInt aDriveNumber, CSessionFs* aSession) |
|
1150 |
{ |
|
1151 |
if((iDriveNumber == aDriveNumber) && (iMode == aMode) && (aSession == NULL || aSession == Session())) |
|
1152 |
return(ETrue); |
|
1153 |
return(EFalse); |
|
1154 |
} |
|
1155 |
||
1156 |
TBaseQue::TBaseQue() |
|
1157 |
// |
|
1158 |
// |
|
1159 |
// |
|
1160 |
{ |
|
1161 |
iHeader.SetOffset(_FOFF(CNotifyInfo,iLink)); |
|
1162 |
TInt r=iQLock.CreateLocal(); |
|
1163 |
__ASSERT_ALWAYS(r==KErrNone,Fault(EBaseQueConstruction)); |
|
1164 |
} |
|
1165 |
||
1166 |
TBaseQue::~TBaseQue() |
|
1167 |
// |
|
1168 |
// |
|
1169 |
// |
|
1170 |
{ |
|
1171 |
iQLock.Close(); |
|
1172 |
} |
|
1173 |
||
1174 |
void TBaseQue::DoAddNotify(CNotifyInfo* aInfo) |
|
1175 |
// |
|
1176 |
// Add notification |
|
1177 |
// Que should be locked by calling function |
|
1178 |
// |
|
1179 |
{ |
|
1180 |
iHeader.AddLast(*aInfo); |
|
1181 |
} |
|
1182 |
||
1183 |
TBool TBaseQue::DoCancelSession(CSessionFs* aSession,TInt aCompletionCode, TRequestStatus* aStatus) |
|
1184 |
// |
|
1185 |
// Cancel notification(s) setup by aSession matching aStatus if set |
|
1186 |
// Que should be locked by calling function |
|
1187 |
// |
|
1188 |
{ |
|
1189 |
TDblQueIter<CNotifyInfo> q(iHeader); |
|
1190 |
CNotifyInfo* info; |
|
1191 |
TBool isFound=EFalse; |
|
1192 |
while((info=q++)!=NULL) |
|
1193 |
{ |
|
1194 |
if(info->Session()==aSession && (!aStatus || aStatus==info->Status())) |
|
1195 |
{ |
|
1196 |
isFound=ETrue; |
|
1197 |
info->Complete(aCompletionCode); |
|
1198 |
delete(info); |
|
1199 |
if(aStatus) |
|
1200 |
break; |
|
1201 |
} |
|
1202 |
} |
|
1203 |
return(isFound); |
|
1204 |
} |
|
1205 |
||
1206 |
void TBaseQue::DoCancelAll(TInt aCompletionCode) |
|
1207 |
// |
|
1208 |
// Cancel all notifications |
|
1209 |
// Que should be locked by calling function |
|
1210 |
// |
|
1211 |
{ |
|
1212 |
TDblQueIter<CNotifyInfo> q(iHeader); |
|
1213 |
CNotifyInfo* info; |
|
1214 |
while((info=q++)!=NULL) |
|
1215 |
{ |
|
1216 |
info->Complete(aCompletionCode); |
|
1217 |
delete(info); |
|
1218 |
} |
|
1219 |
__ASSERT_DEBUG(iHeader.IsEmpty(),Fault(EBaseQueCancel)); |
|
1220 |
} |
|
1221 |
||
1222 |
TBool TBaseQue::IsEmpty() |
|
1223 |
// |
|
1224 |
// Que should be locked by calling function |
|
1225 |
// |
|
1226 |
{ |
|
1227 |
return iHeader.IsEmpty(); |
|
1228 |
} |
|
1229 |
||
1230 |
TBool TChangeQue::IsEmpty() |
|
1231 |
// |
|
1232 |
// |
|
1233 |
// |
|
1234 |
{ |
|
1235 |
iQLock.Wait(); |
|
1236 |
TBool empty = TBaseQue::IsEmpty(); |
|
1237 |
iQLock.Signal(); |
|
1238 |
return(empty); |
|
1239 |
} |
|
1240 |
||
1241 |
TInt TChangeQue::AddNotify(CNotifyInfo* aInfo) |
|
1242 |
// |
|
1243 |
// |
|
1244 |
// |
|
1245 |
{ |
|
1246 |
iQLock.Wait(); |
|
1247 |
TBaseQue::DoAddNotify(aInfo); |
|
1248 |
iQLock.Signal(); |
|
1249 |
return(KErrNone); |
|
1250 |
} |
|
1251 |
||
1252 |
TBool TChangeQue::CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus) |
|
1253 |
// |
|
1254 |
// |
|
1255 |
// |
|
1256 |
{ |
|
1257 |
iQLock.Wait(); |
|
1258 |
TBool isFound=TBaseQue::DoCancelSession(aSession,aCompletionCode,aStatus); |
|
1259 |
iQLock.Signal(); |
|
1260 |
return(isFound); |
|
1261 |
} |
|
1262 |
||
1263 |
void TChangeQue::CancelAll(TInt aCompletionCode) |
|
1264 |
// |
|
1265 |
// |
|
1266 |
// |
|
1267 |
{ |
|
1268 |
iQLock.Wait(); |
|
1269 |
TBaseQue::DoCancelAll(aCompletionCode); |
|
1270 |
iQLock.Signal(); |
|
1271 |
} |
|
1272 |
||
300 | 1273 |
void TChangeQue::CheckChange(CFsNotificationInfo& aRequest) |
0 | 1274 |
// |
1275 |
// complete any notification in que that matches aRequest |
|
1276 |
// |
|
1277 |
{ |
|
1278 |
iQLock.Wait(); |
|
1279 |
TDblQueIter<CNotifyInfo> q(iHeader); |
|
1280 |
CNotifyInfo* info; |
|
1281 |
while((info=q++)!=NULL) |
|
1282 |
{ |
|
1283 |
__ASSERT_DEBUG(info->Type()==CNotifyInfo::EStdChange||info->Type()==CNotifyInfo::EExtChange,Fault(EChangeQueType)); |
|
1284 |
TBool isMatching; |
|
1285 |
if(info->Type()==CNotifyInfo::EStdChange) |
|
300 | 1286 |
isMatching=((CStdChangeInfo*)info)->IsMatching(&aRequest); |
0 | 1287 |
else |
300 | 1288 |
isMatching=((CExtChangeInfo*)info)->IsMatching(&aRequest); |
0 | 1289 |
if(isMatching) |
1290 |
{ |
|
1291 |
__PRINT1(_L("TChangeQue::CheckChange()-Matching info=0x%x"),info); |
|
1292 |
info->Complete(KErrNone); |
|
1293 |
delete(info); |
|
1294 |
} |
|
1295 |
} |
|
1296 |
iQLock.Signal(); |
|
1297 |
} |
|
1298 |
||
1299 |
TBool TDiskSpaceQue::IsEmpty() |
|
1300 |
// |
|
1301 |
// |
|
1302 |
// |
|
1303 |
{ |
|
1304 |
iQLock.Wait(); |
|
1305 |
TBool empty = TBaseQue::IsEmpty(); |
|
1306 |
iQLock.Signal(); |
|
1307 |
return(empty); |
|
1308 |
} |
|
1309 |
||
1310 |
TInt TDiskSpaceQue::AddNotify(CNotifyInfo* aInfo) |
|
1311 |
// |
|
1312 |
// |
|
1313 |
// |
|
1314 |
{ |
|
1315 |
iQLock.Wait(); |
|
1316 |
TInt r=KErrNone; |
|
1317 |
if(iHeader.IsEmpty()) |
|
1318 |
{ |
|
1319 |
r=GetFreeDiskSpace(iFreeDiskSpace); |
|
1320 |
iReservedDiskSpace = TheDrives[iDriveNumber].ReservedSpace(); |
|
1321 |
} |
|
1322 |
if(r==KErrNone) |
|
1323 |
TBaseQue::DoAddNotify(aInfo); |
|
1324 |
iQLock.Signal(); |
|
1325 |
return(r); |
|
1326 |
} |
|
1327 |
||
1328 |
TInt TDiskSpaceQue::CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus) |
|
1329 |
// |
|
1330 |
// |
|
1331 |
// |
|
1332 |
{ |
|
1333 |
iQLock.Wait(); |
|
1334 |
TBaseQue::DoCancelSession(aSession,aCompletionCode,aStatus); |
|
1335 |
iQLock.Signal(); |
|
1336 |
return(KErrNone); |
|
1337 |
} |
|
1338 |
||
1339 |
void TDiskSpaceQue::CancelAll(TInt aCompletionCode) |
|
1340 |
// |
|
1341 |
// |
|
1342 |
// |
|
1343 |
{ |
|
1344 |
iQLock.Wait(); |
|
1345 |
TBaseQue::DoCancelAll(aCompletionCode); |
|
1346 |
iQLock.Signal(); |
|
1347 |
} |
|
1348 |
||
1349 |
||
1350 |
void TDiskSpaceQue::CheckDiskSpace() |
|
1351 |
// |
|
1352 |
// Complete any disk space notification whose threshold has been crossed |
|
1353 |
// |
|
1354 |
{ |
|
1355 |
iQLock.Wait(); |
|
1356 |
if(iHeader.IsEmpty()) |
|
1357 |
{ |
|
1358 |
iQLock.Signal(); |
|
1359 |
return; |
|
1360 |
} |
|
1361 |
TInt64 freeSpace; |
|
1362 |
TInt r=GetFreeDiskSpace(freeSpace); |
|
1363 |
TInt64 reservedSpace(TheDrives[iDriveNumber].ReservedSpace()); |
|
1364 |
if(r==KErrNone) |
|
1365 |
{ |
|
1366 |
if((freeSpace==iFreeDiskSpace) && (reservedSpace==iReservedDiskSpace)) |
|
1367 |
{ |
|
1368 |
iQLock.Signal(); |
|
1369 |
return; |
|
1370 |
} |
|
1371 |
TDblQueIter<CNotifyInfo> q(iHeader); |
|
1372 |
CNotifyInfo* info; |
|
1373 |
while((info=q++)!=NULL) |
|
1374 |
{ |
|
1375 |
__ASSERT_DEBUG(info->Type()==CNotifyInfo::EDiskSpace,Fault(EDiskSpaceQueType1)); |
|
1376 |
||
1377 |
TInt64 newSessionFreeSpace(freeSpace); |
|
1378 |
TInt64 oldSessionFreeSpace(iFreeDiskSpace); |
|
1379 |
if(!info->Session()->ReservedAccess(iDriveNumber)) |
|
1380 |
{ |
|
1381 |
newSessionFreeSpace -= reservedSpace; |
|
1382 |
oldSessionFreeSpace -= iReservedDiskSpace; |
|
1383 |
} |
|
1384 |
||
1385 |
if(((CDiskSpaceInfo*)info)->IsMatching(oldSessionFreeSpace,newSessionFreeSpace)) |
|
1386 |
{ |
|
1387 |
__PRINT1(_L("TDiskSpaceQue::CheckDiskSpace()-Matching info=0x%x"),info); |
|
1388 |
info->Complete(KErrNone); |
|
1389 |
delete(info); |
|
1390 |
} |
|
1391 |
} |
|
1392 |
iFreeDiskSpace=freeSpace; |
|
1393 |
iReservedDiskSpace=reservedSpace; |
|
1394 |
} |
|
1395 |
else |
|
1396 |
TBaseQue::DoCancelAll(KErrNone); |
|
1397 |
iQLock.Signal(); |
|
1398 |
} |
|
1399 |
||
1400 |
void TDiskSpaceQue::CheckDiskSpace(TInt64& aFreeDiskSpace) |
|
1401 |
// |
|
1402 |
// |
|
1403 |
// |
|
1404 |
{ |
|
1405 |
iQLock.Wait(); |
|
1406 |
if(iHeader.IsEmpty()) |
|
1407 |
{ |
|
1408 |
iQLock.Signal(); |
|
1409 |
return; |
|
1410 |
} |
|
1411 |
||
1412 |
TInt64 reservedSpace(TheDrives[iDriveNumber].ReservedSpace()); |
|
1413 |
||
1414 |
if((aFreeDiskSpace==iFreeDiskSpace) && (reservedSpace==iReservedDiskSpace)) |
|
1415 |
{ |
|
1416 |
iQLock.Signal(); |
|
1417 |
return; |
|
1418 |
} |
|
1419 |
TDblQueIter<CNotifyInfo> q(iHeader); |
|
1420 |
CNotifyInfo* info; |
|
1421 |
while((info=q++)!=NULL) |
|
1422 |
{ |
|
1423 |
__ASSERT_DEBUG(info->Type()==CNotifyInfo::EDiskSpace,Fault(EDiskSpaceQueType2)); |
|
1424 |
||
1425 |
TInt64 newSessionFreeSpace(aFreeDiskSpace); |
|
1426 |
TInt64 oldSessionFreeSpace(iFreeDiskSpace); |
|
1427 |
if(!info->Session()->ReservedAccess(iDriveNumber)) |
|
1428 |
{ |
|
1429 |
newSessionFreeSpace -= reservedSpace; |
|
1430 |
oldSessionFreeSpace -= iReservedDiskSpace; |
|
1431 |
} |
|
1432 |
||
1433 |
if(((CDiskSpaceInfo*)info)->IsMatching(oldSessionFreeSpace,newSessionFreeSpace)) |
|
1434 |
{ |
|
1435 |
__PRINT1(_L("TDiskSpaceQue::CheckDiskSpace()-Matching info=0x%x"),info); |
|
1436 |
info->Complete(KErrNone); |
|
1437 |
delete(info); |
|
1438 |
} |
|
1439 |
} |
|
1440 |
iFreeDiskSpace=aFreeDiskSpace; |
|
1441 |
iReservedDiskSpace=reservedSpace; |
|
1442 |
iQLock.Signal(); |
|
1443 |
} |
|
1444 |
||
1445 |
TInt TDiskSpaceQue::GetFreeDiskSpace(TInt64& aFreeDiskSpace) |
|
1446 |
// |
|
1447 |
// |
|
1448 |
// |
|
1449 |
{ |
|
1450 |
__ASSERT_DEBUG(iDriveNumber>=EDriveA&&iDriveNumber<=EDriveZ,Fault(EDiskSpaceQueDrive)); |
|
1451 |
__CHECK_DRIVETHREAD(iDriveNumber); |
|
1452 |
TInt r=TheDrives[iDriveNumber].FreeDiskSpace(aFreeDiskSpace); |
|
1453 |
return(r); |
|
1454 |
} |
|
1455 |
||
1456 |
TInt TDebugQue::AddNotify(CNotifyInfo* aInfo) |
|
1457 |
// |
|
1458 |
// |
|
1459 |
// |
|
1460 |
{ |
|
1461 |
iQLock.Wait(); |
|
1462 |
TBaseQue::DoAddNotify(aInfo); |
|
1463 |
iQLock.Signal(); |
|
1464 |
return(KErrNone); |
|
1465 |
} |
|
1466 |
||
1467 |
TInt TDebugQue::CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus) |
|
1468 |
// |
|
1469 |
// |
|
1470 |
// |
|
1471 |
{ |
|
1472 |
iQLock.Wait(); |
|
1473 |
TBool isFound=TBaseQue::DoCancelSession(aSession,aCompletionCode,aStatus); |
|
1474 |
iQLock.Signal(); |
|
1475 |
return(isFound); |
|
1476 |
} |
|
1477 |
||
1478 |
void TDebugQue::CancelAll(TInt aCompletionCode) |
|
1479 |
// |
|
1480 |
// |
|
1481 |
// |
|
1482 |
{ |
|
1483 |
iQLock.Wait(); |
|
1484 |
TBaseQue::DoCancelAll(aCompletionCode); |
|
1485 |
iQLock.Signal(); |
|
1486 |
} |
|
1487 |
||
1488 |
void TDebugQue::CheckDebug(TUint aDebugChange) |
|
1489 |
// |
|
1490 |
// Complete any debug notification whose debug type matches aDebugChange |
|
1491 |
// |
|
1492 |
{ |
|
1493 |
iQLock.Wait(); |
|
1494 |
TDblQueIter<CNotifyInfo> q(iHeader); |
|
1495 |
CNotifyInfo* info; |
|
1496 |
while((info=q++)!=NULL) |
|
1497 |
{ |
|
1498 |
__ASSERT_DEBUG(info->Type()==CNotifyInfo::EDebugChange,Fault(EDebugQueType)); |
|
1499 |
if(((CDebugChangeInfo*)info)->IsMatching(aDebugChange)) |
|
1500 |
{ |
|
1501 |
__PRINT1(_L("TDebugQue::CheckDebug()-Matching info=0x%x"),info); |
|
1502 |
info->Complete(KErrNone); |
|
1503 |
delete(info); |
|
1504 |
} |
|
1505 |
} |
|
1506 |
iQLock.Signal(); |
|
1507 |
} |
|
1508 |
||
1509 |
TInt TDismountNotifyQue::AddNotify(CNotifyInfo* aInfo) |
|
1510 |
// |
|
1511 |
// |
|
1512 |
// |
|
1513 |
{ |
|
1514 |
iQLock.Wait(); |
|
1515 |
TBaseQue::DoAddNotify(aInfo); |
|
1516 |
iQLock.Signal(); |
|
1517 |
return(KErrNone); |
|
1518 |
} |
|
1519 |
||
286 | 1520 |
void TDismountNotifyQue::CancelSession(CSessionFs* aSession,TInt aCompletionCode,TRequestStatus* aStatus) |
0 | 1521 |
// |
1522 |
// |
|
1523 |
{ |
|
1524 |
iQLock.Wait(); |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1525 |
|
286 | 1526 |
TDblQueIter<CDismountNotifyInfo> q(iHeader); |
1527 |
CDismountNotifyInfo* info; |
|
1528 |
while((info=q++)!=NULL) |
|
1529 |
{ |
|
1530 |
if(info->Session()==aSession && (!aStatus || aStatus==info->Status())) |
|
1531 |
{ |
|
1532 |
TInt driveNumber = info->DriveNumber(); |
|
1533 |
||
1534 |
info->Complete(aCompletionCode); |
|
1535 |
TInt mode = info->Mode(); |
|
1536 |
||
1537 |
delete info; |
|
1538 |
info = NULL; |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1539 |
|
286 | 1540 |
// if we're cancelling a dismount request (EFsDismountNotifyClients or EFsDismountForceDismount), |
1541 |
// then we need to cancel the deferred dismount and issue a disk change notification as observers |
|
1542 |
// may be expecting one... |
|
1543 |
if (mode == EFsDismountNotifyClients || mode == EFsDismountForceDismount) |
|
1544 |
{ |
|
1545 |
TheDrives[driveNumber].SetDismountDeferred(EFalse); |
|
1546 |
FsNotify::DiskChange(driveNumber); |
|
1547 |
} |
|
1548 |
||
1549 |
if(aStatus) |
|
1550 |
break; |
|
1551 |
} |
|
1552 |
} |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1553 |
|
0 | 1554 |
iQLock.Signal(); |
1555 |
} |
|
1556 |
||
1557 |
void TDismountNotifyQue::CancelAll(TInt aCompletionCode) |
|
1558 |
// |
|
1559 |
// |
|
1560 |
// |
|
1561 |
{ |
|
1562 |
iQLock.Wait(); |
|
1563 |
TBaseQue::DoCancelAll(aCompletionCode); |
|
1564 |
iQLock.Signal(); |
|
1565 |
} |
|
1566 |
||
1567 |
void TDismountNotifyQue::CheckDismount(TNotifyDismountMode aMode, TInt aDrive, TBool aRemove, TInt aError) |
|
1568 |
// |
|
1569 |
// Complete any dismount notifications on the specified drive. |
|
1570 |
// |
|
1571 |
{ |
|
1572 |
iQLock.Wait(); |
|
1573 |
TDblQueIter<CNotifyInfo> q(iHeader); |
|
1574 |
CNotifyInfo* info; |
|
1575 |
while((info=q++)!=NULL) |
|
1576 |
{ |
|
1577 |
__ASSERT_DEBUG(info->Type()==CNotifyInfo::EDismount,Fault(EBadDismountNotifyType)); |
|
1578 |
if(((CDismountNotifyInfo*)info)->IsMatching(aMode, aDrive, NULL)) |
|
1579 |
{ |
|
1580 |
__PRINT1(_L("TDismountNotifyQue::CheckDismount()-Matching info=0x%x"),info); |
|
1581 |
info->Complete(aError); |
|
1582 |
if(aRemove) |
|
286 | 1583 |
delete info; |
0 | 1584 |
} |
1585 |
} |
|
1586 |
||
286 | 1587 |
__ASSERT_ALWAYS(!(aRemove && aMode == EFsDismountRegisterClient && TheDrives[aDrive].DismountLocked() > 0), Fault(EDismountLocked)); |
0 | 1588 |
|
1589 |
iQLock.Signal(); |
|
1590 |
} |
|
1591 |
||
1592 |
TBool TDismountNotifyQue::HandlePendingDismount(CSessionFs* aSession, TInt aDrive) |
|
1593 |
// |
|
286 | 1594 |
// Determine if the session has any outstanding *completed* dismount notifications on the specified drive |
1595 |
// and delete them. Called from TFsAllowDismount::DoRequestL() |
|
0 | 1596 |
// |
1597 |
{ |
|
1598 |
iQLock.Wait(); |
|
286 | 1599 |
TDblQueIter<CDismountNotifyInfo> q(iHeader); |
1600 |
CDismountNotifyInfo* info; |
|
1601 |
||
1602 |
TBool entryFound = EFalse; |
|
1603 |
||
0 | 1604 |
while((info=q++)!=NULL) |
1605 |
{ |
|
1606 |
__ASSERT_DEBUG(info->Type()==CNotifyInfo::EDismount,Fault(EBadDismountNotifyType)); |
|
1607 |
if(((CDismountNotifyInfo*)info)->IsMatching(EFsDismountRegisterClient, aDrive, aSession)) |
|
1608 |
{ |
|
286 | 1609 |
__PRINT1(_L("TDismountNotifyQue::HandlePendingDismount()-Pending info=0x%x"),info); |
1610 |
||
1611 |
if (info->Completed()) |
|
1612 |
delete info; |
|
1613 |
||
1614 |
entryFound = ETrue; |
|
0 | 1615 |
} |
1616 |
} |
|
1617 |
iQLock.Signal(); |
|
286 | 1618 |
|
1619 |
return entryFound; |
|
0 | 1620 |
} |
1621 |
||
1622 |
void FsNotify::Initialise() |
|
1623 |
// |
|
1624 |
// |
|
1625 |
// |
|
1626 |
{ |
|
1627 |
for(TInt i=0;i<KMaxDiskQues;++i) |
|
1628 |
{ |
|
1629 |
iDiskSpaceQues[i].SetDriveNumber(i); |
|
1630 |
} |
|
1631 |
} |
|
1632 |
||
1633 |
TBool FsNotify::IsChangeQueEmpty(TInt aDrive) |
|
1634 |
// |
|
1635 |
// |
|
1636 |
// |
|
1637 |
{ |
|
1638 |
if((iChangeQues[ChangeIndex(aDrive)].IsEmpty()) && (iChangeQues[ChangeIndex(KDriveInvalid)].IsEmpty())) |
|
1639 |
return ETrue; |
|
1640 |
||
1641 |
return EFalse; |
|
1642 |
} |
|
1643 |
||
1644 |
TInt FsNotify::AddChange(CNotifyInfo* aInfo,TInt aDrive) |
|
1645 |
// |
|
1646 |
// |
|
1647 |
// |
|
1648 |
{ |
|
1649 |
__ASSERT_DEBUG(aInfo->Type()==CNotifyInfo::EStdChange||aInfo->Type()==CNotifyInfo::EExtChange,Fault(EBadChangeNotifyType)); |
|
1650 |
__PRINT2(_L("FsNotify::AddChange() drive=%d,info=0x%x"),aDrive,aInfo); |
|
1651 |
iChangeQues[ChangeIndex(aDrive)].AddNotify(aInfo); |
|
1652 |
return(KErrNone); |
|
1653 |
} |
|
1654 |
||
1655 |
TBool FsNotify::IsDiskSpaceQueEmpty(TInt aDrive) |
|
1656 |
// |
|
1657 |
// |
|
1658 |
// |
|
1659 |
{ |
|
1660 |
if(iDiskSpaceQues[aDrive].IsEmpty()) |
|
1661 |
return ETrue; |
|
1662 |
||
1663 |
return EFalse; |
|
1664 |
} |
|
1665 |
||
1666 |
TInt FsNotify::AddDiskSpace(CNotifyInfo* aInfo,TInt aDrive) |
|
1667 |
// |
|
1668 |
// |
|
1669 |
// |
|
1670 |
{ |
|
1671 |
__ASSERT_DEBUG(aInfo->Type()==CNotifyInfo::EDiskSpace,Fault(EBadDiskNotifyType)); |
|
1672 |
__ASSERT_DEBUG((aDrive>=EDriveA && aDrive<=EDriveZ),Fault(EDiskBadIndex1)); |
|
1673 |
__PRINT2(_L("FsNotify::AddDiskSpace() drive=%d,info=0x%x"),aDrive,aInfo); |
|
1674 |
return(iDiskSpaceQues[aDrive].AddNotify(aInfo)); |
|
1675 |
} |
|
1676 |
||
1677 |
TInt FsNotify::AddDebug(CNotifyInfo* aDebugInfo) |
|
1678 |
// |
|
1679 |
// |
|
1680 |
// |
|
1681 |
{ |
|
1682 |
__ASSERT_DEBUG(aDebugInfo->Type()==CNotifyInfo::EDebugChange,Fault(EBadDebugNotifyType)); |
|
1683 |
__PRINT1(_L("FsNotify::AddDebug() info=0x%x"),aDebugInfo); |
|
1684 |
iDebugQue.AddNotify(aDebugInfo); |
|
1685 |
return(KErrNone); |
|
1686 |
} |
|
1687 |
||
1688 |
TInt FsNotify::AddDismountNotify(CNotifyInfo* aDismountNotifyInfo) |
|
1689 |
// |
|
1690 |
// |
|
1691 |
// |
|
1692 |
{ |
|
1693 |
__ASSERT_DEBUG(aDismountNotifyInfo->Type()==CNotifyInfo::EDismount,Fault(EBadDismountNotifyType)); |
|
1694 |
__PRINT1(_L("FsNotify::AddDismountNotify() info=0x%x"),aDismountNotifyInfo); |
|
1695 |
iDismountNotifyQue.AddNotify(aDismountNotifyInfo); |
|
1696 |
return(KErrNone); |
|
1697 |
} |
|
1698 |
||
300 | 1699 |
|
1700 |
void FsNotify::HandleChange(CFsNotificationInfo& aNotificationInfo) |
|
0 | 1701 |
// |
1702 |
// Check whether any change notifications need to be completed due to aRequest on aDrive |
|
1703 |
// |
|
300 | 1704 |
{ |
1705 |
__PRINT1(_L("FsNotify::HandleChange(TFsNotificationInfo) DriveNumber=%d"),aNotificationInfo.DriveNumber()); |
|
1706 |
if(aNotificationInfo.Request() && !aNotificationInfo.Request()->IsChangeNotify()) |
|
1707 |
return; |
|
1708 |
iChangeQues[ChangeIndex(aNotificationInfo.DriveNumber())].CheckChange(aNotificationInfo); |
|
1709 |
iChangeQues[ChangeIndex(KDriveInvalid)].CheckChange(aNotificationInfo); |
|
1710 |
} |
|
0 | 1711 |
|
1712 |
||
1713 |
void FsNotify::HandleDiskSpace(CFsRequest* aRequest,TInt aDrive) |
|
1714 |
// |
|
1715 |
// Check whether any disk space notifications need to be completed due to aRequest on aDrive |
|
1716 |
// |
|
1717 |
{ |
|
1718 |
__ASSERT_DEBUG((aDrive>=EDriveA && aDrive<=EDriveZ) || aDrive==KDriveInvalid,Fault(EDiskBadIndex2)); |
|
1719 |
__PRINT2(_L("FsNotify::HandleDiskSpace() aRequest=0x%x, aDrive=%d"),aRequest,aDrive); |
|
1720 |
||
1721 |
if(!aRequest->Operation()->IsDiskSpaceNotify()) |
|
1722 |
return; |
|
1723 |
TInt f = aRequest->Operation()->Function(); |
|
1724 |
if ((f == EFsFileWrite || f == EFsFileWriteDirty) && !((CFsClientMessageRequest*)aRequest)->IsFreeChanged()) |
|
1725 |
return; |
|
1726 |
if (FsThreadManager::IsDriveThread(aDrive,EFalse)) |
|
1727 |
iDiskSpaceQues[aDrive].CheckDiskSpace(); |
|
1728 |
} |
|
1729 |
||
1730 |
void FsNotify::HandleDiskSpace(TInt aDrive, TInt64& aFreeSpace) |
|
1731 |
// |
|
1732 |
// |
|
1733 |
// |
|
1734 |
{ |
|
1735 |
__ASSERT_DEBUG((aDrive>=EDriveA && aDrive<=EDriveZ),Fault(EDiskBadIndex3)); |
|
1736 |
__PRINT1(_L("FsNotify::HandleDiskSpace() aDrive=%d"),aDrive); |
|
1737 |
iDiskSpaceQues[aDrive].CheckDiskSpace(aFreeSpace); |
|
1738 |
} |
|
1739 |
||
1740 |
void FsNotify::HandleDebug(TUint aFunction) |
|
1741 |
// |
|
1742 |
// Check whether any debug notifications need to be completed due to aFunction |
|
1743 |
// |
|
1744 |
{ |
|
1745 |
__PRINT1(_L("FsNotify::HandleDebug() aFunction=0x%x"),aFunction); |
|
1746 |
if(!(aFunction&KDebugNotifyMask)) |
|
1747 |
return; |
|
1748 |
iDebugQue.CheckDebug(aFunction); |
|
1749 |
} |
|
1750 |
||
1751 |
void FsNotify::HandleDismount(TNotifyDismountMode aMode, TInt aDrive, TBool aRemove, TInt err) |
|
1752 |
// |
|
1753 |
// Handle dismount notifications for the given drive |
|
1754 |
// |
|
1755 |
{ |
|
1756 |
__PRINT4(_L("FsNotify::HandleDismount() aMode = %d, aDrive=%d, aRemove=%d, err=%d"),aMode,aDrive,aRemove,err); |
|
1757 |
iDismountNotifyQue.CheckDismount(aMode, aDrive, aRemove, err); |
|
1758 |
} |
|
1759 |
||
1760 |
TBool FsNotify::HandlePendingDismount(CSessionFs* aSession, TInt aDrive) |
|
1761 |
// |
|
1762 |
// Checks if the session has an outstanding notification registered on the drive |
|
1763 |
// |
|
1764 |
{ |
|
1765 |
__PRINT1(_L("FsNotify::HandlePendingDismount() aDrive=%d"),aDrive); |
|
1766 |
return iDismountNotifyQue.HandlePendingDismount(aSession, aDrive); |
|
1767 |
} |
|
1768 |
||
1769 |
void FsNotify::DiskChange(TInt aDrive) |
|
1770 |
// |
|
1771 |
// Complete all notifications in queus due to a disk change |
|
1772 |
// |
|
1773 |
{ |
|
1774 |
__ASSERT_DEBUG((aDrive>=EDriveA && aDrive<=EDriveZ),Fault(EDiskChangeDrive)); |
|
1775 |
__PRINT1(_L("FsNotify::DiskChange() aDrive=%d"),aDrive); |
|
1776 |
iChangeQues[ChangeIndex(aDrive)].CancelAll(KErrNone); |
|
1777 |
iChangeQues[ChangeIndex(KDriveInvalid)].CancelAll(KErrNone); |
|
1778 |
iDiskSpaceQues[aDrive].CancelAll(KErrNone); |
|
1779 |
iDebugQue.CancelAll(KErrNone); |
|
1780 |
||
1781 |
// if there are any files containing dirty data, start issuing write-dirty data requests to trigger |
|
1782 |
// a critical notifier (CFileCache::HandleWriteDirtyError()) |
|
1783 |
// otherwise purge all file caches |
|
1784 |
TDrive& drive=TheDrives[aDrive]; |
|
1785 |
drive.FlushCachedFileInfo(ETrue); |
|
1786 |
} |
|
1787 |
||
1788 |
||
1789 |
void FsNotify::CancelChangeSession(CSessionFs* aSession,TRequestStatus* aStatus) |
|
1790 |
// |
|
1791 |
// Cancel change notifcation(s) setup by aSession and matching aStatus if not NULL |
|
1792 |
// |
|
1793 |
{ |
|
1794 |
__PRINT2(_L("FsNotify::CancelChangeSession() aSession=0x%x aStatus=0x%x"),aSession,aStatus); |
|
1795 |
for(TInt i=0;i<KMaxNotifyQues;++i) |
|
1796 |
{ |
|
1797 |
TBool isFound=iChangeQues[i].CancelSession(aSession,KErrCancel,aStatus); |
|
1798 |
if(aStatus && isFound) |
|
1799 |
break; |
|
1800 |
} |
|
1801 |
} |
|
1802 |
||
1803 |
void FsNotify::CancelDiskSpaceSession(CSessionFs* aSession,TRequestStatus* aStatus) |
|
1804 |
// |
|
1805 |
// Cancel disk space notification(s) setup by aSession and matching aStatus if not NULL |
|
1806 |
// |
|
1807 |
||
1808 |
{ |
|
1809 |
__PRINT2(_L("FsNotify::CancelDiskSpaceSession() aSession=0x%x aStatus=0x%x"),aSession,aStatus); |
|
1810 |
for(TInt i=0;i<KMaxDiskQues;++i) |
|
1811 |
{ |
|
1812 |
TBool isFound=iDiskSpaceQues[i].CancelSession(aSession,KErrCancel,aStatus); |
|
1813 |
if(aStatus && isFound) |
|
1814 |
break; |
|
1815 |
} |
|
1816 |
} |
|
1817 |
||
1818 |
void FsNotify::CancelDebugSession(CSessionFs* aSession, TRequestStatus* aStatus) |
|
1819 |
// |
|
1820 |
// Cancel debug notification(s) setup by aSession and matching aStatus if not NULL |
|
1821 |
// |
|
1822 |
{ |
|
1823 |
__PRINT2(_L("FsNotify::CancelDebugSession() aSession=0x%x aStatus=0x%x"),aSession,aStatus); |
|
1824 |
iDebugQue.CancelSession(aSession,KErrCancel,aStatus); |
|
1825 |
} |
|
1826 |
||
286 | 1827 |
void FsNotify::CancelDismountNotifySession(CSessionFs* aSession, TRequestStatus* aStatus) |
0 | 1828 |
// |
1829 |
// Cancel all media removal notification(s) setup by aSession (if aStatus == NULL) |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1830 |
// else cancels all outstanding notifications(s) for the session |
0 | 1831 |
// |
1832 |
{ |
|
1833 |
__PRINT2(_L("FsNotify::CancelDismountNotifySession() aSession=0x%x aStatus=0x%x"),aSession,aStatus); |
|
286 | 1834 |
iDismountNotifyQue.CancelSession(aSession,KErrCancel,aStatus); |
0 | 1835 |
} |
1836 |
||
1837 |
void FsNotify::CancelSession(CSessionFs* aSession) |
|
1838 |
// |
|
1839 |
// |
|
1840 |
// |
|
1841 |
{ |
|
1842 |
__PRINT(_L("FsNotify::CancelSession")); |
|
1843 |
FsNotify::CancelChangeSession(aSession); |
|
1844 |
FsNotify::CancelDiskSpaceSession(aSession); |
|
1845 |
FsNotify::CancelDebugSession(aSession); |
|
1846 |
FsNotify::CancelDismountNotifySession(aSession); |
|
1847 |
} |
|
1848 |
||
1849 |
||
1850 |
TInt FsNotify::ChangeIndex(TInt aDrive) |
|
1851 |
// |
|
1852 |
// |
|
1853 |
// |
|
1854 |
{ |
|
1855 |
__ASSERT_DEBUG((aDrive>=EDriveA && aDrive<=EDriveZ) || aDrive==KDriveInvalid,Fault(EChangeBadIndex)); |
|
1856 |
if(aDrive==KDriveInvalid) |
|
1857 |
return(0); |
|
1858 |
else |
|
1859 |
return(aDrive+1); |
|
1860 |
} |
|
1861 |