appfw/apparchitecture/apserv/APSSES.CPP
changeset 48 2222076f5c60
parent 29 6a787171e1de
child 69 dcd4152cfe55
equal deleted inserted replaced
40:951aeeb3da43 48:2222076f5c60
   419 	delete iOpaqueData_pendingDispatchToClient;
   419 	delete iOpaqueData_pendingDispatchToClient;
   420 	}
   420 	}
   421 
   421 
   422 void CApaAppArcServSession::ServiceL(const RMessage2& aMessage)
   422 void CApaAppArcServSession::ServiceL(const RMessage2& aMessage)
   423 	{
   423 	{
   424 #ifdef _DEBUG    
   424 #ifdef APPARC_SHOW_TRACE    
   425     TFullName* name = new(ELeave) TFullName();
   425     TFullName* name = new(ELeave) TFullName();
   426     RThread client;
   426     RThread client;
   427     if ( aMessage.Client( client ) == KErrNone )
   427     if ( aMessage.Client( client ) == KErrNone )
   428         {
   428         {
   429         client.FullName( *name );
   429         client.FullName( *name );
   622 		REComSession::FinalClose();
   622 		REComSession::FinalClose();
   623 	#endif
   623 	#endif
   624 		break;
   624 		break;
   625 	default:
   625 	default:
   626 		iAppListSession->DoServiceL(aMessage);
   626 		iAppListSession->DoServiceL(aMessage);
   627 #ifdef _DEBUG   
   627 #ifdef APPARC_SHOW_TRACE   
   628 		RDebug::Print( _L("[Apparc] CApaAppListServSession::ServiceL(0x%08x) - END - op code: %04d, completeMessage: %d"), this, aMessage.Function(), completeMessage );
   628 		RDebug::Print( _L("[Apparc] CApaAppListServSession::ServiceL(0x%08x) - END - op code: %04d, completeMessage: %d"), this, aMessage.Function(), completeMessage );
   629 #endif		
   629 #endif		
   630 		return;
   630 		return;
   631 		}
   631 		}
   632 	
   632 	
   633 #ifdef _DEBUG 	
   633 #ifdef APPARC_SHOW_TRACE 	
   634     RDebug::Print( _L("[Apparc] CApaAppListServSession::ServiceL(0x%08x) - END - op code: %04d, completeMessage: %d"), this, aMessage.Function(), completeMessage );
   634     RDebug::Print( _L("[Apparc] CApaAppListServSession::ServiceL(0x%08x) - END - op code: %04d, completeMessage: %d"), this, aMessage.Function(), completeMessage );
   635 #endif	
   635 #endif	
   636 	if (completeMessage && !aMessage.IsNull())
   636 	if (completeMessage && !aMessage.IsNull())
   637 		aMessage.Complete(KErrNone);
   637 		aMessage.Complete(KErrNone);
   638 	}
   638 	}
  1454 	aInfo.iFullName = entry.iFullName;
  1454 	aInfo.iFullName = entry.iFullName;
  1455 	aInfo.iCaption = app->Caption();
  1455 	aInfo.iCaption = app->Caption();
  1456 	aInfo.iShortCaption = app->ShortCaption();
  1456 	aInfo.iShortCaption = app->ShortCaption();
  1457 	}
  1457 	}
  1458 	
  1458 	
  1459 void CApaAppArcServSession::DoRecognizeUnpackLC(HBufC*& aName, HBufC8*& aBuffer, const RMessage2& aMessage)
  1459 TPtrC8 CApaAppArcServSession::DoRecognizeUnpackLC(HBufC*& aName, RChunk& aLocalChunk, const RMessage2& aMessage)
  1460 	{
  1460     {
  1461 	ASSERT(aName==NULL);
  1461     ASSERT(aName==NULL);
  1462 	ASSERT(aBuffer==NULL);
  1462     
  1463 	aName=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1)));
  1463     aName=HBufC::NewLC(User::LeaveIfError(aMessage.GetDesLength(1)));
  1464 	TPtr name(aName->Des());
  1464     TPtr name(aName->Des());
  1465 	aMessage.ReadL(1, name);
  1465     aMessage.ReadL(1, name);
  1466 	aBuffer=HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesLength(2)));
  1466     
  1467 	TPtr8 buffer(aBuffer->Des());
  1467     HBufC8* buffer=NULL;
  1468 	aMessage.ReadL(2, buffer);
  1468     TInt error=KErrNone;
  1469 	}
  1469     TInt bufferSize= aMessage.GetDesLength(2);
       
  1470     User::LeaveIfError(bufferSize);
       
  1471     //Allocate memory in apparc's process heap.
       
  1472     TRAP(error, buffer=HBufC8::NewL(bufferSize));
       
  1473 
       
  1474     if(error==KErrNone)
       
  1475         {
       
  1476         CleanupStack::PushL(buffer);
       
  1477         TPtr8 bufPtr(buffer->Des());
       
  1478         aMessage.ReadL(2, bufPtr);   
       
  1479         return bufPtr;
       
  1480         }
       
  1481     else if(error==KErrNoMemory)
       
  1482         {
       
  1483         //If memory is not available in apparc's process heap, then allocate in kernel heap
       
  1484         User::LeaveIfError(aLocalChunk.CreateLocal(bufferSize,bufferSize));
       
  1485         CleanupClosePushL(aLocalChunk);
       
  1486         TPtr8 bufPtr(aLocalChunk.Base(), bufferSize);
       
  1487         aMessage.ReadL(2, bufPtr); 
       
  1488         return bufPtr;        
       
  1489         }
       
  1490     else
       
  1491         {
       
  1492         User::Leave(error);
       
  1493         }
       
  1494     
       
  1495     TPtrC8 bufPtr(NULL,0); //Never executed. To make compiler happy
       
  1496     return bufPtr;
       
  1497     }
  1470 
  1498 
  1471 void CApaAppArcServSession::RecognizeDataL(const RMessage2& aMessage)
  1499 void CApaAppArcServSession::RecognizeDataL(const RMessage2& aMessage)
  1472 // Recognize the data type of an object
  1500 // Recognize the data type of an object
  1473 	{
  1501     {
  1474 	HBufC* name=NULL;
  1502     HBufC* name=NULL;
  1475 	HBufC8* buffer=NULL;
  1503     RChunk localChunk;
  1476 	DoRecognizeUnpackLC(name,buffer,aMessage);
  1504     
  1477 
  1505     TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage);
  1478 	const TDataRecognitionResult result = iServ.RecognizeDataL(*name, *buffer);
  1506 
  1479 
  1507     const TDataRecognitionResult result = iServ.RecognizeDataL(*name, bufPtr);
  1480 	CleanupStack::PopAndDestroy(2); // name & buffer
  1508 
  1481 	aMessage.WriteL(0,TPckgC<TDataRecognitionResult>(result));
  1509     CleanupStack::PopAndDestroy(2); // name & buffer or localChunk
  1482 	}
  1510     aMessage.WriteL(0,TPckgC<TDataRecognitionResult>(result));
       
  1511     }
  1483 
  1512 
  1484 
  1513 
  1485 void CApaAppArcServSession::RecognizeFilesL(const RMessage2& aMessage)
  1514 void CApaAppArcServSession::RecognizeFilesL(const RMessage2& aMessage)
  1486 	{
  1515 	{
  1487 	// if there is an outstanding async. request, we even don't allow 
  1516 	// if there is an outstanding async. request, we even don't allow 
  1752 	aMessage.WriteL(0, TPckgC<TDataRecognitionResult>(result));
  1781 	aMessage.WriteL(0, TPckgC<TDataRecognitionResult>(result));
  1753 	}
  1782 	}
  1754 	
  1783 	
  1755 void CApaAppArcServSession::RecognizeSpecificDataL(const RMessage2& aMessage)
  1784 void CApaAppArcServSession::RecognizeSpecificDataL(const RMessage2& aMessage)
  1756 // Determine whether an object is of a specific data type
  1785 // Determine whether an object is of a specific data type
  1757 	{
  1786     {
  1758 	HBufC* name=NULL;
  1787     HBufC* name=NULL;
  1759 	HBufC8* buffer=NULL;
  1788     RChunk localChunk;
  1760 	DoRecognizeUnpackLC(name,buffer,aMessage);
  1789     
  1761 	TDataType dataType;
  1790     TPtrC8 bufPtr=DoRecognizeUnpackLC(name, localChunk, aMessage);
  1762 	{TPckg<TDataType> dataType_asDescriptor(dataType);
  1791     TDataType dataType;
  1763 	aMessage.ReadL(0, dataType_asDescriptor);}
  1792     {TPckg<TDataType> dataType_asDescriptor(dataType);
  1764 	aMessage.Complete(iServ.RecognizeDataL(*name,*buffer,dataType));
  1793     aMessage.ReadL(0, dataType_asDescriptor);}
  1765 	CleanupStack::PopAndDestroy(2); // name & buffer
  1794     aMessage.Complete(iServ.RecognizeDataL(*name,bufPtr,dataType));
  1766 	}
  1795     CleanupStack::PopAndDestroy(2); // name & buffer or localChunk
       
  1796     }
  1767 
  1797 
  1768 void CApaAppArcServSession::RecognizeSpecificDataPassedByFileHandleL(const RMessage2& aMessage)
  1798 void CApaAppArcServSession::RecognizeSpecificDataPassedByFileHandleL(const RMessage2& aMessage)
  1769 	{
  1799 	{
  1770 	RFile file;
  1800 	RFile file;
  1771 	CleanupClosePushL(file);
  1801 	CleanupClosePushL(file);