Exemplo n.º 1
0
void CSandboxSession::ServiceL(const RMessage2 &aMessage)
	{
	if (aMessage.Function() >= EMaxArgs)
		{
		aMessage.Complete(KErrArgument);
		return;
		}

	if (aMessage.Function() == EGetRecog2)
		{
		aMessage.WriteL(0, iBuf);
		iBuf.Close();
		aMessage.Complete(KErrNone);
		}
	else if (aMessage.Function() == EGetRecog)
		{
		if (iBuf.MaxLength() == 0)
			{
			iBuf.ReAllocL(1024); // Must be > sizeof(TDataType) otherwise the reallocating logic below is flawed
			}
		TUid uid = TUid::Uid(aMessage.Int0());
		TUid destructorKey;
		CApaDataRecognizerType* rec = static_cast<CApaDataRecognizerType*>(REComSession::CreateImplementationL(uid, destructorKey));
		TInt count = rec->MimeTypesCount();
		for (TInt j = 0; j < count; j++)
			{
			TDataType type = rec->SupportedDataTypeL(j);
			TPckg<TDataType> buf(type);
			if (iBuf.Length() + buf.Length() >= iBuf.MaxLength())
				{
				iBuf.ReAllocL(iBuf.MaxLength() * 2);
				}
			iBuf.Append(buf);
			}

		aMessage.Complete(iBuf.Size());
		}
	else if (aMessage.Function() == ECloseServer)
		{
		aMessage.Complete(KErrNone);
		CActiveScheduler::Stop();
		}
	else if (aMessage.Function() == EGetVTablePtr)
		{
		TUid destructorKey;
		TAny* obj = NULL;
		obj = REComSession::CreateImplementationL(TUid::Uid(aMessage.Int0()), destructorKey);
		TAny* vtablePtr = *((TAny**)obj);	
		TPckg<TAny*> res(vtablePtr);
		aMessage.WriteL(1, res);
		aMessage.Complete(KErrNone);
		}
	else
		{
		ASSERT(0);
		}
	}
Exemplo n.º 2
0
// -----------------------------------------------------------------------------
// XIMPRBuf8Helper::GrowIfNeededL()
// -----------------------------------------------------------------------------
//
EXPORT_C void XIMPRBuf8Helper::GrowIfNeededL( RBuf8& aBuf, const TInt aMaxLength )
    {
    if ( aBuf.MaxLength() < aMaxLength )
        {
        aBuf.ReAllocL( aMaxLength );
        }
    }