|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implementation of CSBESession class. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include "sbeserver.h" |
|
25 #include "sbesession.h" |
|
26 #include "sbeclientserver.h" |
|
27 #include <connect/panic.h> |
|
28 #include "sbedataownermanager.h" |
|
29 #include <connect/sbtypes.h> |
|
30 #include "sblog.h" |
|
31 #include <apgcli.h> |
|
32 |
|
33 namespace conn |
|
34 { |
|
35 |
|
36 /** This block size for the internal buffer |
|
37 @internalTechnology |
|
38 */ |
|
39 const TInt KSBBufferBlockSize = 4096; |
|
40 |
|
41 CSBESession::CSBESession() : iTransferBuf(NULL), iTransferTextBuf(NULL), iArrayCount(0) |
|
42 /** |
|
43 Class Constructor |
|
44 */ |
|
45 { |
|
46 } |
|
47 |
|
48 CSBESession::~CSBESession() |
|
49 /** |
|
50 Class destructor |
|
51 */ |
|
52 { |
|
53 // |
|
54 // If the client has detached properly, they should |
|
55 // have done this - but just in case. |
|
56 Server().DropSession(); |
|
57 ResetTransferBuf(); |
|
58 delete iExtCurEntry; |
|
59 } |
|
60 |
|
61 void CSBESession::CreateL() |
|
62 /** |
|
63 Creates a connection between the Secure Backup Engine server and the Secure |
|
64 Backup Engine session. Increments the server's session count |
|
65 */ |
|
66 { |
|
67 // |
|
68 // Increase the servers session count. |
|
69 Server().AddSession(); |
|
70 } |
|
71 |
|
72 void CSBESession::ServiceL(const RMessage2& aMessage) |
|
73 /** |
|
74 Called by the client server framework to service a message request |
|
75 from a client. |
|
76 |
|
77 @param aMessage Reference to a RMessage2 object |
|
78 */ |
|
79 { |
|
80 #ifdef SBE_LOGGING_ENABLED |
|
81 RThread thread; |
|
82 aMessage.Client(thread); |
|
83 const TFullName threadName( thread.FullName() ); |
|
84 thread.Close(); |
|
85 #endif |
|
86 |
|
87 switch(aMessage.Function()) |
|
88 { |
|
89 // |
|
90 // Connection config getting/setting. |
|
91 case ESBEMsgGetGSHHandle: |
|
92 { |
|
93 __LOG1("CSBESession::ServiceL() - ESBEMsgGetGSHHandle for thread: %S", &threadName); |
|
94 aMessage.Complete(Server().GlobalSharedHeap()); |
|
95 break; |
|
96 } |
|
97 case ESBEMsgPrepDataOwnerInfo: |
|
98 { |
|
99 __LOG1("CSBESession::ServiceL() - ESBEMsgPrepDataOwnerInfo for thread: %S", &threadName); |
|
100 PrepDataOwnerInfoL(aMessage); |
|
101 break; |
|
102 } |
|
103 case ESBEMsgGetDataOwnerInfo: |
|
104 { |
|
105 __LOG1("CSBESession::ServiceL() - ESBEMsgGetDataOwnerInfo for thread: %S", &threadName); |
|
106 ReturnDataOwnerInfoL(aMessage); |
|
107 break; |
|
108 } |
|
109 case ESBEMsgPrepPublicFiles: |
|
110 { |
|
111 __LOG1("CSBESession::ServiceL() - ESBEMsgPrepPublicFiles for thread: %S", &threadName); |
|
112 PrepPublicFileListL(aMessage); |
|
113 break; |
|
114 } |
|
115 case ESBEMsgGetPublicFiles: |
|
116 { |
|
117 __LOG1("CSBESession::ServiceL() - ESBEMsgGetPublicFiles for thread: %S", &threadName); |
|
118 ReturnPublicFileListL(aMessage); |
|
119 break; |
|
120 } |
|
121 case ESBEMsgPrepPublicFilesRaw: |
|
122 { |
|
123 __LOG1("CSBESession::ServiceL() - ESBEMsgPrepPublicFilesRaw for thread: %S", &threadName); |
|
124 PrepPublicFileListRawL(aMessage); |
|
125 break; |
|
126 } |
|
127 case ESBEMsgGetPublicFilesRaw: |
|
128 { |
|
129 __LOG1("CSBESession::ServiceL() - ESBEMsgGetPublicFilesRaw for thread: %S", &threadName); |
|
130 ReturnPublicFileListRawL(aMessage); |
|
131 break; |
|
132 } |
|
133 case ESBEMsgPrepPublicFilesXML: |
|
134 { |
|
135 __LOG1("CSBESession::ServiceL() - ESBEMsgPrepPublicFilesXML for thread: %S", &threadName); |
|
136 PrepPublicFileListXMLL(aMessage); |
|
137 break; |
|
138 } |
|
139 case ESBEMsgGetPublicFilesXML: |
|
140 { |
|
141 __LOG1("CSBESession::ServiceL() - ESBEMsgGetPublicFilesXML for thread: %S", &threadName); |
|
142 ReturnPublicFileListXMLL(aMessage); |
|
143 break; |
|
144 } |
|
145 case ESBEMsgSetBURMode: |
|
146 { |
|
147 __LOG1("CSBESession::ServiceL() - ESBEMsgSetBURMode for thread: %S", &threadName); |
|
148 SetBURModeL(aMessage); |
|
149 break; |
|
150 } |
|
151 case ESBEMsgSetSIDListPartial: |
|
152 { |
|
153 __LOG1("CSBESession::ServiceL() - ESBEMsgSetSIDListPartial for thread: %S", &threadName); |
|
154 SetSIDListForPartialBURL(aMessage); |
|
155 break; |
|
156 } |
|
157 case ESBEMsgPrepSIDStatus: |
|
158 { |
|
159 __LOG1("CSBESession::ServiceL() - ESBEMsgPrepSIDStatus for thread: %S", &threadName); |
|
160 PrepSIDStatusL(aMessage); |
|
161 break; |
|
162 } |
|
163 case ESBEMsgGetSIDStatus: |
|
164 { |
|
165 __LOG1("CSBESession::ServiceL() - ESBEMsgGetSIDStatus for thread: %S", &threadName); |
|
166 ReturnSIDStatusL(aMessage); |
|
167 break; |
|
168 } |
|
169 case ESBEMsgRequestDataSync: |
|
170 case ESBEMsgRequestDataAsync: |
|
171 { |
|
172 __LOG1("CSBESession::ServiceL() - ESBEMsgRequestDataSync / ESBEMsgRequestDataAsync for thread: %S", &threadName); |
|
173 TRAPD(reqDataErr, RequestDataAsyncL(aMessage)); |
|
174 if (reqDataErr != KErrNone) |
|
175 { |
|
176 Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse); |
|
177 User::Leave(reqDataErr); |
|
178 } |
|
179 break; |
|
180 } |
|
181 case ESBEMsgSupplyDataSync: |
|
182 { |
|
183 __LOG1("CSBESession::ServiceL() - ESBEMsgSupplyDataSync for thread: %S", &threadName); |
|
184 TRAPD(supDataErr, SupplyDataSyncL(aMessage)); |
|
185 if (supDataErr != KErrNone) |
|
186 { |
|
187 Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse); |
|
188 User::Leave(supDataErr); |
|
189 } |
|
190 break; |
|
191 } |
|
192 case ESBEMsgAllSnapshotsSupplied: |
|
193 { |
|
194 __LOG1("CSBESession::ServiceL() - ESBEMsgAllSnapshotsSupplied for thread: %S", &threadName); |
|
195 AllSnapshotsSuppliedL(aMessage); |
|
196 break; |
|
197 } |
|
198 case ESBEMsgGetExpectedDataSize: |
|
199 { |
|
200 __LOG1("CSBESession::ServiceL() - ESBEMsgGetExpectedDataSize for thread: %S", &threadName); |
|
201 GetExpectedDataSizeL(aMessage); |
|
202 break; |
|
203 } |
|
204 case ESBEMsgAllSystemFilesRestored: |
|
205 { |
|
206 __LOG1("CSBESession::ServiceL() - ESBEMsgAllSystemFilesRestored for thread: %S", &threadName); |
|
207 AllSystemFilesRestoredL(); |
|
208 aMessage.Complete(KErrNone); |
|
209 break; |
|
210 } |
|
211 case ESBEMsgPrepLargePublicFiles: |
|
212 { |
|
213 __LOG1("CSBESession::ServiceL() - ESBEMsgPrepPublicFiles for thread: %S", &threadName); |
|
214 PrepLargePublicFileListL(aMessage); |
|
215 break; |
|
216 } |
|
217 case ESBEMsgGetLargePublicFiles: |
|
218 { |
|
219 __LOG1("CSBESession::ServiceL() - ESBEMsgGetPublicFiles for thread: %S", &threadName); |
|
220 ReturnLargePublicFileListL(aMessage); |
|
221 break; |
|
222 } |
|
223 default: |
|
224 { |
|
225 __LOG1("CSBESession::ServiceL() - UNKNOWN OP CODE for thread: %S", &threadName); |
|
226 User::Leave(KErrNotSupported); |
|
227 } |
|
228 } |
|
229 |
|
230 __LOG1("CSBESession::ServiceL() - Completed OK for thread: %S", &threadName); |
|
231 } |
|
232 |
|
233 inline CSBEServer& CSBESession::Server() const |
|
234 /** |
|
235 Returns a non-cost reference to this CServer object. |
|
236 |
|
237 @return The non-const reference to this. |
|
238 */ |
|
239 { |
|
240 return *static_cast<CSBEServer*>(const_cast<CServer2*>(CSession2::Server())); |
|
241 } |
|
242 |
|
243 void CSBESession::PrepDataOwnerInfoL(const RMessage2& aMessage) |
|
244 /** |
|
245 Prepares the |
|
246 */ |
|
247 { |
|
248 TInt err = KErrNone; |
|
249 ResetTransferBuf(); |
|
250 RPointerArray<CDataOwnerInfo> doiArray; |
|
251 TRAP(err, |
|
252 { |
|
253 Server().DataOwnerManager().GetDataOwnersL(doiArray); |
|
254 |
|
255 iTransferBuf = HBufC8::NewL(KSBBufferBlockSize); |
|
256 TPtr8 transferBufPtr(iTransferBuf->Des()); |
|
257 |
|
258 iArrayCount = doiArray.Count(); |
|
259 |
|
260 HBufC8* dataOwnerBuffer = NULL; |
|
261 for (TInt index = 0; index < iArrayCount; index++) |
|
262 { |
|
263 dataOwnerBuffer = doiArray[index]->ExternaliseLC(); |
|
264 |
|
265 if (transferBufPtr.Size() + dataOwnerBuffer->Size() > transferBufPtr.MaxSize()) |
|
266 { |
|
267 iTransferBuf = iTransferBuf->ReAllocL(transferBufPtr.MaxSize() + KSBBufferBlockSize); |
|
268 transferBufPtr.Set(iTransferBuf->Des()); |
|
269 } |
|
270 |
|
271 // Append the flattened data owner to the IPC transfer buffer |
|
272 transferBufPtr.Append(*dataOwnerBuffer); |
|
273 |
|
274 CleanupStack::PopAndDestroy(dataOwnerBuffer); |
|
275 } |
|
276 } |
|
277 ); // TRAP |
|
278 |
|
279 doiArray.ResetAndDestroy(); |
|
280 doiArray.Close(); |
|
281 |
|
282 User::LeaveIfError(err); |
|
283 |
|
284 // complete the message with the total size of the buffer so that the |
|
285 // client can create the appropriate sized descriptor for receiving the data |
|
286 aMessage.Complete(iTransferBuf->Des().Size()); |
|
287 } |
|
288 |
|
289 void CSBESession::ReturnDataOwnerInfoL(const RMessage2& aMessage) |
|
290 /** |
|
291 Return the previously populated buffer to the client |
|
292 @param aMessage The message sent by the client to the server |
|
293 */ |
|
294 { |
|
295 __ASSERT_DEBUG(iTransferBuf, Panic(KErrNotFound)); |
|
296 |
|
297 // return the previously allocated transfer buffer |
|
298 aMessage.WriteL(0, *iTransferBuf); |
|
299 aMessage.Complete(iArrayCount); |
|
300 |
|
301 ResetTransferBuf(); |
|
302 } |
|
303 |
|
304 void CSBESession::PrepPublicFileListL(const RMessage2& aMessage) |
|
305 /** |
|
306 Compile a list of public files owned by a particular SID to be backed up |
|
307 @param aMessage The message sent by the client to the server |
|
308 */ |
|
309 { |
|
310 RFileArray fileArray; |
|
311 CleanupClosePushL(fileArray); |
|
312 HBufC8* pGenericDataTypeBuffer = HBufC8::NewLC(aMessage.GetDesLengthL(1)); |
|
313 |
|
314 TPtr8 genericDataTypeBuffer(pGenericDataTypeBuffer->Des()); |
|
315 aMessage.ReadL(1, genericDataTypeBuffer); |
|
316 |
|
317 TDriveNumber drive = static_cast<TDriveNumber>(aMessage.Int0()); |
|
318 |
|
319 CSBGenericDataType* pGenericDataType = CSBGenericDataType::NewL(*pGenericDataTypeBuffer); |
|
320 CleanupStack::PopAndDestroy(pGenericDataTypeBuffer); |
|
321 CleanupStack::PushL(pGenericDataType); |
|
322 Server().DataOwnerManager().GetPublicFileListL(pGenericDataType, drive, fileArray); |
|
323 CleanupStack::PopAndDestroy(pGenericDataType); |
|
324 |
|
325 iTransferBuf = fileArray.ExternaliseL(); |
|
326 |
|
327 CleanupStack::PopAndDestroy(&fileArray); |
|
328 |
|
329 // complete the message with the total size of the buffer so that the |
|
330 // client can create the appropriate sized descriptor for receiving the data |
|
331 aMessage.Complete(iTransferBuf->Des().MaxSize()); |
|
332 } |
|
333 |
|
334 void CSBESession::ReturnPublicFileListL(const RMessage2& aMessage) |
|
335 /** Return the previously populated buffer to the client |
|
336 @param aMessage The message sent by the client to the server */ |
|
337 { |
|
338 __ASSERT_DEBUG(iTransferBuf, Panic(KErrArgument)); |
|
339 |
|
340 // return the previously allocated transfer buffer |
|
341 aMessage.WriteL(0, *iTransferBuf); |
|
342 |
|
343 aMessage.Complete(KErrNone); |
|
344 |
|
345 ResetTransferBuf(); |
|
346 } |
|
347 |
|
348 void CSBESession::PrepPublicFileListRawL(const RMessage2& aMessage) |
|
349 /** |
|
350 Compile a raw list of public files owned by a particular SID to be backed up |
|
351 @param aMessage The message sent by the client to the server |
|
352 */ |
|
353 { |
|
354 RRestoreFileFilterArray fileFilterArray; |
|
355 CleanupClosePushL(fileFilterArray); |
|
356 TPckgBuf<TDriveNumber> driveNumPkg; |
|
357 HBufC8* pGenericDataTypeBuffer = HBufC8::NewLC(aMessage.GetDesLengthL(1)); |
|
358 |
|
359 TPtr8 genericDataTypeBuffer(pGenericDataTypeBuffer->Des()); |
|
360 |
|
361 aMessage.ReadL(0, driveNumPkg); |
|
362 aMessage.ReadL(1, genericDataTypeBuffer); |
|
363 |
|
364 CSBGenericDataType* pGenericDataType = CSBGenericDataType::NewL(*pGenericDataTypeBuffer); |
|
365 CleanupStack::PopAndDestroy(pGenericDataTypeBuffer); |
|
366 CleanupStack::PushL(pGenericDataType); |
|
367 |
|
368 Server().DataOwnerManager().GetRawPublicFileListL(pGenericDataType, driveNumPkg(), fileFilterArray); |
|
369 CleanupStack::PopAndDestroy(pGenericDataType); |
|
370 |
|
371 iTransferBuf = fileFilterArray.ExternaliseL(); |
|
372 |
|
373 CleanupStack::PopAndDestroy(&fileFilterArray); |
|
374 |
|
375 // complete the message with the total size of the buffer so that the |
|
376 // client can create the appropriate sized descriptor for receiving the data |
|
377 aMessage.Complete(iTransferBuf->Des().MaxSize()); |
|
378 } |
|
379 |
|
380 void CSBESession::ReturnPublicFileListRawL(const RMessage2& aMessage) |
|
381 /** Return the previously populated buffer to the client |
|
382 @param aMessage The message sent by the client to the server */ |
|
383 { |
|
384 __ASSERT_DEBUG(iTransferBuf, Panic(KErrArgument)); |
|
385 |
|
386 // return the previously allocated transfer buffer |
|
387 aMessage.WriteL(0, *iTransferBuf); |
|
388 |
|
389 aMessage.Complete(KErrNone); |
|
390 |
|
391 ResetTransferBuf(); |
|
392 } |
|
393 |
|
394 void CSBESession::PrepPublicFileListXMLL(const RMessage2& aMessage) |
|
395 /** |
|
396 */ |
|
397 { |
|
398 TPckgBuf<TDriveNumber> driveNumPkg; |
|
399 TPckgBuf<TSecureId> sidPkg; |
|
400 |
|
401 ResetTransferBuf(); |
|
402 |
|
403 iTransferTextBuf = HBufC::NewL(0); |
|
404 |
|
405 Server().DataOwnerManager().GetXMLPublicFileListL(sidPkg(), driveNumPkg(), iTransferTextBuf); |
|
406 |
|
407 iTransferBuf = HBufC8::NewL(0); |
|
408 |
|
409 aMessage.Complete(iTransferBuf->Des().MaxSize()); |
|
410 } |
|
411 |
|
412 void CSBESession::ReturnPublicFileListXMLL(const RMessage2& aMessage) |
|
413 /** |
|
414 Return the previously populated buffer to the client |
|
415 @param aMessage The message sent by the client to the server |
|
416 */ |
|
417 { |
|
418 __ASSERT_DEBUG(iTransferBuf, Panic(KErrArgument)); |
|
419 |
|
420 // return the previously allocated transfer buffer |
|
421 aMessage.WriteL(0, *iTransferTextBuf); |
|
422 |
|
423 aMessage.Complete(KErrNone); |
|
424 |
|
425 ResetTransferBuf(); |
|
426 } |
|
427 |
|
428 void CSBESession::SetBURModeL(const RMessage2& aMessage) |
|
429 /** |
|
430 Set the Backup and Restore mode on/off and configure the BUR options |
|
431 |
|
432 @param aMessage The message sent by the client to the server |
|
433 */ |
|
434 { |
|
435 TDriveList driveList; |
|
436 |
|
437 aMessage.ReadL(0, driveList); |
|
438 TBURPartType burType = static_cast<TBURPartType>(aMessage.Int1()); |
|
439 TBackupIncType incType = static_cast<TBackupIncType>(aMessage.Int2()); |
|
440 |
|
441 |
|
442 // Unlock the global heap |
|
443 Server().GSHInterface().ResetHeap(Server().GlobalSharedHeap()); |
|
444 |
|
445 Server().DataOwnerManager().SetBURModeL(driveList, burType, incType); |
|
446 |
|
447 aMessage.Complete(KErrNone); |
|
448 } |
|
449 |
|
450 void CSBESession::SetSIDListForPartialBURL(const RMessage2& aMessage) |
|
451 /** |
|
452 Set a list of SID's that require base backup regardless of the device backup mode |
|
453 |
|
454 @param aMessage The message sent by the client to the server |
|
455 */ |
|
456 { |
|
457 HBufC8* flatArray = HBufC8::NewLC(aMessage.GetDesLengthL(0)); |
|
458 TPtr8 flatArrayPtr(flatArray->Des()); |
|
459 |
|
460 aMessage.ReadL(0, flatArrayPtr); |
|
461 |
|
462 Server().DataOwnerManager().SetSIDListForPartialBURL(flatArrayPtr); |
|
463 |
|
464 CleanupStack::PopAndDestroy(flatArray); |
|
465 |
|
466 aMessage.Complete(KErrNone); |
|
467 } |
|
468 |
|
469 void CSBESession::PrepSIDStatusL(const RMessage2& aMessage) |
|
470 /** |
|
471 Extract the array of SID's of which the status is required |
|
472 |
|
473 @param aMessage The message sent from the client to the server |
|
474 */ |
|
475 { |
|
476 ResetTransferBuf(); |
|
477 iTransferBuf = HBufC8::NewL(aMessage.GetDesLengthL(0)); |
|
478 |
|
479 TPtr8 transBuf(iTransferBuf->Des()); |
|
480 // Copy the IPC'd buffer into our transfer buffer |
|
481 aMessage.ReadL(0, transBuf); |
|
482 |
|
483 aMessage.Complete(KErrNone); |
|
484 } |
|
485 |
|
486 void CSBESession::ReturnSIDStatusL(const RMessage2& aMessage) |
|
487 /** |
|
488 Populate and return the array of SID's complete with their statuses |
|
489 |
|
490 @param aMessage The message sent from the client to the server |
|
491 */ |
|
492 { |
|
493 RSIDStatusArray* pStatusArray = RSIDStatusArray::InternaliseL(*iTransferBuf); |
|
494 CleanupStack::PushL(pStatusArray); |
|
495 CleanupClosePushL(*pStatusArray); |
|
496 |
|
497 // We're finished with the received externalised SIDStatusArray for now, delete it |
|
498 ResetTransferBuf(); |
|
499 |
|
500 // Ask DOM to populate the Statuses in the status array |
|
501 Server().DataOwnerManager().SIDStatusL(*pStatusArray); |
|
502 |
|
503 iTransferBuf = pStatusArray->ExternaliseL(); |
|
504 |
|
505 CleanupStack::PopAndDestroy(2, pStatusArray); |
|
506 |
|
507 aMessage.WriteL(0, *iTransferBuf); |
|
508 aMessage.Complete(KErrNone); |
|
509 |
|
510 ResetTransferBuf(); |
|
511 } |
|
512 |
|
513 void CSBESession::RequestDataAsyncL(const RMessage2& aMessage) |
|
514 /** |
|
515 Handle the client's asynchronous request for data from the SBE |
|
516 */ |
|
517 { |
|
518 iMessage = aMessage; |
|
519 |
|
520 __LOG("CSBESession::RequestDataAsyncL() - START"); |
|
521 TBool finished = EFalse; // Set by DOM, initialised to eliminate warning |
|
522 HBufC8* pTransferredBuf = HBufC8::NewLC(iMessage.GetDesLengthL(0)); |
|
523 |
|
524 TPtr8 transBuf(pTransferredBuf->Des()); |
|
525 // Copy the IPC'd buffer into our transfer buffer |
|
526 iMessage.ReadL(0, transBuf); |
|
527 |
|
528 // Extract the generic type from the client IPC request |
|
529 CSBGenericTransferType* pGenericType = CSBGenericTransferType::NewL(*pTransferredBuf); |
|
530 CleanupStack::PopAndDestroy(pTransferredBuf); |
|
531 CleanupStack::PushL(pGenericType); |
|
532 |
|
533 TPtr8& writeBuf = Server().GSHInterface().WriteBufferL(Server().GlobalSharedHeap()); |
|
534 |
|
535 Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(ETrue); |
|
536 |
|
537 Server().GSHInterface().Header(Server().GlobalSharedHeap()).GenericTransferTypeBuffer() = pGenericType->Externalise(); |
|
538 |
|
539 // Call the DOM to populate the GSH with the data to return |
|
540 Server().DataOwnerManager().RequestDataL(pGenericType, writeBuf, finished); |
|
541 |
|
542 CleanupStack::PopAndDestroy(pGenericType); |
|
543 |
|
544 Server().GSHInterface().Header(Server().GlobalSharedHeap()).iFinished = finished; |
|
545 __LOG2("CSBESession::RequestDataAsyncL() - Server-side data length: %d, address: 0x%08x", writeBuf.Length(), writeBuf.Ptr()); |
|
546 //__LOGDATA("CSBESession::RequestDataAsyncL() - %S", writeBuf.Ptr(), writeBuf.Length()); |
|
547 |
|
548 Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse); |
|
549 |
|
550 if (!iMessage.IsNull()) |
|
551 { |
|
552 iMessage.Complete(KErrNone); |
|
553 } |
|
554 |
|
555 __LOG("CSBESession::RequestDataAsyncL() - END"); |
|
556 } |
|
557 |
|
558 void CSBESession::RequestDataSyncL(const RMessage2& aMessage) |
|
559 /** |
|
560 Handle the client's synchronous request for data from the SBE |
|
561 */ |
|
562 { |
|
563 __LOG("CSBESession::RequestDataSyncL() - START"); |
|
564 TBool finished = EFalse; // Set by DOM, initialised to eliminate warning |
|
565 HBufC8* pTransferredBuf = HBufC8::NewLC(aMessage.GetDesLengthL(0)); |
|
566 |
|
567 TPtr8 transBuf(pTransferredBuf->Des()); |
|
568 // Copy the IPC'd buffer into our transfer buffer |
|
569 aMessage.ReadL(0, transBuf); |
|
570 |
|
571 // Extract the generic type from the client IPC request |
|
572 CSBGenericTransferType* pGenericType = CSBGenericTransferType::NewL(*pTransferredBuf); |
|
573 CleanupStack::PopAndDestroy(pTransferredBuf); |
|
574 CleanupStack::PushL(pGenericType); |
|
575 |
|
576 TPtr8& writeBuf = Server().GSHInterface().WriteBufferL(Server().GlobalSharedHeap()); |
|
577 |
|
578 Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(ETrue); |
|
579 |
|
580 Server().GSHInterface().Header(Server().GlobalSharedHeap()).GenericTransferTypeBuffer() = pGenericType->Externalise(); |
|
581 |
|
582 // Call the DOM to populate the GSH with the data to return |
|
583 Server().DataOwnerManager().RequestDataL(pGenericType, writeBuf, finished); |
|
584 |
|
585 CleanupStack::PopAndDestroy(pGenericType); |
|
586 |
|
587 Server().GSHInterface().Header(Server().GlobalSharedHeap()).iFinished = finished; |
|
588 |
|
589 Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse); |
|
590 __LOG2("CSBESession::RequestDataSyncL() - Server-side data length: %d, address: 0x%08x", writeBuf.Length(), writeBuf.Ptr()); |
|
591 //__LOGDATA("CSBESession::RequestDataSyncL() - %S", writeBuf.Ptr(), writeBuf.Length()); |
|
592 |
|
593 aMessage.Complete(KErrNone); |
|
594 __LOG("CSBESession::RequestDataSyncL() - END"); |
|
595 } |
|
596 |
|
597 void CSBESession::SupplyDataSyncL(const RMessage2& aMessage) |
|
598 /** |
|
599 Handle the client's synchronous request to supply data to the SBE |
|
600 */ |
|
601 { |
|
602 __LOG("CSBESession::SupplyDataSyncL() - START"); |
|
603 TBool finished = aMessage.Int0(); |
|
604 |
|
605 CSBGenericTransferType* pGenericType = CSBGenericTransferType::NewL( |
|
606 Server().GSHInterface().Header(Server().GlobalSharedHeap()) |
|
607 .GenericTransferTypeBuffer()); |
|
608 CleanupStack::PushL(pGenericType); |
|
609 |
|
610 TPtrC8& readBuf = Server().GSHInterface().ReadBufferL(Server().GlobalSharedHeap()); |
|
611 |
|
612 Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(ETrue); |
|
613 __LOG2("CSBESession::SupplyDataSyncL() - Server-side data length: %d, address: 0x%08x", readBuf.Length(), readBuf.Ptr()); |
|
614 //__LOGDATA("CSBESession::SupplyDataSyncL() - %S", readBuf.Ptr(), readBuf.Length()); |
|
615 |
|
616 Server().DataOwnerManager().SupplyDataL(pGenericType, readBuf, finished); |
|
617 |
|
618 |
|
619 CleanupStack::PopAndDestroy(pGenericType); |
|
620 |
|
621 Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse); |
|
622 |
|
623 aMessage.Complete(KErrNone); |
|
624 __LOG("CSBESession::SupplyDataSyncL() - END"); |
|
625 } |
|
626 |
|
627 void CSBESession::GetExpectedDataSizeL(const RMessage2& aMessage) |
|
628 /** |
|
629 Return the size of data that the DOM expects to send back to the PC |
|
630 */ |
|
631 { |
|
632 TUint size; |
|
633 TPckg<TUint> sizePkg(size); |
|
634 |
|
635 TInt bufferLen = aMessage.GetDesLengthL(0); |
|
636 HBufC8* transTypeBuf = HBufC8::NewL(bufferLen); |
|
637 CleanupStack::PushL(transTypeBuf); |
|
638 |
|
639 TPtr8 transTypeBufDes(transTypeBuf->Des()); |
|
640 aMessage.ReadL(0, transTypeBufDes); |
|
641 |
|
642 CSBGenericTransferType* pGenericType = CSBGenericTransferType::NewL(transTypeBufDes); |
|
643 CleanupStack::PopAndDestroy(transTypeBuf); |
|
644 CleanupStack::PushL(pGenericType); |
|
645 |
|
646 aMessage.ReadL(1, sizePkg); |
|
647 |
|
648 Server().DataOwnerManager().GetExpectedDataSizeL(pGenericType, sizePkg()); |
|
649 CleanupStack::PopAndDestroy(pGenericType); |
|
650 |
|
651 aMessage.WriteL(1, sizePkg); |
|
652 |
|
653 aMessage.Complete(KErrNone); |
|
654 } |
|
655 |
|
656 void CSBESession::AllSnapshotsSuppliedL(const RMessage2& aMessage) |
|
657 /** |
|
658 */ |
|
659 { |
|
660 Server().DataOwnerManager().AllSnapshotsSuppliedL(); |
|
661 |
|
662 aMessage.Complete(KErrNone); |
|
663 } |
|
664 |
|
665 void CSBESession::AllSystemFilesRestoredL() |
|
666 /** |
|
667 Sent by the client to indicate that all registration files |
|
668 @param aMessage IPC message sent from the client |
|
669 */ |
|
670 { |
|
671 Server().DataOwnerManager().AllSystemFilesRestoredL(); |
|
672 } |
|
673 |
|
674 void CSBESession::PrepLargePublicFileListL(const RMessage2& aMessage) |
|
675 /** |
|
676 Compile a list of public files owned by a particular SID to be backed up |
|
677 @param aMessage The message sent by the client to the server |
|
678 */ |
|
679 { |
|
680 HBufC8* pGenericDataTypeBuffer = HBufC8::NewLC(aMessage.GetDesLengthL(1)); |
|
681 TPtr8 genericDataTypeBuffer(pGenericDataTypeBuffer->Des()); |
|
682 |
|
683 TDriveNumber drive = static_cast<TDriveNumber>(aMessage.Int0()); |
|
684 aMessage.ReadL(1, genericDataTypeBuffer); |
|
685 TInt cursor = aMessage.Int2(); |
|
686 TInt maxSize = aMessage.Int3(); |
|
687 |
|
688 CSBGenericDataType* pGenericDataType = CSBGenericDataType::NewL(*pGenericDataTypeBuffer); |
|
689 CleanupStack::PopAndDestroy(pGenericDataTypeBuffer); |
|
690 CleanupStack::PushL(pGenericDataType); |
|
691 |
|
692 // Create a transfer type (ignored by the client side, just here for future reference |
|
693 CSBGenericTransferType* transType = NULL; |
|
694 |
|
695 switch (pGenericDataType->DerivedTypeL()) |
|
696 { |
|
697 case ESIDDerivedType: |
|
698 { |
|
699 |
|
700 CSBSecureId* sid = CSBSecureId::NewL(pGenericDataType); |
|
701 CleanupStack::PushL(sid); |
|
702 transType = CSBSIDTransferType::NewL(sid->SecureIdL(), drive, EPublicFileListing); |
|
703 CleanupStack::PopAndDestroy(sid); |
|
704 break; |
|
705 } |
|
706 case EPackageDerivedType: |
|
707 { |
|
708 CSBPackageId* pkg = CSBPackageId::NewL(pGenericDataType); |
|
709 CleanupStack::PushL(pkg); |
|
710 transType = CSBPackageTransferType::NewL(pkg->PackageIdL(), drive, ESystemData); |
|
711 CleanupStack::PopAndDestroy(pkg); |
|
712 break; |
|
713 } |
|
714 case EJavaDerivedType: |
|
715 { |
|
716 CSBJavaId* java = CSBJavaId::NewL(pGenericDataType); |
|
717 CleanupStack::PushL(java); |
|
718 transType = CSBJavaTransferType::NewL(java->SuiteHashL(), drive, EJavaMIDletData); |
|
719 CleanupStack::PopAndDestroy(java); |
|
720 break; |
|
721 } |
|
722 default: |
|
723 { |
|
724 __LOG1("Unknown generic data type supplied, leaving with KErrUnknown (%d)", KErrUnknown); |
|
725 User::Leave(KErrUnknown); |
|
726 } |
|
727 } |
|
728 CleanupStack::PushL(transType); |
|
729 |
|
730 // Get a writeable buffer from the global shared heap |
|
731 TPtr8& writeBuf = Server().GSHInterface().WriteBufferL(Server().GlobalSharedHeap()); |
|
732 Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(ETrue); |
|
733 Server().GSHInterface().Header(Server().GlobalSharedHeap()).GenericTransferTypeBuffer() = transType->Externalise(); |
|
734 |
|
735 // This is required to look up the MIME type of the file entry and convert it into a textual representation |
|
736 RApaLsSession apaSession; |
|
737 User::LeaveIfError(apaSession.Connect()); |
|
738 CleanupClosePushL(apaSession); |
|
739 |
|
740 // Copy file entries from the cursor until either the end of the list is reached or the |
|
741 // max response size ceiling is reached. Store the number added for the call to ReturnLargePublicFileListL |
|
742 iFinished = EFalse; |
|
743 TInt currentIndex = cursor; |
|
744 TInt currentSize = 0; |
|
745 iTotalEntries = 0; |
|
746 |
|
747 if (currentIndex == 0) |
|
748 { |
|
749 // Starting from the beginning, remove previously saved entry |
|
750 delete iExtCurEntry; |
|
751 iExtCurEntry = 0; |
|
752 } |
|
753 |
|
754 while (currentSize < maxSize) |
|
755 { |
|
756 if (!iExtCurEntry) |
|
757 { |
|
758 TEntry entry; |
|
759 Server().DataOwnerManager().GetNextPublicFileL(pGenericDataType, (currentIndex == 0), drive, entry); |
|
760 if (entry.iName.Length()) |
|
761 { |
|
762 ++currentIndex; |
|
763 |
|
764 // Pull the next entry out of the list and translate into CSBEFileEntry |
|
765 CSBEFileEntry* pEntry = CSBEFileEntry::NewLC(entry, apaSession); |
|
766 |
|
767 // Pack it into the GSH |
|
768 iExtCurEntry = pEntry->ExternaliseLC(); |
|
769 CleanupStack::Pop(iExtCurEntry); |
|
770 |
|
771 CleanupStack::PopAndDestroy(pEntry); |
|
772 } |
|
773 } |
|
774 // else - use the remaining entry from the previous call |
|
775 |
|
776 if (iExtCurEntry) |
|
777 { |
|
778 // If this entry isn't going to bust our max RAM parameter, then pack it in |
|
779 currentSize += iExtCurEntry->Size(); |
|
780 if (currentSize <= maxSize) |
|
781 { |
|
782 writeBuf.Append(*iExtCurEntry); |
|
783 delete iExtCurEntry; |
|
784 iExtCurEntry = 0; |
|
785 ++iTotalEntries; |
|
786 } |
|
787 // else - leave iExtCurEntry until the next call |
|
788 } |
|
789 else |
|
790 { |
|
791 // No more entries left, must have reached the end of the list |
|
792 iFinished = ETrue; |
|
793 break; |
|
794 } |
|
795 } |
|
796 CleanupStack::PopAndDestroy(&apaSession); |
|
797 __LOG2("CSBESession::PrepLargePublicFileListL() - Server-side data length: %d, address: 0x%08x", writeBuf.Length(), writeBuf.Ptr()); |
|
798 |
|
799 Server().GSHInterface().Header(Server().GlobalSharedHeap()).iFinished = iFinished; |
|
800 |
|
801 Server().GSHInterface().Header(Server().GlobalSharedHeap()).SetLockedFlag(EFalse); |
|
802 |
|
803 CleanupStack::PopAndDestroy(transType); |
|
804 CleanupStack::PopAndDestroy(pGenericDataType); |
|
805 |
|
806 aMessage.Complete(KErrNone); |
|
807 } |
|
808 |
|
809 void CSBESession::ReturnLargePublicFileListL(const RMessage2& aMessage) |
|
810 /** Return the previously populated buffer to the client |
|
811 @param aMessage The message sent by the client to the server */ |
|
812 { |
|
813 TPckg<TBool> finPkg(iFinished); |
|
814 TPckg<TInt> totalPkg(iTotalEntries); |
|
815 aMessage.WriteL(0, finPkg); |
|
816 aMessage.WriteL(1, totalPkg); |
|
817 aMessage.Complete(KErrNone); |
|
818 } |
|
819 |
|
820 void CSBESession::ResetTransferBuf() |
|
821 /** |
|
822 */ |
|
823 { |
|
824 if (iTransferBuf != NULL) |
|
825 { |
|
826 delete iTransferBuf; |
|
827 iTransferBuf = NULL; |
|
828 } |
|
829 |
|
830 if (iTransferTextBuf != NULL) |
|
831 { |
|
832 delete iTransferTextBuf; |
|
833 iTransferTextBuf = NULL; |
|
834 } |
|
835 |
|
836 iArrayCount = 0; |
|
837 } |
|
838 } |