--- a/appfw/apparchitecture/apserv/APSSES.CPP Wed Jun 09 09:52:12 2010 +0300
+++ b/appfw/apparchitecture/apserv/APSSES.CPP Mon Jun 21 15:51:07 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1997-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"
@@ -1206,28 +1206,57 @@
aInfo.iShortCaption = app->ShortCaption();
}
-void CApaAppArcServSession::DoRecognizeUnpackLC(HBufC*& aName, HBufC8*& aBuffer, const RMessage2& aMessage)
+TPtrC8 CApaAppArcServSession::DoRecognizeUnpackLC(HBufC*& aName, RChunk& aLocalChunk, const RMessage2& aMessage)
{
- ASSERT(aName==NULL);
- ASSERT(aBuffer==NULL);
- aName=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1)));
- TPtr name(aName->Des());
- aMessage.ReadL(1, name);
- aBuffer=HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesLength(2)));
- TPtr8 buffer(aBuffer->Des());
- aMessage.ReadL(2, buffer);
+ ASSERT(aName==NULL);
+
+ aName=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1)));
+ TPtr name(aName->Des());
+ aMessage.ReadL(1, name);
+
+ HBufC8* buffer=NULL;
+ TInt error=KErrNone;
+ TInt bufferSize= aMessage.GetDesLength(2);
+ User::LeaveIfError(bufferSize);
+ //Allocate memory in apparc's process heap.
+ TRAP(error, buffer=HBufC8::NewL(bufferSize));
+
+ if(error==KErrNone)
+ {
+ CleanupStack::PushL(buffer);
+ TPtr8 bufPtr(buffer->Des());
+ aMessage.ReadL(2, bufPtr);
+ return bufPtr;
+ }
+ else if(error==KErrNoMemory)
+ {
+ //If memory is not available in apparc's process heap, then allocate in kernel heap
+ User::LeaveIfError(aLocalChunk.CreateLocal(bufferSize,bufferSize));
+ CleanupClosePushL(aLocalChunk);
+ TPtr8 bufPtr(aLocalChunk.Base(), bufferSize);
+ aMessage.ReadL(2, bufPtr);
+ return bufPtr;
+ }
+ else
+ {
+ User::Leave(error);
+ }
+
+ TPtrC8 bufPtr(NULL,0); //Never executed. To make compiler happy
+ return bufPtr;
}
void CApaAppArcServSession::RecognizeDataL(const RMessage2& aMessage)
// Recognize the data type of an object
{
HBufC* name=NULL;
- HBufC8* buffer=NULL;
- DoRecognizeUnpackLC(name,buffer,aMessage);
+ RChunk localChunk;
+
+ TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage);
- const TDataRecognitionResult result = iServ.RecognizeDataL(*name, *buffer);
+ const TDataRecognitionResult result = iServ.RecognizeDataL(*name, bufPtr);
- CleanupStack::PopAndDestroy(2); // name & buffer
+ CleanupStack::PopAndDestroy(2); // name & buffer or localChunk
aMessage.WriteL(0,TPckgC<TDataRecognitionResult>(result));
}
@@ -1506,13 +1535,14 @@
// Determine whether an object is of a specific data type
{
HBufC* name=NULL;
- HBufC8* buffer=NULL;
- DoRecognizeUnpackLC(name,buffer,aMessage);
+ RChunk localChunk;
+
+ TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage);
TDataType dataType;
{TPckg<TDataType> dataType_asDescriptor(dataType);
aMessage.ReadL(0, dataType_asDescriptor);}
- aMessage.Complete(iServ.RecognizeDataL(*name,*buffer,dataType));
- CleanupStack::PopAndDestroy(2); // name & buffer
+ aMessage.Complete(iServ.RecognizeDataL(*name,bufPtr,dataType));
+ CleanupStack::PopAndDestroy(2); // name & buffer or localChunk
}
void CApaAppArcServSession::RecognizeSpecificDataPassedByFileHandleL(const RMessage2& aMessage)