Revision: 201023 RCL_3 PDK_3.0.1
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 21 Jun 2010 16:13:01 +0300
branchRCL_3
changeset 18 b9e74fff3740
parent 16 b9bc42ac264b
child 20 e4175d61d967
Revision: 201023 Kit: 2010125
messagingfw/msgsrvnstore/server/inc/MCLIENT.H
messagingfw/msgsrvnstore/server/inc/MSVIPC.H
messagingfw/msgsrvnstore/server/inc/MSVSERV.H
messagingfw/msgsrvnstore/server/src/MCLENTRY.CPP
messagingfw/msgsrvnstore/server/src/MCLIENT.CPP
messagingfw/msgsrvnstore/server/src/MSVIPC.CPP
messagingfw/msgsrvnstore/server/src/MSVSESS.CPP
messagingfw/scheduledsendmtm/schedulesendmtm/inc/MsvSchedulePackage.h
--- a/messagingfw/msgsrvnstore/server/inc/MCLIENT.H	Wed Jun 09 10:13:14 2010 +0300
+++ b/messagingfw/msgsrvnstore/server/inc/MCLIENT.H	Mon Jun 21 16:13:01 2010 +0300
@@ -217,7 +217,6 @@
 	void SendCommandDataL(TMsvOp aOperationId, const CMsvEntrySelection& aSelection, TInt aCommand, const TDesC8& aParameter);
 	void TestSlotAvailableL();
 	void PackOperationDataL(const CMsvEntrySelection& aSelection, TInt aParameter1, TInt aParameter2);
-	void DoGetEntryL(TMsvId aId, TMsvId& aService, TMsvEntry& aEntry);
 
 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
 	void DoGetChildrenAllL(TMsvId aId, CArrayPtrFlat<CMsvClientEntry>& aEntries, const TMsvSelectionOrdering& aOrdering);
--- a/messagingfw/msgsrvnstore/server/inc/MSVIPC.H	Wed Jun 09 10:13:14 2010 +0300
+++ b/messagingfw/msgsrvnstore/server/inc/MSVIPC.H	Mon Jun 21 16:13:01 2010 +0300
@@ -93,6 +93,8 @@
 	IMPORT_C TMsvPackedEntry(HBufC8*& aBuffer);
 	IMPORT_C TInt PackEntry(const TMsvEntry& aEntry);
 	IMPORT_C void UnpackEntry(TMsvEntry& aEntry);
+    TInt PackEntryAndService(const TMsvEntry& aEntry, const TMsvId& aServiceId);
+    void UnpackEntryAndService(TMsvEntry& aEntry, TMsvId& aServiceId);
 private:
 	HBufC8*& iBuffer;
 	};
--- a/messagingfw/msgsrvnstore/server/inc/MSVSERV.H	Wed Jun 09 10:13:14 2010 +0300
+++ b/messagingfw/msgsrvnstore/server/inc/MSVSERV.H	Mon Jun 21 16:13:01 2010 +0300
@@ -585,7 +585,7 @@
 	void CopyCommandDataL(const RMessage2 &aMessage);
 	HBufC8* RecoverOperationData(TMsvOp aOpId);
 	//
-	void PackEntryAndWriteBufferL(const RMessage2 &aMessage, TInt aParam, const TMsvEntry& aEntry);
+	void PackEntryAndWriteBufferL(const RMessage2 &aMessage, TInt aParam, const TMsvEntry& aEntry, const TMsvId& aServiceId);
 	//
 	void WriteBufferL(const RMessage2 &aMessage, TInt aParam);
 	void WriteL(const RMessage2 &aMessage, TInt aParam, const TDesC8& aDes);
--- a/messagingfw/msgsrvnstore/server/src/MCLENTRY.CPP	Wed Jun 09 10:13:14 2010 +0300
+++ b/messagingfw/msgsrvnstore/server/src/MCLENTRY.CPP	Mon Jun 21 16:13:01 2010 +0300
@@ -2726,13 +2726,20 @@
 //
 	{
 	TInt count = aSelection.Count();
-	while (count--)
-		{
-		if (!IsAChild(aSelection.At(count)))
-			{
-			return EFalse;
-			}
-		}
+	if(!count)
+	    {
+        return EFalse;
+	    }
+	else
+	    {
+        while (count--)
+            {
+            if (!IsAChild(aSelection.At(count)))
+                {
+                return EFalse;
+                }
+            }
+	    }
 	return ETrue;
 	}
 
