epoc32/include/mmf/common/mmfipc.inl
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2003-2009 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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     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.symbianfoundation.org/legal/licencesv10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    13 // Description:
    13 // Description:
    14 // include\mmf\common\mmfipc.inl
    14 // include\mmf\common\mmfipc.inl
    15 // 
    15 // 
    16 //
    16 //
    17 
    17 
    18 #ifdef __MMF_USE_IPC_V2__
       
    19 
       
    20 //
       
    21 // CMmfIpcSession
       
    22 //
       
    23 
       
    24 inline void CMmfIpcSession::CreateL(const CMmfIpcServer& /*aServer*/)
       
    25 	{
       
    26 	// default does nothing
       
    27 	} 
       
    28 	
       
    29 inline void CMmfIpcSession::CreateL() 
       
    30 	{ 
       
    31 	const CMmfIpcServer* server = static_cast<const CMmfIpcServer*>(Server());
       
    32 	CreateL(*server); // simulate CSession::CreateL() call
       
    33 	}
       
    34 
       
    35 //
       
    36 // CMmfIcpServer
       
    37 //
       
    38 
       
    39 inline CMmfIpcServer::CMmfIpcServer(TInt aPriority,TServerType aType):
       
    40 	CServer2(aPriority,aType)
       
    41 	{
       
    42 	}
       
    43 
       
    44 inline CSession2* CMmfIpcServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const
       
    45 	{
       
    46 	return NewSessionL(aVersion);
       
    47 	}
       
    48 
       
    49 #endif //__MMF_USE_IPC_V2__
       
    50 
    18 
    51 //
    19 //
    52 // RMmfSessionBase
    20 // RMmfSessionBase
    53 //
    21 //
    54 
    22 
   290 	p[3] = static_cast<TAny*>(&aResult);
   258 	p[3] = static_cast<TAny*>(&aResult);
   291 	RSessionBase::SendReceive(aFunction, p, aStatus);
   259 	RSessionBase::SendReceive(aFunction, p, aStatus);
   292 #endif //__MMF_USE_IPC_V2__
   260 #endif //__MMF_USE_IPC_V2__
   293 	}
   261 	}
   294 	
   262 	
   295 //
       
   296 // MmfMessageUtil
       
   297 //
       
   298 
       
   299 inline void MmfMessageUtil::ReadL(const RMmfIpcMessage& aMessage, TInt aParam, TDes8& aResult)
       
   300 	{
       
   301 #ifdef __MMF_USE_IPC_V2__
       
   302 	User::LeaveIfError(aMessage.Read(aParam, aResult));
       
   303 #else
       
   304 	// expect aParam to be a literal - so this code should optimise out
       
   305 	if (aParam==0)
       
   306 		aMessage.ReadL(aMessage.Ptr0(), aResult);
       
   307 	else if (aParam==1)
       
   308 		aMessage.ReadL(aMessage.Ptr1(), aResult);
       
   309 	else if (aParam==2)
       
   310 		aMessage.ReadL(aMessage.Ptr2(), aResult);
       
   311 	else if (aParam==3)
       
   312 		aMessage.ReadL(aMessage.Ptr3(), aResult);
       
   313 	else
       
   314 		User::Leave(KErrArgument);
       
   315 #endif //__MMF_USE_IPC_V2__
       
   316 	}
       
   317 
       
   318 inline void MmfMessageUtil::WriteL(const RMmfIpcMessage& aMessage, TInt aParam, const TDesC8& aValue)
       
   319 	{
       
   320 #ifdef __MMF_USE_IPC_V2__
       
   321 	User::LeaveIfError(aMessage.Write(aParam, aValue));
       
   322 #else
       
   323 	// expect aParam to be a literal - so this code should optimise out
       
   324 	if (aParam==0)
       
   325 		aMessage.WriteL(aMessage.Ptr0(), aValue);
       
   326 	else if (aParam==1)
       
   327 		aMessage.WriteL(aMessage.Ptr1(), aValue);
       
   328 	else if (aParam==2)
       
   329 		aMessage.WriteL(aMessage.Ptr2(), aValue);
       
   330 	else if (aParam==3)
       
   331 		aMessage.WriteL(aMessage.Ptr3(), aValue);
       
   332 	else
       
   333 		User::Leave(KErrArgument);
       
   334 #endif //__MMF_USE_IPC_V2__
       
   335 	}
       
   336 
       
   337 inline TInt MmfMessageUtil::Read(const RMmfIpcMessage& aMessage, TInt aParam, TDes8& aResult)
       
   338 	{
       
   339 #ifdef __MMF_USE_IPC_V2__
       
   340 	return aMessage.Read(aParam, aResult);
       
   341 #else
       
   342 	TRAPD(error, ReadL(aMessage, aParam, aResult));
       
   343 	return error;
       
   344 #endif //__MMF_USE_IPC_V2__
       
   345 	}
       
   346 
       
   347 inline TInt MmfMessageUtil::Write(const RMmfIpcMessage& aMessage, TInt aParam, const TDesC8& aValue)
       
   348 	{
       
   349 #ifdef __MMF_USE_IPC_V2__
       
   350 	return aMessage.Write(aParam, aValue);
       
   351 #else
       
   352 	TRAPD(error, WriteL(aMessage, aParam, aValue));
       
   353 	return error;
       
   354 #endif //__MMF_USE_IPC_V2__
       
   355 }
       
   356 
       
   357 //TDesC versions
   263 //TDesC versions
   358 
   264 
   359 inline void RMmfSessionBase::SendReceive(TInt aFunction, const TDesC& aParam0, TRequestStatus& aStatus) const
   265 inline void RMmfSessionBase::SendReceive(TInt aFunction, const TDesC& aParam0, TRequestStatus& aStatus) const
   360 	{
   266 	{
   361 #ifdef __MMF_USE_IPC_V2__
   267 #ifdef __MMF_USE_IPC_V2__