1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
1204 aInfo.iFullName = entry.iFullName; |
1204 aInfo.iFullName = entry.iFullName; |
1205 aInfo.iCaption = app->Caption(); |
1205 aInfo.iCaption = app->Caption(); |
1206 aInfo.iShortCaption = app->ShortCaption(); |
1206 aInfo.iShortCaption = app->ShortCaption(); |
1207 } |
1207 } |
1208 |
1208 |
1209 void CApaAppArcServSession::DoRecognizeUnpackLC(HBufC*& aName, HBufC8*& aBuffer, const RMessage2& aMessage) |
1209 TPtrC8 CApaAppArcServSession::DoRecognizeUnpackLC(HBufC*& aName, RChunk& aLocalChunk, const RMessage2& aMessage) |
1210 { |
1210 { |
1211 ASSERT(aName==NULL); |
1211 ASSERT(aName==NULL); |
1212 ASSERT(aBuffer==NULL); |
1212 |
1213 aName=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1))); |
1213 aName=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1))); |
1214 TPtr name(aName->Des()); |
1214 TPtr name(aName->Des()); |
1215 aMessage.ReadL(1, name); |
1215 aMessage.ReadL(1, name); |
1216 aBuffer=HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesLength(2))); |
1216 |
1217 TPtr8 buffer(aBuffer->Des()); |
1217 HBufC8* buffer=NULL; |
1218 aMessage.ReadL(2, buffer); |
1218 TInt error=KErrNone; |
|
1219 TInt bufferSize= aMessage.GetDesLength(2); |
|
1220 User::LeaveIfError(bufferSize); |
|
1221 //Allocate memory in apparc's process heap. |
|
1222 TRAP(error, buffer=HBufC8::NewL(bufferSize)); |
|
1223 |
|
1224 if(error==KErrNone) |
|
1225 { |
|
1226 CleanupStack::PushL(buffer); |
|
1227 TPtr8 bufPtr(buffer->Des()); |
|
1228 aMessage.ReadL(2, bufPtr); |
|
1229 return bufPtr; |
|
1230 } |
|
1231 else if(error==KErrNoMemory) |
|
1232 { |
|
1233 //If memory is not available in apparc's process heap, then allocate in kernel heap |
|
1234 User::LeaveIfError(aLocalChunk.CreateLocal(bufferSize,bufferSize)); |
|
1235 CleanupClosePushL(aLocalChunk); |
|
1236 TPtr8 bufPtr(aLocalChunk.Base(), bufferSize); |
|
1237 aMessage.ReadL(2, bufPtr); |
|
1238 return bufPtr; |
|
1239 } |
|
1240 else |
|
1241 { |
|
1242 User::Leave(error); |
|
1243 } |
|
1244 |
|
1245 TPtrC8 bufPtr(NULL,0); //Never executed. To make compiler happy |
|
1246 return bufPtr; |
1219 } |
1247 } |
1220 |
1248 |
1221 void CApaAppArcServSession::RecognizeDataL(const RMessage2& aMessage) |
1249 void CApaAppArcServSession::RecognizeDataL(const RMessage2& aMessage) |
1222 // Recognize the data type of an object |
1250 // Recognize the data type of an object |
1223 { |
1251 { |
1224 HBufC* name=NULL; |
1252 HBufC* name=NULL; |
1225 HBufC8* buffer=NULL; |
1253 RChunk localChunk; |
1226 DoRecognizeUnpackLC(name,buffer,aMessage); |
1254 |
1227 |
1255 TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage); |
1228 const TDataRecognitionResult result = iServ.RecognizeDataL(*name, *buffer); |
1256 |
1229 |
1257 const TDataRecognitionResult result = iServ.RecognizeDataL(*name, bufPtr); |
1230 CleanupStack::PopAndDestroy(2); // name & buffer |
1258 |
|
1259 CleanupStack::PopAndDestroy(2); // name & buffer or localChunk |
1231 aMessage.WriteL(0,TPckgC<TDataRecognitionResult>(result)); |
1260 aMessage.WriteL(0,TPckgC<TDataRecognitionResult>(result)); |
1232 } |
1261 } |
1233 |
1262 |
1234 |
1263 |
1235 void CApaAppArcServSession::RecognizeFilesL(const RMessage2& aMessage) |
1264 void CApaAppArcServSession::RecognizeFilesL(const RMessage2& aMessage) |
1504 |
1533 |
1505 void CApaAppArcServSession::RecognizeSpecificDataL(const RMessage2& aMessage) |
1534 void CApaAppArcServSession::RecognizeSpecificDataL(const RMessage2& aMessage) |
1506 // Determine whether an object is of a specific data type |
1535 // Determine whether an object is of a specific data type |
1507 { |
1536 { |
1508 HBufC* name=NULL; |
1537 HBufC* name=NULL; |
1509 HBufC8* buffer=NULL; |
1538 RChunk localChunk; |
1510 DoRecognizeUnpackLC(name,buffer,aMessage); |
1539 |
|
1540 TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage); |
1511 TDataType dataType; |
1541 TDataType dataType; |
1512 {TPckg<TDataType> dataType_asDescriptor(dataType); |
1542 {TPckg<TDataType> dataType_asDescriptor(dataType); |
1513 aMessage.ReadL(0, dataType_asDescriptor);} |
1543 aMessage.ReadL(0, dataType_asDescriptor);} |
1514 aMessage.Complete(iServ.RecognizeDataL(*name,*buffer,dataType)); |
1544 aMessage.Complete(iServ.RecognizeDataL(*name,bufPtr,dataType)); |
1515 CleanupStack::PopAndDestroy(2); // name & buffer |
1545 CleanupStack::PopAndDestroy(2); // name & buffer or localChunk |
1516 } |
1546 } |
1517 |
1547 |
1518 void CApaAppArcServSession::RecognizeSpecificDataPassedByFileHandleL(const RMessage2& aMessage) |
1548 void CApaAppArcServSession::RecognizeSpecificDataPassedByFileHandleL(const RMessage2& aMessage) |
1519 { |
1549 { |
1520 RFile file; |
1550 RFile file; |