author | hgs |
Mon, 01 Nov 2010 20:11:36 +0000 | |
changeset 299 | b5a01337d018 |
parent 31 | 56f325a607ea |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2008-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_notifier_handlers.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
#include "sf_std.h" |
|
18 |
#include "sf_notifier.h" |
|
19 |
||
20 |
#ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
21 |
||
22 |
TInt TFsNotificationOpen::Initialise(CFsRequest* /*aRequest*/) |
|
23 |
{ |
|
24 |
return KErrNone; |
|
25 |
} |
|
26 |
||
27 |
TInt TFsNotificationOpen::DoRequestL(CFsRequest* aRequest) |
|
28 |
{ |
|
29 |
__PRINT(_L("TFsNotificationOpen::DoRequestL()")); |
|
30 |
//Check whether we've got a notification manager |
|
31 |
//If not, create it and call OpenL |
|
32 |
if(!FsNotificationManager::IsInitialised()) |
|
33 |
{ |
|
34 |
FsNotificationManager::OpenL(); |
|
35 |
} |
|
36 |
||
37 |
//Create a new CFsNotifyRequest and add it to the manager |
|
38 |
CFsNotifyRequest* notifyRequest = CFsNotifyRequest::NewL(); |
|
39 |
||
40 |
//Get handle and add request to manager and Session->Handles |
|
41 |
TInt handle = 0; |
|
42 |
TBool addedToManager = EFalse; |
|
43 |
TRAPD(ret,HandleRequestL(aRequest, notifyRequest, handle,addedToManager)); |
|
44 |
if (ret!=KErrNone) |
|
45 |
{ |
|
46 |
//Remove request from Session->Handles if it was already added |
|
47 |
if (handle!=0) |
|
48 |
aRequest->Session()->Handles().Remove(handle,ETrue); |
|
49 |
||
50 |
//Remove request from manager |
|
51 |
if(addedToManager) |
|
52 |
{ |
|
53 |
FsNotificationManager::Lock(); |
|
54 |
FsNotificationManager::RemoveNotificationRequest(notifyRequest); |
|
55 |
FsNotificationManager::Unlock(); |
|
56 |
} |
|
57 |
delete notifyRequest; |
|
58 |
return(ret); |
|
59 |
} |
|
60 |
||
61 |
notifyRequest->iSession = aRequest->Session(); |
|
62 |
aRequest->Session()->IncResourceCount(); |
|
63 |
return ret; |
|
64 |
} |
|
65 |
||
66 |
//Get handle and add request to Session->Handles |
|
67 |
void TFsNotificationOpen::HandleRequestL(CFsRequest* aRequest, CFsNotifyRequest* aNotifyRequest, TInt& aHandle,TBool& aAddedToManager) |
|
68 |
{ |
|
69 |
aAddedToManager = EFalse; |
|
70 |
FsNotificationManager::AddNotificationRequestL(aNotifyRequest); |
|
71 |
aAddedToManager = ETrue; |
|
72 |
aHandle = aRequest->Session()->Handles().AddL(aNotifyRequest,ETrue); |
|
73 |
TPtrC8 pH((TUint8*)&aHandle, sizeof(TInt)); |
|
74 |
aRequest->WriteL(KMsgPtr3,pH); |
|
75 |
} |
|
76 |
||
77 |
TInt TFsNotificationBuffer::Initialise(CFsRequest* /*aRequest*/) |
|
78 |
{ |
|
79 |
return KErrNone; |
|
80 |
} |
|
81 |
||
82 |
TInt TFsNotificationBuffer::DoRequestL(CFsRequest* aRequest) |
|
83 |
{ |
|
84 |
__PRINT(_L("TFsNotificationBuffer::DoRequestL()")); |
|
85 |
HBufC8* buffer = (HBufC8*)(aRequest->Message().Ptr0()); |
|
86 |
TInt handle = aRequest->Message().Int3(); |
|
87 |
CFsNotifyRequest* notifyRequest = (CFsNotifyRequest*)SessionObjectFromHandle(handle,0,aRequest->Session()); |
|
88 |
if(!notifyRequest) |
|
89 |
return KErrBadHandle; |
|
90 |
if(!buffer) |
|
91 |
return KErrArgument; |
|
92 |
||
93 |
notifyRequest->iClientBufferSize = aRequest->Message().Int1(); |
|
94 |
notifyRequest->iBufferMsg = aRequest->Message(); |
|
95 |
return KErrNone; |
|
96 |
} |
|
97 |
||
98 |
TInt TFsNotificationRequest::Initialise(CFsRequest* aRequest) |
|
99 |
{ |
|
100 |
TInt handle = aRequest->Message().Int3(); |
|
101 |
CFsNotifyRequest* notifyRequest = (CFsNotifyRequest*)SessionObjectFromHandle(handle,0,aRequest->Session()); |
|
102 |
if(!notifyRequest) |
|
103 |
return KErrBadHandle; |
|
104 |
||
105 |
//Check the tail's validity |
|
106 |
TInt tail; |
|
107 |
TPckg<TInt> tailPkg(tail); |
|
108 |
TInt r = aRequest->Read(KMsgPtr0,tailPkg); |
|
109 |
||
110 |
if(r!=KErrNone || tail < 0 || tail > notifyRequest->iClientBufferSize) |
|
111 |
return KErrArgument; |
|
112 |
||
113 |
return KErrNone; |
|
114 |
} |
|
115 |
||
116 |
TInt TFsNotificationRequest::DoRequestL(CFsRequest* aRequest) |
|
117 |
{ |
|
118 |
__PRINT(_L("TFsNotificationRequest::DoRequestL()")); |
|
119 |
//We need to check whether there is anything in the buffer |
|
120 |
//If so we should complete straight away. |
|
121 |
FsNotificationManager::Lock(); |
|
122 |
||
123 |
//Get notification request |
|
124 |
TInt handle = aRequest->Message().Int3(); |
|
125 |
CFsNotifyRequest* notifyRequest = (CFsNotifyRequest*)SessionObjectFromHandle(handle,0,aRequest->Session()); |
|
126 |
if(!notifyRequest) |
|
127 |
{ |
|
128 |
FsNotificationManager::Unlock(); |
|
129 |
return KErrBadHandle; |
|
130 |
} |
|
131 |
||
132 |
TInt r = notifyRequest->SetClientMessage(aRequest->Message()); |
|
133 |
if(r != KErrNone) |
|
134 |
{ |
|
135 |
FsNotificationManager::Unlock(); |
|
136 |
return r; |
|
137 |
} |
|
138 |
||
139 |
CFsNotifyRequest::TNotifyRequestStatus status = notifyRequest->ActiveStatus(); |
|
140 |
if(status==CFsNotifyRequest::EOutstanding || |
|
141 |
status==CFsNotifyRequest::EOutstandingOverflow) |
|
142 |
{ |
|
143 |
notifyRequest->CompleteClientRequest(KErrNone); |
|
144 |
} |
|
145 |
||
146 |
//Update Status |
|
147 |
if(status!=CFsNotifyRequest::EOutstandingOverflow) |
|
148 |
{ |
|
149 |
notifyRequest->SetActive(CFsNotifyRequest::EActive); |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
150 |
// RDebug::Print(_L("TFsNotificationRequest::DoRequestL Not-OutOver- iClientHead==%d, iClientTail==%d"),notifyRequest->iClientHead,notifyRequest->iClientTail); |
0 | 151 |
} |
152 |
else |
|
153 |
{ |
|
154 |
notifyRequest->SetActive(CFsNotifyRequest::EInactive); |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
155 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
156 |
// RDebug::Print(_L("TFsNotificationRequest::DoRequestL OutOver- iClientHead==%d, iClientTail==%d"),notifyRequest->iClientHead,notifyRequest->iClientTail); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
157 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
158 |
// If the user is in OutstandingOverflow notification state, |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
159 |
// then we can set iClientHead to be equal to iServerTail now. |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
160 |
// That way if the client requests again and the state will go |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
161 |
// back to active, the server will see that buffer as empty |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
// rather than full/overflow. |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
notifyRequest->iClientHead = notifyRequest->iClientTail; |
0 | 165 |
} |
166 |
FsNotificationManager::Unlock(); |
|
167 |
return r; |
|
168 |
} |
|
169 |
||
170 |
TInt TFsNotificationCancel::Initialise(CFsRequest* /*aRequest*/) |
|
171 |
{ |
|
172 |
return KErrNone; |
|
173 |
} |
|
174 |
||
175 |
TInt TFsNotificationCancel::DoRequestL(CFsRequest* aRequest) |
|
176 |
{ |
|
177 |
__PRINT(_L("TFsNotificationCancel::DoRequestL()")); |
|
178 |
FsNotificationManager::Lock(); |
|
179 |
||
180 |
//Get notification request and deactivate filter |
|
181 |
TInt handle = aRequest->Message().Int3(); |
|
182 |
CFsNotifyRequest* notifyRequest = (CFsNotifyRequest*)SessionObjectFromHandle(handle,0,aRequest->Session()); |
|
183 |
if(!notifyRequest) |
|
184 |
{ |
|
185 |
FsNotificationManager::Unlock(); |
|
186 |
return KErrBadHandle; |
|
187 |
} |
|
188 |
||
189 |
if(notifyRequest->ClientMsgHandle()!=0) |
|
190 |
{ |
|
191 |
notifyRequest->SetActive(CFsNotifyRequest::EInactive); |
|
192 |
notifyRequest->CompleteClientRequest(KErrCancel,ETrue); |
|
193 |
} |
|
194 |
FsNotificationManager::Unlock(); |
|
195 |
return KErrNone; |
|
196 |
} |
|
197 |
||
198 |
TInt TFsNotificationSubClose::Initialise(CFsRequest* /*aRequest*/) |
|
199 |
{ |
|
200 |
return KErrNone; |
|
201 |
} |
|
202 |
||
203 |
TInt TFsNotificationSubClose::DoRequestL(CFsRequest* aRequest) |
|
204 |
{ |
|
205 |
__PRINT(_L("TFsNotificationSubClose::DoRequestL()")); |
|
206 |
FsNotificationManager::Lock(); |
|
207 |
||
208 |
//We need to complete the buffer request here as this type of request is not |
|
209 |
//completed in the normal way as it is kept open in order that we can access the buffer |
|
210 |
//in the client-side for the lifetime of this subsession. |
|
211 |
TInt handle = aRequest->Message().Int3(); |
|
212 |
CFsNotifyRequest* notifyRequest = (CFsNotifyRequest*) SessionObjectFromHandle(handle,0,aRequest->Session()); |
|
213 |
if(!notifyRequest) |
|
214 |
{ |
|
215 |
FsNotificationManager::Unlock(); |
|
216 |
return KErrBadHandle; |
|
217 |
} |
|
218 |
||
219 |
notifyRequest->RemoveFilters(); |
|
220 |
notifyRequest->CloseNotification(); //Completes the buffer and the client requests. |
|
221 |
||
222 |
TInt count = FsNotificationManager::Count(); |
|
223 |
||
224 |
//Also deletes notifyRequest |
|
225 |
aRequest->Session()->Handles().Remove(handle,ETrue); |
|
226 |
if(count==1) |
|
227 |
{ |
|
228 |
//If this is the last request then we need to remove the manager |
|
229 |
FsNotificationManager::Close(); |
|
230 |
} |
|
231 |
||
232 |
FsNotificationManager::Unlock(); |
|
233 |
aRequest->Session()->DecResourceCount(); |
|
234 |
notifyRequest = NULL; |
|
235 |
||
236 |
return(KErrNone); |
|
237 |
} |
|
238 |
||
239 |
TInt TFsNotificationAdd::Initialise(CFsRequest* aRequest) |
|
240 |
{ |
|
241 |
__PRINT(_L("TFsNotificationAdd::Initialise()")); |
|
242 |
TUint filter = (TUint) aRequest->Message().Int0(); |
|
243 |
//If it's AllOps then it's ok |
|
244 |
if (filter!=TFsNotification::EAllOps) |
|
245 |
{ |
|
246 |
||
247 |
TInt invalid = filter & ~KNotificationValidFiltersMask; |
|
248 |
//Check: Non-valid values ARE NOT set |
|
249 |
// and valid values ARE set. |
|
250 |
if(invalid || !filter) |
|
251 |
{ |
|
252 |
return KErrArgument; |
|
253 |
} |
|
254 |
} |
|
255 |
||
256 |
TFileName path; |
|
257 |
TInt r = aRequest->Read(KMsgPtr1,path); |
|
258 |
if(r != KErrNone) |
|
259 |
{ |
|
260 |
return r; |
|
261 |
} |
|
262 |
||
263 |
if(path.Length() >= 2) |
|
299 | 264 |
r=PathCheck(aRequest->Message(),path.Mid(2),&KCapFsSysFileTemp,&KCapFsPriFileTemp,&KCapFsROFileTemp, __PLATSEC_DIAGNOSTIC_STRING("Notification Add Filter")); |
0 | 265 |
return r; |
266 |
} |
|
267 |
||
268 |
TInt TFsNotificationAdd::DoRequestL(CFsRequest* aRequest) |
|
269 |
{ |
|
270 |
__PRINT(_L("TFsNotificationAdd::DoRequestL()")); |
|
271 |
TInt handle = aRequest->Message().Int3(); |
|
272 |
CFsNotifyRequest* notifyRequest = (CFsNotifyRequest*) SessionObjectFromHandle(handle,0,aRequest->Session()); |
|
273 |
if(!notifyRequest) |
|
274 |
return KErrBadHandle; |
|
275 |
||
276 |
TFileName path; |
|
277 |
aRequest->Read(KMsgPtr1,path); |
|
278 |
||
279 |
TFileName filename; |
|
280 |
TInt r = aRequest->Read(KMsgPtr2,filename); |
|
281 |
if(r!= KErrNone) |
|
282 |
return r; |
|
283 |
||
284 |
__PRINT2(_L("TFsNotificationAdd::AddNotification() path=%S, filename=%S"),&path,&filename); |
|
285 |
||
286 |
//If this is a path starting with 'drive-letter:' |
|
299 | 287 |
TInt driveNum = CFsNotificationInfo::DriveNumber(path); |
288 |
if(path.Length() >= 2) |
|
289 |
{ |
|
290 |
if(path[1] != (TText)':') |
|
291 |
{ |
|
292 |
if(path[0]!=(TText)'*') |
|
293 |
{ |
|
294 |
return KErrPathNotFound; |
|
295 |
} |
|
296 |
} |
|
297 |
else // 2nd char is ':' |
|
298 |
{ |
|
299 |
if(driveNum < EDriveA || driveNum > EDriveZ) |
|
300 |
{ |
|
301 |
if(path[0]!=(TText)'?') |
|
302 |
return KErrPathNotFound; |
|
303 |
} |
|
304 |
} |
|
305 |
} |
|
0 | 306 |
|
307 |
CleanupStack::PushL(notifyRequest); |
|
299 | 308 |
TPtrC pathPtr(path); |
309 |
if(driveNum!=KErrNotFound || ((path.Length() >=1) && path[0]=='?')) |
|
310 |
//Remove the drive: part of the the path if it's got one. |
|
311 |
pathPtr.Set(path.Mid(2)); |
|
312 |
CFsNotificationPathFilter* filter = CFsNotificationPathFilter::NewL(pathPtr,filename,driveNum); |
|
0 | 313 |
|
314 |
//Bitmask of filter types |
|
315 |
TUint filterMask = (TUint) aRequest->Message().Int0(); |
|
316 |
||
317 |
r = notifyRequest->AddFilterL(filter,filterMask); |
|
318 |
CleanupStack::Pop(notifyRequest); |
|
319 |
||
320 |
if(r == KErrNone) |
|
321 |
{ |
|
322 |
FsNotificationManager::Lock(); |
|
323 |
//Increment global filter register |
|
324 |
FsNotificationManager::SetFilterRegisterMask(filterMask,(TBool)ETrue); |
|
325 |
FsNotificationManager::Unlock(); |
|
326 |
} |
|
327 |
return r; |
|
328 |
} |
|
329 |
||
330 |
TInt TFsNotificationRemove::Initialise(CFsRequest* /*aRequest*/) |
|
331 |
{ |
|
332 |
__PRINT(_L("TFsNotificationRemove::Initialise()")); |
|
333 |
return KErrNone; |
|
334 |
} |
|
335 |
||
336 |
TInt TFsNotificationRemove::DoRequestL(CFsRequest* aRequest) |
|
337 |
{ |
|
338 |
__PRINT(_L("TFsNotificationRemove::DoRequestL()")); |
|
339 |
FsNotificationManager::Lock(); |
|
340 |
||
341 |
TInt handle = aRequest->Message().Int3(); |
|
342 |
CFsNotifyRequest* notifyRequest = (CFsNotifyRequest*) SessionObjectFromHandle(handle,0,aRequest->Session()); |
|
343 |
if(!notifyRequest) |
|
344 |
{ |
|
345 |
FsNotificationManager::Unlock(); |
|
346 |
return KErrBadHandle; |
|
347 |
} |
|
348 |
||
349 |
TInt r = notifyRequest->RemoveFilters(); |
|
350 |
FsNotificationManager::Unlock(); |
|
351 |
return r; |
|
352 |
} |
|
353 |
||
354 |
#else //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
355 |
||
356 |
CFsObjectCon* FsNotificationManager::iNotifyRequests = NULL; |
|
357 |
||
358 |
CFsNotifyRequest::CFsNotifyRequest() |
|
359 |
{ |
|
360 |
} |
|
361 |
||
362 |
CFsNotifyRequest::~CFsNotifyRequest() |
|
363 |
{ |
|
364 |
} |
|
365 |
||
366 |
TInt TFsNotificationOpen::Initialise(CFsRequest* /*aRequest*/) |
|
367 |
{ |
|
368 |
return KErrNotSupported; |
|
369 |
} |
|
370 |
||
371 |
TInt TFsNotificationOpen::DoRequestL(CFsRequest* /*aRequest*/) |
|
372 |
{ |
|
373 |
return KErrNotSupported; |
|
374 |
} |
|
375 |
||
376 |
void TFsNotificationOpen::HandleRequestL(CFsRequest* /*aRequest*/, CFsNotifyRequest* /*aNotifyRequest*/, TInt& /*aHandle*/,TBool& /*aAddedToManager*/) |
|
377 |
{ |
|
378 |
User::Leave(KErrNotSupported); |
|
379 |
} |
|
380 |
||
381 |
TInt TFsNotificationBuffer::Initialise(CFsRequest* /*aRequest*/) |
|
382 |
{ |
|
383 |
return KErrNotSupported; |
|
384 |
} |
|
385 |
||
386 |
TInt TFsNotificationBuffer::DoRequestL(CFsRequest* /*aRequest*/) |
|
387 |
{ |
|
388 |
return KErrNotSupported; |
|
389 |
} |
|
390 |
||
391 |
TInt TFsNotificationRequest::Initialise(CFsRequest* /*aRequest*/) |
|
392 |
{ |
|
393 |
return KErrNotSupported; |
|
394 |
} |
|
395 |
||
396 |
TInt TFsNotificationRequest::DoRequestL(CFsRequest* /*aRequest*/) |
|
397 |
{ |
|
398 |
return KErrNotSupported; |
|
399 |
} |
|
400 |
||
401 |
TInt TFsNotificationCancel::Initialise(CFsRequest* /*aRequest*/) |
|
402 |
{ |
|
403 |
return KErrNotSupported; |
|
404 |
} |
|
405 |
||
406 |
TInt TFsNotificationCancel::DoRequestL(CFsRequest* /*aRequest*/) |
|
407 |
{ |
|
408 |
return KErrNotSupported; |
|
409 |
} |
|
410 |
||
411 |
TInt TFsNotificationSubClose::Initialise(CFsRequest* /*aRequest*/) |
|
412 |
{ |
|
413 |
return KErrNotSupported; |
|
414 |
} |
|
415 |
||
416 |
TInt TFsNotificationSubClose::DoRequestL(CFsRequest* /*aRequest*/) |
|
417 |
{ |
|
418 |
return KErrNotSupported; |
|
419 |
} |
|
420 |
||
421 |
TInt TFsNotificationAdd::Initialise(CFsRequest* /*aRequest*/) |
|
422 |
{ |
|
423 |
return KErrNotSupported; |
|
424 |
} |
|
425 |
||
426 |
TInt TFsNotificationAdd::DoRequestL(CFsRequest* /*aRequest*/) |
|
427 |
{ |
|
428 |
return KErrNotSupported; |
|
429 |
} |
|
430 |
||
431 |
TInt TFsNotificationRemove::Initialise(CFsRequest* /*aRequest*/) |
|
432 |
{ |
|
433 |
return KErrNotSupported; |
|
434 |
} |
|
435 |
||
436 |
TInt TFsNotificationRemove::DoRequestL(CFsRequest* /*aRequest*/) |
|
437 |
{ |
|
438 |
return KErrNotSupported; |
|
439 |
} |
|
440 |
||
441 |
#endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
442 |