470 @capability ReadUserData This is required to access any entry where the condition |
470 @capability ReadUserData This is required to access any entry where the condition |
471 described for no capabilities does not apply. |
471 described for no capabilities does not apply. |
472 */ |
472 */ |
473 EXPORT_C TInt RMsvServerSession::GetEntry(TMsvId aId, TMsvId& aService, TMsvEntry& aEntry) |
473 EXPORT_C TInt RMsvServerSession::GetEntry(TMsvId aId, TMsvId& aService, TMsvEntry& aEntry) |
474 { |
474 { |
475 TRAPD(error, DoGetEntryL(aId, aService, aEntry)); |
475 // pass the buffer and its max length to receive the data through |
476 return error; |
476 TPtr8 ptr=iBuffer->Des(); |
477 } |
477 TInt maxLength = iBuffer->Des().MaxLength(); |
478 |
478 |
479 void RMsvServerSession::DoGetEntryL(TMsvId aId, TMsvId& aService, TMsvEntry& aEntry) |
|
480 { |
|
481 // pass the buffer to receive the data through |
|
482 TPtr8 ptr=iBuffer->Des(); |
|
483 // get the service the entry i sunder |
|
484 TPckg<TMsvId> service(aService); |
|
485 // signal the server |
479 // signal the server |
486 TInt error = SendReceive(EMsvGetEntry,TIpcArgs(aId,&ptr,&service)); |
480 TInt error = SendReceive(EMsvGetEntry,TIpcArgs(aId, &ptr, maxLength)); |
487 while(error == KErrOverflow) |
481 while(error == KErrOverflow) |
488 { |
482 { |
489 // increase the size of the buffer and try again |
483 // increase the size of the buffer and try again |
490 iBuffer->Des().SetLength(0); |
484 iBuffer->Des().SetLength(0); |
491 iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength); |
485 // TRAP here and return if leaving with error |
492 // pass the buffer to receive the data through |
486 TRAP(error, iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength)); |
493 TPtr8 ptr=iBuffer->Des(); |
487 if( error != KErrNone) |
494 error = SendReceive(EMsvGetEntry,TIpcArgs(aId,&ptr,&service)); |
488 { |
495 } |
489 break; |
496 User::LeaveIfError(error); |
490 } |
497 TMsvPackedEntry packedEntry(iBuffer); |
491 // pass the buffer to receive the data through |
498 packedEntry.UnpackEntry(aEntry); |
492 TPtr8 ptr=iBuffer->Des(); |
|
493 maxLength = iBuffer->Des().MaxLength(); |
|
494 error = SendReceive(EMsvGetEntry,TIpcArgs(aId,&ptr,maxLength)); |
|
495 } |
|
496 |
|
497 if( error == KErrNone) |
|
498 { |
|
499 TMsvPackedEntry packedEntry(iBuffer); |
|
500 // Unpack the entry and servie id from same buffer |
|
501 packedEntry.UnpackEntryAndService(aEntry, aService); |
|
502 } |
|
503 |
|
504 return error; |
499 } |
505 } |
500 |
506 |
501 /** |
507 /** |
502 Gets the children of the index entry with the specified unique id. |
508 Gets the children of the index entry with the specified unique id. |
503 |
509 |