datacommsserver/esockserver/CoreProviders/src/corescpr.cpp
changeset 0 dfb7c4ff071f
child 18 9644881fedd0
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2006-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 // Core SCPR Implementation
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include "corescpr.h"
       
    24 #include <comms-infras/corescprstates.h>
       
    25 #include <comms-infras/corescpractivities.h>
       
    26 
       
    27 #include <comms-infras/ss_log.h>
       
    28 #include <comms-infras/ss_nodeinterfaces.h>
       
    29 #include <comms-infras/ss_nodemessages_factory.h>
       
    30 #include <elements/sm_statetriple.h>
       
    31 #include <elements/nm_signatures.h>
       
    32 
       
    33 #if defined(__CFLOG_ACTIVE) || defined(SYMBIAN_TRACE_ENABLE)
       
    34 	_LIT8(KCoreSCPRSubTag, "corescpr");
       
    35 #endif
       
    36 
       
    37 using namespace ESock;
       
    38 using namespace NetStateMachine;
       
    39 using namespace Messages;
       
    40 using namespace MeshMachine;
       
    41 
       
    42 //We reserve space for two preallocated activities that may start concurrently on the SCPR
       
    43 //node: destroy and data client stop.
       
    44 static const TUint KDefaultMaxPreallocatedActivityCount = 2;
       
    45 static const TUint KMaxPreallocatedActivitySize = sizeof(MeshMachine::CNodeRetryParallelActivity) + sizeof(MeshMachine::APreallocatedOriginators<4>);
       
    46 static const TUint KSCPRPreallocatedActivityBufferSize = KDefaultMaxPreallocatedActivityCount * KMaxPreallocatedActivitySize;
       
    47 
       
    48 EXPORT_C CCoreSubConnectionProvider::CCoreSubConnectionProvider(CSubConnectionProviderFactoryBase& aFactory,
       
    49                                                                 const MeshMachine::TNodeActivityMap& aActivityMap)
       
    50 :CSubConnectionProviderBase(aFactory,aActivityMap)
       
    51 	{
       
    52 	LOG_NODE_CREATE(KCoreSCPRSubTag, CCoreSubConnectionProvider);
       
    53 	}
       
    54 
       
    55 EXPORT_C CCoreSubConnectionProvider::CCoreSubConnectionProvider(CSubConnectionProviderFactoryBase& aFactory)
       
    56 :CSubConnectionProviderBase(aFactory,SCprActivities::coreSCprActivities::Self())
       
    57 	{
       
    58 	LOG_NODE_CREATE(KCoreSCPRSubTag, CCoreSubConnectionProvider);
       
    59 	}
       
    60 
       
    61 EXPORT_C CCoreSubConnectionProvider* CCoreSubConnectionProvider::NewL(CSubConnectionProviderFactoryBase& aFactory)
       
    62 	{
       
    63     CCoreSubConnectionProvider* provider = new (ELeave) CCoreSubConnectionProvider(aFactory);
       
    64     CleanupStack::PushL(provider);
       
    65     provider->ConstructL(KSCPRPreallocatedActivityBufferSize);
       
    66     CleanupStack::Pop();
       
    67     return provider;
       
    68 	}
       
    69 
       
    70 EXPORT_C CCoreSubConnectionProvider::~CCoreSubConnectionProvider()
       
    71 	{
       
    72 	LOG_NODE_DESTROY(KCoreSCPRSubTag, CCoreSubConnectionProvider);
       
    73 	}
       
    74 
       
    75 EXPORT_C void CCoreSubConnectionProvider::Received(TNodeContextBase& aContext)
       
    76     {
       
    77     Messages::TNodeSignal::TMessageId noPeerIds[] = {
       
    78         TCFFactory::TPeerFoundOrCreated::Id(),
       
    79         TCFPeer::TJoinRequest::Id(),
       
    80         Messages::TNodeSignal::TMessageId()
       
    81         };
       
    82     MeshMachine::AMMNodeBase::Received(noPeerIds, aContext);
       
    83 	MeshMachine::AMMNodeBase::PostReceived(aContext);
       
    84 	}
       
    85 
       
    86 EXPORT_C void CCoreSubConnectionProvider::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aMessage)
       
    87     {
       
    88 	TNodeContext<CCoreSubConnectionProvider> ctx(*this, aMessage, aSender, aRecipient);
       
    89     CCoreSubConnectionProvider::Received(ctx);
       
    90     User::LeaveIfError(ctx.iReturn);
       
    91 	}
       
    92 
       
    93 
       
    94