telephonyprotocols/pdplayer/umts/spudfsm/src/cpdpfsmfactory.cpp
branchRCL_3
changeset 66 07a122eea281
parent 65 630d2f34d719
equal deleted inserted replaced
65:630d2f34d719 66:07a122eea281
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-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 "Eclipse Public License v1.0"
     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.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 /**
    18 /**
    19  @file 
    19  @file 
    20  @internalComponent
    20  @internalComponent
    21 */
    21 */
    22  
    22  
    23 
       
    24 
       
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "cpdpfsmfactoryTraces.h"
       
    28 #endif
       
    29 
       
    30 #include "cpdpfsmfactory.h"
    23 #include "cpdpfsmfactory.h"
       
    24 #include "spudfsmdebuglogger.h"
    31 
    25 
    32 // NewL 
    26 // NewL 
    33 CPdpFsmFactory* CPdpFsmFactory::NewL ()
    27 CPdpFsmFactory* CPdpFsmFactory::NewL ()
    34     {
    28     {
    35 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_NEWL_1, ">>CPdpFsmFactory::NewL()");
    29 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::NewL()");
    36 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_NEWL_2, "<<CPdpFsmFactory::NewL()");
    30 	
    37 	return new (ELeave) CPdpFsmFactory ();	
    31 	return new (ELeave) CPdpFsmFactory ();	
    38     }
    32     }
    39 
    33 
    40 #if defined(__VC32__)
    34 #if defined(__VC32__)
    41 #if (_MSC_VER >= 1200)
    35 #if (_MSC_VER >= 1200)
    68   iStateStopping (this),
    62   iStateStopping (this),
    69   iStateCreatingMbms(this),
    63   iStateCreatingMbms(this),
    70   iStateActivatingMbms(this),
    64   iStateActivatingMbms(this),
    71   iStateCreatedMbms(this)
    65   iStateCreatedMbms(this)
    72     {
    66     {
    73 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_CTOR_1, ">>CPdpFsmFactory::CPdpFsmFactory()");
    67 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::CPdpFsmFactory()");
    74 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_CTOR_2, "<<CPdpFsmFactory::CPdpFsmFactory()");
       
    75     }
    68     }
    76 
    69 
    77 
    70 
    78 CPdpFsmFactory::~CPdpFsmFactory()
    71 CPdpFsmFactory::~CPdpFsmFactory()
    79     {
    72     {
    80 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_DTOR_1, ">>CPdpFsmFactory::~CPdpFsmFactory()");
    73 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::~CPdpFsmFactory()");
    81 
    74 
    82 	iContexts.DeleteAll();
    75 	iContexts.DeleteAll();
    83     iContexts.Reset();
    76     iContexts.Reset();
    84 	
    77 	
    85     delete iEtelDriverInput;   
    78     delete iEtelDriverInput;   
    86     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_DTOR_2, "<<CPdpFsmFactory::~CPdpFsmFactory()");
       
    87     }
    79     }
    88 
    80 
    89 
    81 
    90 void CPdpFsmFactory::InitL(const TName& aTsyName, CPdpFsmInterface * aPdpFsmInterface)
    82 void CPdpFsmFactory::InitL(const TName& aTsyName, CPdpFsmInterface * aPdpFsmInterface)
    91     {
    83     {
    92 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_INITL_1, ">>CPdpFsmFactory::InitL()");
    84 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::InitL()");
    93 
    85 
    94 	iPdpFsmInterface = aPdpFsmInterface;
    86 	iPdpFsmInterface = aPdpFsmInterface;
    95 	
    87 	
    96 	iTsyName = aTsyName;
    88 	iTsyName = aTsyName;
    97 
    89 
    98 	// lets kick off the ETelDriver first then we only alloc FSMs if it works
    90 	// lets kick off the ETelDriver first then we only alloc FSMs if it works
    99 	//
    91 	//
   100 	iEtelDriverInput = new (ELeave) REtelDriverInput;
    92 	iEtelDriverInput = new (ELeave) REtelDriverInput;
   101 
    93 
   102 	iEtelDriverInput->OpenL (*iPdpFsmInterface);
    94 	iEtelDriverInput->OpenL (*iPdpFsmInterface);
   103 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_INITL_2, "<<CPdpFsmFactory::InitL()");
    95 
   104 	// Only create PDP contexts if specifically requested.
    96 	// Only create PDP contexts if specifically requested.
   105     }
    97     }
   106 
    98 
   107 
    99 
   108 void CPdpFsmFactory::Close (void)
   100 void CPdpFsmFactory::Close (void)
   109     {
   101     {
   110 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_CLOSE_1, ">>CPdpFsmFactory::Close()");
   102 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::Close()");
   111 	// in OOM conditions iEtelDriveInput may not have successfully
   103 	// in OOM conditions iEtelDriveInput may not have successfully
   112 	// been created, check here for safety.
   104 	// been created, check here for safety.
   113 	if (iEtelDriverInput != NULL)
   105 	if (iEtelDriverInput != NULL)
   114 	    {
   106 	    {
   115         iEtelDriverInput->Close();
   107         iEtelDriverInput->Close();
   116 	    }
   108 	    }
   117 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_CLOSE_2, "<<CPdpFsmFactory::Close()");
       
   118     }
   109     }
   119 
   110 
   120 
   111 
   121 /** 
   112 /** 
   122 @return may return NULL if there is no PDP context with that Id
   113 @return may return NULL if there is no PDP context with that Id
   123 */
   114 */
   124 CPdpFsm* CPdpFsmFactory::GetFsmContext (TContextId aPdpId)
   115 CPdpFsm* CPdpFsmFactory::GetFsmContext (TContextId aPdpId)
   125     {
   116     {
   126 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_GETFSMCONTEXT_1, ">>CPdpFsmFactory::GetContext()");
   117 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::GetContext()");
   127 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_GETFSMCONTEXT_2, "<<CPdpFsmFactory::GetContext()");
   118 
   128 	return iContexts[aPdpId];
   119 	return iContexts[aPdpId];
   129     }
   120     }
   130 
   121 
   131 
   122 
   132 const TName& CPdpFsmFactory::TsyName(void)
   123 const TName& CPdpFsmFactory::TsyName(void)
   138 TInt CPdpFsmFactory::NewFsmContext(TContextId aPdpId)
   129 TInt CPdpFsmFactory::NewFsmContext(TContextId aPdpId)
   139 #else
   130 #else
   140 TContextId CPdpFsmFactory::NewFsmContextL(MPdpFsmEventHandler& aPdpFsmEventHandler,SpudMan::TPdpContextType aContextType)
   131 TContextId CPdpFsmFactory::NewFsmContextL(MPdpFsmEventHandler& aPdpFsmEventHandler,SpudMan::TPdpContextType aContextType)
   141 #endif
   132 #endif
   142     {
   133     {
   143 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_NEWFSMCONTEXTL_1, ">>CPdpFsmFactory::NewFsmContext()");
   134 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::NewFsmContext()");
   144 
   135 
   145 #ifndef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
   136 #ifndef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
   146 	TInt ret = KErrNone;
   137 	TInt ret = KErrNone;
   147 	ASSERT(ContextIdIsValid(aPdpId));
   138 	ASSERT(ContextIdIsValid(aPdpId));
   148     if (!HaveFsmContext(aPdpId))
   139     if (!HaveFsmContext(aPdpId))
   152 	    TRAP(ret,
   143 	    TRAP(ret,
   153 	         CPdpFsm* p = CPdpFsm::NewL(aPdpId, this, iEtelDriverInput);
   144 	         CPdpFsm* p = CPdpFsm::NewL(aPdpId, this, iEtelDriverInput);
   154 	         iContexts[aPdpId] = p;       
   145 	         iContexts[aPdpId] = p;       
   155 	         );
   146 	         );
   156 	    }
   147 	    }
   157     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_NEWFSMCONTEXTL_2, "<<CPdpFsmFactory::NewFsmContext()");
       
   158    return ret;
   148    return ret;
   159 #else
   149 #else
   160 	TInt i=0;
   150 	TInt i=0;
   161     while (i < KMaxPdpContexts && iContexts[i] != NULL)
   151     while (i < KMaxPdpContexts && iContexts[i] != NULL)
   162     	{
   152     	{
   166         {
   156         {
   167         CPdpFsm* p = CPdpFsm::NewL(i, this, iEtelDriverInput, aPdpFsmEventHandler, aContextType);
   157         CPdpFsm* p = CPdpFsm::NewL(i, this, iEtelDriverInput, aPdpFsmEventHandler, aContextType);
   168         iContexts[i] = p;
   158         iContexts[i] = p;
   169         iEtelDriverInput->CreatePdpL(i, aContextType);
   159         iEtelDriverInput->CreatePdpL(i, aContextType);
   170         }
   160         }
   171     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_NEWFSMCONTEXTL_3, "<<CPdpFsmFactory::NewFsmContext()");
   161         return i;
   172     return i;
       
   173 #endif	
   162 #endif	
   174     }
   163     }
   175    
   164    
   176 TInt CPdpFsmFactory::DeleteFsmContext(TContextId aPdpId)
   165 TInt CPdpFsmFactory::DeleteFsmContext(TContextId aPdpId)
   177     {
   166     {
   178 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_DELETEFSMCONTEXT_1, ">>CPdpFsmFactory::DeleteFsmContext()");
   167 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::DeleteFsmContext()");
   179 	ASSERT(ContextIsValid(aPdpId));
   168 	ASSERT(ContextIsValid(aPdpId));
   180 
   169 
   181     delete iContexts[aPdpId];
   170     delete iContexts[aPdpId];
   182     iContexts[aPdpId] = NULL;
   171     iContexts[aPdpId] = NULL;
   183     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_DELETEFSMCONTEXT_2, "<<CPdpFsmFactory::DeleteFsmContext()");
   172     
   184 	return KErrNone;
   173 	return KErrNone;
   185     }
   174     }
   186     
   175