--- a/messagingfw/msgsrvnstore/server/src/MCLIENT.CPP	Wed Jun 09 10:13:14 2010 +0300
+++ b/messagingfw/msgsrvnstore/server/src/MCLIENT.CPP	Mon Jun 21 16:13:01 2010 +0300
@@ -472,30 +472,36 @@
 */
 EXPORT_C TInt RMsvServerSession::GetEntry(TMsvId aId, TMsvId& aService, TMsvEntry& aEntry)
 	{
-	TRAPD(error, DoGetEntryL(aId, aService, aEntry));
-	return error;
-	}
-
-void RMsvServerSession::DoGetEntryL(TMsvId aId, TMsvId& aService, TMsvEntry& aEntry)
-	{
-	// pass the buffer to receive the data through
-	TPtr8 ptr=iBuffer->Des();
-	// get the service the entry i sunder
-	TPckg<TMsvId> service(aService);
+    // pass the buffer and its max length to receive the data through
+    TPtr8 ptr=iBuffer->Des();
+    TInt maxLength = iBuffer->Des().MaxLength();
+    
 	// signal the server
-	TInt error = SendReceive(EMsvGetEntry,TIpcArgs(aId,&ptr,&service));
-	while(error == KErrOverflow)
-		{
-		// increase the size of the buffer and try again
-		iBuffer->Des().SetLength(0);
-		iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
-		// pass the buffer to receive the data through
-		TPtr8 ptr=iBuffer->Des();
-		error = SendReceive(EMsvGetEntry,TIpcArgs(aId,&ptr,&service));
-		}
-	User::LeaveIfError(error);
-	TMsvPackedEntry packedEntry(iBuffer);
-	packedEntry.UnpackEntry(aEntry);
+    TInt error = SendReceive(EMsvGetEntry,TIpcArgs(aId, &ptr, maxLength));
+    while(error == KErrOverflow)
+        {
+        // increase the size of the buffer and try again
+        iBuffer->Des().SetLength(0);
+        // TRAP here and return if leaving with error
+        TRAP(error, iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength));
+        if( error != KErrNone)
+			{
+            break;
+			}
+        // pass the buffer to receive the data through
+        TPtr8 ptr=iBuffer->Des();
+        maxLength = iBuffer->Des().MaxLength();
+        error = SendReceive(EMsvGetEntry,TIpcArgs(aId,&ptr,maxLength));
+        }
+
+    if( error == KErrNone)
+        {
+        TMsvPackedEntry packedEntry(iBuffer);
+        // Unpack the entry and servie id from same buffer
+        packedEntry.UnpackEntryAndService(aEntry, aService);
+        }
+
+    return error;
 	}
 
 /**
--- a/messagingfw/msgsrvnstore/server/src/MSVIPC.CPP	Wed Jun 09 10:13:14 2010 +0300
+++ b/messagingfw/msgsrvnstore/server/src/MSVIPC.CPP	Mon Jun 21 16:13:01 2010 +0300
@@ -155,6 +155,49 @@
 	DoUnpackEntry(pS, aEntry);
 	}
 
+TInt TMsvPackedEntry::PackEntryAndService(const TMsvEntry& aEntry, const TMsvId& aServiceId)
+    {
+    // find the start and end of the buffer
+    const TUint8* pS = iBuffer->Ptr();
+    const TUint8* pE = PtrAdd(pS, iBuffer->Des().MaxSize());
+
+    TInt error = DoPackEntry(pS, pE, aEntry);
+    if (error==KErrNone)
+        {
+        TInt sizeDes = Align4(sizeof(TMsvId));
+        if ((pS + sizeDes)>pE)
+            {
+            return KErrOverflow;
+            }            
+        // copy the entry and descriptors into the memory area
+        Mem::Copy((void*)pS, &aServiceId, sizeof(TMsvId));
+        pS += sizeDes;
+
+        // update the length of the buffer
+        iBuffer->Des().SetLength(pS-iBuffer->Ptr());
+        }
+
+    return error;    
+    }
+
+void TMsvPackedEntry::UnpackEntryAndService(TMsvEntry& aEntry, TMsvId& aServiceId)
+    {
+#if defined(_DEBUG)
+    // check that the buffer contain a valid package
+    const TMsvEntry* dEntry = (TMsvEntry*) iBuffer->Ptr();
+    const TUint8* dPos = PtrAdd(iBuffer->Ptr(), Align4(sizeof(TMsvEntry)) + Align4(dEntry->iDescription.Size()) + Align4(dEntry->iDetails.Size()) + Align4(sizeof(TMsvId)) );
+    __ASSERT_DEBUG(dPos <= PtrAdd(iBuffer->Ptr(), iBuffer->Des().MaxLength()), PanicServer(EMsvEntryOverrunBuffer));
+#endif
+    
+    TUint8* pS = CONST_CAST(TUint8*, iBuffer->Ptr());
+    DoUnpackEntry(pS, aEntry);
+
+    // get the service id from the current position in the buffer
+    const TMsvId* pServiceId = (TMsvId*)pS;
+    aServiceId = *pServiceId;
+    pS = Align4(pS + sizeof(TMsvId));
+    }
+
 //**********************************
 // TMsvPackedEntryArray
 //**********************************
--- a/messagingfw/msgsrvnstore/server/src/MSVSESS.CPP	Wed Jun 09 10:13:14 2010 +0300
+++ b/messagingfw/msgsrvnstore/server/src/MSVSESS.CPP	Mon Jun 21 16:13:01 2010 +0300
@@ -696,7 +696,6 @@
 		}
 	}
 
-
 void CMsvServerSession::WriteBufferL(const RMessage2& aMessage, TInt aParam)
 //
 // Copies the packed entry buffer from the client
@@ -980,22 +979,28 @@
 	}
 
 
-void CMsvServerSession::PackEntryAndWriteBufferL(const RMessage2 &aMessage, const TInt aParam, const TMsvEntry& aEntry)
-//
+void CMsvServerSession::PackEntryAndWriteBufferL(const RMessage2 &aMessage, const TInt aParam, const TMsvEntry& aEntry, const TMsvId& aServiceId)
 //
 //
 	{
-	// package the entry
+	// package the entry and service id in same buffer
 	TMsvPackedEntry packedEntry(iBuffer);
-	TInt error = packedEntry.PackEntry(aEntry);
+	TInt error = packedEntry.PackEntryAndService(aEntry, aServiceId);
 	while(error!=KErrNone)
 		{
 		// increase the size of the buffer and try again
 		iBuffer->Des().SetLength(0); // to avoid copying contents
 		iBuffer = iBuffer->ReAllocL(iBuffer->Des().MaxSize() + KMsvSessionBufferLength);
-		error = packedEntry.PackEntry(aEntry);
+		error = packedEntry.PackEntryAndService(aEntry, aServiceId);
 		}
-	WriteBufferL(aMessage, aParam);
+	// max destination length is passed from client
+	TInt maxDesLen = aMessage.Int2();
+    if (maxDesLen < iBuffer->Des().Length())
+		{
+        User::Leave(KErrOverflow);
+		}
+
+    aMessage.WriteL(aParam, iBuffer->Des());
 	}
 
 void CMsvServerSession::GetEntryL(const RMessage2 &aMessage)
@@ -1015,18 +1020,17 @@
 		iMsvServer.PoliceReadEntryL(aMessage, ownerId, __PLATSEC_DIAGNOSTIC_STRING("Checked by CMsvServerSession::GetEntryL"));
 
 		// get the owning service and write that back
-		TPckgBuf<TMsvId> service;
-		if (id==KMsvRootIndexEntryId)
-			service()=KMsvRootIndexEntryId;
+		TMsvId service;
+		if (id == KMsvRootIndexEntryId)
+			service = KMsvRootIndexEntryId;
 		else
 			{
-			iMsvServer.IndexAdapter().OwningService(id, service()); // error ignore as the entry exists
+			iMsvServer.IndexAdapter().OwningService(id, service); // error ignore as the entry exists
 			}
-
-		WriteL(aMessage, 2, service);
 		// write the entry back
-		PackEntryAndWriteBufferL(aMessage, 1, *entryPtr);
+		PackEntryAndWriteBufferL(aMessage, 1, *entryPtr, service);
 		}
+
 	aMessage.Complete(error);
 	}
 
--- a/messagingfw/scheduledsendmtm/schedulesendmtm/inc/MsvSchedulePackage.h	Wed Jun 09 10:13:14 2010 +0300
+++ b/messagingfw/scheduledsendmtm/schedulesendmtm/inc/MsvSchedulePackage.h	Mon Jun 21 16:13:01 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1999-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -16,6 +16,9 @@
 #ifndef MSV_SCHEDULE_PACKAGE_H_
 #define MSV_SCHEDULE_PACKAGE_H_
 
+#include <s32std.h>
+#include <msvstd.h>
+
 //
 //
 //	TMsvSchedulePackage Declaration