telephonyprotocols/rawipnif/src/rawipmcpr.cpp
changeset 0 3553901f7fa8
child 19 630d2f34d719
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     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 // RawIP MCPR
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include <comms-infras/ss_log.h>
       
    24 #include "rawipmcpr.h"
       
    25 #include <comms-infras/linkprovision.h>
       
    26 #include "RawIpAgentHandler.h"
       
    27 #include <comms-infras/agentmcpractivities.h>
       
    28 #include <comms-infras/coremcpractivities.h>
       
    29 #include <comms-infras/ss_msgintercept.h>
       
    30 
       
    31 using namespace ESock;
       
    32 using namespace NetStateMachine;
       
    33 using namespace MCprActivities;
       
    34 using namespace Messages;
       
    35 using namespace MeshMachine;
       
    36 
       
    37 
       
    38 // No Bearer Activity
       
    39 namespace RawIPMCPRNoBearerActivity
       
    40 {
       
    41 DECLARE_DEFINE_NODEACTIVITY(ECFActivityNoBearer, activity, TCFControlProvider::TNoBearer)
       
    42 	FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingNoBearer, MeshMachine::TNoTag)
       
    43 	LAST_NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendBearer)
       
    44 NODEACTIVITY_END()
       
    45 }
       
    46 
       
    47 // Activity Map
       
    48 namespace RawIPMCprStates
       
    49 {
       
    50 DECLARE_DEFINE_ACTIVITY_MAP(stateMap)
       
    51    ACTIVITY_MAP_ENTRY(RawIPMCPRNoBearerActivity, activity)
       
    52 ACTIVITY_MAP_END_BASE(AgentMCprActivities, agentMCprActivities)
       
    53 } // namespace RawIPMCprStates
       
    54 
       
    55 //-=========================================================
       
    56 //
       
    57 //CRawIpMetaConnectionProvider implementation
       
    58 //
       
    59 //-=========================================================
       
    60 
       
    61 CRawIpMetaConnectionProvider* CRawIpMetaConnectionProvider::NewL(ESock::CMetaConnectionProviderFactoryBase& aFactory, const TProviderInfo& aProviderInfo)
       
    62     {
       
    63     // coverity[alloc_fn] coverity[alias] coverity[assign]
       
    64     CRawIpMetaConnectionProvider* self = new (ELeave) CRawIpMetaConnectionProvider(aFactory, aProviderInfo);
       
    65     // coverity[push]
       
    66     CleanupStack::PushL(self);
       
    67     // coverity[alias] coverity[double_push]
       
    68     self->ConstructL();
       
    69     CleanupStack::Pop(self);
       
    70     return self;
       
    71     }
       
    72 
       
    73 void CRawIpMetaConnectionProvider::ConstructL()
       
    74 	{
       
    75 	CAgentMetaConnectionProvider::ConstructL();
       
    76 	SetAccessPointConfigFromDbL();
       
    77 	}
       
    78 
       
    79 CRawIpMetaConnectionProvider::CRawIpMetaConnectionProvider(CMetaConnectionProviderFactoryBase& aFactory, const TProviderInfo& aProviderInfo)
       
    80 :	CAgentMetaConnectionProvider(aFactory, aProviderInfo, RawIPMCprStates::stateMap::Self())
       
    81 	{
       
    82 	LOG_NODE_CREATE(KRawIPMCprTag, CRawIpMetaConnectionProvider);
       
    83 	}
       
    84 
       
    85 CRawIpMetaConnectionProvider::~CRawIpMetaConnectionProvider()
       
    86 	{
       
    87 	// Cleanup up Agent Notification Handler
       
    88 	SetAgentNotificationHandlerL(NULL);
       
    89 	delete iAgentHandler;
       
    90 
       
    91 	LOG_NODE_DESTROY(KRawIPMCprTag, CRawIpMetaConnectionProvider);
       
    92 	}
       
    93 
       
    94 void CRawIpMetaConnectionProvider::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aMessage)
       
    95     {
       
    96 	__CFLOG_VAR((KRawIPMCprTag, KRawIPMCprSubTag, _L8("CRawIpMetaConnectionProvider [this=%08x]::ReceivedL() aCFMessage=%d"),
       
    97 	   this, aCFMessage.MessageId()));
       
    98 
       
    99 	ESOCK_DEBUG_MESSAGE_INTERCEPT(aSender, aMessage, aRecipient);
       
   100 
       
   101 	TNodeContext<CRawIpMetaConnectionProvider> ctx(*this, aMessage, aSender, aRecipient);
       
   102     CCoreMetaConnectionProvider::Received(ctx);
       
   103     User::LeaveIfError(ctx.iReturn);
       
   104 	}
       
   105 
       
   106 void CRawIpMetaConnectionProvider::SetAccessPointConfigFromDbL()
       
   107 /**
       
   108 Setup provisioning information
       
   109 */
       
   110     {
       
   111     RMetaExtensionContainer mec;
       
   112     mec.Open(AccessPointConfig());
       
   113     CleanupClosePushL(mec);
       
   114     
       
   115 	CCommsDatIapView* iapView = OpenIapViewLC();
       
   116 
       
   117 	// Presumptions:
       
   118 	// - none of the extensions can already exist in the AccessPointConfig array.  AppendExtensionL()
       
   119 	//   is presumed to panic if adding the same extension a second time.
       
   120 	// - if we have added several extensions to the AccessPointConfig array before getting a failure
       
   121 	//   and leaving, it is presumed that the MCPr will be destroyed and AccessPointConfig destructor
       
   122 	//   will clean up the extensions immediately afterwards.
       
   123 
       
   124 	mec.AppendExtensionL(CIPConfig::NewFromGPRSOutLC(iapView));
       
   125 	CleanupStack::Pop(); //Ownership with the list
       
   126 
       
   127 	mec.AppendExtensionL(CBCAProvision::NewLC(iapView));
       
   128 	CleanupStack::Pop(); //Ownership with the list
       
   129 
       
   130 	CleanupStack::PopAndDestroy();			// CloseIapView();
       
   131 
       
   132 	iAccessPointConfig.Close();
       
   133 	iAccessPointConfig.Open(mec);
       
   134 	CleanupStack::PopAndDestroy(&mec);
       
   135 
       
   136 	// Setup RawIp Agent Notification handler in order to retrieve TSY and connection speed
       
   137 	// information from the Agent once ConnectComplete() occurs.
       
   138 	ASSERT(iAgentHandler == NULL);
       
   139 	iAgentHandler = new (ELeave) CRawIpAgentHandler;
       
   140 	SetAgentNotificationHandlerL(iAgentHandler);	// ownership NOT transferred
       
   141 	}
       
   142