datacommsserver/esockserver/ssock/ss_mmnode_subsess.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "ss_mmnode_subsess.h"
       
    17 #include "ss_apiext_messages.h"
       
    18 #include <comms-infras/ss_nodemessages_internal_esock.h>
       
    19 
       
    20 using namespace ESock;
       
    21 using namespace Messages;
       
    22 using namespace MeshMachine;
       
    23 
       
    24 void CMMSockSubSession::HandleMessageReturnValue(TNodeContextBase& aContext)
       
    25     {
       
    26 	TCFInternalEsock::TSubSess* msg = message_cast<TCFInternalEsock::TSubSess>(&aContext.iMessage);
       
    27 	if (msg && !msg->iMessage.IsNull())
       
    28 		{
       
    29 		msg->iMessage.Complete(aContext.iReturn);
       
    30 		DontCompleteCurrentRequest();
       
    31 		}
       
    32 	else
       
    33     	{
       
    34     	MeshMachine::AMMNodeBase::HandleMessageReturnValue(aContext);
       
    35     	}
       
    36     }
       
    37 
       
    38 void CMMSockSubSession::ConstructL()
       
    39     {
       
    40     CSockSubSession::ConstructL(NULL);
       
    41     ACFMMNodeIdBase::ConstructL();
       
    42     }
       
    43 
       
    44 
       
    45 //Very useful function not to have to construct a message on the stack
       
    46 void CMMSockSubSession::ReceivedL(TUint16 aIpcId, const Messages::TSignatureBase& aCFMessage)
       
    47 	{
       
    48 	static_cast<Messages::ANode*>(this)->ReceivedL(TNodeCtxId(aIpcId, Id()), TNodeCtxId(aIpcId, Id()), const_cast<Messages::TSignatureBase&>(aCFMessage));
       
    49 	}
       
    50 
       
    51 //This function could be specialised by any of the subsessions
       
    52 void CMMSockSubSession::CommsApiExtBindIfaceL(const RMessage2& aMessage)
       
    53 	{
       
    54 	const RNodeInterface* sp = ServiceProvider();
       
    55 	if (sp)
       
    56     	{
       
    57 		TSupportedCommsApiExt interfaceId = static_cast<TSupportedCommsApiExt>(aMessage.Int0());
       
    58 		TOpenExtensionInterface msg(UniqueId(), interfaceId, aMessage);
       
    59     	sp->PostMessage(Id(), msg);
       
    60     	DontCompleteCurrentRequest();
       
    61     	}
       
    62     else
       
    63         {
       
    64         User::Leave(KErrNotReady);
       
    65         }
       
    66 	}
       
    67 
       
    68 //This function could be specialised by any of the subsessions
       
    69 void CMMSockSubSession::CommsApiExtIfaceSendReceiveL(const RMessage2& aMessage)
       
    70 	{
       
    71 	const RNodeInterface* sp = ServiceProvider();
       
    72 	if (sp)
       
    73     	{
       
    74 		Elements::RResponseMsg responseMsg(aMessage, aMessage.Int0(), 1, 2);
       
    75 		TApiExtMsgDispatcher msgDispatcher(UniqueId(), responseMsg);
       
    76     	sp->PostMessage(Id(), msgDispatcher);
       
    77     	DontCompleteCurrentRequest();
       
    78     	}
       
    79     else
       
    80         {
       
    81         User::Leave(KErrNotReady);
       
    82         }
       
    83 
       
    84 	}
       
    85 
       
    86 //This function could be specialised by any of the subsessions
       
    87 void CMMSockSubSession::CloseExtensionInterface(const RMessage2& aMessage)
       
    88 	{
       
    89 	const RNodeInterface* sp = ServiceProvider();
       
    90 	if (sp)
       
    91     	{
       
    92 		TSupportedCommsApiExt interfaceId = static_cast<TSupportedCommsApiExt>(aMessage.Int0());
       
    93 		TCloseExtensionInterface msg(UniqueId(), interfaceId, aMessage);
       
    94     	sp->PostMessage(Id(), msg);
       
    95     	DontCompleteCurrentRequest();
       
    96     	}
       
    97 	}
       
    98 
       
    99 //This function could be specialised by any of the subsessions
       
   100 void CMMSockSubSession::CancelAndCloseAllClientExtIfaces()
       
   101 	{
       
   102 	const RNodeInterface* sp = ServiceProvider();
       
   103 	if(sp)
       
   104 		{
       
   105 		TCancelAndCloseAllClientExtItf msg(UniqueId());
       
   106 		sp->PostMessage(Id(), msg);
       
   107 		}
       
   108 	}
       
   109 
       
   110