messagingfw/msgsrvnstore/server/src/MSVSESS.CPP
branchRCL_3
changeset 18 b9e74fff3740
parent 6 fe71b07a6401
child 21 e5b3a2155e1a
equal deleted inserted replaced
16:b9bc42ac264b 18:b9e74fff3740
   694 		// desLen is negative leave with an error.
   694 		// desLen is negative leave with an error.
   695 		User::Leave(KErrArgument);
   695 		User::Leave(KErrArgument);
   696 		}
   696 		}
   697 	}
   697 	}
   698 
   698 
   699 
       
   700 void CMsvServerSession::WriteBufferL(const RMessage2& aMessage, TInt aParam)
   699 void CMsvServerSession::WriteBufferL(const RMessage2& aMessage, TInt aParam)
   701 //
   700 //
   702 // Copies the packed entry buffer from the client
   701 // Copies the packed entry buffer from the client
   703 // Only fails if the client buffer is not large enough
   702 // Only fails if the client buffer is not large enough
   704 //
   703 //
   978 	iOperations.AppendL(operation); // will not fail - see start of function
   977 	iOperations.AppendL(operation); // will not fail - see start of function
   979 	CleanupStack::Pop(); // operation
   978 	CleanupStack::Pop(); // operation
   980 	}
   979 	}
   981 
   980 
   982 
   981 
   983 void CMsvServerSession::PackEntryAndWriteBufferL(const RMessage2 &aMessage, const TInt aParam, const TMsvEntry& aEntry)
   982 void CMsvServerSession::PackEntryAndWriteBufferL(const RMessage2 &aMessage, const TInt aParam, const TMsvEntry& aEntry, const TMsvId& aServiceId)
   984 //
   983 //
   985 //
   984 //
   986 //
   985 	{
   987 	{
   986 	// package the entry and service id in same buffer
   988 	// package the entry
       
   989 	TMsvPackedEntry packedEntry(iBuffer);
   987 	TMsvPackedEntry packedEntry(iBuffer);
   990 	TInt error = packedEntry.PackEntry(aEntry);
   988 	TInt error = packedEntry.PackEntryAndService(aEntry, aServiceId);
   991 	while(error!=KErrNone)
   989 	while(error!=KErrNone)
   992 		{
   990 		{
   993 		// increase the size of the buffer and try again
   991 		// increase the size of the buffer and try again
   994 		iBuffer->Des().SetLength(0); // to avoid copying contents
   992 		iBuffer->Des().SetLength(0); // to avoid copying contents
   995 		iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
   993 		iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
   996 		error = packedEntry.PackEntry(aEntry);
   994 		error = packedEntry.PackEntryAndService(aEntry, aServiceId);
   997 		}
   995 		}
   998 	WriteBufferL(aMessage, aParam);
   996 	// max destination length is passed from client
       
   997 	TInt maxDesLen = aMessage.Int2();
       
   998     if (maxDesLen < iBuffer->Des().Length())
       
   999 		{
       
  1000         User::Leave(KErrOverflow);
       
  1001 		}
       
  1002 
       
  1003     aMessage.WriteL(aParam, iBuffer->Des());
   999 	}
  1004 	}
  1000 
  1005 
  1001 void CMsvServerSession::GetEntryL(const RMessage2 &aMessage)
  1006 void CMsvServerSession::GetEntryL(const RMessage2 &aMessage)
  1002 //
  1007 //
  1003 // Returns the index entry for the given id
  1008 // Returns the index entry for the given id
  1013 		{
  1018 		{
  1014 		// Police request - client must be able to read the entry.
  1019 		// Police request - client must be able to read the entry.
  1015 		iMsvServer.PoliceReadEntryL(aMessage, ownerId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetEntryL"));
  1020 		iMsvServer.PoliceReadEntryL(aMessage, ownerId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetEntryL"));
  1016 
  1021 
  1017 		// get the owning service and write that back
  1022 		// get the owning service and write that back
  1018 		TPckgBuf<TMsvId> service;
  1023 		TMsvId service;
  1019 		if (id==KMsvRootIndexEntryId)
  1024 		if (id == KMsvRootIndexEntryId)
  1020 			service()=KMsvRootIndexEntryId;
  1025 			service = KMsvRootIndexEntryId;
  1021 		else
  1026 		else
  1022 			{
  1027 			{
  1023 			iMsvServer.IndexAdapter().OwningService(id, service()); // error ignore as the entry exists
  1028 			iMsvServer.IndexAdapter().OwningService(id, service); // error ignore as the entry exists
  1024 			}
  1029 			}
  1025 
       
  1026 		WriteL(aMessage, 2, service);
       
  1027 		// write the entry back
  1030 		// write the entry back
  1028 		PackEntryAndWriteBufferL(aMessage, 1, *entryPtr);
  1031 		PackEntryAndWriteBufferL(aMessage, 1, *entryPtr, service);
  1029 		}
  1032 		}
       
  1033 
  1030 	aMessage.Complete(error);
  1034 	aMessage.Complete(error);
  1031 	}
  1035 	}
  1032 
  1036 
  1033 void CMsvServerSession::OutstandingOperationsL(const RMessage2& aMessage)
  1037 void CMsvServerSession::OutstandingOperationsL(const RMessage2& aMessage)
  1034 	{
  1038 	{